[PATCH v2 1/2] libcamera: formats: Silence warning when creating a PixelFormatInfo from a null format
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Fri Feb 14 17:27:33 CET 2025
Hi Stefan,
Thank you for the patch.
On Fri, Feb 14, 2025 at 05:09:47PM +0100, Stefan Klug wrote:
> Calling PixelFormat().toString() correctly returns "0x0-<INVALID>" but it
> also produces the following, possibly confusing, warning:
>
> WARN Formats formats.cpp:1006 Unsupported pixel format 0x00000000
>
> Silence the warning in PixelFormatInfo::info() in case the format is
> invalid.
Sleeping over this made me wonder where/when you hit this warning. Is
there a valid use case to call this function with a default-constructed
pixel format ?
> Signed-off-by: Stefan Klug <stefan.klug at ideasonboard.com>
> Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> src/libcamera/formats.cpp | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
> index bfcdfc08960d..b4518e61d04a 100644
> --- a/src/libcamera/formats.cpp
> +++ b/src/libcamera/formats.cpp
> @@ -1001,6 +1001,9 @@ const std::map<PixelFormat, PixelFormatInfo> pixelFormatInfo{
> */
> const PixelFormatInfo &PixelFormatInfo::info(const PixelFormat &format)
> {
> + if (!format.isValid())
> + return pixelFormatInfoInvalid;
> +
> const auto iter = pixelFormatInfo.find(format);
> if (iter == pixelFormatInfo.end()) {
> LOG(Formats, Warning)
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list