summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2018-07-27 08:34:08 +0200
committerLuca Barbato <lu_zero@gentoo.org>2018-08-05 22:45:08 +0200
commitf89ec87afaf0d1abb6d450253b0b348fd554533b (patch)
tree07bd5e8f2ed484d864e3901b191d470b7700f4e7
parente1e3a12242347dd11174b2fb9ddac8dc8df16224 (diff)
downloadffmpeg-streaming-f89ec87afaf0d1abb6d450253b0b348fd554533b.zip
ffmpeg-streaming-f89ec87afaf0d1abb6d450253b0b348fd554533b.tar.gz
frame: Simplify the video allocation
-rw-r--r--libavutil/frame.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/libavutil/frame.c b/libavutil/frame.c
index db3897c..fa62459 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -89,12 +89,8 @@ void av_frame_free(AVFrame **frame)
static int get_video_buffer(AVFrame *frame, int align)
{
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
int ret, i;
- if (!desc)
- return AVERROR(EINVAL);
-
if ((ret = av_image_check_size(frame->width, frame->height, 0, NULL)) < 0)
return ret;
@@ -111,24 +107,17 @@ static int get_video_buffer(AVFrame *frame, int align)
frame->linesize[i] = FFALIGN(frame->linesize[i], align);
}
- for (i = 0; i < 4 && frame->linesize[i]; i++) {
- int h = frame->height;
- if (i == 1 || i == 2)
- h = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
+ if ((ret = av_image_fill_pointers(frame->data, frame->format, frame->height,
+ NULL, frame->linesize)) < 0)
+ return ret;
- frame->buf[i] = av_buffer_alloc(frame->linesize[i] * h);
- if (!frame->buf[i])
- goto fail;
+ frame->buf[0] = av_buffer_alloc(ret);
+ if (!frame->buf[0])
+ goto fail;
- frame->data[i] = frame->buf[i]->data;
- }
- if (desc->flags & AV_PIX_FMT_FLAG_PAL || desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) {
- av_buffer_unref(&frame->buf[1]);
- frame->buf[1] = av_buffer_alloc(1024);
- if (!frame->buf[1])
- goto fail;
- frame->data[1] = frame->buf[1]->data;
- }
+ if (av_image_fill_pointers(frame->data, frame->format, frame->height,
+ frame->buf[0]->data, frame->linesize) < 0)
+ goto fail;
frame->extended_data = frame->data;
OpenPOWER on IntegriCloud