]> git.sesse.net Git - ffmpeg/commitdiff
swr: scale data down in noise shaping to avoid cliping
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 10 Jan 2013 00:28:24 +0000 (01:28 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 10 Jan 2013 00:44:15 +0000 (01:44 +0100)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libswresample/dither.c

index 66bf18431048f51504a579dfa0c4ccbf8151dca0..d7a5b6b55876ef45e9b215e4c8dc6368fffda716 100644 (file)
@@ -106,6 +106,7 @@ int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFo
             s->dither.ns_taps = f->len;
             for (j=0; j<f->len; j++)
                 s->dither.ns_coeffs[j] = f->coefs[j];
+            s->dither.ns_scale_1 *= 1 - exp(f->gain_cB * M_LN10 * 0.005) * 2 / (1<<(8*av_get_bytes_per_sample(out_fmt)));
             break;
         }
     }