[FFmpeg-cvslog] aacenc: copy PRNG from the decoder

Rostislav Pehlivanov git at videolan.org
Sun Sep 6 16:31:40 CEST 2015


ffmpeg | branch: master | Rostislav Pehlivanov <atomnuker at gmail.com> | Sun Sep  6 15:06:34 2015 +0100| [92aa3e7fb21a4b0764ac8a0348a5bf84badee216] | committer: Rostislav Pehlivanov

aacenc: copy PRNG from the decoder

Needed for the following PNS commits.

Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=92aa3e7fb21a4b0764ac8a0348a5bf84badee216
---

 libavcodec/aacenc.c       |    1 +
 libavcodec/aacenc.h       |    1 +
 libavcodec/aacenc_utils.h |    9 +++++++++
 3 files changed, 11 insertions(+)

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 9cce1a2..2b2d039 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -861,6 +861,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
         ff_aac_coder_init_mips(s);
 
     s->lambda = avctx->global_quality > 0 ? avctx->global_quality : 120;
+    s->random_state = 0x1f2e3d4c;
 
     ff_aac_tableinit();
 
diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h
index 2b7a62a..54951f9 100644
--- a/libavcodec/aacenc.h
+++ b/libavcodec/aacenc.h
@@ -98,6 +98,7 @@ typedef struct AACEncContext {
     AACCoefficientsEncoder *coder;
     int cur_channel;
     int last_frame;
+    int random_state;
     float lambda;
     AudioFrameQueue afq;
     DECLARE_ALIGNED(16, int,   qcoefs)[96];      ///< quantized coefficients
diff --git a/libavcodec/aacenc_utils.h b/libavcodec/aacenc_utils.h
index 327fbad..0ab15a3 100644
--- a/libavcodec/aacenc_utils.h
+++ b/libavcodec/aacenc_utils.h
@@ -128,6 +128,15 @@ static inline int quant_array_idx(const float val, const float *arr, const int n
     return index;
 }
 
+/*
+ * linear congruential pseudorandom number generator, copied from the decoder
+ */
+static inline int lcg_random(unsigned previous_val)
+{
+    union { unsigned u; int s; } v = { previous_val * 1664525u + 1013904223 };
+    return v.s;
+}
+
 #define ERROR_IF(cond, ...) \
     if (cond) { \
         av_log(avctx, AV_LOG_ERROR, __VA_ARGS__); \



More information about the ffmpeg-cvslog mailing list