[FFmpeg-devel] [PATCH 16/18] avcodec/pthread_slice: Combine allocating and zeroing entries

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Fri Jul 1 01:29:47 EEST 2022


Actually, ff_slice_thread_allocz_entries() always already
allocates zeroed entries, so ff_reset_entries() was already
unnecessary. Make this more clear by renaming it to
ff_slice_thread_allocz_entries().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/hevcdec.c       | 3 +--
 libavcodec/pthread_slice.c | 8 +-------
 libavcodec/thread.h        | 3 +--
 libavcodec/utils.c         | 6 +-----
 4 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 5215f06e31..e2568c04c0 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -2698,10 +2698,9 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal)
     }
 
     atomic_store(&s->wpp_err, 0);
-    res = ff_alloc_entries(s->avctx, s->sh.num_entry_point_offsets + 1);
+    res = ff_slice_thread_allocz_entries(s->avctx, s->sh.num_entry_point_offsets + 1);
     if (res < 0)
         goto error;
-    ff_reset_entries(s->avctx);
 
     for (i = 0; i <= s->sh.num_entry_point_offsets; i++) {
         ret[i] = 0;
diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c
index e34116116d..756cc59dbf 100644
--- a/libavcodec/pthread_slice.c
+++ b/libavcodec/pthread_slice.c
@@ -237,7 +237,7 @@ void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int
     pthread_mutex_unlock(&progress->mutex);
 }
 
-int ff_alloc_entries(AVCodecContext *avctx, int count)
+int ff_slice_thread_allocz_entries(AVCodecContext *avctx, int count)
 {
     if (avctx->active_thread_type & FF_THREAD_SLICE)  {
         SliceThreadContext *p = avctx->internal->thread_ctx;
@@ -256,9 +256,3 @@ int ff_alloc_entries(AVCodecContext *avctx, int count)
 
     return 0;
 }
-
-void ff_reset_entries(AVCodecContext *avctx)
-{
-    SliceThreadContext *p = avctx->internal->thread_ctx;
-    memset(p->entries, 0, p->entries_count * sizeof(int));
-}
diff --git a/libavcodec/thread.h b/libavcodec/thread.h
index 92cbd927f1..d5673f25ea 100644
--- a/libavcodec/thread.h
+++ b/libavcodec/thread.h
@@ -104,8 +104,7 @@ int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx,
         int (*action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr),
         int (*main_func)(AVCodecContext *c), void *arg, int *ret, int job_count);
 void ff_thread_free(AVCodecContext *s);
-int ff_alloc_entries(AVCodecContext *avctx, int count);
-void ff_reset_entries(AVCodecContext *avctx);
+int ff_slice_thread_allocz_entries(AVCodecContext *avctx, int count);
 int ff_slice_thread_init_progress(AVCodecContext *avctx);
 void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n);
 void ff_thread_await_progress2(AVCodecContext *avctx,  int field, int thread, int shift);
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index f78475d0ad..cae61d80ff 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -963,15 +963,11 @@ int ff_slice_thread_init_progress(AVCodecContext *avctx)
     return 0;
 }
 
-int ff_alloc_entries(AVCodecContext *avctx, int count)
+int ff_slice_thread_allocz_entries(AVCodecContext *avctx, int count)
 {
     return 0;
 }
 
-void ff_reset_entries(AVCodecContext *avctx)
-{
-}
-
 void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift)
 {
 }
-- 
2.34.1



More information about the ffmpeg-devel mailing list