mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/libdav1d: use av_image_get_buffer_size() to calculate frame size
Calling av_image_fill_arrays() with NULL as src argument may result in UB. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
c40d36076a
commit
5eb4405fc5
|
@ -66,12 +66,11 @@ static int libdav1d_picture_allocator(Dav1dPicture *p, void *cookie)
|
||||||
{
|
{
|
||||||
Libdav1dContext *dav1d = cookie;
|
Libdav1dContext *dav1d = cookie;
|
||||||
enum AVPixelFormat format = pix_fmt[p->p.layout][p->seq_hdr->hbd];
|
enum AVPixelFormat format = pix_fmt[p->p.layout][p->seq_hdr->hbd];
|
||||||
int ret, linesize[4], h = FFALIGN(p->p.h, 128);
|
int ret, linesize[4], h = FFALIGN(p->p.h, 128), w = FFALIGN(p->p.w, 128);
|
||||||
uint8_t *aligned_ptr, *data[4];
|
uint8_t *aligned_ptr, *data[4];
|
||||||
AVBufferRef *buf;
|
AVBufferRef *buf;
|
||||||
|
|
||||||
ret = av_image_fill_arrays(data, linesize, NULL, format, FFALIGN(p->p.w, 128),
|
ret = av_image_get_buffer_size(format, w, h, DAV1D_PICTURE_ALIGNMENT);
|
||||||
h, DAV1D_PICTURE_ALIGNMENT);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -94,7 +93,8 @@ static int libdav1d_picture_allocator(Dav1dPicture *p, void *cookie)
|
||||||
// Use the extra DAV1D_PICTURE_ALIGNMENT padding bytes in the buffer to align it
|
// Use the extra DAV1D_PICTURE_ALIGNMENT padding bytes in the buffer to align it
|
||||||
// if required.
|
// if required.
|
||||||
aligned_ptr = (uint8_t *)FFALIGN((uintptr_t)buf->data, DAV1D_PICTURE_ALIGNMENT);
|
aligned_ptr = (uint8_t *)FFALIGN((uintptr_t)buf->data, DAV1D_PICTURE_ALIGNMENT);
|
||||||
ret = av_image_fill_pointers(data, format, h, aligned_ptr, linesize);
|
ret = av_image_fill_arrays(data, linesize, aligned_ptr, format, w, h,
|
||||||
|
DAV1D_PICTURE_ALIGNMENT);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_buffer_unref(&buf);
|
av_buffer_unref(&buf);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue