libcamera: ipu3: Use std::max() instead of expandTo() to get the max resolution
Using Size::expandTo() to find the max resolution might generate a non-existent resolution. For example, when application request streams for 1920x1080 and 1600x1200, the max resolution will be wrongly 1920x1200 and fails the configuration. Bug: https://bugs.libcamera.org/show_bug.cgi?id=139 Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
45c198da63
commit
ba72e4202f
1 changed files with 12 additions and 10 deletions
|
@ -243,6 +243,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
|
||||||
*/
|
*/
|
||||||
unsigned int rawCount = 0;
|
unsigned int rawCount = 0;
|
||||||
unsigned int yuvCount = 0;
|
unsigned int yuvCount = 0;
|
||||||
|
Size rawRequirement;
|
||||||
Size maxYuvSize;
|
Size maxYuvSize;
|
||||||
Size rawSize;
|
Size rawSize;
|
||||||
|
|
||||||
|
@ -251,10 +252,11 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
|
||||||
|
|
||||||
if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) {
|
if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) {
|
||||||
rawCount++;
|
rawCount++;
|
||||||
rawSize.expandTo(cfg.size);
|
rawSize = std::max(rawSize, cfg.size);
|
||||||
} else {
|
} else {
|
||||||
yuvCount++;
|
yuvCount++;
|
||||||
maxYuvSize.expandTo(cfg.size);
|
maxYuvSize = std::max(maxYuvSize, cfg.size);
|
||||||
|
rawRequirement.expandTo(cfg.size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,17 +285,17 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
|
||||||
* The output YUV streams will be limited in size to the maximum frame
|
* The output YUV streams will be limited in size to the maximum frame
|
||||||
* size requested for the RAW stream, if present.
|
* size requested for the RAW stream, if present.
|
||||||
*
|
*
|
||||||
* If no raw stream is requested generate a size as large as the maximum
|
* If no raw stream is requested, generate a size from the largest YUV
|
||||||
* requested YUV size aligned to the ImgU constraints and bound by the
|
* stream, aligned to the ImgU constraints and bound
|
||||||
* sensor's maximum resolution. See
|
* by the sensor's maximum resolution. See
|
||||||
* https://bugs.libcamera.org/show_bug.cgi?id=32
|
* https://bugs.libcamera.org/show_bug.cgi?id=32
|
||||||
*/
|
*/
|
||||||
if (rawSize.isNull())
|
if (rawSize.isNull())
|
||||||
rawSize = maxYuvSize.expandedTo({ ImgUDevice::kIFMaxCropWidth,
|
rawSize = rawRequirement.expandedTo({ ImgUDevice::kIFMaxCropWidth,
|
||||||
ImgUDevice::kIFMaxCropHeight })
|
ImgUDevice::kIFMaxCropHeight })
|
||||||
.grownBy({ ImgUDevice::kOutputMarginWidth,
|
.grownBy({ ImgUDevice::kOutputMarginWidth,
|
||||||
ImgUDevice::kOutputMarginHeight })
|
ImgUDevice::kOutputMarginHeight })
|
||||||
.boundedTo(data_->cio2_.sensor()->resolution());
|
.boundedTo(data_->cio2_.sensor()->resolution());
|
||||||
|
|
||||||
cio2Configuration_ = data_->cio2_.generateConfiguration(rawSize);
|
cio2Configuration_ = data_->cio2_.generateConfiguration(rawSize);
|
||||||
if (!cio2Configuration_.pixelFormat.isValid())
|
if (!cio2Configuration_.pixelFormat.isValid())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue