libcamera: converter: Add function to query crop bounds
The inputCropBounds_ member of the V4L2M2MConverter::Stream class is only initialized after a V4L2M2MConverter::configure() call, when the streams are initialized. However, the converter has crop limits that do not depend on the configured Streams, and which are currently not accessible from the class interface. Add a new inputCropBounds() function to the V4L2M2MConverter class that allows to retrieve the converter crop limits before any stream is configured. This is particularly useful for pipelines to initialize controls and properties and to implement validation before the Camera gets configured. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
This commit is contained in:
@@ -185,6 +185,16 @@ Converter::~Converter()
|
||||
|
||||
/**
|
||||
* \fn Converter::inputCropBounds()
|
||||
* \brief Retrieve the crop bounds of the converter
|
||||
*
|
||||
* Retrieve the minimum and maximum crop bounds of the converter. This can be
|
||||
* used to query the crop bounds before configuring a stream.
|
||||
*
|
||||
* \return A pair containing the minimum and maximum crop bound in that order
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn Converter::inputCropBounds(const Stream *stream)
|
||||
* \brief Retrieve the crop bounds for \a stream
|
||||
* \param[in] stream The output stream
|
||||
*
|
||||
@@ -195,6 +205,9 @@ Converter::~Converter()
|
||||
* this function should be called after the \a stream has been configured using
|
||||
* configure().
|
||||
*
|
||||
* When called with an unconfigured \a stream, this function returns a pair of
|
||||
* null rectangles.
|
||||
*
|
||||
* \return A pair containing the minimum and maximum crop bound in that order
|
||||
*/
|
||||
|
||||
|
||||
@@ -273,10 +273,9 @@ V4L2M2MConverter::V4L2M2MConverter(MediaDevice *media)
|
||||
return;
|
||||
}
|
||||
|
||||
Rectangle minCrop;
|
||||
Rectangle maxCrop;
|
||||
ret = getCropBounds(m2m_->output(), minCrop, maxCrop);
|
||||
if (!ret && minCrop != maxCrop) {
|
||||
ret = getCropBounds(m2m_->output(), inputCropBounds_.first,
|
||||
inputCropBounds_.second);
|
||||
if (!ret && inputCropBounds_.first != inputCropBounds_.second) {
|
||||
features_ |= Feature::InputCrop;
|
||||
|
||||
LOG(Converter, Info)
|
||||
@@ -469,14 +468,21 @@ int V4L2M2MConverter::setInputCrop(const Stream *stream, Rectangle *rect)
|
||||
}
|
||||
|
||||
/**
|
||||
* \copydoc libcamera::Converter::inputCropBounds
|
||||
* \fn libcamera::V4L2M2MConverter::inputCropBounds()
|
||||
* \copydoc libcamera::Converter::inputCropBounds()
|
||||
*/
|
||||
|
||||
/**
|
||||
* \copydoc libcamera::Converter::inputCropBounds(const Stream *stream)
|
||||
*/
|
||||
std::pair<Rectangle, Rectangle>
|
||||
V4L2M2MConverter::inputCropBounds(const Stream *stream)
|
||||
{
|
||||
auto iter = streams_.find(stream);
|
||||
if (iter == streams_.end())
|
||||
if (iter == streams_.end()) {
|
||||
LOG(Converter, Error) << "Invalid output stream";
|
||||
return {};
|
||||
}
|
||||
|
||||
return iter->second->inputCropBounds();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user