0
我有两个YV12格式的图像缓冲区,需要将它们合并为一个并排图像。将两个YV12图像缓冲区合并为一个并排图像
(1920×1080)+(1920×1080)=(3840 * 1080)
YV12被分成3米单独的平面上。
YYYYYYYY VV UU
像素格式是每像素12位。
我创建了一个方法,memcpy
s一个缓冲区(1920x1080)到一个更大的缓冲区(3840x1080),但它不起作用。
这是我的C++。
BYTE* source = buffer;
BYTE* destination = convertBuffer3D;
// copy over the Y
for (int x = 0; x < height; x++)
{
memcpy(destination, source, width);
destination += width * 2;
source += width;
}
// copy over the V
for (int x = 0; x < (height/2); x++)
{
memcpy(destination, source, width/2);
destination += width;
source += width/2;
}
// copy over the U
for (int x = 0; x < (height/2); x++)
{
memcpy(destination, source, width/2);
destination += width;
source += width/2;
}
我预计:
相反,我得到这样的结果:
我缺少什么?
代码看起来约权。你可能错过了其他的东西(跨越任何一个图像被扩展?底部填充?)。 –
没有扩展我们的填充。我的1920x1080图像的总缓冲区大小是3110400(1920x1080x1.5),所以没有额外的数据。 –
另外我想如果它是NV12而不是YV12,也会有类似的效果。然后你需要在循环之后简单地检查源和目标。如果它们是正确的,那么问题不在于循环,而在于图像结构与您期望的不同。 –