From patchwork Thu May 13 15:21:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 12273 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 4E6F8C31F1 for ; Thu, 13 May 2021 15:20:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8557C68926; Thu, 13 May 2021 17:20:40 +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 D5243688E4 for ; Thu, 13 May 2021 17:20:38 +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 41868C0006; 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:10 +0200 Message-Id: <20210513152116.17666-3-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 2/8] libcamera: ipu3: imgu: Filter resolutions < IF_CROP_MAX 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" As reported in https://bugs.libcamera.org/show_bug.cgi?id=32 allowing resolutions < IF_CROP_MAX leads to a not manageable number configurations to be tested, slowing down the ImgU pipe configuration to a point which is not acceptable for production devices. Filter all resolutions < IF_CROP_MAX to maintain the run-time complexity acceptable and remove the safety check that was meant to avoid overflows when computing the IF rectangle sizes. Bug: https://bugs.libcamera.org/show_bug.cgi?id=32 Signed-off-by: Jacopo Mondi Reviewed-by: Hirokazu Honda Reviewed-by: Jean-Michel Hautbois --- src/libcamera/pipeline/ipu3/imgu.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index acc625ab0fac..f25f14a71e9e 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -392,6 +392,17 @@ ImgUDevice::PipeConfig ImgUDevice::calculatePipeConfig(Pipe *pipe) LOG(IPU3, Debug) << "vf: " << pipe->viewfinder.toString(); const Size &in = pipe->input; + + /* + * \todo Filter out all resolutions < IF_CROP_MAX. + * See https://bugs.libcamera.org/show_bug.cgi?id=32 + */ + if (in.width < IF_CROP_MAX_W || in.height < IF_CROP_MAX_H) { + LOG(IPU3, Error) << "Input resolution " << in.toString() + << " not supported"; + return {}; + } + Size gdc = calculateGDC(pipe); float bdsSF = static_cast(in.width) / gdc.width; @@ -400,10 +411,8 @@ ImgUDevice::PipeConfig ImgUDevice::calculatePipeConfig(Pipe *pipe) /* 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 = std::min(IF_ALIGN_W, - in.width - IF_CROP_MAX_W); - unsigned int minIfHeight = std::min(IF_ALIGN_H, - in.height - IF_CROP_MAX_H); + unsigned int minIfWidth = in.width - IF_CROP_MAX_W; + unsigned int minIfHeight = in.height - IF_CROP_MAX_H; while (ifWidth >= minIfWidth) { while (ifHeight >= minIfHeight) { Size iif{ ifWidth, ifHeight }; @@ -417,8 +426,8 @@ ImgUDevice::PipeConfig ImgUDevice::calculatePipeConfig(Pipe *pipe) /* Repeat search by scaling width first. */ ifWidth = utils::alignUp(in.width, IF_ALIGN_W); ifHeight = utils::alignUp(in.height, IF_ALIGN_H); - minIfWidth = std::min(IF_ALIGN_W, in.width - IF_CROP_MAX_W); - minIfHeight = std::min(IF_ALIGN_H, in.height - IF_CROP_MAX_H); + minIfWidth = in.width - IF_CROP_MAX_W; + minIfHeight = in.height - IF_CROP_MAX_H; while (ifHeight >= minIfHeight) { /* * \todo This procedure is probably broken: