[FFmpeg-devel] [PATCH] ac3dec: fix non-optimal dithering of zero bit mantissas

Nicolas George nicolas.george at normalesup.org
Sat Jan 5 12:10:11 CET 2013

Le sextidi 16 nivôse, an CCXXI, Reimar Döffinger a écrit :
> Not sure about lfg (though IMHO it should be replaced by lcg anyway to
> not needlessly waste CPU time) but usually the lower bits contain more
> "randomness". Thus you should generally be using some kind of modulo
> operation instead of a division.

It does not happen frequently, but in that particular case you are
absolutely wrong.

For that kind of LFGs:

 * Please also consider a simple LCG like state= state*1664525+1013904223,

(libavutil/lfg.h) the period should be 2^32 (assuming 1664525 and
1013904223 are correctly chosen) is odd, and the high order bits have that
period, but the low order bits have a much smaller period.

The math is absolutely trivial: arithmetic modulo k is a reduction of
arithmetic modulo n if k is a divisor of n; therefore, the m lower bits of a
32-bits LFG is just a m-bits LFG, with at most 2^m period.

For LCGs, I do not know. It is probably easily available on the web.


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130105/a8fcded6/attachment.asc>

More information about the ffmpeg-devel mailing list