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
qffmpeghwaccel_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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 QFFMPEGHWACCEL_P_H
4#define QFFMPEGHWACCEL_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/qffmpeg_p.h>
18#include <QtFFmpegMediaPluginImpl/private/qffmpegtextureconverter_p.h>
19#include <QtMultimedia/qvideoframeformat.h>
20#include <QtMultimedia/private/qhwvideobuffer_p.h>
21#include <QtMultimedia/private/qrhivaluemapper_p.h>
22#include <QtCore/qspan.h>
23
24#include <memory>
25#include <mutex>
26
27QT_BEGIN_NAMESPACE
28
29class QRhi;
30class QRhiTexture;
32
33namespace QFFmpeg {
34
35// used for the get_format callback for the decoder
36AVPixelFormat getFormat(AVCodecContext *s, const AVPixelFormat *fmt);
37
38class HWAccel;
39
40class HWAccel;
42
43/**
44 * @brief The HwFrameContextData class contains custom belongings
45 * of hw frames context.
46 */
48{
49 using AVHWFramesContextDeleter = void (*)(struct AVHWFramesContext *ctx);
50 AVHWFramesContextDeleter avDeleter = nullptr;
51 void *avUserOpaque = nullptr;
52
54
55 /**
56 * @brief gets or creates an instance of the class, associated with
57 * the frames context of the specified frame. Note, AVFrame
58 * holds shared ownership of the frames context, so consider this
59 * when designing HwFrameContextData's lifetime.
60 */
61 static HwFrameContextData &ensure(AVFrame &hwFrame);
62};
63
65{
66 const AVBufferUPtr m_hwDeviceContext;
67 AVBufferUPtr m_hwFramesContext;
68
69 mutable std::once_flag m_constraintsOnceFlag;
70 mutable AVHWFramesConstraintsUPtr m_constraints;
71
72public:
74
75 static HWAccelUPtr create(AVHWDeviceType deviceType);
76
77 static std::pair<std::optional<Codec>, HWAccelUPtr> findDecoderWithHwAccel(AVCodecID id);
78
80
81 AVBufferRef *hwDeviceContextAsBuffer() const { return m_hwDeviceContext.get(); }
83 AVPixelFormat hwFormat() const;
85
86 bool matchesSizeContraints(QSize size) const;
87
88 void createFramesContext(AVPixelFormat swFormat, const QSize &size);
89 void updateFramesContext(AVPixelFormat swFormat, const QSize &size);
90 AVBufferRef *hwFramesContextAsBuffer() const { return m_hwFramesContext.get(); }
91 AVHWFramesContext *hwFramesContext() const;
92
93 static AVPixelFormat format(AVFrame *frame);
96
97private:
98 HWAccel(AVBufferUPtr hwDeviceContext) : m_hwDeviceContext(std::move(hwDeviceContext)) { }
99};
100
101AVFrameUPtr copyFromHwPool(AVFrameUPtr frame);
102
103} // namespace QFFmpeg
104
105QT_END_NAMESPACE
106
107#endif
AVHWFramesContext * hwFramesContext() const
static QSpan< const AVHWDeviceType > encodingDeviceTypes()
bool matchesSizeContraints(QSize size) const
AVBufferRef * hwFramesContextAsBuffer() const
static QSpan< const AVHWDeviceType > decodingDeviceTypes()
void createFramesContext(AVPixelFormat swFormat, const QSize &size)
static AVPixelFormat format(AVFrame *frame)
AVBufferRef * hwDeviceContextAsBuffer() const
static HWAccelUPtr create(AVHWDeviceType deviceType)
const AVHWFramesConstraints * constraints() const
void updateFramesContext(AVPixelFormat swFormat, const QSize &size)
AVHWDeviceContext * hwDeviceContext() const
AVPixelFormat hwFormat() const
AVHWDeviceType deviceType() const
AVCodecCapabilities
Definition qffmpeg_p.h:315
AVFrameUPtr copyFromHwPool(AVFrameUPtr frame)
QT_MANGLE_NAMESPACE(QMacScreenCaptureStreamDelegate) QMacScreenCaptureStreamDelegate
AVPixelFormat getFormat(AVCodecContext *codecContext, const AVPixelFormat *fmt)
Definition qcompare.h:111
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)
The HwFrameContextData class contains custom belongings of hw frames context.
static HwFrameContextData & ensure(AVFrame &hwFrame)
gets or creates an instance of the class, associated with the frames context of the specified frame....
AVHWFramesContextDeleter avDeleter
QRhiValueMapper< TextureConverter > textureConverterMapper