diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-03-24 12:16:53 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-03-24 14:51:09 +0200 |
commit | e74885c870a8d13736b422f8faadec3339cc588d (patch) | |
tree | f0778a5f1b5a7d2ee8d07dfbc02fe49678ac00a2 /src/qcam/main_window.cpp | |
parent | 8bd4f20193abafdd8bc25b9b0d37a0aced8aa2cb (diff) |
qcam: main_window: Prefer stream formats that don't require conversion
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>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/qcam/main_window.cpp')
-rw-r--r-- | src/qcam/main_window.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index b13660bc..56573269 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"; |