libcamera: geometry: Use Size to store min and max in SizeRange
Instead of storing four integers for the minimum and maximum width and height in the SizeRange class, use two instance of the Size class for the minimum and maximum sizes. While it at replace the mention of image size with size in the SizeRange documentation, as the Size class isn't limited to image sizes. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
e7f446e1ed
commit
72afcbb087
4 changed files with 23 additions and 38 deletions
|
@ -38,21 +38,17 @@ struct Size {
|
||||||
|
|
||||||
struct SizeRange {
|
struct SizeRange {
|
||||||
SizeRange()
|
SizeRange()
|
||||||
: SizeRange(0, 0, 0, 0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SizeRange(unsigned int minW, unsigned int minH,
|
SizeRange(unsigned int minW, unsigned int minH,
|
||||||
unsigned int maxW, unsigned int maxH)
|
unsigned int maxW, unsigned int maxH)
|
||||||
: minWidth(minW), minHeight(minH), maxWidth(maxW),
|
: min(minW, minH), max(maxW, maxH)
|
||||||
maxHeight(maxH)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int minWidth;
|
Size min;
|
||||||
unsigned int minHeight;
|
Size max;
|
||||||
unsigned int maxWidth;
|
|
||||||
unsigned int maxHeight;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace libcamera */
|
} /* namespace libcamera */
|
||||||
|
|
|
@ -93,11 +93,11 @@ const std::string Rectangle::toString() const
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \struct SizeRange
|
* \struct SizeRange
|
||||||
* \brief Describe a range of image sizes
|
* \brief Describe a range of sizes
|
||||||
*
|
*
|
||||||
* SizeRange describes a range of image sizes included in the (minWidth,
|
* SizeRange describes a range of sizes included in the [min, max]
|
||||||
* minHeight) - (maxWidth, maxHeight) interval. If the minimum and
|
* interval for both the width and the height. If the minimum and
|
||||||
* maximum sizes are identical it represents a single image resolution.
|
* maximum sizes are identical it represents a single size.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,23 +115,13 @@ const std::string Rectangle::toString() const
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \var SizeRange::minWidth
|
* \var SizeRange::min
|
||||||
* \brief The minimum image width
|
* \brief The minimum size
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \var SizeRange::minHeight
|
* \var SizeRange::max
|
||||||
* \brief The minimum image height
|
* \brief The maximum size
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \var SizeRange::maxWidth
|
|
||||||
* \brief The maximum image width
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \var SizeRange::maxHeight
|
|
||||||
* \brief The maximum image height
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
} /* namespace libcamera */
|
} /* namespace libcamera */
|
||||||
|
|
|
@ -1058,10 +1058,9 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (const SizeRange &size : it.second) {
|
for (const SizeRange &size : it.second) {
|
||||||
if (maxSize_.width < size.maxWidth &&
|
if (maxSize_.width < size.max.width &&
|
||||||
maxSize_.height < size.maxHeight) {
|
maxSize_.height < size.max.height) {
|
||||||
maxSize_.width = size.maxWidth;
|
maxSize_ = size.max;
|
||||||
maxSize_.height = size.maxHeight;
|
|
||||||
mbusCode_ = mbusCode;
|
mbusCode_ = mbusCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1116,19 +1115,19 @@ int CIO2Device::configure(const StreamConfiguration &config,
|
||||||
* as possible. This will need to be revisited when
|
* as possible. This will need to be revisited when
|
||||||
* implementing the scaling policy.
|
* implementing the scaling policy.
|
||||||
*/
|
*/
|
||||||
if (size.maxWidth < config.width ||
|
if (size.max.width < config.width ||
|
||||||
size.maxHeight < config.height)
|
size.max.height < config.height)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
unsigned int diff = size.maxWidth * size.maxHeight
|
unsigned int diff = size.max.width * size.max.height
|
||||||
- imageSize;
|
- imageSize;
|
||||||
if (diff >= best)
|
if (diff >= best)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
best = diff;
|
best = diff;
|
||||||
|
|
||||||
sensorFormat.width = size.maxWidth;
|
sensorFormat.width = size.max.width;
|
||||||
sensorFormat.height = size.maxHeight;
|
sensorFormat.height = size.max.height;
|
||||||
sensorFormat.mbus_code = it.first;
|
sensorFormat.mbus_code = it.first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,10 @@ void ListFormatsTest::printFormats(unsigned int pad,
|
||||||
for (SizeRange &size : sizes) {
|
for (SizeRange &size : sizes) {
|
||||||
cout << " mbus code: 0x" << setfill('0') << setw(4)
|
cout << " mbus code: 0x" << setfill('0') << setw(4)
|
||||||
<< hex << code << endl;
|
<< hex << code << endl;
|
||||||
cout << " min width: " << dec << size.minWidth << endl;
|
cout << " min width: " << dec << size.min.width << endl;
|
||||||
cout << " min height: " << dec << size.minHeight << endl;
|
cout << " min height: " << dec << size.min.height << endl;
|
||||||
cout << " max width: " << dec << size.maxWidth << endl;
|
cout << " max width: " << dec << size.max.width << endl;
|
||||||
cout << " max height: " << dec << size.maxHeight << endl;
|
cout << " max height: " << dec << size.max.height << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue