From patchwork Thu Sep 23 08:37:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13905 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 A3FB8BF01C for ; Thu, 23 Sep 2021 08:38:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 699226918F; Thu, 23 Sep 2021 10:38:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RkLvqrB9"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F66E69188 for ; Thu, 23 Sep 2021 10:38:00 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [IPv6:2405:204:8203:58de:7651:79c1:5e62:dca9]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7BC5745E; Thu, 23 Sep 2021 10:37:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1632386279; bh=OIhhuvSys565EjNfQuYNSbgaPKYG4kY85OIhbFK/0JQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RkLvqrB9AJhKk1tkpel2YArps4C+PIFDK8BzAIXyNDKgXO51EL7bROmcw6u8qhjf2 QBwc8OI5srRHgEIgEdWQ0R0KNNVD/k4hTL4HX7eIUmHnKdBbevXGgiL2RLYJwit1d4 3eU2ai7/KfFCjb6gleuhfXi5bT9jKY20RS7OnpNc= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Thu, 23 Sep 2021 14:07:47 +0530 Message-Id: <20210923083748.146265-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210923083748.146265-1-umang.jain@ideasonboard.com> References: <20210923083748.146265-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 1/2] android: camera_capabilities: Clarify CameraMetadata allocation 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" CameraMetadata's constructor take in number of entries and number of bytes to be allocated for those entries. However, CameraMetadata is already capable of resizing its container on the fly, in case more entries are added to it. Hence, the numbers passed in during the construction acts as hint values for initialization. Clarify this in CameraCapabilities::requestTemplatePreview() and remove the \todo, as the arguments and the \todo gives the perspective that we need to be quite accurate with the numbers of entries / bytes, which is not the case. Signed-off-by: Umang Jain Reviewed-by: Paul Elder Reviewed-by: Hirokazu Honda Reviewed-by: Jacopo Mondi --- src/android/camera_capabilities.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index e92bca42..edeb6943 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -1340,8 +1340,12 @@ std::unique_ptr CameraCapabilities::requestTemplateManual() cons std::unique_ptr CameraCapabilities::requestTemplatePreview() const { /* - * \todo Keep this in sync with the actual number of entries. - * Currently: 20 entries, 35 bytes + * Give initial hint of entries and number of bytes to be allocated. + * It is deliberate that the hint is slightly larger than required, to + * avoid resizing the container. + * + * CameraMetadata is capable of resizing the container on the fly, if + * adding a new entry will exceed its capacity. */ auto requestTemplate = std::make_unique(21, 36); if (!requestTemplate->isValid()) { From patchwork Thu Sep 23 08:37:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 13906 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 0CA96BF01C for ; Thu, 23 Sep 2021 08:38:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C0E436918C; Thu, 23 Sep 2021 10:38:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="D3MqJ1xX"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5AF42687DC for ; Thu, 23 Sep 2021 10:38:04 +0200 (CEST) Received: from perceval.ideasonboard.com (unknown [IPv6:2405:204:8203:58de:7651:79c1:5e62:dca9]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E937858B; Thu, 23 Sep 2021 10:38:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1632386284; bh=iB4nwK/QnGjbVfoC9pwEtE8hkWXhxfdiEZDXyH1RBoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D3MqJ1xXpPYP0Rmpfru6nzJAWwqCGk7AB9kIeaxRVvA0HLyoATM7vuHNBi3YeX6GV BnjDpYnHPHPNbwa+H4h+/PSRhJEbJFq5HvE7okjCNYeRyoSRgIM4nmGLJQVc5EK5dY +UvCeFRQ3S273OOyZl2w5k6MYLVu42gpXntHfLWY= From: Umang Jain To: libcamera-devel@lists.libcamera.org Date: Thu, 23 Sep 2021 14:07:48 +0530 Message-Id: <20210923083748.146265-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210923083748.146265-1-umang.jain@ideasonboard.com> References: <20210923083748.146265-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 2/2] android: Fix generation of thumbnail for EXIF data 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" Generation of thumbnail is not occuring currently because ANDROID_JPEG_THUMBNAIL_SIZE is not set for request metadata passed to PostProcessorJpeg::process(). This is a regression introduced in 1264628d3c92("android: jpeg: Configure thumbnailer based on request metadata"). The patch fixes this issue by setting ANDROID_JPEG_THUMBNAIL_SIZE in the request metadata template populated by CameraCapabilities::requestTemplatePreview(). The value for ANDROID_JPEG_THUMBNAIL_SIZE is set to be the first non-zero size reported by static metadata ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES. Fixes: 1264628d3c92("android: jpeg: Configure thumbnailer based on request metadata") Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Hirokazu Honda Reviewed-by: Jacopo Mondi --- src/android/camera_capabilities.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index edeb6943..ed59ae1c 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -1347,7 +1347,7 @@ std::unique_ptr CameraCapabilities::requestTemplatePreview() con * CameraMetadata is capable of resizing the container on the fly, if * adding a new entry will exceed its capacity. */ - auto requestTemplate = std::make_unique(21, 36); + auto requestTemplate = std::make_unique(22, 38); if (!requestTemplate->isValid()) { return nullptr; } @@ -1368,6 +1368,25 @@ std::unique_ptr CameraCapabilities::requestTemplatePreview() con requestTemplate->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, entry.data.i32, 2); + /* + * Get thumbnail sizes from static metadata and add the first non-zero + * size to the template. + */ + found = staticMetadata_->getEntry(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, + &entry); + ASSERT(found && entry.count >= 4); + unsigned int j = 0; + while (j < entry.count / 2) { + if (entry.data.i32[j] == 0 || entry.data.i32[j + 1] == 0) { + j += 2; + continue; + } + + requestTemplate->addEntry(ANDROID_JPEG_THUMBNAIL_SIZE, + entry.data.i32 + j, 2); + break; + } + uint8_t aeMode = ANDROID_CONTROL_AE_MODE_ON; requestTemplate->addEntry(ANDROID_CONTROL_AE_MODE, aeMode);