diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-11-04 05:38:31 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-11-24 11:35:03 +0100 |
commit | 659c61ba7caaa98a3ae6c3a3347b6ff557a4a084 (patch) | |
tree | 09dca22add2cb2350c31b3619b81f95572a43bba | |
parent | 4a9ffce91cef3c56d34db7f5966c1b48241a2536 (diff) | |
download | ffmpeg-659c61ba7caaa98a3ae6c3a3347b6ff557a4a084.tar.gz |
avcodec/atrac9dec: Don't use unnecessarily large VLC tables
Using more bits for a VLC than the longest code has has no advantage.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-rw-r--r-- | libavcodec/atrac9dec.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libavcodec/atrac9dec.c b/libavcodec/atrac9dec.c index ecf95f1777..0477b304d2 100644 --- a/libavcodec/atrac9dec.c +++ b/libavcodec/atrac9dec.c @@ -26,6 +26,8 @@ #include "libavutil/lfg.h" #include "libavutil/float_dsp.h" +#define ATRAC9_SF_VLC_BITS 8 + typedef struct ATRAC9ChannelData { int band_ext; int q_unit_cnt; @@ -272,7 +274,8 @@ static inline int read_scalefactors(ATRAC9Context *s, ATRAC9BlockData *b, c->scalefactors[0] = get_bits(gb, len); for (int i = 1; i < b->band_ext_q_unit; i++) { - int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, 9, 1); + int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, + ATRAC9_SF_VLC_BITS, 1); c->scalefactors[i] = val & ((1 << len) - 1); } @@ -302,7 +305,7 @@ static inline int read_scalefactors(ATRAC9Context *s, ATRAC9BlockData *b, const VLC *tab = &s->sf_vlc[1][len]; for (int i = 0; i < unit_cnt; i++) { - int dist = get_vlc2(gb, tab->table, 9, 1); + int dist = get_vlc2(gb, tab->table, ATRAC9_SF_VLC_BITS, 1); c->scalefactors[i] = baseline[i] + dist; } @@ -325,7 +328,8 @@ static inline int read_scalefactors(ATRAC9Context *s, ATRAC9BlockData *b, c->scalefactors[0] = get_bits(gb, len); for (int i = 1; i < unit_cnt; i++) { - int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, 9, 1); + int val = c->scalefactors[i - 1] + get_vlc2(gb, tab->table, + ATRAC9_SF_VLC_BITS, 1); c->scalefactors[i] = val & ((1 << len) - 1); } @@ -930,7 +934,8 @@ static av_cold int atrac9_decode_init(AVCodecContext *avctx) for (int i = 1; i < 7; i++) { const HuffmanCodebook *hf = &at9_huffman_sf_unsigned[i]; - init_vlc(&s->sf_vlc[0][i], 9, hf->size, hf->bits, 1, 1, hf->codes, + init_vlc(&s->sf_vlc[0][i], ATRAC9_SF_VLC_BITS, hf->size, + hf->bits, 1, 1, hf->codes, 2, 2, 0); } @@ -943,7 +948,7 @@ static av_cold int atrac9_decode_init(AVCodecContext *avctx) for (int j = 0; j < nums; j++) sym[j] = sign_extend(j, hf->value_bits); - ff_init_vlc_sparse(&s->sf_vlc[1][i], 9, hf->size, hf->bits, 1, 1, + ff_init_vlc_sparse(&s->sf_vlc[1][i], ATRAC9_SF_VLC_BITS, hf->size, hf->bits, 1, 1, hf->codes, 2, 2, sym, sizeof(*sym), sizeof(*sym), 0); } |