[libcamera-devel,v4,2/2] android: Fix generation of thumbnail for EXIF data
diff mbox series

Message ID 20210923083748.146265-3-umang.jain@ideasonboard.com
State Superseded
Delegated to: Umang Jain
Headers show
Series
  • android: Fix generation of thumbnail for EXIF data
Related show

Commit Message

Umang Jain Sept. 23, 2021, 8:37 a.m. UTC
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 <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
---
 src/android/camera_capabilities.cpp | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

Comments

Jacopo Mondi Sept. 27, 2021, 7:51 p.m. UTC | #1
Hi Umang,

On Thu, Sep 23, 2021 at 02:07:48PM +0530, Umang Jain wrote:
> 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 <umang.jain@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

> ---
>  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<CameraMetadata> 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<CameraMetadata>(21, 36);
> +	auto requestTemplate = std::make_unique<CameraMetadata>(22, 38);
>  	if (!requestTemplate->isValid()) {
>  		return nullptr;
>  	}
> @@ -1368,6 +1368,25 @@ std::unique_ptr<CameraMetadata> 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);
>
> --
> 2.31.1
>

Patch
diff mbox series

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<CameraMetadata> 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<CameraMetadata>(21, 36);
+	auto requestTemplate = std::make_unique<CameraMetadata>(22, 38);
 	if (!requestTemplate->isValid()) {
 		return nullptr;
 	}
@@ -1368,6 +1368,25 @@  std::unique_ptr<CameraMetadata> 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);