summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libavcodec/aaccoder.c8
-rw-r--r--libavcodec/aacenc.c2
-rw-r--r--libavcodec/aacenc.h2
-rw-r--r--libavcodec/aacenc_utils.h10
4 files changed, 9 insertions, 13 deletions
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 7e55494..15d467b 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -693,8 +693,12 @@ static void search_for_pns(AACEncContext *s, AVCodecContext *avctx, SingleChanne
float band_energy, scale, pns_senergy;
const int start_c = (w+w2)*128+sce->ics.swb_offset[g];
band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g];
- for (i = 0; i < sce->ics.swb_sizes[g]; i++)
- PNS[i] = s->random_state = lcg_random(s->random_state);
+ for (i = 0; i < sce->ics.swb_sizes[g]; i+=2) {
+ double rnd[2];
+ av_bmg_get(&s->lfg, rnd);
+ PNS[i+0] = (float)rnd[0];
+ PNS[i+1] = (float)rnd[1];
+ }
band_energy = s->fdsp->scalarproduct_float(PNS, PNS, sce->ics.swb_sizes[g]);
scale = noise_amp/sqrtf(band_energy);
s->fdsp->vector_fmul_scalar(PNS, PNS, scale, sce->ics.swb_sizes[g]);
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 3406f43..ec09063 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -904,7 +904,6 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
s->channels = avctx->channels;
s->chan_map = aac_chan_configs[s->channels-1];
- s->random_state = 0x1f2e3d4c;
s->lambda = avctx->global_quality > 0 ? avctx->global_quality : 120;
avctx->extradata_size = 5;
avctx->frame_size = 1024;
@@ -997,6 +996,7 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
goto fail;
s->psypp = ff_psy_preprocess_init(avctx);
ff_lpc_init(&s->lpc, 2*avctx->frame_size, TNS_MAX_ORDER, FF_LPC_TYPE_LEVINSON);
+ av_lfg_init(&s->lfg, 0x72adca55);
if (HAVE_MIPSDSP)
ff_aac_coder_init_mips(s);
diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h
index d8bed82..2b721d3 100644
--- a/libavcodec/aacenc.h
+++ b/libavcodec/aacenc.h
@@ -23,6 +23,7 @@
#define AVCODEC_AACENC_H
#include "libavutil/float_dsp.h"
+#include "libavutil/lfg.h"
#include "avcodec.h"
#include "put_bits.h"
@@ -100,6 +101,7 @@ typedef struct AACEncContext {
FFTContext mdct1024; ///< long (1024 samples) frame transform context
FFTContext mdct128; ///< short (128 samples) frame transform context
AVFloatDSPContext *fdsp;
+ AVLFG lfg; ///< PRNG needed for PNS
float *planar_samples[8]; ///< saved preprocessed input
int profile; ///< copied from avctx
diff --git a/libavcodec/aacenc_utils.h b/libavcodec/aacenc_utils.h
index 5b308f2..736e4a0 100644
--- a/libavcodec/aacenc_utils.h
+++ b/libavcodec/aacenc_utils.h
@@ -183,16 +183,6 @@ static av_always_inline float bval2bmax(float b)
}
/*
- * 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;
-}
-
-
-/*
* Compute a nextband map to be used with SF delta constraint utilities.
* The nextband array should contain 128 elements, and positions that don't
* map to valid, nonzero bands of the form w*16+g (with w being the initial
OpenPOWER on IntegriCloud