ffmpeg | branch: master | Anton Khirnov <an...@khirnov.net> | Fri Mar 22 
20:49:33 2024 +0100| [e0de84ad2e25632b9a2f402f9e71a222c00567bb] | committer: 
Anton Khirnov

lavc/encode: map AVCodecContext.decoded_side_data to coded_side_data

This way it can be automagically propagated through the encoder to
muxing.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e0de84ad2e25632b9a2f402f9e71a222c00567bb
---

 libavcodec/encode.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/libavcodec/encode.c b/libavcodec/encode.c
index 7fc9737e93..46e46a055e 100644
--- a/libavcodec/encode.c
+++ b/libavcodec/encode.c
@@ -782,6 +782,29 @@ int ff_encode_preinit(AVCodecContext *avctx)
             return AVERROR(ENOMEM);
     }
 
+    for (int i = 0; ff_sd_global_map[i].packet < AV_PKT_DATA_NB; i++) {
+        const enum AVPacketSideDataType type_packet = 
ff_sd_global_map[i].packet;
+        const enum AVFrameSideDataType  type_frame  = 
ff_sd_global_map[i].frame;
+        const AVFrameSideData *sd_frame;
+        AVPacketSideData      *sd_packet;
+
+        sd_frame = av_frame_side_data_get(avctx->decoded_side_data,
+                                          avctx->nb_decoded_side_data,
+                                          type_frame);
+        if (!sd_frame ||
+            av_packet_side_data_get(avctx->coded_side_data, 
avctx->nb_coded_side_data,
+                                    type_packet))
+
+            continue;
+
+        sd_packet = av_packet_side_data_new(&avctx->coded_side_data, 
&avctx->nb_coded_side_data,
+                                            type_packet, sd_frame->size, 0);
+        if (!sd_packet)
+            return AVERROR(ENOMEM);
+
+        memcpy(sd_packet->data, sd_frame->data, sd_frame->size);
+    }
+
     if (CONFIG_FRAME_THREAD_ENCODER) {
         ret = ff_frame_thread_encoder_init(avctx);
         if (ret < 0)

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to