summaryrefslogtreecommitdiff
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-03-11 20:43:58 +0000
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-03-13 19:47:47 +0000
commit117b432748ca87de4cd0f09d9b1495545e264733 (patch)
tree0542c2432120a0e973bcc1748a717f122787f97c /libavcodec/utils.c
parent9993a067f6c8c7e7838052ac3146aa6b80dd7e81 (diff)
lavc: Introduce AVCodec internal capabilities
This field is designed for marking codec properties useful to lavc internals. Two internal capabilities are added: - FF_CODEC_CAP_INIT_THREADSAFE: codec can be opened without locks; - FF_CODEC_CAP_INIT_CLEANUP: codec frees memory if initialization fails.
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 7b169ff209..f1acd780dc 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1049,7 +1049,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
}
entangled_thread_counter++;
- if (entangled_thread_counter != 1) {
+ if (entangled_thread_counter != 1 &&
+ !(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE)) {
av_log(avctx, AV_LOG_ERROR,
"Insufficient thread locking. At least %d threads are "
"calling avcodec_open2() at the same time right now.\n",
@@ -1286,6 +1287,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);
av_freep(&avctx->priv_data);
if (avctx->internal) {