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>
20#include <QtMultimedia/private/qhwvideobuffer_p.h>
21#include <QtMultimedia/private/qrhivaluemapper_p.h>
22
23#include <qshareddata.h>
24#include <memory>
25#include <functional>
26#include <mutex>
27
28QT_BEGIN_NAMESPACE
29
30class QRhi;
31class QRhiTexture;
33
34namespace QFFmpeg {
35
36// used for the get_format callback for the decoder
37AVPixelFormat getFormat(AVCodecContext *s, const AVPixelFormat *fmt);
38
39class HWAccel;
40
41class HWAccel;
43
44/**
45 * @brief The HwFrameContextData class contains custom belongings
46 * of hw frames context.
47 */
49{
51
52 /**
53 * @brief gets or creates an instance of the class, associated with
54 * the frames context of the specified frame. Note, AVFrame
55 * holds shared ownership of the frames context, so consider this
56 * when designing HwFrameContextData's lifetime.
57 */
58 static HwFrameContextData &ensure(AVFrame &hwFrame);
59};
60
62{
63 AVBufferUPtr m_hwDeviceContext;
64 AVBufferUPtr m_hwFramesContext;
65
66 mutable std::once_flag m_constraintsOnceFlag;
67 mutable AVHWFramesConstraintsUPtr m_constraints;
68
69public:
71
72 static HWAccelUPtr create(AVHWDeviceType deviceType);
73
75
77
78 AVBufferRef *hwDeviceContextAsBuffer() const { return m_hwDeviceContext.get(); }
80 AVPixelFormat hwFormat() const;
82
83 bool matchesSizeContraints(QSize size) const;
84
85 void createFramesContext(AVPixelFormat swFormat, const QSize &size);
86 AVBufferRef *hwFramesContextAsBuffer() const { return m_hwFramesContext.get(); }
88
89 static AVPixelFormat format(AVFrame *frame);
91
93
94private:
95 HWAccel(AVBufferUPtr hwDeviceContext) : m_hwDeviceContext(std::move(hwDeviceContext)) { }
96};
97
98AVFrameUPtr copyFromHwPool(AVFrameUPtr frame);
99
100} // namespace QFFmpeg
101
102QT_END_NAMESPACE
103
104#endif
AVHWFramesContext * hwFramesContext() const
bool matchesSizeContraints(QSize size) const
static const std::vector< AVHWDeviceType > & decodingDeviceTypes()
AVBufferRef * hwFramesContextAsBuffer() const
static const std::vector< AVHWDeviceType > & encodingDeviceTypes()
void createFramesContext(AVPixelFormat swFormat, const QSize &size)
static AVPixelFormat format(AVFrame *frame)
AVBufferRef * hwDeviceContextAsBuffer() const
static HWAccelUPtr create(AVHWDeviceType deviceType)
const AVHWFramesConstraints * constraints() const
AVHWDeviceContext * hwDeviceContext() const
AVPixelFormat hwFormat() const
static std::pair< std::optional< Codec >, HWAccelUPtr > findDecoderWithHwAccel(AVCodecID id)
AVHWDeviceType deviceType() const
AVPixelFormat getFormat(AVCodecContext *s, const AVPixelFormat *fmt)
AVFrameUPtr copyFromHwPool(AVFrameUPtr frame)
bool findAndOpenAVDecoder(AVCodecID codecId, const std::function< AVScore(const Codec &)> &scoresGetter, const std::function< bool(const Codec &)> &codecOpener)
std::conditional_t< QT_FFMPEG_AVIO_WRITE_CONST, const uint8_t *, uint8_t * > AvioWriteBufferType
std::optional< Codec > findAVEncoder(AVCodecID codecId, const std::optional< PixelOrSampleFormat > &format={})
bool findAndOpenAVEncoder(AVCodecID codecId, const std::function< AVScore(const Codec &)> &scoresGetter, const std::function< bool(const Codec &)> &codecOpener)
std::optional< Codec > findAVDecoder(AVCodecID codecId, const std::optional< PixelOrSampleFormat > &format={})
#define qCDebug(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)
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....
QRhiValueMapper< TextureConverter > textureConverterMapper