summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Belyavsky <belyavskyv@gmail.com>2023-11-22 17:43:09 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-01-22 19:02:06 +0000
commitbb5bd27ce1011753d43bff68a6e7ee2e98bf3a37 (patch)
tree9ca1aa7efee4b5a4acacbd18d924a45c70905c18
parentfd893ee8d3b1a0f4721b5b98c0de219f19e4db2c (diff)
EVRCustomPresenter: skip samples that came too late
In some cases, the mixer may produce output samples that are already stale, i.e. their presentation + duration extends beyond the current clock time. This occurs when the video file's native sample rate exceeds the actual video frame rendering rate. This is especially true when HW acceleration is not used, so we spent more time presenting each video frame. The current implementation simply schedules _all_ video samples for presentation, which can lead to problems when the video plays at a slower speed and reaches the end later than expected. So, to solve this, just check if the sample time is already passed, and if yes - discard, i.e. return it to the pool immediately. Fixes: QTBUG-118587 Pick-to: 6.5 Change-Id: I449e4ea7ef7b74a843e12ce7f488bc10c5087f76 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> (cherry picked from commit ecf836403022d766b4c38b9f413d551939cfb059) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 4f9b1a1173e936827a4bd2190f42f866ef4fdc6f)
-rw-r--r--src/plugins/multimedia/windows/evr/evrcustompresenter.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/plugins/multimedia/windows/evr/evrcustompresenter.cpp b/src/plugins/multimedia/windows/evr/evrcustompresenter.cpp
index a98ca703b..1cb381c5c 100644
--- a/src/plugins/multimedia/windows/evr/evrcustompresenter.cpp
+++ b/src/plugins/multimedia/windows/evr/evrcustompresenter.cpp
@@ -216,6 +216,11 @@ HRESULT Scheduler::scheduleSample(const ComPtr<IMFSample> &sample, bool presentN
if (presentNow || !m_clock) {
m_presenter->presentSample(sample);
} else {
+ if (m_playbackRate > 0.0f && qt_evr_isSampleTimePassed(m_clock.Get(), sample.Get())) {
+ qCDebug(qLcEvrCustomPresenter) << "Discard the sample, it came too late";
+ return hr;
+ }
+
// Queue the sample and ask the scheduler thread to wake up.
m_mutex.lock();
m_scheduledSamples.enqueue(sample);