Message ID | 20200708134417.67747-14-paul.elder@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
On Wed, Jul 08, 2020 at 10:44:09PM +0900, Paul Elder wrote: > Unsupported formats should not be added to the configuration when > generating the configuration. Filter them out. > > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > --- > Cosmetic change in v4 > > No change in v3 > --- > src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 13 +++++-------- > 1 file changed, 5 insertions(+), 8 deletions(-) > > diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp > index 80a0e77..9db69dd 100644 > --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp > +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp > @@ -161,14 +161,11 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera, > std::map<V4L2PixelFormat, std::vector<SizeRange>> v4l2Formats = > data->video_->formats(); > std::map<PixelFormat, std::vector<SizeRange>> deviceFormats; > - std::transform(v4l2Formats.begin(), v4l2Formats.end(), > - std::inserter(deviceFormats, deviceFormats.begin()), > - [&](const decltype(v4l2Formats)::value_type &format) { > - return decltype(deviceFormats)::value_type{ > - format.first.toPixelFormat(), > - format.second > - }; > - }); > + for (const auto &format : v4l2Formats) { > + PixelFormat pixelFormat = format.first.toPixelFormat(); > + if (pixelFormat.isValid()) > + deviceFormats[pixelFormat] = format.second; > + } I'm not able to get to like std::transform and friends, so I'm happy to see it being replaced with a more readable loop here and in the previous one Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Thanks j > > StreamFormats formats(deviceFormats); > StreamConfiguration cfg(formats); > -- > 2.27.0 > > _______________________________________________ > libcamera-devel mailing list > libcamera-devel@lists.libcamera.org > https://lists.libcamera.org/listinfo/libcamera-devel
diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 80a0e77..9db69dd 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -161,14 +161,11 @@ CameraConfiguration *PipelineHandlerUVC::generateConfiguration(Camera *camera, std::map<V4L2PixelFormat, std::vector<SizeRange>> v4l2Formats = data->video_->formats(); std::map<PixelFormat, std::vector<SizeRange>> deviceFormats; - std::transform(v4l2Formats.begin(), v4l2Formats.end(), - std::inserter(deviceFormats, deviceFormats.begin()), - [&](const decltype(v4l2Formats)::value_type &format) { - return decltype(deviceFormats)::value_type{ - format.first.toPixelFormat(), - format.second - }; - }); + for (const auto &format : v4l2Formats) { + PixelFormat pixelFormat = format.first.toPixelFormat(); + if (pixelFormat.isValid()) + deviceFormats[pixelFormat] = format.second; + } StreamFormats formats(deviceFormats); StreamConfiguration cfg(formats);