summaryrefslogtreecommitdiff
path: root/libavcodec/mpegaudiodec_template.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-11-17 15:53:43 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-12-08 17:51:47 +0100
commitdb234dbf73fe97611a75163bbb3b7c22ff953696 (patch)
treeed52f826e3ffb585b2c7378be8a99e1c7bc41eb5 /libavcodec/mpegaudiodec_template.c
parent12ace68ab0f07b8049dd9807dd9ea302187bd44b (diff)
downloadffmpeg-db234dbf73fe97611a75163bbb3b7c22ff953696.tar.gz
avcodec/mpegaudiodec: Reduce the size of tables used to initialize VLCs
By switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths() one can replace tables of codes of type uint16_t by tables of symbols of type uint8_t; this saves about 1.3KB for both the fixed and floating point decoders (if enabled). Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/mpegaudiodec_template.c')
-rw-r--r--libavcodec/mpegaudiodec_template.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c
index 88679723fc..edd69684da 100644
--- a/libavcodec/mpegaudiodec_template.c
+++ b/libavcodec/mpegaudiodec_template.c
@@ -288,26 +288,21 @@ static av_cold void decode_init_static(void)
offset = 0;
for (int i = 0; i < 15;) {
const HuffTable *h = &mpa_huff_tables[i];
- int xsize, x, y;
- uint8_t tmp_bits [512] = { 0 };
- uint16_t tmp_codes[512] = { 0 };
+ uint16_t tmp_symbols[256];
+ int nb_codes = h->nb_codes;
- xsize = h->xsize;
+ for (int j = 0; j < nb_codes; j++) {
+ uint8_t high = h->symbols[j] & 0xF0, low = h->symbols[j] & 0xF;
- j = 0;
- for (x = 0; x < xsize; x++) {
- for (y = 0; y < xsize; y++) {
- tmp_bits [(x << 5) | y | ((x && y) << 4)]= h->bits [j ];
- tmp_codes[(x << 5) | y | ((x && y) << 4)]= h->codes[j++];
- }
+ tmp_symbols[j] = high << 1 | ((high && low) << 4) | low;
}
/* XXX: fail test */
huff_vlc[++i].table = huff_vlc_tables + offset;
huff_vlc[i].table_allocated = FF_ARRAY_ELEMS(huff_vlc_tables) - offset;
- init_vlc(&huff_vlc[i], 7, 512,
- tmp_bits, 1, 1, tmp_codes, 2, 2,
- INIT_VLC_STATIC_OVERLONG);
+ ff_init_vlc_from_lengths(&huff_vlc[i], 7, nb_codes,
+ h->bits, 1, tmp_symbols, 2, 2,
+ 0, INIT_VLC_STATIC_OVERLONG, NULL);
offset += huff_vlc[i].table_size;
}
av_assert0(offset == FF_ARRAY_ELEMS(huff_vlc_tables));