Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qffmpegvideoframeencoder_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 QFFMPEGVIDEOFRAMEENCODER_P_H
4#define QFFMPEGVIDEOFRAMEENCODER_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 "qffmpeghwaccel_p.h"
18#include "private/qplatformmediarecorder_p.h"
19
21
23
24namespace QFFmpeg {
25
27{
28public:
29 static std::unique_ptr<VideoFrameEncoder> create(const QMediaEncoderSettings &encoderSettings,
30 const QSize &sourceSize,
31 QtVideo::Rotation sourceRotation,
32 qreal sourceFrameRate,
33 AVPixelFormat sourceFormat,
34 AVPixelFormat sourceSWFormat,
35 AVFormatContext *formatContext);
36
38
39 bool open();
40
41 AVPixelFormat sourceFormat() const { return m_sourceFormat; }
42 AVPixelFormat targetFormat() const { return m_targetFormat; }
43
44 qint64 getPts(qint64 ms) const;
45
46 const AVRational &getTimeBase() const;
47
50
51private:
52 VideoFrameEncoder() = default;
53
54 void updateConversions();
55
56 bool initCodec();
57
58 bool initTargetFormats();
59
60 bool initCodecContext(AVFormatContext *formatContext);
61
62private:
63 QMediaEncoderSettings m_settings;
64 QSize m_sourceSize;
66
67 std::unique_ptr<HWAccel> m_accel;
68 const AVCodec *m_codec = nullptr;
69 AVStream *m_stream = nullptr;
70 AVCodecContextUPtr m_codecContext;
71 std::unique_ptr<SwsContext, decltype(&sws_freeContext)> m_converter = { nullptr,
72 &sws_freeContext };
73 AVPixelFormat m_sourceFormat = AV_PIX_FMT_NONE;
74 AVPixelFormat m_sourceSWFormat = AV_PIX_FMT_NONE;
75 AVPixelFormat m_targetFormat = AV_PIX_FMT_NONE;
76 AVPixelFormat m_targetSWFormat = AV_PIX_FMT_NONE;
77 bool m_downloadFromHW = false;
78 bool m_uploadToHW = false;
79
80 AVRational m_codecFrameRate = { 0, 1 };
81
82 int64_t m_prevPacketDts = AV_NOPTS_VALUE;
83 int64_t m_packetDtsOffset = 0;
84};
85}
86
88
89#endif
const AVRational & getTimeBase() const
\inmodule QtCore
Definition qsize.h:25
std::unique_ptr< AVCodecContext, AVDeleter< decltype(&avcodec_free_context), &avcodec_free_context > > AVCodecContextUPtr
Definition qffmpeg_p.h:144
std::unique_ptr< AVFrame, AVDeleter< decltype(&av_frame_free), &av_frame_free > > AVFrameUPtr
Definition qffmpeg_p.h:134
std::unique_ptr< AVPacket, AVDeleter< decltype(&av_packet_free), &av_packet_free > > AVPacketUPtr
Definition qffmpeg_p.h:141
Combined button and popup list for selecting options.
long long qint64
Definition qtypes.h:60
double qreal
Definition qtypes.h:187
QFrame frame
[0]
view create()