~ubuntu-branches/debian/squeeze/gstreamer0.10-ffmpeg/squeeze

« back to all changes in this revision

Viewing changes to gst-libs/ext/ffmpeg/libavutil/lfg.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2010-02-19 18:14:59 UTC
  • mfrom: (4.1.5 experimental)
  • Revision ID: james.westby@ubuntu.com-20100219181459-mect96st3px2jfsi
Tags: 0.10.9.2-1
* New upstream pre-release:
  + debian/patches/03_restricted-caps.patch,
    debian/patches/04_ignore-vdpau.patch:
    - Dropped, merged upstream.
* debian/patches/03_too-new-codec-ids.patch:
  + Disable some ffmpeg codec IDs because Debian's
    ffmpeg is once again too old...

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    c->index=0;
40
40
}
41
41
 
 
42
void av_bmg_get(AVLFG *lfg, double out[2])
 
43
{
 
44
    double x1, x2, w;
 
45
 
 
46
    do {
 
47
        x1 = 2.0/UINT_MAX*av_lfg_get(lfg) - 1.0;
 
48
        x2 = 2.0/UINT_MAX*av_lfg_get(lfg) - 1.0;
 
49
        w = x1*x1 + x2*x2;
 
50
    } while (w >= 1.0);
 
51
 
 
52
    w = sqrt((-2.0 * log(w)) / w);
 
53
    out[0] = x1 * w;
 
54
    out[1] = x2 * w;
 
55
}
 
56
 
42
57
#ifdef TEST
43
58
#include "log.h"
44
59
#include "common.h"
56
71
//            av_log(NULL,AV_LOG_ERROR, "%X\n", av_lfg_get(&state));
57
72
            x+=av_lfg_get(&state);
58
73
        }
59
 
        STOP_TIMER("624 calls of av_random");
 
74
        STOP_TIMER("624 calls of av_lfg_get");
60
75
    }
61
76
    av_log(NULL, AV_LOG_ERROR, "final value:%X\n", x);
 
77
 
 
78
    /* BMG usage example */
 
79
    {
 
80
        double mean   = 1000;
 
81
        double stddev = 53;
 
82
 
 
83
        av_lfg_init(&state, 42);
 
84
 
 
85
        for (i = 0; i < 1000; i += 2) {
 
86
            double bmg_out[2];
 
87
            av_bmg_get(&state, bmg_out);
 
88
            av_log(NULL, AV_LOG_INFO,
 
89
                   "%f\n%f\n",
 
90
                   bmg_out[0] * stddev + mean,
 
91
                   bmg_out[1] * stddev + mean);
 
92
        }
 
93
    }
 
94
 
62
95
    return 0;
63
96
}
64
97
#endif