diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-06-30 20:36:53 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-07-25 23:35:22 +0200 |
commit | 571e4055dc241f8b4556a27b49691edc02edf10b (patch) | |
tree | e146d21f7059aa3ba9aa4c2c8a87d355bf796c93 | |
parent | b4ca3c7e4e4a098651f013b80d9d88cc1dc4d6b7 (diff) | |
download | ffmpeg-571e4055dc241f8b4556a27b49691edc02edf10b.tar.gz |
avcodec/pthread_slice: Reuse buffer if possible
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r-- | libavcodec/pthread_slice.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c index 756cc59dbf..a4d31c6f4d 100644 --- a/libavcodec/pthread_slice.c +++ b/libavcodec/pthread_slice.c @@ -242,9 +242,11 @@ int ff_slice_thread_allocz_entries(AVCodecContext *avctx, int count) if (avctx->active_thread_type & FF_THREAD_SLICE) { SliceThreadContext *p = avctx->internal->thread_ctx; - if (p->entries) { - av_freep(&p->entries); + if (p->entries_count == count) { + memset(p->entries, 0, p->entries_count * sizeof(*p->entries)); + return 0; } + av_freep(&p->entries); p->entries = av_calloc(count, sizeof(*p->entries)); if (!p->entries) { |