[FFmpeg-devel] [PATCH] lavfi/zscale: fix tmp buffer ptr alignment for zimg_filter_graph_process (v2)

James Almer jamrial at gmail.com
Sat Nov 9 19:25:40 EET 2024


On 11/9/2024 2:05 PM, Pavel Koshevoy wrote:
> ---
>   libavfilter/vf_zscale.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
> index 4ba059064b..07e295652d 100644
> --- a/libavfilter/vf_zscale.c
> +++ b/libavfilter/vf_zscale.c
> @@ -630,7 +630,7 @@ static int graphs_build(AVFrame *in, AVFrame *out, const AVPixFmtDescriptor *des
>   
>       if (s->tmp[job_nr])
>           av_freep(&s->tmp[job_nr]);
> -    s->tmp[job_nr] = av_calloc(size, 1);
> +    s->tmp[job_nr] = av_calloc(size + ZIMG_ALIGNMENT - 1, 1);
>       if (!s->tmp[job_nr])
>           return AVERROR(ENOMEM);
>   
> @@ -750,7 +750,9 @@ static int filter_slice(AVFilterContext *ctx, void *data, int job_nr, int n_jobs
>       }
>       if (!s->graph[job_nr])
>           return AVERROR(EINVAL);
> -    ret = zimg_filter_graph_process(s->graph[job_nr], &src_buf, &dst_buf, s->tmp[job_nr], 0, 0, 0, 0);
> +    ret = zimg_filter_graph_process(s->graph[job_nr], &src_buf, &dst_buf,
> +                                    (uint8_t *)FFALIGN((uintptr_t)s->tmp[job_nr], ZIMG_ALIGNMENT),
> +                                    0, 0, 0, 0);
>       if (ret)
>           return print_zimg_error(ctx);
>   
> @@ -765,7 +767,9 @@ static int filter_slice(AVFilterContext *ctx, void *data, int job_nr, int n_jobs
>   
>           if (!s->alpha_graph[job_nr])
>               return AVERROR(EINVAL);
> -        ret = zimg_filter_graph_process(s->alpha_graph[job_nr], &src_buf, &dst_buf, s->tmp[job_nr], 0, 0, 0, 0);
> +        ret = zimg_filter_graph_process(s->alpha_graph[job_nr], &src_buf, &dst_buf,
> +                                        (uint8_t *)FFALIGN((uintptr_t)s->tmp[job_nr], ZIMG_ALIGNMENT),
> +                                        0, 0, 0, 0);
>           if (ret)
>               return print_zimg_error(ctx);
>       }

Should be ok. Will push soon unless there are objections.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241109/7ef11494/attachment.sig>


More information about the ffmpeg-devel mailing list