[v1,2/3] libcamera: virtual: Query number of planes correctly
diff mbox series

Message ID 20241211152542.1095857-2-pobrn@protonmail.com
State Superseded
Headers show
Series
  • [v1,1/3] libcamera: virtual: Avoid some copies
Related show

Commit Message

Barnabás Pőcze Dec. 11, 2024, 3:25 p.m. UTC
`PixelFormatInfo::planes.size()` always returns 3 since `planes` is
an array, but that is not the number of planes of the pixel format.
Use the `numPlanes()` getter instead.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
---
 src/libcamera/pipeline/virtual/virtual.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart Dec. 11, 2024, 4:47 p.m. UTC | #1
Hi Barnabás,

Thank you for the patch.

On Wed, Dec 11, 2024 at 03:25:50PM +0000, Barnabás Pőcze wrote:
> `PixelFormatInfo::planes.size()` always returns 3 since `planes` is
> an array, but that is not the number of planes of the pixel format.
> Use the `numPlanes()` getter instead.
> 
> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>

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

> ---
>  src/libcamera/pipeline/virtual/virtual.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp
> index 3126bdd7d..aae94efee 100644
> --- a/src/libcamera/pipeline/virtual/virtual.cpp
> +++ b/src/libcamera/pipeline/virtual/virtual.cpp
> @@ -278,7 +278,7 @@ int PipelineHandlerVirtual::exportFrameBuffers([[maybe_unused]] Camera *camera,
>  	const PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat);
>  
>  	std::vector<unsigned int> planeSizes;
> -	for (size_t i = 0; i < info.planes.size(); ++i)
> +	for (size_t i = 0; i < info.numPlanes(); ++i)
>  		planeSizes.push_back(info.planeSize(config.size, i));
>  
>  	return dmaBufAllocator_.exportBuffers(config.bufferCount, planeSizes, buffers);
Kieran Bingham Dec. 17, 2024, 4:08 p.m. UTC | #2
Quoting Barnabás Pőcze (2024-12-11 15:25:50)
> `PixelFormatInfo::planes.size()` always returns 3 since `planes` is
> an array, but that is not the number of planes of the pixel format.
> Use the `numPlanes()` getter instead.
> 
> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/libcamera/pipeline/virtual/virtual.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp
> index 3126bdd7d..aae94efee 100644
> --- a/src/libcamera/pipeline/virtual/virtual.cpp
> +++ b/src/libcamera/pipeline/virtual/virtual.cpp
> @@ -278,7 +278,7 @@ int PipelineHandlerVirtual::exportFrameBuffers([[maybe_unused]] Camera *camera,
>         const PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat);
>  
>         std::vector<unsigned int> planeSizes;
> -       for (size_t i = 0; i < info.planes.size(); ++i)
> +       for (size_t i = 0; i < info.numPlanes(); ++i)
>                 planeSizes.push_back(info.planeSize(config.size, i));
>  
>         return dmaBufAllocator_.exportBuffers(config.bufferCount, planeSizes, buffers);
> -- 
> 2.47.1
> 
>

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/virtual/virtual.cpp b/src/libcamera/pipeline/virtual/virtual.cpp
index 3126bdd7d..aae94efee 100644
--- a/src/libcamera/pipeline/virtual/virtual.cpp
+++ b/src/libcamera/pipeline/virtual/virtual.cpp
@@ -278,7 +278,7 @@  int PipelineHandlerVirtual::exportFrameBuffers([[maybe_unused]] Camera *camera,
 	const PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat);
 
 	std::vector<unsigned int> planeSizes;
-	for (size_t i = 0; i < info.planes.size(); ++i)
+	for (size_t i = 0; i < info.numPlanes(); ++i)
 		planeSizes.push_back(info.planeSize(config.size, i));
 
 	return dmaBufAllocator_.exportBuffers(config.bufferCount, planeSizes, buffers);