From 9b12b292d9b523f44174fc2b6827ec2f519b9235 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 6 Feb 2016 07:07:10 +0100 Subject: [PATCH] wmadec: Simplify get_vlc(). The last parameter is always bigger than 2, which is all the function needs to know. Hence we may remove the parameter and get rid of some macros that were only used to compute it. --- bitstream.c | 9 +++------ bitstream.h | 3 +-- wmadec_filter.c | 13 +++---------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/bitstream.c b/bitstream.c index 1593b99e..638d19a3 100644 --- a/bitstream.c +++ b/bitstream.c @@ -166,29 +166,26 @@ void free_vlc(struct vlc *vlc) * \param gbc The getbit context structure. * \param table The vlc tables to use. * \param bits The number of bits which will be read at once. - * \param max_depth The number of times \a bits bits must be read to completely - * read the longest vlc code = (max_vlc_length + bits - 1) / bits. * * The \a bits parameter must be identical to the \a nb_bits value supplied to * \ref init_vlc(). * * \return The vlc code. */ -int get_vlc(struct getbit_context *gbc, VLC_TYPE(*table)[2], int bits, - int max_depth) +int get_vlc(struct getbit_context *gbc, VLC_TYPE(*table)[2], int bits) { int n, idx, nb_bits, code; idx = show_bits(gbc, bits); code = table[idx][0]; n = table[idx][1]; - if (max_depth > 1 && n < 0) { + if (n < 0) { skip_bits(gbc, bits); nb_bits = -n; idx = show_bits(gbc, nb_bits) + code; code = table[idx][0]; n = table[idx][1]; - if (max_depth > 2 && n < 0) { + if (n < 0) { skip_bits(gbc, nb_bits); nb_bits = -n; idx = show_bits(gbc, nb_bits) + code; diff --git a/bitstream.h b/bitstream.h index 5890d08c..ee32667e 100644 --- a/bitstream.h +++ b/bitstream.h @@ -88,5 +88,4 @@ static inline void init_get_bits(struct getbit_context *gbc, void init_vlc(struct vlc *vlc, int nb_bits, int nb_codes, const void *bits, const void *codes, int codes_size); void free_vlc(struct vlc *vlc); -int get_vlc(struct getbit_context *gbc, VLC_TYPE(*table)[2], int bits, - int max_depth); +int get_vlc(struct getbit_context *gbc, VLC_TYPE(*table)[2], int bits); diff --git a/wmadec_filter.c b/wmadec_filter.c index 6b7251ee..c1f0c302 100644 --- a/wmadec_filter.c +++ b/wmadec_filter.c @@ -131,13 +131,8 @@ struct private_wmadec_data { }; #define EXPVLCBITS 8 -#define EXPMAX DIV_ROUND_UP(19, EXPVLCBITS) - #define HGAINVLCBITS 9 -#define HGAINMAX DIV_ROUND_UP(13, HGAINVLCBITS) - #define VLCBITS 9 -#define VLCMAX DIV_ROUND_UP(22, VLCBITS) /** \cond sine_winows */ @@ -586,7 +581,7 @@ static int decode_exp_vlc(struct private_wmadec_data *pwd, int ch) last_exp = 36; while (q < q_end) { - code = get_vlc(&pwd->gb, pwd->exp_vlc.table, EXPVLCBITS, EXPMAX); + code = get_vlc(&pwd->gb, pwd->exp_vlc.table, EXPVLCBITS); if (code < 0) return code; /* NOTE: this offset is the same as MPEG4 AAC ! */ @@ -714,8 +709,7 @@ static int compute_high_band_values(struct private_wmadec_data *pwd, val = get_bits(&pwd->gb, 7) - 19; else { int code = get_vlc(&pwd->gb, - pwd->hgain_vlc.table, HGAINVLCBITS, - HGAINMAX); + pwd->hgain_vlc.table, HGAINVLCBITS); if (code < 0) return code; val += code - 18; @@ -946,8 +940,7 @@ static int wma_decode_block(struct private_wmadec_data *pwd) eptr = ptr + nb_coefs[ch]; memset(ptr, 0, pwd->block_len * sizeof(int16_t)); for (;;) { - code = get_vlc(&pwd->gb, coef_vlc->table, - VLCBITS, VLCMAX); + code = get_vlc(&pwd->gb, coef_vlc->table, VLCBITS); if (code < 0) return code; if (code == 1) /* EOB */ -- 2.39.5