diff options
author | Loren Merritt <lorenm@u.washington.edu> | 2007-09-28 06:06:18 +0000 |
---|---|---|
committer | Loren Merritt <lorenm@u.washington.edu> | 2007-09-28 06:06:18 +0000 |
commit | 28e968c4a4f2298de5dab736ae0934cc168aa2ca (patch) | |
tree | 4019ec43837fbf6edc32c6cbd7840f2c1f5a17dc /libavcodec/flacenc.c | |
parent | 7e1e297ee3e5f2bcb5cb67928534c4907e61eccf (diff) | |
download | ffmpeg-28e968c4a4f2298de5dab736ae0934cc168aa2ca.tar.gz |
2.5x faster compute_autocorr()
overall flac encoding: 15-50% faster on core2, 8-30% on k8, 2-20% on p4 (depending on compression_level)
Originally committed as revision 10606 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/flacenc.c')
-rw-r--r-- | libavcodec/flacenc.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index f5766e85a4..b2b3c84e69 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -607,21 +607,30 @@ static void apply_welch_window(const int32_t *data, int len, double *w_data) static void compute_autocorr(const int32_t *data, int len, int lag, double *autoc) { - int i, lag_ptr; + int i, j; double tmp[len + lag]; double *data1= tmp + lag; apply_welch_window(data, len, data1); - for(i=0; i<lag; i++){ - autoc[i] = 1.0; - data1[i-lag]= 0.0; - } + for(j=0; j<lag; j++) + data1[j-lag]= 0.0; - for(i=0; i<len; i++){ - for(lag_ptr= i-lag; lag_ptr<=i; lag_ptr++){ - autoc[i-lag_ptr] += data1[i] * data1[lag_ptr]; + for(j=0; j<lag; j+=2){ + double sum0 = 1.0, sum1 = 1.0; + for(i=0; i<len; i++){ + sum0 += data1[i] * data1[i-j]; + sum1 += data1[i] * data1[i-j-1]; } + autoc[j ] = sum0; + autoc[j+1] = sum1; + } + + if(j==lag){ + double sum = 1.0; + for(i=0; i<len; i++) + sum += data1[i] * data1[i-j]; + autoc[j] = sum; } } |