{"id":19071,"url":"https://patchwork.libcamera.org/api/1.1/patches/19071/?format=json","web_url":"https://patchwork.libcamera.org/patch/19071/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20230921165550.50956-8-jacopo.mondi@ideasonboard.com>","date":"2023-09-21T16:55:44","name":"[libcamera-devel,v5,07/13] libcamera: rpi: Make isRaw/isYuv/isRgb static functions","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"5b351d7bdb22de6e8b3ffbb0fa8aef7c53b05a3a","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/1.1/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19071/mbox/","series":[{"id":4034,"url":"https://patchwork.libcamera.org/api/1.1/series/4034/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4034","date":"2023-09-21T16:55:37","name":"libcamera: Introduce SensorConfiguration","version":5,"mbox":"https://patchwork.libcamera.org/series/4034/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19071/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19071/checks/","tags":{},"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 17077C32B0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 21 Sep 2023 16:56:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C733862951;\n\tThu, 21 Sep 2023 18:56:09 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7397B6294B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Sep 2023 18:56:04 +0200 (CEST)","from uno.lan (93-46-82-201.ip106.fastwebnet.it [93.46.82.201])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E48668201;\n\tThu, 21 Sep 2023 18:54:26 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1695315369;\n\tbh=KYw8rMgmbFYHbYUts551PNuej39xt6wtjn+gIchmE9w=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=MQ8LdeCg0nAKOv4qH0iQ1GVR7o0l7IwQMOtma1dcnmTlUAm/aYaR295vdKabPQ3VH\n\t+gc2Pqn6QCSzinzHenfMaQ02mgyi4sovzFZKLueJIrltJ5UiL/VgfOtdOGBUc+OUOb\n\t04fjB4QSZPCO9hh/Yb7TWn6iqip1VC2ZWn/ryi/NMEfVGxAf0PzwfnOh4mfHuTo7nA\n\tRAXnvJgxkDUmiSWrc/M1iJVoPWFgVsZD1dAHK9Bm3uMb4F3sL9RcPUEh4C3kQCN7fl\n\tCJmDkx6jMy1jEq3gs5BBpk8S+cawABPz5qLAf5eveNQga1RdzqeENdj5tbFguh9lmK\n\tviOVUWbaH1PEQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1695315267;\n\tbh=KYw8rMgmbFYHbYUts551PNuej39xt6wtjn+gIchmE9w=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Gi4Qv4lWd3c/Bot7TWbLbPWVWfdb7+uABp5wigsu6/O5a9V6BpesHnAhrEVqo0ufu\n\tPLe0C/cpXI8/xilQgIFjOppbtgs03xy1S9KqJUmQR2pzXsBBP58WxrU+5JsW3P4R6H\n\tSq7odYE3vmo6S+262B3oqjjoXZHyHLAFlONX2y0Y="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Gi4Qv4lW\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 21 Sep 2023 18:55:44 +0200","Message-ID":"<20230921165550.50956-8-jacopo.mondi@ideasonboard.com>","X-Mailer":"git-send-email 2.42.0","In-Reply-To":"<20230921165550.50956-1-jacopo.mondi@ideasonboard.com>","References":"<20230921165550.50956-1-jacopo.mondi@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 07/13] libcamera: rpi: Make\n\tisRaw/isYuv/isRgb static functions","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":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Naushir Patuck <naush@raspberrypi.com>\n\nMove the existing isRaw()/isYuv()/isRgb()into a static function of\nPipelineHandlerBase. This will allow then to be shared with the\npipeline handler derived class.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n .../pipeline/rpi/common/pipeline_base.cpp     | 52 +++++++++----------\n .../pipeline/rpi/common/pipeline_base.h       |  4 ++\n 2 files changed, 30 insertions(+), 26 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\nindex 502cdff0051b..f6f6185cbfef 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n@@ -37,12 +37,6 @@ namespace {\n \n constexpr unsigned int defaultRawBitDepth = 12;\n \n-bool isRaw(const PixelFormat &pixFmt)\n-{\n-\t/* This test works for both Bayer and raw mono formats. */\n-\treturn BayerFormat::fromPixelFormat(pixFmt).isValid();\n-}\n-\n PixelFormat mbusCodeToPixelFormat(unsigned int mbus_code,\n \t\t\t\t  BayerFormat::Packing packingReq)\n {\n@@ -91,22 +85,6 @@ std::optional<ColorSpace> findValidColorSpace(const ColorSpace &colourSpace)\n \treturn std::nullopt;\n }\n \n-bool isRgb(const PixelFormat &pixFmt)\n-{\n-\tconst PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);\n-\treturn info.colourEncoding == PixelFormatInfo::ColourEncodingRGB;\n-}\n-\n-bool isYuv(const PixelFormat &pixFmt)\n-{\n-\t/* The code below would return true for raw mono streams, so weed those out first. */\n-\tif (isRaw(pixFmt))\n-\t\treturn false;\n-\n-\tconst PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);\n-\treturn info.colourEncoding == PixelFormatInfo::ColourEncodingYUV;\n-}\n-\n } /* namespace */\n \n /*\n@@ -129,7 +107,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validateColorSpaces([[maybe_\n \n \tfor (auto cfg : config_) {\n \t\t/* First fix up raw streams to have the \"raw\" colour space. */\n-\t\tif (isRaw(cfg.pixelFormat)) {\n+\t\tif (PipelineHandlerBase::isRaw(cfg.pixelFormat)) {\n \t\t\t/* If there was no value here, that doesn't count as \"adjusted\". */\n \t\t\tif (cfg.colorSpace && cfg.colorSpace != ColorSpace::Raw)\n \t\t\t\tstatus = Adjusted;\n@@ -156,13 +134,13 @@ CameraConfiguration::Status RPiCameraConfiguration::validateColorSpaces([[maybe_\n \t\tif (cfg.colorSpace == ColorSpace::Raw)\n \t\t\tcontinue;\n \n-\t\tif (isYuv(cfg.pixelFormat) && cfg.colorSpace != yuvColorSpace_) {\n+\t\tif (PipelineHandlerBase::isYuv(cfg.pixelFormat) && cfg.colorSpace != yuvColorSpace_) {\n \t\t\t/* Again, no value means \"not adjusted\". */\n \t\t\tif (cfg.colorSpace)\n \t\t\t\tstatus = Adjusted;\n \t\t\tcfg.colorSpace = yuvColorSpace_;\n \t\t}\n-\t\tif (isRgb(cfg.pixelFormat) && cfg.colorSpace != rgbColorSpace_) {\n+\t\tif (PipelineHandlerBase::isRgb(cfg.pixelFormat) && cfg.colorSpace != rgbColorSpace_) {\n \t\t\t/* Be nice, and let the YUV version count as non-adjusted too. */\n \t\t\tif (cfg.colorSpace && cfg.colorSpace != yuvColorSpace_)\n \t\t\t\tstatus = Adjusted;\n@@ -203,7 +181,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \n \tstd::vector<CameraData::StreamParams> rawStreams, outStreams;\n \tfor (const auto &[index, cfg] : utils::enumerate(config_)) {\n-\t\tif (isRaw(cfg.pixelFormat))\n+\t\tif (PipelineHandlerBase::isRaw(cfg.pixelFormat))\n \t\t\trawStreams.emplace_back(index, &cfg);\n \t\telse\n \t\t\toutStreams.emplace_back(index, &cfg);\n@@ -351,6 +329,28 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()\n \treturn status;\n }\n \n+bool PipelineHandlerBase::isRgb(const PixelFormat &pixFmt)\n+{\n+\tconst PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);\n+\treturn info.colourEncoding == PixelFormatInfo::ColourEncodingRGB;\n+}\n+\n+bool PipelineHandlerBase::isYuv(const PixelFormat &pixFmt)\n+{\n+\t/* The code below would return true for raw mono streams, so weed those out first. */\n+\tif (PipelineHandlerBase::isRaw(pixFmt))\n+\t\treturn false;\n+\n+\tconst PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);\n+\treturn info.colourEncoding == PixelFormatInfo::ColourEncodingYUV;\n+}\n+\n+bool PipelineHandlerBase::isRaw(const PixelFormat &pixFmt)\n+{\n+\t/* This test works for both Bayer and raw mono formats. */\n+\treturn BayerFormat::fromPixelFormat(pixFmt).isValid();\n+}\n+\n V4L2DeviceFormat PipelineHandlerBase::toV4L2DeviceFormat(const V4L2VideoDevice *dev,\n \t\t\t\t\t\t\t const V4L2SubdeviceFormat &format,\n \t\t\t\t\t\t\t BayerFormat::Packing packingReq)\ndiff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h\nindex 3e7c487fb0bf..135b74392140 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.h\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h\n@@ -213,6 +213,10 @@ public:\n \t{\n \t}\n \n+\tstatic bool isRgb(const PixelFormat &pixFmt);\n+\tstatic bool isYuv(const PixelFormat &pixFmt);\n+\tstatic bool isRaw(const PixelFormat &pixFmt);\n+\n \tstatic V4L2DeviceFormat toV4L2DeviceFormat(const V4L2VideoDevice *dev,\n \t\t\t\t\t\t   const V4L2SubdeviceFormat &format,\n \t\t\t\t\t\t   BayerFormat::Packing packingReq);\n","prefixes":["libcamera-devel","v5","07/13"]}