diff mbox series

[FFmpeg-devel,032/114] avcodec/mimic: Make VLC static

Message ID 20201110104851.321029-33-andreas.rheinhardt@gmail.com
State Superseded
Headers show
Series VLC, esp. init_vlc patches | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 10, 2020, 10:47 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/mimic.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c
index 32f02d4b61..3e4d7c2576 100644
--- a/libavcodec/mimic.c
+++ b/libavcodec/mimic.c
@@ -58,13 +58,14 @@  typedef struct MimicContext {
     BswapDSPContext bbdsp;
     HpelDSPContext  hdsp;
     IDCTDSPContext  idsp;
-    VLC             vlc;
 
     /* Kept in the context so multithreading can have a constant to read from */
     int             next_cur_index;
     int             next_prev_index;
 } MimicContext;
 
+static VLC block_vlc;
+
 static const uint8_t huffsyms[] = {
     0x10, 0x20, 0x30, 0x00, 0x11, 0x40, 0x50, 0x12, 0x13, 0x21, 0x31, 0x60,
     0x14, 0x15, 0x16, 0x22, 0x41, 0x17, 0x18, 0x23, 0x24, 0x25, 0x32, 0x42,
@@ -111,25 +112,20 @@  static av_cold int mimic_decode_end(AVCodecContext *avctx)
         av_frame_free(&ctx->frames[i].f);
     }
 
-    ff_free_vlc(&ctx->vlc);
-
     return 0;
 }
 
 static av_cold int mimic_decode_init(AVCodecContext *avctx)
 {
     MimicContext *ctx = avctx->priv_data;
-    int ret, i;
+    int i;
 
     ctx->prev_index = 0;
     ctx->cur_index  = 15;
 
-    ret = ff_init_vlc_from_lengths(&ctx->vlc, MIMIC_VLC_BITS, FF_ARRAY_ELEMS(huffbits),
-                                   huffbits, 1, huffsyms, 1, 1, 0, 0);
-    if (ret < 0) {
-        av_log(avctx, AV_LOG_ERROR, "error initializing vlc table\n");
-        return ret;
-    }
+    if (!block_vlc.table_size)
+        INIT_VLC_STATIC_FROM_LENGTHS(&block_vlc, MIMIC_VLC_BITS, FF_ARRAY_ELEMS(huffbits),
+                                     huffbits, 1, huffsyms, 1, 1, 0, 0, 4368);
     ff_blockdsp_init(&ctx->bdsp, avctx);
     ff_bswapdsp_init(&ctx->bbdsp);
     ff_hpeldsp_init(&ctx->hdsp, avctx->flags);
@@ -223,7 +219,7 @@  static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale)
         int value;
         int coeff;
 
-        vlc = get_vlc2(&ctx->gb, ctx->vlc.table, MIMIC_VLC_BITS, 3);
+        vlc = get_vlc2(&ctx->gb, block_vlc.table, MIMIC_VLC_BITS, 3);
         if (!vlc) /* end-of-block code */
             return 0;
         if (vlc == -1)