aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/utils.c
diff options
context:
space:
mode:
authorAsh Hughes <ashes-iontach@hotmail.com>2012-10-19 01:12:56 +0000
committerMichael Niedermayer <michaelni@gmx.at>2012-10-19 18:05:12 +0200
commit2470851f1228006473d9ce825604aa1cfe1c5916 (patch)
tree47d60b5381f5777f54a26e20eb85c991b5b9939e /libavcodec/utils.c
parent7abf394814d818973db562102f21ab9d10540840 (diff)
downloadffmpeg-2470851f1228006473d9ce825604aa1cfe1c5916.tar.gz
lavc: enable recursively using avcodec_open2/close.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r--libavcodec/utils.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index a238e62b87..926fdee88b 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -798,6 +798,27 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
}
#endif
+int attribute_align_arg ff_codec_open2_recursive(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
+{
+ int ret = 0;
+
+ entangled_thread_counter--;
+ /* Release any user-supplied mutex. */
+ if (ff_lockmgr_cb) {
+ (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE);
+ }
+
+ ret = avcodec_open2(avctx, codec, options);
+
+ /* If there is a user-supplied mutex locking routine, call it. */
+ if (ff_lockmgr_cb) {
+ if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
+ return -1;
+ }
+ entangled_thread_counter++;
+ return ret;
+}
+
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
{
int ret = 0;
@@ -1809,6 +1830,27 @@ void avsubtitle_free(AVSubtitle *sub)
memset(sub, 0, sizeof(AVSubtitle));
}
+av_cold int ff_codec_close_recursive(AVCodecContext *avctx)
+{
+ int ret = 0;
+
+ entangled_thread_counter--;
+ /* Release any user-supplied mutex. */
+ if (ff_lockmgr_cb) {
+ (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE);
+ }
+
+ ret = avcodec_close(avctx);
+
+ /* If there is a user-supplied mutex locking routine, call it. */
+ if (ff_lockmgr_cb) {
+ if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
+ return -1;
+ }
+ entangled_thread_counter++;
+ return ret;
+}
+
av_cold int avcodec_close(AVCodecContext *avctx)
{
/* If there is a user-supplied mutex locking routine, call it. */