[PATCH v2 1/2] libcamera: formats: Silence warning when creating a PixelFormatInfo from a null format
Stefan Klug
stefan.klug at ideasonboard.com
Fri Feb 14 17:42:16 CET 2025
Hi Laurent,
On Fri, Feb 14, 2025 at 06:27:33PM +0200, Laurent Pinchart wrote:
> 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 ?
At least I can explain where it happens. Let's see if that is valid...
The V4L2M2MStream has a logPrefix() function which calls
stream_->configuration().toString(). So when you log something early in
the lifetime of the converter (even if it is a debug message that
doesn't show up) that warning shows up. I was puzzled by this until I
realized it is just normal flow. And I see no better way to solve it.
Best regards,
Stefan
>
> > 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