怎么把kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange CVPixelBufferRef转换为纹理?

时间:2018-12-10 16:10:13

标签: ios opengl-es rgb video-processing yuv

我的像素缓冲区(CVPixelBufferRef)为kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange。我可以像这样将其转换为纹理:

if CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault, // allocator: The CFAllocator to use for allocating the texture object. This parameter can be NULL.
                                                fWebRTC.fvideoTextureCacheRef, // textureCache: The texture cache object that will manage the texture.
                                                aPixelBuffer, // sourceImage: The CVImageBuffer that you want to create a texture from.
                                                nil,  // textureAttributes: A CFDictionary containing the attributes to be used for creating the CVOpenGLESTexture objects. This parameter can be NULL.
                                                GL_TEXTURE_2D, // target: The target texture. GL_TEXTURE_2D and GL_RENDERBUFFER are the only targets currently supported.
                                                GL_LUMINANCE,  // internalFormat: The number of color components in the texture. Examples are GL_RGBA, GL_LUMINANCE, GL_RGBA8_OES, GL_RED, and GL_RG.
                                                aWidth, // width: The width of the texture image.
                                                aHeight, // height The height of the texture image.
                                                GL_LUMINANCE,  // format: The format of the pixel data. Examples are GL_RGBA and GL_LUMINANCE.
                                                GL_UNSIGNED_BYTE, // type: The data type of the pixel data. One example is GL_UNSIGNED_BYTE.
                                                0,  // planeIndex: The plane of the CVImageBuffer to map bind. Ignored for non-planar CVImageBuffers.
                                                @fWebRTC.fTextureRef) <> kCVReturnSuccess then begin // textureOut: A pointer to a CVOpenGLESTexture where the newly created texture object will be placed.

问题是使用GL_LUMINANCE时,纹理将以灰度打印:(那么如何将kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange CVPixelBufferRef转换为可以稍后以全彩绘制的纹理? / p>

0 个答案:

没有答案