[FFmpeg-devel] [PATCH 17/30] avformat: remove deprecated FF_API_AVSTREAM_SIDE_DATA
James Almer
jamrial at gmail.com
Mon Feb 24 00:06:17 EET 2025
Deprecated since 2023-10-06.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavformat/avformat.c | 80 ----------------------------
libavformat/avformat.h | 103 ------------------------------------
libavformat/demux.c | 46 ----------------
libavformat/demux_utils.c | 12 -----
libavformat/internal.h | 11 ----
libavformat/mux.c | 22 --------
libavformat/options.c | 5 --
libavformat/seek.c | 7 ---
libavformat/version_major.h | 1 -
9 files changed, 287 deletions(-)
diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index f53299cc40..18ca4643ee 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -50,14 +50,6 @@ void ff_free_stream(AVStream **pst)
if (!st)
return;
-#if FF_API_AVSTREAM_SIDE_DATA
-FF_DISABLE_DEPRECATION_WARNINGS
- for (int i = 0; i < st->nb_side_data; i++)
- av_freep(&st->side_data[i].data);
- av_freep(&st->side_data);
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
if (st->attached_pic.data)
av_packet_unref(&st->attached_pic);
@@ -199,78 +191,6 @@ void avformat_free_context(AVFormatContext *s)
av_free(s);
}
-#if FF_API_AVSTREAM_SIDE_DATA
-FF_DISABLE_DEPRECATION_WARNINGS
-uint8_t *av_stream_get_side_data(const AVStream *st,
- enum AVPacketSideDataType type, size_t *size)
-{
- for (int i = 0; i < st->nb_side_data; i++) {
- if (st->side_data[i].type == type) {
- if (size)
- *size = st->side_data[i].size;
- return st->side_data[i].data;
- }
- }
- if (size)
- *size = 0;
- return NULL;
-}
-
-int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
- uint8_t *data, size_t size)
-{
- AVPacketSideData *sd, *tmp;
-
- for (int i = 0; i < st->nb_side_data; i++) {
- sd = &st->side_data[i];
-
- if (sd->type == type) {
- av_freep(&sd->data);
- sd->data = data;
- sd->size = size;
- return 0;
- }
- }
-
- if (st->nb_side_data + 1U > FFMIN(INT_MAX, SIZE_MAX / sizeof(*tmp)))
- return AVERROR(ERANGE);
-
- tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));
- if (!tmp) {
- return AVERROR(ENOMEM);
- }
-
- st->side_data = tmp;
- st->nb_side_data++;
-
- sd = &st->side_data[st->nb_side_data - 1];
- sd->type = type;
- sd->data = data;
- sd->size = size;
-
- return 0;
-}
-
-uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
- size_t size)
-{
- int ret;
- uint8_t *data = av_malloc(size);
-
- if (!data)
- return NULL;
-
- ret = av_stream_add_side_data(st, type, data, size);
- if (ret < 0) {
- av_freep(&data);
- return NULL;
- }
-
- return data;
-}
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
/**
* Copy all stream parameters from source to destination stream, with the
* exception of the index field, which is usually set by avformat_new_stream().
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 08e3206290..fabe1d305c 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -844,38 +844,6 @@ typedef struct AVStream {
*/
AVPacket attached_pic;
-#if FF_API_AVSTREAM_SIDE_DATA
- /**
- * An array of side data that applies to the whole stream (i.e. the
- * container does not allow it to change between packets).
- *
- * There may be no overlap between the side data in this array and side data
- * in the packets. I.e. a given side data is either exported by the muxer
- * (demuxing) / set by the caller (muxing) in this array, then it never
- * appears in the packets, or the side data is exported / sent through
- * the packets (always in the first packet where the value becomes known or
- * changes), then it does not appear in this array.
- *
- * - demuxing: Set by libavformat when the stream is created.
- * - muxing: May be set by the caller before avformat_write_header().
- *
- * Freed by libavformat in avformat_free_context().
- *
- * @deprecated use AVStream's @ref AVCodecParameters.coded_side_data
- * "codecpar side data".
- */
- attribute_deprecated
- AVPacketSideData *side_data;
- /**
- * The number of elements in the AVStream.side_data array.
- *
- * @deprecated use AVStream's @ref AVCodecParameters.nb_coded_side_data
- * "codecpar side data".
- */
- attribute_deprecated
- int nb_side_data;
-#endif
-
/**
* Flags indicating events happening on the stream, a combination of
* AVSTREAM_EVENT_FLAG_*.
@@ -1923,26 +1891,6 @@ typedef struct AVFormatContext {
int64_t duration_probesize;
} AVFormatContext;
-#if FF_API_AVSTREAM_SIDE_DATA
-/**
- * This function will cause global side data to be injected in the next packet
- * of each stream as well as after any subsequent seek.
- *
- * @note global side data is always available in every AVStream's
- * @ref AVCodecParameters.coded_side_data "codecpar side data" array, and
- * in a @ref AVCodecContext.coded_side_data "decoder's side data" array if
- * initialized with said stream's codecpar.
- * @see av_packet_side_data_get()
- *
- * @deprecated this function should never be needed, as global side data is now
- * exported in AVCodecParameters and should
- * be propagated from demuxers to decoders via
- * ::avcodec_parameters_to_context()
- */
-attribute_deprecated
-void av_format_inject_global_side_data(AVFormatContext *s);
-#endif
-
#if FF_API_GET_DUR_ESTIMATE_METHOD
/**
* Returns the method used to set ctx->duration.
@@ -2131,57 +2079,6 @@ AVStream *avformat_new_stream(AVFormatContext *s, const struct AVCodec *c);
*/
int avformat_stream_group_add_stream(AVStreamGroup *stg, AVStream *st);
-#if FF_API_AVSTREAM_SIDE_DATA
-/**
- * Wrap an existing array as stream side data.
- *
- * @param st stream
- * @param type side information type
- * @param data the side data array. It must be allocated with the av_malloc()
- * family of functions. The ownership of the data is transferred to
- * st.
- * @param size side information size
- *
- * @return zero on success, a negative AVERROR code on failure. On failure,
- * the stream is unchanged and the data remains owned by the caller.
- * @deprecated use av_packet_side_data_add() with the stream's
- * @ref AVCodecParameters.coded_side_data "codecpar side data"
- */
-attribute_deprecated
-int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
- uint8_t *data, size_t size);
-
-/**
- * Allocate new information from stream.
- *
- * @param stream stream
- * @param type desired side information type
- * @param size side information size
- *
- * @return pointer to fresh allocated data or NULL otherwise
- * @deprecated use av_packet_side_data_new() with the stream's
- * @ref AVCodecParameters.coded_side_data "codecpar side data"
- */
-attribute_deprecated
-uint8_t *av_stream_new_side_data(AVStream *stream,
- enum AVPacketSideDataType type, size_t size);
-/**
- * Get side information from stream.
- *
- * @param stream stream
- * @param type desired side information type
- * @param size If supplied, *size will be set to the size of the side data
- * or to zero if the desired side data is not present.
- *
- * @return pointer to data if present or NULL otherwise
- * @deprecated use av_packet_side_data_get() with the stream's
- * @ref AVCodecParameters.coded_side_data "codecpar side data"
- */
-attribute_deprecated
-uint8_t *av_stream_get_side_data(const AVStream *stream,
- enum AVPacketSideDataType type, size_t *size);
-#endif
-
AVProgram *av_new_program(AVFormatContext *s, int id);
/**
diff --git a/libavformat/demux.c b/libavformat/demux.c
index c0bfb9cb67..71af8acad9 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -1495,27 +1495,6 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
}
sti->skip_samples = 0;
}
-
-#if FF_API_AVSTREAM_SIDE_DATA
- if (sti->inject_global_side_data) {
- for (int i = 0; i < st->codecpar->nb_coded_side_data; i++) {
- const AVPacketSideData *const src_sd = &st->codecpar->coded_side_data[i];
- uint8_t *dst_data;
-
- if (av_packet_get_side_data(pkt, src_sd->type, NULL))
- continue;
-
- dst_data = av_packet_new_side_data(pkt, src_sd->type, src_sd->size);
- if (!dst_data) {
- av_log(s, AV_LOG_WARNING, "Could not inject global side data\n");
- continue;
- }
-
- memcpy(dst_data, src_sd->data, src_sd->size);
- }
- sti->inject_global_side_data = 0;
- }
-#endif
}
if (!fci->metafree) {
@@ -3074,31 +3053,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
}
sti->avctx_inited = 0;
-#if FF_API_AVSTREAM_SIDE_DATA
-FF_DISABLE_DEPRECATION_WARNINGS
- if (st->codecpar->nb_coded_side_data > 0) {
- av_assert0(!st->side_data && !st->nb_side_data);
- st->side_data = av_calloc(st->codecpar->nb_coded_side_data, sizeof(*st->side_data));
- if (!st->side_data) {
- ret = AVERROR(ENOMEM);
- goto find_stream_info_err;
- }
-
- for (int j = 0; j < st->codecpar->nb_coded_side_data; j++) {
- uint8_t *data = av_memdup(st->codecpar->coded_side_data[j].data,
- st->codecpar->coded_side_data[j].size);
- if (!data) {
- ret = AVERROR(ENOMEM);
- goto find_stream_info_err;
- }
- st->side_data[j].type = st->codecpar->coded_side_data[j].type;
- st->side_data[j].size = st->codecpar->coded_side_data[j].size;
- st->side_data[j].data = data;
- st->nb_side_data++;
- }
- }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
}
find_stream_info_err:
diff --git a/libavformat/demux_utils.c b/libavformat/demux_utils.c
index 9aae521c6c..b632277460 100644
--- a/libavformat/demux_utils.c
+++ b/libavformat/demux_utils.c
@@ -81,18 +81,6 @@ AVChapter *avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_ba
return chapter;
}
-#if FF_API_AVSTREAM_SIDE_DATA
-void av_format_inject_global_side_data(AVFormatContext *s)
-{
- FFFormatContext *const si = ffformatcontext(s);
- si->inject_global_side_data = 1;
- for (unsigned i = 0; i < s->nb_streams; i++) {
- AVStream *st = s->streams[i];
- ffstream(st)->inject_global_side_data = 1;
- }
-}
-#endif
-
int avformat_queue_attached_pictures(AVFormatContext *s)
{
FormatContextInternal *const fci = ff_fc_internal(s);
diff --git a/libavformat/internal.h b/libavformat/internal.h
index b909adf209..500c310b88 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -110,10 +110,6 @@ typedef struct FFFormatContext {
*/
AVPacket *pkt;
-#if FF_API_AVSTREAM_SIDE_DATA
- int inject_global_side_data;
-#endif
-
int avoid_negative_ts_use_pts;
/**
@@ -292,13 +288,6 @@ typedef struct FFStream {
uint8_t dts_ordered;
uint8_t dts_misordered;
-#if FF_API_AVSTREAM_SIDE_DATA
- /**
- * Internal data to inject global side data
- */
- int inject_global_side_data;
-#endif
-
/**
* display aspect ratio (0 if unknown)
* - encoding: unused
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 60204f6266..db3b6c2bfe 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -295,27 +295,6 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
}
}
-#if FF_API_AVSTREAM_SIDE_DATA
-FF_DISABLE_DEPRECATION_WARNINGS
- /* if the caller is using the deprecated AVStream side_data API,
- * copy its contents to AVStream.codecpar, giving it priority
- over existing side data in the latter */
- for (int i = 0; i < st->nb_side_data; i++) {
- const AVPacketSideData *sd_src = &st->side_data[i];
- AVPacketSideData *sd_dst;
-
- sd_dst = av_packet_side_data_new(&st->codecpar->coded_side_data,
- &st->codecpar->nb_coded_side_data,
- sd_src->type, sd_src->size, 0);
- if (!sd_dst) {
- ret = AVERROR(ENOMEM);
- goto fail;
- }
- memcpy(sd_dst->data, sd_src->data, sd_src->size);
- }
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
-
desc = avcodec_descriptor_get(par->codec_id);
if (desc && desc->props & AV_CODEC_PROP_REORDER)
sti->reorder = 1;
@@ -965,7 +944,6 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
int stream_count = 0;
int noninterleaved_count = 0;
int ret;
- int eof = flush;
if (has_packet) {
if ((ret = ff_interleave_add_packet(s, pkt, interleave_compare_dts)) < 0)
diff --git a/libavformat/options.c b/libavformat/options.c
index b314cd4a35..76b91169a5 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -250,7 +250,6 @@ const AVClass *av_stream_get_class(void)
AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
{
- FFFormatContext *const si = ffformatcontext(s);
FFStream *sti;
AVStream *st;
AVStream **streams;
@@ -322,10 +321,6 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
sti->transferred_mux_tb = (AVRational) { 0, 1 };;
#endif
-#if FF_API_AVSTREAM_SIDE_DATA
- sti->inject_global_side_data = si->inject_global_side_data;
-#endif
-
sti->need_context_update = 1;
s->streams[s->nb_streams++] = st;
diff --git a/libavformat/seek.c b/libavformat/seek.c
index a096d5e5b3..c0d94371e6 100644
--- a/libavformat/seek.c
+++ b/libavformat/seek.c
@@ -715,8 +715,6 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts,
/** Flush the frame reader. */
void ff_read_frame_flush(AVFormatContext *s)
{
- FFFormatContext *const si = ffformatcontext(s);
-
ff_flush_packet_queue(s);
/* Reset read state for each stream. */
@@ -741,11 +739,6 @@ void ff_read_frame_flush(AVFormatContext *s)
for (int j = 0; j < MAX_REORDER_DELAY + 1; j++)
sti->pts_buffer[j] = AV_NOPTS_VALUE;
-#if FF_API_AVSTREAM_SIDE_DATA
- if (si->inject_global_side_data)
- sti->inject_global_side_data = 1;
-#endif
-
sti->skip_samples = 0;
}
}
diff --git a/libavformat/version_major.h b/libavformat/version_major.h
index f76d811889..aec4ee6e74 100644
--- a/libavformat/version_major.h
+++ b/libavformat/version_major.h
@@ -42,7 +42,6 @@
*
*/
#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 62)
-#define FF_API_AVSTREAM_SIDE_DATA (LIBAVFORMAT_VERSION_MAJOR < 62)
#define FF_API_GET_DUR_ESTIMATE_METHOD (LIBAVFORMAT_VERSION_MAJOR < 62)
#define FF_API_INTERNAL_TIMING (LIBAVFORMAT_VERSION_MAJOR < 62)
--
2.48.1
More information about the ffmpeg-devel
mailing list