mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-17 20:17:55 +02:00
aacenc: switch to using the RNG from libavutil
PSNR doesn't change as expected. The AAC spec doesn't really say anything about how exactly to generate noise. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
This commit is contained in:
parent
932cbc846f
commit
ade31b9424
@ -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]);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -182,16 +182,6 @@ static av_always_inline float bval2bmax(float b)
|
||||
return 0.001f + 0.0035f * (b*b*b) / (15.5f*15.5f*15.5f);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user