[FFmpeg-devel] [PATCH] lavu/get_video_buffer: also align data pointers
Pavel Koshevoy
pkoshevoy at gmail.com
Sat Nov 9 19:34:30 EET 2024
On Sat, Nov 9, 2024 at 10:27 AM James Almer <jamrial at gmail.com> wrote:
> 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
>
>
So if we update the doxy then the change will be accepted?
I don't understand the reluctance to improve the behavior of this API.
> >
> > 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++) {
>
> _______________________________________________
> 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