# HG changeset patch # User reimar # Date 1195411971 0 # Node ID c18499a044ce8e375d7f8c2f360a5a364b348d2d # Parent bbdd0202c238c8c1eb9dcb2a308b6c5ab129155f Change to a 64 bit accumulation variable instead of shifting. Changing the way the loop is done is necessary to reduce register pressure. About 20% speedup even on 32 bit x86. diff -r bbdd0202c238 -r c18499a044ce libaf/af_scaletempo.c --- a/libaf/af_scaletempo.c Sun Nov 18 18:33:45 2007 +0000 +++ b/libaf/af_scaletempo.c Sun Nov 18 18:52:51 2007 +0000 @@ -69,7 +69,6 @@ void* buf_pre_corr; void* table_window; int (*best_overlap_offset)(struct af_scaletempo_s* s); - short shift_corr; // command line float scale_nominal; float ms_stride; @@ -153,7 +152,7 @@ { int32_t *pw, *ppc; int16_t *po, *search_start; - int32_t best_corr = INT_MIN; + int64_t best_corr = INT64_MIN; int best_off = 0; int off; long i; @@ -168,12 +167,14 @@ search_start = (int16_t*)s->buf_queue + s->num_channels; for (off=0; offframes_search; off++) { - int32_t corr = 0; + int64_t corr = 0; int16_t* ps = search_start; ppc = s->buf_pre_corr; + ppc += s->samples_overlap - s->num_channels; + ps += s->samples_overlap - s->num_channels; i = -(s->samples_overlap - s->num_channels); do { - corr += ( *ppc++ * *ps++ ) >> s->shift_corr; + corr += ppc[i] * ps[i]; } while (++i < 0); if (corr > best_corr) { best_corr = corr; @@ -380,7 +381,6 @@ *pw++ = v; } } - s->shift_corr = av_log2( 2*(s->samples_overlap - nch) - 1 ); s->best_overlap_offset = best_overlap_offset_s16; } else { float* pw;