diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-05 09:34:40 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-05 13:15:35 +0000 |
commit | 8daa96db2991c24c9102e736413f79241813b7df (patch) | |
tree | a0ad77ea3bd135b73be987d252f499dd95f6c4ea /src/plugins/directshow/common | |
parent | 8421bdc381c3c64b3733dda5aec9d422282989d4 (diff) |
DirectShow: Fix clang-tidy warnings about loops
- Replace by range-based for
Change-Id: Ie73bf5b6e1ebd90e4db653af0791ec88b68ed883
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/plugins/directshow/common')
-rw-r--r-- | src/plugins/directshow/common/directshowmediatype.cpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/plugins/directshow/common/directshowmediatype.cpp b/src/plugins/directshow/common/directshowmediatype.cpp index b2a514609..dc8e598f0 100644 --- a/src/plugins/directshow/common/directshowmediatype.cpp +++ b/src/plugins/directshow/common/directshowmediatype.cpp @@ -222,11 +222,10 @@ void DirectShowMediaType::clear(AM_MEDIA_TYPE &type) GUID DirectShowMediaType::convertPixelFormat(QVideoFrame::PixelFormat format) { - const int count = sizeof(qt_typeLookup) / sizeof(TypeLookup); - - for (int i = 0; i < count; ++i) - if (qt_typeLookup[i].pixelFormat == format) - return qt_typeLookup[i].mediaType; + for (const auto &lookupType : qt_typeLookup) { + if (lookupType.pixelFormat == format) + return lookupType.mediaType; + } return MEDIASUBTYPE_None; } @@ -236,16 +235,14 @@ QVideoSurfaceFormat DirectShowMediaType::videoFormatFromType(const AM_MEDIA_TYPE if (!type) return QVideoSurfaceFormat(); - const int count = sizeof(qt_typeLookup) / sizeof(TypeLookup); - - for (int i = 0; i < count; ++i) { - if (IsEqualGUID(qt_typeLookup[i].mediaType, type->subtype) && type->cbFormat > 0) { + for (const auto &lookupType : qt_typeLookup) { + if (IsEqualGUID(lookupType.mediaType, type->subtype) && type->cbFormat > 0) { if (IsEqualGUID(type->formattype, FORMAT_VideoInfo)) { VIDEOINFOHEADER *header = reinterpret_cast<VIDEOINFOHEADER *>(type->pbFormat); QVideoSurfaceFormat format( QSize(header->bmiHeader.biWidth, qAbs(header->bmiHeader.biHeight)), - qt_typeLookup[i].pixelFormat); + lookupType.pixelFormat); if (header->AvgTimePerFrame > 0) format.setFrameRate(10000 /header->AvgTimePerFrame); @@ -258,7 +255,7 @@ QVideoSurfaceFormat DirectShowMediaType::videoFormatFromType(const AM_MEDIA_TYPE QVideoSurfaceFormat format( QSize(header->bmiHeader.biWidth, qAbs(header->bmiHeader.biHeight)), - qt_typeLookup[i].pixelFormat); + lookupType.pixelFormat); if (header->AvgTimePerFrame > 0) format.setFrameRate(10000 / header->AvgTimePerFrame); @@ -277,12 +274,9 @@ QVideoFrame::PixelFormat DirectShowMediaType::pixelFormatFromType(const AM_MEDIA if (!type) return QVideoFrame::Format_Invalid; - const int count = sizeof(qt_typeLookup) / sizeof(TypeLookup); - - for (int i = 0; i < count; ++i) { - if (IsEqualGUID(qt_typeLookup[i].mediaType, type->subtype)) { - return qt_typeLookup[i].pixelFormat; - } + for (const auto &lookupType : qt_typeLookup) { + if (IsEqualGUID(lookupType.mediaType, type->subtype)) + return lookupType.pixelFormat; } return QVideoFrame::Format_Invalid; |