From patchwork Wed Jun 19 02:51:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 1453 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A4A0561A2F for ; Wed, 19 Jun 2019 04:52:24 +0200 (CEST) X-Halon-ID: 3b53e2e9-923d-11e9-8ab4-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 3b53e2e9-923d-11e9-8ab4-005056917a89; Wed, 19 Jun 2019 04:52:10 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 19 Jun 2019 04:51:15 +0200 Message-Id: <20190619025129.21164-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190619025129.21164-1-niklas.soderlund@ragnatech.se> References: <20190619025129.21164-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 02/16] libcamera: geometry: SizeRange: Extend with step information 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: Wed, 19 Jun 2019 02:52:25 -0000 The size range described might be subject to certain step limitations. Make it possible to record this information. Signed-off-by: Niklas Söderlund Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- include/libcamera/geometry.h | 13 ++++++++-- src/libcamera/geometry.cpp | 49 +++++++++++++++++++++++++++++++++--- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h index ec5ed2bee196c82d..b2a8e5b0e005e4db 100644 --- a/include/libcamera/geometry.h +++ b/include/libcamera/geometry.h @@ -73,18 +73,27 @@ struct SizeRange { } SizeRange(unsigned int width, unsigned int height) - : min(width, height), max(width, height) + : min(width, height), max(width, height), hStep(1), vStep(1) { } SizeRange(unsigned int minW, unsigned int minH, unsigned int maxW, unsigned int maxH) - : min(minW, minH), max(maxW, maxH) + : min(minW, minH), max(maxW, maxH), hStep(1), vStep(1) + { + } + + SizeRange(unsigned int minW, unsigned int minH, + unsigned int maxW, unsigned int maxH, + unsigned int hstep, unsigned int vstep) + : min(minW, minH), max(maxW, maxH), hStep(hstep), vStep(vstep) { } Size min; Size max; + unsigned int hStep; + unsigned int vStep; }; bool operator==(const SizeRange &lhs, const SizeRange &rhs); diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index 26a05b9e7d800077..1ea102935bdb256c 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -186,9 +186,29 @@ bool operator<(const Size &lhs, const Size &rhs) * \struct SizeRange * \brief Describe a range of sizes * - * 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. + * A 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. + * + * Size ranges may further limit the valid sizes through steps in the horizontal + * and vertical direction. The step values represent the increase in pixels + * between two valid width or height values, starting from the minimum. Valid + * sizes within the range are thus expressed as + * + * width = min.width + hStep * x + * height = min.height + vStep * y + * + * Where + * + * width <= max.width + * height < max.height + * + * Note that the step values are not equivalent to alignments, as the minimum + * width or height may not be a multiple of the corresponding step. + * + * The step values may be zero when the range describes only minimum and + * maximum sizes without implying that all, or any, intermediate size is valid. + * SizeRange instances the describe a single size have both set values set to 1. */ /** @@ -213,6 +233,19 @@ bool operator<(const Size &lhs, const Size &rhs) * \param[in] maxH The maximum height */ +/** + * \fn SizeRange::SizeRange(unsigned int minW, unsigned int minH, + * unsigned int maxW, unsigned int maxH, + * unsigned int hstep, unsigned int vstep) + * \brief Construct an initialized size range + * \param[in] minW The minimum width + * \param[in] minH The minimum height + * \param[in] maxW The maximum width + * \param[in] maxH The maximum height + * \param[in] hstep The horizontal step + * \param[in] vstep The vertical step + */ + /** * \var SizeRange::min * \brief The minimum size @@ -223,6 +256,16 @@ bool operator<(const Size &lhs, const Size &rhs) * \brief The maximum size */ +/** + * \var SizeRange::hStep + * \brief The horizontal step + */ + +/** + * \var SizeRange::vStep + * \brief The vertical step + */ + /** * \brief Compare size ranges for equality * \return True if the two size ranges are equal, false otherwise