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 QCFType<CVMetalTextureRef> m_cvMetalTexture[3] = {};
52#if defined(Q_OS_MACOS)
53 QCFType<CVOpenGLTextureRef> m_cvOpenGLTexture;
54#elif defined(Q_OS_IOS)
55 QCFType<CVOpenGLESTextureRef> m_cvOpenGLESTexture;
58 QAVFHelpers::QSharedCVPixelBuffer m_buffer;
152#if defined(Q_OS_MACOS)
154#elif defined(Q_OS_IOS)
163 case QRhiTexture::UnknownFormat:
164 return MTLPixelFormatInvalid;
165 case QRhiTexture::RGBA8:
166 return MTLPixelFormatRGBA8Unorm;
167 case QRhiTexture::BGRA8:
168 return MTLPixelFormatBGRA8Unorm;
169 case QRhiTexture::R8:
170 case QRhiTexture::RED_OR_ALPHA8:
171 return MTLPixelFormatR8Unorm;
172 case QRhiTexture::RG8:
173 return MTLPixelFormatRG8Unorm;
174 case QRhiTexture::R16:
175 return MTLPixelFormatR16Unorm;
176 case QRhiTexture::RG16:
177 return MTLPixelFormatRG16Unorm;
179 case QRhiTexture::RGBA16F:
180 return MTLPixelFormatRGBA16Float;
181 case QRhiTexture::RGBA32F:
182 return MTLPixelFormatRGBA32Float;
183 case QRhiTexture::R16F:
184 return MTLPixelFormatR16Float;
185 case QRhiTexture::R32F:
186 return MTLPixelFormatR32Float;
310VideoToolBoxTextureHandles::~VideoToolBoxTextureHandles()
314quint64 VideoToolBoxTextureHandles::textureHandle(QRhi &,
int plane)
316 if (rhi->backend() == QRhi::Metal)
317 return m_cvMetalTexture[plane] ? qint64(CVMetalTextureGetTexture(m_cvMetalTexture[plane])) : 0;
319 Q_ASSERT(plane == 0);
321 return CVOpenGLTextureGetName(m_cvOpenGLTexture);
324 return CVOpenGLESTextureGetName(m_cvOpenGLESTexture);
static MTLPixelFormat rhiTextureFormatToMetalFormat(QRhiTexture::Format f)
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)