summaryrefslogtreecommitdiffstats
path: root/src
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 12:35:04 +0000
commit4f9b1a1173e936827a4bd2190f42f866ef4fdc6f (patch)
tree4c413ad541b18c7e932b9018dc71fa61a8b68842 /src
parenta25b5eafc1dbf047c9c9c6556cd45f8c21beea9d (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.6 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>
Diffstat (limited to 'src')
-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 423f47779..890a5b6bb 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);