From patchwork Sun Jun 16 16:39:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 20336 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 033C6C3293 for ; Sun, 16 Jun 2024 16:39:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9F4196549E; Sun, 16 Jun 2024 18:39:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fNpKPXXP"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0089E6549D for ; Sun, 16 Jun 2024 18:39:43 +0200 (CEST) Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EAA4B581 for ; Sun, 16 Jun 2024 18:39:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718555966; bh=C53sEocjWN6QqGh5FTS7x1cao59+Pmh6LGpurAx+yd4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fNpKPXXPOj+g3M6DRI+kRbctNGWAWywiVp7TxlytiFrO14iSlvrGsg32dgvpFvSkT 3U7jE42/dOZQD36tbuILBrZNcKWPPzhJ4LKcAOVtnletlLFEDtKbYXU17E4ff9WqG4 lwkoYTiGWtF9aEofKXRyTjb8oBGTMdmtAFODvtn4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Subject: [PATCH 08/12] ipa: rkisp1: agc: Simplify predivider calculation Date: Sun, 16 Jun 2024 19:39:06 +0300 Message-ID: <20240616163910.5506-9-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240616163910.5506-1-laurent.pinchart@ideasonboard.com> References: <20240616163910.5506-1-laurent.pinchart@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" The condition if (std::pow(std::floor(root), 2) < factor) predivider = static_cast(std::ceil(root)); else predivider = static_cast(std::floor(root)); can only be false when the factor's root is an integer. In that case, std::ceil(root) and std::floor(root) will be equal. The computation can thus be simplified by always rounding up. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- src/ipa/rkisp1/algorithms/agc.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index 9f3b59b45f95..a61201bb05c9 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -115,12 +115,7 @@ uint8_t Agc::computeHistogramPredivider(const Size &size, int count = mode == RKISP1_CIF_ISP_HISTOGRAM_MODE_RGB_COMBINED ? 3 : 1; double factor = size.width * size.height * count / 65536.0; double root = std::sqrt(factor); - uint8_t predivider; - - if (std::pow(std::floor(root), 2) < factor) - predivider = static_cast(std::ceil(root)); - else - predivider = static_cast(std::floor(root)); + uint8_t predivider = static_cast(std::ceil(root)); return std::clamp(predivider, 3, 127); }