From patchwork Mon Nov 9 16:12:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 28829 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 38F17C335B for ; Mon, 9 Nov 2026 16:13:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 500106A80C; Mon, 9 Nov 2026 17:13:04 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="f4oUMhwK"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A75F96A7E1 for ; Mon, 9 Nov 2026 17:12:52 +0100 (CET) Received: from pb-laptop.local (185.221.143.99.nat.pool.zt.hu [185.221.143.99]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DB74715CD; Mon, 9 Nov 2026 17:10:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1794240631; bh=yRJ00lyxRV4FLhw5VKtLGFEGIDP7ouzAwnDBWSMZSKE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f4oUMhwKr0MSViRqxTMkwDw3kEhDK/zlXXvd2FFRVGz1UtJKA82bcRqxQ5y3+Y5T8 efg2ePyW9Tgsm/PpCyubMnVaG7KFEpQZOp6GSOdj3rNYd/m5Z+gCYMhgmjl9dp/3ct l/JQg/H9vzxDzpuRUg6h+Hq2CYasLbIZ+EuueVRI= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Stefan Klug Subject: [PATCH v8 11/18] ipa: libipa: agc: Better respect frame duration limits Date: Mon, 9 Nov 2026 17:12:38 +0100 Message-ID: <20261109161246.513264-12-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261109161246.513264-1-barnabas.pocze@ideasonboard.com> References: <20261109161246.513264-1-barnabas.pocze@ideasonboard.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" Only frame durations that are multiples of the line duration are possible, and currently it is possible that a smaller frame duration is selected even if a frame duration satisfying the requested limits is available. This is caused by the float -> integer truncation during the calculation. For (an unrealistic) example, if the exposure time is 24ms, the min frame duration is 33ms, and the line duration is 2ms, then 32ms will be used as the frame duration even if e.g. 34 would be allowed by the max frame duration. So round the result to ensure that if not prevented by the max frame duration then a value that satisfies the limits is selected. Signed-off-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi Reviewed-by: Stefan Klug --- src/ipa/libipa/agc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ipa/libipa/agc.cpp b/src/ipa/libipa/agc.cpp index 3963a1555e..6c415a2fd2 100644 --- a/src/ipa/libipa/agc.cpp +++ b/src/ipa/libipa/agc.cpp @@ -850,7 +850,8 @@ void AgcAlgorithm::processFrameDuration(const agc::Session &session, * the minimum frame duration when we have short exposures. */ const auto frameLength = std::max( - frameContext.minFrameDuration / lineDuration, + std::min(std::ceil(frameContext.minFrameDuration / lineDuration), + frameContext.maxFrameDuration / lineDuration), frameContext.exposure); frameContext.vblank = frameLength - session.sensor.outputSize.height;