diff mbox series

[FFmpeg-devel,v2,09/27] avcodec/vp9: Replace atomic_store() by atomic_init()

Message ID GV1P250MB0737C6713DD57425B4A70F328F002@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel,v2,01/27] avcodec/threadprogress: Add new API for frame-threaded progress | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt April 8, 2024, 8:13 p.m. UTC
This part of the code is not slice-threaded and they are
semantically an initialization, so use atomic_init()
instead of the potentially expensive atomic_store()
(which uses sequentially consistent memory ordering).

Also remove the initial initialization directly after
allocating this array.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/vp9.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 443eb74c3c..3adfb98f2d 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -55,7 +55,6 @@  DEFINE_OFFSET_ARRAY(VP9Context, vp9_context, pthread_init_cnt,
 
 static int vp9_alloc_entries(AVCodecContext *avctx, int n) {
     VP9Context *s = avctx->priv_data;
-    int i;
 
     if (avctx->active_thread_type & FF_THREAD_SLICE)  {
         if (s->entries)
@@ -64,9 +63,6 @@  static int vp9_alloc_entries(AVCodecContext *avctx, int n) {
         s->entries = av_malloc_array(n, sizeof(atomic_int));
         if (!s->entries)
             return AVERROR(ENOMEM);
-
-        for (i  = 0; i < n; i++)
-            atomic_init(&s->entries[i], 0);
     }
     return 0;
 }
@@ -1661,7 +1657,7 @@  static int vp9_decode_frame(AVCodecContext *avctx, AVFrame *frame,
 #if HAVE_THREADS
     if (avctx->active_thread_type & FF_THREAD_SLICE) {
         for (i = 0; i < s->sb_rows; i++)
-            atomic_store(&s->entries[i], 0);
+            atomic_init(&s->entries[i], 0);
     }
 #endif