From patchwork Thu May 13 15:21:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12274 X-Patchwork-Delegate: jacopo@jmondi.org 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 51021C31F1 for ; Thu, 13 May 2021 15:20:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1BB5068922; Thu, 13 May 2021 17:20:43 +0200 (CEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9925D688E4 for ; Thu, 13 May 2021 17:20:40 +0200 (CEST) X-Originating-IP: 79.53.131.195 Received: from uno.homenet.telecomitalia.it (host-79-53-131-195.retail.telecomitalia.it [79.53.131.195]) (Authenticated sender: jacopo@jmondi.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 1B708C0006; Thu, 13 May 2021 15:20:38 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 13 May 2021 17:21:11 +0200 Message-Id: <20210513152116.17666-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210513152116.17666-1-jacopo@jmondi.org> References: <20210513152116.17666-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/8] libcamera: ipu3: imgu: Filter BDS by height 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" Apply to calculateBDS() function the content of commit 243d134 ("Fix some bug for some resolutions") from https://github.com/intel/intel-ipu3-pipecfg.git. The calculated BDS sizes are filtered by height and not only by width anymore. Signed-off-by: Jacopo Mondi Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois Acked-by: Niklas Söderlund Reviewed-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/imgu.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index f25f14a71e9e..d878a029ad84 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -33,6 +33,7 @@ namespace { * at revision: 61e83f2f7606 ("Add more information into README") */ +static constexpr unsigned int FILTER_W = 4; static constexpr unsigned int FILTER_H = 4; static constexpr unsigned int IF_ALIGN_W = 2; @@ -194,15 +195,20 @@ void calculateBDSHeight(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc void calculateBDS(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc, float bdsSF) { - unsigned int minBDSWidth = gdc.width + FILTER_H * 2; + unsigned int minBDSWidth = gdc.width + FILTER_W * 2; + unsigned int minBDSHeight = gdc.height + FILTER_H * 2; float sf = bdsSF; while (sf <= BDS_SF_MAX && sf >= BDS_SF_MIN) { float bdsWidth = static_cast(iif.width) / sf; + float bdsHeight = static_cast(iif.height) / sf; - if (std::fmod(bdsWidth, 1.0) == 0) { + if (std::fmod(bdsWidth, 1.0) == 0 && + std::fmod(bdsHeight, 1.0) == 0) { unsigned int bdsIntWidth = static_cast(bdsWidth); - if (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth) + unsigned int bdsIntHeight = static_cast(bdsHeight); + if (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth && + !(bdsIntHeight % BDS_ALIGN_H) && bdsHeight >= minBDSHeight) calculateBDSHeight(pipe, iif, gdc, bdsIntWidth, sf); } @@ -212,10 +218,14 @@ void calculateBDS(ImgUDevice::Pipe *pipe, const Size &iif, const Size &gdc, floa sf = bdsSF; while (sf <= BDS_SF_MAX && sf >= BDS_SF_MIN) { float bdsWidth = static_cast(iif.width) / sf; + float bdsHeight = static_cast(iif.height) / sf; - if (std::fmod(bdsWidth, 1.0) == 0) { + if (std::fmod(bdsWidth, 1.0) == 0 && + std::fmod(bdsHeight, 1.0) == 0) { unsigned int bdsIntWidth = static_cast(bdsWidth); - if (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth) + unsigned int bdsIntHeight = static_cast(bdsHeight); + if (!(bdsIntWidth % BDS_ALIGN_W) && bdsWidth >= minBDSWidth && + !(bdsIntHeight % BDS_ALIGN_H) && bdsHeight >= minBDSHeight) calculateBDSHeight(pipe, iif, gdc, bdsIntWidth, sf); }