]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/v4l2_buffers: Add handling for NV21 and YUV420P
authorDave Stevenson <dave.stevenson@raspberrypi.org>
Thu, 22 Mar 2018 16:01:35 +0000 (16:01 +0000)
committerAman Gupta <aman@tmm1.net>
Wed, 11 Sep 2019 01:56:40 +0000 (18:56 -0700)
The single planar support was for NV12 only.
Add NV21 and YUV420P support.

Signed-off-by: Aman Gupta <aman@tmm1.net>
libavcodec/v4l2_buffers.c

index 51b0d25cad931ac99d8a1715b21d428ba65f874b..de72b7f80c78d3dadfdc2f9f15941bd484db7f33 100644 (file)
@@ -321,11 +321,20 @@ 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:
+        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;
     }