52 ? kCVPixelBufferLock_ReadOnly
57 mapData.nPlanes = CVPixelBufferGetPlaneCount(m_buffer);
62 mapData.bytesPerLine[0] = CVPixelBufferGetBytesPerRow(m_buffer);
63 mapData.data[0] =
static_cast<uchar*
>(CVPixelBufferGetBaseAddress(m_buffer));
64 mapData.size[0] = CVPixelBufferGetDataSize(m_buffer);
71 mapData.bytesPerLine[
i] = CVPixelBufferGetBytesPerRowOfPlane(m_buffer,
i);
72 mapData.size[
i] =
mapData.bytesPerLine[
i]*CVPixelBufferGetHeightOfPlane(m_buffer,
i);
73 mapData.data[
i] =
static_cast<uchar*
>(CVPixelBufferGetBaseAddressOfPlane(m_buffer,
i));
123 int bufferPlanes = CVPixelBufferGetPlaneCount(m_buffer);
125 if (plane > 0 && plane >= bufferPlanes)
130 if (!cvMetalTexture[plane]) {
131 size_t width = CVPixelBufferGetWidth(m_buffer);
132 size_t height = CVPixelBufferGetHeight(m_buffer);
138 if (!metalCache &&
sink->cvMetalTextureCache)
139 metalCache = CVMetalTextureCacheRef(CFRetain(
sink->cvMetalTextureCache));
141 qWarning(
"cannot create texture, Metal texture cache was released?");
144 auto ret = CVMetalTextureCacheCreateTextureFromImage(
151 &cvMetalTexture[plane]);
153 if (
ret != kCVReturnSuccess)
162 return cvMetalTexture[plane] ?
quint64(CVMetalTextureGetTexture(cvMetalTexture[plane])) : 0;
166 CVOpenGLTextureCacheFlush(
sink->cvOpenGLTextureCache, 0);
168 const CVReturn cvret = CVOpenGLTextureCacheCreateTextureFromImage(
170 sink->cvOpenGLTextureCache,
174 if (cvret != kCVReturnSuccess)
175 qWarning() <<
"OpenGL texture creation failed" << cvret;
179 return CVOpenGLTextureGetName(cvOpenGLTexture);
182 CVOpenGLESTextureCacheFlush(
sink->cvOpenGLESTextureCache, 0);
184 const CVReturn cvret = CVOpenGLESTextureCacheCreateTextureFromImage(
186 sink->cvOpenGLESTextureCache,
191 CVPixelBufferGetWidth(m_buffer),
192 CVPixelBufferGetHeight(m_buffer),
197 if (cvret != kCVReturnSuccess)
198 qWarning() <<
"OpenGL ES texture creation failed" << cvret;
201 return CVOpenGLESTextureGetName(cvOpenGLESTexture);
Format
Specifies the texture format.
const TextureDescription * textureDescription(QVideoFrameFormat::PixelFormat format)
QRhiTexture::Format textureFormat[maxPlanes]
int widthForPlane(int width, int plane) const
int heightForPlane(int height, int plane) const