[FFmpeg-devel] [RFC] ac3dec: need to use LFG?

Reimar Döffinger Reimar.Doeffinger
Wed Jan 13 00:26:58 CET 2010


Hello,
not sure if this was already discussed once, but...
for me AC3 decoder is another 1.5% faster by just using a LCG instead of LFG.
Of course the checksum of the decoded data will change.
Patch:
Index: libavcodec/ac3dec.c
===================================================================
--- libavcodec/ac3dec.c	(revision 21175)
+++ libavcodec/ac3dec.c	(working copy)
@@ -193,7 +193,7 @@
     ff_mdct_init(&s->imdct_512, 9, 1, 1.0);
     ff_kbd_window_init(s->window, 5.0, 256);
     dsputil_init(&s->dsp, avctx);
-    av_lfg_init(&s->dith_state, 0);
+    s->dith_state = 0x79381c11;
 
     /* set bias values for float to int16 conversion */
     if(s->dsp.float_to_int16_interleave == ff_float_to_int16_interleave_c) {
@@ -466,9 +466,10 @@
         int mantissa;
         switch(bap){
             case 0:
-                if (dither)
-                    mantissa = (av_lfg_get(&s->dith_state) & 0x7FFFFF) - 0x400000;
-                else
+                if (dither) {
+                    mantissa = (s->dith_state >> 9) - 0x400000;
+                    s->dith_state = s->dith_state * 1664525 + 1013904223;
+                } else
                     mantissa = 0;
                 break;
             case 1:
Index: libavcodec/ac3dec.h
===================================================================
--- libavcodec/ac3dec.h	(revision 21174)
+++ libavcodec/ac3dec.h	(working copy)
@@ -141,7 +141,7 @@
 
 ///@defgroup dithering zero-mantissa dithering
     int dither_flag[AC3_MAX_CHANNELS];      ///< dither flags                           (dithflg)
-    AVLFG dith_state;                       ///< for dither generation
+    uint32_t dith_state;                    ///< for dither generation
 ///@}
 
 ///@defgroup imdct IMDCT




More information about the ffmpeg-devel mailing list