diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-04-15 22:43:25 -0400 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2011-05-01 13:32:04 -0400 |
commit | ba6bce5140f09ed84d54f93fd5c816cbcf150c90 (patch) | |
tree | ace0ef1be941e91db8d302f3d2895e923715b5b2 | |
parent | 4142487d1cd8c555e13f156d1cc89f838099db10 (diff) | |
download | ffmpeg-ba6bce5140f09ed84d54f93fd5c816cbcf150c90.tar.gz |
ac3enc: merge compute_exp_strategy_ch() into compute_exp_strategy()
-rw-r--r-- | libavcodec/ac3enc.c | 75 |
1 files changed, 33 insertions, 42 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 47fd9b6a34..b61021f097 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -561,55 +561,46 @@ static void extract_exponents(AC3EncodeContext *s) /** - * Calculate exponent strategies for all blocks in a single channel. - */ -static void compute_exp_strategy_ch(AC3EncodeContext *s, uint8_t *exp_strategy, - uint8_t *exp) -{ - int blk, blk1; - int exp_diff; - - /* estimate if the exponent variation & decide if they should be - reused in the next frame */ - exp_strategy[0] = EXP_NEW; - exp += AC3_MAX_COEFS; - for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) { - exp_diff = s->dsp.sad[0](NULL, exp, exp - AC3_MAX_COEFS, 16, 16); - if (exp_diff > EXP_DIFF_THRESHOLD) - exp_strategy[blk] = EXP_NEW; - else - exp_strategy[blk] = EXP_REUSE; - exp += AC3_MAX_COEFS; - } - - /* now select the encoding strategy type : if exponents are often - recoded, we use a coarse encoding */ - blk = 0; - while (blk < AC3_MAX_BLOCKS) { - blk1 = blk + 1; - while (blk1 < AC3_MAX_BLOCKS && exp_strategy[blk1] == EXP_REUSE) - blk1++; - switch (blk1 - blk) { - case 1: exp_strategy[blk] = EXP_D45; break; - case 2: - case 3: exp_strategy[blk] = EXP_D25; break; - default: exp_strategy[blk] = EXP_D15; break; - } - blk = blk1; - } -} - - -/** * Calculate exponent strategies for all channels. * Array arrangement is reversed to simplify the per-channel calculation. */ static void compute_exp_strategy(AC3EncodeContext *s) { - int ch, blk; + int ch, blk, blk1; for (ch = 0; ch < s->fbw_channels; ch++) { - compute_exp_strategy_ch(s, s->exp_strategy[ch], s->blocks[0].exp[ch]); + uint8_t *exp_strategy = s->exp_strategy[ch]; + uint8_t *exp = s->blocks[0].exp[ch]; + int exp_diff; + + /* estimate if the exponent variation & decide if they should be + reused in the next frame */ + exp_strategy[0] = EXP_NEW; + exp += AC3_MAX_COEFS; + for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) { + exp_diff = s->dsp.sad[0](NULL, exp, exp - AC3_MAX_COEFS, 16, 16); + if (exp_diff > EXP_DIFF_THRESHOLD) + exp_strategy[blk] = EXP_NEW; + else + exp_strategy[blk] = EXP_REUSE; + exp += AC3_MAX_COEFS; + } + + /* now select the encoding strategy type : if exponents are often + recoded, we use a coarse encoding */ + blk = 0; + while (blk < AC3_MAX_BLOCKS) { + blk1 = blk + 1; + while (blk1 < AC3_MAX_BLOCKS && exp_strategy[blk1] == EXP_REUSE) + blk1++; + switch (blk1 - blk) { + case 1: exp_strategy[blk] = EXP_D45; break; + case 2: + case 3: exp_strategy[blk] = EXP_D25; break; + default: exp_strategy[blk] = EXP_D15; break; + } + blk = blk1; + } } if (s->lfe_on) { ch = s->lfe_channel; |