[FFmpeg-cvslog] avcodec: Remove deprecated AVPacket API

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


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Thu Feb 25 18:14:11 2021 +0100| [ab227d8fe1df3a95e98be5e2596ea7e4172496fa] | committer: James Almer

avcodec: Remove deprecated AVPacket API

Deprecated in ce70f28a1732c74a9cd7fec2d56178750bd6e457.

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=ab227d8fe1df3a95e98be5e2596ea7e4172496fa
---

 libavcodec/avpacket.c | 118 --------------------------------------------------
 libavcodec/packet.h   |  39 -----------------
 libavcodec/version.h  |   3 --
 3 files changed, 160 deletions(-)

diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index b726a8db0e..4995a83bf8 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -174,108 +174,6 @@ int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size)
     return 0;
 }
 
-#if FF_API_AVPACKET_OLD_API
-FF_DISABLE_DEPRECATION_WARNINGS
-#define ALLOC_MALLOC(data, size) data = av_malloc(size)
-#define ALLOC_BUF(data, size)                \
-do {                                         \
-    av_buffer_realloc(&pkt->buf, size);      \
-    data = pkt->buf ? pkt->buf->data : NULL; \
-} while (0)
-
-#define DUP_DATA(dst, src, size, padding, ALLOC)                        \
-    do {                                                                \
-        void *data;                                                     \
-        if (padding) {                                                  \
-            if ((unsigned)(size) >                                      \
-                (unsigned)(size) + AV_INPUT_BUFFER_PADDING_SIZE)        \
-                goto failed_alloc;                                      \
-            ALLOC(data, size + AV_INPUT_BUFFER_PADDING_SIZE);           \
-        } else {                                                        \
-            ALLOC(data, size);                                          \
-        }                                                               \
-        if (!data)                                                      \
-            goto failed_alloc;                                          \
-        memcpy(data, src, size);                                        \
-        if (padding)                                                    \
-            memset((uint8_t *)data + size, 0,                           \
-                   AV_INPUT_BUFFER_PADDING_SIZE);                       \
-        dst = data;                                                     \
-    } while (0)
-
-/* Makes duplicates of data, side_data, but does not copy any other fields */
-static int copy_packet_data(AVPacket *pkt, const AVPacket *src, int dup)
-{
-    pkt->data      = NULL;
-    pkt->side_data = NULL;
-    pkt->side_data_elems = 0;
-    if (pkt->buf) {
-        AVBufferRef *ref = av_buffer_ref(src->buf);
-        if (!ref)
-            return AVERROR(ENOMEM);
-        pkt->buf  = ref;
-        pkt->data = ref->data;
-    } else {
-        DUP_DATA(pkt->data, src->data, pkt->size, 1, ALLOC_BUF);
-    }
-    if (src->side_data_elems && dup) {
-        pkt->side_data = src->side_data;
-        pkt->side_data_elems = src->side_data_elems;
-    }
-    if (src->side_data_elems && !dup) {
-        return av_copy_packet_side_data(pkt, src);
-    }
-    return 0;
-
-failed_alloc:
-    av_packet_unref(pkt);
-    return AVERROR(ENOMEM);
-}
-
-int av_copy_packet_side_data(AVPacket *pkt, const AVPacket *src)
-{
-    if (src->side_data_elems) {
-        int i;
-        DUP_DATA(pkt->side_data, src->side_data,
-                src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
-        if (src != pkt) {
-            memset(pkt->side_data, 0,
-                   src->side_data_elems * sizeof(*src->side_data));
-        }
-        for (i = 0; i < src->side_data_elems; i++) {
-            DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
-                    src->side_data[i].size, 1, ALLOC_MALLOC);
-            pkt->side_data[i].size = src->side_data[i].size;
-            pkt->side_data[i].type = src->side_data[i].type;
-        }
-    }
-    pkt->side_data_elems = src->side_data_elems;
-    return 0;
-
-failed_alloc:
-    av_packet_unref(pkt);
-    return AVERROR(ENOMEM);
-}
-
-int av_dup_packet(AVPacket *pkt)
-{
-    AVPacket tmp_pkt;
-
-    if (!pkt->buf && pkt->data) {
-        tmp_pkt = *pkt;
-        return copy_packet_data(pkt, &tmp_pkt, 1);
-    }
-    return 0;
-}
-
-int av_copy_packet(AVPacket *dst, const AVPacket *src)
-{
-    *dst = *src;
-    return copy_packet_data(dst, src, 0);
-}
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
 void av_packet_free_side_data(AVPacket *pkt)
 {
     int i;
@@ -285,22 +183,6 @@ void av_packet_free_side_data(AVPacket *pkt)
     pkt->side_data_elems = 0;
 }
 
-#if FF_API_AVPACKET_OLD_API
-FF_DISABLE_DEPRECATION_WARNINGS
-void av_free_packet(AVPacket *pkt)
-{
-    if (pkt) {
-        if (pkt->buf)
-            av_buffer_unref(&pkt->buf);
-        pkt->data            = NULL;
-        pkt->size            = 0;
-
-        av_packet_free_side_data(pkt);
-    }
-}
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
 int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type,
                             uint8_t *data, size_t size)
 {
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index 47e9b8999b..a4cd8f5615 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -519,45 +519,6 @@ int av_grow_packet(AVPacket *pkt, int grow_by);
  */
 int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
 
-#if FF_API_AVPACKET_OLD_API
-/**
- * @warning This is a hack - the packet memory allocation stuff is broken. The
- * packet is allocated if it was not really allocated.
- *
- * @deprecated Use av_packet_ref or av_packet_make_refcounted
- */
-attribute_deprecated
-int av_dup_packet(AVPacket *pkt);
-/**
- * Copy packet, including contents
- *
- * @return 0 on success, negative AVERROR on fail
- *
- * @deprecated Use av_packet_ref
- */
-attribute_deprecated
-int av_copy_packet(AVPacket *dst, const AVPacket *src);
-
-/**
- * Copy packet side data
- *
- * @return 0 on success, negative AVERROR on fail
- *
- * @deprecated Use av_packet_copy_props
- */
-attribute_deprecated
-int av_copy_packet_side_data(AVPacket *dst, const AVPacket *src);
-
-/**
- * Free a packet.
- *
- * @deprecated Use av_packet_unref
- *
- * @param pkt packet to free
- */
-attribute_deprecated
-void av_free_packet(AVPacket *pkt);
-#endif
 /**
  * Allocate new information of a packet.
  *
diff --git a/libavcodec/version.h b/libavcodec/version.h
index d4a48b026b..dfa04d7fc3 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -60,9 +60,6 @@
 #ifndef FF_API_AVPICTURE
 #define FF_API_AVPICTURE         (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
-#ifndef FF_API_AVPACKET_OLD_API
-#define FF_API_AVPACKET_OLD_API (LIBAVCODEC_VERSION_MAJOR < 59)
-#endif
 #ifndef FF_API_RTP_CALLBACK
 #define FF_API_RTP_CALLBACK      (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif



More information about the ffmpeg-cvslog mailing list