[FFmpeg-devel] [PATCH 1/2] Support playing SMV files.
Ash Hughes
ashes-iontach at hotmail.com
Fri Oct 19 03:12:56 CEST 2012
Renamed functions to follow convention
Ash
---
diff -uNr ffmpeg-vanilla/libavcodec/utils.c ffmpeg/libavcodec/utils.c
--- ffmpeg-vanilla/libavcodec/utils.c 2012-10-16 18:09:41.283863114 +0100
+++ ffmpeg/libavcodec/utils.c 2012-10-19 01:48:02.120851863 +0100
@@ -798,6 +798,27 @@
}
#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 @@
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. */
diff -uNr ffmpeg-vanilla/libavcodec/internal.h ffmpeg/libavcodec/internal.h
--- ffmpeg-vanilla/libavcodec/internal.h 2012-10-16 18:09:41.247862923 +0100
+++ ffmpeg/libavcodec/internal.h 2012-10-19 01:46:35.420421944 +0100
@@ -178,4 +178,16 @@
int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx);
+/**
+ * Call avcodec_open2 recursively by decrementing counter, unlocking mutex,
+ * calling the function and then restoring again. Assumes the mutex is
+ * already locked
+ */
+int ff_codec_open2_recursive(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options);
+
+/**
+ * Call avcodec_close recursively, counterpart to avcodec_open2_recursive.
+ */
+int ff_codec_close_recursive(AVCodecContext *avctx);
+
#endif /* AVCODEC_INTERNAL_H */
Date: Thu, 18 Oct 2012 01:21:32 +0200
From: michaelni at gmx.at
To: ffmpeg-devel at ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 1/2] Support playing SMV files.
On Tue, Oct 16, 2012 at 06:48:06PM +0000, Ash Hughes wrote:
> This patch updates libavcodec to enable recursively using avcodec_open2/close. Used in the SMV decoder to open an MJPEG decoder.
>
> Ash
>
> ---
> diff -uNr ffmpeg-vanilla/libavcodec/utils.c ffmpeg/libavcodec/utils.c
> --- ffmpeg-vanilla/libavcodec/utils.c 2012-10-16 18:09:41.283863114 +0100
> +++ ffmpeg/libavcodec/utils.c 2012-10-16 17:58:22.784498604 +0100
> @@ -798,6 +798,27 @@
> }
> #endif
>
> +int attribute_align_arg avcodec_open2_recursive(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
av prefixes are for external API, this is (at least currently)
internal API so should have a ff prefix instead
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list