Patch Detail
Show a patch.
GET /api/patches/24080/?format=api
{ "id": 24080, "url": "https://patchwork.libcamera.org/api/patches/24080/?format=api", "web_url": "https://patchwork.libcamera.org/patch/24080/", "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": "<20250808141315.413839-10-stefan.klug@ideasonboard.com>", "date": "2025-08-08T14:12:47", "name": "[v2,09/16] ipa: rkisp1: agc: Add correction for exposure quantization", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "a7dac2d2c7ccfbea886b5c53ddcaea380f2c2bda", "submitter": { "id": 184, "url": "https://patchwork.libcamera.org/api/people/184/?format=api", "name": "Stefan Klug", "email": "stefan.klug@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/24080/mbox/", "series": [ { "id": 5364, "url": "https://patchwork.libcamera.org/api/series/5364/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5364", "date": "2025-08-08T14:12:38", "name": "Implement WDR algorithm", "version": 2, "mbox": "https://patchwork.libcamera.org/series/5364/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/24080/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/24080/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 65CE8BDCC1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 8 Aug 2025 14:14:12 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1EF2069230;\n\tFri, 8 Aug 2025 16:14:12 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 20F0C6921E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 8 Aug 2025 16:14:10 +0200 (CEST)", "from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:3ea1:35ac:90da:a221])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 2C936208E; \n\tFri, 8 Aug 2025 16:13:20 +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=\"guKc8LFl\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1754662400;\n\tbh=AZBECBfp5wAEJjuKXVy2zSaRSaqp6qqt7J1e6gBu4I4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=guKc8LFlRyIuZx/Pn0q7LxavfC6NkocyGIlgQHGVa56tFtVAc/Q2rTTthqPdbwal7\n\t5uh89AkrI5nIenhmch1E9dL96HAiocCplsPHg3SjRxbyA2C5PP7FrfCK2QWyl2gvin\n\tkGOZn83TetXUUIcZZuoQF30Kd/WvFqYYwG9WR/Jw=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Stefan Klug <stefan.klug@ideasonboard.com>", "Subject": "[PATCH v2 09/16] ipa: rkisp1: agc: Add correction for exposure\n\tquantization", "Date": "Fri, 8 Aug 2025 16:12:47 +0200", "Message-ID": "<20250808141315.413839-10-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.48.1", "In-Reply-To": "<20250808141315.413839-1-stefan.klug@ideasonboard.com>", "References": "<20250808141315.413839-1-stefan.klug@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": "There are several occations where quantization can lead to visible\neffects.\n\nIn WDR mode it can happen that exposure times get set to very low values\n(Sometimes 2-3 lines). This intentionally introduced underexposure is\ncorrected by the GWDR module. As exposure time is quantized by lines,\nthe smallest possible change in exposure time now results in a quite\nvisible change in perceived brightness.\n\nSometimes the possible gain steps are also quite large leading to\nvisible jumps if e.g. if the exposure time is fixed.\n\nMitigate that by applying a global gain to account for the error\nintroduced by the exposure quantization.\n\nToDo: This needs perfect frame synchronous control of the sensor to work\nproperly which is not guaranteed in all cases. It still improves the\nbehavior with the current regulation and can easily be skipped, when\nthere is no compress algorithm.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/agc.cpp | 24 +++++++++++++++++++++---\n src/ipa/rkisp1/ipa_context.h | 2 ++\n 2 files changed, 23 insertions(+), 3 deletions(-)", "diff": "diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\nindex 0a29326841fb..d34c041f9fe1 100644\n--- a/src/ipa/rkisp1/algorithms/agc.cpp\n+++ b/src/ipa/rkisp1/algorithms/agc.cpp\n@@ -199,6 +199,9 @@ int Agc::configure(IPAContext &context, const IPACameraSensorInfo &configInfo)\n \tcontext.configuration.agc.measureWindow.h_size = configInfo.outputSize.width;\n \tcontext.configuration.agc.measureWindow.v_size = configInfo.outputSize.height;\n \n+\tAgcMeanLuminance::configure(context.configuration.sensor.lineDuration,\n+\t\t\t\t context.camHelper.get());\n+\n \tsetLimits(context.configuration.sensor.minExposureTime,\n \t\t context.configuration.sensor.maxExposureTime,\n \t\t context.configuration.sensor.minAnalogueGain,\n@@ -283,6 +286,10 @@ void Agc::queueRequest(IPAContext &context,\n \tif (!frameContext.agc.autoGainEnabled)\n \t\tframeContext.agc.gain = agc.manual.gain;\n \n+\tif (!frameContext.agc.autoExposureEnabled &&\n+\t !frameContext.agc.autoGainEnabled)\n+\t\tframeContext.agc.quantizationGain = 1.0;\n+\n \tconst auto &meteringMode = controls.get(controls::AeMeteringMode);\n \tif (meteringMode) {\n \t\tframeContext.agc.updateMetering = agc.meteringMode != *meteringMode;\n@@ -336,12 +343,17 @@ void Agc::prepare(IPAContext &context, const uint32_t frame,\n {\n \tuint32_t activeAutoExposure = context.activeState.agc.automatic.exposure;\n \tdouble activeAutoGain = context.activeState.agc.automatic.gain;\n+\tdouble activeAutoQGain = context.activeState.agc.automatic.quantizationGain;\n \n \t/* Populate exposure and gain in auto mode */\n-\tif (frameContext.agc.autoExposureEnabled)\n+\tif (frameContext.agc.autoExposureEnabled) {\n \t\tframeContext.agc.exposure = activeAutoExposure;\n-\tif (frameContext.agc.autoGainEnabled)\n+\t\tframeContext.agc.quantizationGain = activeAutoQGain;\n+\t}\n+\tif (frameContext.agc.autoGainEnabled) {\n \t\tframeContext.agc.gain = activeAutoGain;\n+\t\tframeContext.agc.quantizationGain = activeAutoQGain;\n+\t}\n \n \t/*\n \t * Populate manual exposure and gain from the active auto values when\n@@ -354,6 +366,12 @@ void Agc::prepare(IPAContext &context, const uint32_t frame,\n \tif (!frameContext.agc.autoGainEnabled && frameContext.agc.autoGainModeChange) {\n \t\tcontext.activeState.agc.manual.gain = activeAutoGain;\n \t\tframeContext.agc.gain = activeAutoGain;\n+\t\tframeContext.agc.quantizationGain = activeAutoQGain;\n+\t}\n+\n+\tif (context.activeState.compress.supported) {\n+\t\tframeContext.compress.enable = true;\n+\t\tframeContext.compress.gain = frameContext.agc.quantizationGain;\n \t}\n \n \tif (frame > 0 && !frameContext.agc.updateMetering)\n@@ -582,7 +600,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n \t/* Update the estimated exposure and gain. */\n \tactiveState.agc.automatic.exposure = newExposureTime / lineDuration;\n \tactiveState.agc.automatic.gain = aGain;\n-\n+\tactiveState.agc.automatic.quantizationGain = qGain;\n \t/*\n \t * Expand the target frame duration so that we do not run faster than\n \t * the minimum frame duration when we have short exposures.\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex 37a74215ce19..362ab2fda5fe 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -77,6 +77,7 @@ struct IPAActiveState {\n \t\tstruct {\n \t\t\tuint32_t exposure;\n \t\t\tdouble gain;\n+\t\t\tdouble quantizationGain;\n \t\t} automatic;\n \n \t\tbool autoExposureEnabled;\n@@ -135,6 +136,7 @@ struct IPAFrameContext : public FrameContext {\n \t\tuint32_t exposure;\n \t\tdouble gain;\n \t\tdouble exposureValue;\n+\t\tdouble quantizationGain;\n \t\tuint32_t vblank;\n \t\tbool autoExposureEnabled;\n \t\tbool autoGainEnabled;\n", "prefixes": [ "v2", "09/16" ] }