[{"id":37851,"web_url":"https://patchwork.libcamera.org/comment/37851/","msgid":"<176907337757.3882822.331700300696163803@neptunite.rasen.tech>","date":"2026-01-22T09:16:17","subject":"Re: [PATCH v1 16/35] ipa: rkisp1: agc: Process frame duration at the\n\tright time","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Quoting Stefan Klug (2025-10-24 17:50:40)\n> The frame duration and vblank should not be calculated during process()\n> but within prepare(), where the data for that frame get's computed.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/algorithms/agc.cpp | 20 ++++++++++----------\n>  src/ipa/rkisp1/algorithms/agc.h   |  3 +--\n>  2 files changed, 11 insertions(+), 12 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> index c67106339ef8..5ce77b7672f2 100644\n> --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> @@ -383,6 +383,12 @@ void Agc::prepare(IPAContext &context, const uint32_t frame,\n>  \n>         frameContext.agc.yTarget = context.activeState.agc.automatic.yTarget;\n>  \n> +       /*\n> +        * Expand the target frame duration so that we do not run faster than\n> +        * the minimum frame duration when we have short exposures.\n> +        */\n> +       processFrameDuration(context, frameContext);\n> +\n>         if (frame > 0 && !frameContext.agc.updateMetering)\n>                 return;\n>  \n> @@ -511,11 +517,13 @@ double Agc::estimateLuminance(double gain) const\n>   * Compute and populate vblank from the target frame duration.\n>   */\n>  void Agc::processFrameDuration(IPAContext &context,\n> -                              IPAFrameContext &frameContext,\n> -                              utils::Duration frameDuration)\n> +                              IPAFrameContext &frameContext)\n>  {\n>         IPACameraSensorInfo &sensorInfo = context.sensorInfo;\n>         utils::Duration lineDuration = context.configuration.sensor.lineDuration;\n> +       utils::Duration frameDuration = frameContext.agc.exposure * lineDuration;\n> +\n> +       frameDuration = std::max(frameDuration, frameContext.agc.minFrameDuration);\n\nLooks good to me.\n\n>  \n>         frameContext.agc.vblank = (frameDuration / lineDuration) - sensorInfo.outputSize.height;\n>  \n> @@ -539,8 +547,6 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>                   ControlList &metadata)\n>  {\n>         if (!stats) {\n> -               processFrameDuration(context, frameContext,\n> -                                    frameContext.agc.minFrameDuration);\n\nThis hasn't been replaced... oh it's in the next patch. I think it should be\nsquashed then so that we don't break in between patches. It's not a complex\npatch.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n>                 fillMetadata(context, frameContext, metadata);\n>                 return;\n>         }\n> @@ -641,12 +647,6 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>         activeState.agc.automatic.gain = aGain;\n>         activeState.agc.automatic.quantizationGain = qGain;\n>         activeState.agc.automatic.yTarget = effectiveYTarget();\n> -       /*\n> -        * Expand the target frame duration so that we do not run faster than\n> -        * the minimum frame duration when we have short exposures.\n> -        */\n> -       processFrameDuration(context, frameContext,\n> -                            std::max(frameContext.agc.minFrameDuration, newExposureTime));\n>  \n>         fillMetadata(context, frameContext, metadata);\n>         expMeans_ = {};\n> diff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h\n> index 7867eed9c4e3..4432711f43af 100644\n> --- a/src/ipa/rkisp1/algorithms/agc.h\n> +++ b/src/ipa/rkisp1/algorithms/agc.h\n> @@ -51,8 +51,7 @@ private:\n>                           ControlList &metadata);\n>         double estimateLuminance(double gain) const override;\n>         void processFrameDuration(IPAContext &context,\n> -                                 IPAFrameContext &frameContext,\n> -                                 utils::Duration frameDuration);\n> +                                 IPAFrameContext &frameContext);\n>  \n>         Span<const uint8_t> expMeans_;\n>         Span<const uint8_t> weights_;\n> -- \n> 2.48.1\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 47D81BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 22 Jan 2026 09:16:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EC0B061FDC;\n\tThu, 22 Jan 2026 10:16:24 +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 1C36561FD8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 22 Jan 2026 10:16:23 +0100 (CET)","from neptunite.rasen.tech (unknown\n\t[IPv6:2404:7a81:160:2100:8816:a947:ebed:2ec7])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 380AF2DD;\n\tThu, 22 Jan 2026 10:15:49 +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=\"gXomALTO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1769073350;\n\tbh=QCil10Lmb+2chPOj5io46gXKv0lFYUKYoiHaINao/Uk=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=gXomALTOc42CYOXLxRGfe4EypafpkcLwYFG0vu63jtoqRRnoBYuXFJDE+bYfX139/\n\tFvfSev+1f3T3PxV4per+363w8ahpr5s2I+TNnRMe8e0r27uC1N/NiSsKSJVEAec9ar\n\tLkls52OY2L8q9XYdQWWUPghoKrsNRyHmLQRpCiy8=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251024085130.995967-17-stefan.klug@ideasonboard.com>","References":"<20251024085130.995967-1-stefan.klug@ideasonboard.com>\n\t<20251024085130.995967-17-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v1 16/35] ipa: rkisp1: agc: Process frame duration at the\n\tright time","From":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 22 Jan 2026 18:16:17 +0900","Message-ID":"<176907337757.3882822.331700300696163803@neptunite.rasen.tech>","User-Agent":"alot/0.0.0","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>"}}]