diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-01-15 01:59:21 +0000 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2011-01-15 01:59:21 +0000 |
commit | 964f2cf2a0e6c06dd4491d729a5437ab74336967 (patch) | |
tree | c4efc61a4c0dae1315ba44d055a899ef13ecf23d /libavcodec/ac3enc.c | |
parent | 7d87d56ff810b921537138f91048a932065260a1 (diff) | |
download | ffmpeg-964f2cf2a0e6c06dd4491d729a5437ab74336967.tar.gz |
Process all EXP_REUSE blocks at once in exponent_min().
43% faster in function encode_exponents().
Originally committed as revision 26358 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ac3enc.c')
-rw-r--r-- | libavcodec/ac3enc.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 61986be8f3..9b8efaa429 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -500,15 +500,25 @@ static void compute_exp_strategy(AC3EncodeContext *s) /** * Set each encoded exponent in a block to the minimum of itself and the - * exponent in the same frequency bin of a following block. - * exp[i] = min(exp[i], exp1[i] + * exponents in the same frequency bin of up to 5 following blocks. */ -static void exponent_min(uint8_t *exp, uint8_t *exp1, int n) +static void exponent_min(uint8_t *exp, int num_reuse_blocks, int nb_coefs) { - int i; - for (i = 0; i < n; i++) { - if (exp1[i] < exp[i]) - exp[i] = exp1[i]; + int blk, i; + + if (!num_reuse_blocks) + return; + + for (i = 0; i < nb_coefs; i++) { + uint8_t min_exp = *exp; + uint8_t *exp1 = exp + AC3_MAX_COEFS; + for (blk = 0; blk < num_reuse_blocks; blk++) { + uint8_t next_exp = *exp1; + if (next_exp < min_exp) + min_exp = next_exp; + exp1 += AC3_MAX_COEFS; + } + *exp++ = min_exp; } } @@ -589,7 +599,7 @@ static void encode_exponents(AC3EncodeContext *s) { int blk, blk1, ch; uint8_t *exp, *exp1, *exp_strategy; - int nb_coefs; + int nb_coefs, num_reuse_blocks; for (ch = 0; ch < s->channels; ch++) { exp = s->blocks[0].exp[ch]; @@ -599,13 +609,16 @@ static void encode_exponents(AC3EncodeContext *s) blk = 0; while (blk < AC3_MAX_BLOCKS) { blk1 = blk + 1; - exp1 = exp + AC3_MAX_COEFS; - /* for the EXP_REUSE case we select the min of the exponents */ + + /* count the number of EXP_REUSE blocks after the current block */ while (blk1 < AC3_MAX_BLOCKS && exp_strategy[blk1] == EXP_REUSE) { - exponent_min(exp, exp1, nb_coefs); blk1++; - exp1 += AC3_MAX_COEFS; } + num_reuse_blocks = blk1 - blk - 1; + + /* for the EXP_REUSE case we select the min of the exponents */ + exponent_min(exp, num_reuse_blocks, nb_coefs); + encode_exponents_blk_ch(exp, nb_coefs, exp_strategy[blk]); /* copy encoded exponents for reuse case */ |