libcamera: geometry: Construct SizeRange from Size
The SizeRange constructors take minimum and maximum width and height values as separate arguments. We have a Size class to convey size information, use it in the constructors, and update the callers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
+10
-17
@@ -217,31 +217,24 @@ bool operator<(const Size &lhs, const Size &rhs)
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn SizeRange::SizeRange(unsigned int width, unsigned int height)
|
||||
* \fn SizeRange::SizeRange(const Size &size)
|
||||
* \brief Construct a size range representing a single size
|
||||
* \param[in] width The size width
|
||||
* \param[in] height The size height
|
||||
* \param[in] size The size
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn SizeRange::SizeRange(unsigned int minW, unsigned int minH,
|
||||
* unsigned int maxW, unsigned int maxH)
|
||||
* \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
|
||||
* \fn SizeRange::SizeRange(const Size &minSize, const Size &maxSize)
|
||||
* \brief Construct a size range with specified min and max, and steps of 1
|
||||
* \param[in] minSize The minimum size
|
||||
* \param[in] maxSize The maximum size
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn SizeRange::SizeRange(unsigned int minW, unsigned int minH,
|
||||
* unsigned int maxW, unsigned int maxH,
|
||||
* \fn SizeRange::SizeRange(const Size &minSize, const Size &maxSize,
|
||||
* 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
|
||||
* \brief Construct a size range with specified min, max and step
|
||||
* \param[in] minSize The minimum size
|
||||
* \param[in] maxSize The maximum size
|
||||
* \param[in] hstep The horizontal step
|
||||
* \param[in] vstep The vertical step
|
||||
*/
|
||||
|
||||
@@ -177,7 +177,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,
|
||||
for (PixelFormat pixelformat : pixelformats) {
|
||||
/* The scaler hardcodes a x3 scale-up ratio. */
|
||||
std::vector<SizeRange> sizes{
|
||||
SizeRange{ 48, 48, 4096, 2160 }
|
||||
SizeRange{ { 48, 48 }, { 4096, 2160 } }
|
||||
};
|
||||
formats[pixelformat] = sizes;
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ SizeRange StreamFormats::range(const PixelFormat &pixelformat) const
|
||||
return ranges[0];
|
||||
|
||||
LOG(Stream, Debug) << "Building range from discrete sizes";
|
||||
SizeRange range(UINT_MAX, UINT_MAX, 0, 0);
|
||||
SizeRange range({ UINT_MAX, UINT_MAX }, { 0, 0 });
|
||||
for (const SizeRange &limit : ranges) {
|
||||
if (limit.min < range.min)
|
||||
range.min = limit.min;
|
||||
|
||||
@@ -313,8 +313,8 @@ std::vector<SizeRange> V4L2Subdevice::enumPadSizes(unsigned int pad,
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
sizes.emplace_back(sizeEnum.min_width, sizeEnum.min_height,
|
||||
sizeEnum.max_width, sizeEnum.max_height);
|
||||
sizes.emplace_back(Size{ sizeEnum.min_width, sizeEnum.min_height },
|
||||
Size{ sizeEnum.max_width, sizeEnum.max_height });
|
||||
}
|
||||
|
||||
if (ret < 0 && ret != -EINVAL && ret != -ENOTTY) {
|
||||
|
||||
@@ -971,20 +971,20 @@ std::vector<SizeRange> V4L2VideoDevice::enumSizes(unsigned int pixelFormat)
|
||||
|
||||
switch (frameSize.type) {
|
||||
case V4L2_FRMSIZE_TYPE_DISCRETE:
|
||||
sizes.emplace_back(frameSize.discrete.width,
|
||||
frameSize.discrete.height);
|
||||
sizes.emplace_back(Size{ frameSize.discrete.width,
|
||||
frameSize.discrete.height });
|
||||
break;
|
||||
case V4L2_FRMSIZE_TYPE_CONTINUOUS:
|
||||
sizes.emplace_back(frameSize.stepwise.min_width,
|
||||
frameSize.stepwise.min_height,
|
||||
frameSize.stepwise.max_width,
|
||||
frameSize.stepwise.max_height);
|
||||
sizes.emplace_back(Size{ frameSize.stepwise.min_width,
|
||||
frameSize.stepwise.min_height },
|
||||
Size{ frameSize.stepwise.max_width,
|
||||
frameSize.stepwise.max_height });
|
||||
break;
|
||||
case V4L2_FRMSIZE_TYPE_STEPWISE:
|
||||
sizes.emplace_back(frameSize.stepwise.min_width,
|
||||
frameSize.stepwise.min_height,
|
||||
frameSize.stepwise.max_width,
|
||||
frameSize.stepwise.max_height,
|
||||
sizes.emplace_back(Size{ frameSize.stepwise.min_width,
|
||||
frameSize.stepwise.min_height },
|
||||
Size{ frameSize.stepwise.max_width,
|
||||
frameSize.stepwise.max_height },
|
||||
frameSize.stepwise.step_width,
|
||||
frameSize.stepwise.step_height);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user