[libcamera-devel] [PATCH 2/2] qcam: main_window: Prefer stream formats that don't require conversion

Kieran Bingham kieran.bingham at ideasonboard.com
Tue Mar 24 13:41:13 CET 2020


Hi Laurent,

On 24/03/2020 10:30, Laurent Pinchart wrote:
> Query the viewfinder for the formats it supports natively, and select
> one of them for the stream if possible.

This should help improve performances indeed!

Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>

> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
>  src/qcam/main_window.cpp | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
> index b13660bccb25..565732698a5e 100644
> --- a/src/qcam/main_window.cpp
> +++ b/src/qcam/main_window.cpp
> @@ -297,6 +297,19 @@ int MainWindow::startCapture()
>  		}
>  	}
>  
> +	/* Use a format supported by the viewfinder if available. */
> +	std::vector<PixelFormat> formats = cfg.formats().pixelformats();

That's just a reference right? Not a full copy of the pixelformats() table?

> +	for (const PixelFormat &format : viewfinder_->nativeFormats()) {
> +		auto match = std::find_if(formats.begin(), formats.end(),
> +					  [&](const PixelFormat &f) {
> +						  return f == format;
> +					  });
> +		if (match != formats.end()) {
> +			cfg.pixelFormat = format;
> +			break;
> +		}
> +	}
> +
>  	CameraConfiguration::Status validation = config_->validate();
>  	if (validation == CameraConfiguration::Invalid) {
>  		qWarning() << "Failed to create valid camera configuration";
> 

-- 
Regards
--
Kieran


More information about the libcamera-devel mailing list