[FFmpeg-cvslog] avcodec/4xm: Avoid unnecessary VLC structures
Andreas Rheinhardt
git at videolan.org
Tue Oct 31 22:15:51 EET 2023
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Sep 24 17:23:47 2023 +0200| [25b9ff2780fdf1fbce914aeb68e77699d47147b6] | committer: Andreas Rheinhardt
avcodec/4xm: Avoid unnecessary VLC structures
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>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=25b9ff2780fdf1fbce914aeb68e77699d47147b6
---
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);
More information about the ffmpeg-cvslog
mailing list