From 1e3feb69fbe7820c4879e67191fc46c818e8d214 Mon Sep 17 00:00:00 2001 From: jbr Date: Sun, 27 Sep 2009 07:16:51 +0000 Subject: [PATCH] Rearrange loop structure for approx. 35-50% faster calc_transform_coeffs_cpl() depending on content. git-svn-id: file:///var/local/repositories/ffmpeg/trunk@20055 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b --- libavcodec/ac3dec.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index efeb284b4a..85c60241ed 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -416,17 +416,22 @@ static void calc_transform_coeffs_cpl(AC3DecodeContext *s) bin = s->start_freq[CPL_CH]; for (band = 0; band < s->num_cpl_bands; band++) { + int band_start = bin; int band_end = bin + s->cpl_band_sizes[band]; - for (; bin < band_end; bin++) { - for (ch = 1; ch <= s->fbw_channels; ch++) { - if (s->channel_in_cpl[ch]) { + for (ch = 1; ch <= s->fbw_channels; ch++) { + if (s->channel_in_cpl[ch]) { + int64_t cpl_coord = s->cpl_coords[ch][band]; + for (bin = band_start; bin < band_end; bin++) { s->fixed_coeffs[ch][bin] = ((int64_t)s->fixed_coeffs[CPL_CH][bin] * - (int64_t)s->cpl_coords[ch][band]) >> 23; - if (ch == 2 && s->phase_flags[band]) - s->fixed_coeffs[ch][bin] = -s->fixed_coeffs[ch][bin]; + cpl_coord) >> 23; + } + if (ch == 2 && s->phase_flags[band]) { + for (bin = band_start; bin < band_end; bin++) + s->fixed_coeffs[2][bin] = -s->fixed_coeffs[2][bin]; } } } + bin = band_end; } } -- 2.11.4.GIT