[libcamera-devel] libcamera: pipeline: simple: converter: Handle unsupported input format
diff mbox series

Message ID 20220715151607.1010433-1-xavier.roumegue@oss.nxp.com
State Accepted
Headers show
Series
  • [libcamera-devel] libcamera: pipeline: simple: converter: Handle unsupported input format
Related show

Commit Message

Xavier Roumegue July 15, 2022, 3:16 p.m. UTC
SimpleConverter::formats() should return an empty vector if the input
format is not supported by the converter.

Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
---
 src/libcamera/pipeline/simple/converter.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Laurent Pinchart July 20, 2022, 3:12 p.m. UTC | #1
Hi Xavier,

Thank you for the patch.

On Fri, Jul 15, 2022 at 05:16:07PM +0200, Xavier Roumegue via libcamera-devel wrote:
> SimpleConverter::formats() should return an empty vector if the input
> format is not supported by the converter.
> 
> Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>

Makes sense.

> ---
>  src/libcamera/pipeline/simple/converter.cpp | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp
> index 77c44fc8..19134edc 100644
> --- a/src/libcamera/pipeline/simple/converter.cpp
> +++ b/src/libcamera/pipeline/simple/converter.cpp
> @@ -220,6 +220,12 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)
>  		return {};
>  	}
>  
> +	if (v4l2Format.fourcc != V4L2PixelFormat::fromPixelFormat(input)) {
> +		LOG(SimplePipeline, Debug)
> +			<< "Input format " << input.toString() << " not supported.";

PixelFormat has an operator<<(), so you can write

		LOG(SimplePipeline, Debug)
			<< "Input format " << input << " not supported.";

With this,

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

No need for a v2, I'll make the change when applying.

> +		return {};
> +	}
> +
>  	std::vector<PixelFormat> pixelFormats;
>  
>  	for (const auto &format : m2m_->capture()->formats()) {
Umang Jain July 21, 2022, 6:04 p.m. UTC | #2
Hi,

Thank you for the patch,

On 7/15/22 20:46, Xavier Roumegue via libcamera-devel wrote:
> SimpleConverter::formats() should return an empty vector if the input
> format is not supported by the converter.
>
> Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>


With Laurent's suggestion applied,

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

> ---
>   src/libcamera/pipeline/simple/converter.cpp | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp
> index 77c44fc8..19134edc 100644
> --- a/src/libcamera/pipeline/simple/converter.cpp
> +++ b/src/libcamera/pipeline/simple/converter.cpp
> @@ -220,6 +220,12 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)
>   		return {};
>   	}
>   
> +	if (v4l2Format.fourcc != V4L2PixelFormat::fromPixelFormat(input)) {
> +		LOG(SimplePipeline, Debug)
> +			<< "Input format " << input.toString() << " not supported.";
> +		return {};
> +	}
> +
>   	std::vector<PixelFormat> pixelFormats;
>   
>   	for (const auto &format : m2m_->capture()->formats()) {

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp
index 77c44fc8..19134edc 100644
--- a/src/libcamera/pipeline/simple/converter.cpp
+++ b/src/libcamera/pipeline/simple/converter.cpp
@@ -220,6 +220,12 @@  std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)
 		return {};
 	}
 
+	if (v4l2Format.fourcc != V4L2PixelFormat::fromPixelFormat(input)) {
+		LOG(SimplePipeline, Debug)
+			<< "Input format " << input.toString() << " not supported.";
+		return {};
+	}
+
 	std::vector<PixelFormat> pixelFormats;
 
 	for (const auto &format : m2m_->capture()->formats()) {