[FFmpeg-cvslog] r10606 - trunk/libavcodec/flacenc.c
lorenm
subversion
Fri Sep 28 08:06:18 CEST 2007
Author: lorenm
Date: Fri Sep 28 08:06:18 2007
New Revision: 10606
Log:
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)
Modified:
trunk/libavcodec/flacenc.c
Modified: trunk/libavcodec/flacenc.c
==============================================================================
--- trunk/libavcodec/flacenc.c (original)
+++ trunk/libavcodec/flacenc.c Fri Sep 28 08:06:18 2007
@@ -607,21 +607,30 @@ static void apply_welch_window(const int
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;
}
}
More information about the ffmpeg-cvslog
mailing list