diff mbox series

[FFmpeg-devel] avcodec/h264_slice: sync User Data Unregistered SEI buffers across threads

Message ID 20200917164304.6469-1-jamrial@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel] avcodec/h264_slice: sync User Data Unregistered SEI buffers across threads
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

James Almer Sept. 17, 2020, 4:43 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/h264_slice.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index cfc29e186c..bb95a92792 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -439,6 +439,25 @@  int ff_h264_update_thread_context(AVCodecContext *dst,
             return AVERROR(ENOMEM);
     }
 
+    for (i = 0; i < h->sei.unregistered.nb_buf_ref; i++)
+        av_buffer_unref(&h->sei.unregistered.buf_ref[i]);
+    h->sei.unregistered.nb_buf_ref = 0;
+
+    if (h1->sei.unregistered.nb_buf_ref) {
+        ret = av_reallocp_array(&h->sei.unregistered.buf_ref,
+                                h1->sei.unregistered.nb_buf_ref,
+                                sizeof(*h1->sei.unregistered.buf_ref));
+        if (ret < 0)
+            return ret;
+
+        for (i = 0; i < h1->sei.unregistered.nb_buf_ref; i++) {
+            h->sei.unregistered.buf_ref[i] = av_buffer_ref(h1->sei.unregistered.buf_ref[i]);
+            if (!h->sei.unregistered.buf_ref[i])
+                return AVERROR(ENOMEM);
+            h->sei.unregistered.nb_buf_ref++;
+        }
+    }
+
     if (!h->cur_pic_ptr)
         return 0;