From patchwork Wed Oct 13 01:26:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14113 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 06321BDC71 for ; Wed, 13 Oct 2021 01:26:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7B85D68F57; Wed, 13 Oct 2021 03:26:51 +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="ZVfwA6yS"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 30F3968F4D for ; Wed, 13 Oct 2021 03:26:49 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BDB04291; Wed, 13 Oct 2021 03:26:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1634088409; bh=7NVSWSd6dd4hFhb4gdpGU87X3Do1cfXYrwebrxaaGyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZVfwA6ySP4u0BVoOtOKTFVH1Ea+7dSr8E/FIix2aPw4brN3lGHTkD4CL2iYPgwO6h 8BhugOCEBZJJ4fGh8CiuJchIIOX3kXwchoIP22WX6O/GfQXzq/2dPzAPwX/iruoGqJ eZbUWAdHfPwI0Lx1IEkn5o2g0qzK+HA/sc+PLDSo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 13 Oct 2021 04:26:30 +0300 Message-Id: <20211013012630.18877-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211013012630.18877-1-laurent.pinchart@ideasonboard.com> References: <20211013012630.18877-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: ipu3: Use new Size grownBy() and shrunkBy() helpers 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 Size class has new helpers that can simplify the code in the IPU3 pipeline handler. Use them. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/ipu3/ipu3.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 92e869257e53..262b9a23703e 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -438,11 +438,10 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera, * \todo Clarify the alignment constraints as explained * in validate() */ - size = sensorResolution.boundedTo(IMGU_OUTPUT_MAX_SIZE); - size.width = utils::alignDown(size.width - 1, - IMGU_OUTPUT_WIDTH_MARGIN); - size.height = utils::alignDown(size.height - 1, - IMGU_OUTPUT_HEIGHT_MARGIN); + size = sensorResolution.boundedTo(IMGU_OUTPUT_MAX_SIZE) + .shrunkBy({ 1, 1 }) + .alignedDownTo(IMGU_OUTPUT_WIDTH_MARGIN, + IMGU_OUTPUT_HEIGHT_MARGIN); pixelFormat = formats::NV12; bufferCount = IPU3_BUFFER_COUNT; streamFormats[pixelFormat] = { { IMGU_OUTPUT_MIN_SIZE, size } }; @@ -996,8 +995,7 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) */ /* The strictly smaller size than the sensor resolution, aligned to margins. */ - Size minSize = Size(sensor->resolution().width - 1, - sensor->resolution().height - 1) + Size minSize = sensor->resolution().shrunkBy({ 1, 1 }) .alignedDownTo(IMGU_OUTPUT_WIDTH_MARGIN, IMGU_OUTPUT_HEIGHT_MARGIN); @@ -1005,8 +1003,7 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) * Either the smallest margin-aligned size larger than the viewfinder * size or the adjusted sensor resolution. */ - minSize = Size(IPU3ViewfinderSize.width + 1, - IPU3ViewfinderSize.height + 1) + minSize = IPU3ViewfinderSize.grownBy({ 1, 1 }) .alignedUpTo(IMGU_OUTPUT_WIDTH_MARGIN, IMGU_OUTPUT_HEIGHT_MARGIN) .boundedTo(minSize);