[libcamera-devel,02/17] libcamera: geometry: SizeRange: Add constructor for a single size

Message ID 20190527001543.13593-3-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • libcamera: Add support for format information and validation
Related show

Commit Message

Niklas Söderlund May 27, 2019, 12:15 a.m. UTC
The SizeRange can describe a single size where min == max. Add a
constructor to help create such a description.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 include/libcamera/geometry.h | 5 +++++
 src/libcamera/geometry.cpp   | 7 +++++++
 2 files changed, 12 insertions(+)

Comments

Jacopo Mondi May 27, 2019, 9:22 a.m. UTC | #1
Hi Niklas,

On Mon, May 27, 2019 at 02:15:28AM +0200, Niklas Söderlund wrote:
> The SizeRange can describe a single size where min == max. Add a
> constructor to help create such a description.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> ---
>  include/libcamera/geometry.h | 5 +++++
>  src/libcamera/geometry.cpp   | 7 +++++++
>  2 files changed, 12 insertions(+)
>
> diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h
> index a87d65d3ed7951c2..ec5ed2bee196c82d 100644
> --- a/include/libcamera/geometry.h
> +++ b/include/libcamera/geometry.h
> @@ -72,6 +72,11 @@ struct SizeRange {
>  	{
>  	}
>
> +	SizeRange(unsigned int width, unsigned int height)
> +		: min(width, height), max(width, height)
> +	{
> +	}
> +
>  	SizeRange(unsigned int minW, unsigned int minH,
>  		  unsigned int maxW, unsigned int maxH)
>  		: min(minW, minH), max(maxW, maxH)
> diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp
> index 97c367bcb454b517..cc25b816e6796ba1 100644
> --- a/src/libcamera/geometry.cpp
> +++ b/src/libcamera/geometry.cpp
> @@ -196,6 +196,13 @@ bool operator<(const Size &lhs, const Size &rhs)
>   * \brief Construct a size range initialized to 0
>   */
>
> +/**
> + * \fn SizeRange::SizeRange(unsigned int width, unsigned int height)
> + * \brief Construct size range with a single size

nit: for consistency with the existing constructor and the structure
documentation:
        \brief Construct a size range representing a single size

> + * \param[in] width Single width
> + * \param[in] height Single height

nit: I would drop 'Single' in favour of just 'The size width/height'

Minors apart:
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
   j

> + */
> +
>  /**
>   * \fn SizeRange::SizeRange(unsigned int minW, unsigned int minH, unsigned int maxW, unsigned int maxH)
>   * \brief Construct an initialized size range
> --
> 2.21.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart June 8, 2019, 4:27 p.m. UTC | #2
Hi Niklas,

On Mon, May 27, 2019 at 11:22:29AM +0200, Jacopo Mondi wrote:
> On Mon, May 27, 2019 at 02:15:28AM +0200, Niklas Söderlund wrote:
> > The SizeRange can describe a single size where min == max. Add a
> > constructor to help create such a description.
> >
> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> > ---
> >  include/libcamera/geometry.h | 5 +++++
> >  src/libcamera/geometry.cpp   | 7 +++++++
> >  2 files changed, 12 insertions(+)
> >
> > diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h
> > index a87d65d3ed7951c2..ec5ed2bee196c82d 100644
> > --- a/include/libcamera/geometry.h
> > +++ b/include/libcamera/geometry.h
> > @@ -72,6 +72,11 @@ struct SizeRange {
> >  	{
> >  	}
> >
> > +	SizeRange(unsigned int width, unsigned int height)
> > +		: min(width, height), max(width, height)
> > +	{
> > +	}
> > +
> >  	SizeRange(unsigned int minW, unsigned int minH,
> >  		  unsigned int maxW, unsigned int maxH)
> >  		: min(minW, minH), max(maxW, maxH)
> > diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp
> > index 97c367bcb454b517..cc25b816e6796ba1 100644
> > --- a/src/libcamera/geometry.cpp
> > +++ b/src/libcamera/geometry.cpp
> > @@ -196,6 +196,13 @@ bool operator<(const Size &lhs, const Size &rhs)
> >   * \brief Construct a size range initialized to 0
> >   */
> >
> > +/**
> > + * \fn SizeRange::SizeRange(unsigned int width, unsigned int height)
> > + * \brief Construct size range with a single size
> 
> nit: for consistency with the existing constructor and the structure
> documentation:
>         \brief Construct a size range representing a single size
> 
> > + * \param[in] width Single width
> > + * \param[in] height Single height
> 
> nit: I would drop 'Single' in favour of just 'The size width/height'
> 
> Minors apart:
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

I agree with both comments.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> > + */
> > +
> >  /**
> >   * \fn SizeRange::SizeRange(unsigned int minW, unsigned int minH, unsigned int maxW, unsigned int maxH)
> >   * \brief Construct an initialized size range

Patch

diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h
index a87d65d3ed7951c2..ec5ed2bee196c82d 100644
--- a/include/libcamera/geometry.h
+++ b/include/libcamera/geometry.h
@@ -72,6 +72,11 @@  struct SizeRange {
 	{
 	}
 
+	SizeRange(unsigned int width, unsigned int height)
+		: min(width, height), max(width, height)
+	{
+	}
+
 	SizeRange(unsigned int minW, unsigned int minH,
 		  unsigned int maxW, unsigned int maxH)
 		: min(minW, minH), max(maxW, maxH)
diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp
index 97c367bcb454b517..cc25b816e6796ba1 100644
--- a/src/libcamera/geometry.cpp
+++ b/src/libcamera/geometry.cpp
@@ -196,6 +196,13 @@  bool operator<(const Size &lhs, const Size &rhs)
  * \brief Construct a size range initialized to 0
  */
 
+/**
+ * \fn SizeRange::SizeRange(unsigned int width, unsigned int height)
+ * \brief Construct size range with a single size
+ * \param[in] width Single width
+ * \param[in] height Single height
+ */
+
 /**
  * \fn SizeRange::SizeRange(unsigned int minW, unsigned int minH, unsigned int maxW, unsigned int maxH)
  * \brief Construct an initialized size range