[FFmpeg-cvslog] lavc: deprecate avcodec_copy_context()

Anton Khirnov git at videolan.org
Sun Jun 26 14:37:00 CEST 2016


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat May 21 11:46:44 2016 +0200| [5f30ac27795f9f98043e8582ccaad8813104adc4] | committer: Anton Khirnov

lavc: deprecate avcodec_copy_context()

Since AVCodecContext contains a lot of complex state, copying a codec
context is not a well-defined operation. The purpose for which it is
typically used (which is well-defined) is copying the stream parameters
from one codec context to another. That is now possible with through the
AVCodecParameters API. Therefore, there is no reason for
avcodec_copy_context() to exist.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5f30ac27795f9f98043e8582ccaad8813104adc4
---

 libavcodec/avcodec.h |    9 +++++++++
 libavcodec/options.c |    2 ++
 libavcodec/version.h |    3 +++
 3 files changed, 14 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index bb54565..639ecf3 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3648,6 +3648,7 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec);
  */
 const AVClass *avcodec_get_class(void);
 
+#if FF_API_COPY_CONTEXT
 /**
  * Copy the settings of the source AVCodecContext into the destination
  * AVCodecContext. The resulting destination codec context will be
@@ -3658,8 +3659,16 @@ const AVClass *avcodec_get_class(void);
  *             avcodec_alloc_context3(), but otherwise uninitialized
  * @param src source codec context
  * @return AVERROR() on error (e.g. memory allocation error), 0 on success
+ *
+ * @deprecated The semantics of this function are ill-defined and it should not
+ * be used. If you need to transfer the stream parameters from one codec context
+ * to another, use an intermediate AVCodecParameters instance and the
+ * avcodec_parameters_from_context() / avcodec_parameters_to_context()
+ * functions.
  */
+attribute_deprecated
 int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src);
+#endif
 
 /**
  * Allocate a new AVCodecParameters and set its fields to default values
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 49c8aea..50bacd3 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -155,6 +155,7 @@ void avcodec_free_context(AVCodecContext **pavctx)
     av_freep(pavctx);
 }
 
+#if FF_API_COPY_CONTEXT
 int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
 {
     const AVCodec *orig_codec = dest->codec;
@@ -225,6 +226,7 @@ fail:
 #endif
     return AVERROR(ENOMEM);
 }
+#endif
 
 const AVClass *avcodec_get_class(void)
 {
diff --git a/libavcodec/version.h b/libavcodec/version.h
index db3f33a..57006c9 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -200,5 +200,8 @@
 #ifndef FF_API_OLD_BSF
 #define FF_API_OLD_BSF          (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_COPY_CONTEXT
+#define FF_API_COPY_CONTEXT     (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 
 #endif /* AVCODEC_VERSION_H */



More information about the ffmpeg-cvslog mailing list