Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/mediautils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ int media::bestFormat(const QList<Format> &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) &&
Expand Down
3 changes: 3 additions & 0 deletions tests/backend_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<media::Format> 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);
Comment on lines +44 to +46

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Slow-camera fallback lacks tests

The new test always includes formats that reach 15 fps, so it does not cover the new fallback: when every format is slower, pick the fastest before comparing size. A future change could restore size-first selection for slow cameras without failing this test. Add a case where a smaller, faster format wins, plus an equal-rate tie where the larger format wins.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

QCOMPARE(media::targetFps(15,15),15.0);
}
void clockExcludesPauses() {
Expand Down