Message ID | 20200803161816.107113-3-kieran.bingham@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Kieran, Thank you for the patch. On Mon, Aug 03, 2020 at 05:18:06PM +0100, Kieran Bingham wrote: > Determine the number of planes used by a format by counting the number > of PxielFormatPlaneInfo entries with a valid entry. s/PxielFormatPlaneInfo/PixelFormatPlaneInfo/ > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > --- > v2: > - Rename to numPlanes Even in the subject line ? :-) > - Simplify fucntion doc. > --- > include/libcamera/internal/formats.h | 2 ++ > src/libcamera/formats.cpp | 18 ++++++++++++++++++ > 2 files changed, 20 insertions(+) > > diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h > index b8e474916378..51a8a6b8b0ae 100644 > --- a/include/libcamera/internal/formats.h > +++ b/include/libcamera/internal/formats.h > @@ -46,6 +46,8 @@ public: > unsigned int frameSize(const Size &size, > const std::array<unsigned int, 3> &strides) const; > > + unsigned int numPlanes() const; > + > /* \todo Add support for non-contiguous memory planes */ > const char *name; > PixelFormat format; > diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp > index a51e96810aed..ebaae9be3d75 100644 > --- a/src/libcamera/formats.cpp > +++ b/src/libcamera/formats.cpp > @@ -821,4 +821,22 @@ PixelFormatInfo::frameSize(const Size &size, > return sum; > } > > +/** > + * \brief Retrieve the number of planes represented by the format > + * \return The number of planes used by the format > + */ > +unsigned int PixelFormatInfo::numPlanes() const > +{ > + unsigned int count = 0; > + > + for (const PixelFormatPlaneInfo &p : planes) { > + if (p.bytesPerGroup == 0) > + break; > + > + count++; > + } > + > + return count; > +} > + > } /* namespace libcamera */
diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h index b8e474916378..51a8a6b8b0ae 100644 --- a/include/libcamera/internal/formats.h +++ b/include/libcamera/internal/formats.h @@ -46,6 +46,8 @@ public: unsigned int frameSize(const Size &size, const std::array<unsigned int, 3> &strides) const; + unsigned int numPlanes() const; + /* \todo Add support for non-contiguous memory planes */ const char *name; PixelFormat format; diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index a51e96810aed..ebaae9be3d75 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -821,4 +821,22 @@ PixelFormatInfo::frameSize(const Size &size, return sum; } +/** + * \brief Retrieve the number of planes represented by the format + * \return The number of planes used by the format + */ +unsigned int PixelFormatInfo::numPlanes() const +{ + unsigned int count = 0; + + for (const PixelFormatPlaneInfo &p : planes) { + if (p.bytesPerGroup == 0) + break; + + count++; + } + + return count; +} + } /* namespace libcamera */