[libcamera-devel] [PATCH v3 14/16] android: Populate streams and duration in the same loop

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Oct 13 03:43:47 CEST 2021


Hi Jacopo,

Thank you for the patch.

On Mon, Oct 11, 2021 at 05:11:52PM +0200, Jacopo Mondi wrote:
> The ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS and
> ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS static metadata are
> populated by looping on the streamConfigurations_ vector.
> 
> Unify them in a single loop to avoid repeating it.
> 
> Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>
> Reviewed-by: Umang Jain <umang.jain at ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
>  src/android/camera_capabilities.cpp | 22 +++++++++-------------
>  1 file changed, 9 insertions(+), 13 deletions(-)
> 
> diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp
> index e26c722ef4e5..2e9d1bcb3340 100644
> --- a/src/android/camera_capabilities.cpp
> +++ b/src/android/camera_capabilities.cpp
> @@ -1266,7 +1266,9 @@ int CameraCapabilities::initializeStaticMetadata()
>  				  maxZoom);
>  
>  	std::vector<uint32_t> availableStreamConfigurations;
> +	std::vector<int64_t> minFrameDurations;
>  	availableStreamConfigurations.reserve(streamConfigurations_.size() * 4);
> +	minFrameDurations.reserve(streamConfigurations_.size() * 4);
>  	for (const auto &entry : streamConfigurations_) {
>  		/*
>  		 * Filter out YUV streams not capable of running at 30 FPS.
> @@ -1285,12 +1287,19 @@ int CameraCapabilities::initializeStaticMetadata()
>  		if (entry.androidFormat != HAL_PIXEL_FORMAT_BLOB && fps < 30)
>  			continue;
>  
> +		/* Stream configuration map. */
>  		availableStreamConfigurations.push_back(entry.androidFormat);
>  		availableStreamConfigurations.push_back(entry.resolution.width);
>  		availableStreamConfigurations.push_back(entry.resolution.height);
>  		availableStreamConfigurations.push_back(
>  			ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT);
>  
> +		/* Per-stream durations. */
> +		minFrameDurations.push_back(entry.androidFormat);
> +		minFrameDurations.push_back(entry.resolution.width);
> +		minFrameDurations.push_back(entry.resolution.height);
> +		minFrameDurations.push_back(entry.minFrameDurationNsec);
> +
>  		LOG(HAL, Debug)
>  			<< "Output Stream: " << utils::hex(entry.androidFormat)
>  			<< " (" << entry.resolution.toString() << ")["
> @@ -1300,19 +1309,6 @@ int CameraCapabilities::initializeStaticMetadata()
>  	staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS,
>  				  availableStreamConfigurations);
>  

In the review of v2, I meant dropping the blank line right here, not the
one you've added just above this addEntry() call. It doesn't matter
much, please do what you like best.

> -	std::vector<int64_t> minFrameDurations;
> -	minFrameDurations.reserve(streamConfigurations_.size() * 4);
> -	for (const auto &entry : streamConfigurations_) {
> -		unsigned int fps = static_cast<unsigned int>
> -				   (floor(1e9 / entry.minFrameDurationNsec + 0.05f));
> -		if (entry.androidFormat != HAL_PIXEL_FORMAT_BLOB && fps < 30)
> -			continue;
> -
> -		minFrameDurations.push_back(entry.androidFormat);
> -		minFrameDurations.push_back(entry.resolution.width);
> -		minFrameDurations.push_back(entry.resolution.height);
> -		minFrameDurations.push_back(entry.minFrameDurationNsec);
> -	}
>  	staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS,
>  				  minFrameDurations);
>  

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list