Commit 28e968c4 authored by Loren Merritt's avatar Loren Merritt
Browse files

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
parent 7e1e297e
...@@ -607,21 +607,30 @@ static void apply_welch_window(const int32_t *data, int len, double *w_data) ...@@ -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, static void compute_autocorr(const int32_t *data, int len, int lag,
double *autoc) double *autoc)
{ {
int i, lag_ptr; int i, j;
double tmp[len + lag]; double tmp[len + lag];
double *data1= tmp + lag; double *data1= tmp + lag;
apply_welch_window(data, len, data1); apply_welch_window(data, len, data1);
for(i=0; i<lag; i++){ for(j=0; j<lag; j++)
autoc[i] = 1.0; data1[j-lag]= 0.0;
data1[i-lag]= 0.0;
}
for(i=0; i<len; i++){ for(j=0; j<lag; j+=2){
for(lag_ptr= i-lag; lag_ptr<=i; lag_ptr++){ double sum0 = 1.0, sum1 = 1.0;
autoc[i-lag_ptr] += data1[i] * data1[lag_ptr]; 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;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment