{"id":22898,"url":"https://patchwork.libcamera.org/api/patches/22898/?format=json","web_url":"https://patchwork.libcamera.org/patch/22898/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20250228125600.3241397-3-stefan.klug@ideasonboard.com>","date":"2025-02-28T12:55:54","name":"[2/3] ipa: libipa: agc_mean_luminance: Error out when effectiveExposureValue is zero","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"86190f6895ca407919c123f7c531e4d0d3b37933","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22898/mbox/","series":[{"id":5029,"url":"https://patchwork.libcamera.org/api/series/5029/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5029","date":"2025-02-28T12:55:52","name":"rkisp1: Reduce oscillations on startup","version":1,"mbox":"https://patchwork.libcamera.org/series/5029/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22898/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22898/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 A1B0FC3259\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 28 Feb 2025 12:56:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 61DB2687BA;\n\tFri, 28 Feb 2025 13:56:15 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EFF3B68779\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 Feb 2025 13:56:11 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:a7e:b81b:5754:579])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B90C8606;\n\tFri, 28 Feb 2025 13:54:42 +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=\"Kd6saCJT\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1740747282;\n\tbh=jfWt3vcpi/oPWJ4CUwlEdWHx902yi+uElEhZdRa7Af8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Kd6saCJTakos8y3yzUubNIWyGMEq3fzdeW34pgsR2Zi/FxYOvFCh/u18FolyjLvBp\n\tZP3n8iF+2o/tRRRDLwzC8tjSaJHU1gE4/iwMnKTFsJm2tZN1PvEnNqukibbwNFVPAz\n\t8BHdc2S2GH0sxsTRkuJgVKmqbxoos7RRotA6JKi4=","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","Subject":"[PATCH 2/3] ipa: libipa: agc_mean_luminance: Error out when\n\teffectiveExposureValue is zero","Date":"Fri, 28 Feb 2025 13:55:54 +0100","Message-ID":"<20250228125600.3241397-3-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20250228125600.3241397-1-stefan.klug@ideasonboard.com>","References":"<20250228125600.3241397-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":"In a proper system it never happens that the effectiveExposureValue\ndrops to zero. If that still happens due to a bug outside of\nagc_mean_luminance, the calculated gain goes towards infinity but the\nnewExposureValue is still 0 because it is the result of multiplying the\neffectiveExposureTime with the gain, leading to wild oscillations.\n\nCatch that condition, print an error message and set the new effective\nexposure value to an arbitrary 10ms.\n\nNote that in any case the underlying problem must be fixed. The\nimportant change is the added error message to be able to detect such a\nsituation.\n\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n src/ipa/libipa/agc_mean_luminance.cpp | 7 +++++++\n 1 file changed, 7 insertions(+)","diff":"diff --git a/src/ipa/libipa/agc_mean_luminance.cpp b/src/ipa/libipa/agc_mean_luminance.cpp\nindex 02555a44d271..a7343c18f5aa 100644\n--- a/src/ipa/libipa/agc_mean_luminance.cpp\n+++ b/src/ipa/libipa/agc_mean_luminance.cpp\n@@ -541,6 +541,13 @@ AgcMeanLuminance::calculateNewEv(uint32_t constraintModeIndex,\n \tstd::shared_ptr<ExposureModeHelper> exposureModeHelper =\n \t\texposureModeHelpers_.at(exposureModeIndex);\n \n+\tif (effectiveExposureValue == 0s) {\n+\t\tLOG(AgcMeanLuminance, Error) << \"Effective exposure value is 0.\"\n+\t\t\t\t\t     << \" Resetting exposure time and\"\n+\t\t\t\t\t     << \" gain to arbitrary defaults.\";\n+\t\treturn exposureModeHelper->splitExposure(10ms);\n+\t}\n+\n \tdouble gain = estimateInitialGain();\n \tgain = constraintClampGain(constraintModeIndex, yHist, gain);\n \n","prefixes":["2/3"]}