[{"id":26190,"web_url":"https://patchwork.libcamera.org/comment/26190/","msgid":"<CAEmqJPr9ygo9gHKr8XVjZoCPYc+GiqyvDOtX7XtBK7dLZyvUEA@mail.gmail.com>","date":"2023-01-06T10:09:32","subject":"Re: [libcamera-devel] [PATCH v2 2/2] pipeline: raspberrypi: Fix\n\thandling of colour spaces","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi David,\n\nThank you for your work.\n\nOn Tue, 3 Jan 2023 at 11:33, David Plowman via libcamera-devel <\nlibcamera-devel@lists.libcamera.org> wrote:\n\n> We implement a custom validateColorSpaces method that forces all\n> (non-raw) streams to same colour space, whilst distinguishing RGB\n> streams from YUV ones, as the former must have the YCbCr encoding and\n> range over-written.\n>\n> When we apply the colour space, we always send the full YUV version as\n> that gets converted correctly to what our hardware drivers expect. It\n> is also careful to check what comes back as the YCbCr information gets\n> overwritten again.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  .../pipeline/raspberrypi/raspberrypi.cpp      | 99 ++++++++++++++++++-\n>  1 file changed, 98 insertions(+), 1 deletion(-)\n>\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 8569df17..bb574afc 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -310,6 +310,7 @@ class RPiCameraConfiguration : public\n> CameraConfiguration\n>  public:\n>         RPiCameraConfiguration(const RPiCameraData *data);\n>\n> +       CameraConfiguration::Status validateColorSpaces(ColorSpaceFlags\n> flags);\n>         Status validate() override;\n>\n>         /* Cache the combinedTransform_ that will be applied to the sensor\n> */\n> @@ -317,6 +318,13 @@ public:\n>\n>  private:\n>         const RPiCameraData *data_;\n> +\n> +       /*\n> +        * Store the colour spaces that all our streams will have. RGB\n> format streams\n> +        * will be the same but need the YCbCr fields cleared.\n> +        */\n> +       std::optional<ColorSpace> yuvColorSpace_;\n> +       std::optional<ColorSpace> rgbColorSpace_;\n>  };\n>\n\nShould these fields live in RPiCameraData for the multi-camera cases?\n\n\n>\n>  class PipelineHandlerRPi : public PipelineHandler\n> @@ -357,6 +365,89 @@ RPiCameraConfiguration::RPiCameraConfiguration(const\n> RPiCameraData *data)\n>  {\n>  }\n>\n> +static const std::vector<ColorSpace> validColorSpaces = {\n> +       ColorSpace::Sycc,\n> +       ColorSpace::Smpte170m,\n> +       ColorSpace::Rec709\n> +};\n> +\n> +static std::optional<ColorSpace> findValidColorSpace(const ColorSpace\n> &colourSpace)\n> +{\n> +       for (auto cs : validColorSpaces) {\n> +               if (colourSpace.primaries == cs.primaries &&\n> +                   colourSpace.transferFunction == cs.transferFunction)\n> +                       return cs;\n> +       }\n> +\n> +       return std::nullopt;\n> +}\n> +\n> +static bool isRgb(const PixelFormat &pixFmt)\n> +{\n> +       /*\n> +        * Be careful not to use this when a format might be raw because\n> it returns\n> +        * the wrong result for mono raw streams.\n> +        */\n>\n\nCould we add an assert that tests this?\n\nWith those addressed (if appropriate):\n\nReviewed-by: Naushir Patuck <naushir@raspberrypi.com>\n\n\n> +       const PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);\n> +       return info.colourEncoding == PixelFormatInfo::ColourEncodingRGB;\n> +}\n> +\n> +static bool isYuv(const PixelFormat &pixFmt)\n> +{\n> +       const PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);\n> +       return info.colourEncoding == PixelFormatInfo::ColourEncodingYUV;\n> +}\n> +\n> +CameraConfiguration::Status\n> RPiCameraConfiguration::validateColorSpaces([[maybe_unused]]\n> ColorSpaceFlags flags)\n> +{\n> +       Status status = Valid;\n> +       yuvColorSpace_.reset();\n> +\n> +       for (auto cfg : config_) {\n> +               /* First fix up raw streams to have the \"raw\" colour\n> space. */\n> +               if (isRaw(cfg.pixelFormat) && cfg.colorSpace !=\n> ColorSpace::Raw) {\n> +                       /* If there was no value here, that doesn't count\n> as \"adjusted\". */\n> +                       if (cfg.colorSpace)\n> +                               status = Adjusted;\n> +                       cfg.colorSpace = ColorSpace::Raw;\n> +               }\n> +\n> +               /* Next we need to find our shared colour space. The first\n> valid one will do. */\n> +               if (cfg.colorSpace && cfg.colorSpace != ColorSpace::Raw &&\n> !yuvColorSpace_)\n> +                       yuvColorSpace_ =\n> findValidColorSpace(cfg.colorSpace.value());\n> +       }\n> +\n> +       /* If no colour space was given anywhere, choose sYCC. */\n> +       if (!yuvColorSpace_)\n> +               yuvColorSpace_ = ColorSpace::Sycc;\n> +\n> +       /* Note the version of this that any RGB streams will have to use.\n> */\n> +       rgbColorSpace_ = yuvColorSpace_;\n> +       rgbColorSpace_->ycbcrEncoding = ColorSpace::YcbcrEncoding::None;\n> +       rgbColorSpace_->range = ColorSpace::Range::Full;\n> +\n> +       /* Go through the streams again and force everyone to the same\n> colour space. */\n> +       for (auto cfg : config_) {\n> +               if (cfg.colorSpace == ColorSpace::Raw)\n> +                       continue;\n> +\n> +               if (isYuv(cfg.pixelFormat) && cfg.colorSpace !=\n> yuvColorSpace_) {\n> +                       /* Again, no value means \"not adjusted\". */\n> +                       if (cfg.colorSpace)\n> +                               status = Adjusted;\n> +                       cfg.colorSpace = yuvColorSpace_;\n> +               }\n> +               if (isRgb(cfg.pixelFormat) && cfg.colorSpace !=\n> rgbColorSpace_) {\n> +                       /* Be nice, and let the YUV version count as\n> non-adjusted too. */\n> +                       if (cfg.colorSpace && cfg.colorSpace !=\n> yuvColorSpace_)\n> +                               status = Adjusted;\n> +                       cfg.colorSpace = rgbColorSpace_;\n> +               }\n> +       }\n> +\n> +       return status;\n> +}\n> +\n>  CameraConfiguration::Status RPiCameraConfiguration::validate()\n>  {\n>         Status status = Valid;\n> @@ -533,7 +624,8 @@ CameraConfiguration::Status\n> RPiCameraConfiguration::validate()\n>                 V4L2DeviceFormat format;\n>                 format.fourcc = dev->toV4L2PixelFormat(cfg.pixelFormat);\n>                 format.size = cfg.size;\n> -               format.colorSpace = cfg.colorSpace;\n> +               /* We want to send the associated YCbCr info through to\n> the driver. */\n> +               format.colorSpace = yuvColorSpace_;\n>\n>                 LOG(RPI, Debug)\n>                         << \"Try color space \" <<\n> ColorSpace::toString(cfg.colorSpace);\n> @@ -542,6 +634,11 @@ CameraConfiguration::Status\n> RPiCameraConfiguration::validate()\n>                 if (ret)\n>                         return Invalid;\n>\n> +               /*\n> +                * But for RGB streams, the YCbCr info gets overwritten on\n> the way back\n> +                * so we must check against what the stream cfg says, not\n> what we actually\n> +                * requested (which carefully included the YCbCr info)!\n> +                */\n>                 if (cfg.colorSpace != format.colorSpace) {\n>                         status = Adjusted;\n>                         LOG(RPI, Debug)\n> --\n> 2.30.2\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 EEA20BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  6 Jan 2023 10:09:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3228D625CF;\n\tFri,  6 Jan 2023 11:09:51 +0100 (CET)","from mail-yw1-x1133.google.com (mail-yw1-x1133.google.com\n\t[IPv6:2607:f8b0:4864:20::1133])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 594C161F09\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Jan 2023 11:09:49 +0100 (CET)","by mail-yw1-x1133.google.com with SMTP id\n\t00721157ae682-4a263c4ddbaso16915297b3.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 06 Jan 2023 02:09:49 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1672999791;\n\tbh=vzxXmScC2xl+ucilcpvtwb5fVrdMiIWlDnJo0ATmu8E=;\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=NFR83FXoQ0ejK0x762guLS/PUtIRy3J7h5Q8V4LZLWy8a5q0rUTKkCEYBmg3o1XfA\n\t79fEvC5a0zWtV3AJ4WruPICHMut8lTAvbK3uzRUBmkiJoyNVx3EeK+1doy7OGjCfvN\n\tRIUZIu1oh/sUGCk2Fp0wNo/D+wxMhm7kiXU2QaJiafuwU8/QK2Z1YSyX8oCOQcE0q5\n\t2oXGfNP/C4Hb00O6s6Lm67pY8OqhNwo5RqCM+YRILoOyI9ZtUyPwkfs2edOTEzUF47\n\tLBkesJQqOx3uBtsD/NYKGJJMMT54fuCGAAQuaXIqfWe48t+ZjRz26S9XG0ZxQdAKBy\n\t+RP78GLtSBh6w==","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:message-id:reply-to;\n\tbh=mloSxRJQJhFGyWRzz7BRlpjIsrJyjs/cnwRP+e97yFs=;\n\tb=DxBCRdyiIrJmEoB2wol2OZHbgJIFC1IW9ixtcL9upC03HmOupSOwhE+3iOgMSkloY+\n\tveRaaXmgZBAWuvIXSd6eshOuOXwdeGkzBn8IOWq9QuWogJNLLvvBBWQs616Ast7StSpg\n\t8wI7+lCAM+Umw0Vd+mL6DpJ1yDKo5AFCopL+9DByu471fMsR7DJhhydzIyD+FTZluJXq\n\ta6QAP0Jr/8JDh0fHoy0BH27Y66CNYbX6F+vHskKskJvld67ghVEGSI0S6jaK38WUgroA\n\tiNYph3dEkqZ8j6NWHZzVKGmbzWFh9deP2nlx+Nh0cMC5Bv7Cqt4Ias/L77CJJO7BDOGF\n\tx20w=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"DxBCRdyi\"; 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:message-id\n\t:reply-to;\n\tbh=mloSxRJQJhFGyWRzz7BRlpjIsrJyjs/cnwRP+e97yFs=;\n\tb=uuKtkFbL6w8Sdsxta4NtVRP0fdpoOdLQHRM/ReYNE9dG/4Z5Xv02pVmx3QXtJ5iDy8\n\tk7ryJ88ovDpQ3hK36KA9Its9R45y5lSsO0cdwqdUh6VAOID9DkwVtlUgBm6TVqLm8M6g\n\twYEj1Ykxw71WBsb7noPi6wFfypE9MpIz8LXYZb2xdrsZXONFwUfENCFBPPUp+00zZt08\n\tLKWSNca43WDHJg2J5dA3R20pWOp1UbNxnKYGuDXTiAVJFmuEvHMIGPgMSy7J2ZFVym6M\n\ti6NfgyNaXBEldTZxm6VCCJJeJikr6Lx7GEq7ccHb+J89YFGZv813FtsNJa3ywMIhXM+x\n\tnezA==","X-Gm-Message-State":"AFqh2kpFlExjL/NFvZDzK7oF/vvDbagIECD8Cz9H/fqMMoWa50b1EedO\n\tRuU0E3hVcouZQk6ziiAJMoN74eGc0tyKutcvy4Ffsg==","X-Google-Smtp-Source":"AMrXdXupfBLoQ6JH9RUVThxMYiDDhGz7S1bF1cvRF0bcYzd6DUw9GKGKzIWvHzupdh3dO8QEXpbhymShgr5lfTjl/uA=","X-Received":"by 2002:a81:8101:0:b0:38e:b5bc:e996 with SMTP id\n\tr1-20020a818101000000b0038eb5bce996mr261086ywf.493.1672999788128;\n\tFri, 06 Jan 2023 02:09:48 -0800 (PST)","MIME-Version":"1.0","References":"<20230103113313.5423-1-david.plowman@raspberrypi.com>\n\t<20230103113313.5423-3-david.plowman@raspberrypi.com>","In-Reply-To":"<20230103113313.5423-3-david.plowman@raspberrypi.com>","Date":"Fri, 6 Jan 2023 10:09:32 +0000","Message-ID":"<CAEmqJPr9ygo9gHKr8XVjZoCPYc+GiqyvDOtX7XtBK7dLZyvUEA@mail.gmail.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Content-Type":"multipart/alternative; boundary=\"00000000000014c1c705f1959eee\"","Subject":"Re: [libcamera-devel] [PATCH v2 2/2] pipeline: raspberrypi: Fix\n\thandling of colour spaces","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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.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":26218,"web_url":"https://patchwork.libcamera.org/comment/26218/","msgid":"<CAHW6GYKACD5xyVnzR42B8pfeU9Exta=k=bax9KD9xGALkCwEmg@mail.gmail.com>","date":"2023-01-12T11:35:03","subject":"Re: [libcamera-devel] [PATCH v2 2/2] pipeline: raspberrypi: Fix\n\thandling of colour spaces","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Naush\n\nThanks for the suggestions.\n\nOn Fri, 6 Jan 2023 at 10:09, Naushir Patuck <naush@raspberrypi.com> wrote:\n>\n> Hi David,\n>\n> Thank you for your work.\n>\n> On Tue, 3 Jan 2023 at 11:33, David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org> wrote:\n>>\n>> We implement a custom validateColorSpaces method that forces all\n>> (non-raw) streams to same colour space, whilst distinguishing RGB\n>> streams from YUV ones, as the former must have the YCbCr encoding and\n>> range over-written.\n>>\n>> When we apply the colour space, we always send the full YUV version as\n>> that gets converted correctly to what our hardware drivers expect. It\n>> is also careful to check what comes back as the YCbCr information gets\n>> overwritten again.\n>>\n>> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n>> ---\n>>  .../pipeline/raspberrypi/raspberrypi.cpp      | 99 ++++++++++++++++++-\n>>  1 file changed, 98 insertions(+), 1 deletion(-)\n>>\n>> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n>> index 8569df17..bb574afc 100644\n>> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n>> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n>> @@ -310,6 +310,7 @@ class RPiCameraConfiguration : public CameraConfiguration\n>>  public:\n>>         RPiCameraConfiguration(const RPiCameraData *data);\n>>\n>> +       CameraConfiguration::Status validateColorSpaces(ColorSpaceFlags flags);\n>>         Status validate() override;\n>>\n>>         /* Cache the combinedTransform_ that will be applied to the sensor */\n>> @@ -317,6 +318,13 @@ public:\n>>\n>>  private:\n>>         const RPiCameraData *data_;\n>> +\n>> +       /*\n>> +        * Store the colour spaces that all our streams will have. RGB format streams\n>> +        * will be the same but need the YCbCr fields cleared.\n>> +        */\n>> +       std::optional<ColorSpace> yuvColorSpace_;\n>> +       std::optional<ColorSpace> rgbColorSpace_;\n>>  };\n>\n>\n> Should these fields live in RPiCameraData for the multi-camera cases?\n\nHaving looked again at this, I think we've decided it's OK.\n\n>\n>>\n>>\n>>  class PipelineHandlerRPi : public PipelineHandler\n>> @@ -357,6 +365,89 @@ RPiCameraConfiguration::RPiCameraConfiguration(const RPiCameraData *data)\n>>  {\n>>  }\n>>\n>> +static const std::vector<ColorSpace> validColorSpaces = {\n>> +       ColorSpace::Sycc,\n>> +       ColorSpace::Smpte170m,\n>> +       ColorSpace::Rec709\n>> +};\n>> +\n>> +static std::optional<ColorSpace> findValidColorSpace(const ColorSpace &colourSpace)\n>> +{\n>> +       for (auto cs : validColorSpaces) {\n>> +               if (colourSpace.primaries == cs.primaries &&\n>> +                   colourSpace.transferFunction == cs.transferFunction)\n>> +                       return cs;\n>> +       }\n>> +\n>> +       return std::nullopt;\n>> +}\n>> +\n>> +static bool isRgb(const PixelFormat &pixFmt)\n>> +{\n>> +       /*\n>> +        * Be careful not to use this when a format might be raw because it returns\n>> +        * the wrong result for mono raw streams.\n>> +        */\n>\n>\n> Could we add an assert that tests this?\n\nTrue enough. In fact, why don't I just handle that case correctly?\nI'll submit a v3 with that little change!\n\nThanks\nDavid\n\n>\n> With those addressed (if appropriate):\n>\n> Reviewed-by: Naushir Patuck <naushir@raspberrypi.com>\n>\n>>\n>> +       const PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);\n>> +       return info.colourEncoding == PixelFormatInfo::ColourEncodingRGB;\n>> +}\n>> +\n>> +static bool isYuv(const PixelFormat &pixFmt)\n>> +{\n>> +       const PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);\n>> +       return info.colourEncoding == PixelFormatInfo::ColourEncodingYUV;\n>> +}\n>> +\n>> +CameraConfiguration::Status RPiCameraConfiguration::validateColorSpaces([[maybe_unused]] ColorSpaceFlags flags)\n>> +{\n>> +       Status status = Valid;\n>> +       yuvColorSpace_.reset();\n>> +\n>> +       for (auto cfg : config_) {\n>> +               /* First fix up raw streams to have the \"raw\" colour space. */\n>> +               if (isRaw(cfg.pixelFormat) && cfg.colorSpace != ColorSpace::Raw) {\n>> +                       /* If there was no value here, that doesn't count as \"adjusted\". */\n>> +                       if (cfg.colorSpace)\n>> +                               status = Adjusted;\n>> +                       cfg.colorSpace = ColorSpace::Raw;\n>> +               }\n>> +\n>> +               /* Next we need to find our shared colour space. The first valid one will do. */\n>> +               if (cfg.colorSpace && cfg.colorSpace != ColorSpace::Raw && !yuvColorSpace_)\n>> +                       yuvColorSpace_ = findValidColorSpace(cfg.colorSpace.value());\n>> +       }\n>> +\n>> +       /* If no colour space was given anywhere, choose sYCC. */\n>> +       if (!yuvColorSpace_)\n>> +               yuvColorSpace_ = ColorSpace::Sycc;\n>> +\n>> +       /* Note the version of this that any RGB streams will have to use. */\n>> +       rgbColorSpace_ = yuvColorSpace_;\n>> +       rgbColorSpace_->ycbcrEncoding = ColorSpace::YcbcrEncoding::None;\n>> +       rgbColorSpace_->range = ColorSpace::Range::Full;\n>> +\n>> +       /* Go through the streams again and force everyone to the same colour space. */\n>> +       for (auto cfg : config_) {\n>> +               if (cfg.colorSpace == ColorSpace::Raw)\n>> +                       continue;\n>> +\n>> +               if (isYuv(cfg.pixelFormat) && cfg.colorSpace != yuvColorSpace_) {\n>> +                       /* Again, no value means \"not adjusted\". */\n>> +                       if (cfg.colorSpace)\n>> +                               status = Adjusted;\n>> +                       cfg.colorSpace = yuvColorSpace_;\n>> +               }\n>> +               if (isRgb(cfg.pixelFormat) && cfg.colorSpace != rgbColorSpace_) {\n>> +                       /* Be nice, and let the YUV version count as non-adjusted too. */\n>> +                       if (cfg.colorSpace && cfg.colorSpace != yuvColorSpace_)\n>> +                               status = Adjusted;\n>> +                       cfg.colorSpace = rgbColorSpace_;\n>> +               }\n>> +       }\n>> +\n>> +       return status;\n>> +}\n>> +\n>>  CameraConfiguration::Status RPiCameraConfiguration::validate()\n>>  {\n>>         Status status = Valid;\n>> @@ -533,7 +624,8 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n>>                 V4L2DeviceFormat format;\n>>                 format.fourcc = dev->toV4L2PixelFormat(cfg.pixelFormat);\n>>                 format.size = cfg.size;\n>> -               format.colorSpace = cfg.colorSpace;\n>> +               /* We want to send the associated YCbCr info through to the driver. */\n>> +               format.colorSpace = yuvColorSpace_;\n>>\n>>                 LOG(RPI, Debug)\n>>                         << \"Try color space \" << ColorSpace::toString(cfg.colorSpace);\n>> @@ -542,6 +634,11 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n>>                 if (ret)\n>>                         return Invalid;\n>>\n>> +               /*\n>> +                * But for RGB streams, the YCbCr info gets overwritten on the way back\n>> +                * so we must check against what the stream cfg says, not what we actually\n>> +                * requested (which carefully included the YCbCr info)!\n>> +                */\n>>                 if (cfg.colorSpace != format.colorSpace) {\n>>                         status = Adjusted;\n>>                         LOG(RPI, Debug)\n>> --\n>> 2.30.2\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 BB428C3292\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 12 Jan 2023 11:35:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1C52661F05;\n\tThu, 12 Jan 2023 12:35:18 +0100 (CET)","from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com\n\t[IPv6:2607:f8b0:4864:20::22e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BC33561F05\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Jan 2023 12:35:15 +0100 (CET)","by mail-oi1-x22e.google.com with SMTP id d188so3902499oia.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Jan 2023 03:35:15 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1673523318;\n\tbh=bdTgvXNCgOfVfvSzO6Fm/Ruji1FlcQquw1qwDfdPhJI=;\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=kbFNNIVx0P/5ZFakpzUK2mYCz83PwMl518Omn+hrV56i3lONl3LLEPOGumIhG++8k\n\tSJFdlgUh1S/0DXO8BskjldYt4drOJD1dH9DTozjeC2IG9J/1CdOawmg2Rg7oigsbwL\n\toJ9rvV9VscZzxuVbZAAoKUu2hE5EWsoEC4q7BPKvsEEY+lSd2gxa7zvu1qXAd2v5s7\n\tRRJghrWcRXHvBqZAY6qxA3wZlnE0mzdcWcAwyjJvRG0y9TsTKJpyZ9AfnL3V+oDt0w\n\tsTPceneeE5RgANxgmX4E5a3XS3ML95xg0f9BIDnR0WqxHhKho3bLv5WyXDTXG+m/T8\n\tyuHt804GUmbbw==","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:message-id:reply-to;\n\tbh=xn93h675WsDB+YtU0rdSMD/pmn3/eL0ScPYdzJtj1Pc=;\n\tb=CUyDoWw5pTQSXiOSMvNfv3jeCtrR2HMe+mOXcNel+7eOpllglXBW+M+tbeB2gkGtNg\n\tg7WzPUnbo1vNnLv9Gbk7waZrwnADqFZ5ebjoqrNYv8Mu6iNkRMV5B8Pq18tklg1zcSbx\n\t7MwRMFMUtlCoWWB2K50o+Eg0cqpMFIq+Jc/npvZGNksV6azZAmBNVJ0keZ90RrcHruap\n\tPctsc50JUGGR51BUi8q4ou8gzPjLNLrgk7KbKxfF6V/Uc+BGViIv6sBnRMeUED0WjF7g\n\tQpWq0+jxewELeUXxxabQ2oeU857p5hE2TT2urve54dieuvGPdCph4zA8Mz2ZOCfD3wWi\n\thlOg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"CUyDoWw5\"; 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:message-id\n\t:reply-to;\n\tbh=xn93h675WsDB+YtU0rdSMD/pmn3/eL0ScPYdzJtj1Pc=;\n\tb=DcdQCwQpEO8jaoGjPiOoDs6tMXji1ufPYUsoFuibELCO/xOgeKvJICwrTSUIli4TEV\n\tiq0BgE8e9s7Vx0uZ5vD9O4s/D5Bz94+uu/Pbrcga8aV5w3U3yFkd5AA94MPr5/EuUzkY\n\tLtTXZBaSfaASjvSgXfrL0AQwW67nujPxz30YlcAupgN5wPdg/VgH1pLBUKxL84Qkzeff\n\tui3GOPVDK+1kIV2r64Oo22ay8iCvkIYkq4/xHmUcnv3YqoQQ78sEJPMzbijBABvS0zrS\n\tvJDylHRonpiZxSifhWpoZ+rLRG/OSokpCWaWI9D/AOHh1vxND5Kh+GvSzgkSb0KGYYZh\n\txnuw==","X-Gm-Message-State":"AFqh2krR1JdxI/Da2OGWGuExhNZ4vM929LuHeOtTCNErNrwbFeMByjn8\n\tB1cDIJW0XH6YiDHTUNVkW2WwA26AUcAfPlpK/dgWrdbrzQ0bNA==","X-Google-Smtp-Source":"AMrXdXt8X6HDJTEm5ZogpPTy5bVVk/8bVC/D0c3ulOlIio7pfjN+wEwE496W19StHzkbBFtCe/QCj55+wvwu+v7bHPs=","X-Received":"by 2002:a05:6808:196:b0:360:fbf1:4489 with SMTP id\n\tw22-20020a056808019600b00360fbf14489mr4413891oic.20.1673523314281;\n\tThu, 12 Jan 2023 03:35:14 -0800 (PST)","MIME-Version":"1.0","References":"<20230103113313.5423-1-david.plowman@raspberrypi.com>\n\t<20230103113313.5423-3-david.plowman@raspberrypi.com>\n\t<CAEmqJPr9ygo9gHKr8XVjZoCPYc+GiqyvDOtX7XtBK7dLZyvUEA@mail.gmail.com>","In-Reply-To":"<CAEmqJPr9ygo9gHKr8XVjZoCPYc+GiqyvDOtX7XtBK7dLZyvUEA@mail.gmail.com>","Date":"Thu, 12 Jan 2023 11:35:03 +0000","Message-ID":"<CAHW6GYKACD5xyVnzR42B8pfeU9Exta=k=bax9KD9xGALkCwEmg@mail.gmail.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 2/2] pipeline: raspberrypi: Fix\n\thandling of colour spaces","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@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]