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 sourceFormat,
31 AVPixelFormat sourceSWFormat, const Codec &codec,
32 const HWAccel *accel,
33 const AVPixelFormatSet &prohibitedFormats = {});
34
35AVScore findSWFormatScores(const Codec &codec, AVPixelFormat sourceSWFormat);
36
37/**
38 * @brief adjustFrameRate get a rational frame rate be requested qreal rate.
39 * If the codec supports fixed frame rate (non-null supportedRates),
40 * the function selects the most suitable one,
41 * otherwise just makes AVRational from qreal.
42 */
43AVRational adjustFrameRate(QSpan<const AVRational> supportedRates, qreal requestedRate);
44
45/**
46 * @brief adjustFrameTimeBase gets adjusted timebase by a list of supported frame rates
47 * and an already adjusted frame rate.
48 *
49 * Timebase is the fundamental unit of time (in seconds) in terms
50 * of which frame timestamps are represented.
51 * For fixed-fps content (non-null supportedRates),
52 * timebase should be 1/framerate.
53 *
54 * For more information, see AVStream::time_base and AVCodecContext::time_base.
55 *
56 * The adjusted time base is supposed to be set to stream and codec context.
57 */
58AVRational adjustFrameTimeBase(QSpan<const AVRational> supportedRates, AVRational frameRate);
59
60QSize adjustVideoResolution(const Codec &codec, QSize requestedResolution);
61
62int getScaleConversionType(const QSize &sourceSize, const QSize &targetSize);
63
64} // namespace QFFmpeg
65
66QT_END_NAMESPACE
67
68#endif // QFFMPEGVIDEOENCODERUTILS_P_H
69

source code of qtmultimedia/src/plugins/multimedia/ffmpeg/recordingengine/qffmpegvideoencoderutils_p.h