From patchwork Mon Sep 13 14:58:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Michel Hautbois X-Patchwork-Id: 13830 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 63B5EBDB1D for ; Mon, 13 Sep 2021 14:58:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 66C186919E; Mon, 13 Sep 2021 16:58:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rFtIbZxp"; 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 648AC69181 for ; Mon, 13 Sep 2021 16:58:14 +0200 (CEST) Received: from tatooine.ideasonboard.com (unknown [IPv6:2a01:e0a:169:7140:edc5:688b:2ede:8b4b]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 19D4BB2B; Mon, 13 Sep 2021 16:58:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1631545094; bh=ev9EYZqNEM+QpWmZ7GJvB0KehupDBJH9gQNrxZjN0dI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rFtIbZxpH19QT1/m71SG0xqrayMLWEdiE+ayu/t7B+SVWMdvomKx5tfxvZByJngdD a5l/23wkvttgeITOi1OoeQsdDBEAXlyIMyHj6YWAn5ChJptIl9aNXohPaFenjZxPlV eovRgBU3ksBSgFyM9TgTsapgNyt+Mb5jHKNbXNxI= From: Jean-Michel Hautbois To: libcamera-devel@lists.libcamera.org Date: Mon, 13 Sep 2021 16:58:01 +0200 Message-Id: <20210913145810.66515-3-jeanmichel.hautbois@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210913145810.66515-1-jeanmichel.hautbois@ideasonboard.com> References: <20210913145810.66515-1-jeanmichel.hautbois@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 02/11] ipa: ipu3: Improve the documentation of BDS grid 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 BDS grid has its own limitations for the log2 width and height for each cell of pixels. Use constexpr for those and comment it to help understanding their usage. Signed-off-by: Jean-Michel Hautbois Reviewed-by: Laurent Pinchart --- src/ipa/ipu3/ipu3.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 90053069..c71f2a6c 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -345,6 +345,8 @@ int IPAIPU3::start() } /** + * \brief Calculate a grid for the AWB statistics + * * This function calculates a grid for the AWB algorithm in the IPU3 firmware. * Its input is the BDS output size calculated in the ImgU. * It is limited for now to the simplest method: find the lesser error @@ -364,16 +366,24 @@ void IPAIPU3::calculateBdsGrid(const Size &bdsOutputSize) /* Set the BDS output size in the IPAConfiguration structure */ context_.configuration.grid.bdsOutputSize = bdsOutputSize; - for (uint32_t widthShift = 3; widthShift <= 7; ++widthShift) { + /* + * The log2 of the width and height of each cell is limited by the ImgU + * in the interval [3, 7] according to the kernel header. + */ + constexpr uint32_t kCellMin = 3; + constexpr uint32_t kCellMax = 7; + + for (uint32_t widthShift = kCellMin; widthShift <= kCellMax; ++widthShift) { uint32_t width = std::min(kMaxCellWidthPerSet, bdsOutputSize.width >> widthShift); width = width << widthShift; - for (uint32_t heightShift = 3; heightShift <= 7; ++heightShift) { + + for (uint32_t heightShift = kCellMin; heightShift <= kCellMax; ++heightShift) { int32_t height = std::min(kMaxCellHeightPerSet, bdsOutputSize.height >> heightShift); height = height << heightShift; uint32_t error = std::abs(static_cast(width - bdsOutputSize.width)) - + std::abs(static_cast(height - bdsOutputSize.height)); + + std::abs(static_cast(height - bdsOutputSize.height)); if (error > minError) continue;