CVPixelBufferGetWidth(pixelbuffer)和CVPixelBufferGetWidthOfPlane(pixelbuffer,0)有什么区别?

时间:2019-04-29 11:02:54

标签: ios swift yuv cvpixelbuffer

CVPixelBufferGetWidth(pixelbuffer)CVPixelBufferGetWidthOfPlane(pixelbuffer, 0)CVPixelBufferGetHeight(pixelbuffer)CVPixelBufferGetHeightOfPlane(pixelbuffer, 0)之间是否有任何区别。

我搜索Wiki,上面写着:

As with most Y′UV formats, there are as many Y′ values as there are pixels.

这并不是说y的值在所有格式下都等于图像宽度。

如果

CVPixelBufferGetWidth(pixelbuffer) == CVPixelBufferGetWidthOfPlane(pixelbuffer, 0)

CVPixelBufferGetHeight(pixelbuffer) == CVPixelBufferGetHeightOfPlane(pixelbuffer, 0)

1 个答案:

答案 0 :(得分:0)

并非所有像素缓冲区都是平面的(也就是说,与YUV缓冲区一样,包含多个数据平面)。在决定使用哪个函数查询宽度/高度之前,请先检查CVPixelBufferIsPlanar来确定您的功能是否存在。 (当然,如果您从始终是平面的源中获取缓冲区,则可以放心地跳过该检查。)

CVPixelBufferGetWidthOfPlane的文档请注意,传递非平面缓冲区时,它始终返回零。在这种情况下,(针对平面0的)返回值不应等于CVPixelBufferGetWidth的返回值。