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>
This commit is contained in:
Andreas Rheinhardt 2020-11-23 05:09:57 +01:00
parent 14be39e44a
commit e5b416dadd
3 changed files with 12 additions and 17 deletions

View File

@ -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];

View File

@ -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] = {

View File

@ -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)