diff mbox series

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

Message ID 20200917170652.6524-1-jamrial@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,v2] 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, 5:06 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
Now it also updates the x264_build field.

 libavcodec/h264_slice.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

James Almer Sept. 21, 2020, 2:06 p.m. UTC | #1
On 9/17/2020 2:06 PM, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> Now it also updates the x264_build field.
> 
>  libavcodec/h264_slice.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> index cfc29e186c..f091cd4dc1 100644
> --- a/libavcodec/h264_slice.c
> +++ b/libavcodec/h264_slice.c
> @@ -439,6 +439,26 @@ 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++;
> +        }
> +    }
> +    h->sei.unregistered.x264_build = h1->sei.unregistered.x264_build;
> +
>      if (!h->cur_pic_ptr)
>          return 0;

Will apply soon.
diff mbox series

Patch

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index cfc29e186c..f091cd4dc1 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -439,6 +439,26 @@  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++;
+        }
+    }
+    h->sei.unregistered.x264_build = h1->sei.unregistered.x264_build;
+
     if (!h->cur_pic_ptr)
         return 0;