Add PixelFormat::NV12

This commit is contained in:
Wojtek Figat
2024-05-15 11:14:16 +02:00
parent 3ae30a59b3
commit 9d2dc91920
6 changed files with 18 additions and 2 deletions

View File

@@ -558,6 +558,11 @@ API_ENUM() enum class PixelFormat : uint32
/// </summary>
YUY2 = 108,
/// <summary>
/// Packed YUV 4:2:0 video texture format. Texture uses separate views to access the luma (Y) plane separately from the chroma (UV) planes. For luminance data view, the mapping to the view channel is Y->R8. For chrominance data view, the mapping to the view channel is U->R8 and V->G8.
/// </summary>
NV12 = 109,
/// <summary>
/// The maximum format value (for internal use only).
/// </summary>

View File

@@ -150,6 +150,8 @@ void PixelFormatExtensions::Init()
PixelFormat::BC4_UNorm,
};
InitFormat(formats8, 4);
sizeOfInBits[(int32)PixelFormat::NV12] = 12;
}
int32 PixelFormatExtensions::SizeInBits(PixelFormat format)
@@ -379,6 +381,7 @@ bool PixelFormatExtensions::IsVideo(const PixelFormat format)
switch (format)
{
case PixelFormat::YUY2:
case PixelFormat::NV12:
return true;
default:
return false;

View File

@@ -349,6 +349,10 @@ void RenderTools::ComputePitch(PixelFormat format, int32 width, int32 height, ui
rowPitch = ((width + 1) >> 1) * 4;
slicePitch = rowPitch * height;
break;
case PixelFormat::NV12:
rowPitch = width;
slicePitch = width * height * 3 / 2;
break;
default:
// Default byte alignment
rowPitch = (width * PixelFormatExtensions::SizeInBits(format) + 7) / 8;