From e74885c870a8d13736b422f8faadec3339cc588d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 24 Mar 2020 12:16:53 +0200 Subject: 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 Reviewed-by: Kieran Bingham --- src/qcam/main_window.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/qcam') 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 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"; -- cgit v1.2.1