]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
wma: Simplify get_vlc().
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 6 Jun 2017 07:29:37 +0000 (09:29 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 6 Jul 2017 19:00:36 +0000 (21:00 +0200)
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.

bitstream.c
bitstream.h
wmadec_filter.c

index a2a0537a47a9fe7d2c64ceadbb39bb41c58c0aba..c2018b56f593264b15034b639c4103045220ab96 100644 (file)
@@ -165,33 +165,29 @@ void free_vlc(struct vlc *vlc)
  * Parse a vlc code.
  *
  * \param gbc The getbit context structure.
  * 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.
  */
  *
  * \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;
 
 {
        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) {
        if (n < 0) {
-               skip_bits(gbc, bits);
+               skip_bits(gbc, vlc->bits);
                nb_bits = -n;
                idx = show_bits(gbc, nb_bits) + code;
                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;
                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);
                }
        }
        skip_bits(gbc, n);
index bed370ff6a5c0f167f3148d91e4049ec1c7b8c39..4d81fa3b25521053c8cafcf49a4b14542b83e74a 100644 (file)
@@ -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);
 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);
index 525ed3150cda5affb9b479029b7e9aa5f461a0aa..6ddedac23c79deb11cad10e48df0895bcf3f1532 100644 (file)
@@ -581,7 +581,7 @@ static int decode_exp_vlc(struct private_wmadec_data *pwd, int ch)
        last_exp = 36;
 
        while (q < q_end) {
        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 ! */
                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 {
                        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;
                                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 (;;) {
                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 */
                        if (code < 0)
                                return code;
                        if (code == 1) /* EOB */