[{"id":33669,"web_url":"https://patchwork.libcamera.org/comment/33669/","msgid":"<20250320165535.GA13623@pendragon.ideasonboard.com>","date":"2025-03-20T16:55:35","subject":"Re: [PATCH] libcamera: software_isp: Assign colour spaces in\n\tconfigurations","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Milan,\n\nThank you for the patch.\n\nOn Thu, Mar 20, 2025 at 05:26:24PM +0100, Milan Zamazal wrote:\n> StreamConfiguration's should have colorSpace set.  This is not the case\n> in the simple pipeline.  Let's set it there, basically mimicking what\n> rpi and rkisp1 pipelines do (having a common helper may be a\n> consideration).\n> \n> This also fixes a crash in `cam' due to accessing an unset colorSpace.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>  src/libcamera/pipeline/simple/simple.cpp | 16 +++++++++++++++-\n>  1 file changed, 15 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index 6e039bf3..62db96ca 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -25,6 +25,7 @@\n>  #include <libcamera/base/log.h>\n>  \n>  #include <libcamera/camera.h>\n> +#include <libcamera/color_space.h>\n>  #include <libcamera/control_ids.h>\n>  #include <libcamera/request.h>\n>  #include <libcamera/stream.h>\n> @@ -1196,11 +1197,24 @@ SimplePipelineHandler::generateConfiguration(Camera *camera, Span<const StreamRo\n>  \t *\n>  \t * \\todo Implement a better way to pick the default format\n>  \t */\n> -\tfor ([[maybe_unused]] StreamRole role : roles) {\n> +\tfor (StreamRole role : roles) {\n>  \t\tStreamConfiguration cfg{ StreamFormats{ formats } };\n>  \t\tcfg.pixelFormat = formats.begin()->first;\n>  \t\tcfg.size = formats.begin()->second[0].max;\n>  \n> +\t\tswitch (role) {\n> +\t\tcase StreamRole::Raw:\n> +\t\t\tcfg.colorSpace = ColorSpace::Raw;\n> +\t\t\tbreak;\n> +\t\tcase StreamRole::StillCapture:\n> +\t\tcase StreamRole::Viewfinder:\n> +\t\t\tcfg.colorSpace = ColorSpace::Sycc;\n> +\t\t\tbreak;\n> +\t\tcase StreamRole::VideoRecording:\n> +\t\t\tcfg.colorSpace = ColorSpace::Rec709;\n> +\t\t\tbreak;\n> +\t\t}\n> +\n\nDoesn't this need to depend on the hardware ? For instance\nColorSpace::Rec709 uses limited range, so it only makes sense with YUV\nformats. When using a YUV sensor you may be able to produce that colour\nspace, but the software ISP doesn't support outputting YUV.\n\nYou also need colour space handling in\nSimpleCameraConfiguration::validate().\n\n>  \t\tconfig->addConfiguration(cfg);\n>  \t}\n>","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 E5EF0C3304\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 20 Mar 2025 16:56:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2D424617F7;\n\tThu, 20 Mar 2025 17:56:00 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 754C9617F5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 20 Mar 2025 17:55:58 +0100 (CET)","from pendragon.ideasonboard.com (unknown [157.231.223.213])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B456C743;\n\tThu, 20 Mar 2025 17:54:14 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"eDinHL+q\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1742489654;\n\tbh=NxsKNeJ1lVdshTvL+XZ1OLGvT+kXUVDXO4e8+b9oJfA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=eDinHL+qUNnk7z5BxkD6mVr86PTC+wbrVqVMekRXXn4dV7Y9aOL/pOpkow8IjORNn\n\tsvUrBi1XnNaX3n8gAc8J/tmPmYMr/n7pflwhKhxMFRkGbJji+X8r/k6LI4nA22d6OK\n\t0CxnQ9D1r6+aTYyWzw2kToIUlwKkiKfKx2lUC6wQ=","Date":"Thu, 20 Mar 2025 18:55:35 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Milan Zamazal <mzamazal@redhat.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"Re: [PATCH] libcamera: software_isp: Assign colour spaces in\n\tconfigurations","Message-ID":"<20250320165535.GA13623@pendragon.ideasonboard.com>","References":"<20250320162624.121616-1-mzamazal@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250320162624.121616-1-mzamazal@redhat.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":33670,"web_url":"https://patchwork.libcamera.org/comment/33670/","msgid":"<174249111948.783128.17522586842211761612@ping.linuxembedded.co.uk>","date":"2025-03-20T17:18:39","subject":"Re: [PATCH] libcamera: software_isp: Assign colour spaces in\n\tconfigurations","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Milan Zamazal (2025-03-20 16:26:24)\n> StreamConfiguration's should have colorSpace set.  This is not the case\n> in the simple pipeline.  Let's set it there, basically mimicking what\n> rpi and rkisp1 pipelines do (having a common helper may be a\n> consideration).\n> \n> This also fixes a crash in `cam' due to accessing an unset colorSpace.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>  src/libcamera/pipeline/simple/simple.cpp | 16 +++++++++++++++-\n>  1 file changed, 15 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index 6e039bf3..62db96ca 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -25,6 +25,7 @@\n>  #include <libcamera/base/log.h>\n>  \n>  #include <libcamera/camera.h>\n> +#include <libcamera/color_space.h>\n>  #include <libcamera/control_ids.h>\n>  #include <libcamera/request.h>\n>  #include <libcamera/stream.h>\n> @@ -1196,11 +1197,24 @@ SimplePipelineHandler::generateConfiguration(Camera *camera, Span<const StreamRo\n>          *\n>          * \\todo Implement a better way to pick the default format\n>          */\n> -       for ([[maybe_unused]] StreamRole role : roles) {\n> +       for (StreamRole role : roles) {\n>                 StreamConfiguration cfg{ StreamFormats{ formats } };\n>                 cfg.pixelFormat = formats.begin()->first;\n>                 cfg.size = formats.begin()->second[0].max;\n>  \n> +               switch (role) {\n> +               case StreamRole::Raw:\n> +                       cfg.colorSpace = ColorSpace::Raw;\n> +                       break;\n> +               case StreamRole::StillCapture:\n> +               case StreamRole::Viewfinder:\n> +                       cfg.colorSpace = ColorSpace::Sycc;\n> +                       break;\n> +               case StreamRole::VideoRecording:\n> +                       cfg.colorSpace = ColorSpace::Rec709;\n> +                       break;\n> +               }\n> +\n\nI'm not convinced we can set these like this yet. I don't think it's\ncorrect/accurate yet - The debayering isn't performing any CCM or color\nspace conversion that I can see - so I 'suspect' they are always in\nColorSpace::Raw...  but I'm not sure if that's actually valid for a\ndebayered stream ?\n\nBut until there's any form of CSC ... I don't think we can report that\nwe're in Rec709 for instance...\n\nSo maybe ColorSpace::Raw is the correct thing to report for all cases\nnow.\n\nAnd crucially, it needs to be set in validate() so that if an\napplication 'requests' a specific colorspace, the validation specifies\nwhat will actually be provided. (so in the future if there is any CSC,\nit would ensure that the correct colorspace is reported back)...\n\n--\nKieran\n\n\n>                 config->addConfiguration(cfg);\n>         }\n>  \n> -- \n> 2.49.0\n>","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 049E7C3301\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 20 Mar 2025 17:18:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3939368950;\n\tThu, 20 Mar 2025 18:18:44 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 992B3617F5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 20 Mar 2025 18:18:42 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C45EF743;\n\tThu, 20 Mar 2025 18:16:58 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"LUI5L4lU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1742491018;\n\tbh=3+3if+9NDhS3MaP/9MXDbDNsxWg7gzhJWYnmx8hZpJQ=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=LUI5L4lUDO4dil9MhN7krMncv7nliW6TEV+hVF7eu5QeroeImT2JqAprwKcwEN0mw\n\tupRmW/bdulsOnxFm65X0tpuQMA0TegWsK710ztgkE4yXe9Em5rD4sd1XQrjr8P1FLo\n\tPVRAx0UrVV2PN47StZVFdCcCU0jXEXC7WikhjsvU=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250320162624.121616-1-mzamazal@redhat.com>","References":"<20250320162624.121616-1-mzamazal@redhat.com>","Subject":"Re: [PATCH] libcamera: software_isp: Assign colour spaces in\n\tconfigurations","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Milan Zamazal <mzamazal@redhat.com>","To":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Date":"Thu, 20 Mar 2025 17:18:39 +0000","Message-ID":"<174249111948.783128.17522586842211761612@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":33672,"web_url":"https://patchwork.libcamera.org/comment/33672/","msgid":"<20250320172830.GB13623@pendragon.ideasonboard.com>","date":"2025-03-20T17:28:30","subject":"Re: [PATCH] libcamera: software_isp: Assign colour spaces in\n\tconfigurations","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, Mar 20, 2025 at 05:18:39PM +0000, Kieran Bingham wrote:\n> Quoting Milan Zamazal (2025-03-20 16:26:24)\n> > StreamConfiguration's should have colorSpace set.  This is not the case\n> > in the simple pipeline.  Let's set it there, basically mimicking what\n> > rpi and rkisp1 pipelines do (having a common helper may be a\n> > consideration).\n> > \n> > This also fixes a crash in `cam' due to accessing an unset colorSpace.\n> > \n> > Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> > ---\n> >  src/libcamera/pipeline/simple/simple.cpp | 16 +++++++++++++++-\n> >  1 file changed, 15 insertions(+), 1 deletion(-)\n> > \n> > diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> > index 6e039bf3..62db96ca 100644\n> > --- a/src/libcamera/pipeline/simple/simple.cpp\n> > +++ b/src/libcamera/pipeline/simple/simple.cpp\n> > @@ -25,6 +25,7 @@\n> >  #include <libcamera/base/log.h>\n> >  \n> >  #include <libcamera/camera.h>\n> > +#include <libcamera/color_space.h>\n> >  #include <libcamera/control_ids.h>\n> >  #include <libcamera/request.h>\n> >  #include <libcamera/stream.h>\n> > @@ -1196,11 +1197,24 @@ SimplePipelineHandler::generateConfiguration(Camera *camera, Span<const StreamRo\n> >          *\n> >          * \\todo Implement a better way to pick the default format\n> >          */\n> > -       for ([[maybe_unused]] StreamRole role : roles) {\n> > +       for (StreamRole role : roles) {\n> >                 StreamConfiguration cfg{ StreamFormats{ formats } };\n> >                 cfg.pixelFormat = formats.begin()->first;\n> >                 cfg.size = formats.begin()->second[0].max;\n> >  \n> > +               switch (role) {\n> > +               case StreamRole::Raw:\n> > +                       cfg.colorSpace = ColorSpace::Raw;\n> > +                       break;\n> > +               case StreamRole::StillCapture:\n> > +               case StreamRole::Viewfinder:\n> > +                       cfg.colorSpace = ColorSpace::Sycc;\n> > +                       break;\n> > +               case StreamRole::VideoRecording:\n> > +                       cfg.colorSpace = ColorSpace::Rec709;\n> > +                       break;\n> > +               }\n> > +\n> \n> I'm not convinced we can set these like this yet. I don't think it's\n> correct/accurate yet - The debayering isn't performing any CCM or color\n> space conversion that I can see - so I 'suspect' they are always in\n> ColorSpace::Raw...  but I'm not sure if that's actually valid for a\n> debayered stream ?\n> \n> But until there's any form of CSC ... I don't think we can report that\n> we're in Rec709 for instance...\n\nThe soft ISP outputs RGB only, so ycbcrEncoding must be\nYcbcrEncoding::None and range must be Range::Full.\n\n> So maybe ColorSpace::Raw is the correct thing to report for all cases\n> now.\n\nDon't forget that the simpler pipeline handler also works with RGB/YUV\nsensors, without the soft ISP. This needs to be taken into account too.\n\n> And crucially, it needs to be set in validate() so that if an\n> application 'requests' a specific colorspace, the validation specifies\n> what will actually be provided. (so in the future if there is any CSC,\n> it would ensure that the correct colorspace is reported back)...\n> \n> >                 config->addConfiguration(cfg);\n> >         }\n> >","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 61DB0C3304\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 20 Mar 2025 17:28:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8129C68950;\n\tThu, 20 Mar 2025 18:28:55 +0100 (CET)","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 2BD07617F5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 20 Mar 2025 18:28:53 +0100 (CET)","from pendragon.ideasonboard.com (unknown [157.231.223.213])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4E6AA743;\n\tThu, 20 Mar 2025 18:27:09 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"TB/qs7pV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1742491629;\n\tbh=XPUt1pRNqaq1Hz0pA8q9yHCm/zDj87qXJtga4fBdJkI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=TB/qs7pVfXxM355t9VZjuBgiExb6LkQSKXrUv8gFtqvLZnJzbnuL2tfzs6RTynH9B\n\tgdf6O3O14xdvjNC0SdgJHyT8q+D1Iu/aQKe6EEAmK3AvMzzc72JF4UbuXPn4lCQGPh\n\td1tRbqBYyxqF293CKf9vQdMUigc+eztXX1Xpb+QY=","Date":"Thu, 20 Mar 2025 19:28:30 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Milan Zamazal <mzamazal@redhat.com>, libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH] libcamera: software_isp: Assign colour spaces in\n\tconfigurations","Message-ID":"<20250320172830.GB13623@pendragon.ideasonboard.com>","References":"<20250320162624.121616-1-mzamazal@redhat.com>\n\t<174249111948.783128.17522586842211761612@ping.linuxembedded.co.uk>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<174249111948.783128.17522586842211761612@ping.linuxembedded.co.uk>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]