diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-06-21 13:39:02 -0400 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2011-06-22 12:18:10 -0400 |
commit | 0e4dbe2996cad6d5e0b1c1d702306f3bd8499df9 (patch) | |
tree | 5522eaa3a14a27a2c697ee62e83cc77538f8fe7b /libavcodec | |
parent | 2702a6f114f996ddfb334f1d8ddfae50e2c7eef7 (diff) | |
download | ffmpeg-0e4dbe2996cad6d5e0b1c1d702306f3bd8499df9.tar.gz |
ac3enc: avoid masking output in asym_quant() by using signed values for
quantized mantissas.
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/ac3enc.c | 22 | ||||
-rw-r--r-- | libavcodec/ac3enc.h | 2 |
2 files changed, 12 insertions, 12 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 3426bd252a..1db69414a5 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -46,7 +46,7 @@ #include "eac3enc.h" typedef struct AC3Mant { - uint16_t *qmant1_ptr, *qmant2_ptr, *qmant4_ptr; ///< mantissa pointers for bap=1,2,4 + int16_t *qmant1_ptr, *qmant2_ptr, *qmant4_ptr; ///< mantissa pointers for bap=1,2,4 int mant1_cnt, mant2_cnt, mant4_cnt; ///< mantissa counts for bap=1,2,4 } AC3Mant; @@ -1136,7 +1136,7 @@ static inline int asym_quant(int c, int e, int qbits) if (v >= m) v = m - 1; av_assert2(v >= -m); - return v & ((1 << qbits)-1); + return v; } @@ -1145,7 +1145,7 @@ static inline int asym_quant(int c, int e, int qbits) */ static void quantize_mantissas_blk_ch(AC3Mant *s, int32_t *fixed_coef, uint8_t *exp, uint8_t *bap, - uint16_t *qmant, int start_freq, + int16_t *qmant, int start_freq, int end_freq) { int i; @@ -1497,14 +1497,14 @@ static void output_audio_block(AC3EncodeContext *s, int blk) q = block->qmant[ch][i]; b = s->ref_bap[ch][blk][i]; switch (b) { - case 0: break; - case 1: if (q != 128) put_bits(&s->pb, 5, q); break; - case 2: if (q != 128) put_bits(&s->pb, 7, q); break; - case 3: put_bits(&s->pb, 3, q); break; - case 4: if (q != 128) put_bits(&s->pb, 7, q); break; - case 14: put_bits(&s->pb, 14, q); break; - case 15: put_bits(&s->pb, 16, q); break; - default: put_bits(&s->pb, b-1, q); break; + case 0: break; + case 1: if (q != 128) put_bits (&s->pb, 5, q); break; + case 2: if (q != 128) put_bits (&s->pb, 7, q); break; + case 3: put_sbits(&s->pb, 3, q); break; + case 4: if (q != 128) put_bits (&s->pb, 7, q); break; + case 14: put_sbits(&s->pb, 14, q); break; + case 15: put_sbits(&s->pb, 16, q); break; + default: put_sbits(&s->pb, b-1, q); break; } } if (ch == CPL_CH) diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index bf25298940..01abe94e0d 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -212,7 +212,7 @@ typedef struct AC3EncodeContext { int16_t *psd_buffer; int16_t *band_psd_buffer; int16_t *mask_buffer; - uint16_t *qmant_buffer; + int16_t *qmant_buffer; uint8_t *cpl_coord_exp_buffer; uint8_t *cpl_coord_mant_buffer; |