[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 11:30:12 CET 2020


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 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();
+	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