[{"id":24380,"web_url":"https://patchwork.libcamera.org/comment/24380/","msgid":"<YuwPFmExcTPOU6oN@pendragon.ideasonboard.com>","date":"2022-08-04T18:25:26","subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: formats: Fix colour\n\tencoding for \"R\" raw greyscale formats","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nThank you for the patch.\n\nOn Thu, Aug 04, 2022 at 11:45:49AM +0100, David Plowman via libcamera-devel wrote:\n> These are being used for raw monochrome sensors and so the colour\n> encoding should be \"raw\".\n\nOuch. This is something I didn't foresee, but we have a problem here.\nThese can refer to both raw data from monochrome sensors, but also\ngreyscale data processed by an ISP. We currently don't consider as RAW\nformats, which means that\n\n- The CameraConfiguration::validateColorSpaces() will accept other color\n  spaces that ColorSpace::Raw.\n- The IPU3 and Raspberry Pi pipeline handlers, and the Android HAL, will\n  consider them as processed streams, not raw streams.\n\nThis patch will change that, quite likely introducing breakages.\n\nNow, the interesting question is how to support both raw monochrome data\nand processed monochrome data. Any idea ? :-)\n\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  src/libcamera/formats.cpp | 8 ++++----\n>  1 file changed, 4 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> index 283ecb3d..7b98fef2 100644\n> --- a/src/libcamera/formats.cpp\n> +++ b/src/libcamera/formats.cpp\n> @@ -531,7 +531,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n>  \t\t\t.multi = V4L2PixelFormat(),\n>  \t\t},\n>  \t\t.bitsPerPixel = 8,\n> -\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> +\t\t.colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n>  \t\t.packed = false,\n>  \t\t.pixelsPerGroup = 1,\n>  \t\t.planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }},\n> @@ -544,7 +544,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n>  \t\t\t.multi = V4L2PixelFormat(),\n>  \t\t},\n>  \t\t.bitsPerPixel = 10,\n> -\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> +\t\t.colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n>  \t\t.packed = false,\n>  \t\t.pixelsPerGroup = 1,\n>  \t\t.planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},\n> @@ -557,7 +557,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n>  \t\t\t.multi = V4L2PixelFormat(),\n>  \t\t},\n>  \t\t.bitsPerPixel = 12,\n> -\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> +\t\t.colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n>  \t\t.packed = false,\n>  \t\t.pixelsPerGroup = 1,\n>  \t\t.planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},\n> @@ -570,7 +570,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n>  \t\t\t.multi = V4L2PixelFormat(),\n>  \t\t},\n>  \t\t.bitsPerPixel = 10,\n> -\t\t.colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> +\t\t.colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n>  \t\t.packed = true,\n>  \t\t.pixelsPerGroup = 4,\n>  \t\t.planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }},","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9A579BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Aug 2022 18:25:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 008BE6332B;\n\tThu,  4 Aug 2022 20:25:35 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D3FF6330D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Aug 2022 20:25:34 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8E265481;\n\tThu,  4 Aug 2022 20:25:33 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659637535;\n\tbh=dlESxs5IBC7l7hR48wdm7T0ARVLFSRw7TnUmbsyceyc=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=ESuxBziAUcwjaaPIUDisZjg7cyZJ1zU5kERsA3ZWCVu7iAPStGJqNt0vbK1vI52V5\n\tbW6uLKnmlyWmke1YIEMnUC9so5VA6sEo1+/UvUFloFm3nktIxsB4EGy+vcIHLYMHgz\n\ti42/BoHxxnHrjtzbVVG5qkeDJVndhBvg9lsjja6p37wI784kq5BxRE0dBxyrsD/uYs\n\tP5ArNHDePqGI7/EI97fwiYomwuFJnQqvIv3Q9gk0OG9/e50/HOAn9f3gi2ocbgl0SP\n\ttR2nrVpfhnqTJAcAzD9WgeVmJmjdD/XuwU+gSvHwWVIuSKEo+Nd+llRASMkkOjnesJ\n\temQb7myxWbkwQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1659637533;\n\tbh=dlESxs5IBC7l7hR48wdm7T0ARVLFSRw7TnUmbsyceyc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=H0Vkbi9AGp/bWfcjANpoCRnoLKCbeVIG8OIi1lm09aguFjcIBVVNESErF/OZITxRL\n\t+08q7VSKX5qpr/j1f/BK/vuEB16DnnDkVcN3rghnowZze4n/Z2g9nF1ZKpt+DGt/jl\n\tMhntZ1twq1a3JpDQ//7vOyz8nQNaFE58PU4+Kqy4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"H0Vkbi9A\"; dkim-atps=neutral","Date":"Thu, 4 Aug 2022 21:25:26 +0300","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<YuwPFmExcTPOU6oN@pendragon.ideasonboard.com>","References":"<20220804104550.4600-1-david.plowman@raspberrypi.com>\n\t<20220804104550.4600-2-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220804104550.4600-2-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: formats: Fix colour\n\tencoding for \"R\" raw greyscale 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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24429,"web_url":"https://patchwork.libcamera.org/comment/24429/","msgid":"<CAHW6GY+S=9qH80yFGaUndMs-sjwaCH4KVZ1zxtoCWDfE5Kxfyg@mail.gmail.com>","date":"2022-08-08T11:18:31","subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: formats: Fix colour\n\tencoding for \"R\" raw greyscale 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 feedback.\n\nOn Thu, 4 Aug 2022 at 19:25, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi David,\n>\n> Thank you for the patch.\n>\n> On Thu, Aug 04, 2022 at 11:45:49AM +0100, David Plowman via libcamera-devel wrote:\n> > These are being used for raw monochrome sensors and so the colour\n> > encoding should be \"raw\".\n>\n> Ouch. This is something I didn't foresee, but we have a problem here.\n> These can refer to both raw data from monochrome sensors, but also\n> greyscale data processed by an ISP. We currently don't consider as RAW\n> formats, which means that\n>\n> - The CameraConfiguration::validateColorSpaces() will accept other color\n>   spaces that ColorSpace::Raw.\n> - The IPU3 and Raspberry Pi pipeline handlers, and the Android HAL, will\n>   consider them as processed streams, not raw streams.\n>\n> This patch will change that, quite likely introducing breakages.\n>\n> Now, the interesting question is how to support both raw monochrome data\n> and processed monochrome data. Any idea ? :-)\n\nHmm. That's all a bit awkward. Am I right in thinking that this comes\nfundamentally from the V4L2 drivers which tell us a format (e.g.\n\"10-bit greyscale\") but not whether it's raw or processed? Which\npresumably makes it a bit awkward to fix \"properly\".\n\nAlternatively, I suppose we could add (slightly ugly) workarounds in\nthe Pi pipeline handler, along the lines of \"oh, it says R10, I know\nthat's really a raw format\", because that's true for us. I don't\nreally think that I'm seeing anything better than this at the\nmoment...\n\nThanks!\n\nDavid\n\n>\n> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > ---\n> >  src/libcamera/formats.cpp | 8 ++++----\n> >  1 file changed, 4 insertions(+), 4 deletions(-)\n> >\n> > diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> > index 283ecb3d..7b98fef2 100644\n> > --- a/src/libcamera/formats.cpp\n> > +++ b/src/libcamera/formats.cpp\n> > @@ -531,7 +531,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> >                       .multi = V4L2PixelFormat(),\n> >               },\n> >               .bitsPerPixel = 8,\n> > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> >               .packed = false,\n> >               .pixelsPerGroup = 1,\n> >               .planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }},\n> > @@ -544,7 +544,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> >                       .multi = V4L2PixelFormat(),\n> >               },\n> >               .bitsPerPixel = 10,\n> > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> >               .packed = false,\n> >               .pixelsPerGroup = 1,\n> >               .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},\n> > @@ -557,7 +557,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> >                       .multi = V4L2PixelFormat(),\n> >               },\n> >               .bitsPerPixel = 12,\n> > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> >               .packed = false,\n> >               .pixelsPerGroup = 1,\n> >               .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},\n> > @@ -570,7 +570,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> >                       .multi = V4L2PixelFormat(),\n> >               },\n> >               .bitsPerPixel = 10,\n> > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> >               .packed = true,\n> >               .pixelsPerGroup = 4,\n> >               .planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }},\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id EF680BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  8 Aug 2022 11:18:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 459326332B;\n\tMon,  8 Aug 2022 13:18:43 +0200 (CEST)","from mail-ed1-x533.google.com (mail-ed1-x533.google.com\n\t[IPv6:2a00:1450:4864:20::533])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 97AE963315\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  8 Aug 2022 13:18:41 +0200 (CEST)","by mail-ed1-x533.google.com with SMTP id z2so10906769edc.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 08 Aug 2022 04:18:41 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659957523;\n\tbh=BL1xdw7ePDS3NQBLY/thau8dv6yWrZMLlKguYruMp0w=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=JvzDMo7NZSnwrTaN3L3m6JdhFqFzqirMitu8It9mB1p2THcP1Y9C/DB4oPnYsAlUX\n\tcWnOrgrjbS4B2+RuQIgDN3aWBOMUPftubuU9xDiccsKzmwBLW9Pku7uPh2E9tsY5vV\n\tNnlYr1mY3chs1ESCr/aliAtKApqMhK3IkjJdtXnD4yjACImAxK177kG8I8ylJNGmDD\n\tJW333+jfIA1zJc1S3bGJKsZS8L6RqAlej9M27aVvhg5IChgFu8tJq4L09+ChZmZGoC\n\tVKerycighUvL0Z9UcaQ8n0N8ol5udFmaJLAEtd/7oICZVbgN1EKEIi1idwOyRUDi++\n\tD82QfcUXQOaYA==","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=jaREr+XbnwjDNPp3H43C2yhgU2oRuPQUC4NTmH0fy1I=;\n\tb=o2oMoLemR5RDS/O09dD/ePIwt7IhnuNn6Rkmi5bR0FsB0MDZdZ9lzqwaZUxo77y+fW\n\tvtUtTZgJvChN4lv5XUMPcSnYGGCZbX7M7dD6lwapDOJ8bsxQHMYQIQjIk7KkdHRX7f7N\n\tKCgAD+57p0lHkPqwNDjWk/qTKY56xnQx4PZH7WF4hpQ+8IzKFMeEg96SZc52LIjV5i+1\n\tjnADMV6BQmO4IJ2B12i2lzpRlY8HiIHQ2p7klgY/Iam9Lu8DlISJMSwAO8Q0nidTzXVg\n\tHZ743KEy0NvTu9jjDBMffbocj+ZGnpzTV13o22STcsg/MF/qicqv6DIpinf7X/igKspT\n\tBAfQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"o2oMoLem\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=jaREr+XbnwjDNPp3H43C2yhgU2oRuPQUC4NTmH0fy1I=;\n\tb=d6vvUly4I9BBlC/OzCOwVqm4Nna4Q+AjTULpD1LHs2mDteiBhWRm1QNdaK0G0ezFLH\n\t0nfRRfgVBbbPj1txB1AECu8A3JHdy5l6+t2/CVkAlsCuqPtFKYqKdStQjFGGnUwfOgIc\n\tXai6M3f3GrNImdqMVAeJUiRrxmsZVUGrnimA5gFpjuIxUM6PUhEWcxbXPAmFWhu48US6\n\tUYYuRxFMys4dkB59/h3CkY9Gqb1RNluHRCRqNqNRZA3XbHeUJuTZPkrakLTh9xo7Apgn\n\t0crrwiRBlO/wadIYmBwLhAEdUCGhH7P7FapbUR3gDq1mkTGu7BshE4QBHPL5j8d1gCRy\n\tzpsQ==","X-Gm-Message-State":"ACgBeo06K6BwX3lXm2Bl8d1FMnGgVlfDEgjWyy3AYomw1uwOBXvyFWzr\n\tXo0DiQ3A22EZZERIZPbOkySwu7mlCtA9mvxaA4Jug8eUUJc=","X-Google-Smtp-Source":"AA6agR48+tNExdir1Fx4Loxg9yelpbDLhVvVDxbBiqWsvUi+AgPtj9bzEmJcoLO2IPuJQcgCMPSk2bfs09hlCW2I6V0=","X-Received":"by 2002:a05:6402:3509:b0:43e:d80b:44a8 with SMTP id\n\tb9-20020a056402350900b0043ed80b44a8mr16282329edd.255.1659957521203;\n\tMon, 08 Aug 2022 04:18:41 -0700 (PDT)","MIME-Version":"1.0","References":"<20220804104550.4600-1-david.plowman@raspberrypi.com>\n\t<20220804104550.4600-2-david.plowman@raspberrypi.com>\n\t<YuwPFmExcTPOU6oN@pendragon.ideasonboard.com>","In-Reply-To":"<YuwPFmExcTPOU6oN@pendragon.ideasonboard.com>","Date":"Mon, 8 Aug 2022 12:18:31 +0100","Message-ID":"<CAHW6GY+S=9qH80yFGaUndMs-sjwaCH4KVZ1zxtoCWDfE5Kxfyg@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: formats: Fix colour\n\tencoding for \"R\" raw greyscale 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>","From":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24517,"web_url":"https://patchwork.libcamera.org/comment/24517/","msgid":"<CAHW6GY+rQ7tphHg2ebysWMk+0bxVUcxBYQoegsVtRbuT-d4EOA@mail.gmail.com>","date":"2022-08-10T11:14:04","subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: formats: Fix colour\n\tencoding for \"R\" raw greyscale formats","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi again\n\nOn Mon, 8 Aug 2022 at 12:18, David Plowman\n<david.plowman@raspberrypi.com> wrote:\n>\n> Hi Laurent\n>\n> Thanks for the feedback.\n>\n> On Thu, 4 Aug 2022 at 19:25, Laurent Pinchart\n> <laurent.pinchart@ideasonboard.com> wrote:\n> >\n> > Hi David,\n> >\n> > Thank you for the patch.\n> >\n> > On Thu, Aug 04, 2022 at 11:45:49AM +0100, David Plowman via libcamera-devel wrote:\n> > > These are being used for raw monochrome sensors and so the colour\n> > > encoding should be \"raw\".\n> >\n> > Ouch. This is something I didn't foresee, but we have a problem here.\n> > These can refer to both raw data from monochrome sensors, but also\n> > greyscale data processed by an ISP. We currently don't consider as RAW\n> > formats, which means that\n> >\n> > - The CameraConfiguration::validateColorSpaces() will accept other color\n> >   spaces that ColorSpace::Raw.\n> > - The IPU3 and Raspberry Pi pipeline handlers, and the Android HAL, will\n> >   consider them as processed streams, not raw streams.\n> >\n> > This patch will change that, quite likely introducing breakages.\n> >\n> > Now, the interesting question is how to support both raw monochrome data\n> > and processed monochrome data. Any idea ? :-)\n>\n> Hmm. That's all a bit awkward. Am I right in thinking that this comes\n> fundamentally from the V4L2 drivers which tell us a format (e.g.\n> \"10-bit greyscale\") but not whether it's raw or processed? Which\n> presumably makes it a bit awkward to fix \"properly\".\n>\n> Alternatively, I suppose we could add (slightly ugly) workarounds in\n> the Pi pipeline handler, along the lines of \"oh, it says R10, I know\n> that's really a raw format\", because that's true for us. I don't\n> really think that I'm seeing anything better than this at the\n> moment...\n\nHere's another thought...\n\nThe problem is that we have more than one possible colour encoding for\nthe \"R\" formats. If we aren't going to change V4L2 to have raw and\nnon-raw \"R\" formats anytime soon then maybe we should let the\nPixelFormatInfo record all the possible colour encodings.\n\nNow, I'm guessing that turning the PixelFormatInfo.colourEncoding\nfield into a std::vector<enum ColourEncoding> is probably going to be\na bit annoying to existing code. We could decide to do it, though\nanother option might be to add an \"alternate\" colour encoding field\ninstead.\n\nThis too could just be a std::vector<enum ColourEncoding> that\ncontains all the other possibilities. The benefit is that it doesn't\nupset existing code which wouldn't check the new field and nothing\nwould change. The table in formats.h could omit the field altogether\n(leaving an empty vector) except where it is needed.\n\nThoughts?\n\nDavid\n\n>\n> Thanks!\n>\n> David\n>\n> >\n> > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > ---\n> > >  src/libcamera/formats.cpp | 8 ++++----\n> > >  1 file changed, 4 insertions(+), 4 deletions(-)\n> > >\n> > > diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> > > index 283ecb3d..7b98fef2 100644\n> > > --- a/src/libcamera/formats.cpp\n> > > +++ b/src/libcamera/formats.cpp\n> > > @@ -531,7 +531,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > >                       .multi = V4L2PixelFormat(),\n> > >               },\n> > >               .bitsPerPixel = 8,\n> > > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> > >               .packed = false,\n> > >               .pixelsPerGroup = 1,\n> > >               .planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }},\n> > > @@ -544,7 +544,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > >                       .multi = V4L2PixelFormat(),\n> > >               },\n> > >               .bitsPerPixel = 10,\n> > > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> > >               .packed = false,\n> > >               .pixelsPerGroup = 1,\n> > >               .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},\n> > > @@ -557,7 +557,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > >                       .multi = V4L2PixelFormat(),\n> > >               },\n> > >               .bitsPerPixel = 12,\n> > > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> > >               .packed = false,\n> > >               .pixelsPerGroup = 1,\n> > >               .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},\n> > > @@ -570,7 +570,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > >                       .multi = V4L2PixelFormat(),\n> > >               },\n> > >               .bitsPerPixel = 10,\n> > > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> > >               .packed = true,\n> > >               .pixelsPerGroup = 4,\n> > >               .planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }},\n> >\n> > --\n> > Regards,\n> >\n> > Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 827FFBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Aug 2022 11:14:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C19B26332B;\n\tWed, 10 Aug 2022 13:14:17 +0200 (CEST)","from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com\n\t[IPv6:2a00:1450:4864:20::62d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D12C7600EA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Aug 2022 13:14:15 +0200 (CEST)","by mail-ej1-x62d.google.com with SMTP id tl27so27102655ejc.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Aug 2022 04:14:15 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660130057;\n\tbh=Q1M5ZjSaxVv0Eg9jsqsjf7N8HF9fALTdT+imdcuIYmc=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=RDo8vW/fe8RqPuUxF00fARi8dOVipCWpF/WmwY0FT7lTMnGisgLTsD5F9B9lPXHHX\n\tp2v42VZkJz2Vvw4iAcxfrw7Iv8ewMLLMw3wJRl/AMG2u0uQwgwgGQz7NTxv0GKibeC\n\ttr/JvN56Gm4bkg9tEheLBTX3Z+gujtnYWkOtv7SFSLEurSy8Xh6WbeF1OdNpShcva8\n\tK++I0nK6xxKvOqOgVDC9hZduDODUG0dL9GwMkoRCofXT0DjxI+e5Ljko7fvHzF3Qdc\n\tKPjdoCLw91TrhP846+9OZKhOz2ICZsMTg9uawfk8l8Ac5EEtG09qZeU6a4xTG6XuHt\n\tAJ2NMBqnEScPQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc;\n\tbh=aeCSfGtmgNpww+tbxxvKp656DbMvVUQ/nHVJElS00Yk=;\n\tb=Zd0fbgZfUvXOMyFqPGP9RPGDNMMaKoEsAtNRnBIJutgwMvrLFSpoKlZVA9rCU9IPLp\n\tIdXdFl3DzMn2ckqrlthHht2cK2oD+pG1SF5/hcb+dqYzMqKd2DY6mmwCwBEwM3mnJPrj\n\tLFIDAnNj4vUlg52EO7Rk4mmsVl3jPB0H+RSZlubx445VFQJGBKTGieQ6ePh0pNwKTkan\n\tPFiM2ot+efVckp0TrB3xF2zkIkxmC8cS1Ec16HswFeGsJfABDaZNvafy94M7W58fBqUu\n\tg0z66+ncneutFWqUz1O4glu0oK8sesfHgVN5zJxs6cCNN3gZlCaa5obYkgVUzGp8dBIQ\n\thXMQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"Zd0fbgZf\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc;\n\tbh=aeCSfGtmgNpww+tbxxvKp656DbMvVUQ/nHVJElS00Yk=;\n\tb=AUbD7jB8FB4TWe45eqf+aqpIgTYzjAViqFbcNs1NjwAGaSvFcR/1iBlmam/4mUuuxn\n\tfm4WATSKrLUDqNPm0WEi8/yKMRt1qveK5Gvdy8pzVmEES6I1rWjodoIXQmT11fwYJt0V\n\tU2A5X/MTQ1Ct4WTwR9qAHWnHHTwmCRLNIRyEscrxAeWqV/5TGXw9LvzGKttprfYd4awy\n\tAnQpycRzPk2dDUag+da6f+OmHtzRwz9KVA9kYy9uvxFBMSXQgZg7EDQkpho/lfUCmyVD\n\teYgLBbNdvkeivbjGB+ZeMew7Z8kjHiUQoeazC/jZwNdiCXvzD8ArkMN3FUf1Awh27S7U\n\tovHw==","X-Gm-Message-State":"ACgBeo0/V1MkssqFuDAd/vWfpjO+OURgYdRTABMGuWBkHTy8mCC1LOTI\n\t4anyurB8FwmwiXim6iv1phGmYKxUxFzOQj4P30eXN8VvxNI=","X-Google-Smtp-Source":"AA6agR4I+Wf+bEhK7RFVVCEbKo+WF120PCkXVnQiZy+kp8/UGXiIOdUKfGNO0+xOIjWrRvmg9Dt8CxxrhjMfjC3p/pU=","X-Received":"by 2002:a17:906:ef8f:b0:731:4a01:7781 with SMTP id\n\tze15-20020a170906ef8f00b007314a017781mr11554214ejb.268.1660130055309;\n\tWed, 10 Aug 2022 04:14:15 -0700 (PDT)","MIME-Version":"1.0","References":"<20220804104550.4600-1-david.plowman@raspberrypi.com>\n\t<20220804104550.4600-2-david.plowman@raspberrypi.com>\n\t<YuwPFmExcTPOU6oN@pendragon.ideasonboard.com>\n\t<CAHW6GY+S=9qH80yFGaUndMs-sjwaCH4KVZ1zxtoCWDfE5Kxfyg@mail.gmail.com>","In-Reply-To":"<CAHW6GY+S=9qH80yFGaUndMs-sjwaCH4KVZ1zxtoCWDfE5Kxfyg@mail.gmail.com>","Date":"Wed, 10 Aug 2022 12:14:04 +0100","Message-ID":"<CAHW6GY+rQ7tphHg2ebysWMk+0bxVUcxBYQoegsVtRbuT-d4EOA@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: formats: Fix colour\n\tencoding for \"R\" raw greyscale 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>","From":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":25280,"web_url":"https://patchwork.libcamera.org/comment/25280/","msgid":"<YzyXNNogb+BH4uut@pendragon.ideasonboard.com>","date":"2022-10-04T20:27:32","subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: formats: Fix colour\n\tencoding for \"R\" raw greyscale 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, Aug 10, 2022 at 12:14:04PM +0100, David Plowman wrote:\n> On Mon, 8 Aug 2022 at 12:18, David Plowman wrote:\n> > On Thu, 4 Aug 2022 at 19:25, Laurent Pinchart wrote:\n> > > On Thu, Aug 04, 2022 at 11:45:49AM +0100, David Plowman via libcamera-devel wrote:\n> > > > These are being used for raw monochrome sensors and so the colour\n> > > > encoding should be \"raw\".\n> > >\n> > > Ouch. This is something I didn't foresee, but we have a problem here.\n> > > These can refer to both raw data from monochrome sensors, but also\n> > > greyscale data processed by an ISP. We currently don't consider as RAW\n> > > formats, which means that\n> > >\n> > > - The CameraConfiguration::validateColorSpaces() will accept other color\n> > >   spaces that ColorSpace::Raw.\n> > > - The IPU3 and Raspberry Pi pipeline handlers, and the Android HAL, will\n> > >   consider them as processed streams, not raw streams.\n> > >\n> > > This patch will change that, quite likely introducing breakages.\n> > >\n> > > Now, the interesting question is how to support both raw monochrome data\n> > > and processed monochrome data. Any idea ? :-)\n> >\n> > Hmm. That's all a bit awkward. Am I right in thinking that this comes\n> > fundamentally from the V4L2 drivers which tell us a format (e.g.\n> > \"10-bit greyscale\") but not whether it's raw or processed? Which\n> > presumably makes it a bit awkward to fix \"properly\".\n\nIn some cases that can be problematic, such as when an ISP receives\ngreyscale raw data and has the ability to output greyscale processed\ndata, or bypass all processing to capture the raw data. We wouldn't be\nable to configure this through the format on the ISP source pad only. In\nthat case it's probably best to use a different means to configure the\nISP bypass (V4L2 control, MC link, ISP parameter buffer, ...). In all\nother cases, the pipeline handler should be able to figure things out.\n\n> > Alternatively, I suppose we could add (slightly ugly) workarounds in\n> > the Pi pipeline handler, along the lines of \"oh, it says R10, I know\n> > that's really a raw format\", because that's true for us. I don't\n> > really think that I'm seeing anything better than this at the\n> > moment...\n> \n> Here's another thought...\n> \n> The problem is that we have more than one possible colour encoding for\n> the \"R\" formats. If we aren't going to change V4L2 to have raw and\n> non-raw \"R\" formats anytime soon then maybe we should let the\n> PixelFormatInfo record all the possible colour encodings.\n\nThe libcamera PixelFormat class shares with V4L2 the inability to\ndiscriminate between raw and processed formats, but I don't think V4L2\nlimits us as such. It is hidden within the pipeline handler and not\nexposed to applications, so we could change the PixelFormat class\nwithout requiring a similar change in V4L2 pixel formats.\n\n> Now, I'm guessing that turning the PixelFormatInfo.colourEncoding\n> field into a std::vector<enum ColourEncoding> is probably going to be\n> a bit annoying to existing code. We could decide to do it, though\n> another option might be to add an \"alternate\" colour encoding field\n> instead.\n> \n> This too could just be a std::vector<enum ColourEncoding> that\n> contains all the other possibilities. The benefit is that it doesn't\n> upset existing code which wouldn't check the new field and nothing\n> would change. The table in formats.h could omit the field altogether\n> (leaving an empty vector) except where it is needed.\n> \n> Thoughts?\n\nI've merged your patch that works around this issue for the Raspberry Pi\npipeline handler, so from that point of view the problem is solved. I'd\nstill like to share my thoughts though.\n\nI'm not sure the lack of discrimination ability in the pixel format is\nactually an issue. The pixel format is conceptually the same in both\ncase, it's 8-bit or 10-bit or 12-bit greyscale data in memory. I like\nthe idea that the pixel format describes the memory format, and not what\nprocessing has been applied. I would like to keep this.\n\nWhat we're missing, in my opinion, is a way to determine where in the\npipeline to capture a frame based on other information than just the\npixel format. I think this is something we could get from streams, by\nmaking them take a more important role in the camera configuration.\nApplications should be able to decide which streams to capture in a more\nexplicit way. I'll resume at some poit work I started a while ago to\nrework the configuration API, and I will likely go in this direction.\n\nThis of course leaves open the question of what the colourEncoding\nmember of the PixelFormatInfo class should store. Your idea of using a\nvector isn't a bad one, but I'd like to revisit that on top of the\nconfiguration API rework, as usage of the colourEncoding field will\npossibly be quite different then.\n\n> > > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > > ---\n> > > >  src/libcamera/formats.cpp | 8 ++++----\n> > > >  1 file changed, 4 insertions(+), 4 deletions(-)\n> > > >\n> > > > diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> > > > index 283ecb3d..7b98fef2 100644\n> > > > --- a/src/libcamera/formats.cpp\n> > > > +++ b/src/libcamera/formats.cpp\n> > > > @@ -531,7 +531,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > > >                       .multi = V4L2PixelFormat(),\n> > > >               },\n> > > >               .bitsPerPixel = 8,\n> > > > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> > > >               .packed = false,\n> > > >               .pixelsPerGroup = 1,\n> > > >               .planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }},\n> > > > @@ -544,7 +544,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > > >                       .multi = V4L2PixelFormat(),\n> > > >               },\n> > > >               .bitsPerPixel = 10,\n> > > > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> > > >               .packed = false,\n> > > >               .pixelsPerGroup = 1,\n> > > >               .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},\n> > > > @@ -557,7 +557,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > > >                       .multi = V4L2PixelFormat(),\n> > > >               },\n> > > >               .bitsPerPixel = 12,\n> > > > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> > > >               .packed = false,\n> > > >               .pixelsPerGroup = 1,\n> > > >               .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},\n> > > > @@ -570,7 +570,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > > >                       .multi = V4L2PixelFormat(),\n> > > >               },\n> > > >               .bitsPerPixel = 10,\n> > > > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> > > >               .packed = true,\n> > > >               .pixelsPerGroup = 4,\n> > > >               .planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }},","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id ABBA0BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  4 Oct 2022 20:27:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D2B7960ABD;\n\tTue,  4 Oct 2022 22:27:37 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C28C1601C7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  4 Oct 2022 22:27:35 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2D20B2D9;\n\tTue,  4 Oct 2022 22:27:35 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664915257;\n\tbh=ya1HsmotZoSVcKUeMrvYhD148B6eTRFKSSQSkv/4S5c=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=XDSQAhyvOFZzjZ3xJ0JrufJVtxPT8ODvQMCyZb+HRBQ3Lncnvmm+gnams9610TKWN\n\tFqWL3Gz117l3uU8OQKjZkUq0EORNE5rbGQ0bDBbdgTC1RLMHvZ9oyPBqj1eek8c5eO\n\tSHMt6pHxyisWCSsDJ+jjTJBDf/cI14Dsot0u8Lf/MGRqqEGsOLSRxv80SjF2Y6GV2H\n\tK+iYpuBbbYZFZnQA5+P2Q1kg/i5CELcIvZuJH8u99Mfj4k0T/+KGs2SCI4gmbmw8S9\n\tTX8PWEfXmYBXg68afYiideWuaYy9uHMd4LuHdPvC0xh9xu7w1pfRDr7EI637xn9ewn\n\ttgKXdquDbp60A==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1664915255;\n\tbh=ya1HsmotZoSVcKUeMrvYhD148B6eTRFKSSQSkv/4S5c=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Ohn1Cht18Ea8JiDKkqT1xuZ8znq698rLOGoGxGSTktvuael+lAGqKY1jI6IIfK+Vp\n\tO/7pVdS2N6TiAZ5aL+rL5QJnYpSGyFKUkd5egNGVIOWRUHf4EEBaf1zG3rOl1g0ghO\n\tl1Wxg0A1Fx5OoW+pY/iVWoFz9XYLIgd2jnPmNrWM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Ohn1Cht1\"; dkim-atps=neutral","Date":"Tue, 4 Oct 2022 23:27:32 +0300","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<YzyXNNogb+BH4uut@pendragon.ideasonboard.com>","References":"<20220804104550.4600-1-david.plowman@raspberrypi.com>\n\t<20220804104550.4600-2-david.plowman@raspberrypi.com>\n\t<YuwPFmExcTPOU6oN@pendragon.ideasonboard.com>\n\t<CAHW6GY+S=9qH80yFGaUndMs-sjwaCH4KVZ1zxtoCWDfE5Kxfyg@mail.gmail.com>\n\t<CAHW6GY+rQ7tphHg2ebysWMk+0bxVUcxBYQoegsVtRbuT-d4EOA@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAHW6GY+rQ7tphHg2ebysWMk+0bxVUcxBYQoegsVtRbuT-d4EOA@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: formats: Fix colour\n\tencoding for \"R\" raw greyscale 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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":25286,"web_url":"https://patchwork.libcamera.org/comment/25286/","msgid":"<CAHW6GYJe-SjwiDPFskRDHd5L-YjdZkVKB2jF2Ps6CYR+RwkW_w@mail.gmail.com>","date":"2022-10-05T08:54:09","subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: formats: Fix colour\n\tencoding for \"R\" raw greyscale 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 merging our \"workaround\" patch. That helps us to keep going\nin the meantime! On the wider subject...\n\nOn Tue, 4 Oct 2022 at 21:27, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi David,\n>\n> On Wed, Aug 10, 2022 at 12:14:04PM +0100, David Plowman wrote:\n> > On Mon, 8 Aug 2022 at 12:18, David Plowman wrote:\n> > > On Thu, 4 Aug 2022 at 19:25, Laurent Pinchart wrote:\n> > > > On Thu, Aug 04, 2022 at 11:45:49AM +0100, David Plowman via libcamera-devel wrote:\n> > > > > These are being used for raw monochrome sensors and so the colour\n> > > > > encoding should be \"raw\".\n> > > >\n> > > > Ouch. This is something I didn't foresee, but we have a problem here.\n> > > > These can refer to both raw data from monochrome sensors, but also\n> > > > greyscale data processed by an ISP. We currently don't consider as RAW\n> > > > formats, which means that\n> > > >\n> > > > - The CameraConfiguration::validateColorSpaces() will accept other color\n> > > >   spaces that ColorSpace::Raw.\n> > > > - The IPU3 and Raspberry Pi pipeline handlers, and the Android HAL, will\n> > > >   consider them as processed streams, not raw streams.\n> > > >\n> > > > This patch will change that, quite likely introducing breakages.\n> > > >\n> > > > Now, the interesting question is how to support both raw monochrome data\n> > > > and processed monochrome data. Any idea ? :-)\n> > >\n> > > Hmm. That's all a bit awkward. Am I right in thinking that this comes\n> > > fundamentally from the V4L2 drivers which tell us a format (e.g.\n> > > \"10-bit greyscale\") but not whether it's raw or processed? Which\n> > > presumably makes it a bit awkward to fix \"properly\".\n>\n> In some cases that can be problematic, such as when an ISP receives\n> greyscale raw data and has the ability to output greyscale processed\n> data, or bypass all processing to capture the raw data. We wouldn't be\n> able to configure this through the format on the ISP source pad only. In\n> that case it's probably best to use a different means to configure the\n> ISP bypass (V4L2 control, MC link, ISP parameter buffer, ...). In all\n> other cases, the pipeline handler should be able to figure things out.\n>\n> > > Alternatively, I suppose we could add (slightly ugly) workarounds in\n> > > the Pi pipeline handler, along the lines of \"oh, it says R10, I know\n> > > that's really a raw format\", because that's true for us. I don't\n> > > really think that I'm seeing anything better than this at the\n> > > moment...\n> >\n> > Here's another thought...\n> >\n> > The problem is that we have more than one possible colour encoding for\n> > the \"R\" formats. If we aren't going to change V4L2 to have raw and\n> > non-raw \"R\" formats anytime soon then maybe we should let the\n> > PixelFormatInfo record all the possible colour encodings.\n>\n> The libcamera PixelFormat class shares with V4L2 the inability to\n> discriminate between raw and processed formats, but I don't think V4L2\n> limits us as such. It is hidden within the pipeline handler and not\n> exposed to applications, so we could change the PixelFormat class\n> without requiring a similar change in V4L2 pixel formats.\n>\n> > Now, I'm guessing that turning the PixelFormatInfo.colourEncoding\n> > field into a std::vector<enum ColourEncoding> is probably going to be\n> > a bit annoying to existing code. We could decide to do it, though\n> > another option might be to add an \"alternate\" colour encoding field\n> > instead.\n> >\n> > This too could just be a std::vector<enum ColourEncoding> that\n> > contains all the other possibilities. The benefit is that it doesn't\n> > upset existing code which wouldn't check the new field and nothing\n> > would change. The table in formats.h could omit the field altogether\n> > (leaving an empty vector) except where it is needed.\n> >\n> > Thoughts?\n>\n> I've merged your patch that works around this issue for the Raspberry Pi\n> pipeline handler, so from that point of view the problem is solved. I'd\n> still like to share my thoughts though.\n>\n> I'm not sure the lack of discrimination ability in the pixel format is\n> actually an issue. The pixel format is conceptually the same in both\n> case, it's 8-bit or 10-bit or 12-bit greyscale data in memory. I like\n> the idea that the pixel format describes the memory format, and not what\n> processing has been applied. I would like to keep this.\n\nI agree with this. I guess the question is whether the PixelFormat\nclass is describing just the memory format, or something more. In the\nformer case I think things like \"colour encoding\" simply shouldn't be\nthere. In the latter case... well, there's a long history of folks\nmixing memory formats, colour encodings and colour spaces together in\nslightly implicit ways, and I'm not sure it's been doing us much good,\nbut it's a hard thing to fix!!\n\n>\n> What we're missing, in my opinion, is a way to determine where in the\n> pipeline to capture a frame based on other information than just the\n> pixel format. I think this is something we could get from streams, by\n> making them take a more important role in the camera configuration.\n> Applications should be able to decide which streams to capture in a more\n> explicit way. I'll resume at some poit work I started a while ago to\n> rework the configuration API, and I will likely go in this direction.\n\nWould be interested to hear more about this! I'm not quite sure what\n\"which streams to capture in a more explicit way\" might mean?\n\nFrom my point of view the configuration API seems mostly pretty good,\napart from some niggles with the format / colour encoding (as\ndiscussed above) or recent colour space changes which are unhelpful to\nus. libcamera of course already has a lot of active users (a good\nthing, I hasten to add) so I'm a bit nervous about rocking the boat\ntoo much!!\n\nThanks!\nDavid\n\n>\n> This of course leaves open the question of what the colourEncoding\n> member of the PixelFormatInfo class should store. Your idea of using a\n> vector isn't a bad one, but I'd like to revisit that on top of the\n> configuration API rework, as usage of the colourEncoding field will\n> possibly be quite different then.\n>\n> > > > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > > > ---\n> > > > >  src/libcamera/formats.cpp | 8 ++++----\n> > > > >  1 file changed, 4 insertions(+), 4 deletions(-)\n> > > > >\n> > > > > diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp\n> > > > > index 283ecb3d..7b98fef2 100644\n> > > > > --- a/src/libcamera/formats.cpp\n> > > > > +++ b/src/libcamera/formats.cpp\n> > > > > @@ -531,7 +531,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > > > >                       .multi = V4L2PixelFormat(),\n> > > > >               },\n> > > > >               .bitsPerPixel = 8,\n> > > > > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > > > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> > > > >               .packed = false,\n> > > > >               .pixelsPerGroup = 1,\n> > > > >               .planes = {{ { 1, 1 }, { 0, 0 }, { 0, 0 } }},\n> > > > > @@ -544,7 +544,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > > > >                       .multi = V4L2PixelFormat(),\n> > > > >               },\n> > > > >               .bitsPerPixel = 10,\n> > > > > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > > > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> > > > >               .packed = false,\n> > > > >               .pixelsPerGroup = 1,\n> > > > >               .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},\n> > > > > @@ -557,7 +557,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > > > >                       .multi = V4L2PixelFormat(),\n> > > > >               },\n> > > > >               .bitsPerPixel = 12,\n> > > > > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > > > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> > > > >               .packed = false,\n> > > > >               .pixelsPerGroup = 1,\n> > > > >               .planes = {{ { 2, 1 }, { 0, 0 }, { 0, 0 } }},\n> > > > > @@ -570,7 +570,7 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{\n> > > > >                       .multi = V4L2PixelFormat(),\n> > > > >               },\n> > > > >               .bitsPerPixel = 10,\n> > > > > -             .colourEncoding = PixelFormatInfo::ColourEncodingYUV,\n> > > > > +             .colourEncoding = PixelFormatInfo::ColourEncodingRAW,\n> > > > >               .packed = true,\n> > > > >               .pixelsPerGroup = 4,\n> > > > >               .planes = {{ { 5, 1 }, { 0, 0 }, { 0, 0 } }},\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D756DBD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Oct 2022 08:54:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1A75061FAC;\n\tWed,  5 Oct 2022 10:54:25 +0200 (CEST)","from mail-pg1-x532.google.com (mail-pg1-x532.google.com\n\t[IPv6:2607:f8b0:4864:20::532])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A197C60A88\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Oct 2022 10:54:22 +0200 (CEST)","by mail-pg1-x532.google.com with SMTP id 78so14748308pgb.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 05 Oct 2022 01:54:22 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664960065;\n\tbh=SeVd/Nk2ZZYGe7BNmYjsxF4qzwbN1dadvSjvEWJCx3M=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=eZMRVPhOrOh+r4O1aeGgiTm2h2aDaVTMqr3PNf0WScdLZpAv+wdR4XNKZNvHzGZHZ\n\tmTUe+9k39svq/G1wRgJFvYZchV9aBeXzPIUkQiNNSWgp4SC4HkWg03GZsrzxjydg1w\n\tXBYihIxiymuHZdz5bM8vfVbjHGBDx75Bgysw5fP8frq+R1tIzvxHVonn95eUYpCLWL\n\tgzKfXE8bYplCFTSJ1flvJuerU8k+SOAqFiQlyAmql1xjmNgvsokc57fLlNXKtIBVIO\n\t8GPXl21tcXqDkFbkW08MuZ7Dx3RRtvwNWW0HkRre1g/ptdwv8Svlj2nCarAKP45wvt\n\tbxmNRHrhlGJMQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date;\n\tbh=sj0gK32kyl4Jz5g1+TyiOIGhlroIrdXEf3HgFGelGcw=;\n\tb=JkHJIjxwBu+42yVaIdHoZv4+s/Zw1cOvGMSoUom8YfObqTvgZEFJRUG3YSEZUYit12\n\tYawc86HF+NoIVxjfr0Dy+NIKZdkIZa8gSh2FEYaWZr3fN+j7eBFKE5uQreD92wSUX2aU\n\t2avswjGYkiwOsaP64+VJzI4oKNg07vodtHzzZO4WNEJf61zQpdDNnckiqL1Ll3S5e/Lt\n\tQxzteMyIXjwYOnkbjef8YTEIaYqwx3RdA6bbkhtjr555J84I6adtzI85uz3iJ8/mi4TV\n\tMR9hsI/YCenVah9cxq/yesPKdXThYGr7BcEIaSeoHO/yCfz/uO1cz41Gk4zSNOedDQE/\n\tqaMg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"JkHJIjxw\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date;\n\tbh=sj0gK32kyl4Jz5g1+TyiOIGhlroIrdXEf3HgFGelGcw=;\n\tb=Uzy5UYBGSHGWJcBfMxrZWkcR5bUutC6eztwYpytFJQRmkdMoVLeAVJyf+jKU2VhHjW\n\t77o8HUJZGSHJZIElWoRmo9E4XkDOYgATuC7krpgP++ezLyuhJ+2Xg4qPMPsUtSjPrC1O\n\trLaCGIXax6JZWm0CZfN3GyUkZdYid/7GJdEgidW3HlTJRon/RpQFEyth3Ce5ReyCtdyO\n\tD3BAI7R6rpo6DqN7jAwFOJdnFPm+glyuRefIh7IYF2mo6C+BR/BkZDjniC+HlY5Y7wdk\n\tlNpFQfYKhXXrWtxcmeY5iAV7PKhOko590ng6EEEMVq6lFVdfpQa/Tfk0h1vkcFD0ANnS\n\tExrA==","X-Gm-Message-State":"ACrzQf1wbeXM9yLiRuWIuAJ5sgV8FHCIMGn15gBZj+EjZhV4fZSIF5LP\n\tElhazQj+8tbT8wv4PDHmlpqq6D7wuSrcGBH9LpxXF7Exe9w=","X-Google-Smtp-Source":"AMsMyM58y0c9+u4gYkA9+QL+9yXqqRKGDbbgoitDMn1i6u5B5WpnG0yF/EjuBdglZnXT3Cj0xTQnL6VV+0i8+HiDbQw=","X-Received":"by 2002:a63:f103:0:b0:439:398f:80f8 with SMTP id\n\tf3-20020a63f103000000b00439398f80f8mr8237716pgi.494.1664960060958;\n\tWed, 05 Oct 2022 01:54:20 -0700 (PDT)","MIME-Version":"1.0","References":"<20220804104550.4600-1-david.plowman@raspberrypi.com>\n\t<20220804104550.4600-2-david.plowman@raspberrypi.com>\n\t<YuwPFmExcTPOU6oN@pendragon.ideasonboard.com>\n\t<CAHW6GY+S=9qH80yFGaUndMs-sjwaCH4KVZ1zxtoCWDfE5Kxfyg@mail.gmail.com>\n\t<CAHW6GY+rQ7tphHg2ebysWMk+0bxVUcxBYQoegsVtRbuT-d4EOA@mail.gmail.com>\n\t<YzyXNNogb+BH4uut@pendragon.ideasonboard.com>","In-Reply-To":"<YzyXNNogb+BH4uut@pendragon.ideasonboard.com>","Date":"Wed, 5 Oct 2022 09:54:09 +0100","Message-ID":"<CAHW6GYJe-SjwiDPFskRDHd5L-YjdZkVKB2jF2Ps6CYR+RwkW_w@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: formats: Fix colour\n\tencoding for \"R\" raw greyscale 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>","From":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]