Same rationale as with packet side data, it was never meant to do otherwise
as av_frame_get_side_data returns the first entry it finds of a given type.

Based on code from libavformat's av_stream_add_side_data().

Signed-off-by: James Almer <jamr...@gmail.com>
---
 libavutil/frame.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libavutil/frame.c b/libavutil/frame.c
index 24d5d5f184..c41d4be8cc 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -638,10 +638,24 @@ static AVFrameSideData *frame_new_side_data(AVFrame 
*frame,
                                             AVBufferRef *buf)
 {
     AVFrameSideData *ret, **tmp;
+    int i;
 
     if (!buf)
         return NULL;
 
+    for (i = 0; i < frame->nb_side_data; i++) {
+        AVFrameSideData *sd = frame->side_data[i];
+
+        if (sd->type == type) {
+            av_buffer_unref(&sd->buf);
+            av_dict_free(&sd->metadata);
+            sd->buf  = buf;
+            sd->data = sd->buf->data;
+            sd->size = buf->size;
+            return sd;
+        }
+    }
+
     if (frame->nb_side_data > INT_MAX / sizeof(*frame->side_data) - 1)
         goto fail;
 
-- 
2.13.3

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to