[FFmpeg-cvslog] fftools/ffmpeg_dec: don't try to copy side data from the decoder if it already exists in the output frame

James Almer git at videolan.org
Wed Feb 26 01:00:41 EET 2025


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sun Feb 23 23:57:44 2025 -0300| [8e6032990cdad1d8455ffd24d4fec20fcc78a3e2] | committer: James Almer

fftools/ffmpeg_dec: don't try to copy side data from the decoder if it already exists in the output frame

We can't use AV_FRAME_SIDE_DATA_FLAG_REPLACE here because the side data already in the
frame should have priority over the global one, so just ensure we don't copy any if
it already exists.

Fixes ticket #11468.

Signed-off-by: James Almer <jamrial at gmail.com>

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

 fftools/ffmpeg_dec.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 84ba5c6d5d..01a6933bcc 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -788,10 +788,14 @@ static int packet_decode(DecoderPriv *dp, AVPacket *pkt, AVFrame *frame)
 
         frame->time_base = dec->pkt_timebase;
 
-        ret = clone_side_data(&frame->side_data, &frame->nb_side_data,
-                              dec->decoded_side_data, dec->nb_decoded_side_data, 0);
-        if (ret < 0)
-            return ret;
+        for (int i = 0; i < dec->nb_decoded_side_data; i++) {
+            const AVFrameSideData *src = dec->decoded_side_data[i];
+            if (av_frame_side_data_get(frame->side_data, frame->nb_side_data, src->type))
+                continue;
+            ret = av_frame_side_data_clone(&frame->side_data, &frame->nb_side_data, src, 0);
+            if (ret < 0)
+                return ret;
+        }
 
         if (dec->codec_type == AVMEDIA_TYPE_AUDIO) {
             dp->dec.samples_decoded += frame->nb_samples;



More information about the ffmpeg-cvslog mailing list