4#include <QtFFmpegMediaPluginImpl/private/qffmpeghwaccel_videotoolbox_p.h>
6#if !defined(Q_OS_DARWIN)
7#error "Configuration error"
10#include <QtCore/qloggingcategory.h>
12#include <QtFFmpegMediaPluginImpl/private/qffmpegvideobuffer_p.h>
14#include <QtGui/qopenglcontext.h>
15#include <QtGui/rhi/qrhi.h>
17#include <QtMultimedia/private/qavfhelpers_p.h>
18#include <QtMultimedia/private/qvideotexturehelper_p.h>
19#include <QtMultimedia/qvideoframeformat.h>
21#include <CoreVideo/CVMetalTexture.h>
22#include <CoreVideo/CVMetalTextureCache.h>
25#import <AppKit/AppKit.h>
28#import <OpenGLES/EAGL.h>
30#import <Metal/Metal.h>
41class VideoToolBoxTextureHandles :
public QVideoFrameTexturesHandles
44 ~VideoToolBoxTextureHandles();
45 quint64 textureHandle(QRhi &,
int plane)
override;
47 TextureConverterBackendPtr parentConverterBackend;
50 CVMetalTextureRef cvMetalTexture[3] = {};
52#if defined(Q_OS_MACOS)
53 CVOpenGLTextureRef cvOpenGLTexture;
54#elif defined(Q_OS_IOS)
55 CVOpenGLESTextureRef cvOpenGLESTexture;
58 QAVFHelpers::QSharedCVPixelBuffer m_buffer;
79 qWarning() <<
"Metal texture cache creation failed";
98 qWarning() <<
"OpenGL texture cache creation failed";
110 qWarning() <<
"OpenGL texture cache creation failed";
128#if defined(Q_OS_MACOS)
130#elif defined(Q_OS_IOS)
139 case QRhiTexture::UnknownFormat:
140 return MTLPixelFormatInvalid;
141 case QRhiTexture::RGBA8:
142 return MTLPixelFormatRGBA8Unorm;
143 case QRhiTexture::BGRA8:
144 return MTLPixelFormatBGRA8Unorm;
145 case QRhiTexture::R8:
146 case QRhiTexture::RED_OR_ALPHA8:
147 return MTLPixelFormatR8Unorm;
148 case QRhiTexture::RG8:
149 return MTLPixelFormatRG8Unorm;
150 case QRhiTexture::R16:
151 return MTLPixelFormatR16Unorm;
152 case QRhiTexture::RG16:
153 return MTLPixelFormatRG16Unorm;
155 case QRhiTexture::RGBA16F:
156 return MTLPixelFormatRGBA16Float;
157 case QRhiTexture::RGBA32F:
158 return MTLPixelFormatRGBA32Float;
159 case QRhiTexture::R16F:
160 return MTLPixelFormatR16Float;
161 case QRhiTexture::R32F:
162 return MTLPixelFormatR32Float;
276VideoToolBoxTextureHandles::~VideoToolBoxTextureHandles()
280quint64 VideoToolBoxTextureHandles::textureHandle(QRhi &,
int plane)
282 if (rhi->backend() == QRhi::Metal)
283 return cvMetalTexture[plane] ? qint64(CVMetalTextureGetTexture(cvMetalTexture[plane])) : 0;
285 Q_ASSERT(plane == 0);
287 return CVOpenGLTextureGetName(cvOpenGLTexture);
290 return CVOpenGLESTextureGetName(cvOpenGLESTexture);
static MTLPixelFormat rhiTextureFormatToMetalFormat(QRhiTexture::Format f)
std::conditional_t< QT_FFMPEG_AVIO_WRITE_CONST, const uint8_t *, uint8_t * > AvioWriteBufferType
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)