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;
81 qWarning() <<
"Metal texture cache creation failed";
106 qWarning() <<
"OpenGL texture cache creation failed";
124 qWarning() <<
"OpenGLES texture cache creation failed";
146#if defined(Q_OS_MACOS)
148#elif defined(Q_OS_IOS)
157 case QRhiTexture::UnknownFormat:
158 return MTLPixelFormatInvalid;
159 case QRhiTexture::RGBA8:
160 return MTLPixelFormatRGBA8Unorm;
161 case QRhiTexture::BGRA8:
162 return MTLPixelFormatBGRA8Unorm;
163 case QRhiTexture::R8:
164 case QRhiTexture::RED_OR_ALPHA8:
165 return MTLPixelFormatR8Unorm;
166 case QRhiTexture::RG8:
167 return MTLPixelFormatRG8Unorm;
168 case QRhiTexture::R16:
169 return MTLPixelFormatR16Unorm;
170 case QRhiTexture::RG16:
171 return MTLPixelFormatRG16Unorm;
173 case QRhiTexture::RGBA16F:
174 return MTLPixelFormatRGBA16Float;
175 case QRhiTexture::RGBA32F:
176 return MTLPixelFormatRGBA32Float;
177 case QRhiTexture::R16F:
178 return MTLPixelFormatR16Float;
179 case QRhiTexture::R32F:
180 return MTLPixelFormatR32Float;
306VideoToolBoxTextureHandles::~VideoToolBoxTextureHandles()
310quint64 VideoToolBoxTextureHandles::textureHandle(QRhi &,
int plane)
312 if (rhi->backend() == QRhi::Metal)
313 return m_cvMetalTexture[plane] ? qint64(CVMetalTextureGetTexture(m_cvMetalTexture[plane])) : 0;
315 Q_ASSERT(plane == 0);
317 return CVOpenGLTextureGetName(m_cvOpenGLTexture);
320 return CVOpenGLESTextureGetName(m_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)