History

avformat: remove deprecated FF_API_AVSTREAM_SIDE_DATA

Deprecated since 2023-10-06.

James Almer committed 1 year ago

Commit ec8e7961 parent c1532389 files · +0 −287Browse files

Unified · Split

9 files
  1. libavformat/avformat.c +0 −80
  2. libavformat/avformat.h +0 −103
  3. libavformat/demux.c +0 −46
  4. libavformat/demux_utils.c +0 −12
  5. libavformat/internal.h +0 −11
  6. libavformat/mux.c +0 −22
  7. libavformat/options.c +0 −5
  8. libavformat/seek.c +0 −7
  9. libavformat/version_major.h +0 −1
libavformat/avformat.c+0−80
@@ -50,14 +50,6 @@ void ff_free_stream(AVStream **pst) · 49 unmodified lines
5050 if (!st)
5151 return;
5252
53−#if FF_API_AVSTREAM_SIDE_DATA
54−FF_DISABLE_DEPRECATION_WARNINGS
55− for (int i = 0; i < st->nb_side_data; i++)
56− av_freep(&st->side_data[i].data);
57− av_freep(&st->side_data);
58−FF_ENABLE_DEPRECATION_WARNINGS
59−#endif
60−
6153 if (st->attached_pic.data)
6254 av_packet_unref(&st->attached_pic);
6355
@@ -199,78 +191,6 @@ void avformat_free_context(AVFormatContext *s) · 135 unmodified lines
199191 av_free(s);
200192 }
201193
202−#if FF_API_AVSTREAM_SIDE_DATA
203−FF_DISABLE_DEPRECATION_WARNINGS
204−uint8_t *av_stream_get_side_data(const AVStream *st,
205− enum AVPacketSideDataType type, size_t *size)
206−{
207− for (int i = 0; i < st->nb_side_data; i++) {
208− if (st->side_data[i].type == type) {
209− if (size)
210− *size = st->side_data[i].size;
211− return st->side_data[i].data;
212− }
213− }
214− if (size)
215− *size = 0;
216− return NULL;
217−}
218−
219−int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
220− uint8_t *data, size_t size)
221−{
222− AVPacketSideData *sd, *tmp;
223−
224− for (int i = 0; i < st->nb_side_data; i++) {
225− sd = &st->side_data[i];
226−
227− if (sd->type == type) {
228− av_freep(&sd->data);
229− sd->data = data;
230− sd->size = size;
231− return 0;
232− }
233− }
234−
235− if (st->nb_side_data + 1U > FFMIN(INT_MAX, SIZE_MAX / sizeof(*tmp)))
236− return AVERROR(ERANGE);
237−
238− tmp = av_realloc_array(st->side_data, st->nb_side_data + 1, sizeof(*tmp));
239− if (!tmp) {
240− return AVERROR(ENOMEM);
241− }
242−
243− st->side_data = tmp;
244− st->nb_side_data++;
245−
246− sd = &st->side_data[st->nb_side_data - 1];
247− sd->type = type;
248− sd->data = data;
249− sd->size = size;
250−
251− return 0;
252−}
253−
254−uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
255− size_t size)
256−{
257− int ret;
258− uint8_t *data = av_malloc(size);
259−
260− if (!data)
261− return NULL;
262−
263− ret = av_stream_add_side_data(st, type, data, size);
264− if (ret < 0) {
265− av_freep(&data);
266− return NULL;
267− }
268−
269− return data;
270−}
271−FF_ENABLE_DEPRECATION_WARNINGS
272−#endif
273−
274194 /**
275195 * Copy all stream parameters from source to destination stream, with the
276196 * exception of the index field, which is usually set by avformat_new_stream().
libavformat/avformat.h+0−103
@@ -844,38 +844,6 @@ typedef struct AVStream { · 843 unmodified lines
844844 */
845845 AVPacket attached_pic;
846846
847−#if FF_API_AVSTREAM_SIDE_DATA
848− /**
849− * An array of side data that applies to the whole stream (i.e. the
850− * container does not allow it to change between packets).
851− *
852− * There may be no overlap between the side data in this array and side data
853− * in the packets. I.e. a given side data is either exported by the muxer
854− * (demuxing) / set by the caller (muxing) in this array, then it never
855− * appears in the packets, or the side data is exported / sent through
856− * the packets (always in the first packet where the value becomes known or
857− * changes), then it does not appear in this array.
858− *
859− * - demuxing: Set by libavformat when the stream is created.
860− * - muxing: May be set by the caller before avformat_write_header().
861− *
862− * Freed by libavformat in avformat_free_context().
863− *
864− * @deprecated use AVStream's @ref AVCodecParameters.coded_side_data
865− * "codecpar side data".
866− */
867− attribute_deprecated
868− AVPacketSideData *side_data;
869− /**
870− * The number of elements in the AVStream.side_data array.
871− *
872− * @deprecated use AVStream's @ref AVCodecParameters.nb_coded_side_data
873− * "codecpar side data".
874− */
875− attribute_deprecated
876− int nb_side_data;
877−#endif
878−
879847 /**
880848 * Flags indicating events happening on the stream, a combination of
881849 * AVSTREAM_EVENT_FLAG_*.
@@ -1923,26 +1891,6 @@ typedef struct AVFormatContext { · 1041 unmodified lines
19231891 int64_t duration_probesize;
19241892 } AVFormatContext;
19251893
1926−#if FF_API_AVSTREAM_SIDE_DATA
1927−/**
1928− * This function will cause global side data to be injected in the next packet
1929− * of each stream as well as after any subsequent seek.
1930− *
1931− * @note global side data is always available in every AVStream's
1932− * @ref AVCodecParameters.coded_side_data "codecpar side data" array, and
1933− * in a @ref AVCodecContext.coded_side_data "decoder's side data" array if
1934− * initialized with said stream's codecpar.
1935− * @see av_packet_side_data_get()
1936− *
1937− * @deprecated this function should never be needed, as global side data is now
1938− * exported in AVCodecParameters and should
1939− * be propagated from demuxers to decoders via
1940− * ::avcodec_parameters_to_context()
1941− */
1942−attribute_deprecated
1943−void av_format_inject_global_side_data(AVFormatContext *s);
1944−#endif
1945−
19461894 #if FF_API_GET_DUR_ESTIMATE_METHOD
19471895 /**
19481896 * Returns the method used to set ctx->duration.
@@ -2131,57 +2079,6 @@ AVStream *avformat_new_stream(AVFormatContext *s, const struct AVCodec *c); · 182 unmodified lines
21312079 */
21322080 int avformat_stream_group_add_stream(AVStreamGroup *stg, AVStream *st);
21332081
2134−#if FF_API_AVSTREAM_SIDE_DATA
2135−/**
2136− * Wrap an existing array as stream side data.
2137− *
2138− * @param st stream
2139− * @param type side information type
2140− * @param data the side data array. It must be allocated with the av_malloc()
2141− * family of functions. The ownership of the data is transferred to
2142− * st.
2143− * @param size side information size
2144− *
2145− * @return zero on success, a negative AVERROR code on failure. On failure,
2146− * the stream is unchanged and the data remains owned by the caller.
2147− * @deprecated use av_packet_side_data_add() with the stream's
2148− * @ref AVCodecParameters.coded_side_data "codecpar side data"
2149− */
2150−attribute_deprecated
2151−int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
2152− uint8_t *data, size_t size);
2153−
2154−/**
2155− * Allocate new information from stream.
2156− *
2157− * @param stream stream
2158− * @param type desired side information type
2159− * @param size side information size
2160− *
2161− * @return pointer to fresh allocated data or NULL otherwise
2162− * @deprecated use av_packet_side_data_new() with the stream's
2163− * @ref AVCodecParameters.coded_side_data "codecpar side data"
2164− */
2165−attribute_deprecated
2166−uint8_t *av_stream_new_side_data(AVStream *stream,
2167− enum AVPacketSideDataType type, size_t size);
2168−/**
2169− * Get side information from stream.
2170− *
2171− * @param stream stream
2172− * @param type desired side information type
2173− * @param size If supplied, *size will be set to the size of the side data
2174− * or to zero if the desired side data is not present.
2175− *
2176− * @return pointer to data if present or NULL otherwise
2177− * @deprecated use av_packet_side_data_get() with the stream's
2178− * @ref AVCodecParameters.coded_side_data "codecpar side data"
2179− */
2180−attribute_deprecated
2181−uint8_t *av_stream_get_side_data(const AVStream *stream,
2182− enum AVPacketSideDataType type, size_t *size);
2183−#endif
2184−
21852082 AVProgram *av_new_program(AVFormatContext *s, int id);
21862083
21872084 /**
libavformat/demux.c+0−46
@@ -1496,27 +1496,6 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 1495 unmodified lines
14961496 }
14971497 sti->skip_samples = 0;
14981498 }
1499−
1500−#if FF_API_AVSTREAM_SIDE_DATA
1501− if (sti->inject_global_side_data) {
1502− for (int i = 0; i < st->codecpar->nb_coded_side_data; i++) {
1503− const AVPacketSideData *const src_sd = &st->codecpar->coded_side_data[i];
1504− uint8_t *dst_data;
1505−
1506− if (av_packet_get_side_data(pkt, src_sd->type, NULL))
1507− continue;
1508−
1509− dst_data = av_packet_new_side_data(pkt, src_sd->type, src_sd->size);
1510− if (!dst_data) {
1511− av_log(s, AV_LOG_WARNING, "Could not inject global side data\n");
1512− continue;
1513− }
1514−
1515− memcpy(dst_data, src_sd->data, src_sd->size);
1516− }
1517− sti->inject_global_side_data = 0;
1518− }
1519−#endif
15201499 }
15211500
15221501 if (!fci->metafree) {
@@ -3075,31 +3054,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 1552 unmodified lines
30753054 }
30763055
30773056 sti->avctx_inited = 0;
3078−#if FF_API_AVSTREAM_SIDE_DATA
3079−FF_DISABLE_DEPRECATION_WARNINGS
3080− if (st->codecpar->nb_coded_side_data > 0) {
3081− av_assert0(!st->side_data && !st->nb_side_data);
3082− st->side_data = av_calloc(st->codecpar->nb_coded_side_data, sizeof(*st->side_data));
3083− if (!st->side_data) {
3084− ret = AVERROR(ENOMEM);
3085− goto find_stream_info_err;
3086− }
3087−
3088− for (int j = 0; j < st->codecpar->nb_coded_side_data; j++) {
3089− uint8_t *data = av_memdup(st->codecpar->coded_side_data[j].data,
3090− st->codecpar->coded_side_data[j].size);
3091− if (!data) {
3092− ret = AVERROR(ENOMEM);
3093− goto find_stream_info_err;
3094− }
3095− st->side_data[j].type = st->codecpar->coded_side_data[j].type;
3096− st->side_data[j].size = st->codecpar->coded_side_data[j].size;
3097− st->side_data[j].data = data;
3098− st->nb_side_data++;
3099− }
3100− }
3101−FF_ENABLE_DEPRECATION_WARNINGS
3102−#endif
31033057 }
31043058
31053059 find_stream_info_err:
libavformat/demux_utils.c+0−12
@@ -81,18 +81,6 @@ AVChapter *avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_ba · 80 unmodified lines
8181 return chapter;
8282 }
8383
84−#if FF_API_AVSTREAM_SIDE_DATA
85−void av_format_inject_global_side_data(AVFormatContext *s)
86−{
87− FFFormatContext *const si = ffformatcontext(s);
88− si->inject_global_side_data = 1;
89− for (unsigned i = 0; i < s->nb_streams; i++) {
90− AVStream *st = s->streams[i];
91− ffstream(st)->inject_global_side_data = 1;
92− }
93−}
94−#endif
95−
9684 int avformat_queue_attached_pictures(AVFormatContext *s)
9785 {
9886 FormatContextInternal *const fci = ff_fc_internal(s);
libavformat/internal.h+0−11
@@ -110,10 +110,6 @@ typedef struct FFFormatContext { · 109 unmodified lines
110110 */
111111 AVPacket *pkt;
112112
113−#if FF_API_AVSTREAM_SIDE_DATA
114− int inject_global_side_data;
115−#endif
116−
117113 int avoid_negative_ts_use_pts;
118114
119115 /**
@@ -292,13 +288,6 @@ typedef struct FFStream { · 172 unmodified lines
292288 uint8_t dts_ordered;
293289 uint8_t dts_misordered;
294290
295−#if FF_API_AVSTREAM_SIDE_DATA
296− /**
297− * Internal data to inject global side data
298− */
299− int inject_global_side_data;
300−#endif
301−
302291 /**
303292 * display aspect ratio (0 if unknown)
304293 * - encoding: unused
libavformat/mux.c+0−22
@@ -295,27 +295,6 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options) · 294 unmodified lines
295295 }
296296 }
297297
298−#if FF_API_AVSTREAM_SIDE_DATA
299−FF_DISABLE_DEPRECATION_WARNINGS
300− /* if the caller is using the deprecated AVStream side_data API,
301− * copy its contents to AVStream.codecpar, giving it priority
302− over existing side data in the latter */
303− for (int i = 0; i < st->nb_side_data; i++) {
304− const AVPacketSideData *sd_src = &st->side_data[i];
305− AVPacketSideData *sd_dst;
306−
307− sd_dst = av_packet_side_data_new(&st->codecpar->coded_side_data,
308− &st->codecpar->nb_coded_side_data,
309− sd_src->type, sd_src->size, 0);
310− if (!sd_dst) {
311− ret = AVERROR(ENOMEM);
312− goto fail;
313− }
314− memcpy(sd_dst->data, sd_src->data, sd_src->size);
315− }
316−FF_ENABLE_DEPRECATION_WARNINGS
317−#endif
318−
319298 desc = avcodec_descriptor_get(par->codec_id);
320299 if (desc && desc->props & AV_CODEC_PROP_REORDER)
321300 sti->reorder = 1;
@@ -965,7 +944,6 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 643 unmodified lines
965944 int stream_count = 0;
966945 int noninterleaved_count = 0;
967946 int ret;
968− int eof = flush;
969947
970948 if (has_packet) {
971949 if ((ret = ff_interleave_add_packet(s, pkt, interleave_compare_dts)) < 0)
libavformat/options.c+0−5
@@ -250,7 +250,6 @@ const AVClass *av_stream_get_class(void) · 249 unmodified lines
250250
251251 AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
252252 {
253− FFFormatContext *const si = ffformatcontext(s);
254253 FFStream *sti;
255254 AVStream *st;
256255 AVStream **streams;
@@ -322,10 +321,6 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c) · 65 unmodified lines
322321 sti->transferred_mux_tb = (AVRational) { 0, 1 };;
323322 #endif
324323
325−#if FF_API_AVSTREAM_SIDE_DATA
326− sti->inject_global_side_data = si->inject_global_side_data;
327−#endif
328−
329324 sti->need_context_update = 1;
330325
331326 s->streams[s->nb_streams++] = st;
libavformat/seek.c+0−7
@@ -715,8 +715,6 @@ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, · 714 unmodified lines
715715 /** Flush the frame reader. */
716716 void ff_read_frame_flush(AVFormatContext *s)
717717 {
718− FFFormatContext *const si = ffformatcontext(s);
719−
720718 ff_flush_packet_queue(s);
721719
722720 /* Reset read state for each stream. */
@@ -741,11 +739,6 @@ void ff_read_frame_flush(AVFormatContext *s) · 18 unmodified lines
741739 for (int j = 0; j < MAX_REORDER_DELAY + 1; j++)
742740 sti->pts_buffer[j] = AV_NOPTS_VALUE;
743741
744−#if FF_API_AVSTREAM_SIDE_DATA
745− if (si->inject_global_side_data)
746− sti->inject_global_side_data = 1;
747−#endif
748−
749742 sti->skip_samples = 0;
750743 }
751744 }
libavformat/version_major.h+0−1
@@ -42,7 +42,6 @@ · 41 unmodified lines
4242 *
4343 */
4444 #define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 62)
45−#define FF_API_AVSTREAM_SIDE_DATA (LIBAVFORMAT_VERSION_MAJOR < 62)
4645
4746 #define FF_API_GET_DUR_ESTIMATE_METHOD (LIBAVFORMAT_VERSION_MAJOR < 62)
4847 #define FF_API_INTERNAL_TIMING (LIBAVFORMAT_VERSION_MAJOR < 62)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t