diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-03-13 21:43:37 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2025-03-17 03:26:07 +0100 |
commit | 997b33f64c98f3a195d19e2121c61907549313fc (patch) | |
tree | 52e4cfb2d30b56545e2d1e22ab77b8527a73f1bc /libavcodec/hqx.c | |
parent | 004367a0a38578583fff4e3ef9501574965aee1b (diff) | |
download | ffmpeg-997b33f64c98f3a195d19e2121c61907549313fc.tar.gz |
avcodec/hqxvlc: Make dc9, dc10 VLC tables static
It allows to share them between frame threads.
dc11 can unfortunately not be made static without increasing
LOCALBUF_ELEMS in vlc.c.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/hqx.c')
-rw-r--r-- | libavcodec/hqx.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/libavcodec/hqx.c b/libavcodec/hqx.c index aab28a2156..e5a727a609 100644 --- a/libavcodec/hqx.c +++ b/libavcodec/hqx.c @@ -70,7 +70,7 @@ typedef struct HQXContext { const VLCElem *dc_vlc; - VLC dc_vlcs[3]; + VLC dc11_vlc; } HQXContext; #define HQX_HEADER_SIZE 59 @@ -481,7 +481,7 @@ static int hqx_decode_frame(AVCodecContext *avctx, AVFrame *frame, av_log(avctx, AV_LOG_ERROR, "Invalid DC precision 8.\n"); return AVERROR_INVALIDDATA; } - ctx->dc_vlc = ctx->dc_vlcs[dcb_code - 1].table; + ctx->dc_vlc = dcb_code == 3 ? ctx->dc11_vlc.table : dc_vlc[dcb_code - 1]; ctx->dcb = dcb_code + 8; ret = av_image_check_size(ctx->width, ctx->height, 0, avctx); if (ret < 0) { @@ -539,12 +539,9 @@ static int hqx_decode_frame(AVCodecContext *avctx, AVFrame *frame, static av_cold int hqx_decode_close(AVCodecContext *avctx) { - int i; HQXContext *ctx = avctx->priv_data; - for (i = 0; i < 3; i++) { - ff_vlc_free(&ctx->dc_vlcs[i]); - } + ff_vlc_free(&ctx->dc11_vlc); return 0; } @@ -553,11 +550,11 @@ static av_cold int hqx_decode_init(AVCodecContext *avctx) { static AVOnce init_static_once = AV_ONCE_INIT; HQXContext *ctx = avctx->priv_data; - int ret; + int ret = vlc_init(&ctx->dc11_vlc, HQX_DC_VLC_BITS, FF_ARRAY_ELEMS(dc11_vlc_lens), + dc11_vlc_lens, 1, 1, dc11_vlc_bits, 2, 2, 0); - INIT_DC_TABLE(0, dc9); - INIT_DC_TABLE(1, dc10); - INIT_DC_TABLE(2, dc11); + if (ret < 0) + return ret; ff_hqxdsp_init(&ctx->hqxdsp); |