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
50 if (!st)50 if (!st)
51 return;51 return;
52 52
53#if FF_API_AVSTREAM_SIDE_DATA
54FF_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);
58FF_ENABLE_DEPRECATION_WARNINGS
59#endif
60
61 if (st->attached_pic.data)53 if (st->attached_pic.data)
62 av_packet_unref(&st->attached_pic);54 av_packet_unref(&st->attached_pic);
63 55
@@ -199,78 +191,6 @@ void avformat_free_context(AVFormatContext *s) · 135 unmodified lines
199 av_free(s);191 av_free(s);
200}192}
201 193
202#if FF_API_AVSTREAM_SIDE_DATA
203FF_DISABLE_DEPRECATION_WARNINGS
204uint8_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
219int 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
254uint8_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}
271FF_ENABLE_DEPRECATION_WARNINGS
272#endif
273
274/**194/**
275 * Copy all stream parameters from source to destination stream, with the195 * Copy all stream parameters from source to destination stream, with the
276 * exception of the index field, which is usually set by avformat_new_stream().196 * 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
844 */844 */
845 AVPacket attached_pic;845 AVPacket attached_pic;
846 846
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
879 /**847 /**
880 * Flags indicating events happening on the stream, a combination of848 * Flags indicating events happening on the stream, a combination of
881 * AVSTREAM_EVENT_FLAG_*.849 * AVSTREAM_EVENT_FLAG_*.
@@ -1923,26 +1891,6 @@ typedef struct AVFormatContext { · 1041 unmodified lines
1923 int64_t duration_probesize;1891 int64_t duration_probesize;
1924} AVFormatContext;1892} AVFormatContext;
1925 1893
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 */
1942attribute_deprecated
1943void av_format_inject_global_side_data(AVFormatContext *s);
1944#endif
1945
1946#if FF_API_GET_DUR_ESTIMATE_METHOD1894#if FF_API_GET_DUR_ESTIMATE_METHOD
1947/**1895/**
1948 * Returns the method used to set ctx->duration.1896 * 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
2131 */2079 */
2132int avformat_stream_group_add_stream(AVStreamGroup *stg, AVStream *st);2080int avformat_stream_group_add_stream(AVStreamGroup *stg, AVStream *st);
2133 2081
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 */
2150attribute_deprecated
2151int 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 */
2165attribute_deprecated
2166uint8_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 */
2180attribute_deprecated
2181uint8_t *av_stream_get_side_data(const AVStream *stream,
2182 enum AVPacketSideDataType type, size_t *size);
2183#endif
2184
2185AVProgram *av_new_program(AVFormatContext *s, int id);2082AVProgram *av_new_program(AVFormatContext *s, int id);
2186 2083
2187/**2084/**
libavformat/demux.c+0−46
@@ -1496,27 +1496,6 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 1495 unmodified lines
1496 }1496 }
1497 sti->skip_samples = 0;1497 sti->skip_samples = 0;
1498 }1498 }
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
1520 }1499 }
1521 1500
1522 if (!fci->metafree) {1501 if (!fci->metafree) {
@@ -3075,31 +3054,6 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) · 1552 unmodified lines
3075 }3054 }
3076 3055
3077 sti->avctx_inited = 0;3056 sti->avctx_inited = 0;
3078#if FF_API_AVSTREAM_SIDE_DATA
3079FF_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 }
3101FF_ENABLE_DEPRECATION_WARNINGS
3102#endif
3103 }3057 }
3104 3058
3105find_stream_info_err:3059find_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
81 return chapter;81 return chapter;
82}82}
83 83
84#if FF_API_AVSTREAM_SIDE_DATA
85void 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
96int avformat_queue_attached_pictures(AVFormatContext *s)84int avformat_queue_attached_pictures(AVFormatContext *s)
97{85{
98 FormatContextInternal *const fci = ff_fc_internal(s);86 FormatContextInternal *const fci = ff_fc_internal(s);
libavformat/internal.h+0−11
@@ -110,10 +110,6 @@ typedef struct FFFormatContext { · 109 unmodified lines
110 */110 */
111 AVPacket *pkt;111 AVPacket *pkt;
112 112
113#if FF_API_AVSTREAM_SIDE_DATA
114 int inject_global_side_data;
115#endif
116
117 int avoid_negative_ts_use_pts;113 int avoid_negative_ts_use_pts;
118 114
119 /**115 /**
@@ -292,13 +288,6 @@ typedef struct FFStream { · 172 unmodified lines
292 uint8_t dts_ordered;288 uint8_t dts_ordered;
293 uint8_t dts_misordered;289 uint8_t dts_misordered;
294 290
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
302 /**291 /**
303 * display aspect ratio (0 if unknown)292 * display aspect ratio (0 if unknown)
304 * - encoding: unused293 * - encoding: unused
libavformat/mux.c+0−22
@@ -295,27 +295,6 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options) · 294 unmodified lines
295 }295 }
296 }296 }
297 297
298#if FF_API_AVSTREAM_SIDE_DATA
299FF_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 }
316FF_ENABLE_DEPRECATION_WARNINGS
317#endif
318
319 desc = avcodec_descriptor_get(par->codec_id);298 desc = avcodec_descriptor_get(par->codec_id);
320 if (desc && desc->props & AV_CODEC_PROP_REORDER)299 if (desc && desc->props & AV_CODEC_PROP_REORDER)
321 sti->reorder = 1;300 sti->reorder = 1;
@@ -965,7 +944,6 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt, · 643 unmodified lines
965 int stream_count = 0;944 int stream_count = 0;
966 int noninterleaved_count = 0;945 int noninterleaved_count = 0;
967 int ret;946 int ret;
968 int eof = flush;
969 947
970 if (has_packet) {948 if (has_packet) {
971 if ((ret = ff_interleave_add_packet(s, pkt, interleave_compare_dts)) < 0)949 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
250 250
251AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)251AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
252{252{
253 FFFormatContext *const si = ffformatcontext(s);
254 FFStream *sti;253 FFStream *sti;
255 AVStream *st;254 AVStream *st;
256 AVStream **streams;255 AVStream **streams;
@@ -322,10 +321,6 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c) · 65 unmodified lines
322 sti->transferred_mux_tb = (AVRational) { 0, 1 };;321 sti->transferred_mux_tb = (AVRational) { 0, 1 };;
323#endif322#endif
324 323
325#if FF_API_AVSTREAM_SIDE_DATA
326 sti->inject_global_side_data = si->inject_global_side_data;
327#endif
328
329 sti->need_context_update = 1;324 sti->need_context_update = 1;
330 325
331 s->streams[s->nb_streams++] = st;326 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
715/** Flush the frame reader. */715/** Flush the frame reader. */
716void ff_read_frame_flush(AVFormatContext *s)716void ff_read_frame_flush(AVFormatContext *s)
717{717{
718 FFFormatContext *const si = ffformatcontext(s);
719
720 ff_flush_packet_queue(s);718 ff_flush_packet_queue(s);
721 719
722 /* Reset read state for each stream. */720 /* Reset read state for each stream. */
@@ -741,11 +739,6 @@ void ff_read_frame_flush(AVFormatContext *s) · 18 unmodified lines
741 for (int j = 0; j < MAX_REORDER_DELAY + 1; j++)739 for (int j = 0; j < MAX_REORDER_DELAY + 1; j++)
742 sti->pts_buffer[j] = AV_NOPTS_VALUE;740 sti->pts_buffer[j] = AV_NOPTS_VALUE;
743 741
744#if FF_API_AVSTREAM_SIDE_DATA
745 if (si->inject_global_side_data)
746 sti->inject_global_side_data = 1;
747#endif
748
749 sti->skip_samples = 0;742 sti->skip_samples = 0;
750 }743 }
751}744}
libavformat/version_major.h+0−1
@@ -42,7 +42,6 @@ · 41 unmodified lines
42 *42 *
43 */43 */
44#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 62)44#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 62)
45#define FF_API_AVSTREAM_SIDE_DATA (LIBAVFORMAT_VERSION_MAJOR < 62)
46 45
47#define FF_API_GET_DUR_ESTIMATE_METHOD (LIBAVFORMAT_VERSION_MAJOR < 62)46#define FF_API_GET_DUR_ESTIMATE_METHOD (LIBAVFORMAT_VERSION_MAJOR < 62)
48#define FF_API_INTERNAL_TIMING (LIBAVFORMAT_VERSION_MAJOR < 62)47#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