aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/ac3enc.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2010-12-16 22:47:07 +0000
committerJustin Ruggles <justin.ruggles@gmail.com>2010-12-16 22:47:07 +0000
commit795063db3b9f62e9ebf47d0ee99932bf4aea6800 (patch)
treefd72ac52062fbb21ebd04b66dff64f414dc2d7e0 /libavcodec/ac3enc.c
parent126a29b871e9c4a52351655801f343d0e022eb50 (diff)
downloadffmpeg-795063db3b9f62e9ebf47d0ee99932bf4aea6800.tar.gz
Copy bap from previous block when exponent strategy is EXP_REUSE.
We can do this because exponents are the only bit allocation parameters which change from block-to-block currently. Approx. 57% faster in function bit_alloc(). Approx. 25% faster overall encoding. Originally committed as revision 26040 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ac3enc.c')
-rw-r--r--libavcodec/ac3enc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index cc5232b8a1..2bfb44ecce 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1028,10 +1028,18 @@ static int bit_alloc(AC3EncodeContext *s,
mant_cnt[1] = mant_cnt[2] = 2;
mant_cnt[4] = 1;
for (ch = 0; ch < s->channels; ch++) {
+ /* Currently the only bit allocation parameters which vary across
+ blocks within a frame are the exponent values. We can take
+ advantage of that by reusing the bit allocation pointers
+ whenever we reuse exponents. */
+ if (block->exp_strategy[ch] == EXP_REUSE) {
+ memcpy(block->bap[ch], s->blocks[blk-1].bap[ch], AC3_MAX_COEFS);
+ } else {
ff_ac3_bit_alloc_calc_bap(block->mask[ch], block->psd[ch], 0,
s->nb_coefs[ch], snr_offset,
s->bit_alloc.floor, ff_ac3_bap_tab,
block->bap[ch]);
+ }
mantissa_bits += compute_mantissa_size(mant_cnt, block->bap[ch], s->nb_coefs[ch]);
}
mantissa_bits += compute_mantissa_size_final(mant_cnt);