struct vlc coef_vlc[2];
uint16_t *run_table[2];
uint16_t *level_table[2];
- const struct coef_vlc_table *coef_vlcs[2];
/** Frame length in samples. */
int frame_len;
/** log2 of frame_len. */
window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n)));
}
-static void init_coef_vlc(struct vlc *vlc, uint16_t **prun_table,
- uint16_t **plevel_table, const struct coef_vlc_table *vlc_table)
+static void init_coef_vlc(struct private_wmadec_data *pwd, int sidx, int didx)
{
- int n = vlc_table->n;
- const uint8_t *table_bits = vlc_table->huffbits;
- const uint32_t *table_codes = vlc_table->huffcodes;
- const uint16_t *levels_table = vlc_table->levels;
- uint16_t *run_table, *level_table;
- int i, l, j, k, level;
+ const struct coef_vlc_table *src = coef_vlcs + sidx;
+ struct vlc *dst = pwd->coef_vlc + didx;
+ int i, l, j, k, level, n = src->n;
- init_vlc(vlc, VLCBITS, n, table_bits, table_codes, 4);
-
- run_table = para_malloc(n * sizeof(uint16_t));
- level_table = para_malloc(n * sizeof(uint16_t));
+ init_vlc(dst, VLCBITS, n, src->huffbits, src->huffcodes, 4);
+ pwd->run_table[didx] = para_malloc(n * sizeof(uint16_t));
+ pwd->level_table[didx] = para_malloc(n * sizeof(uint16_t));
i = 2;
level = 1;
k = 0;
while (i < n) {
- l = levels_table[k++];
+ l = src->levels[k++];
for (j = 0; j < l; j++) {
- run_table[i] = j;
- level_table[i] = level;
+ pwd->run_table[didx][i] = j;
+ pwd->level_table[didx][i] = level;
i++;
}
level++;
}
- *prun_table = run_table;
- *plevel_table = level_table;
}
/* compute the scale factor band sizes for each MDCT block size */
}
/* choose the VLC tables for the coefficients */
- coef_vlc_table = 2;
+ coef_vlc_table = 4;
if (ahi->sample_rate >= 32000) {
if (bps1 < 0.72)
coef_vlc_table = 0;
else if (bps1 < 1.16)
- coef_vlc_table = 1;
+ coef_vlc_table = 2;
}
- pwd->coef_vlcs[0] = &coef_vlcs[coef_vlc_table * 2];
- pwd->coef_vlcs[1] = &coef_vlcs[coef_vlc_table * 2 + 1];
- init_coef_vlc(&pwd->coef_vlc[0], &pwd->run_table[0], &pwd->level_table[0],
- pwd->coef_vlcs[0]);
- init_coef_vlc(&pwd->coef_vlc[1], &pwd->run_table[1], &pwd->level_table[1],
- pwd->coef_vlcs[1]);
+ init_coef_vlc(pwd, coef_vlc_table, 0);
+ init_coef_vlc(pwd, coef_vlc_table + 1, 1);
return 0;
}