1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

- fix insufficient code length for exp_vlc

- move vlc tweaking parameters to one place

Originally committed as revision 4987 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Jindřich Makovička 2006-02-11 19:39:05 +00:00
parent dc2a1ce5c0
commit 63a5b0b1ae

View File

@ -57,6 +57,13 @@
#define LSP_POW_BITS 7 #define LSP_POW_BITS 7
#define VLCBITS 9 #define VLCBITS 9
#define VLCMAX ((22+VLCBITS-1)/VLCBITS)
#define EXPVLCBITS 8
#define EXPMAX ((19+EXPVLCBITS-1)/EXPVLCBITS)
#define HGAINVLCBITS 9
#define HGAINMAX ((13+HGAINVLCBITS-1)/HGAINVLCBITS)
typedef struct WMADecodeContext { typedef struct WMADecodeContext {
GetBitContext gb; GetBitContext gb;
@ -185,7 +192,7 @@ static void init_coef_vlc(VLC *vlc,
const uint16_t *p; const uint16_t *p;
int i, l, j, level; int i, l, j, level;
init_vlc(vlc, 9, n, table_bits, 1, 1, table_codes, 4, 4, 0); init_vlc(vlc, VLCBITS, n, table_bits, 1, 1, table_codes, 4, 4, 0);
run_table = av_malloc(n * sizeof(uint16_t)); run_table = av_malloc(n * sizeof(uint16_t));
level_table = av_malloc(n * sizeof(uint16_t)); level_table = av_malloc(n * sizeof(uint16_t));
@ -494,13 +501,13 @@ static int wma_decode_init(AVCodecContext * avctx)
} }
} }
#endif #endif
init_vlc(&s->hgain_vlc, 9, sizeof(hgain_huffbits), init_vlc(&s->hgain_vlc, HGAINVLCBITS, sizeof(hgain_huffbits),
hgain_huffbits, 1, 1, hgain_huffbits, 1, 1,
hgain_huffcodes, 2, 2, 0); hgain_huffcodes, 2, 2, 0);
} }
if (s->use_exp_vlc) { if (s->use_exp_vlc) {
init_vlc(&s->exp_vlc, 9, sizeof(scale_huffbits), init_vlc(&s->exp_vlc, EXPVLCBITS, sizeof(scale_huffbits),
scale_huffbits, 1, 1, scale_huffbits, 1, 1,
scale_huffcodes, 4, 4, 0); scale_huffcodes, 4, 4, 0);
} else { } else {
@ -681,7 +688,7 @@ static int decode_exp_vlc(WMADecodeContext *s, int ch)
} }
last_exp = 36; last_exp = 36;
while (q < q_end) { while (q < q_end) {
code = get_vlc2(&s->gb, s->exp_vlc.table, VLCBITS, 2); code = get_vlc2(&s->gb, s->exp_vlc.table, EXPVLCBITS, EXPMAX);
if (code < 0) if (code < 0)
return -1; return -1;
/* NOTE: this offset is the same as MPEG4 AAC ! */ /* NOTE: this offset is the same as MPEG4 AAC ! */
@ -822,7 +829,7 @@ static int wma_decode_block(WMADecodeContext *s)
if (val == (int)0x80000000) { if (val == (int)0x80000000) {
val = get_bits(&s->gb, 7) - 19; val = get_bits(&s->gb, 7) - 19;
} else { } else {
code = get_vlc2(&s->gb, s->hgain_vlc.table, VLCBITS, 2); code = get_vlc2(&s->gb, s->hgain_vlc.table, HGAINVLCBITS, HGAINMAX);
if (code < 0) if (code < 0)
return -1; return -1;
val += code - 18; val += code - 18;
@ -879,7 +886,7 @@ static int wma_decode_block(WMADecodeContext *s)
eptr = ptr + nb_coefs[ch]; eptr = ptr + nb_coefs[ch];
memset(ptr, 0, s->block_len * sizeof(int16_t)); memset(ptr, 0, s->block_len * sizeof(int16_t));
for(;;) { for(;;) {
code = get_vlc2(&s->gb, coef_vlc->table, VLCBITS, 3); code = get_vlc2(&s->gb, coef_vlc->table, VLCBITS, VLCMAX);
if (code < 0) if (code < 0)
return -1; return -1;
if (code == 1) { if (code == 1) {