[FFmpeg-cvslog] avcodec/options: Remove deprecated avcodec_copy_context

Andreas Rheinhardt git at videolan.org
Wed Apr 28 00:14:54 EEST 2021


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Fri Feb 26 03:56:33 2021 +0100| [bc9dca5c955614aacc62ff19259de11d126e4a39] | committer: James Almer

avcodec/options: Remove deprecated avcodec_copy_context

Deprecated in 5f30ac27795f9f98043e8582ccaad8813104adc4.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
Signed-off-by: James Almer <jamrial at gmail.com>

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

 libavcodec/avcodec.h |  22 -----------
 libavcodec/options.c | 105 ---------------------------------------------------
 libavcodec/version.h |   3 --
 3 files changed, 130 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index cbc1556e0e..ea60e1fe46 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2569,28 +2569,6 @@ const AVClass *avcodec_get_frame_class(void);
  */
 const AVClass *avcodec_get_subtitle_rect_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
- * unopened, i.e. you are required to call avcodec_open2() before you
- * can use this AVCodecContext to decode/encode video/audio data.
- *
- * @param dest target codec context, should be initialized with
- *             avcodec_alloc_context3(NULL), 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
-
 /**
  * Fill the parameters struct based on the values from the supplied codec
  * context. Any allocated fields in par are freed and replaced with duplicates
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 833072b192..369110b8d0 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -193,111 +193,6 @@ void avcodec_free_context(AVCodecContext **pavctx)
     av_freep(pavctx);
 }
 
-#if FF_API_COPY_CONTEXT
-static void copy_context_reset(AVCodecContext *avctx)
-{
-    int i;
-
-    av_opt_free(avctx);
-#if FF_API_CODED_FRAME
-FF_DISABLE_DEPRECATION_WARNINGS
-    av_frame_free(&avctx->coded_frame);
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-    av_freep(&avctx->rc_override);
-    av_freep(&avctx->intra_matrix);
-    av_freep(&avctx->inter_matrix);
-    av_freep(&avctx->extradata);
-    av_freep(&avctx->subtitle_header);
-    av_buffer_unref(&avctx->hw_frames_ctx);
-    av_buffer_unref(&avctx->hw_device_ctx);
-    for (i = 0; i < avctx->nb_coded_side_data; i++)
-        av_freep(&avctx->coded_side_data[i].data);
-    av_freep(&avctx->coded_side_data);
-    avctx->subtitle_header_size = 0;
-    avctx->nb_coded_side_data = 0;
-    avctx->extradata_size = 0;
-}
-
-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(dest)) { // check that the dest context is uninitialized
-        av_log(dest, AV_LOG_ERROR,
-               "Tried to copy AVCodecContext %p into already-initialized %p\n",
-               src, dest);
-        return AVERROR(EINVAL);
-    }
-
-    copy_context_reset(dest);
-
-    memcpy(dest, src, sizeof(*dest));
-    av_opt_copy(dest, src);
-
-    dest->priv_data       = orig_priv_data;
-    dest->codec           = orig_codec;
-
-    if (orig_priv_data && src->codec && src->codec->priv_class &&
-        dest->codec && dest->codec->priv_class)
-        av_opt_copy(orig_priv_data, src->priv_data);
-
-
-    /* set values specific to opened codecs back to their default state */
-    dest->slice_offset    = NULL;
-    dest->hwaccel         = NULL;
-    dest->internal        = NULL;
-#if FF_API_CODED_FRAME
-FF_DISABLE_DEPRECATION_WARNINGS
-    dest->coded_frame     = NULL;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
-    /* reallocate values that should be allocated separately */
-    dest->extradata       = NULL;
-    dest->coded_side_data = NULL;
-    dest->intra_matrix    = NULL;
-    dest->inter_matrix    = NULL;
-    dest->rc_override     = NULL;
-    dest->subtitle_header = NULL;
-    dest->hw_frames_ctx   = NULL;
-    dest->hw_device_ctx   = NULL;
-    dest->nb_coded_side_data = 0;
-
-#define alloc_and_copy_or_fail(obj, size, pad) \
-    if (src->obj && size > 0) { \
-        dest->obj = av_malloc(size + pad); \
-        if (!dest->obj) \
-            goto fail; \
-        memcpy(dest->obj, src->obj, size); \
-        if (pad) \
-            memset(((uint8_t *) dest->obj) + size, 0, pad); \
-    }
-    alloc_and_copy_or_fail(extradata,    src->extradata_size,
-                           AV_INPUT_BUFFER_PADDING_SIZE);
-    dest->extradata_size  = src->extradata_size;
-    alloc_and_copy_or_fail(intra_matrix, 64 * sizeof(int16_t), 0);
-    alloc_and_copy_or_fail(inter_matrix, 64 * sizeof(int16_t), 0);
-    alloc_and_copy_or_fail(rc_override,  src->rc_override_count * sizeof(*src->rc_override), 0);
-    alloc_and_copy_or_fail(subtitle_header, src->subtitle_header_size, 1);
-    av_assert0(dest->subtitle_header_size == src->subtitle_header_size);
-#undef alloc_and_copy_or_fail
-
-    if (src->hw_frames_ctx) {
-        dest->hw_frames_ctx = av_buffer_ref(src->hw_frames_ctx);
-        if (!dest->hw_frames_ctx)
-            goto fail;
-    }
-
-    return 0;
-
-fail:
-    copy_context_reset(dest);
-    return AVERROR(ENOMEM);
-}
-#endif
-
 const AVClass *avcodec_get_class(void)
 {
     return &av_codec_context_class;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 14d9388aa4..a4638ca7fc 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -63,9 +63,6 @@
 #ifndef FF_API_VBV_DELAY
 #define FF_API_VBV_DELAY         (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
-#ifndef FF_API_COPY_CONTEXT
-#define FF_API_COPY_CONTEXT     (LIBAVCODEC_VERSION_MAJOR < 59)
-#endif
 #ifndef FF_API_NVENC_OLD_NAME
 #define FF_API_NVENC_OLD_NAME    (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif



More information about the ffmpeg-cvslog mailing list