[{"id":34420,"web_url":"https://patchwork.libcamera.org/comment/34420/","msgid":"<anljptka6arkrtqe5zizecgas5itfimdgqr45o6ot4zw6cfqgn@nvbr6p55d23c>","date":"2025-06-05T07:11:05","subject":"Re: [PATCH v2 2/6] ipa: rpi: Replace dropFrameCount in the IPA -> PH\n\tinterface","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Naush\n\nOn Thu, May 22, 2025 at 08:48:18AM +0100, Naushir Patuck wrote:\n> Replace the dropFrameCount parameter returned from ipa::start() to the\n> pipeline handler by startupFrameCount and invalidFrameCount. The former\n> counts the number of frames required for AWB/AGC to converge, and the\n> latter counts the number of invalid frames produced by the sensor when\n> starting up.\n>\n> In the pipeline handler, use the sum of these 2 values to replicate the\n> existing dropFrameCount behaviour.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  include/libcamera/ipa/raspberrypi.mojom            |  3 ++-\n>  src/ipa/rpi/common/ipa_base.cpp                    | 14 ++++++++------\n>  .../pipeline/rpi/common/pipeline_base.cpp          |  4 ++--\n>  3 files changed, 12 insertions(+), 9 deletions(-)\n>\n> diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom\n> index e30c70bde08b..12b083e9d04b 100644\n> --- a/include/libcamera/ipa/raspberrypi.mojom\n> +++ b/include/libcamera/ipa/raspberrypi.mojom\n> @@ -52,7 +52,8 @@ struct ConfigResult {\n>\n>  struct StartResult {\n>  \tlibcamera.ControlList controls;\n> -\tint32 dropFrameCount;\n> +\tint32 startupFrameCount;\n> +\tint32 invalidFrameCount;\n>  };\n>\n>  struct PrepareParams {\n> diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp\n> index e0a93daa9db2..c15f8a7bf71e 100644\n> --- a/src/ipa/rpi/common/ipa_base.cpp\n> +++ b/src/ipa/rpi/common/ipa_base.cpp\n> @@ -324,6 +324,7 @@ void IpaBase::start(const ControlList &controls, StartResult *result)\n>  \t * \"mistrusted\", which depends on whether this is a startup from cold,\n>  \t * or merely a mode switch in a running system.\n>  \t */\n> +\tunsigned int agcConvergenceFrames = 0, awbConvergenceFrames = 0;\n>  \tframeCount_ = 0;\n>  \tif (firstStart_) {\n>  \t\tdropFrameCount_ = helper_->hideFramesStartup();\n> @@ -336,7 +337,6 @@ void IpaBase::start(const ControlList &controls, StartResult *result)\n>  \t\t * (mistrustCount_) that they won't see. But if zero (i.e.\n>  \t\t * no convergence necessary), no frames need to be dropped.\n>  \t\t */\n> -\t\tunsigned int agcConvergenceFrames = 0;\n>  \t\tRPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(\n>  \t\t\tcontroller_.getAlgorithm(\"agc\"));\n>  \t\tif (agc) {\n> @@ -345,7 +345,6 @@ void IpaBase::start(const ControlList &controls, StartResult *result)\n>  \t\t\t\tagcConvergenceFrames += mistrustCount_;\n>  \t\t}\n>\n> -\t\tunsigned int awbConvergenceFrames = 0;\n>  \t\tRPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>(\n>  \t\t\tcontroller_.getAlgorithm(\"awb\"));\n>  \t\tif (awb) {\n> @@ -353,15 +352,18 @@ void IpaBase::start(const ControlList &controls, StartResult *result)\n>  \t\t\tif (awbConvergenceFrames)\n>  \t\t\t\tawbConvergenceFrames += mistrustCount_;\n>  \t\t}\n> -\n> -\t\tdropFrameCount_ = std::max({ dropFrameCount_, agcConvergenceFrames, awbConvergenceFrames });\n> -\t\tLOG(IPARPI, Debug) << \"Drop \" << dropFrameCount_ << \" frames on startup\";\n>  \t} else {\n>  \t\tdropFrameCount_ = helper_->hideFramesModeSwitch();\n>  \t\tmistrustCount_ = helper_->mistrustFramesModeSwitch();\n>  \t}\n>\n> -\tresult->dropFrameCount = dropFrameCount_;\n> +\tresult->startupFrameCount = std::max({ agcConvergenceFrames, awbConvergenceFrames });\n> +\tresult->invalidFrameCount = dropFrameCount_;\n> +\n> +\tdropFrameCount_ = std::max({ dropFrameCount_, agcConvergenceFrames, awbConvergenceFrames });\n> +\n> +\tLOG(IPARPI, Debug) << \"Startup frames: \" << result->startupFrameCount\n> +\t\t\t   << \" Invalid frames: \" << result->invalidFrameCount;\n>\n>  \tfirstStart_ = false;\n>  \tlastRunTimestamp_ = 0;\n> diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n> index 1f13e5230fae..5956485953a2 100644\n> --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n> +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n> @@ -660,8 +660,8 @@ int PipelineHandlerBase::start(Camera *camera, const ControlList *controls)\n>  \t\tdata->setSensorControls(result.controls);\n>\n>  \t/* Configure the number of dropped frames required on startup. */\n> -\tdata->dropFrameCount_ = data->config_.disableStartupFrameDrops\n> -\t\t\t      ? 0 : result.dropFrameCount;\n> +\tdata->dropFrameCount_ = data->config_.disableStartupFrameDrops ?\n> +\t\t\t0 : result.startupFrameCount + result.invalidFrameCount;\n\nI would have kept the previous style. Can be adjusted when applying\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n>\n>  \tfor (auto const stream : data->streams_)\n>  \t\tstream->resetBuffers();\n> --\n> 2.43.0\n>","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 D87DDC31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  5 Jun 2025 07:11:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6536868DBD;\n\tThu,  5 Jun 2025 09:11:10 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A76D768DB2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  5 Jun 2025 09:11:08 +0200 (CEST)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C7155752;\n\tThu,  5 Jun 2025 09:11:04 +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=\"XqYzaSny\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1749107464;\n\tbh=dtPkOmSLyUX/9TlNk7l+Cvw723UG4Byzka2DBqa4Y74=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=XqYzaSnyrh8sYfPLdlZhjOwUTklUq4ahj5dxvZ6FEBCgqyShM8KXohwQu2FGk5bgF\n\t/7PzjBZuvofNTMTqgHDrtpbeitggOY7oAiwUi4sozqATBQO53gi2TozgS4Ry8ilvPs\n\tLniXLX0D3oVM0vEx4L1+qEbkbIBBE8bcMoa1et40=","Date":"Thu, 5 Jun 2025 09:11:05 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tDavid Plowman <david.plowman@raspberrypi.com>","Subject":"Re: [PATCH v2 2/6] ipa: rpi: Replace dropFrameCount in the IPA -> PH\n\tinterface","Message-ID":"<anljptka6arkrtqe5zizecgas5itfimdgqr45o6ot4zw6cfqgn@nvbr6p55d23c>","References":"<20250522075244.1198110-1-naush@raspberrypi.com>\n\t<20250522075244.1198110-3-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20250522075244.1198110-3-naush@raspberrypi.com>","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>"}}]