Message ID | 20220715135007.53574-3-jacopo@jmondi.org |
---|---|
State | Superseded, archived |
Headers | show |
Series |
|
Related | show |
Hi! > The PixelFormatInfo::info(const V4L2PixelFormat &format) function > returns the PixelFormatInfo associated with a V4L2 pixel format. > > As we prepare to associate multiple V4L2 formats to a single > PixelFormatInfo rework the function to search the given V4L2 format > in a list. > > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> > +++ b/src/libcamera/formats.cpp > @@ -994,10 +994,19 @@ const PixelFormatInfo &PixelFormatInfo::info(const PixelFormat &format) > */ > const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format) > { > + auto matchFormats = [&format](const std::vector<V4L2PixelFormat> &formats) { > + const auto &it = std::find_if(formats.begin(), formats.end(), > + [&format](const V4L2PixelFormat &fmt) { > + return format == fmt; > + }); > + > + return it == formats.end() ? false : true; I'd do it != formats.end() here. Best regards, Pavel
diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index f7e9adc7ff77..86fc698a0f4e 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -994,10 +994,19 @@ const PixelFormatInfo &PixelFormatInfo::info(const PixelFormat &format) */ const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format) { + auto matchFormats = [&format](const std::vector<V4L2PixelFormat> &formats) { + const auto &it = std::find_if(formats.begin(), formats.end(), + [&format](const V4L2PixelFormat &fmt) { + return format == fmt; + }); + + return it == formats.end() ? false : true; + }; + const auto &info = std::find_if(pixelFormatInfo.begin(), pixelFormatInfo.end(), - [format](auto pair) { - return pair.second.v4l2Formats.single[0] == format || - pair.second.v4l2Formats.multi[0] == format; + [&matchFormats](auto &pair) { + return matchFormats(pair.second.v4l2Formats.single) || + matchFormats(pair.second.v4l2Formats.multi); }); if (info == pixelFormatInfo.end()) return pixelFormatInfoInvalid;
The PixelFormatInfo::info(const V4L2PixelFormat &format) function returns the PixelFormatInfo associated with a V4L2 pixel format. As we prepare to associate multiple V4L2 formats to a single PixelFormatInfo rework the function to search the given V4L2 format in a list. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> --- src/libcamera/formats.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)