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

Kieran Bingham kieran.bingham at ideasonboard.com
Wed Apr 27 16:26:06 CEST 2022


Quoting Han-Lin Chen via libcamera-devel (2022-04-26 12:43:30)
> 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
> +                        * which only allows the stream configuration with the
> +                        * minimum frame duration achieves the target FPS.

This doesn't quite make sense, (perhaps it was supposed to be 'with the
minimum frame duration which achieves the target FPS') but I think Jacopo
said it may be dropped in his review so I won't worry too much about it.


> +                        */
> +                       minFrameDuration = 1e9 / fps;


Can this calculation be simplified so that we operate only on the
minFrameDuration, and not calculate the FPS from the minFrameDuration,
only to then convert the FPS back to a minFrameDuration?


> +
>                         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