ffmpeg: add handling for nv21 and yuv420p

This commit is contained in:
Joo Aun Saw 2019-08-19 16:58:52 +10:00
parent 79c4368009
commit ef90015cac

View File

@ -0,0 +1,41 @@
commit 0550486542f4c4628abf9e5cf1090c8f328f215f
Author: Dave Stevenson <dave.stevenson@raspberrypi.org>
Date: Thu Mar 22 16:01:35 2018 +0000
v4l2_buffers: Add handling for NV21 and YUV420P
diff --git a/libavcodec/v4l2_buffers.c b/libavcodec/v4l2_buffers.c
index aef911f..0f4dbb2 100644
--- a/libavcodec/v4l2_buffers.c
+++ b/libavcodec/v4l2_buffers.c
@@ -321,11 +321,21 @@ int ff_v4l2_buffer_buf_to_avframe(AVFrame *frame, V4L2Buffer *avbuf)
/* 1.1 fixup special cases */
switch (avbuf->context->av_pix_fmt) {
case AV_PIX_FMT_NV12:
+ case AV_PIX_FMT_NV21:
if (avbuf->num_planes > 1)
break;
frame->linesize[1] = avbuf->plane_info[0].bytesperline;
frame->data[1] = frame->buf[0]->data + avbuf->plane_info[0].bytesperline * avbuf->context->format.fmt.pix_mp.height;
break;
+ case AV_PIX_FMT_YUV420P:
+ /* No YV12? support? */
+ if (avbuf->num_planes > 1)
+ break;
+ frame->linesize[1] = avbuf->plane_info[0].bytesperline >> 1;
+ frame->linesize[2] = avbuf->plane_info[0].bytesperline >> 1;
+ frame->data[1] = frame->buf[0]->data + avbuf->plane_info[0].bytesperline * avbuf->context->format.fmt.pix_mp.height;
+ frame->data[2] = frame->data[1] + ((avbuf->plane_info[0].bytesperline * avbuf->context->format.fmt.pix_mp.height) >> 2);
+ break;
default:
break;
}
@@ -468,6 +478,7 @@ int ff_v4l2_buffer_enqueue(V4L2Buffer* avbuf)
avbuf->buf.flags = avbuf->flags;
+ av_log(NULL, AV_LOG_ERROR, "ff_v4l2_buffer_enqueue: VIDIOC_QBUF : fd %d, index %u type %u\n", buf_to_m2mctx(avbuf)->fd, avbuf->buf.index, avbuf->buf.type);
ret = ioctl(buf_to_m2mctx(avbuf)->fd, VIDIOC_QBUF, &avbuf->buf);
if (ret < 0)
return AVERROR(errno);