1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

swr: reorder the operations in the noise shaping code

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-01-10 00:27:04 +01:00
parent ead3a2a37e
commit 0b60fc94aa
2 changed files with 4 additions and 2 deletions

View File

@ -118,6 +118,7 @@ int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFo
if (s->dither.method > SWR_DITHER_NS) { if (s->dither.method > SWR_DITHER_NS) {
s->dither.noise.bps = 4; s->dither.noise.bps = 4;
s->dither.noise.fmt = AV_SAMPLE_FMT_FLTP; s->dither.noise.fmt = AV_SAMPLE_FMT_FLTP;
s->dither.noise_scale = 1;
} }
return 0; return 0;

View File

@ -34,12 +34,13 @@ void RENAME(swri_noise_shaping)(SwrContext *s, AudioData *srcs, AudioData *noise
DELEM *data = (DELEM*)srcs->ch[ch]; DELEM *data = (DELEM*)srcs->ch[ch];
pos = s->dither.ns_pos; pos = s->dither.ns_pos;
for (i=0; i<count; i++) { for (i=0; i<count; i++) {
double d1, d = data[i]; double d1, d = data[i]*S_1;
for(j=0; j<taps; j++) for(j=0; j<taps; j++)
d -= s->dither.ns_coeffs[j] * s->dither.ns_errors[ch][pos + j]; d -= s->dither.ns_coeffs[j] * s->dither.ns_errors[ch][pos + j];
pos = pos ? pos - 1 : pos - 1 + taps; pos = pos ? pos - 1 : pos - 1 + taps;
d1 = rint((d + noise[i]) * S_1)*S; d1 = rint(d + noise[i]);
s->dither.ns_errors[ch][pos + taps] = s->dither.ns_errors[ch][pos] = d1 - d; s->dither.ns_errors[ch][pos + taps] = s->dither.ns_errors[ch][pos] = d1 - d;
d1 *= S;
CLIP(d1); CLIP(d1);
data[i] = d1; data[i] = d1;
} }