[FFmpeg-devel] [PATCH v2 149/162] avcodec/mv30: Reduce the size of tables used to initialize VLCs

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Fri Nov 20 09:33:14 EET 2020


By switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths() one
can remove the array of codes of type uint16_t here; given that the
symbols are the default ones (0,1,2,...), no explicit symbols table
needs to be added.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavcodec/mv30.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c
index 5bfe4b0614..1ee6be0c99 100644
--- a/libavcodec/mv30.c
+++ b/libavcodec/mv30.c
@@ -35,6 +35,8 @@
 #include "internal.h"
 #include "aandcttab.h"
 
+#define CBP_VLC_BITS  9
+
 typedef struct MV30Context {
     GetBitContext  gb;
 
@@ -651,18 +653,14 @@ static int decode_frame(AVCodecContext *avctx, void *data,
     return avpkt->size;
 }
 
-static const uint16_t cbp_codes[] = {
-    0, 1, 4, 5, 6, 0xE, 0x1E, 0x3E, 0x7E, 0xFE, 0x1FE, 0x1FF,
-};
-
 static const uint8_t cbp_bits[] = {
     2, 2, 3, 3, 3, 4, 5, 6, 7, 8, 9, 9,
 };
 
 static av_cold void init_static_data(void)
 {
-    INIT_VLC_SPARSE_STATIC(&cbp_tab, 9, FF_ARRAY_ELEMS(cbp_bits),
-                           cbp_bits, 1, 1, cbp_codes, 2, 2, NULL, 0, 0, 512);
+    INIT_VLC_STATIC_FROM_LENGTHS(&cbp_tab, CBP_VLC_BITS, FF_ARRAY_ELEMS(cbp_bits),
+                                 cbp_bits, 1, NULL, 0, 0, 0, 0, 1 << CBP_VLC_BITS);
 }
 
 static av_cold int decode_init(AVCodecContext *avctx)
-- 
2.25.1



More information about the ffmpeg-devel mailing list