diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-02-10 20:20:36 +0300 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-02-11 04:54:09 +0300 |
commit | a30ac54a19d27920ec262ebb104e1f48092a3715 (patch) | |
tree | b10fb52d87c891e190faf757d665b7c254dace2c /libavcodec/ac3enc.c | |
parent | 952f231588c18cd1a95e001c517f2d529017363f (diff) |
Add x86-optimized versions of exponent_min().
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit dda3f0ef48aa5c3b03566b60b6bf63211e1fe579)
Diffstat (limited to 'libavcodec/ac3enc.c')
-rw-r--r-- | libavcodec/ac3enc.c | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index e41a0aec65..851fdc9caf 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -33,6 +33,7 @@ #include "avcodec.h" #include "put_bits.h" #include "dsputil.h" +#include "ac3dsp.h" #include "ac3.h" #include "audioconvert.h" @@ -86,6 +87,7 @@ typedef struct AC3Block { typedef struct AC3EncodeContext { PutBitContext pb; ///< bitstream writer context DSPContext dsp; + AC3DSPContext ac3dsp; ///< AC-3 optimized functions AC3MDCTContext mdct; ///< MDCT context AC3Block blocks[AC3_MAX_BLOCKS]; ///< per-block info @@ -458,7 +460,6 @@ static void compute_exp_strategy_ch(AC3EncodeContext *s, uint8_t *exp_strategy, exp_strategy[blk] = EXP_REUSE; exp += AC3_MAX_COEFS; } - emms_c(); /* now select the encoding strategy type : if exponents are often recoded, we use a coarse encoding */ @@ -499,31 +500,6 @@ static void compute_exp_strategy(AC3EncodeContext *s) /** - * Set each encoded exponent in a block to the minimum of itself and the - * exponents in the same frequency bin of up to 5 following blocks. - */ -static void exponent_min(uint8_t *exp, int num_reuse_blocks, int nb_coefs) -{ - 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; - } -} - - -/** * Update the exponents so that they are the ones the decoder will decode. */ static void encode_exponents_blk_ch(uint8_t *exp, int nb_exps, int exp_strategy) @@ -616,7 +592,7 @@ static void encode_exponents(AC3EncodeContext *s) 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); + s->ac3dsp.ac3_exponent_min(exp, num_reuse_blocks, nb_coefs); encode_exponents_blk_ch(exp, nb_coefs, exp_strategy[blk]); @@ -704,6 +680,8 @@ static void process_exponents(AC3EncodeContext *s) encode_exponents(s); group_exponents(s); + + emms_c(); } @@ -1856,6 +1834,7 @@ static av_cold int ac3_encode_init(AVCodecContext *avctx) avctx->coded_frame= avcodec_alloc_frame(); dsputil_init(&s->dsp, avctx); + ff_ac3dsp_init(&s->ac3dsp); return 0; init_fail: |