[{"id":5260,"web_url":"https://patchwork.libcamera.org/comment/5260/","msgid":"<20200617221812.GB32604@pendragon.ideasonboard.com>","date":"2020-06-17T22:18:12","subject":"Re: [libcamera-devel] [PATCH] libcamera: add support for planar\n\tYUV422 and YUV420 formats","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nOn Wed, Jun 17, 2020 at 05:44:42PM +0100, David Plowman wrote:\n> These formats can be helpful when downstream applications or libraries\n> support them natively (avoiding a costly conversion).\n\nBut only if cameras can provide them :-)\n\nDoes the Raspberry Pi ISP support both V4L2_PIX_FMT_YUV420 and\nV4L2_PIX_FMT_YUV422P ? I see mentions of the former in the driver, but\nnot of the latter.\n\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  src/libcamera/formats.cpp          | 14 ++++++++++++++\n>  src/libcamera/v4l2_pixelformat.cpp |  2 ++\n>  src/v4l2/v4l2_camera_proxy.cpp     |  2 ++\n>  3 files changed, 18 insertions(+)\n> \n> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> index 2ac3b41..dcd1dcf 100644\n> --- a/src/libcamera/formats.cpp\n> +++ b/src/libcamera/formats.cpp\n> @@ -268,6 +268,20 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n>  \t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n>  \t\t.packed = false,\n>  \t} },\n> +\t{ PixelFormat(DRM_FORMAT_YUV422), {\n> +\t\t.format = PixelFormat(DRM_FORMAT_YUV422),\n> +\t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV422P),\n> +\t\t.bitsPerPixel = 16,\n> +\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> +\t\t.packed = false,\n> +\t} },\n> +\t{ PixelFormat(DRM_FORMAT_YUV420), {\n> +\t\t.format = PixelFormat(DRM_FORMAT_YUV420),\n> +\t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV420),\n> +\t\t.bitsPerPixel = 12,\n> +\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> +\t\t.packed = false,\n> +\t} },\n>  \n>  \t/* Greyscale formats. */\n>  \t{ PixelFormat(DRM_FORMAT_R8), {\n> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp\n> index 94fae47..01778c0 100644\n> --- a/src/libcamera/v4l2_pixelformat.cpp\n> +++ b/src/libcamera/v4l2_pixelformat.cpp\n> @@ -64,6 +64,8 @@ const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{\n>  \t{ V4L2PixelFormat(V4L2_PIX_FMT_NV61), PixelFormat(DRM_FORMAT_NV61) },\n>  \t{ V4L2PixelFormat(V4L2_PIX_FMT_NV12), PixelFormat(DRM_FORMAT_NV12) },\n>  \t{ V4L2PixelFormat(V4L2_PIX_FMT_NV21), PixelFormat(DRM_FORMAT_NV21) },\n> +\t{ V4L2PixelFormat(V4L2_PIX_FMT_YUV422P), PixelFormat(DRM_FORMAT_YUV422) },\n> +\t{ V4L2PixelFormat(V4L2_PIX_FMT_YUV420), PixelFormat(DRM_FORMAT_YUV420) },\n>  \n>  \t/* Greyscale formats. */\n>  \t{ V4L2PixelFormat(V4L2_PIX_FMT_GREY), PixelFormat(DRM_FORMAT_R8) },\n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index d7f14e6..a54d47e 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -576,6 +576,8 @@ static const std::array<PixelFormatInfo, 14> pixelFormatInfo = {{\n>  \t{ PixelFormat(DRM_FORMAT_NV61),\t\tV4L2_PIX_FMT_NV61,\t2, {{ {  8, 1, 1 }, { 16, 2, 1 }, {  0, 0, 0 } }} },\n>  \t{ PixelFormat(DRM_FORMAT_NV24),\t\tV4L2_PIX_FMT_NV24,\t2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n>  \t{ PixelFormat(DRM_FORMAT_NV42),\t\tV4L2_PIX_FMT_NV42,\t2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n> +\t{ PixelFormat(DRM_FORMAT_YUV422),\tV4L2_PIX_FMT_YUV422P,\t2, {{ {  8, 1, 1 }, { 8, 2, 1 }, {  8, 2, 1 } }} },\n> +\t{ PixelFormat(DRM_FORMAT_YUV420),\tV4L2_PIX_FMT_YUV420,\t2, {{ {  8, 1, 1 }, { 8, 2, 2 }, {  8, 2, 2 } }} },\n>  \t/* Compressed formats. */\n>  \t/*\n>  \t * \\todo Get a better image size estimate for MJPEG, via","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D4B28603C1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Jun 2020 00:18:43 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1835DF9;\n\tThu, 18 Jun 2020 00:18:43 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"FRK/bk4m\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592432323;\n\tbh=Sr5LlTjVXbBcJezsbyJMl/u+8/IjFQKwvCgf/Us0lFI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=FRK/bk4mYGzf/nN5y1GHmbH82m1k0MSvtjZZxoI0khrRF/hqvoknsEI3gBF0bzL44\n\t8ZBEmrUz6LdCe6SLV86jP8t7Cp3Pmp0KUpSxrE3xY7mao3JBwLVacc5cPL5rJtMlC9\n\tEGHGeGPtfRLdMZOO26WuQ88WJBP4yQzsdo2jQOzs=","Date":"Thu, 18 Jun 2020 01:18:12 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200617221812.GB32604@pendragon.ideasonboard.com>","References":"<20200617164442.2643-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200617164442.2643-1-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: add support for planar\n\tYUV422 and YUV420 formats","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Wed, 17 Jun 2020 22:18:44 -0000"}},{"id":5261,"web_url":"https://patchwork.libcamera.org/comment/5261/","msgid":"<20200618004624.GE19884@pendragon.ideasonboard.com>","date":"2020-06-18T00:46:24","subject":"Re: [libcamera-devel] [PATCH] libcamera: add support for planar\n\tYUV422 and YUV420 formats","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nOn Thu, Jun 18, 2020 at 01:18:21AM +0300, Laurent Pinchart wrote:\n> On Wed, Jun 17, 2020 at 05:44:42PM +0100, David Plowman wrote:\n> > These formats can be helpful when downstream applications or libraries\n> > support them natively (avoiding a costly conversion).\n> \n> But only if cameras can provide them :-)\n> \n> Does the Raspberry Pi ISP support both V4L2_PIX_FMT_YUV420 and\n> V4L2_PIX_FMT_YUV422P ? I see mentions of the former in the driver, but\n> not of the latter.\n> \n> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > ---\n> >  src/libcamera/formats.cpp          | 14 ++++++++++++++\n> >  src/libcamera/v4l2_pixelformat.cpp |  2 ++\n> >  src/v4l2/v4l2_camera_proxy.cpp     |  2 ++\n> >  3 files changed, 18 insertions(+)\n> > \n> > diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> > index 2ac3b41..dcd1dcf 100644\n> > --- a/src/libcamera/formats.cpp\n> > +++ b/src/libcamera/formats.cpp\n> > @@ -268,6 +268,20 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> >  \t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> >  \t\t.packed = false,\n> >  \t} },\n> > +\t{ PixelFormat(DRM_FORMAT_YUV422), {\n> > +\t\t.format = PixelFormat(DRM_FORMAT_YUV422),\n> > +\t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV422P),\n> > +\t\t.bitsPerPixel = 16,\n> > +\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > +\t\t.packed = false,\n> > +\t} },\n> > +\t{ PixelFormat(DRM_FORMAT_YUV420), {\n> > +\t\t.format = PixelFormat(DRM_FORMAT_YUV420),\n> > +\t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV420),\n> > +\t\t.bitsPerPixel = 12,\n> > +\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > +\t\t.packed = false,\n> > +\t} },\n\nI may merge in the morning a patch series that rework format handling\nand would conflict with this patch. If that's the case, I'll rebase this\npatch and send the rebased version to the list.\n\n> >  \n> >  \t/* Greyscale formats. */\n> >  \t{ PixelFormat(DRM_FORMAT_R8), {\n> > diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp\n> > index 94fae47..01778c0 100644\n> > --- a/src/libcamera/v4l2_pixelformat.cpp\n> > +++ b/src/libcamera/v4l2_pixelformat.cpp\n> > @@ -64,6 +64,8 @@ const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{\n> >  \t{ V4L2PixelFormat(V4L2_PIX_FMT_NV61), PixelFormat(DRM_FORMAT_NV61) },\n> >  \t{ V4L2PixelFormat(V4L2_PIX_FMT_NV12), PixelFormat(DRM_FORMAT_NV12) },\n> >  \t{ V4L2PixelFormat(V4L2_PIX_FMT_NV21), PixelFormat(DRM_FORMAT_NV21) },\n> > +\t{ V4L2PixelFormat(V4L2_PIX_FMT_YUV422P), PixelFormat(DRM_FORMAT_YUV422) },\n> > +\t{ V4L2PixelFormat(V4L2_PIX_FMT_YUV420), PixelFormat(DRM_FORMAT_YUV420) },\n> >  \n> >  \t/* Greyscale formats. */\n> >  \t{ V4L2PixelFormat(V4L2_PIX_FMT_GREY), PixelFormat(DRM_FORMAT_R8) },\n> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > index d7f14e6..a54d47e 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > @@ -576,6 +576,8 @@ static const std::array<PixelFormatInfo, 14> pixelFormatInfo = {{\n> >  \t{ PixelFormat(DRM_FORMAT_NV61),\t\tV4L2_PIX_FMT_NV61,\t2, {{ {  8, 1, 1 }, { 16, 2, 1 }, {  0, 0, 0 } }} },\n> >  \t{ PixelFormat(DRM_FORMAT_NV24),\t\tV4L2_PIX_FMT_NV24,\t2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n> >  \t{ PixelFormat(DRM_FORMAT_NV42),\t\tV4L2_PIX_FMT_NV42,\t2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n> > +\t{ PixelFormat(DRM_FORMAT_YUV422),\tV4L2_PIX_FMT_YUV422P,\t2, {{ {  8, 1, 1 }, { 8, 2, 1 }, {  8, 2, 1 } }} },\n> > +\t{ PixelFormat(DRM_FORMAT_YUV420),\tV4L2_PIX_FMT_YUV420,\t2, {{ {  8, 1, 1 }, { 8, 2, 2 }, {  8, 2, 2 } }} },\n\nAdditionally, don't those formats have 3 planes, not two ?\n\n> >  \t/* Compressed formats. */\n> >  \t/*\n> >  \t * \\todo Get a better image size estimate for MJPEG, via","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E88D3603C1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Jun 2020 02:46:47 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 590D7440;\n\tThu, 18 Jun 2020 02:46:47 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"jsE6/huc\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592441207;\n\tbh=vM9zHCGbFOEc0q7I+Z3krfbii0PJZK7WyU25HCZP1CY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=jsE6/hucbpnMK+0KUTe5iEsZelLpUNk3+605LyzyuFZMrme9KQPQ+ASiFPmo0W4pP\n\tSjoub7dr7Qlcy/yQojzAEkTjYyiUEz+C1DWVKGnfeqcC2ajn9SjZ12XFKNSBHvL9nK\n\twLpl797fn/hv7I1XOffVlqgWYh7Q8s5GEQ9tpWcI=","Date":"Thu, 18 Jun 2020 03:46:24 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200618004624.GE19884@pendragon.ideasonboard.com>","References":"<20200617164442.2643-1-david.plowman@raspberrypi.com>\n\t<20200617221812.GB32604@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200617221812.GB32604@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: add support for planar\n\tYUV422 and YUV420 formats","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 18 Jun 2020 00:46:48 -0000"}},{"id":5266,"web_url":"https://patchwork.libcamera.org/comment/5266/","msgid":"<CAHW6GY+7pZDOA0iHQnWK4k-oycMSwDraekv_MAjVWOqJGf+_xA@mail.gmail.com>","date":"2020-06-18T08:19:55","subject":"Re: [libcamera-devel] [PATCH] libcamera: add support for planar\n\tYUV422 and YUV420 formats","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Laurent\n\nThanks for the review and the correction.\n\nJust to add some background, I've found that libjpeg works _way_\nfaster if you can feed\nit directly with planar YUV420 (what it calls \"raw\" data), hence the\nmotivation for this\npatch. I added YUV422 because, although we don't support it yet, it's\ncommon for folks\nto prefer 422 rather than 420 JPEGs, so I expect we'll need to do it\nat some point.\n\nI'm happy to re-submit the patch if you like, though it sounds like\nthe work you're doing\nmeans this isn't worth the trouble. Just let me know!\n\nThanks again and best regards\nDavid\n\nOn Thu, 18 Jun 2020 at 01:46, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi David,\n>\n> On Thu, Jun 18, 2020 at 01:18:21AM +0300, Laurent Pinchart wrote:\n> > On Wed, Jun 17, 2020 at 05:44:42PM +0100, David Plowman wrote:\n> > > These formats can be helpful when downstream applications or libraries\n> > > support them natively (avoiding a costly conversion).\n> >\n> > But only if cameras can provide them :-)\n> >\n> > Does the Raspberry Pi ISP support both V4L2_PIX_FMT_YUV420 and\n> > V4L2_PIX_FMT_YUV422P ? I see mentions of the former in the driver, but\n> > not of the latter.\n> >\n> > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > ---\n> > >  src/libcamera/formats.cpp          | 14 ++++++++++++++\n> > >  src/libcamera/v4l2_pixelformat.cpp |  2 ++\n> > >  src/v4l2/v4l2_camera_proxy.cpp     |  2 ++\n> > >  3 files changed, 18 insertions(+)\n> > >\n> > > diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> > > index 2ac3b41..dcd1dcf 100644\n> > > --- a/src/libcamera/formats.cpp\n> > > +++ b/src/libcamera/formats.cpp\n> > > @@ -268,6 +268,20 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > >             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > >             .packed = false,\n> > >     } },\n> > > +   { PixelFormat(DRM_FORMAT_YUV422), {\n> > > +           .format = PixelFormat(DRM_FORMAT_YUV422),\n> > > +           .v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV422P),\n> > > +           .bitsPerPixel = 16,\n> > > +           .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > +           .packed = false,\n> > > +   } },\n> > > +   { PixelFormat(DRM_FORMAT_YUV420), {\n> > > +           .format = PixelFormat(DRM_FORMAT_YUV420),\n> > > +           .v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV420),\n> > > +           .bitsPerPixel = 12,\n> > > +           .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > +           .packed = false,\n> > > +   } },\n>\n> I may merge in the morning a patch series that rework format handling\n> and would conflict with this patch. If that's the case, I'll rebase this\n> patch and send the rebased version to the list.\n>\n> > >\n> > >     /* Greyscale formats. */\n> > >     { PixelFormat(DRM_FORMAT_R8), {\n> > > diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp\n> > > index 94fae47..01778c0 100644\n> > > --- a/src/libcamera/v4l2_pixelformat.cpp\n> > > +++ b/src/libcamera/v4l2_pixelformat.cpp\n> > > @@ -64,6 +64,8 @@ const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{\n> > >     { V4L2PixelFormat(V4L2_PIX_FMT_NV61), PixelFormat(DRM_FORMAT_NV61) },\n> > >     { V4L2PixelFormat(V4L2_PIX_FMT_NV12), PixelFormat(DRM_FORMAT_NV12) },\n> > >     { V4L2PixelFormat(V4L2_PIX_FMT_NV21), PixelFormat(DRM_FORMAT_NV21) },\n> > > +   { V4L2PixelFormat(V4L2_PIX_FMT_YUV422P), PixelFormat(DRM_FORMAT_YUV422) },\n> > > +   { V4L2PixelFormat(V4L2_PIX_FMT_YUV420), PixelFormat(DRM_FORMAT_YUV420) },\n> > >\n> > >     /* Greyscale formats. */\n> > >     { V4L2PixelFormat(V4L2_PIX_FMT_GREY), PixelFormat(DRM_FORMAT_R8) },\n> > > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > > index d7f14e6..a54d47e 100644\n> > > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > > @@ -576,6 +576,8 @@ static const std::array<PixelFormatInfo, 14> pixelFormatInfo = {{\n> > >     { PixelFormat(DRM_FORMAT_NV61),         V4L2_PIX_FMT_NV61,      2, {{ {  8, 1, 1 }, { 16, 2, 1 }, {  0, 0, 0 } }} },\n> > >     { PixelFormat(DRM_FORMAT_NV24),         V4L2_PIX_FMT_NV24,      2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n> > >     { PixelFormat(DRM_FORMAT_NV42),         V4L2_PIX_FMT_NV42,      2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n> > > +   { PixelFormat(DRM_FORMAT_YUV422),       V4L2_PIX_FMT_YUV422P,   2, {{ {  8, 1, 1 }, { 8, 2, 1 }, {  8, 2, 1 } }} },\n> > > +   { PixelFormat(DRM_FORMAT_YUV420),       V4L2_PIX_FMT_YUV420,    2, {{ {  8, 1, 1 }, { 8, 2, 2 }, {  8, 2, 2 } }} },\n>\n> Additionally, don't those formats have 3 planes, not two ?\n\nYou are quite right, my mistake. It seems to work both ways...!\n\n>\n> > >     /* Compressed formats. */\n> > >     /*\n> > >      * \\todo Get a better image size estimate for MJPEG, via\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<david.plowman@raspberrypi.com>","Received":["from mail-oi1-x244.google.com (mail-oi1-x244.google.com\n\t[IPv6:2607:f8b0:4864:20::244])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 356EF61167\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Jun 2020 10:20:07 +0200 (CEST)","by mail-oi1-x244.google.com with SMTP id p70so4296448oic.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Jun 2020 01:20:07 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"mqHJUrO7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=5RPrn5yzQActK5MLU3fPH+KBE7tCKZ8kOrdtfplhwTU=;\n\tb=mqHJUrO7oKXKzXLUAAVVsa8Wdk0TpBpa0oiZEdYAPweZkQb9RAdAE3xDGMKoxS+TEE\n\t+70Z3ip7QasDgaTbbzTZs9R3rg2NdyQPcc6Q1id91DbWLR4rczA5wFV7sopTZzXc2gRa\n\tNHk5+PwEsnYg+KHgY9cIsqwrtKL53Y9X8ldF+PcfkMtMHaGSV4FxyJQyWCMUwH+iGDKM\n\t4dZFKQhCOsLSg5iK8u3I3SpXOUrUs1J3ynFfULiQCFvPTlWrd1bemb1VBCAVUAU6Qdhr\n\t1IhK535W3dx8Dof1PXjdvDyY2lkDvRTRsuCewIDub60u45KYSjKP0XQVOcZwMy+dciq3\n\t3uOQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=5RPrn5yzQActK5MLU3fPH+KBE7tCKZ8kOrdtfplhwTU=;\n\tb=n9+TeiZRdCbR5D7Ti5skL4VJXTMN53QZkKB68j/9htiFQrBzUNEdOFk0jhjH7vp4dN\n\tDKUsanQa3sRa98XLzPYhm+gqpUJsNfHskwJcBgeNxKpHre6SH7SNJIAYjGA2wHOg8k0k\n\tSIw2ZPFHFyU0s3wKgd8ZUtx60a+XTgyhqt8r0zAPCnD0efnViHsvFScAMVeEgKuR7wVH\n\toZj0xG1S1lnTTWDYqndpvRCO34z80C/wEwWwBlkMw4AnITO7YRThv6fW3g2OGkImcnW+\n\tcXIw9tziHvCIcpaWw+41Lf2bxRwvZ3gvIYXH/pcyqhV/9OEOY7l4AdcBEGwEzAx1hUhK\n\txEtw==","X-Gm-Message-State":"AOAM5305l38jdmT6lQezJHLHQDci8Fql3jO9zpTENhF6NuMbf4KkSUC2\n\tcbBgDKWlcX8CAA38Wfyzd7G95pCMJjmAAtdUPn6ER/Qm","X-Google-Smtp-Source":"ABdhPJzQKCx7EO/R49OWQamLypOjwFcg4/g7jAJqkCv9rb3U/6dPTZaS8iSe7etlHigxiONq/1lYc5zM9QxNt2bW9A4=","X-Received":"by 2002:aca:8c3:: with SMTP id 186mr1910605oii.55.1592468405966; \n\tThu, 18 Jun 2020 01:20:05 -0700 (PDT)","MIME-Version":"1.0","References":"<20200617164442.2643-1-david.plowman@raspberrypi.com>\n\t<20200617221812.GB32604@pendragon.ideasonboard.com>\n\t<20200618004624.GE19884@pendragon.ideasonboard.com>","In-Reply-To":"<20200618004624.GE19884@pendragon.ideasonboard.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Thu, 18 Jun 2020 09:19:55 +0100","Message-ID":"<CAHW6GY+7pZDOA0iHQnWK4k-oycMSwDraekv_MAjVWOqJGf+_xA@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH] libcamera: add support for planar\n\tYUV422 and YUV420 formats","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 18 Jun 2020 08:20:07 -0000"}},{"id":5317,"web_url":"https://patchwork.libcamera.org/comment/5317/","msgid":"<20200622043116.GL25355@pendragon.ideasonboard.com>","date":"2020-06-22T04:31:16","subject":"Re: [libcamera-devel] [PATCH] libcamera: add support for planar\n\tYUV422 and YUV420 formats","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nOn Thu, Jun 18, 2020 at 09:19:55AM +0100, David Plowman wrote:\n> Hi Laurent\n> \n> Thanks for the review and the correction.\n> \n> Just to add some background, I've found that libjpeg works _way_\n> faster if you can feed\n> it directly with planar YUV420 (what it calls \"raw\" data), hence the\n> motivation for this\n> patch. I added YUV422 because, although we don't support it yet, it's\n> common for folks\n> to prefer 422 rather than 420 JPEGs, so I expect we'll need to do it\n> at some point.\n\nDoes your ISP hardware support YUV422 ?\n\n> I'm happy to re-submit the patch if you like, though it sounds like\n> the work you're doing\n> means this isn't worth the trouble. Just let me know!\n\nI've pushed the format rework, and will send the rebased version of your\npatch shortly.\n\n> On Thu, 18 Jun 2020 at 01:46, Laurent Pinchart wrote:\n> > On Thu, Jun 18, 2020 at 01:18:21AM +0300, Laurent Pinchart wrote:\n> > > On Wed, Jun 17, 2020 at 05:44:42PM +0100, David Plowman wrote:\n> > > > These formats can be helpful when downstream applications or libraries\n> > > > support them natively (avoiding a costly conversion).\n> > >\n> > > But only if cameras can provide them :-)\n> > >\n> > > Does the Raspberry Pi ISP support both V4L2_PIX_FMT_YUV420 and\n> > > V4L2_PIX_FMT_YUV422P ? I see mentions of the former in the driver, but\n> > > not of the latter.\n> > >\n> > > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > > ---\n> > > >  src/libcamera/formats.cpp          | 14 ++++++++++++++\n> > > >  src/libcamera/v4l2_pixelformat.cpp |  2 ++\n> > > >  src/v4l2/v4l2_camera_proxy.cpp     |  2 ++\n> > > >  3 files changed, 18 insertions(+)\n> > > >\n> > > > diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> > > > index 2ac3b41..dcd1dcf 100644\n> > > > --- a/src/libcamera/formats.cpp\n> > > > +++ b/src/libcamera/formats.cpp\n> > > > @@ -268,6 +268,20 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > > >             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > >             .packed = false,\n> > > >     } },\n> > > > +   { PixelFormat(DRM_FORMAT_YUV422), {\n> > > > +           .format = PixelFormat(DRM_FORMAT_YUV422),\n> > > > +           .v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV422P),\n> > > > +           .bitsPerPixel = 16,\n> > > > +           .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > > +           .packed = false,\n> > > > +   } },\n> > > > +   { PixelFormat(DRM_FORMAT_YUV420), {\n> > > > +           .format = PixelFormat(DRM_FORMAT_YUV420),\n> > > > +           .v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV420),\n> > > > +           .bitsPerPixel = 12,\n> > > > +           .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > > +           .packed = false,\n> > > > +   } },\n> >\n> > I may merge in the morning a patch series that rework format handling\n> > and would conflict with this patch. If that's the case, I'll rebase this\n> > patch and send the rebased version to the list.\n> >\n> > > >\n> > > >     /* Greyscale formats. */\n> > > >     { PixelFormat(DRM_FORMAT_R8), {\n> > > > diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp\n> > > > index 94fae47..01778c0 100644\n> > > > --- a/src/libcamera/v4l2_pixelformat.cpp\n> > > > +++ b/src/libcamera/v4l2_pixelformat.cpp\n> > > > @@ -64,6 +64,8 @@ const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{\n> > > >     { V4L2PixelFormat(V4L2_PIX_FMT_NV61), PixelFormat(DRM_FORMAT_NV61) },\n> > > >     { V4L2PixelFormat(V4L2_PIX_FMT_NV12), PixelFormat(DRM_FORMAT_NV12) },\n> > > >     { V4L2PixelFormat(V4L2_PIX_FMT_NV21), PixelFormat(DRM_FORMAT_NV21) },\n> > > > +   { V4L2PixelFormat(V4L2_PIX_FMT_YUV422P), PixelFormat(DRM_FORMAT_YUV422) },\n> > > > +   { V4L2PixelFormat(V4L2_PIX_FMT_YUV420), PixelFormat(DRM_FORMAT_YUV420) },\n> > > >\n> > > >     /* Greyscale formats. */\n> > > >     { V4L2PixelFormat(V4L2_PIX_FMT_GREY), PixelFormat(DRM_FORMAT_R8) },\n> > > > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > > > index d7f14e6..a54d47e 100644\n> > > > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > > > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > > > @@ -576,6 +576,8 @@ static const std::array<PixelFormatInfo, 14> pixelFormatInfo = {{\n> > > >     { PixelFormat(DRM_FORMAT_NV61),         V4L2_PIX_FMT_NV61,      2, {{ {  8, 1, 1 }, { 16, 2, 1 }, {  0, 0, 0 } }} },\n> > > >     { PixelFormat(DRM_FORMAT_NV24),         V4L2_PIX_FMT_NV24,      2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n> > > >     { PixelFormat(DRM_FORMAT_NV42),         V4L2_PIX_FMT_NV42,      2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n> > > > +   { PixelFormat(DRM_FORMAT_YUV422),       V4L2_PIX_FMT_YUV422P,   2, {{ {  8, 1, 1 }, { 8, 2, 1 }, {  8, 2, 1 } }} },\n> > > > +   { PixelFormat(DRM_FORMAT_YUV420),       V4L2_PIX_FMT_YUV420,    2, {{ {  8, 1, 1 }, { 8, 2, 2 }, {  8, 2, 2 } }} },\n> >\n> > Additionally, don't those formats have 3 planes, not two ?\n> \n> You are quite right, my mistake. It seems to work both ways...!\n> \n> > > >     /* Compressed formats. */\n> > > >     /*\n> > > >      * \\todo Get a better image size estimate for MJPEG, via","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 34B73603BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Jun 2020 06:31:41 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9C3C630D;\n\tMon, 22 Jun 2020 06:31:40 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"QF7j4YAq\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592800300;\n\tbh=CNo7vh0P1f689TItf3B9AZB0EhPMbrGELDpqRBBuBJk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=QF7j4YAqJuUYF2d0zAAOHPEnN140bgUKjHz3ZwzbcdQqtxB85wQpsFf8QYYKO5ZHU\n\tqAWIQkSqQ/kRxXP48/M2+uszK6guOqzuOszkrP1i5/N7LG8LApB65SPmDBf+PwX7sl\n\tvEACDa9HB+p6ruAeeYRjkfp/2kqzXKDqUghfheAk=","Date":"Mon, 22 Jun 2020 07:31:16 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200622043116.GL25355@pendragon.ideasonboard.com>","References":"<20200617164442.2643-1-david.plowman@raspberrypi.com>\n\t<20200617221812.GB32604@pendragon.ideasonboard.com>\n\t<20200618004624.GE19884@pendragon.ideasonboard.com>\n\t<CAHW6GY+7pZDOA0iHQnWK4k-oycMSwDraekv_MAjVWOqJGf+_xA@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAHW6GY+7pZDOA0iHQnWK4k-oycMSwDraekv_MAjVWOqJGf+_xA@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: add support for planar\n\tYUV422 and YUV420 formats","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Mon, 22 Jun 2020 04:31:41 -0000"}},{"id":5318,"web_url":"https://patchwork.libcamera.org/comment/5318/","msgid":"<20200622043627.GM25355@pendragon.ideasonboard.com>","date":"2020-06-22T04:36:27","subject":"Re: [libcamera-devel] [PATCH] libcamera: add support for planar\n\tYUV422 and YUV420 formats","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nOn Wed, Jun 17, 2020 at 05:44:42PM +0100, David Plowman wrote:\n> These formats can be helpful when downstream applications or libraries\n> support them natively (avoiding a costly conversion).\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  src/libcamera/formats.cpp          | 14 ++++++++++++++\n>  src/libcamera/v4l2_pixelformat.cpp |  2 ++\n>  src/v4l2/v4l2_camera_proxy.cpp     |  2 ++\n>  3 files changed, 18 insertions(+)\n> \n> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> index 2ac3b41..dcd1dcf 100644\n> --- a/src/libcamera/formats.cpp\n> +++ b/src/libcamera/formats.cpp\n> @@ -268,6 +268,20 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n>  \t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n>  \t\t.packed = false,\n>  \t} },\n> +\t{ PixelFormat(DRM_FORMAT_YUV422), {\n> +\t\t.format = PixelFormat(DRM_FORMAT_YUV422),\n> +\t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV422P),\n> +\t\t.bitsPerPixel = 16,\n> +\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> +\t\t.packed = false,\n> +\t} },\n> +\t{ PixelFormat(DRM_FORMAT_YUV420), {\n> +\t\t.format = PixelFormat(DRM_FORMAT_YUV420),\n> +\t\t.v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV420),\n> +\t\t.bitsPerPixel = 12,\n> +\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> +\t\t.packed = false,\n> +\t} },\n>  \n>  \t/* Greyscale formats. */\n>  \t{ PixelFormat(DRM_FORMAT_R8), {\n> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp\n> index 94fae47..01778c0 100644\n> --- a/src/libcamera/v4l2_pixelformat.cpp\n> +++ b/src/libcamera/v4l2_pixelformat.cpp\n> @@ -64,6 +64,8 @@ const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{\n>  \t{ V4L2PixelFormat(V4L2_PIX_FMT_NV61), PixelFormat(DRM_FORMAT_NV61) },\n>  \t{ V4L2PixelFormat(V4L2_PIX_FMT_NV12), PixelFormat(DRM_FORMAT_NV12) },\n>  \t{ V4L2PixelFormat(V4L2_PIX_FMT_NV21), PixelFormat(DRM_FORMAT_NV21) },\n> +\t{ V4L2PixelFormat(V4L2_PIX_FMT_YUV422P), PixelFormat(DRM_FORMAT_YUV422) },\n> +\t{ V4L2PixelFormat(V4L2_PIX_FMT_YUV420), PixelFormat(DRM_FORMAT_YUV420) },\n>  \n>  \t/* Greyscale formats. */\n>  \t{ V4L2PixelFormat(V4L2_PIX_FMT_GREY), PixelFormat(DRM_FORMAT_R8) },\n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index d7f14e6..a54d47e 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -576,6 +576,8 @@ static const std::array<PixelFormatInfo, 14> pixelFormatInfo = {{\n>  \t{ PixelFormat(DRM_FORMAT_NV61),\t\tV4L2_PIX_FMT_NV61,\t2, {{ {  8, 1, 1 }, { 16, 2, 1 }, {  0, 0, 0 } }} },\n>  \t{ PixelFormat(DRM_FORMAT_NV24),\t\tV4L2_PIX_FMT_NV24,\t2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n>  \t{ PixelFormat(DRM_FORMAT_NV42),\t\tV4L2_PIX_FMT_NV42,\t2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n> +\t{ PixelFormat(DRM_FORMAT_YUV422),\tV4L2_PIX_FMT_YUV422P,\t2, {{ {  8, 1, 1 }, { 8, 2, 1 }, {  8, 2, 1 } }} },\n> +\t{ PixelFormat(DRM_FORMAT_YUV420),\tV4L2_PIX_FMT_YUV420,\t2, {{ {  8, 1, 1 }, { 8, 2, 2 }, {  8, 2, 2 } }} },\n\nThis causes a compilation error, as the array is defined with a fixed\nnumber of elements. Could you make sure to enable compilation of the\nV4L2 compatibility layer to develop patches that touches it ? It's\ndisabled by default, and you can enable it by running\n\n\tmeson configure -Dv4l2=true\n\nin the build directory. Same for the Android compatibility layer, with\n-Dandroid=true if you author patches that impact it. I enable both in\nall my builds, just in case.\n\n>  \t/* Compressed formats. */\n>  \t/*\n>  \t * \\todo Get a better image size estimate for MJPEG, via","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 95DFC603BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Jun 2020 06:36:52 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1AE4930D;\n\tMon, 22 Jun 2020 06:36:52 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"q/9lZz5F\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592800612;\n\tbh=/Fa9aOZ7viFKX/WxUsl1CmjrIDUyhlo8QrSQsE53dU0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=q/9lZz5FFremVPiCg+PWzRgY6nxLhErouKuzVRRMCt0cqBmzivgiHkFnqlPLzhpKj\n\t7uzyf++FPPuHifirAbOy8sFa+H7AvRB+tKDS3p8/czEffjLRPS3vOKcQ0wuLC2xXGv\n\t8Sva3HGD7MPAbWnIivl4GwLMfJPskysBOEc/iXMU=","Date":"Mon, 22 Jun 2020 07:36:27 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200622043627.GM25355@pendragon.ideasonboard.com>","References":"<20200617164442.2643-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200617164442.2643-1-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH] libcamera: add support for planar\n\tYUV422 and YUV420 formats","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Mon, 22 Jun 2020 04:36:52 -0000"}},{"id":5321,"web_url":"https://patchwork.libcamera.org/comment/5321/","msgid":"<CAHW6GYJgUhHKZwdmcR=q_WQrjST5W4rv+VfPYs344JkmvDoz6w@mail.gmail.com>","date":"2020-06-22T08:13:32","subject":"Re: [libcamera-devel] [PATCH] libcamera: add support for planar\n\tYUV422 and YUV420 formats","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Laurent\n\nOn Mon, 22 Jun 2020 at 05:31, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi David,\n>\n> On Thu, Jun 18, 2020 at 09:19:55AM +0100, David Plowman wrote:\n> > Hi Laurent\n> >\n> > Thanks for the review and the correction.\n> >\n> > Just to add some background, I've found that libjpeg works _way_\n> > faster if you can feed\n> > it directly with planar YUV420 (what it calls \"raw\" data), hence the\n> > motivation for this\n> > patch. I added YUV422 because, although we don't support it yet, it's\n> > common for folks\n> > to prefer 422 rather than 420 JPEGs, so I expect we'll need to do it\n> > at some point.\n>\n> Does your ISP hardware support YUV422 ?\n\nYes it does! In fact I think it was our stills format of choice in the\ndistant past...\n\nBest regards\nDavid\n\n>\n> > I'm happy to re-submit the patch if you like, though it sounds like\n> > the work you're doing\n> > means this isn't worth the trouble. Just let me know!\n>\n> I've pushed the format rework, and will send the rebased version of your\n> patch shortly.\n>\n> > On Thu, 18 Jun 2020 at 01:46, Laurent Pinchart wrote:\n> > > On Thu, Jun 18, 2020 at 01:18:21AM +0300, Laurent Pinchart wrote:\n> > > > On Wed, Jun 17, 2020 at 05:44:42PM +0100, David Plowman wrote:\n> > > > > These formats can be helpful when downstream applications or libraries\n> > > > > support them natively (avoiding a costly conversion).\n> > > >\n> > > > But only if cameras can provide them :-)\n> > > >\n> > > > Does the Raspberry Pi ISP support both V4L2_PIX_FMT_YUV420 and\n> > > > V4L2_PIX_FMT_YUV422P ? I see mentions of the former in the driver, but\n> > > > not of the latter.\n> > > >\n> > > > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > > > ---\n> > > > >  src/libcamera/formats.cpp          | 14 ++++++++++++++\n> > > > >  src/libcamera/v4l2_pixelformat.cpp |  2 ++\n> > > > >  src/v4l2/v4l2_camera_proxy.cpp     |  2 ++\n> > > > >  3 files changed, 18 insertions(+)\n> > > > >\n> > > > > diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> > > > > index 2ac3b41..dcd1dcf 100644\n> > > > > --- a/src/libcamera/formats.cpp\n> > > > > +++ b/src/libcamera/formats.cpp\n> > > > > @@ -268,6 +268,20 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > > > >             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > > >             .packed = false,\n> > > > >     } },\n> > > > > +   { PixelFormat(DRM_FORMAT_YUV422), {\n> > > > > +           .format = PixelFormat(DRM_FORMAT_YUV422),\n> > > > > +           .v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV422P),\n> > > > > +           .bitsPerPixel = 16,\n> > > > > +           .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > > > +           .packed = false,\n> > > > > +   } },\n> > > > > +   { PixelFormat(DRM_FORMAT_YUV420), {\n> > > > > +           .format = PixelFormat(DRM_FORMAT_YUV420),\n> > > > > +           .v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_YUV420),\n> > > > > +           .bitsPerPixel = 12,\n> > > > > +           .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > > > +           .packed = false,\n> > > > > +   } },\n> > >\n> > > I may merge in the morning a patch series that rework format handling\n> > > and would conflict with this patch. If that's the case, I'll rebase this\n> > > patch and send the rebased version to the list.\n> > >\n> > > > >\n> > > > >     /* Greyscale formats. */\n> > > > >     { PixelFormat(DRM_FORMAT_R8), {\n> > > > > diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp\n> > > > > index 94fae47..01778c0 100644\n> > > > > --- a/src/libcamera/v4l2_pixelformat.cpp\n> > > > > +++ b/src/libcamera/v4l2_pixelformat.cpp\n> > > > > @@ -64,6 +64,8 @@ const std::map<V4L2PixelFormat, PixelFormat> vpf2pf{\n> > > > >     { V4L2PixelFormat(V4L2_PIX_FMT_NV61), PixelFormat(DRM_FORMAT_NV61) },\n> > > > >     { V4L2PixelFormat(V4L2_PIX_FMT_NV12), PixelFormat(DRM_FORMAT_NV12) },\n> > > > >     { V4L2PixelFormat(V4L2_PIX_FMT_NV21), PixelFormat(DRM_FORMAT_NV21) },\n> > > > > +   { V4L2PixelFormat(V4L2_PIX_FMT_YUV422P), PixelFormat(DRM_FORMAT_YUV422) },\n> > > > > +   { V4L2PixelFormat(V4L2_PIX_FMT_YUV420), PixelFormat(DRM_FORMAT_YUV420) },\n> > > > >\n> > > > >     /* Greyscale formats. */\n> > > > >     { V4L2PixelFormat(V4L2_PIX_FMT_GREY), PixelFormat(DRM_FORMAT_R8) },\n> > > > > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > > > > index d7f14e6..a54d47e 100644\n> > > > > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > > > > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > > > > @@ -576,6 +576,8 @@ static const std::array<PixelFormatInfo, 14> pixelFormatInfo = {{\n> > > > >     { PixelFormat(DRM_FORMAT_NV61),         V4L2_PIX_FMT_NV61,      2, {{ {  8, 1, 1 }, { 16, 2, 1 }, {  0, 0, 0 } }} },\n> > > > >     { PixelFormat(DRM_FORMAT_NV24),         V4L2_PIX_FMT_NV24,      2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n> > > > >     { PixelFormat(DRM_FORMAT_NV42),         V4L2_PIX_FMT_NV42,      2, {{ {  8, 1, 1 }, { 16, 1, 1 }, {  0, 0, 0 } }} },\n> > > > > +   { PixelFormat(DRM_FORMAT_YUV422),       V4L2_PIX_FMT_YUV422P,   2, {{ {  8, 1, 1 }, { 8, 2, 1 }, {  8, 2, 1 } }} },\n> > > > > +   { PixelFormat(DRM_FORMAT_YUV420),       V4L2_PIX_FMT_YUV420,    2, {{ {  8, 1, 1 }, { 8, 2, 2 }, {  8, 2, 2 } }} },\n> > >\n> > > Additionally, don't those formats have 3 planes, not two ?\n> >\n> > You are quite right, my mistake. It seems to work both ways...!\n> >\n> > > > >     /* Compressed formats. */\n> > > > >     /*\n> > > > >      * \\todo Get a better image size estimate for MJPEG, via\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<david.plowman@raspberrypi.com>","Received":["from mail-ot1-x344.google.com (mail-ot1-x344.google.com\n\t[IPv6:2607:f8b0:4864:20::344])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 00F38603BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Jun 2020 10:13:43 +0200 (CEST)","by mail-ot1-x344.google.com with SMTP id s13so12372310otd.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Jun 2020 01:13:43 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"ddkQ3vRp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=csU67G/BJu/cg5yY6Uz6DFixOKz769ih7XHUuRGVRBQ=;\n\tb=ddkQ3vRpnB05GcMrnfHOogIsfr0BAKWyOKnkLCWNIfjaGxx5P46h/Qdx+vbpRp0YVO\n\t3GHxyZKbwf4aScwdxC34pl8aLJeyqoyKExxbAo3xTwLvKpJMNiX/B4Q82Fht3AFbeGW+\n\tDKVoaIZKSZUDH/45WaXtj4IkbMuscKWPrJIdgBcyvzhpBDN1OZEWhCileG0IgqxMIPKz\n\tyKRYLvbjfDh0j2GCDFcP64BiaJCyh1HJpbgQtf2i923viJInsbK9dcoLNqCtXdDSMDH9\n\tvqgDeuQGkdVo8B+zPw4IJFY+JdonYWMT9+mIINYx+SaH/QSuKbXfRnNnoC/u6SBYI8LF\n\tx4SQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=csU67G/BJu/cg5yY6Uz6DFixOKz769ih7XHUuRGVRBQ=;\n\tb=fpwkc/klUGQSYsl8QgcNeeoR6Q7bhTH6MFPrVbiytoYaHIE8Ot++uk52fAmEwh+o+1\n\tS7K9MHwAXnb2+Z7qo9ZT32jF/b8TVSGrA1d3nQ0YGgOAx4ycFj0keX0JPEiLNwZJI8Si\n\t9q/qNr8WGLhKuGMfs99d1RovMmXj9wiDKm6G8l/QlwjvivFuMPEzoOc2ryhv3HoASXwY\n\to1Mhabaq8AjASMnnw4H4No0+GoWVXTiluqXdFsGACUH0bUy+XCP1Aux6nEBzHZrIctcM\n\t6OqOiAewf6+Wd4H3S1jK1sPnzEHSTASmpTEujJp0uXsnmn+Ul07yLCxl+GbRETta04Ux\n\tJRrg==","X-Gm-Message-State":"AOAM532JvWP/ryRrXOrNevb+zvMUuIhZccxVSRyi9DMO2NMuJNwW2NNz\n\tKyFzogj3dU+tyUITRJ7aGpdDE5drzBWBU1Tkxm0rrw==","X-Google-Smtp-Source":"ABdhPJyK0O1m1v9m/k1YVrTLZ55GXEBJE4taUc+UjC5nb0jNxz34ackzCnNVIgme02e2GQ9jj9Zrf1ReUqovQlSc4YU=","X-Received":"by 2002:a9d:5604:: with SMTP id\n\te4mr12867924oti.166.1592813622581; \n\tMon, 22 Jun 2020 01:13:42 -0700 (PDT)","MIME-Version":"1.0","References":"<20200617164442.2643-1-david.plowman@raspberrypi.com>\n\t<20200617221812.GB32604@pendragon.ideasonboard.com>\n\t<20200618004624.GE19884@pendragon.ideasonboard.com>\n\t<CAHW6GY+7pZDOA0iHQnWK4k-oycMSwDraekv_MAjVWOqJGf+_xA@mail.gmail.com>\n\t<20200622043116.GL25355@pendragon.ideasonboard.com>","In-Reply-To":"<20200622043116.GL25355@pendragon.ideasonboard.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Mon, 22 Jun 2020 09:13:32 +0100","Message-ID":"<CAHW6GYJgUhHKZwdmcR=q_WQrjST5W4rv+VfPYs344JkmvDoz6w@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH] libcamera: add support for planar\n\tYUV422 and YUV420 formats","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Mon, 22 Jun 2020 08:13:44 -0000"}}]