From patchwork Wed Aug 5 15:37:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 9241 X-Patchwork-Delegate: jacopo@jmondi.org 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 8408FBD86F for ; Wed, 5 Aug 2020 15:34:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 19DF56071B; Wed, 5 Aug 2020 17:34:12 +0200 (CEST) Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D59EB60599 for ; Wed, 5 Aug 2020 17:34:10 +0200 (CEST) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 4073740007; Wed, 5 Aug 2020 15:34:09 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 5 Aug 2020 17:37:45 +0200 Message-Id: <20200805153745.30378-1-jacopo@jmondi.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] android: camera_device: Report supported JPEG sizes 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 producing the list of image resolution to claim as supported by the camera HAL, the JPEG stream was assumed to be 'always valid' as, at the time, there was no JPEG support in place at all. With the introduction of support for JPEG compression, reporting non-valid sizes as supported obviously causes troubles. In order to avoid reporting non-supported resolutions as supported, produce the list of available JPEG sizes by using the ones supported by the YCbCr_420_888 format, from which the JPEG stream is encoded. Signed-off-by: Jacopo Mondi --- Patch to be applied on top of Kieran's JPEG work. --- src/android/camera_device.cpp | 38 +++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 11 deletions(-) -- 2.27.0 diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index ec8ca934842a..6a9a038a2b53 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -398,27 +398,43 @@ int CameraDevice::initializeStreamConfigurations() */ formatsMap_[androidFormat] = mappedFormat; + /* + * Stop here for JPEG streams: the JPEG supported sizes will + * be tested later using the here recorded non-blob stream sizes. + */ + if (androidFormat == HAL_PIXEL_FORMAT_BLOB) + continue; + for (const Size &res : cameraResolutions) { cfg.pixelFormat = mappedFormat; cfg.size = res; - CameraConfiguration::Status status = cameraConfig->validate(); - /* - * Unconditionally report we can produce JPEG. - * - * \todo The JPEG stream will be implemented as an - * HAL-only stream, but some cameras can produce it - * directly. As of now, claim support for JPEG without - * inspecting where the JPEG stream is produced. - */ - if (androidFormat != HAL_PIXEL_FORMAT_BLOB && - status != CameraConfiguration::Valid) + if (cameraConfig->validate() != CameraConfiguration::Valid) continue; streamConfigurations_.push_back({ res, androidFormat }); } } + /* + * Insert the JPEG sizes by using the ones recorded for YUV streams + * from which JPEG is produced. + */ + std::vector jpegConfigurations; + jpegConfigurations.reserve(cameraResolutions.size()); + + for (const auto &config : streamConfigurations_) { + /* \todo JPEG can be produced from other formats too! */ + if (config.androidFormat != HAL_PIXEL_FORMAT_YCbCr_420_888) + continue; + + jpegConfigurations.push_back({ config.resolution, + HAL_PIXEL_FORMAT_BLOB }); + } + + for (auto const jpegConfig : jpegConfigurations) + streamConfigurations_.push_back(jpegConfig); + LOG(HAL, Debug) << "Collected stream configuration map: "; for (const auto &entry : streamConfigurations_) LOG(HAL, Debug) << "{ " << entry.resolution.toString() << " - "