diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-11-30 14:33:45 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-05-02 03:39:00 +0200 |
commit | 0c47b070e04141472358c84909aa6f001d81f1cb (patch) | |
tree | 1fe4381785f90934c4688aac940684926152d08b | |
parent | 980f002b3f0b63d145918db98cea6bfc5abfc922 (diff) | |
download | ffmpeg-0c47b070e04141472358c84909aa6f001d81f1cb.tar.gz |
avcodec/cook: Make decoder init-threadsafe
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
-rw-r--r-- | libavcodec/cook.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 0c1d986c45..3720772102 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -45,6 +45,7 @@ #include "libavutil/channel_layout.h" #include "libavutil/lfg.h" #include "libavutil/mem_internal.h" +#include "libavutil/thread.h" #include "audiodsp.h" #include "avcodec.h" @@ -1071,6 +1072,7 @@ static void dump_cook_context(COOKContext *q) */ static av_cold int cook_decode_init(AVCodecContext *avctx) { + static AVOnce init_static_once = AV_ONCE_INIT; COOKContext *q = avctx->priv_data; GetByteContext gb; int s = 0; @@ -1249,7 +1251,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) } /* Generate tables */ - init_pow2table(); + ff_thread_once(&init_static_once, init_pow2table); init_gain_table(q); init_cplscales_table(q); @@ -1301,7 +1303,7 @@ const AVCodec ff_cook_decoder = { .close = cook_decode_close, .decode = cook_decode_frame, .capabilities = AV_CODEC_CAP_DR1, - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, }; |