[libcamera-devel,RFC,5/6,HACK] : android: camera_device: Define JPEG size and quality

Message ID 20200721220126.202065-6-kieran.bingham@ideasonboard.com
State RFC
Headers show
Series
  • android: jpeg / software streams
Related show

Commit Message

Kieran Bingham July 21, 2020, 10:01 p.m. UTC
Providing these two keys allows the camera application to capture
without crashing. It does not /succeed/ but it doesn't crash.

The camera application and cros-camera-test still need exif information
to be able to successfully capture or pass the tests.

These metadata values are hardcoded, as there is not yet an easy way to
add dynamic data to the request metadata.

I would like to see all of the infrastructure around adding request
metadata support a more dynamic means of addition, which blocks easily
adding and updating key value pairs otherwise.

But as all of that is a lot of work, here's a hack-ity work around for
the time being. Otherwise no form of the JPEG series will ever be
posted.

Please don't review this. ;-)

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/android/camera_device.cpp | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Jacopo Mondi July 28, 2020, 5 p.m. UTC | #1
On Tue, Jul 21, 2020 at 11:01:25PM +0100, Kieran Bingham wrote:
> Providing these two keys allows the camera application to capture
> without crashing. It does not /succeed/ but it doesn't crash.
>
> The camera application and cros-camera-test still need exif information
> to be able to successfully capture or pass the tests.
>
> These metadata values are hardcoded, as there is not yet an easy way to
> add dynamic data to the request metadata.
>
> I would like to see all of the infrastructure around adding request
> metadata support a more dynamic means of addition, which blocks easily
> adding and updating key value pairs otherwise.
>
> But as all of that is a lot of work, here's a hack-ity work around for
> the time being. Otherwise no form of the JPEG series will ever be
> posted.
>
> Please don't review this. ;-)

as you wish :)

>
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/android/camera_device.cpp | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index 7323d4e58f68..23dde1cfaf98 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -846,6 +846,8 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
>  		ANDROID_SENSOR_EXPOSURE_TIME,
>  		ANDROID_STATISTICS_LENS_SHADING_MAP_MODE,
>  		ANDROID_STATISTICS_SCENE_FLICKER,
> +		ANDROID_JPEG_SIZE,
> +		ANDROID_JPEG_QUALITY,
>  	};
>  	staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS,
>  				  availableResultKeys.data(),
> @@ -1444,10 +1446,10 @@ std::unique_ptr<CameraMetadata> CameraDevice::getResultMetadata(int frame_number
>  {
>  	/*
>  	 * \todo Keep this in sync with the actual number of entries.
> -	 * Currently: 12 entries, 36 bytes

That's the second time I encounter a comment we failed to keep in sync
for metadata.

> +	 * Currently: 17 entries, 58 bytes
>  	 */
>  	std::unique_ptr<CameraMetadata> resultMetadata =
> -		std::make_unique<CameraMetadata>(15, 50);
> +		std::make_unique<CameraMetadata>(17, 58);

>  	if (!resultMetadata->isValid()) {
>  		LOG(HAL, Error) << "Failed to allocate static metadata";
>  		return nullptr;
> @@ -1497,6 +1499,14 @@ std::unique_ptr<CameraMetadata> CameraDevice::getResultMetadata(int frame_number
>  	resultMetadata->addEntry(ANDROID_STATISTICS_SCENE_FLICKER,
>  				 &scene_flicker, 1);
>
> +	const uint32_t jpeg_size = 1 << 13;
> +	resultMetadata->addEntry(ANDROID_JPEG_SIZE,
> +				 &jpeg_size, 1);
> +
> +	const uint32_t jpeg_quality = 95;
> +	resultMetadata->addEntry(ANDROID_JPEG_QUALITY,
> +				 &jpeg_quality, 1);
> +
>  	/*
>  	 * Return the result metadata pack even is not valid: get() will return
>  	 * nullptr.
> --
> 2.25.1
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 7323d4e58f68..23dde1cfaf98 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -846,6 +846,8 @@  const camera_metadata_t *CameraDevice::getStaticMetadata()
 		ANDROID_SENSOR_EXPOSURE_TIME,
 		ANDROID_STATISTICS_LENS_SHADING_MAP_MODE,
 		ANDROID_STATISTICS_SCENE_FLICKER,
+		ANDROID_JPEG_SIZE,
+		ANDROID_JPEG_QUALITY,
 	};
 	staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS,
 				  availableResultKeys.data(),
@@ -1444,10 +1446,10 @@  std::unique_ptr<CameraMetadata> CameraDevice::getResultMetadata(int frame_number
 {
 	/*
 	 * \todo Keep this in sync with the actual number of entries.
-	 * Currently: 12 entries, 36 bytes
+	 * Currently: 17 entries, 58 bytes
 	 */
 	std::unique_ptr<CameraMetadata> resultMetadata =
-		std::make_unique<CameraMetadata>(15, 50);
+		std::make_unique<CameraMetadata>(17, 58);
 	if (!resultMetadata->isValid()) {
 		LOG(HAL, Error) << "Failed to allocate static metadata";
 		return nullptr;
@@ -1497,6 +1499,14 @@  std::unique_ptr<CameraMetadata> CameraDevice::getResultMetadata(int frame_number
 	resultMetadata->addEntry(ANDROID_STATISTICS_SCENE_FLICKER,
 				 &scene_flicker, 1);
 
+	const uint32_t jpeg_size = 1 << 13;
+	resultMetadata->addEntry(ANDROID_JPEG_SIZE,
+				 &jpeg_size, 1);
+
+	const uint32_t jpeg_quality = 95;
+	resultMetadata->addEntry(ANDROID_JPEG_QUALITY,
+				 &jpeg_quality, 1);
+
 	/*
 	 * Return the result metadata pack even is not valid: get() will return
 	 * nullptr.