diff options
author | Michael Niedermayer | 2006-07-02 13:01:01 +0000 |
---|---|---|
committer | Michael Niedermayer | 2006-07-02 13:01:01 +0000 |
commit | b2e30cb32407a434086f613282c6b1802311b671 (patch) | |
tree | a8070c9a0b3692407deb58424cb207b23a3c82d1 /libavcodec/flacenc.c | |
parent | 412759560ccd2a558e0db48f25aa987f4e72d3a1 (diff) |
simplify compute_autocorr
Originally committed as revision 5575 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/flacenc.c')
-rw-r--r-- | libavcodec/flacenc.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index 1ec09bbf66..9259d0fc28 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -583,34 +583,22 @@ 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; - double *data1; - int lag_ptr, ptr; + int i, lag_ptr; + double tmp[len + lag]; + double *data1= tmp + lag; - data1 = av_malloc(len * sizeof(double)); apply_welch_window(data, len, data1); - for(i=0; i<lag; i++) autoc[i] = 1.0; - - ptr = 0; - while(ptr <= lag) { - lag_ptr = 0; - while(lag_ptr <= ptr) { - autoc[ptr-lag_ptr] += data1[ptr] * data1[lag_ptr]; - lag_ptr++; - } - ptr++; + for(i=0; i<lag; i++){ + autoc[i] = 1.0; + data1[i-lag]= 0.0; } - while(ptr < len) { - lag_ptr = ptr - lag; - while(lag_ptr <= ptr) { - autoc[ptr-lag_ptr] += data1[ptr] * data1[lag_ptr]; - lag_ptr++; + + 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]; } - ptr++; } - - av_freep(&data1); } /** |