From patchwork Mon May 3 09:26:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12162 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 9B40FBDE78 for ; Mon, 3 May 2021 09:26:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 470FD6891F; Mon, 3 May 2021 11:26:26 +0200 (CEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EC4A5688E4 for ; Mon, 3 May 2021 11:26:24 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id B8A5CE0006 for ; Mon, 3 May 2021 09:26:24 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 3 May 2021 11:26:59 +0200 Message-Id: <20210503092705.15562-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503092705.15562-1-jacopo@jmondi.org> References: <20210503092705.15562-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/7] libcamera: ipu3: imgu: Update BDS calculation process 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 the last three hunks of commit 243d134 ("Fix some bug for some resolutions") from https://github.com/intel/intel-ipu3-pipecfg.git to the BDS calculation procedure. The BDS calculation is now perfomed by scaling both width and height, and repeated by scaling width first. Tested-by: Jean-Michel Hautbois Reviewed-by: Jean-Michel Hautbois Signed-off-by: Jacopo Mondi Acked-by: Niklas Söderlund Reviewed-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/imgu.cpp | 34 ++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index d5cf05b0c421..8373dc165a61 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -394,19 +394,43 @@ ImgUDevice::PipeConfig ImgUDevice::calculatePipeConfig(Pipe *pipe) const Size &in = pipe->input; Size gdc = calculateGDC(pipe); - unsigned int ifWidth = utils::alignUp(in.width, IF_ALIGN_W); - unsigned int ifHeight = in.height; - unsigned int minIfWidth = in.width - IF_CROP_MAX_W; float bdsSF = static_cast(in.width) / gdc.width; float sf = findScaleFactor(bdsSF, bdsScalingFactors, true); + /* Populate the configurations vector by scaling width and height. */ + unsigned int ifWidth = utils::alignUp(in.width, IF_ALIGN_W); + unsigned int ifHeight = utils::alignUp(in.height, IF_ALIGN_H); + unsigned int minIfWidth = in.width - IF_CROP_MAX_W; + unsigned int minIfHeight = in.height - IF_CROP_MAX_H; while (ifWidth >= minIfWidth) { - Size iif{ ifWidth, ifHeight }; - calculateBDS(pipe, iif, gdc, sf); + while (ifHeight >= minIfHeight) { + Size iif{ ifWidth, ifHeight }; + calculateBDS(pipe, iif, gdc, sf); + ifHeight -= IF_ALIGN_H; + } ifWidth -= IF_ALIGN_W; } + /* Repeat search by scaling width first. */ + ifWidth = utils::alignUp(in.width, IF_ALIGN_W); + ifHeight = utils::alignUp(in.height, IF_ALIGN_H); + minIfWidth = in.width - IF_CROP_MAX_W; + minIfHeight = in.height - IF_CROP_MAX_H; + while (ifHeight >= minIfHeight) { + /* + * \todo This procedure is probably broken: + * https://github.com/intel/intel-ipu3-pipecfg/issues/2 + */ + while (ifWidth >= minIfWidth) { + Size iif{ ifWidth, ifHeight }; + calculateBDS(pipe, iif, gdc, sf); + ifWidth -= IF_ALIGN_W; + } + + ifHeight -= IF_ALIGN_H; + } + if (pipeConfigs.size() == 0) { LOG(IPU3, Error) << "Failed to calculate pipe configuration"; return {};