diff --git a/src/mediautils.cpp b/src/mediautils.cpp index 190212f..33b882c 100644 --- a/src/mediautils.cpp +++ b/src/mediautils.cpp @@ -21,6 +21,11 @@ int media::bestFormat(const QList &formats) { const qint64 area = qint64(f.size.width()) * f.size.height(); const qint64 bestArea = qint64(b.size.width()) * b.size.height(); const double rate = targetFps(f.minFps, f.maxFps), bestRate = targetFps(b.minFps, b.maxFps); + // Largest resolution wins, but only among formats that sustain a usable + // frame rate: uncompressed modes at sensor maximum often run at 2 fps. + constexpr double usableFps = 15; + const double usable = std::min(rate, usableFps), bestUsable = std::min(bestRate, usableFps); + if (usable != bestUsable) { if (usable > bestUsable) best = i; continue; } if (area > bestArea || (area == bestArea && (std::abs(rate - 30) < std::abs(bestRate - 30) || (std::abs(rate - 30) == std::abs(bestRate - 30) && diff --git a/tests/backend_tests.cpp b/tests/backend_tests.cpp index 19745fe..e3cef2a 100644 --- a/tests/backend_tests.cpp +++ b/tests/backend_tests.cpp @@ -41,6 +41,9 @@ private slots: f.append({{3840,2160},30,30,0}); QCOMPARE(media::bestFormat(f),3); f.append({{3840,2160},30,60,0}); QCOMPARE(media::bestFormat(f),3); QCOMPARE(media::bestFormat({}),-1); + // Logitech C925e: YUYV at sensor maximum only manages 2 fps. + QList c{{{2304,1536},2,2,1}, {{1920,1080},5,30,2}, {{1920,1080},5,5,1}, {{640,480},5,30,1}}; + QCOMPARE(media::bestFormat(c),1); QCOMPARE(media::targetFps(15,15),15.0); } void clockExcludesPauses() {