diff mbox series

[FFmpeg-devel,39/45] avcodec/smvjpegdec: Make decoder init-threadsafe

Message ID 20201127010249.2724610-39-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,01/45] avcodec/a64multienc: Fix memleak upon init failure | expand


Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 27, 2020, 1:02 a.m. UTC
The only thing that stands in the way of adding the
FF_CODEC_CAP_INIT_THREADSAFE flag to the SMV JPEG decoder is its usage
of ff_codec_open2_recursive(): This function requires its caller to hold
the lock for the mutex that guards initialization of AVCodecContexts
whose codecs have a non-threadsafe init function and only callers whose
codec does not have the FF_CODEC_CAP_INIT_THREADSAFE flag set hold said
lock (the others don't need to care about said lock). But one can set
the flag if one switches to avcodec_open2() at the same time.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
 libavcodec/smvjpegdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series


diff --git a/libavcodec/smvjpegdec.c b/libavcodec/smvjpegdec.c
index 807d990d00..670e3313c9 100644
--- a/libavcodec/smvjpegdec.c
+++ b/libavcodec/smvjpegdec.c
@@ -124,7 +124,7 @@  static av_cold int smvjpeg_decode_init(AVCodecContext *avctx)
     s->avctx->refcounted_frames = 1;
     s->avctx->flags = avctx->flags;
     s->avctx->idct_algo = avctx->idct_algo;
-    if ((ret = ff_codec_open2_recursive(s->avctx, codec, &thread_opt)) < 0)
+    if ((ret = avcodec_open2(s->avctx, codec, &thread_opt)) < 0)
         av_log(avctx, AV_LOG_ERROR, "MJPEG codec failed to open\n");
@@ -211,5 +211,5 @@  AVCodec ff_smvjpeg_decoder = {
     .close          = smvjpeg_decode_end,
     .decode         = smvjpeg_decode_frame,
     .priv_class     = &smvjpegdec_class,
-    .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,