[FFmpeg-devel] [PATCH] normal PRNG using ziggurat method

Justin Ruggles justin.ruggles
Tue Sep 9 02:05:34 CEST 2008


This is a patch to add a PRNG which generates numbers with standard
normal distribution.  It uses the ziggurat method, which is quite fast
compared to other methods.

I was working on another implementation based on the original paper,
which had sample code in it that I was using as a starting point.  Then
I noticed the teeny tiny print at the bottom of the journal's download
page which states that the code is under GPL... :(  I found another
implementation which was based on the paper without using the
accompanying code and is under a BSD-style license.  I trimmed it down,
cleaned-up it up, and adapted it for FFmpeg.

I need this for spectral extension processing in the E-AC-3 decoder.
The spec requires that the generated noise which is blended with
translated coeffs have "zero-mean, unity variance".

For my needs in E-AC-3, I chose to make it output fixed-point values.
Due to the range needed for normal distribution, I made it signed
4.28-bit instead of 32-bit.  If floating-point output is preferred, I
could change it and just do the conversion in the decoder.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ziggurat_normal_rng.diff
Type: text/x-patch
Size: 8889 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080908/bfe7d5cb/attachment.bin>

More information about the ffmpeg-devel mailing list