[libcamera-devel,SimpleCam] simple-cam: Use new metadata API
diff mbox series

Message ID 20210909121447.3888276-1-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • [libcamera-devel,SimpleCam] simple-cam: Use new metadata API
Related show

Commit Message

Kieran Bingham Sept. 9, 2021, 12:14 p.m. UTC
In libcamera commit 32635054bc76 ("libcamera: framebuffer: Prevent
modifying the number of metadata planes"), the planes are returned as a
const span rather than a vector from the metadata.

This provides better protection on the underlying structures, but was a
break in the API.

Update simple-cam to use the new API.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 simple-cam.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jean-Michel Hautbois Sept. 9, 2021, 1:22 p.m. UTC | #1
Hi Kieran,

On 09/09/2021 14:14, Kieran Bingham wrote:
> In libcamera commit 32635054bc76 ("libcamera: framebuffer: Prevent
> modifying the number of metadata planes"), the planes are returned as a
> const span rather than a vector from the metadata.
> 
> This provides better protection on the underlying structures, but was a
> break in the API.
> 
> Update simple-cam to use the new API.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
> ---
>  simple-cam.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/simple-cam.cpp b/simple-cam.cpp
> index a8ac3c83ccb5..95e472b4377a 100644
> --- a/simple-cam.cpp
> +++ b/simple-cam.cpp
> @@ -58,10 +58,10 @@ static void processRequest(Request *request)
>  			  << " bytesused: ";
>  
>  		unsigned int nplane = 0;
> -		for (const FrameMetadata::Plane &plane : metadata.planes)
> +		for (const FrameMetadata::Plane &plane : metadata.planes())
>  		{
>  			std::cout << plane.bytesused;
> -			if (++nplane < metadata.planes.size())
> +			if (++nplane < metadata.planes().size())
>  				std::cout << "/";
>  		}
>  
>
Laurent Pinchart Sept. 9, 2021, 1:23 p.m. UTC | #2
Hi Kieran,

Thank you for the patch.

On Thu, Sep 09, 2021 at 01:14:47PM +0100, Kieran Bingham wrote:
> In libcamera commit 32635054bc76 ("libcamera: framebuffer: Prevent
> modifying the number of metadata planes"), the planes are returned as a
> const span rather than a vector from the metadata.
> 
> This provides better protection on the underlying structures, but was a
> break in the API.
> 
> Update simple-cam to use the new API.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  simple-cam.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/simple-cam.cpp b/simple-cam.cpp
> index a8ac3c83ccb5..95e472b4377a 100644
> --- a/simple-cam.cpp
> +++ b/simple-cam.cpp
> @@ -58,10 +58,10 @@ static void processRequest(Request *request)
>  			  << " bytesused: ";
>  
>  		unsigned int nplane = 0;
> -		for (const FrameMetadata::Plane &plane : metadata.planes)
> +		for (const FrameMetadata::Plane &plane : metadata.planes())
>  		{
>  			std::cout << plane.bytesused;
> -			if (++nplane < metadata.planes.size())
> +			if (++nplane < metadata.planes().size())
>  				std::cout << "/";

To quote one of your previous reviews, this can be confusing for
applications ;-)

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>  		}
>
Kieran Bingham Sept. 9, 2021, 1:28 p.m. UTC | #3
On 09/09/2021 14:23, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Thu, Sep 09, 2021 at 01:14:47PM +0100, Kieran Bingham wrote:
>> In libcamera commit 32635054bc76 ("libcamera: framebuffer: Prevent
>> modifying the number of metadata planes"), the planes are returned as a
>> const span rather than a vector from the metadata.
>>
>> This provides better protection on the underlying structures, but was a
>> break in the API.
>>
>> Update simple-cam to use the new API.
>>
>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>> ---
>>  simple-cam.cpp | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/simple-cam.cpp b/simple-cam.cpp
>> index a8ac3c83ccb5..95e472b4377a 100644
>> --- a/simple-cam.cpp
>> +++ b/simple-cam.cpp
>> @@ -58,10 +58,10 @@ static void processRequest(Request *request)
>>  			  << " bytesused: ";
>>  
>>  		unsigned int nplane = 0;
>> -		for (const FrameMetadata::Plane &plane : metadata.planes)
>> +		for (const FrameMetadata::Plane &plane : metadata.planes())
>>  		{
>>  			std::cout << plane.bytesused;
>> -			if (++nplane < metadata.planes.size())
>> +			if (++nplane < metadata.planes().size())
>>  				std::cout << "/";
> 
> To quote one of your previous reviews, this can be confusing for
> applications ;-)

Yes, I agree, And I've seen it when testing NV12 with the Vivid pipeline
handler.

But cam does the same thing as well, so I don't want to tackle that in
this patch.


> cam0: Capture 10 frames
> 581200.987851 (0.00 fps) cam0-stream0 seq: 000000 bytesused: 921600/460800
> 581201.187851 (5.00 fps) cam0-stream0 seq: 000001 bytesused: 921600/460800
> 581201.387851 (5.00 fps) cam0-stream0 seq: 000002 bytesused: 921600/460800




> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 

Thanks.


>>  		}
>>  
>

Patch
diff mbox series

diff --git a/simple-cam.cpp b/simple-cam.cpp
index a8ac3c83ccb5..95e472b4377a 100644
--- a/simple-cam.cpp
+++ b/simple-cam.cpp
@@ -58,10 +58,10 @@  static void processRequest(Request *request)
 			  << " bytesused: ";
 
 		unsigned int nplane = 0;
-		for (const FrameMetadata::Plane &plane : metadata.planes)
+		for (const FrameMetadata::Plane &plane : metadata.planes())
 		{
 			std::cout << plane.bytesused;
-			if (++nplane < metadata.planes.size())
+			if (++nplane < metadata.planes().size())
 				std::cout << "/";
 		}