diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 9cce1a2ff0..2b2d039f6e 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 2b7a62a146..54951f9f70 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 327fbad833..0ab15a3e5e 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__); \