[libcamera-devel] [PATCH v2] android: camera_capabilities: Adjust minimum frame duration to match FPS

Jacopo Mondi jacopo at jmondi.org
Tue Apr 26 16:35:25 CEST 2022


Hi Han-Lin

On Tue, Apr 26, 2022 at 07:43:30PM +0800, Han-Lin Chen via libcamera-devel wrote:
> CTS calculates FPS with a rounding formula: See
> Camera2SurfaceViewTestCase.java:getSuitableFpsRangeForDuration()
>
> fps = floor(1e9 / minFrameDuration + 0.05f)
>
> The android adapter reports it as the AE target FPS. The patch adjusts the
> reported minimum frame duration to match the reported FPS.
>
> The requirement comes from ChromeOS which only allows the stream configuration
> with the minimum frame duration achieves the target FPS.
>
> Signed-off-by: Han-Lin Chen <hanlinchen at chromium.org>
> ---
>  src/android/camera_capabilities.cpp | 23 ++++++++++++++++++-----
>  1 file changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> index 55d651f3..5242055c 100644
> --- a/src/android/camera_capabilities.cpp
> +++ b/src/android/camera_capabilities.cpp
> @@ -687,6 +687,21 @@ int CameraCapabilities::initializeStreamConfigurations()
>  					minFrameDuration = minFrameDurationCap;
>  			}
>
> +			/*
> +			 * Calculate FPS as CTS does: see
> +			 * Camera2SurfaceViewTestCase.java:getSuitableFpsRangeForDuration()
> +			 */
> +			unsigned int fps =
> +				static_cast<unsigned int>(floor(1e9 / minFrameDuration + 0.05f));
> +
> +			/*
> +			 * Adjust the minimum frame duration to match the
> +			 * calculated FPS.The requirement comes from ChromeOS
                                         ^ space

> +			 * which only allows the stream configuration with the
> +			 * minimum frame duration achieves the target FPS.

To be honest I would drop the last phrase. We adjust the min frame
duration to match the just calculated fps, regardless of the platform
that requires it.

Anyway, can be adjusted when applying eventually

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

Thanks
  j

> +			 */
> +			minFrameDuration = 1e9 / fps;
> +
>  			streamConfigurations_.push_back({
>  				res, androidFormat, minFrameDuration, maxFrameDuration,
>  			});
> @@ -1287,12 +1302,10 @@ int CameraCapabilities::initializeStaticMetadata()
>  		 * recording profile. Inspecting the Intel IPU3 HAL
>  		 * implementation confirms this but no reference has been found
>  		 * in the metadata documentation.
> -		 *
> -		 * Calculate FPS as CTS does: see
> -		 * Camera2SurfaceViewTestCase.java:getSuitableFpsRangeForDuration()
>  		 */
> -		unsigned int fps = static_cast<unsigned int>
> -				   (floor(1e9 / entry.minFrameDurationNsec + 0.05f));
> +		unsigned int fps =
> +			static_cast<unsigned int>(floor(1e9 / entry.minFrameDurationNsec));
> +
>  		if (entry.androidFormat != HAL_PIXEL_FORMAT_BLOB && fps < 30)
>  			continue;
>
> --
> 2.36.0.rc2.479.g8af0fa9b8e-goog
>


More information about the libcamera-devel mailing list