Message ID | 20200324103012.9678-2-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Commit | e74885c870a8d13736b422f8faadec3339cc588d |
Headers | show |
Series |
|
Related | show |
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@ideasonboard.com> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@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"; >
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@ideasonboard.com> > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@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";
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(); + 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";
Query the viewfinder for the formats it supports natively, and select one of them for the stream if possible. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- src/qcam/main_window.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+)