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

Laurent Pinchart laurent.pinchart at ideasonboard.com
Tue Mar 24 13:52:34 CET 2020


Hi Kieran,

On Tue, Mar 24, 2020 at 12:41:13PM +0000, Kieran Bingham wrote:
> 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?

No, it's a copy, as StreamFormats doesn't store a vector of
PixelFormats, but a map. The vector is constructed at runtime.

> > +	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,

Laurent Pinchart


More information about the libcamera-devel mailing list