Commit 8822e2b9 authored by James Almer's avatar James Almer

Merge commit 'f89ec87a'

* commit 'f89ec87a':
  frame: Simplify the video allocation
Merged-by: 's avatarJames Almer <jamrial@gmail.com>
Padding-Remixed-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parents 44ee858b f89ec87a
...@@ -211,7 +211,8 @@ void av_frame_free(AVFrame **frame) ...@@ -211,7 +211,8 @@ void av_frame_free(AVFrame **frame)
static int get_video_buffer(AVFrame *frame, int align) static int get_video_buffer(AVFrame *frame, int align)
{ {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
int ret, i; int ret, i, padded_height;
int plane_padding = FFMAX(16 + 16/*STRIDE_ALIGN*/, align);
if (!desc) if (!desc)
return AVERROR(EINVAL); return AVERROR(EINVAL);
...@@ -236,23 +237,22 @@ static int get_video_buffer(AVFrame *frame, int align) ...@@ -236,23 +237,22 @@ static int get_video_buffer(AVFrame *frame, int align)
frame->linesize[i] = FFALIGN(frame->linesize[i], align); frame->linesize[i] = FFALIGN(frame->linesize[i], align);
} }
for (i = 0; i < 4 && frame->linesize[i]; i++) { padded_height = FFALIGN(frame->height, 32);
int h = FFALIGN(frame->height, 32); if ((ret = av_image_fill_pointers(frame->data, frame->format, padded_height,
if (i == 1 || i == 2) NULL, frame->linesize)) < 0)
h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h); return ret;
frame->buf[i] = av_buffer_alloc(frame->linesize[i] * h + 16 + 16/*STRIDE_ALIGN*/ - 1); frame->buf[0] = av_buffer_alloc(ret + 4*plane_padding);
if (!frame->buf[i]) if (!frame->buf[0])
goto fail; goto fail;
frame->data[i] = frame->buf[i]->data; if (av_image_fill_pointers(frame->data, frame->format, padded_height,
} frame->buf[0]->data, frame->linesize) < 0)
if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & FF_PSEUDOPAL) { goto fail;
av_buffer_unref(&frame->buf[1]);
frame->buf[1] = av_buffer_alloc(AVPALETTE_SIZE); for (i = 1; i < 4; i++) {
if (!frame->buf[1]) if (frame->data[i])
goto fail; frame->data[i] += i * plane_padding;
frame->data[1] = frame->buf[1]->data;
} }
frame->extended_data = frame->data; frame->extended_data = frame->data;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment