summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-03-13 22:20:17 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-03-13 22:38:53 +0100
commita048bd44b2563dc453e0c97bdca60cf028feaf50 (patch)
tree9160697af0c020fe8841326e81eff6e08670cd11 /libavcodec/utils.c
parent79f013a206394bfc90bbb72995f5cf8965181f51 (diff)
parent117b432748ca87de4cd0f09d9b1495545e264733 (diff)
Merge commit '117b432748ca87de4cd0f09d9b1495545e264733'
* commit '117b432748ca87de4cd0f09d9b1495545e264733': lavc: Introduce AVCodec internal capabilities Conflicts: libavcodec/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b3749af340..14a4d7b6c5 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1318,7 +1318,7 @@ int attribute_align_arg ff_codec_open2_recursive(AVCodecContext *avctx, const AV
ret = avcodec_open2(avctx, codec, options);
- ff_lock_avcodec(avctx);
+ ff_lock_avcodec(avctx, codec);
return ret;
}
@@ -1348,7 +1348,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
if (options)
av_dict_copy(&tmp, *options, 0);
- ret = ff_lock_avcodec(avctx);
+ ret = ff_lock_avcodec(avctx, codec);
if (ret < 0)
return ret;
@@ -1477,7 +1477,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
if (CONFIG_FRAME_THREAD_ENCODER) {
ff_unlock_avcodec(); //we will instanciate a few encoders thus kick the counter to prevent false detection of a problem
ret = ff_frame_thread_encoder_init(avctx, options ? *options : NULL);
- ff_lock_avcodec(avctx);
+ ff_lock_avcodec(avctx, codec);
if (ret < 0)
goto free_and_end;
}
@@ -1704,6 +1704,10 @@ end:
return ret;
free_and_end:
+ if (avctx->codec &&
+ (avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP))
+ avctx->codec->close(avctx);
+
av_dict_free(&tmp);
if (codec->priv_class && codec->priv_data_size)
av_opt_free(avctx->priv_data);
@@ -3600,14 +3604,15 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
return 0;
}
-int ff_lock_avcodec(AVCodecContext *log_ctx)
+int ff_lock_avcodec(AVCodecContext *log_ctx, AVCodec *codec)
{
if (lockmgr_cb) {
if ((*lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
return -1;
}
entangled_thread_counter++;
- if (entangled_thread_counter != 1) {
+ if (entangled_thread_counter != 1 &&
+ !(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE)) {
av_log(log_ctx, AV_LOG_ERROR,
"Insufficient thread locking. At least %d threads are "
"calling avcodec_open2() at the same time right now.\n",