From: Andre Noll Date: Tue, 6 Jun 2017 07:29:37 +0000 (+0200) Subject: wma: Simplify get_vlc(). X-Git-Tag: v0.6.1~44^2~7 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=30fdc1bcb5fd37398943cb6b072a9ca4633f2592;p=paraslash.git wma: Simplify get_vlc(). The "bits" argument of the function is implicitly given by the vlc structure and may thus be omitted from the call. For this to work we must pass a pointer to struct vlc instead of only the table, which further simplifies wmadec_filter.c. --- diff --git a/bitstream.c b/bitstream.c index a2a0537a..c2018b56 100644 --- a/bitstream.c +++ b/bitstream.c @@ -165,33 +165,29 @@ void free_vlc(struct vlc *vlc) * Parse a vlc code. * * \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. - * - * The \a bits parameter must be identical to the \a nb_bits value supplied to - * \ref init_vlc(). + * \param vlc The vlc tables to use. * * \return The vlc code. */ -int get_vlc(struct getbit_context *gbc, int16_t (*table)[2], int bits) +int get_vlc(struct getbit_context *gbc, const struct vlc *vlc) { int n, idx, nb_bits, code; - idx = show_bits(gbc, bits); - code = table[idx][0]; - n = table[idx][1]; + idx = show_bits(gbc, vlc->bits); + code = vlc->table[idx][0]; + n = vlc->table[idx][1]; if (n < 0) { - skip_bits(gbc, bits); + skip_bits(gbc, vlc->bits); nb_bits = -n; idx = show_bits(gbc, nb_bits) + code; - code = table[idx][0]; - n = table[idx][1]; + code = vlc->table[idx][0]; + n = vlc->table[idx][1]; if (n < 0) { skip_bits(gbc, nb_bits); nb_bits = -n; idx = show_bits(gbc, nb_bits) + code; - code = table[idx][0]; - n = table[idx][1]; + code = vlc->table[idx][0]; + n = vlc->table[idx][1]; } } skip_bits(gbc, n); diff --git a/bitstream.h b/bitstream.h index bed370ff..4d81fa3b 100644 --- a/bitstream.h +++ b/bitstream.h @@ -96,4 +96,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, int16_t (*table)[2], int bits); +int get_vlc(struct getbit_context *gbc, const struct vlc *vlc); diff --git a/wmadec_filter.c b/wmadec_filter.c index 525ed315..6ddedac2 100644 --- a/wmadec_filter.c +++ b/wmadec_filter.c @@ -581,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); + code = get_vlc(&pwd->gb, &pwd->exp_vlc); if (code < 0) return code; /* NOTE: this offset is the same as MPEG4 AAC ! */ @@ -708,8 +708,7 @@ static int compute_high_band_values(struct private_wmadec_data *pwd, if (val == (int)0x80000000) val = get_bits(&pwd->gb, 7) - 19; else { - int code = get_vlc(&pwd->gb, - pwd->hgain_vlc.table, HGAINVLCBITS); + int code = get_vlc(&pwd->gb, &pwd->hgain_vlc); if (code < 0) return code; val += code - 18; @@ -940,7 +939,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); + code = get_vlc(&pwd->gb, coef_vlc); if (code < 0) return code; if (code == 1) /* EOB */