14 if (targetRate <= 0 || (sourceRate && qFuzzyCompare(*sourceRate, targetRate))) {
16 m_slotMatchEpsilon = 0;
20 m_slotDuration =
static_cast<qint64>(VideoFrameTimeBase / targetRate);
24 m_sourceDuration =
static_cast<qint64>(qRound(VideoFrameTimeBase / *sourceRate));
29 constexpr double JitterFraction = 0.01;
30 m_slotMatchEpsilon = qRound(
static_cast<
double>(*m_sourceDuration) * JitterFraction);
33 m_sourceDuration = std::nullopt;
36 m_slotMatchEpsilon = 1000;
42 std::vector<FrameInfo> result;
46 result.push_back({ frame, adjustTimeBase, std::nullopt });
50 const qint64 frameStart = frame.startTime();
53 if (frameStart == -1) {
54 result.push_back({ frame, adjustTimeBase, std::nullopt });
58 if (m_nextSlotTime < 0)
59 m_nextSlotTime = frameStart;
61 qint64 frameEnd = frame.endTime();
62 if (frameEnd == -1 && m_sourceDuration)
63 frameEnd = frameStart + *m_sourceDuration;
66 while (frameStart > m_nextSlotTime + m_slotMatchEpsilon)
67 result.push_back(emitPendingFrame());
69 m_pendingFrame = { frame, adjustTimeBase, m_nextSlotTime };
71 m_pendingNeedsFlush = !m_sourceDuration && frameEnd == -1;
74 Q_ASSERT(frameStart <= m_nextSlotTime + m_slotMatchEpsilon);
75 if (frameStart >= m_nextSlotTime)
76 result.push_back(emitPendingFrame());
79 if (frameEnd > frameStart) {
80 while (frameEnd > (m_nextSlotTime + m_slotMatchEpsilon))
81 result.push_back(emitPendingFrame());