[FFmpeg-devel] [PATCH 1/2] libavcodec/options: print a warning when copying open context

Lukasz Marek lukasz.m.luki2 at gmail.com
Tue Dec 2 19:27:32 CET 2014


Context copied from open context cannot be treated as opened.
avcodec_open2 modifies context so reopening it is also questionable.
It is worth to warn when it happens.

Signed-off-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
---
 libavcodec/options.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/options.c b/libavcodec/options.c
index 3dd5df3..dab5140 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -182,6 +182,9 @@ int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
     const AVCodec *orig_codec = dest->codec;
     uint8_t *orig_priv_data = dest->priv_data;
 
+    if (avcodec_is_open(src))
+        av_log(dest, AV_LOG_WARNING, "AVCodecContext is copied from opened context.\n");
+
     if (avcodec_is_open(dest)) { // check that the dest context is uninitialized
         av_log(dest, AV_LOG_ERROR,
                "Tried to copy AVCodecContext %p into already-initialized %p\n",
-- 
1.9.1



More information about the ffmpeg-devel mailing list