aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-11-23 05:09:57 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-12-08 17:51:48 +0100
commite5b416daddd0435571c3483621c6953c56e7cf9a (patch)
treeaa3752eb50790f4213df795db7a4f47f95105ba5
parent14be39e44a7dd5f378e93a9fea0e1ca1e6eba9d6 (diff)
downloadffmpeg-e5b416daddd0435571c3483621c6953c56e7cf9a.tar.gz
avcodec/wmadec: Reduce the size of tables used to initialize VLC
By switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths() one can replace a table of codes of type uint16_t by a table of symbols of type uint8_t, saving space. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-rw-r--r--libavcodec/wma.h3
-rw-r--r--libavcodec/wmadata.h20
-rw-r--r--libavcodec/wmadec.c6
3 files changed, 12 insertions, 17 deletions
diff --git a/libavcodec/wma.h b/libavcodec/wma.h
index c7fcf5047c..7935bcdb31 100644
--- a/libavcodec/wma.h
+++ b/libavcodec/wma.h
@@ -139,8 +139,7 @@ typedef struct WMACodecContext {
#endif /* TRACE */
} WMACodecContext;
-extern const uint16_t ff_wma_hgain_huffcodes[37];
-extern const uint8_t ff_wma_hgain_huffbits[37];
+extern const uint8_t ff_wma_hgain_hufftab[37][2];
extern const float ff_wma_lsp_codebook[NB_LSP_COEFS][16];
extern const uint32_t ff_aac_scalefactor_code[121];
extern const uint8_t ff_aac_scalefactor_bits[121];
diff --git a/libavcodec/wmadata.h b/libavcodec/wmadata.h
index 641cb1813c..ca485a5663 100644
--- a/libavcodec/wmadata.h
+++ b/libavcodec/wmadata.h
@@ -51,18 +51,14 @@ static const uint8_t exponent_band_44100[3][25] = {
{ 17, 4, 8, 8, 4, 12, 12, 8, 8, 24, 16, 20, 24, 32, 40, 60, 80, 152, },
};
-const uint16_t ff_wma_hgain_huffcodes[37] = {
- 0x00003, 0x002e7, 0x00001, 0x005cd, 0x0005d, 0x005c9, 0x0005e, 0x00003,
- 0x00016, 0x0000b, 0x00001, 0x00006, 0x00001, 0x00006, 0x00004, 0x00005,
- 0x00004, 0x00007, 0x00003, 0x00007, 0x00004, 0x0000a, 0x0000a, 0x00002,
- 0x00003, 0x00000, 0x00005, 0x00002, 0x0005f, 0x00004, 0x00003, 0x00002,
- 0x005c8, 0x000b8, 0x005ca, 0x005cb, 0x005cc,
-};
-
-const uint8_t ff_wma_hgain_huffbits[37] = {
- 10, 12, 10, 13, 9, 13, 9, 8, 7, 5, 5, 4, 4, 3, 3, 3,
- 4, 3, 4, 4, 5, 5, 6, 8, 7, 10, 8, 10, 9, 8, 9, 9,
- 13, 10, 13, 13, 13,
+const uint8_t ff_wma_hgain_hufftab[37][2] = {
+ { 25, 10 }, { 2, 10 }, { 27, 10 }, { 0, 10 }, { 31, 9 }, { 30, 9 },
+ { 23, 8 }, { 7, 8 }, { 29, 8 }, { 26, 8 }, { 24, 7 }, { 10, 5 },
+ { 12, 4 }, { 20, 5 }, { 22, 6 }, { 8, 7 }, { 33, 10 }, { 32, 13 },
+ { 5, 13 }, { 34, 13 }, { 35, 13 }, { 36, 13 }, { 3, 13 }, { 1, 12 },
+ { 4, 9 }, { 6, 9 }, { 28, 9 }, { 18, 4 }, { 16, 4 }, { 21, 5 },
+ { 9, 5 }, { 11, 4 }, { 19, 4 }, { 14, 3 }, { 15, 3 }, { 13, 3 },
+ { 17, 3 },
};
const float ff_wma_lsp_codebook[NB_LSP_COEFS][16] = {
diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index 8504d8d6c4..2b9499eba7 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -110,9 +110,9 @@ static av_cold int wma_decode_init(AVCodecContext *avctx)
ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1, 1.0 / 32768.0);
if (s->use_noise_coding) {
- init_vlc(&s->hgain_vlc, HGAINVLCBITS, sizeof(ff_wma_hgain_huffbits),
- ff_wma_hgain_huffbits, 1, 1,
- ff_wma_hgain_huffcodes, 2, 2, 0);
+ ff_init_vlc_from_lengths(&s->hgain_vlc, HGAINVLCBITS, FF_ARRAY_ELEMS(ff_wma_hgain_hufftab),
+ &ff_wma_hgain_hufftab[0][1], 2,
+ &ff_wma_hgain_hufftab[0][0], 2, 1, 0, 0, avctx);
}
if (s->use_exp_vlc)