[FFmpeg-devel] [PATCH] lavu/get_video_buffer: also align data pointers

James Almer jamrial at gmail.com
Sat Nov 9 19:27:33 EET 2024


On 11/9/2024 1:57 PM, Pavel Koshevoy wrote:
> This avoids unpleasant surprises to av_frame_get_buffer callers
> that explicitly specified 64-byte alignment and didn't get
> AVFrame.data pointers that are 64-byte aligned.

Again, the doxy is clear that only the buffer sizes are aligned, not the 
pointers. I'd rather not make this change here. Please see 
https://ffmpeg.org//pipermail/ffmpeg-devel/2024-November/335811.html

> 
> In particular, this fixes an issue in vf_zscale.
> https://github.com/sekrit-twc/zimg/issues/212
> ---
>   libavutil/frame.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index f0a0dba018..7faf7aeae8 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -216,6 +216,7 @@ static int get_video_buffer(AVFrame *frame, int align)
>           total_size += sizes[i];
>       }
>   
> +    total_size += align - 1;
>       frame->buf[0] = av_buffer_alloc(total_size);
>       if (!frame->buf[0]) {
>           ret = AVERROR(ENOMEM);
> @@ -223,7 +224,8 @@ static int get_video_buffer(AVFrame *frame, int align)
>       }
>   
>       if ((ret = av_image_fill_pointers(frame->data, frame->format, padded_height,
> -                                      frame->buf[0]->data, frame->linesize)) < 0)
> +                                      (uint8_t *)FFALIGN((uintptr_t)frame->buf[0]->data, align),
> +                                      frame->linesize)) < 0)
>           goto fail;
>   
>       for (int i = 1; i < 4; i++) {

-------------- 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/7eb1151d/attachment.sig>


More information about the ffmpeg-devel mailing list