summaryrefslogtreecommitdiff
path: root/libavformat/mux.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/mux.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/mux.c')
-rw-r--r--libavformat/mux.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 5a1d6e41cb..c7877c5d98 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -279,6 +279,27 @@ FF_ENABLE_DEPRECATION_WARNINGS
break;
}
+#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;