From patchwork Tue Mar 24 10:30:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3296 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5FB7460414 for ; Tue, 24 Mar 2020 11:30:18 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D8BF8A58 for ; Tue, 24 Mar 2020 11:30:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1585045818; bh=qBu5c2Vl6DLPx3jdP+oopcjapdSMronTHRiolXMSQKo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=vtwM0FqVYLANRJYn0dfvNx/nDgAXWf8WPSVZ8q7DF0+QyGPeDYsYE5fE6/ZI5E+lT 8cRIbTejjiZ7c8mJNislt7xG71o7O4Iql02Nr8Rs7UaRLL+bdplOWS/Oow1faie38O blhy1meK6ofhCXbN+d7s0QkV0+TfrjBqcgWolQWo= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 24 Mar 2020 12:30:12 +0200 Message-Id: <20200324103012.9678-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200324103012.9678-1-laurent.pinchart@ideasonboard.com> References: <20200324103012.9678-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] qcam: main_window: Prefer stream formats that don't require conversion X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Mar 2020 10:30:18 -0000 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(+) 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 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";