{"id":21435,"url":"https://patchwork.libcamera.org/api/1.1/patches/21435/?format=json","web_url":"https://patchwork.libcamera.org/patch/21435/","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":"<20240930152039.72459-3-umang.jain@ideasonboard.com>","date":"2024-09-30T15:20:39","name":"[2/2] libcamera: pipeline: Use isRaw() helper to check RAW pixel formats","commit_ref":null,"pull_url":null,"state":"rejected","archived":false,"hash":"092389eb3abd53cb01314ed5db8d8d9df77908ef","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/1.1/people/86/?format=json","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/21435/mbox/","series":[{"id":4640,"url":"https://patchwork.libcamera.org/api/1.1/series/4640/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4640","date":"2024-09-30T15:20:37","name":"libcamera: pixelformat: Add isRaw() helper","version":1,"mbox":"https://patchwork.libcamera.org/series/4640/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/21435/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/21435/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 2FA8FC32D4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 Sep 2024 15:20:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9D1C86351E;\n\tMon, 30 Sep 2024 17:20:51 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4789163512\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 Sep 2024 17:20:48 +0200 (CEST)","from umang.jain (unknown\n\t[IPv6:2405:201:2015:f873:55d7:c02e:b2eb:ee3f])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3FEEB280;\n\tMon, 30 Sep 2024 17:19:16 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"siOfSjyN\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1727709557;\n\tbh=ZFbCMdeyClpW6m/Cx5DO2jWLzUi48LOTOy3oZp7GJIg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=siOfSjyNbHfDuAwIxYrF1bebXWt5lRNwDDdyg/IbuhOf4ZRz9EqC6XL3n1233EMiW\n\tLtBXaccjbFn2AO5CakiDpD2WTnoOuSWkVI7FXY2SYwgUAPBMKoya9IhUIsBTx9Kkfz\n\tNB3CBNqSFBlwhcaqn6Cx7YSqhiQQLx7juet4XX8Q=","From":"Umang Jain <umang.jain@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tDaniel Scally <dan.scally@ideasonboard.com>,\n\tUmang Jain <umang.jain@ideasonboard.com>","Subject":"[PATCH 2/2] libcamera: pipeline: Use isRaw() helper to check RAW\n\tpixel formats","Date":"Mon, 30 Sep 2024 20:50:39 +0530","Message-ID":"<20240930152039.72459-3-umang.jain@ideasonboard.com>","X-Mailer":"git-send-email 2.45.2","In-Reply-To":"<20240930152039.72459-1-umang.jain@ideasonboard.com>","References":"<20240930152039.72459-1-umang.jain@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>"},"content":"Use the isRaw() helper provided by the PixelFormat class in order to\ndetermine if the given pixel format is a raw format or not.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n src/ipa/rkisp1/rkisp1.cpp                     |  3 +--\n src/libcamera/pipeline/imx8-isi/imx8-isi.cpp  | 13 ++++--------\n src/libcamera/pipeline/ipu3/ipu3.cpp          |  6 ++----\n src/libcamera/pipeline/mali-c55/mali-c55.cpp  | 20 +++++--------------\n src/libcamera/pipeline/rkisp1/rkisp1.cpp      |  9 +++------\n src/libcamera/pipeline/rkisp1/rkisp1_path.cpp | 13 +++++-------\n 6 files changed, 20 insertions(+), 44 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 9e161cab..d0917c19 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -273,8 +273,7 @@ int IPARkISP1::configure(const IPAConfigInfo &ipaConfig,\n \tcontext_.configuration.raw = std::any_of(streamConfig.begin(), streamConfig.end(),\n \t\t[](auto &cfg) -> bool {\n \t\t\tPixelFormat pixelFormat{ cfg.second.pixelFormat };\n-\t\t\tconst PixelFormatInfo &format = PixelFormatInfo::info(pixelFormat);\n-\t\t\treturn format.colourEncoding == PixelFormatInfo::ColourEncodingRAW;\n+\t\t\treturn pixelFormat.isRaw();\n \t\t});\n \n \tfor (auto const &a : algorithms()) {\ndiff --git a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\nindex 72aa6c75..e531ff5e 100644\n--- a/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n+++ b/src/libcamera/pipeline/imx8-isi/imx8-isi.cpp\n@@ -313,8 +313,7 @@ unsigned int ISICameraData::getYuvMediaBusFormat(const PixelFormat &pixelFormat)\n \n unsigned int ISICameraData::getMediaBusFormat(PixelFormat *pixelFormat) const\n {\n-\tif (PixelFormatInfo::info(*pixelFormat).colourEncoding ==\n-\t    PixelFormatInfo::ColourEncodingRAW)\n+\tif (pixelFormat->isRaw())\n \t\treturn getRawMediaBusFormat(pixelFormat);\n \n \treturn getYuvMediaBusFormat(*pixelFormat);\n@@ -453,8 +452,7 @@ ISICameraConfiguration::validateYuv(std::set<Stream *> &availableStreams,\n \t\tLOG(ISI, Debug) << \"Stream \" << i << \": \" << cfg.toString();\n \n \t\t/* If the stream is RAW or not supported default it to YUYV. */\n-\t\tconst PixelFormatInfo &cfgInfo = PixelFormatInfo::info(cfg.pixelFormat);\n-\t\tif (cfgInfo.colourEncoding == PixelFormatInfo::ColourEncodingRAW ||\n+\t\tif (cfg.pixelFormat.isRaw() ||\n \t\t    !formatsMap_.count(cfg.pixelFormat)) {\n \n \t\t\tLOG(ISI, Debug) << \"Stream \" << i << \" format: \"\n@@ -522,10 +520,8 @@ CameraConfiguration::Status ISICameraConfiguration::validate()\n \t\tmaxResolution.width = std::min(2048U, maxResolution.width);\n \n \t/* Validate streams according to the format of the first one. */\n-\tconst PixelFormatInfo info = PixelFormatInfo::info(config_[0].pixelFormat);\n-\n \tStatus validationStatus;\n-\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW)\n+\tif (config_[0].pixelFormat.isRaw())\n \t\tvalidationStatus = validateRaw(availableStreams, maxResolution);\n \telse\n \t\tvalidationStatus = validateYuv(availableStreams, maxResolution);\n@@ -652,8 +648,7 @@ StreamConfiguration PipelineHandlerISI::generateYUVConfiguration(Camera *camera,\n \tstd::map<PixelFormat, std::vector<SizeRange>> streamFormats;\n \n \tfor (const auto &[pixFmt, pipeFmt] : ISICameraConfiguration::formatsMap_) {\n-\t\tconst PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);\n-\t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW)\n+\t\tif (pixFmt.isRaw())\n \t\t\tcontinue;\n \n \t\tstreamFormats[pixFmt] = { { kMinISISize, sensorSize } };\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 430aa902..4e7f43ac 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -215,9 +215,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n \tSize rawSize;\n \n \tfor (const StreamConfiguration &cfg : config_) {\n-\t\tconst PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat);\n-\n-\t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) {\n+\t\tif (cfg.pixelFormat.isRaw()) {\n \t\t\trawCount++;\n \t\t\trawSize = std::max(rawSize, cfg.size);\n \t\t} else {\n@@ -285,7 +283,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n \n \t\tLOG(IPU3, Debug) << \"Validating stream: \" << config_[i].toString();\n \n-\t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) {\n+\t\tif (config_[i].pixelFormat.isRaw()) {\n \t\t\t/* Initialize the RAW stream with the CIO2 configuration. */\n \t\t\tcfg->size = cio2Configuration_.size;\n \t\t\tcfg->pixelFormat = cio2Configuration_.pixelFormat;\ndiff --git a/src/libcamera/pipeline/mali-c55/mali-c55.cpp b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\nindex 45c71c1d..a659a99c 100644\n--- a/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n+++ b/src/libcamera/pipeline/mali-c55/mali-c55.cpp\n@@ -31,16 +31,6 @@\n #include \"libcamera/internal/v4l2_subdevice.h\"\n #include \"libcamera/internal/v4l2_videodevice.h\"\n \n-namespace {\n-\n-bool isFormatRaw(const libcamera::PixelFormat &pixFmt)\n-{\n-\treturn libcamera::PixelFormatInfo::info(pixFmt).colourEncoding ==\n-\t       libcamera::PixelFormatInfo::ColourEncodingRAW;\n-}\n-\n-} /* namespace */\n-\n namespace libcamera {\n \n LOG_DEFINE_CATEGORY(MaliC55)\n@@ -227,7 +217,7 @@ PixelFormat MaliC55CameraData::bestRawFormat() const\n \t */\n \tfor (const auto &maliFormat : maliC55FmtToCode) {\n \t\tPixelFormat pixFmt = maliFormat.first;\n-\t\tif (!isFormatRaw(pixFmt))\n+\t\tif (!pixFmt.isRaw())\n \t\t\tcontinue;\n \n \t\tunsigned int rawCode = maliFormat.second;\n@@ -330,7 +320,7 @@ CameraConfiguration::Status MaliC55CameraConfiguration::validate()\n \tbool frPipeAvailable = true;\n \tStreamConfiguration *rawConfig = nullptr;\n \tfor (StreamConfiguration &config : config_) {\n-\t\tif (!isFormatRaw(config.pixelFormat))\n+\t\tif (!config.pixelFormat.isRaw())\n \t\t\tcontinue;\n \n \t\tif (rawConfig) {\n@@ -375,7 +365,7 @@ CameraConfiguration::Status MaliC55CameraConfiguration::validate()\n \t/* Adjust processed streams. */\n \tSize maxYuvSize;\n \tfor (StreamConfiguration &config : config_) {\n-\t\tif (isFormatRaw(config.pixelFormat))\n+\t\tif (config.pixelFormat.isRaw())\n \t\t\tcontinue;\n \n \t\t/* Adjust format and size for processed streams. */\n@@ -599,7 +589,7 @@ PipelineHandlerMaliC55::generateConfiguration(Camera *camera,\n \t\tstd::map<PixelFormat, std::vector<SizeRange>> formats;\n \t\tfor (const auto &maliFormat : maliC55FmtToCode) {\n \t\t\tPixelFormat pixFmt = maliFormat.first;\n-\t\t\tbool isRaw = isFormatRaw(pixFmt);\n+\t\t\tbool isRaw = pixFmt.isRaw();\n \n \t\t\t/* RAW formats are only supported on the FR pipe. */\n \t\t\tif (pipe != &pipes_[MaliC55FR] && isRaw)\n@@ -795,7 +785,7 @@ int PipelineHandlerMaliC55::configure(Camera *camera,\n \t\tStream *stream = streamConfig.stream();\n \t\tMaliC55Pipe *pipe = pipeFromStream(data, stream);\n \n-\t\tif (isFormatRaw(streamConfig.pixelFormat))\n+\t\tif (streamConfig.pixelFormat.isRaw())\n \t\t\tret = configureRawStream(data, streamConfig, subdevFormat);\n \t\telse\n \t\t\tret = configureProcessedStream(data, streamConfig, subdevFormat);\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex c02c7cf3..6cee7893 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -485,8 +485,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n \t */\n \tif (config_.size() > 1) {\n \t\tfor (const auto &cfg : config_) {\n-\t\t\tif (PixelFormatInfo::info(cfg.pixelFormat).colourEncoding ==\n-\t\t\t    PixelFormatInfo::ColourEncodingRAW) {\n+\t\t\tif (cfg.pixelFormat.isRaw()) {\n \t\t\t\tconfig_.resize(1);\n \t\t\t\tstatus = Adjusted;\n \t\t\t\tbreak;\n@@ -566,8 +565,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()\n \tSize maxSize;\n \n \tfor (const StreamConfiguration &cfg : config_) {\n-\t\tconst PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat);\n-\t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW)\n+\t\tif (cfg.pixelFormat.isRaw())\n \t\t\trawFormat = cfg.pixelFormat;\n \n \t\tmaxSize = std::max(maxSize, cfg.size);\n@@ -749,8 +747,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)\n \t\t<< \" crop \" << rect;\n \n \tconst PixelFormat &streamFormat = config->at(0).pixelFormat;\n-\tconst PixelFormatInfo &info = PixelFormatInfo::info(streamFormat);\n-\tisRaw_ = info.colourEncoding == PixelFormatInfo::ColourEncodingRAW;\n+\tisRaw_ = streamFormat.isRaw();\n \n \t/* YUYV8_2X8 is required on the ISP source path pad for YUV output. */\n \tif (!isRaw_)\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\nindex da8d25c3..cb6117b9 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp\n@@ -182,10 +182,8 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size,\n \tPixelFormat rawFormat;\n \n \tfor (const auto &format : streamFormats_) {\n-\t\tconst PixelFormatInfo &info = PixelFormatInfo::info(format);\n-\n \t\t/* Populate stream formats for non-RAW configurations. */\n-\t\tif (info.colourEncoding != PixelFormatInfo::ColourEncodingRAW) {\n+\t\tif (!format.isRaw()) {\n \t\t\tif (role == StreamRole::Raw)\n \t\t\t\tcontinue;\n \n@@ -217,6 +215,7 @@ RkISP1Path::generateConfiguration(const CameraSensor *sensor, const Size &size,\n \t\t * Store the raw format with the highest bits per pixel for\n \t\t * later usage.\n \t\t */\n+\t\tconst PixelFormatInfo &info = PixelFormatInfo::info(format);\n \t\tif (info.bitsPerPixel > rawBitsPerPixel) {\n \t\t\trawBitsPerPixel = info.bitsPerPixel;\n \t\t\trawFormat = format;\n@@ -272,9 +271,7 @@ CameraConfiguration::Status RkISP1Path::validate(const CameraSensor *sensor,\n \tbool found = false;\n \n \tfor (const auto &format : streamFormats_) {\n-\t\tconst PixelFormatInfo &info = PixelFormatInfo::info(format);\n-\n-\t\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) {\n+\t\tif (format.isRaw()) {\n \t\t\t/* Skip raw formats not supported by the sensor. */\n \t\t\tuint32_t mbusCode = formatToMediaBus.at(format);\n \t\t\tif (std::find(mbusCodes.begin(), mbusCodes.end(), mbusCode) ==\n@@ -285,6 +282,7 @@ CameraConfiguration::Status RkISP1Path::validate(const CameraSensor *sensor,\n \t\t\t * Store the raw format with the highest bits per pixel\n \t\t\t * for later usage.\n \t\t\t */\n+\t\t\tconst PixelFormatInfo &info = PixelFormatInfo::info(format);\n \t\t\tif (info.bitsPerPixel > rawBitsPerPixel) {\n \t\t\t\trawBitsPerPixel = info.bitsPerPixel;\n \t\t\t\trawFormat = format;\n@@ -297,8 +295,7 @@ CameraConfiguration::Status RkISP1Path::validate(const CameraSensor *sensor,\n \t\t}\n \t}\n \n-\tbool isRaw = PixelFormatInfo::info(cfg->pixelFormat).colourEncoding ==\n-\t\t     PixelFormatInfo::ColourEncodingRAW;\n+\tbool isRaw = cfg->pixelFormat.isRaw();\n \n \t/*\n \t * If no raw format supported by the sensor has been found, use a\n","prefixes":["2/2"]}