diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2006-07-13 11:41:52 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2006-07-13 11:41:52 +0000 |
commit | 1484a46753eb5cacaebbc78a53a1aee067094073 (patch) | |
tree | 2a2102872baa5e00c57879ae9325a52b9da7d8ab | |
parent | ebd7617ba7a24cd400511091b8c3ede762595ae4 (diff) | |
download | ffmpeg-1484a46753eb5cacaebbc78a53a1aee067094073.tar.gz |
dither lpc cpeffs
Originally committed as revision 5727 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/flacenc.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 6d4e1d0dca..e21326de5e 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -661,7 +661,7 @@ static void quantize_lpc_coefs(double *lpc_in, int order, int precision, int32_t *lpc_out, int *shift) { int i; - double cmax; + double cmax, error; int32_t qmax; int sh; @@ -697,8 +697,11 @@ static void quantize_lpc_coefs(double *lpc_in, int order, int precision, } /* output quantized coefficients and level shift */ + error=0; for(i=0; i<order; i++) { - lpc_out[i] = (int32_t)(lpc_in[i] * (1 << sh)); + error += lpc_in[i] * (1 << sh); + lpc_out[i] = clip(lrintf(error), -qmax, qmax); + error -= lpc_out[i]; } *shift = sh; } |