• 周五. 3月 29th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

第1年8月1日 ios yuv pixelbuffer

admin

11月 28, 2021

1.

Y通道(Luminance)与 UV通道(Chrominance)分开填充数据,而且需要注意后者是UV交错排列的。在填充数据時还需要考虑到数据对齐的问题,当视频帧的宽高并不是某个对齐基数的倍数時(比如16),内部具体如何分配内存是不确定的,保险的做法就是逐行数据填充。这里我放上填充Chrominance通道数据的例子:

size_t bytesPerRowChrominance = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 1);

long chrominanceWidth = CVPixelBufferGetWidthOfPlane(pixelBuffer, 1);
long chrominanceHeight = CVPixelBufferGetHeightOfPlane(pixelBuffer, 1);

// Chrominance
uint8_t *uvDestPlane = (uint8_t *) CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 1);
memset(uvDestPlane, 0x80, chrominanceHeight * bytesPerRowChrominance);

for (int row = 0; row < chrominanceHeight; ++row) {
    memcpy(uvDestPlane + row * bytesPerRowChrominance,
            uvDataPtr + row * _outVideoWidth,
            _outVideoWidth);
}

free(uvDataPtr);


https://www.cnblogs.com/psklf/p/7700834.html

+ (CVPixelBufferRef) copyDataFromBuffer:(const unsigned char*)buffer toYUVPixelBufferWithWidth:(size_t)w Height:(size_t)h

http://blog.sina.com.cn/s/blog_6ea16f840102vuhy.html

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注