[vlc-commits] [Git][videolan/vlc][master] 2 commits: qt: properly set video resolution labels

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Jun 5 03:03:41 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
cbfc58e6 by Leon Vitanos at 2026-06-05T02:50:53+00:00
qt: properly set video resolution labels

- - - - -
4d01c57d by Leon Vitanos at 2026-06-05T02:50:53+00:00
qt: unify resolution and channel labels for ML items

- - - - -


4 changed files:

- modules/gui/qt/medialibrary/mlhelper.cpp
- modules/gui/qt/medialibrary/mlhelper.hpp
- modules/gui/qt/medialibrary/mlplaylistmedia.cpp
- modules/gui/qt/medialibrary/mlvideo.cpp


Changes:

=====================================
modules/gui/qt/medialibrary/mlhelper.cpp
=====================================
@@ -26,6 +26,34 @@ QString toValidLocalFile(const char *mrl)
     return url.isLocalFile() ? url.toLocalFile() : QString {};
 }
 
+QString channelNameFromNbChannels(unsigned nbChannels)
+{
+    if (nbChannels >= 8)
+        return QStringLiteral("7.1");
+    else if (nbChannels >= 6)
+        return QStringLiteral("5.1");
+    return {};
+}
+
+QString resolutionNameFromSize(unsigned maxWidth, unsigned maxHeight)
+{
+    if (maxWidth == 0 || maxHeight == 0)
+        return {};
+
+    const unsigned int realHeight = (maxHeight < maxWidth) ? maxHeight : maxWidth;
+    const unsigned int realWidth = (maxHeight < maxWidth) ? maxWidth : maxHeight;
+
+    if (realHeight >= 4320 || realWidth >= 4320.0 * (16.0 / 9.0))
+        return QStringLiteral("8K");
+    else if (realHeight >= 2160 || realWidth >= 2160.0 * (16.0 / 9.0))
+        return QStringLiteral("4K");
+    else if (realHeight >= 1080 || realWidth >= 1080.0 * (16.0 / 9.0))
+        return QStringLiteral("HD");
+    else if (realHeight >= 540 || realWidth >= 540.0 * (16.0 / 9.0))
+        return QStringLiteral("SD");
+    return {};
+}
+
 QString urlToDisplayString(const QUrl &url)
 {
     const QString displayString = url.toDisplayString(QUrl::RemovePassword | QUrl::PreferLocalFile | QUrl::NormalizePathSegments);


=====================================
modules/gui/qt/medialibrary/mlhelper.hpp
=====================================
@@ -76,6 +76,9 @@ MLListRange<T> ml_range_iterate(L& list)
 
 QString toValidLocalFile(const char *mrl);
 
+QString channelNameFromNbChannels(unsigned nbChannels);
+QString resolutionNameFromSize(unsigned maxWidth, unsigned maxHeight);
+
 template <typename T, typename O>
 void thumbnailCopy(const MLListRange<T> &list, O dst, const int max)
 {


=====================================
modules/gui/qt/medialibrary/mlplaylistmedia.cpp
=====================================
@@ -63,23 +63,8 @@ MLPlaylistMedia::MLPlaylistMedia(const vlc_ml_media_t * data)
         }
     }
 
-    if (nbChannels >= 8)
-        m_channel = "7.1";
-    else if (nbChannels >= 6)
-        m_channel = "5.1";
-    else
-        m_channel = "";
-
-    if (width >= 7680 && height >= 4320)
-        m_resolution = "8K";
-    else if (width >= 3840 && height >= 2160)
-        m_resolution = "4K";
-    else if (width >= 1440 && height >= 1080)
-        m_resolution = "HD";
-    else if (width >= 720 && height >= 1280)
-        m_resolution = "720p";
-    else
-        m_resolution = "";
+    m_channel = channelNameFromNbChannels(nbChannels);
+    m_resolution = resolutionNameFromSize(width, height);
 }
 
 //-------------------------------------------------------------------------------------------------


=====================================
modules/gui/qt/medialibrary/mlvideo.cpp
=====================================
@@ -109,21 +109,8 @@ MLVideo::MLVideo(const vlc_ml_media_t* data)
         }
     }
 
-    m_channel = "";
-    if ( numChannel >= 8 )
-        m_channel = "7.1";
-    else if ( numChannel >= 6 )
-        m_channel = "5.1";
-
-    m_resolution = "";
-    if ( maxWidth >= 7680 && maxHeight >= 4320 )
-        m_resolution = "8K";
-    else if ( maxWidth >= 3840 && maxHeight >= 2160 )
-        m_resolution = "4K";
-    else if ( maxWidth >= 1440 && maxHeight >= 1080 )
-        m_resolution = "HD";
-    else if ( maxWidth >= 720 && maxHeight >= 1280 )
-        m_resolution = "720p";
+    m_channel = channelNameFromNbChannels(numChannel);
+    m_resolution = resolutionNameFromSize(maxWidth, maxHeight);
 }
 
 bool MLVideo::isNew() const



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e65821678553077d4b11fe01b1c4e48f47432799...4d01c57d3254aff51c5258ded457981622b677f6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/e65821678553077d4b11fe01b1c4e48f47432799...4d01c57d3254aff51c5258ded457981622b677f6
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list