第1年8月1日 ios yuv pixelbuffer
阿新 • • 發佈:2021-08-01
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