summaryrefslogtreecommitdiff
path: root/libavcodec/ac3enc_template.c
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2011-04-03 19:38:41 +0100
committerMans Rullgard <mans@mansr.com>2011-07-06 00:29:59 +0100
commitf507a9fe002c6a444cbd38a1326ee4f9df8c10a1 (patch)
treef6b8cfd0161b7af699efb3a9ebb76f8d9d500efe /libavcodec/ac3enc_template.c
parentfce1e43410bdc032c4cf2b1c66166a9ed99cc8f1 (diff)
downloadffmpeg-f507a9fe002c6a444cbd38a1326ee4f9df8c10a1.tar.gz
ac3enc: move inner loop of compute_rematrixing_strategy to ac3dsp
Diffstat (limited to 'libavcodec/ac3enc_template.c')
-rw-r--r--libavcodec/ac3enc_template.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index c7243c7644..1ee1b617db 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -43,6 +43,9 @@ static int normalize_samples(AC3EncodeContext *s);
static void clip_coefficients(DSPContext *dsp, CoefType *coef, unsigned int len);
+static void sum_square_butterfly(AC3EncodeContext *s, CoefSumType sum[4],
+ const CoefType *coef0, const CoefType *coef1,
+ int len);
int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s)
{
@@ -356,7 +359,7 @@ static void apply_channel_coupling(AC3EncodeContext *s)
static void compute_rematrixing_strategy(AC3EncodeContext *s)
{
int nb_coefs;
- int blk, bnd, i;
+ int blk, bnd;
AC3Block *block, *av_uninit(block0);
if (s->channel_mode != AC3_CHMODE_STEREO)
@@ -384,17 +387,9 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s)
/* calculate calculate sum of squared coeffs for one band in one block */
int start = ff_ac3_rematrix_band_tab[bnd];
int end = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]);
- CoefSumType sum[4] = {0,};
- for (i = start; i < end; i++) {
- CoefType lt = block->mdct_coef[1][i];
- CoefType rt = block->mdct_coef[2][i];
- CoefType md = lt + rt;
- CoefType sd = lt - rt;
- MAC_COEF(sum[0], lt, lt);
- MAC_COEF(sum[1], rt, rt);
- MAC_COEF(sum[2], md, md);
- MAC_COEF(sum[3], sd, sd);
- }
+ CoefSumType sum[4];
+ sum_square_butterfly(s, sum, block->mdct_coef[1] + start,
+ block->mdct_coef[2] + start, end - start);
/* compare sums to determine if rematrixing will be used for this band */
if (FFMIN(sum[2], sum[3]) < FFMIN(sum[0], sum[1]))