diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-11-30 23:58:56 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-05-02 05:14:41 +0200 |
commit | 7d4f1f4d99a95e30a7d5b85dc591e388b2f9f3bd (patch) | |
tree | d441cc73c1effa4aa8074fad349b9507133844d1 /libavcodec/dcadec.c | |
parent | e5bc8b623661db80e854765d7ac359764b0d0760 (diff) |
avcodec/dca*: Make decoder init-threadsafe
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/dcadec.c')
-rw-r--r-- | libavcodec/dcadec.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c index 1aa1b4235b..43694b51f7 100644 --- a/libavcodec/dcadec.c +++ b/libavcodec/dcadec.c @@ -20,6 +20,7 @@ #include "libavutil/opt.h" #include "libavutil/channel_layout.h" +#include "libavutil/thread.h" #include "dcadec.h" #include "dcahuff.h" @@ -318,8 +319,15 @@ static av_cold int dcadec_close(AVCodecContext *avctx) return 0; } +static av_cold void dcadec_init_static(void) +{ + ff_dca_lbr_init_tables(); + ff_dca_init_vlcs(); +} + static av_cold int dcadec_init(AVCodecContext *avctx) { + static AVOnce init_static_once = AV_ONCE_INIT; DCAContext *s = avctx->priv_data; s->avctx = avctx; @@ -328,8 +336,6 @@ static av_cold int dcadec_init(AVCodecContext *avctx) s->xll.avctx = avctx; s->lbr.avctx = avctx; - ff_dca_init_vlcs(); - if (ff_dca_core_init(&s->core) < 0) return AVERROR(ENOMEM); @@ -362,6 +368,8 @@ static av_cold int dcadec_init(AVCodecContext *avctx) break; } + ff_thread_once(&init_static_once, dcadec_init_static); + return 0; } @@ -396,5 +404,5 @@ const AVCodec ff_dca_decoder = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, .priv_class = &dcadec_class, .profiles = NULL_IF_CONFIG_SMALL(ff_dca_profiles), - .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, }; |