Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qffmpegframerateadapter_p.h
Go to the documentation of this file.
1
// Copyright (C) 2026 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
#
ifndef
QFFMPEGFRAMERATEADAPTER_P_H
4
#
define
QFFMPEGFRAMERATEADAPTER_P_H
5
6
//
7
// W A R N I N G
8
// -------------
9
//
10
// This file is not part of the Qt API. It exists purely as an
11
// implementation detail. This header file may change from version to
12
// version without notice, or even be removed.
13
//
14
// We mean it.
15
//
16
17
#
include
<
QtMultimedia
/
qvideoframe
.
h
>
18
#
include
<
QtCore
/
qlist
.
h
>
19
#
include
<
QtFFmpegMediaPluginImpl
/
private
/
qffmpegrecordingengineutils_p
.
h
>
20
21
#
include
<
optional
>
22
23
QT_BEGIN_NAMESPACE
24
25
namespace
QFFmpeg
{
26
27
// Adapts an incoming video stream to a target frame rate by dropping (source faster)
28
// or duplicating (source slower) frames. Output PTS is slot-aligned and never adjusted
29
// backward relative to the encoded frame's capture time.
30
class
FrameRateAdapter
31
{
32
public
:
33
FrameRateAdapter
() =
default
;
34
35
void
setRates
(
std
::optional<
double
> sourceRate,
double
targetRate);
36
37
[[nodiscard]]
bool
isActive
()
const
{
return
m_slotDuration > 0; }
38
[[nodiscard]]
qint64
frameDuration
()
const
{
return
m_slotDuration; }
39
40
// Process one frame. Returns frames to be encoded.
41
// Returns an empty queue when the frame was buffered as a pending candidate
42
// (a later frame will trigger its emission with a forward-adjusted PTS).
43
// adjustTimeBase is stored alongside the pending frame and forwarded to
44
// the first output frame when the pending candidate is eventually emitted.
45
std
::
vector
<
FrameInfo
>
adapt
(
const
QVideoFrame &frame,
bool
adjustTimeBase =
false
);
46
47
std
::
optional
<
FrameInfo
>
flush
();
48
[[nodiscard]]
bool
hasPendingFlush
()
const
{
return
m_pendingNeedsFlush; }
49
50
// Clear all internal state (call on pause/seek).
51
void
reset
();
52
53
private
:
54
[[nodiscard]] FrameInfo emitPendingFrame(
bool
keepPending =
true
);
55
56
qint64 m_slotDuration{ 0 };
// µs per encoder frame; 0 = inactive
57
qint64 m_nextSlotTime{ -1 };
// next slot boundary in µs; -1 = uninitialized
58
qint64 m_slotMatchEpsilon{ 0 };
59
60
std::optional<FrameInfo> m_pendingFrame;
61
std::optional<qint64> m_sourceDuration{ 0 };
62
bool
m_pendingNeedsFlush{
false
};
63
};
64
65
}
// namespace QFFmpeg
66
67
QT_END_NAMESPACE
68
69
#
endif
QFFmpeg::FrameRateAdapter
Definition
qffmpegframerateadapter_p.h:31
QFFmpeg::FrameRateAdapter::reset
void reset()
Definition
qffmpegframerateadapter.cpp:96
QFFmpeg::FrameRateAdapter::flush
std::optional< FrameInfo > flush()
Definition
qffmpegframerateadapter.cpp:87
QFFmpeg::FrameRateAdapter::hasPendingFlush
bool hasPendingFlush() const
Definition
qffmpegframerateadapter_p.h:48
QFFmpeg::FrameRateAdapter::FrameRateAdapter
FrameRateAdapter()=default
QFFmpeg::FrameRateAdapter::setRates
void setRates(std::optional< double > sourceRate, double targetRate)
Definition
qffmpegframerateadapter.cpp:12
QFFmpeg::FrameRateAdapter::isActive
bool isActive() const
Definition
qffmpegframerateadapter_p.h:37
QFFmpeg::FrameRateAdapter::adapt
std::vector< FrameInfo > adapt(const QVideoFrame &frame, bool adjustTimeBase=false)
Definition
qffmpegframerateadapter.cpp:40
QFFmpeg::FrameRateAdapter::frameDuration
qint64 frameDuration() const
Definition
qffmpegframerateadapter_p.h:38
QFFmpeg
Definition
qandroidcacertificates.cpp:26
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qtmultimedia
src
plugins
multimedia
ffmpeg
recordingengine
qffmpegframerateadapter_p.h
Generated on
for Qt by
1.18.0