From patchwork Thu Apr 18 14:14:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1052 Return-Path: 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 83F0E60DC6 for ; Thu, 18 Apr 2019 16:14:56 +0200 (CEST) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 07AB49D6 for ; Thu, 18 Apr 2019 16:14:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1555596896; bh=OGux1LxX1DkklAo1PNNeUYQrQHDpjDw+WM73yR2TIYA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oxk5PrFv8q3BS1sbAGjnwKQ81812sP4d+NBrOEhaNna+m8mSQXiEW9isj0lZWHtwg GlffbIkUDPfsEn19XnEiveQciLNg7XZagdqMk0LtF3JRKGUL7zfD0GlOMYAiHJPrC0 2c1Yyrt91WI0bGdK17rVpv1K5qT3rBXqXAJlz7iM= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Thu, 18 Apr 2019 17:14:29 +0300 Message-Id: <20190418141437.14014-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418141437.14014-1-laurent.pinchart@ideasonboard.com> References: <20190418141437.14014-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 05/13] libcamera: geometry: Use Size to store min and max in SizeRange X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Apr 2019 14:14:57 -0000 Instead of storing four integers for the minimum and maximum width and height in the SizeRange class, use two instance of the Size class for the minimum and maximum sizes. While it at replace the mention of image size with size in the SizeRange documentation, as the Size class isn't limited to image sizes. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- include/libcamera/geometry.h | 10 +++------- src/libcamera/geometry.cpp | 26 ++++++++------------------ src/libcamera/pipeline/ipu3/ipu3.cpp | 17 ++++++++--------- test/v4l2_subdevice/list_formats.cpp | 8 ++++---- 4 files changed, 23 insertions(+), 38 deletions(-) diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h index 7704ab5add21..80f79c6ba2d3 100644 --- a/include/libcamera/geometry.h +++ b/include/libcamera/geometry.h @@ -38,21 +38,17 @@ struct Size { struct SizeRange { SizeRange() - : SizeRange(0, 0, 0, 0) { } SizeRange(unsigned int minW, unsigned int minH, unsigned int maxW, unsigned int maxH) - : minWidth(minW), minHeight(minH), maxWidth(maxW), - maxHeight(maxH) + : min(minW, minH), max(maxW, maxH) { } - unsigned int minWidth; - unsigned int minHeight; - unsigned int maxWidth; - unsigned int maxHeight; + Size min; + Size max; }; } /* namespace libcamera */ diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index 1f875bbe5f48..c1c7daed7259 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -93,11 +93,11 @@ const std::string Rectangle::toString() const /** * \struct SizeRange - * \brief Describe a range of image sizes + * \brief Describe a range of sizes * - * SizeRange describes a range of image sizes included in the (minWidth, - * minHeight) - (maxWidth, maxHeight) interval. If the minimum and - * maximum sizes are identical it represents a single image resolution. + * SizeRange describes a range of sizes included in the [min, max] + * interval for both the width and the height. If the minimum and + * maximum sizes are identical it represents a single size. */ /** @@ -115,23 +115,13 @@ const std::string Rectangle::toString() const */ /** - * \var SizeRange::minWidth - * \brief The minimum image width + * \var SizeRange::min + * \brief The minimum size */ /** - * \var SizeRange::minHeight - * \brief The minimum image height - */ - -/** - * \var SizeRange::maxWidth - * \brief The maximum image width - */ - -/** - * \var SizeRange::maxHeight - * \brief The maximum image height + * \var SizeRange::max + * \brief The maximum size */ } /* namespace libcamera */ diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index f2306efba3bf..fb9ee0af6c3a 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1058,10 +1058,9 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index) continue; for (const SizeRange &size : it.second) { - if (maxSize_.width < size.maxWidth && - maxSize_.height < size.maxHeight) { - maxSize_.width = size.maxWidth; - maxSize_.height = size.maxHeight; + if (maxSize_.width < size.max.width && + maxSize_.height < size.max.height) { + maxSize_ = size.max; mbusCode_ = mbusCode; } } @@ -1116,19 +1115,19 @@ int CIO2Device::configure(const StreamConfiguration &config, * as possible. This will need to be revisited when * implementing the scaling policy. */ - if (size.maxWidth < config.width || - size.maxHeight < config.height) + if (size.max.width < config.width || + size.max.height < config.height) continue; - unsigned int diff = size.maxWidth * size.maxHeight + unsigned int diff = size.max.width * size.max.height - imageSize; if (diff >= best) continue; best = diff; - sensorFormat.width = size.maxWidth; - sensorFormat.height = size.maxHeight; + sensorFormat.width = size.max.width; + sensorFormat.height = size.max.height; sensorFormat.mbus_code = it.first; } } diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp index 47ae3a1c1a28..09dec9abe854 100644 --- a/test/v4l2_subdevice/list_formats.cpp +++ b/test/v4l2_subdevice/list_formats.cpp @@ -37,10 +37,10 @@ void ListFormatsTest::printFormats(unsigned int pad, for (SizeRange &size : sizes) { cout << " mbus code: 0x" << setfill('0') << setw(4) << hex << code << endl; - cout << " min width: " << dec << size.minWidth << endl; - cout << " min height: " << dec << size.minHeight << endl; - cout << " max width: " << dec << size.maxWidth << endl; - cout << " max height: " << dec << size.maxHeight << endl; + cout << " min width: " << dec << size.min.width << endl; + cout << " min height: " << dec << size.min.height << endl; + cout << " max width: " << dec << size.max.width << endl; + cout << " max height: " << dec << size.max.height << endl; } }