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;
151#if defined(Q_OS_MACOS)
153#elif defined(Q_OS_IOS)
162 case QRhiTexture::UnknownFormat:
163 return MTLPixelFormatInvalid;
164 case QRhiTexture::RGBA8:
165 return MTLPixelFormatRGBA8Unorm;
166 case QRhiTexture::BGRA8:
167 return MTLPixelFormatBGRA8Unorm;
168 case QRhiTexture::R8:
169 case QRhiTexture::RED_OR_ALPHA8:
170 return MTLPixelFormatR8Unorm;
171 case QRhiTexture::RG8:
172 return MTLPixelFormatRG8Unorm;
173 case QRhiTexture::R16:
174 return MTLPixelFormatR16Unorm;
175 case QRhiTexture::RG16:
176 return MTLPixelFormatRG16Unorm;
178 case QRhiTexture::RGBA16F:
179 return MTLPixelFormatRGBA16Float;
180 case QRhiTexture::RGBA32F:
181 return MTLPixelFormatRGBA32Float;
182 case QRhiTexture::R16F:
183 return MTLPixelFormatR16Float;
184 case QRhiTexture::R32F:
185 return MTLPixelFormatR32Float;
309VideoToolBoxTextureHandles::~VideoToolBoxTextureHandles()
313quint64 VideoToolBoxTextureHandles::textureHandle(QRhi &,
int plane)
315 if (rhi->backend() == QRhi::Metal)
316 return m_cvMetalTexture[plane] ? qint64(CVMetalTextureGetTexture(m_cvMetalTexture[plane])) : 0;
318 Q_ASSERT(plane == 0);
320 return CVOpenGLTextureGetName(m_cvOpenGLTexture);
323 return CVOpenGLESTextureGetName(m_cvOpenGLESTexture);
static MTLPixelFormat rhiTextureFormatToMetalFormat(QRhiTexture::Format f)
QT_BEGIN_NAMESPACE Q_STATIC_LOGGING_CATEGORY(lcSynthesizedIterableAccess, "qt.iterable.synthesized", QtWarningMsg)