diff options
author | Loren Merritt <lorenm@u.washington.edu> | 2007-09-29 07:43:52 +0000 |
---|---|---|
committer | Loren Merritt <lorenm@u.washington.edu> | 2007-09-29 07:43:52 +0000 |
commit | 19b9c7cc6694bc8d0042dda67f606bd0bf13783b (patch) | |
tree | 13e3bd2c32d2fc6a784a6c7f090a25bdcc3d86b4 | |
parent | 14bd2a9f25fc0de4fb1a2d4afaef09162c51bb35 (diff) | |
download | ffmpeg-19b9c7cc6694bc8d0042dda67f606bd0bf13783b.tar.gz |
was computing one more autocorrelation coefficient that was actually used
Originally committed as revision 10613 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/flacenc.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 3b01a3ba1a..f96bc29c72 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -608,13 +608,14 @@ static void compute_autocorr(const int32_t *data, int len, int lag, double *autoc) { int i, j; - double tmp[len + lag]; + double tmp[len + lag + 1]; double *data1= tmp + lag; apply_welch_window(data, len, data1); for(j=0; j<lag; j++) data1[j-lag]= 0.0; + data1[len] = 0.0; for(j=0; j<lag; j+=2){ double sum0 = 1.0, sum1 = 1.0; @@ -628,8 +629,10 @@ static void compute_autocorr(const int32_t *data, int len, int lag, if(j==lag){ double sum = 1.0; - for(i=0; i<len; i++) - sum += data1[i] * data1[i-j]; + for(i=0; i<len; i+=2){ + sum += data1[i ] * data1[i-j ] + + data1[i+1] * data1[i-j+1]; + } autoc[j] = sum; } } @@ -757,7 +760,7 @@ static int lpc_calc_coefs(const int32_t *samples, int blocksize, int max_order, assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER); if(use_lpc == 1){ - compute_autocorr(samples, blocksize, max_order+1, autoc); + compute_autocorr(samples, blocksize, max_order, autoc); compute_lpc_coefs(autoc, max_order, lpc, ref); }else{ |