summaryrefslogtreecommitdiff
path: root/libavformat/avformat.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2023-07-16 17:57:26 -0300
committerJames Almer <jamrial@gmail.com>2023-10-06 10:03:57 -0300
commit5432d2aacad5fa7420fe2d9369ed061d521e92d6 (patch)
tree9c1bf0307108a16ed652261d590042e5944e288d /libavformat/avformat.c
parent21d7cc6fa9a26e94965fa71b25655d07568450fe (diff)
avformat/avformat: use the side data from AVStream.codecpar
Deprecate AVStream.side_data and its helpers in favor of the AVStream's codecpar.coded_side_data. This will considerably simplify the propagation of global side data to decoders and from encoders. Instead of having to do it inside packets, it will be available during init(). Global and frame specific side data will therefore be distinct. Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/avformat.c')
-rw-r--r--libavformat/avformat.c42
1 files changed, 8 insertions, 34 deletions
diff --git a/libavformat/avformat.c b/libavformat/avformat.c
index 7ff0cf3429..5b8bb7879e 100644
--- a/libavformat/avformat.c
+++ b/libavformat/avformat.c
@@ -48,9 +48,13 @@ 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);
@@ -140,6 +144,8 @@ 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)
{
@@ -207,36 +213,8 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
return data;
}
-
-int ff_stream_side_data_copy(AVStream *dst, const AVStream *src)
-{
- /* Free existing side data*/
- for (int i = 0; i < dst->nb_side_data; i++)
- av_free(dst->side_data[i].data);
- av_freep(&dst->side_data);
- dst->nb_side_data = 0;
-
- /* Copy side data if present */
- if (src->nb_side_data) {
- dst->side_data = av_calloc(src->nb_side_data,
- sizeof(*dst->side_data));
- if (!dst->side_data)
- return AVERROR(ENOMEM);
- dst->nb_side_data = src->nb_side_data;
-
- for (int i = 0; i < src->nb_side_data; i++) {
- uint8_t *data = av_memdup(src->side_data[i].data,
- src->side_data[i].size);
- if (!data)
- return AVERROR(ENOMEM);
- dst->side_data[i].type = src->side_data[i].type;
- dst->side_data[i].size = src->side_data[i].size;
- dst->side_data[i].data = data;
- }
- }
-
- return 0;
-}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
/**
* Copy all stream parameters from source to destination stream, with the
@@ -272,10 +250,6 @@ static int stream_params_copy(AVStream *dst, const AVStream *src)
if (ret < 0)
return ret;
- ret = ff_stream_side_data_copy(dst, src);
- if (ret < 0)
- return ret;
-
av_packet_unref(&dst->attached_pic);
if (src->attached_pic.data) {
ret = av_packet_ref(&dst->attached_pic, &src->attached_pic);