libcamera: pipeline: ipu3: Use new Size grownBy() and shrunkBy() helpers

The Size class has new helpers that can simplify the code in the IPU3
pipeline handler. Use them.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Laurent Pinchart 2021-10-13 04:23:11 +03:00
parent e229b35edf
commit ca5fb99409

View file

@ -438,11 +438,10 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera,
* \todo Clarify the alignment constraints as explained * \todo Clarify the alignment constraints as explained
* in validate() * in validate()
*/ */
size = sensorResolution.boundedTo(IMGU_OUTPUT_MAX_SIZE); size = sensorResolution.boundedTo(IMGU_OUTPUT_MAX_SIZE)
size.width = utils::alignDown(size.width - 1, .shrunkBy({ 1, 1 })
IMGU_OUTPUT_WIDTH_MARGIN); .alignedDownTo(IMGU_OUTPUT_WIDTH_MARGIN,
size.height = utils::alignDown(size.height - 1, IMGU_OUTPUT_HEIGHT_MARGIN);
IMGU_OUTPUT_HEIGHT_MARGIN);
pixelFormat = formats::NV12; pixelFormat = formats::NV12;
bufferCount = IPU3_BUFFER_COUNT; bufferCount = IPU3_BUFFER_COUNT;
streamFormats[pixelFormat] = { { IMGU_OUTPUT_MIN_SIZE, size } }; streamFormats[pixelFormat] = { { IMGU_OUTPUT_MIN_SIZE, size } };
@ -996,20 +995,18 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data)
*/ */
/* The strictly smaller size than the sensor resolution, aligned to margins. */ /* The strictly smaller size than the sensor resolution, aligned to margins. */
Size minSize = Size(sensor->resolution().width - 1, Size minSize = sensor->resolution().shrunkBy({ 1, 1 })
sensor->resolution().height - 1) .alignedDownTo(IMGU_OUTPUT_WIDTH_MARGIN,
.alignedDownTo(IMGU_OUTPUT_WIDTH_MARGIN, IMGU_OUTPUT_HEIGHT_MARGIN);
IMGU_OUTPUT_HEIGHT_MARGIN);
/* /*
* Either the smallest margin-aligned size larger than the viewfinder * Either the smallest margin-aligned size larger than the viewfinder
* size or the adjusted sensor resolution. * size or the adjusted sensor resolution.
*/ */
minSize = Size(IPU3ViewfinderSize.width + 1, minSize = IPU3ViewfinderSize.grownBy({ 1, 1 })
IPU3ViewfinderSize.height + 1) .alignedUpTo(IMGU_OUTPUT_WIDTH_MARGIN,
.alignedUpTo(IMGU_OUTPUT_WIDTH_MARGIN, IMGU_OUTPUT_HEIGHT_MARGIN)
IMGU_OUTPUT_HEIGHT_MARGIN) .boundedTo(minSize);
.boundedTo(minSize);
/* /*
* Re-scale in the sensor's native coordinates. Report (0,0) as * Re-scale in the sensor's native coordinates. Report (0,0) as