diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-12-03 16:56:36 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2021-01-09 04:06:32 +0100 |
commit | 42ee3898c8cfc56b70a68cd3d285953e5802444f (patch) | |
tree | 6be294c732601590124ae6bde1b9b265077f5b8c /libavcodec/ac3dec.c | |
parent | 10663312de979404d2417a120a3c85a68cf70dd5 (diff) | |
download | ffmpeg-42ee3898c8cfc56b70a68cd3d285953e5802444f.tar.gz |
avcodec/ac3dec: Make decoders init-threadsafe
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/ac3dec.c')
-rw-r--r-- | libavcodec/ac3dec.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 3e4bec56b1..c7deb56e1c 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -33,6 +33,7 @@ #include "libavutil/crc.h" #include "libavutil/downmix_info.h" #include "libavutil/opt.h" +#include "libavutil/thread.h" #include "bswapdsp.h" #include "internal.h" #include "aac_ac3_parser.h" @@ -183,12 +184,12 @@ static av_cold void ac3_tables_init(void) */ static av_cold int ac3_decode_init(AVCodecContext *avctx) { + static AVOnce init_static_once = AV_ONCE_INIT; AC3DecodeContext *s = avctx->priv_data; int i, ret; s->avctx = avctx; - ac3_tables_init(); if ((ret = ff_mdct_init(&s->imdct_256, 8, 1, 1.0)) < 0 || (ret = ff_mdct_init(&s->imdct_512, 9, 1, 1.0)) < 0) return ret; @@ -226,6 +227,8 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) s->dlyptr[i] = s->delay[i]; } + ff_thread_once(&init_static_once, ac3_tables_init); + return 0; } |