libcamera: formats: add numPlanes helper
Determine the number of planes used by a format by counting the number of PixelFormatPlaneInfo entries with a valid entry. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
000257a707
commit
38ca814e97
2 changed files with 20 additions and 0 deletions
|
@ -46,6 +46,8 @@ public:
|
||||||
unsigned int frameSize(const Size &size,
|
unsigned int frameSize(const Size &size,
|
||||||
const std::array<unsigned int, 3> &strides) const;
|
const std::array<unsigned int, 3> &strides) const;
|
||||||
|
|
||||||
|
unsigned int numPlanes() const;
|
||||||
|
|
||||||
/* \todo Add support for non-contiguous memory planes */
|
/* \todo Add support for non-contiguous memory planes */
|
||||||
const char *name;
|
const char *name;
|
||||||
PixelFormat format;
|
PixelFormat format;
|
||||||
|
|
|
@ -821,4 +821,22 @@ PixelFormatInfo::frameSize(const Size &size,
|
||||||
return sum;
|
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 */
|
} /* namespace libcamera */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue