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

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