[FFmpeg-devel] [PATCH 35/61] avcodec/4xm: Avoid unnecessary VLC structures
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Wed Sep 27 01:17:06 EEST 2023
Everything besides VLC.table is basically write-only
and even VLC.table can be removed by accessing the
underlying table directly.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
libavcodec/4xm.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
index c3e3a45df5..158b37a38b 100644
--- a/libavcodec/4xm.c
+++ b/libavcodec/4xm.c
@@ -125,7 +125,7 @@ static const uint8_t dequant_table[64] = {
20, 35, 34, 32, 31, 22, 15, 8,
};
-static VLC block_type_vlc[2][4];
+static VLCElem block_type_vlc[2][4][32];
typedef struct CFrameBuffer {
@@ -250,17 +250,15 @@ static void idct(int16_t block[64])
static av_cold void init_vlcs(void)
{
- static VLCElem table[2][4][32];
int i, j;
for (i = 0; i < 2; i++) {
for (j = 0; j < 4; j++) {
- block_type_vlc[i][j].table = table[i][j];
- block_type_vlc[i][j].table_allocated = 32;
- vlc_init(&block_type_vlc[i][j], BLOCK_TYPE_VLC_BITS, 7,
- &block_type_tab[i][j][0][1], 2, 1,
- &block_type_tab[i][j][0][0], 2, 1,
- VLC_INIT_USE_STATIC);
+ ff_vlc_init_table_sparse(block_type_vlc[i][j], FF_ARRAY_ELEMS(block_type_vlc[i][j]),
+ BLOCK_TYPE_VLC_BITS, 7,
+ &block_type_tab[i][j][0][1], 2, 1,
+ &block_type_tab[i][j][0][0], 2, 1,
+ NULL, 0, 0, 0);
}
}
}
@@ -357,7 +355,7 @@ static int decode_p_block(FourXContext *f, uint16_t *dst, const uint16_t *src,
if (get_bits_left(&f->gb) < 1)
return AVERROR_INVALIDDATA;
h = 1 << log2h;
- code = get_vlc2(&f->gb, block_type_vlc[1 - (f->version > 1)][index].table,
+ code = get_vlc2(&f->gb, block_type_vlc[1 - (f->version > 1)][index],
BLOCK_TYPE_VLC_BITS, 1);
av_assert0(code >= 0 && code <= 6);
--
2.34.1
More information about the ffmpeg-devel
mailing list