namespace UnityEngine.XR.ARSubsystems
{
public partial struct XRCpuImage
{
///
/// Formats used by the raw data. See .
///
public enum Format
{
///
/// The format is unknown or could not be determined.
///
Unknown = 0,
///
/// Three-Plane YUV 420 format commonly used by Android. See
///
/// AIMAGE_FORMAT_YUV_420_888.
/// This format consists of three image planes. The first is the Y (luminocity) plane, with 8 bits per
/// pixel. The second and third are the U and V (chromaticity) planes, respectively. Each 2x2 block of pixels
/// share the same chromaticity value, so a given (x, y) pixel's chromaticity value is given by
///
/// u = UPlane[(y / 2) * rowStride + (x / 2) * pixelStride];
/// v = VPlane[(y / 2) * rowStride + (x / 2) * pixelStride];
///
///
AndroidYuv420_888 = 1,
///
/// Bi-Planar Component Y'CbCr 8-bit 4:2:0, full-range (luma=[0,255] chroma=[1,255]) commonly used by
/// iOS. See
///
/// kCVPixelFormatType_420YpCbCr8BiPlanarFullRange.
/// This format consists of two image planes. The first is the Y (luminosity) plane, with 8 bits per
/// pixel. The second plane is the UV (chromaticity) plane. The U and V chromaticity values are interleaved
/// (u0, v0, u1, v1, etc.). Each 2x2 block of pixels share the same chromaticity values, so a given (x, y)
/// pixel's chromaticity value is given by
///
/// u = UvPlane[(y / 2) * rowStride + (x / 2) * pixelStride];
/// v = UvPlane[(y / 2) * rowStride + (x / 2) * pixelStride + 1];
///
/// pixelStride is always 2 for this format, so this can be optimized to
///
/// u = UvPlane[(y >> 1) * rowStride + x & ~1];
/// v = UvPlane[(y >> 1) * rowStride + x | 1];
///
///
IosYpCbCr420_8BiPlanarFullRange = 2,
///
/// A single channel image format with 8 bits per pixel.
///
OneComponent8 = 3,
///
/// IEEE754-2008 binary32 float, describing the depth (distance to an object) in meters
///
DepthFloat32 = 4,
///
/// 16-bit unsigned integer, describing the depth (distance to an object) in millimeters.
///
DepthUint16 = 5,
}
}
///
/// Extensions to the enum.
///
public static class XRCpuImageFormatExtensions
{
///
/// Attempts to convert an to a `UnityEngine.TextureFormat`.
///
/// The being extended.
/// Returns a `TextureFormat` that matches if possible. Returns 0 if there
/// is no matching `TextureFormat`.
public static TextureFormat AsTextureFormat(this XRCpuImage.Format @this)
{
switch (@this)
{
case XRCpuImage.Format.OneComponent8: return TextureFormat.R8;
case XRCpuImage.Format.DepthFloat32: return TextureFormat.RFloat;
case XRCpuImage.Format.DepthUint16: return TextureFormat.RFloat;
default: return 0;
}
}
}
}