UPD: created in-place conversion [YUV 4:2:0 → RGB] but get an artefacts, kind of red ghosts of mine)
If someone knows a solution to fix it or some hints, would be great)
CODE:
if (BufferSize != DataSize)
{
delete[] Buffer;
BufferSize = DataSize;
Buffer = new uint8[BufferSize];
}
for (int32 i = 0; i < DataSize/4; i++)
{
double Y = static_cast<uint8>(Video.Data->GetYBuffer()[i]);
double U = static_cast<uint8>(Video.Data->GetUBuffer()[i / 4]);
double V = static_cast<uint8>(Video.Data->GetVBuffer()[i / 4]);
Y -= 16.0;
U -= 128.0;
V -= 128.0;
// R
Buffer[i*4] = FMath::Clamp(static_cast<int32>(Y * 1.0 + 1.140 * V), 0, 255);
// G
Buffer[i*4+1] = FMath::Clamp(static_cast<int32>(1.0 * Y - 0.395 * U - 0.581 * V), 0, 255);
// B
Buffer[i*4+2] = FMath::Clamp(static_cast<int32>(1.0 * Y + 2.032 * U), 0, 255);
}