[FFmpeg-devel] [PATCH 17/18] avcodec/pthread_slice: Reuse buffer if possible

Paul B Mahol onemda at gmail.com
Fri Jul 1 14:33:51 EEST 2022


On Fri, Jul 1, 2022 at 12:32 AM Andreas Rheinhardt <
andreas.rheinhardt at outlook.com> wrote:

> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  libavcodec/pthread_slice.c | 6 ++++--
>  1 file 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) {
> --
> 2.34.1
>
>
LGTM

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-devel mailing list