Patch Detail
Show a patch.
GET /api/patches/24826/?format=api
{ "id": 24826, "url": "https://patchwork.libcamera.org/api/patches/24826/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24826/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20251026233048.175689-4-kieran.bingham@ideasonboard.com>", "date": "2025-10-26T23:30:40", "name": "[3/6] ipa: rkisp1: cproc: Convert to use Quantized types", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "425861ba50b60aa1f0b70539556a644a271862ad", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24826/mbox/", "series": [ { "id": 5532, "url": "https://patchwork.libcamera.org/api/series/5532/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5532", "date": "2025-10-26T23:30:37", "name": "libipa: Introduce a Quantized type", "version": 1, "mbox": "https://patchwork.libcamera.org/series/5532/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24826/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24826/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 513B5C32CE\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 26 Oct 2025 23:31:03 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DF6AC60758;\n\tMon, 27 Oct 2025 00:30:58 +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 4A5E5606CE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Oct 2025 00:30:54 +0100 (CET)", "from charm.hippo-penny.ts.net (unknown [209.38.108.23])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C644514A6;\n\tMon, 27 Oct 2025 00:29:06 +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=\"r/Jpw4Q2\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1761521346;\n\tbh=bycs83QWG4GQExYg5Tz8fnZpbW85jOhKNNeo9GT5w9Q=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=r/Jpw4Q2LLOvrKI1kVqUcwAsLrIuGGAiNvbSimyjrf9aF8HnHTNqrm33pJKhV8KV2\n\tIYWHSuEu9+Me0CsR9GkjOP2Ou1qwEdFFnnpkqz0GIDiWRKK/1dzU7JN9Urwls2C/7E\n\t2hwIT+vDDuudivEcMydRbRz9KtOO3XsmqOJEY9xw=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "To": "libcamera devel <libcamera-devel@lists.libcamera.org>", "Cc": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "Subject": "[PATCH 3/6] ipa: rkisp1: cproc: Convert to use Quantized types", "Date": "Sun, 26 Oct 2025 23:30:40 +0000", "Message-ID": "<20251026233048.175689-4-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.51.0", "In-Reply-To": "<20251026233048.175689-1-kieran.bingham@ideasonboard.com>", "References": "<20251026233048.175689-1-kieran.bingham@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": "Convert the Contrast and Saturuation helper functions to a Quantizer\ntype to support maintaining the data.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/cproc.cpp | 67 +++++++++++++++++++++--------\n src/ipa/rkisp1/ipa_context.h | 13 +++---\n 2 files changed, 56 insertions(+), 24 deletions(-)", "diff": "diff --git a/src/ipa/rkisp1/algorithms/cproc.cpp b/src/ipa/rkisp1/algorithms/cproc.cpp\nindex d1fff6990d37..44c0fb8425de 100644\n--- a/src/ipa/rkisp1/algorithms/cproc.cpp\n+++ b/src/ipa/rkisp1/algorithms/cproc.cpp\n@@ -14,6 +14,8 @@\n \n #include <libcamera/control_ids.h>\n \n+#include \"libipa/quantized.h\"\n+\n /**\n * \\file cproc.h\n */\n@@ -39,15 +41,44 @@ constexpr float kDefaultBrightness = 0.0f;\n constexpr float kDefaultContrast = 1.0f;\n constexpr float kDefaultSaturation = 1.0f;\n \n-int convertBrightness(const float v)\n+class BrightnessQ : public Quantizer<int8_t>\n {\n-\treturn std::clamp<int>(std::lround(v * 128), -128, 127);\n-}\n+public:\n+\tBrightnessQ(const float val) { set(val); }\n+\tBrightnessQ(const int8_t val) { set(val); }\n \n-int convertContrastOrSaturation(const float v)\n+\tint8_t fromFloat(float v) const override\n+\t{\n+\t\tint quantized = std::lround(v * 128.0f);\n+\t\treturn static_cast<int8_t>(std::clamp<int>(quantized, -128, 127));\n+\t}\n+\n+\tfloat toFloat(int8_t v) const override\n+\t{\n+\t\treturn static_cast<float>(v) / 128.0f;\n+\t}\n+};\n+\n+class ContrastSaturationQuantizer : public Quantizer<uint8_t>\n {\n-\treturn std::clamp<int>(std::lround(v * 128), 0, 255);\n-}\n+public:\n+\tContrastSaturationQuantizer(const float val) { set(val); }\n+\tContrastSaturationQuantizer(const uint8_t val) { set(val); }\n+\n+\tuint8_t fromFloat(const float v) const override\n+\t{\n+\t\tint quantized = std::lround(v * 128.0f);\n+\t\treturn static_cast<uint8_t>(std::clamp<int>(quantized, 0, 255));\n+\t}\n+\n+\tfloat toFloat(const uint8_t v) const override\n+\t{\n+\t\treturn static_cast<float>(v) / 128.0f;\n+\t}\n+};\n+\n+using ContrastQ = ContrastSaturationQuantizer;\n+using SaturationQ = ContrastSaturationQuantizer;\n \n } /* namespace */\n \n@@ -74,9 +105,9 @@ int ColorProcessing::configure(IPAContext &context,\n {\n \tauto &cproc = context.activeState.cproc;\n \n-\tcproc.brightness = convertBrightness(kDefaultBrightness);\n-\tcproc.contrast = convertContrastOrSaturation(kDefaultContrast);\n-\tcproc.saturation = convertContrastOrSaturation(kDefaultSaturation);\n+\tcproc.brightness = BrightnessQ(kDefaultBrightness);\n+\tcproc.contrast = ContrastQ(kDefaultContrast);\n+\tcproc.saturation = SaturationQ(kDefaultSaturation);\n \n \treturn 0;\n }\n@@ -97,35 +128,35 @@ void ColorProcessing::queueRequest(IPAContext &context,\n \n \tconst auto &brightness = controls.get(controls::Brightness);\n \tif (brightness) {\n-\t\tint value = convertBrightness(*brightness);\n+\t\tBrightnessQ value = *brightness;\n \t\tif (cproc.brightness != value) {\n \t\t\tcproc.brightness = value;\n \t\t\tupdate = true;\n \t\t}\n \n-\t\tLOG(RkISP1CProc, Debug) << \"Set brightness to \" << value;\n+\t\tLOG(RkISP1CProc, Debug) << \"Set brightness to \" << value.value();\n \t}\n \n \tconst auto &contrast = controls.get(controls::Contrast);\n \tif (contrast) {\n-\t\tint value = convertContrastOrSaturation(*contrast);\n+\t\tContrastQ value = *contrast;\n \t\tif (cproc.contrast != value) {\n \t\t\tcproc.contrast = value;\n \t\t\tupdate = true;\n \t\t}\n \n-\t\tLOG(RkISP1CProc, Debug) << \"Set contrast to \" << value;\n+\t\tLOG(RkISP1CProc, Debug) << \"Set contrast to \" << value.value();\n \t}\n \n \tconst auto saturation = controls.get(controls::Saturation);\n \tif (saturation) {\n-\t\tint value = convertContrastOrSaturation(*saturation);\n+\t\tSaturationQ value = *saturation;\n \t\tif (cproc.saturation != value) {\n \t\t\tcproc.saturation = value;\n \t\t\tupdate = true;\n \t\t}\n \n-\t\tLOG(RkISP1CProc, Debug) << \"Set saturation to \" << value;\n+\t\tLOG(RkISP1CProc, Debug) << \"Set saturation to \" << value.value();\n \t}\n \n \tframeContext.cproc.brightness = cproc.brightness;\n@@ -148,9 +179,9 @@ void ColorProcessing::prepare([[maybe_unused]] IPAContext &context,\n \n \tauto config = params->block<BlockType::Cproc>();\n \tconfig.setEnabled(true);\n-\tconfig->brightness = frameContext.cproc.brightness;\n-\tconfig->contrast = frameContext.cproc.contrast;\n-\tconfig->sat = frameContext.cproc.saturation;\n+\tconfig->brightness = frameContext.cproc.brightness.quantized();\n+\tconfig->contrast = frameContext.cproc.contrast.quantized();\n+\tconfig->sat = frameContext.cproc.saturation.quantized();\n }\n \n REGISTER_IPA_ALGORITHM(ColorProcessing, \"ColorProcessing\")\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex f85a130d9c23..b7cdfc36b275 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -27,6 +27,7 @@\n #include <libipa/camera_sensor_helper.h>\n #include <libipa/fc_queue.h>\n #include \"libipa/agc_mean_luminance.h\"\n+#include \"libipa/quantized.h\"\n \n namespace libcamera {\n \n@@ -115,9 +116,9 @@ struct IPAActiveState {\n \t} ccm;\n \n \tstruct {\n-\t\tint8_t brightness;\n-\t\tuint8_t contrast;\n-\t\tuint8_t saturation;\n+\t\tQuantized<int8_t> brightness;\n+\t\tQuantized<uint8_t> contrast;\n+\t\tQuantized<uint8_t> saturation;\n \t} cproc;\n \n \tstruct {\n@@ -169,9 +170,9 @@ struct IPAFrameContext : public FrameContext {\n \t} awb;\n \n \tstruct {\n-\t\tint8_t brightness;\n-\t\tuint8_t contrast;\n-\t\tuint8_t saturation;\n+\t\tQuantized<int8_t> brightness;\n+\t\tQuantized<uint8_t> contrast;\n+\t\tQuantized<uint8_t> saturation;\n \t\tbool update;\n \t} cproc;\n \n", "prefixes": [ "3/6" ] }