From patchwork Tue Jul 27 11:05:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 13126 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0C5E3C322C for ; Tue, 27 Jul 2021 11:04:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A8519687CC; Tue, 27 Jul 2021 13:04:37 +0200 (CEST) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D53A760272 for ; Tue, 27 Jul 2021 13:04:35 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 1FB4A20008; Tue, 27 Jul 2021 11:04:34 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Jul 2021 13:05:17 +0200 Message-Id: <20210727110519.11587-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727110519.11587-1-jacopo@jmondi.org> References: <20210727110519.11587-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/3] android: capabilities: Use a throw-away config for YUV stream building 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When building the list of supported YUV streams in getYUVResolutions() the CameraConfiguration provided by the caller as first parameters is used. As the CameraConfiguration will be later actually applied to the Camera, avoid any possible overlap of the configuration parameters by using a throw-away CameraConfiguration generated for the Viewfinder stream role in getYUVResolutions(). It's also nicer to avoid having two functions with a similar purpose such as getYUVResolutions() and getRawResolutions() with different parameter lists, as the presence of a CameraConfiguration as first parameter might be confusing to the reader. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain --- src/android/camera_capabilities.cpp | 10 +++++----- src/android/camera_capabilities.h | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 6b5edb66fad2..6543c2bbc6c3 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -138,13 +138,14 @@ int CameraCapabilities::initialize(std::shared_ptr camera, return initializeStaticMetadata(); } -std::vector CameraCapabilities::getYUVResolutions(CameraConfiguration *cameraConfig, - const PixelFormat &pixelFormat, +std::vector CameraCapabilities::getYUVResolutions(const PixelFormat &pixelFormat, const std::vector &resolutions) { std::vector supportedResolutions; - + std::unique_ptr cameraConfig = + camera_->generateConfiguration({ StreamRole::Viewfinder }); StreamConfiguration &cfg = cameraConfig->at(0); + for (const Size &res : resolutions) { cfg.pixelFormat = pixelFormat; cfg.size = res; @@ -324,8 +325,7 @@ int CameraCapabilities::initializeStreamConfigurations() if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) resolutions = getRawResolutions(mappedFormat); else - resolutions = getYUVResolutions(cameraConfig.get(), - mappedFormat, + resolutions = getYUVResolutions(mappedFormat, cameraResolutions); for (const Size &res : resolutions) { diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h index 4f5be82595d6..e72bf084cd65 100644 --- a/src/android/camera_capabilities.h +++ b/src/android/camera_capabilities.h @@ -43,8 +43,7 @@ private: }; std::vector - getYUVResolutions(libcamera::CameraConfiguration *cameraConfig, - const libcamera::PixelFormat &pixelFormat, + getYUVResolutions(const libcamera::PixelFormat &pixelFormat, const std::vector &resolutions); std::vector getRawResolutions(const libcamera::PixelFormat &pixelFormat);