avcodec: Do not lock during init if there is no init function
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>
Mon, 12 Oct 2015 14:32:28 +0000 (10:32 -0400)
committerLuca Barbato <lu_zero@gentoo.org>
Tue, 13 Oct 2015 11:43:29 +0000 (13:43 +0200)
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libavcodec/utils.c

index a1aece7..430926d 100644 (file)
@@ -845,7 +845,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
         av_dict_copy(&tmp, *options, 0);
 
     /* If there is a user-supplied mutex locking routine, call it. */
-    if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE)) {
+    if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init) {
         if (lockmgr_cb) {
             if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
                 return -1;
@@ -1086,7 +1086,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 #endif
     }
 end:
-    if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE)) {
+    if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init) {
         entangled_thread_counter--;
 
         /* Release any user-supplied mutex. */