avcodec/mpegaudiodec_common: Avoid superfluous VLC structures
For some VLCs here, the number of bits of the VLC is write-only, because it is hardcoded at the call site. Therefore one can replace these VLC structures with the only thing that is actually used: The pointer to the VLCElem table. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
5dc31bc67b
commit
c9aa80c313
|
@ -53,7 +53,7 @@ extern uint32_t ff_table_4_3_value[TABLE_4_3_SIZE];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* VLCs for decoding layer 3 huffman tables */
|
/* VLCs for decoding layer 3 huffman tables */
|
||||||
extern VLC ff_huff_vlc[16];
|
extern const VLCElem *ff_huff_vlc[16];
|
||||||
extern VLC ff_huff_quad_vlc[2];
|
extern VLC ff_huff_quad_vlc[2];
|
||||||
|
|
||||||
/* layer3 scale factor size */
|
/* layer3 scale factor size */
|
||||||
|
|
|
@ -64,7 +64,7 @@ const uint8_t ff_lsf_nsf_table[6][3][4] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* mpegaudio layer 3 huffman tables */
|
/* mpegaudio layer 3 huffman tables */
|
||||||
VLC ff_huff_vlc[16];
|
const VLCElem *ff_huff_vlc[16];
|
||||||
static VLCElem huff_vlc_tables[128 + 128 + 128 + 130 + 128 + 154 + 166 + 142 +
|
static VLCElem huff_vlc_tables[128 + 128 + 128 + 130 + 128 + 154 + 166 + 142 +
|
||||||
204 + 190 + 170 + 542 + 460 + 662 + 414];
|
204 + 190 + 170 + 542 + 460 + 662 + 414];
|
||||||
VLC ff_huff_quad_vlc[2];
|
VLC ff_huff_quad_vlc[2];
|
||||||
|
@ -401,6 +401,7 @@ const uint8_t ff_mpa_pretab[2][22] = {
|
||||||
|
|
||||||
static av_cold void mpegaudiodec_common_init_static(void)
|
static av_cold void mpegaudiodec_common_init_static(void)
|
||||||
{
|
{
|
||||||
|
VLCInitState state = VLC_INIT_STATE(huff_vlc_tables);
|
||||||
const uint8_t *huff_sym = mpa_huffsymbols, *huff_lens = mpa_hufflens;
|
const uint8_t *huff_sym = mpa_huffsymbols, *huff_lens = mpa_hufflens;
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
|
@ -414,7 +415,6 @@ static av_cold void mpegaudiodec_common_init_static(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* huffman decode tables */
|
/* huffman decode tables */
|
||||||
offset = 0;
|
|
||||||
for (int i = 0; i < 15;) {
|
for (int i = 0; i < 15;) {
|
||||||
uint16_t tmp_symbols[256];
|
uint16_t tmp_symbols[256];
|
||||||
int nb_codes_minus_one = mpa_huff_sizes_minus_one[i];
|
int nb_codes_minus_one = mpa_huff_sizes_minus_one[i];
|
||||||
|
@ -426,16 +426,14 @@ static av_cold void mpegaudiodec_common_init_static(void)
|
||||||
tmp_symbols[j] = high << 1 | ((high && low) << 4) | low;
|
tmp_symbols[j] = high << 1 | ((high && low) << 4) | low;
|
||||||
}
|
}
|
||||||
|
|
||||||
ff_huff_vlc[++i].table = huff_vlc_tables + offset;
|
ff_huff_vlc[++i] = ff_vlc_init_tables_from_lengths(&state, 7, j,
|
||||||
ff_huff_vlc[i].table_allocated = FF_ARRAY_ELEMS(huff_vlc_tables) - offset;
|
huff_lens, 1,
|
||||||
ff_vlc_init_from_lengths(&ff_huff_vlc[i], 7, j,
|
tmp_symbols, 2, 2,
|
||||||
huff_lens, 1, tmp_symbols, 2, 2,
|
0, 0);
|
||||||
0, VLC_INIT_STATIC_OVERLONG, NULL);
|
|
||||||
offset += ff_huff_vlc[i].table_size;
|
|
||||||
huff_lens += j;
|
huff_lens += j;
|
||||||
huff_sym += j;
|
huff_sym += j;
|
||||||
}
|
}
|
||||||
av_assert0(offset == FF_ARRAY_ELEMS(huff_vlc_tables));
|
av_assert1(state.size == 0);
|
||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
|
|
|
@ -760,6 +760,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
|
||||||
/* low frequencies (called big values) */
|
/* low frequencies (called big values) */
|
||||||
s_index = 0;
|
s_index = 0;
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
|
const VLCElem *vlctab;
|
||||||
int j, k, l, linbits;
|
int j, k, l, linbits;
|
||||||
j = g->region_size[i];
|
j = g->region_size[i];
|
||||||
if (j == 0)
|
if (j == 0)
|
||||||
|
@ -768,13 +769,13 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
|
||||||
k = g->table_select[i];
|
k = g->table_select[i];
|
||||||
l = ff_mpa_huff_data[k][0];
|
l = ff_mpa_huff_data[k][0];
|
||||||
linbits = ff_mpa_huff_data[k][1];
|
linbits = ff_mpa_huff_data[k][1];
|
||||||
vlc = &ff_huff_vlc[l];
|
|
||||||
|
|
||||||
if (!l) {
|
if (!l) {
|
||||||
memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid) * 2 * j);
|
memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid) * 2 * j);
|
||||||
s_index += 2 * j;
|
s_index += 2 * j;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
vlctab = ff_huff_vlc[l];
|
||||||
|
|
||||||
/* read huffcode and compute each couple */
|
/* read huffcode and compute each couple */
|
||||||
for (; j > 0; j--) {
|
for (; j > 0; j--) {
|
||||||
|
@ -787,7 +788,7 @@ static int huffman_decode(MPADecodeContext *s, GranuleDef *g,
|
||||||
if (pos >= end_pos)
|
if (pos >= end_pos)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
y = get_vlc2(&s->gb, vlc->table, 7, 3);
|
y = get_vlc2(&s->gb, vlctab, 7, 3);
|
||||||
|
|
||||||
if (!y) {
|
if (!y) {
|
||||||
g->sb_hybrid[s_index ] =
|
g->sb_hybrid[s_index ] =
|
||||||
|
|
Loading…
Reference in New Issue