[FFmpeg-soc] [soc]: r3046 - in aac: aac.c aac.h

superdump subversion at mplayerhq.hu
Wed Aug 6 12:00:44 CEST 2008


Author: superdump
Date: Wed Aug  6 12:00:44 2008
New Revision: 3046

Log:
Use a simple LCG as recommended in libavutil/lfg.* rather than Mersenne Twister
as such noise is good enough (sounds the same to my ears on a 1 second sample)
and calculation is faster


Modified:
   aac/aac.c
   aac/aac.h

Modified: aac/aac.c
==============================================================================
--- aac/aac.c	(original)
+++ aac/aac.c	Wed Aug  6 12:00:44 2008
@@ -79,7 +79,6 @@
 #include "avcodec.h"
 #include "bitstream.h"
 #include "dsputil.h"
-#include "libavutil/random.h"
 
 #include "aac.h"
 #include "aactab.h"
@@ -466,6 +465,11 @@ static int audio_specific_config(AACCont
     return 0;
 }
 
+static inline int32_t lcg_random(int32_t *state) {
+    *state = *state * 1664525 + 1013904223;
+    return *state;
+}
+
 static av_cold int aac_decode_init(AVCodecContext * avccontext) {
     AACContext * ac = avccontext->priv_data;
     int i;
@@ -494,7 +498,7 @@ static av_cold int aac_decode_init(AVCod
 
     dsputil_init(&ac->dsp, avccontext);
 
-    av_init_random(0x1f2e3d4c, &ac->random_state);
+    ac->random_state = 0x1f2e3d4c;
 
     // -1024 - Compensate wrong IMDCT method.
     // 32768 - Required to scale values to the correct range for the bias method
@@ -990,7 +994,7 @@ static void dequant(AACContext * ac, flo
                 const float scale = sf[g][i] / ((offsets[i+1] - offsets[i]) * PNS_MEAN_ENERGY);
                 for (group = 0; group < ics->group_len[g]; group++) {
                     for (k = offsets[i]; k < offsets[i+1]; k++)
-                        coef[group*128+k] = (int32_t)av_random(&ac->random_state) * scale;
+                        coef[group*128+k] = lcg_random(&ac->random_state) * scale;
                 }
             } else if (band_type[g][i] != INTENSITY_BT && band_type[g][i] != INTENSITY_BT2) {
                 for (group = 0; group < ics->group_len[g]; group++) {

Modified: aac/aac.h
==============================================================================
--- aac/aac.h	(original)
+++ aac/aac.h	Wed Aug  6 12:00:44 2008
@@ -47,8 +47,6 @@
 
 #include "avcodec.h"
 #include "dsputil.h"
-#include "libavutil/random.h"
-
 #include "mpeg4audio.h"
 
 #include <stdint.h>
@@ -360,7 +358,7 @@ typedef struct {
 #ifdef AAC_SSR
     ssr_context ssrctx;
 #endif /* AAC_SSR */
-    AVRandomState random_state;
+    int32_t random_state;
     /** @} */
 
     /**



More information about the FFmpeg-soc mailing list