diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-10-28 14:35:19 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-12-08 17:51:45 +0100 |
commit | b9dc000679c55ff2c013bdea17b2235228b1ac3f (patch) | |
tree | ded8f58f11a5c0de845a8e6e3ecddc19ef650b00 /libavcodec/mimic.c | |
parent | 34cb6d2360bb603c34eae8f488033bd6b4fbd279 (diff) | |
download | ffmpeg-b9dc000679c55ff2c013bdea17b2235228b1ac3f.tar.gz |
avcodec/mimic: Make VLC static
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/mimic.c')
-rw-r--r-- | libavcodec/mimic.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/libavcodec/mimic.c b/libavcodec/mimic.c index 60c612003a..ea6a7efe93 100644 --- a/libavcodec/mimic.c +++ b/libavcodec/mimic.c @@ -23,6 +23,8 @@ #include <string.h> #include <stdint.h> +#include "libavutil/thread.h" + #include "avcodec.h" #include "blockdsp.h" #include "internal.h" @@ -58,13 +60,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 +114,24 @@ 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 void mimic_init_static(void) +{ + INIT_VLC_STATIC_FROM_LENGTHS(&block_vlc, MIMIC_VLC_BITS, FF_ARRAY_ELEMS(huffbits), + huffbits, 1, huffsyms, 1, 1, 0, 0, 4368); +} + static av_cold int mimic_decode_init(AVCodecContext *avctx) { + static AVOnce init_static_once = AV_ONCE_INIT; 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, avctx); - if (ret < 0) { - av_log(avctx, AV_LOG_ERROR, "error initializing vlc table\n"); - return ret; - } ff_blockdsp_init(&ctx->bdsp, avctx); ff_bswapdsp_init(&ctx->bbdsp); ff_hpeldsp_init(&ctx->hdsp, avctx->flags); @@ -142,6 +144,8 @@ static av_cold int mimic_decode_init(AVCodecContext *avctx) return AVERROR(ENOMEM); } + ff_thread_once(&init_static_once, mimic_init_static); + return 0; } @@ -221,7 +225,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) |