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
qffmpeghwaccel_d3d11_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 QFFMPEGHWACCEL_D3D11_P_H
4#define QFFMPEGHWACCEL_D3D11_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/quniquehandle_p.h>
19#include <private/qcomptr_p.h>
20#include <qt_windows.h>
21
22#include <d3d11.h>
23#include <d3d11_1.h>
24
25#if QT_CONFIG(wmf)
26
28
29class QRhi;
30
31namespace QFFmpeg {
32
33struct SharedTextureHandleTraits
34{
35 using Type = HANDLE;
36 static Type invalidValue() { return nullptr; }
37 static bool close(Type handle) { return CloseHandle(handle) != 0; }
38};
39
40using SharedTextureHandle = QUniqueHandle<SharedTextureHandleTraits>;
41
51class TextureBridge final
52{
53public:
56 bool copyToSharedTex(ID3D11Device *dev, ID3D11DeviceContext *ctx,
57 const ComPtr<ID3D11Texture2D> &tex, UINT index, const QSize &frameSize);
58
60 ComPtr<ID3D11Texture2D> copyFromSharedTex(const ComPtr<ID3D11Device1> &dev,
61 const ComPtr<ID3D11DeviceContext> &ctx);
62
63private:
64 bool ensureDestTex(const ComPtr<ID3D11Device1> &dev);
65 bool ensureSrcTex(ID3D11Device *dev, const ComPtr<ID3D11Texture2D> &tex, const QSize &frameSize);
66 bool isSrcInitialized(const ID3D11Device *dev, const ComPtr<ID3D11Texture2D> &tex, const QSize &frameSize) const;
67 bool recreateSrc(ID3D11Device *dev, const ComPtr<ID3D11Texture2D> &tex, const QSize &frameSize);
68
69 SharedTextureHandle m_sharedHandle{};
70
71 const UINT m_srcKey = 0;
72 ComPtr<ID3D11Texture2D> m_srcTex;
73 ComPtr<IDXGIKeyedMutex> m_srcMutex;
74
75 const UINT m_destKey = 1;
76 ComPtr<ID3D11Device1> m_destDevice;
77 ComPtr<ID3D11Texture2D> m_destTex;
78 ComPtr<IDXGIKeyedMutex> m_destMutex;
79
80 ComPtr<ID3D11Texture2D> m_outputTex;
81};
82
83class D3D11TextureConverter : public TextureConverterBackend
84{
85public:
86 D3D11TextureConverter(QRhi *rhi);
87
88 TextureSet *getTextures(AVFrame *frame) override;
89
90 static void SetupDecoderTextures(AVCodecContext *s);
91
92private:
93 ComPtr<ID3D11Device1> m_rhiDevice;
94 ComPtr<ID3D11DeviceContext> m_rhiCtx;
95 TextureBridge m_bridge;
96};
97
98} // namespace QFFmpeg
99
101
102#endif
103
104#endif
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1804
\inmodule QtCore
Definition qsize.h:25
EGLContext ctx
Combined button and popup list for selecting options.
void * HANDLE
GLuint64 GLenum void * handle
GLuint index
[2]
GLdouble s
[6]
Definition qopenglext.h:235
static constexpr QSize frameSize(const T &frame)
QFrame frame
[0]
Definition moc.h:23