diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-03-15 15:12:17 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-03-15 15:12:17 +0100 |
commit | 27293b840ccae95ddb1f4d8af519e7962b0e373d (patch) | |
tree | 6bcbb7e7757f8ff66a9daa906107273325653b54 /libavcodec/ac3enc.c | |
parent | f7a5e7791dda0b26df198f301db5605555a7a9d3 (diff) | |
download | ffmpeg-27293b840ccae95ddb1f4d8af519e7962b0e373d.tar.gz |
Revert "ac3enc: shift coefficients to 24-bit following MDCT rather than using an exponent offset."
This reverts commit 7e0a284b9f1967d46603711e85e0be01e084eadf.
revert at authors request due to better impementation
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/ac3enc.c')
-rw-r--r-- | libavcodec/ac3enc.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 863f2002e0..baa9597977 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -78,7 +78,7 @@ typedef struct AC3Block { int16_t **band_psd; ///< psd per critical band int16_t **mask; ///< masking curve uint16_t **qmant; ///< quantized mantissas - int8_t coeff_shift[AC3_MAX_CHANNELS]; ///< fixed-point coefficient shift values + int8_t exp_shift[AC3_MAX_CHANNELS]; ///< exponent shift values uint8_t new_rematrixing_strategy; ///< send new rematrixing flags in this block uint8_t rematrixing_flags[4]; ///< rematrixing flags } AC3Block; @@ -269,7 +269,7 @@ static void apply_mdct(AC3EncodeContext *s) apply_window(&s->dsp, s->windowed_samples, input_samples, s->mdct.window, AC3_WINDOW_SIZE); - block->coeff_shift[ch] = normalize_samples(s); + block->exp_shift[ch] = normalize_samples(s); mdct512(&s->mdct, block->mdct_coef[ch], s->windowed_samples); } @@ -416,13 +416,14 @@ static void extract_exponents(AC3EncodeContext *s) AC3Block *block = &s->blocks[blk]; uint8_t *exp = block->exp[ch]; int32_t *coef = block->fixed_coef[ch]; + int exp_shift = block->exp_shift[ch]; for (i = 0; i < AC3_MAX_COEFS; i++) { int e; int v = abs(coef[i]); if (v == 0) e = 24; else { - e = 23 - av_log2(v); + e = 23 - av_log2(v) + exp_shift; if (e >= 24) { e = 24; coef[i] = 0; @@ -1138,7 +1139,7 @@ static inline int asym_quant(int c, int e, int qbits) * Quantize a set of mantissas for a single channel in a single block. */ static void quantize_mantissas_blk_ch(AC3EncodeContext *s, int32_t *fixed_coef, - uint8_t *exp, + int8_t exp_shift, uint8_t *exp, uint8_t *bap, uint16_t *qmant, int n) { int i; @@ -1146,7 +1147,7 @@ static void quantize_mantissas_blk_ch(AC3EncodeContext *s, int32_t *fixed_coef, for (i = 0; i < n; i++) { int v; int c = fixed_coef[i]; - int e = exp[i]; + int e = exp[i] - exp_shift; int b = bap[i]; switch (b) { case 0: @@ -1242,7 +1243,7 @@ static void quantize_mantissas(AC3EncodeContext *s) s->qmant1_ptr = s->qmant2_ptr = s->qmant4_ptr = NULL; for (ch = 0; ch < s->channels; ch++) { - quantize_mantissas_blk_ch(s, block->fixed_coef[ch], + quantize_mantissas_blk_ch(s, block->fixed_coef[ch], block->exp_shift[ch], block->exp[ch], block->bap[ch], block->qmant[ch], s->nb_coefs[ch]); } |