Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qffmpegvideoencoderutils_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 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 QFFMPEGVIDEOENCODERUTILS_P_H
4#define QFFMPEGVIDEOENCODERUTILS_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 <QtFFmpegMediaPluginImpl/private/qffmpegdefs_p.h>
18#include <QtFFmpegMediaPluginImpl/private/qffmpeghwaccel_p.h>
19
20#include <QtCore/qspan.h>
21
22QT_BEGIN_NAMESPACE
23
24namespace QFFmpeg {
25
26std::optional<AVPixelFormat> findTargetSWFormat(AVPixelFormat sourceSWFormat, const Codec &codec,
27 const HWAccel &accel,
28 const AVPixelFormatSet &prohibitedFormats = {});
29
30std::optional<AVPixelFormat> findTargetFormat(AVPixelFormat sourceSWFormat, const Codec &codec,
31 const HWAccel *accel,
32 const AVPixelFormatSet &prohibitedFormats = {});
33
34AVScore findSWFormatScores(const Codec &codec, AVPixelFormat sourceSWFormat);
35
36/**
37 * @brief adjustFrameRate resolves the effective frame rate to negotiate with a codec.
38 *
39 * settingsRate is the user-requested rate from QMediaEncoderSettings
40 * (<= 0 means unset). sourceRate is the source stream's fixed rate
41 * (<= 0 means variable/unknown).
42 *
43 * Target rate priority: settingsRate, if set, always wins. Otherwise sourceRate,
44 * if fixed, is used. Otherwise, if the codec cannot do variable rate
45 * (non-empty supportedRates), DefaultVideoFrameRate is used as a
46 * last-resort target. If the codec can do variable rate (empty
47 * supportedRates) and neither settingsRate nor sourceRate is set,
48 * the result stays variable ({0, 1}).
49 *
50 * If the codec supports only fixed frame rates (non-null
51 * supportedRates), the function selects the closest supported rate
52 * to the resolved preference; otherwise it converts the preference
53 * directly to an AVRational.
54 */
55AVRational adjustFrameRate(QSpan<const AVRational> supportedRates, qreal settingsRate,
56 qreal sourceRate);
57
58/**
59 * @brief adjustFrameTimeBase gets adjusted timebase by a list of supported frame rates
60 * and an already adjusted frame rate.
61 *
62 * Timebase is the fundamental unit of time (in seconds) in terms
63 * of which frame timestamps are represented.
64 * For fixed-fps content (non-null supportedRates, or isFixedRate true),
65 * timebase should be 1/framerate.
66 *
67 * For more information, see AVStream::time_base and AVCodecContext::time_base.
68 *
69 * The adjusted time base is supposed to be set to stream and codec context.
70 */
71AVRational adjustFrameTimeBase(QSpan<const AVRational> supportedRates, AVRational frameRate,
72 bool isFixedRate);
73
74QSize adjustVideoResolution(const Codec &codec, QSize requestedResolution);
75
76SwsFlags getScaleConversionType(const QSize &sourceSize, const QSize &targetSize);
77
78} // namespace QFFmpeg
79
80QT_END_NAMESPACE
81
82#endif // QFFMPEGVIDEOENCODERUTILS_P_H
std::optional< AVPixelFormat > findTargetFormat(AVPixelFormat sourceSWFormat, const Codec &codec, const HWAccel *accel, const AVPixelFormatSet &prohibitedFormats)
AVScore findSWFormatScores(const Codec &codec, AVPixelFormat sourceSWFormat)
SwsFlags getScaleConversionType(const QSize &sourceSize, const QSize &targetSize)
QSize adjustVideoResolution(const Codec &codec, QSize requestedResolution)
QT_MANGLE_NAMESPACE(QMacScreenCaptureStreamDelegate) QMacScreenCaptureStreamDelegate
AVRational adjustFrameRate(QSpan< const AVRational > supportedRates, qreal settingsRate, qreal sourceRate)
adjustFrameRate resolves the effective frame rate to negotiate with a codec.
AVRational adjustFrameTimeBase(QSpan< const AVRational > supportedRates, AVRational frameRate, bool isFixedRate)
adjustFrameTimeBase gets adjusted timebase by a list of supported frame rates and an already adjusted...
std::optional< AVPixelFormat > findTargetSWFormat(AVPixelFormat sourceSWFormat, const Codec &codec, const HWAccel &accel, const AVPixelFormatSet &prohibitedFormats)