diff mbox

[FFmpeg-devel] avcodec/h264_slice: fix access to atomic error_count

Message ID 20180311224958.11642-1-ffmpeg@tmm1.net
State New
Headers show

Commit Message

Aman Karmani March 11, 2018, 10:49 p.m. UTC
From: Aman Gupta <aman@tmm1.net>

---
 libavcodec/h264_slice.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 90e05ed8f1..d0f38783ee 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;
+                atomic_init(&sl->er.error_count, 0);
             }
 
             /* make sure none of those slices overlap */
@@ -2786,7 +2786,7 @@  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) {