Re: [FFmpeg-devel] [PATCH] h264_slice: correct atomics usage

2018-03-11 Thread Aman Gupta
On Sun, Mar 11, 2018 at 4:01 PM, Rostislav Pehlivanov 
wrote:

> Reported by tmm1
>
> Signed-off-by: Rostislav Pehlivanov 
> ---
>  libavcodec/h264_slice.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> index 90e05ed8f1..b381397b4d 100644
> --- a/libavcodec/h264_slice.c
> +++ b/libavcodec/h264_slice.c
> @@ -2762,7 +2762,7 @@ int ff_h264_execute_decode_slices(H264Context *h)
>
>  sl = &h->slice_ctx[i];
>  if (CONFIG_ERROR_RESILIENCE) {
> -sl->er.error_count = 0;
> +sl->er.error_count = ATOMIC_VAR_INIT(0);
>  }
>
>  /* make sure none of those slices overlap */
> @@ -2786,7 +2786,8 @@ int ff_h264_execute_decode_slices(H264Context *h)
>  h->mb_y  = sl->mb_y;
>  if (CONFIG_ERROR_RESILIENCE) {
>  for (i = 1; i < context_count; i++)
> -h->slice_ctx[0].er.error_count +=
> h->slice_ctx[i].er.error_count;
> +atomic_fetch_add(&h->slice_ctx[0].er.error_count,
> + atomic_load(&h->slice_ctx[i].
> er.error_count));
>  }
>
>  if (h->postpone_filter) {
>

LGTM, thanks.


> --
> 2.16.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] h264_slice: correct atomics usage

2018-03-11 Thread Rostislav Pehlivanov
Reported by tmm1

Signed-off-by: Rostislav Pehlivanov 
---
 libavcodec/h264_slice.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 90e05ed8f1..b381397b4d 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -2762,7 +2762,7 @@ int ff_h264_execute_decode_slices(H264Context *h)
 
 sl = &h->slice_ctx[i];
 if (CONFIG_ERROR_RESILIENCE) {
-sl->er.error_count = 0;
+sl->er.error_count = ATOMIC_VAR_INIT(0);
 }
 
 /* make sure none of those slices overlap */
@@ -2786,7 +2786,8 @@ int ff_h264_execute_decode_slices(H264Context *h)
 h->mb_y  = sl->mb_y;
 if (CONFIG_ERROR_RESILIENCE) {
 for (i = 1; i < context_count; i++)
-h->slice_ctx[0].er.error_count += 
h->slice_ctx[i].er.error_count;
+atomic_fetch_add(&h->slice_ctx[0].er.error_count,
+ atomic_load(&h->slice_ctx[i].er.error_count));
 }
 
 if (h->postpone_filter) {
-- 
2.16.2

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