与kCVPixelFormatType_420YpCbCr8Planar一起使用时,CVOpenGLESTextureCacheCreateTextureFromImage返回-6683(kCVReturnPixelBufferNotOpenGLCompatible)

时间:2018-12-16 22:24:40

标签: ios objective-c opengl-es yuv glkit

我从网络回调(voip应用程序)以3个单独的数组获取原始YUV数据。我先做:

sourceComponent

然后

CVPixelBufferCreate(
  kCFAllocatorDefault,
  width,
  height,
  kCVPixelFormatType_420YpCbCr8Planar,
  nil,
  @aPixelBuffer);

但是稍后我尝试做

CVPixelBufferLockBaseAddress(aPixelBuffer, 0);
//-----
aDestPlane := CVPixelBufferGetBaseAddressOfPlane(aPixelBuffer, 0);
move(aRTCI420Buffer.dataY^, aDestPlane^, aRTCI420Buffer.width * aRTCI420Buffer.height);
//-----
aDestPlane := CVPixelBufferGetBaseAddressOfPlane(aPixelBuffer, 1);
move(aRTCI420Buffer.dataU^, aDestPlane^, (aRTCI420Buffer.chromaWidth) * (aRTCI420Buffer.chromaHeight));
//-----
aDestPlane := CVPixelBufferGetBaseAddressOfPlane(aPixelBuffer, 2);
move(aRTCI420Buffer.dataV^, aDestPlane^, (aRTCI420Buffer.chromaWidth) * (aRTCI420Buffer.chromaHeight));
//-----
CVPixelBufferUnlockBaseAddress(aPixelBuffer, 0);

它以CVOpenGLESTextureCacheCreateTextureFromImage( kCFAllocatorDefault, // allocator: The CFAllocator to use for allocating the texture object. This parameter can be NULL. 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_RED_EXT, // internalFormat: The number of color components in the texture. Examples are GL_RGBA, GL_LUMINANCE, GL_RGBA8_OES, GL_RED, and GL_RG. aLumaWidth, // width: The width of the texture image. aLumaHeight, // height The height of the texture image. GL_RED_EXT, // 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. @aTextureRefLuma); // textureOut: A pointer to a CVOpenGLESTexture where the newly created texture object will be placed. 失败。如果我将 kCVPixelFormatType_420YpCbCr8Planar 更改为 kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange ,则可以使用,但是我错过了颜色。知道为什么它会失败吗?

0 个答案:

没有答案