diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-11-15 22:48:35 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-12-08 17:51:46 +0100 |
commit | 0d71ac319f74a85add9c62c31461b4dd4dcfcabd (patch) | |
tree | 9d54d19344365217af86a4e1208c2d36af4a6790 /libavcodec | |
parent | f25dde0e278b0f70cfbcdb281a80de1b1e75f611 (diff) | |
download | ffmpeg-0d71ac319f74a85add9c62c31461b4dd4dcfcabd.tar.gz |
avcodec/indeo2: Make decoder init-threadsafe
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/indeo2.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c index 5a9c0e77be..5721308267 100644 --- a/libavcodec/indeo2.c +++ b/libavcodec/indeo2.c @@ -25,6 +25,7 @@ */ #include "libavutil/attributes.h" +#include "libavutil/thread.h" #define BITSTREAM_READER_LE #include "avcodec.h" @@ -225,8 +226,16 @@ static int ir2_decode_frame(AVCodecContext *avctx, return buf_size; } +static av_cold void ir2_init_static(void) +{ + INIT_VLC_STATIC_FROM_LENGTHS(&ir2_vlc, CODE_VLC_BITS, IR2_CODES, + &ir2_tab[0][1], 2, &ir2_tab[0][0], 2, 1, + 0, INIT_VLC_OUTPUT_LE, 1 << CODE_VLC_BITS); +} + static av_cold int ir2_decode_init(AVCodecContext *avctx) { + static AVOnce init_static_once = AV_ONCE_INIT; Ir2Context * const ic = avctx->priv_data; ic->avctx = avctx; @@ -237,9 +246,7 @@ static av_cold int ir2_decode_init(AVCodecContext *avctx) if (!ic->picture) return AVERROR(ENOMEM); - INIT_VLC_STATIC_FROM_LENGTHS(&ir2_vlc, CODE_VLC_BITS, IR2_CODES, - &ir2_tab[0][1], 2, &ir2_tab[0][0], 2, 1, - 0, INIT_VLC_OUTPUT_LE, 1 << CODE_VLC_BITS); + ff_thread_once(&init_static_once, ir2_init_static); return 0; } @@ -263,4 +270,5 @@ AVCodec ff_indeo2_decoder = { .close = ir2_decode_end, .decode = ir2_decode_frame, .capabilities = AV_CODEC_CAP_DR1, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; |