From patchwork Wed Aug 5 14:09:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 27618 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0F051C330F for ; Wed, 5 Aug 2026 14:12:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DA06568114; Wed, 5 Aug 2026 16:12:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="NI8qUtZ+"; dkim-atps=neutral Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A92CF68103 for ; Wed, 5 Aug 2026 16:12:00 +0200 (CEST) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-47c2ae992beso76550f8f.2 for ; Wed, 05 Aug 2026 07:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1785939120; x=1786543920; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GIB9sY2TtCKE/ZD1C9EN5p2JDeiKXgMFJoFEXjnEd8U=; b=NI8qUtZ+lwc4XanMxP13TDCKyBN0UcbZODgBPoh3l+pfBGWFGpPucYr1vFjiKE7666 NOT+2S9Ty/OtyNMGXsK18o4TM+yBlRALOLprIlIdilyvg2n3nH5ILqHIhjrweVDiInIs 0tu2mhwrUFD00ChyfkJ7k36I8jwPfyk9LWBl63r2Er6oE2PBel92kFuZMH+0OPdrnB1P jdxKAF23eiYdhfpwovSJ4kA2V/1s+Zj3PZrGczKcMnc3eEKlbtNJI1p1m8MAHdZiExo2 obd43mEqaOgVxLhxtt7JQ0yTmQt6uUjh4APrNPPc4pDFCWKZt/magxHi/AZbI/CTNUF5 HB4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785939120; x=1786543920; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=GIB9sY2TtCKE/ZD1C9EN5p2JDeiKXgMFJoFEXjnEd8U=; b=srE0OT5NiconKCir6xIyu7OWdn7Py9/KXwtUFUnCO9gTeWeFj3OawKxwq/JduUeQtV 6ub/FuqTbqcoVV26/yMZpIxOgHfMSbIFe6f8mSteXQAqrb3FMhFDHWG1ki0Fqy8ZCWnP GmQyIlIT5w8naHNY2GQVmJ4DtWJ6e0O0DCtBvf6KArrRQ32jOoJPznoPQp0gnQpAwawB RviT5vKcuppVuwpznY0NOlV8ubMCSzfRTiq33vlYxFXdcUm3IWS/wv2Fu2W1oEdiLIU0 rXoKVN7UkpMvFDw+HVNsgXxWIPZkcI8ioYmodguzqsZ6P9s7eouPnUg2w9NKYI3ye1k8 xpsQ== X-Gm-Message-State: AOJu0YxZD09BtjnvpUJ+eVRzFjeGygHyGO6EzA/zkyS3YhfQ8Ltip5/C lZ/AZ3nFlzB9rUoCD+WD06wGUzJMOirS9ImJZX4sEjm6BlwUD+fwAzJaeUX9uVf1MQ000nNUJfs qkNE97+M= X-Gm-Gg: AR+sD11P6PEa0mP43zUQr9q86eATR7WLuT9U/hL8IjZROdo7S5iUh/0ln/GdJNd9XDf Ny0x+nYdvLhDRnjJtA4JyvNbmpzLkGYCyDP568j2yPI5Cm5SiB3ocBvoMnsf/TPOyb/H8AUoH7i JXlvuzrfs3eqbRhw+a6/2phAqllgWAfNV4hG5puLiVvNlARVU8vREdSr/8owYN92ByXzkX8wN8k hImtQNlxV5YKPil5Zo6KejeZ/z97vpKhTy+/gaMcwij88PrMbTMe6jYExa1z/xgsa5sgCqc1KwW BtFbJvQByZtgrKDZPHuxCA7zF/ftICgcblOOh34TgROzf0QqSbqaX3ax5Va4RN/84ip262VeXYp KBKNt2IWByFpP9M1RaCNvdTRF255RXhqlB3nlVVkicotgmf8qkQnfY7DWmqScDF0orowOKN7qQX cKPB3BJp2V3304Whpka3wPbUkRjERK1FEOMOHTx1bGw2Gv3N4ymP2FTUTDCE3HDHKsq2mKtrcEu 2WB4CYbEcL7X7edHaj4n+L1boob6E6k+iQCJNaPSIvKL3MojrEna5hEpL0A3IbKOp4yvo7yglqv f56Tw12hgD2XyM61nhuH+Yx1TzqPqpoU+JSCoIS4UHQTr6pYEK7af45ojR0wU0rLoSyIx7fQFb8 5eb9oMqzYQS+gi97+pNxokHK2 X-Received: by 2002:a05:600c:1550:b0:493:ad11:6d5c with SMTP id 5b1f17b1804b1-4994e7cf0dcmr42722075e9.4.1785939119990; Wed, 05 Aug 2026 07:11:59 -0700 (PDT) Received: from naush-dell.pitowers.org ([2a00:1098:3142:1f:7130:ff97:e57d:5cf8]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47febfda0d7sm8807952f8f.2.2026.08.05.07.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 07:11:59 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [PATCH v2 1/2] ipa: rpi: Rename mistrustFrames* to mistrustMetadata* Date: Wed, 5 Aug 2026 15:09:21 +0100 Message-ID: <20260805141156.2092208-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260805141156.2092208-1-naush@raspberrypi.com> References: <20260805141156.2092208-1-naush@raspberrypi.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Rename CamHelper::mistrustFramesStartup() to CamHelper::mistrustMetadataStartup() and CamHelper::mistrustFramesModeSwitch() to CamHelper::mistrustMetadataModeSwitch() This matches what the CamHelper member function actually advertises. Rename this to avoid any confusion when reading the code. Also reword some of the comments for the same reason. No functional changes in this commit. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- src/ipa/rpi/cam_helper/cam_helper.cpp | 6 +++--- src/ipa/rpi/cam_helper/cam_helper.h | 16 ++++++++-------- src/ipa/rpi/cam_helper/cam_helper_imx219.cpp | 4 ++-- src/ipa/rpi/cam_helper/cam_helper_imx355.cpp | 4 ++-- src/ipa/rpi/cam_helper/cam_helper_ov5647.cpp | 8 ++++---- src/ipa/rpi/common/ipa_base.cpp | 6 +++--- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ipa/rpi/cam_helper/cam_helper.cpp b/src/ipa/rpi/cam_helper/cam_helper.cpp index dfdcd167839a..ce0040137519 100644 --- a/src/ipa/rpi/cam_helper/cam_helper.cpp +++ b/src/ipa/rpi/cam_helper/cam_helper.cpp @@ -192,13 +192,13 @@ unsigned int CamHelper::hideFramesModeSwitch() const return 0; } -unsigned int CamHelper::mistrustFramesStartup() const +unsigned int CamHelper::mistrustMetadataStartup() const { - /* Many sensors return a single bad frame on start-up. */ + /* Many sensors return bad metadata on the first frame after start-up. */ return 1; } -unsigned int CamHelper::mistrustFramesModeSwitch() const +unsigned int CamHelper::mistrustMetadataModeSwitch() const { /* Many sensors return valid metadata immediately. */ return 0; diff --git a/src/ipa/rpi/cam_helper/cam_helper.h b/src/ipa/rpi/cam_helper/cam_helper.h index bd101895f23e..5a022d305f7e 100644 --- a/src/ipa/rpi/cam_helper/cam_helper.h +++ b/src/ipa/rpi/cam_helper/cam_helper.h @@ -56,12 +56,12 @@ namespace RPiController { * HideFramesModeSwitch(): Tell the pipeline handler not to return this * many frames after a mode switch (other than start-up). Some sensors * may produce innvalid frames after a mode switch; others may not. - * MistrustFramesStartup(): At start-up a sensor may return frames for - * which we should not run any control algorithms (for example, metadata - * may be invalid). - * MistrustFramesModeSwitch(): The number of frames, after a mode switch - * (other than start-up), for which control algorithms should not run - * (for example, metadata may be unreliable). + * mistrustMetadataStartup(): At start-up, a sensor may return this number of + * frames with invalid metadata. This metadata cannot be relied upon by the + * control algorithms. + * mistrustMetadataModeSwitch(): On a mode switch, a sensor may return this + * number of frames with invalid metadata. This metadata cannot be relied + * upon by the control algorithms. * getMinDebinFactor(): the binning factor after which we should apply * "debinning", which corrects for the uneven spatial sampling of the * standard binning process. A return value of 2 means to enable @@ -96,8 +96,8 @@ public: virtual double getModeSensitivity(const CameraMode &mode) const; virtual unsigned int hideFramesStartup() const; virtual unsigned int hideFramesModeSwitch() const; - virtual unsigned int mistrustFramesStartup() const; - virtual unsigned int mistrustFramesModeSwitch() const; + virtual unsigned int mistrustMetadataStartup() const; + virtual unsigned int mistrustMetadataModeSwitch() const; virtual unsigned int getMinDebinFactor() const; protected: diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx219.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx219.cpp index ba01153ebecf..c9e5479aa67a 100644 --- a/src/ipa/rpi/cam_helper/cam_helper_imx219.cpp +++ b/src/ipa/rpi/cam_helper/cam_helper_imx219.cpp @@ -44,7 +44,7 @@ public: CamHelperImx219(); uint32_t gainCode(double gain) const override; double gain(uint32_t gainCode) const override; - unsigned int mistrustFramesModeSwitch() const override; + unsigned int mistrustMetadataModeSwitch() const override; bool sensorEmbeddedDataPresent() const override; private: @@ -77,7 +77,7 @@ double CamHelperImx219::gain(uint32_t gainCode) const return 256.0 / (256 - gainCode); } -unsigned int CamHelperImx219::mistrustFramesModeSwitch() const +unsigned int CamHelperImx219::mistrustMetadataModeSwitch() const { /* * For reasons unknown, we do occasionally get a bogus metadata frame diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx355.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx355.cpp index 00e5fc836433..e6cac83be3be 100644 --- a/src/ipa/rpi/cam_helper/cam_helper_imx355.cpp +++ b/src/ipa/rpi/cam_helper/cam_helper_imx355.cpp @@ -20,7 +20,7 @@ public: CamHelperImx355(); uint32_t gainCode(double gain) const override; double gain(uint32_t gainCode) const override; - unsigned int mistrustFramesModeSwitch() const override; + unsigned int mistrustMetadataModeSwitch() const override; bool sensorEmbeddedDataPresent() const override; private: @@ -46,7 +46,7 @@ double CamHelperImx355::gain(uint32_t gainCode) const return 1024.0 / (1024 - gainCode); } -unsigned int CamHelperImx355::mistrustFramesModeSwitch() const +unsigned int CamHelperImx355::mistrustMetadataModeSwitch() const { /* * For reasons unknown, we do occasionally get a bogus metadata frame diff --git a/src/ipa/rpi/cam_helper/cam_helper_ov5647.cpp b/src/ipa/rpi/cam_helper/cam_helper_ov5647.cpp index 40d6b6d76452..3b6fbb17ad96 100644 --- a/src/ipa/rpi/cam_helper/cam_helper_ov5647.cpp +++ b/src/ipa/rpi/cam_helper/cam_helper_ov5647.cpp @@ -19,8 +19,8 @@ public: double gain(uint32_t gainCode) const override; unsigned int hideFramesStartup() const override; unsigned int hideFramesModeSwitch() const override; - unsigned int mistrustFramesStartup() const override; - unsigned int mistrustFramesModeSwitch() const override; + unsigned int mistrustMetadataStartup() const override; + unsigned int mistrustMetadataModeSwitch() const override; private: /* @@ -68,7 +68,7 @@ unsigned int CamHelperOv5647::hideFramesModeSwitch() const return 2; } -unsigned int CamHelperOv5647::mistrustFramesStartup() const +unsigned int CamHelperOv5647::mistrustMetadataStartup() const { /* * First couple of frames are under-exposed and are no good for control @@ -77,7 +77,7 @@ unsigned int CamHelperOv5647::mistrustFramesStartup() const return 2; } -unsigned int CamHelperOv5647::mistrustFramesModeSwitch() const +unsigned int CamHelperOv5647::mistrustMetadataModeSwitch() const { /* * First couple of frames are under-exposed even after a simple diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index dacafa578c98..aa17d39fea7b 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -351,12 +351,12 @@ void IpaBase::start(const ControlList &controls, StartResult *result) frameCount_ = 0; if (firstStart_) { invalidCount_ = helper_->hideFramesStartup(); - mistrustCount_ = helper_->mistrustFramesStartup(); + mistrustCount_ = helper_->mistrustMetadataStartup(); /* * Query the AGC/AWB for how many frames they may take to * converge sufficiently. Where these numbers are non-zero - * we must allow for the frames with bad statistics + * we must allow for the frames with bad metadata * (mistrustCount_) that they won't see. But if zero (i.e. * no convergence necessary), no frames need to be dropped. */ @@ -377,7 +377,7 @@ void IpaBase::start(const ControlList &controls, StartResult *result) } } else { invalidCount_ = helper_->hideFramesModeSwitch(); - mistrustCount_ = helper_->mistrustFramesModeSwitch(); + mistrustCount_ = helper_->mistrustMetadataModeSwitch(); } result->startupFrameCount = std::max({ agcConvergenceFrames, awbConvergenceFrames }); From patchwork Wed Aug 5 14:09:22 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 27619 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id ACF8FC3334 for ; Wed, 5 Aug 2026 14:12:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id ADD5868116; Wed, 5 Aug 2026 16:12:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="EMSYUl+G"; dkim-atps=neutral Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5EC9C68103 for ; Wed, 5 Aug 2026 16:12:01 +0200 (CEST) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-4731f5ffa74so69627f8f.1 for ; Wed, 05 Aug 2026 07:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1785939121; x=1786543921; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+QaiyA6Di1yFBuTZ62W2vJ2BamTuFqMtU/6Mg7atVXU=; b=EMSYUl+GW0v9BbjaEnt1ZvJ24NZ4lW9gb3H+OSl+xdDV6IPVODiwEYUvpuZyvXRQeY eUASqieURsuZuJYDpd82eXl5Icv1TU7LTc/l/XvlL4+wYKq/T4+jFJDcespytrwEKPhJ A99oQB1z2JsL1p7l+xTHcx0HFrMJjNP/h+R82+66FNMIAPIvWEGKEYoCimfRXCSSrdHq ACSj7IgFyKC5DXoR5lpd9HwsbGzq1A3iML21rGj6YgO+8cEW9f+BxZRQC3414P9Kc+85 WKLI3YNf+C9uYV3jBdKzhldm3cRL/a1cKQTLgs5QRpouWAQi2BONyjlVieFSwDtKQYin ZIkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785939121; x=1786543921; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=+QaiyA6Di1yFBuTZ62W2vJ2BamTuFqMtU/6Mg7atVXU=; b=lgy6yW//EmI52wbMZLcyBFiIv/dv0YVjGL2QRAYci7HyfJ16RPTnYhvpbv/3V1XSsC qsQhZkb8GKCdOeQlQHCYEazH/S1g5g56tk3Z+QEqocaTaskeAFp/MFmtouhAWupQ//Go qXQK84W0tUu3Pv5gfRb/A0uZeAMERQkc6Y926Pvfl+GbJLeo9zORv9fZVG+zbds4IQWL D7DSfzsDLyWtC4eEZfr0EfESZLR4Eqn50+jqvKanWfkCU+65HLK2/bKpXuez8nwZ2oOo nJqNaBqCj/wLLOJP4gTQNLIzoPIClD0LKImHM3MtjLrvCsRrPGw/L97dxUbbMqj6EPoN e4ZQ== X-Gm-Message-State: AOJu0Yy6yfdZTmiFfGSndYM3rzYLeZC1IcLD8a2FN/a/niJuF4emJyRr ka7ZuERoxAmilprd7zDafZ+6VhVg4SEoNraXMegQsejQON9OjkvwadSdTi9v03w4A2LZtrkzYt8 nMfVhmtY= X-Gm-Gg: AR+sD13D2ms05b7XGcpPV1urxT6gVpeJ78DZGUOnQjoiCYPDj3moI8YFFKSLBrs7I79 SuctL1dtjb5HEzNyiLuomCqLqZdEBTKLrdVo8pVTjX1hH3pvQUSwUM53BvS+mjNn6dPVKs9L1gZ DPKajUCT71sWrIhKMXLWJ22lh1Zv7PyqmuDiYuANn+VirxzG/G/3wfULp/6qQ0GHM/iQKctp9f1 72nkCNR7eb3TopheVwjsAzLYrbeFqGYr2gcW+DYWNwTF9mOj/DMerwHftqUuBuFZjFXUNKxVN2G dibYfDyeC1k4k+WNnk4ezU+v/6TAqDaI5jpPsBKXmVNKDR1x8l+HzUZ5aXq4Xh2DgCboeUQyDAu kZw9gw9G95Ce5igaUtDJ8VEe0WTmcQVcbtRouXju4uApKHCFBaIpUhDTflzuwHeQI+JaOqYVvif Y1n73S/CbL6S7vhJw+6YEWuQELcE8yfaGKYPBnUMePm0dGGdd7UzP2JHrunHv7nHHgfhOw/z6bc ZSIEBWFaAmrZjHeM3Sz5Krg5bgHzvxtM+hKN+WYQZZ5RkdpK/qT0U9eVj0p9jP3W3qJFbfQ4m5c kkki4pUwp6///qGo5xayUv6jfamN2/YUPnoZooY/aMzuN1XJ/2+6qcwJikGs9OxWhD9qWGdHIav ngm2WaBvD5XF38RQfbkecq6YV X-Received: by 2002:a05:6000:290a:b0:47f:7526:5a0 with SMTP id ffacd0b85a97d-47fec47628bmr6070546f8f.0.1785939120736; Wed, 05 Aug 2026 07:12:00 -0700 (PDT) Received: from naush-dell.pitowers.org ([2a00:1098:3142:1f:7130:ff97:e57d:5cf8]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47febfda0d7sm8807952f8f.2.2026.08.05.07.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 07:12:00 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck , Kieran Bingham , David Plowman Subject: [PATCH v2 2/2] ipa: rpi: Gate CamHelper::prepare() by the mistrust count Date: Wed, 5 Aug 2026 15:09:22 +0100 Message-ID: <20260805141156.2092208-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260805141156.2092208-1-naush@raspberrypi.com> References: <20260805141156.2092208-1-naush@raspberrypi.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The current logic in the IPA gates the controller/algorithms from running on a the frame if mistrustCount_ > 0. This logic is somewhat incorrect, as the image data is indeed valid, just the embedded data and other bits of metadata are possibly invalid. This commit changes the gating so that the controller/algorithms do run on frames where mistrustCount_ > 0, and CamHelper::prepare() gets gated. CamHelper::prepare() is where the embedded data parsing occurs, and if it does not run, we simply use the DelayedControls values provided by the pipeline handler. Bug: https://github.com/raspberrypi/libcamera/issues/345 Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham Reviewed-by: David Plowman --- src/ipa/rpi/common/ipa_base.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index aa17d39fea7b..7e00c2799b4e 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -355,26 +355,17 @@ void IpaBase::start(const ControlList &controls, StartResult *result) /* * Query the AGC/AWB for how many frames they may take to - * converge sufficiently. Where these numbers are non-zero - * we must allow for the frames with bad metadata - * (mistrustCount_) that they won't see. But if zero (i.e. - * no convergence necessary), no frames need to be dropped. + * converge sufficiently. */ RPiController::AgcAlgorithm *agc = dynamic_cast( controller_.getAlgorithm("agc")); - if (agc) { + if (agc) agcConvergenceFrames = agc->getConvergenceFrames(); - if (agcConvergenceFrames) - agcConvergenceFrames += mistrustCount_; - } RPiController::AwbAlgorithm *awb = dynamic_cast( controller_.getAlgorithm("awb")); - if (awb) { + if (awb) awbConvergenceFrames = awb->getConvergenceFrames(); - if (awbConvergenceFrames) - awbConvergenceFrames += mistrustCount_; - } } else { invalidCount_ = helper_->hideFramesModeSwitch(); mistrustCount_ = helper_->mistrustMetadataModeSwitch(); @@ -470,8 +461,11 @@ void IpaBase::prepareIsp(const PrepareParams ¶ms) /* * This may overwrite the DeviceStatus using values from the sensor * metadata, and may also do additional custom processing. + * + * Only call CamHelper::prepare() when we know the metadata can be trusted. */ - helper_->prepare(embeddedBuffer, rpiMetadata); + if (frameCount_ >= mistrustCount_) + helper_->prepare(embeddedBuffer, rpiMetadata); bool delayedRequestControls = false; delayedMetadata.get("ipa.request_controls", delayedRequestControls); @@ -527,7 +521,7 @@ void IpaBase::processStats(const ProcessParams ¶ms) unsigned int ipaContext = params.ipaContext % rpiMetadata_.size(); RPiController::Metadata &rpiMetadata = rpiMetadata_[ipaContext]; - if (processPending_ && frameCount_ >= mistrustCount_) { + if (processPending_) { auto it = buffers_.find(params.buffers.stats); if (it == buffers_.end()) { LOG(IPARPI, Error) << "Could not find stats buffer!";