Class YUVToRGBAConverter
- Namespace
- Uralstech.UXR.QuestCamera
The default YUV 4:2:0 to RGBA converter that uses a compute shader to convert the camera texture to RGBA.
public class YUVToRGBAConverter
- Inheritance
-
objectYUVToRGBAConverter
Constructors
YUVToRGBAConverter(Resolution)
public YUVToRGBAConverter(Resolution resolution)
Parameters
resolutionResolution
Fields
_kernelHandle
protected int _kernelHandle
Field Value
- int
_threadGroupsX
protected readonly int _threadGroupsX
Field Value
- int
_threadGroupsY
protected readonly int _threadGroupsY
Field Value
- int
_uComputeBuffer
Buffer containing U (color) data of the frame being processed.
protected readonly ComputeBuffer _uComputeBuffer
Field Value
- ComputeBuffer
_uvBufferSize
protected readonly int _uvBufferSize
Field Value
- int
_vComputeBuffer
Buffer containing V (color) data of the frame being processed.
protected readonly ComputeBuffer _vComputeBuffer
Field Value
- ComputeBuffer
_yBufferSize
protected readonly int _yBufferSize
Field Value
- int
_yComputeBuffer
Buffer containing Y (luminance) data of the frame being processed.
protected readonly ComputeBuffer _yComputeBuffer
Field Value
- ComputeBuffer
Properties
FrameCaptureTimestamp
The timestamp the last frame processed was captured at in nanoseconds.
public long FrameCaptureTimestamp { get; protected set; }
Property Value
- long
FrameRenderTexture
The RenderTexture which will contain the RGBA camera frames.
public RenderTexture FrameRenderTexture { get; protected set; }
Property Value
- RenderTexture
Shader
The shader used to convert YUV 4:2:0 to an RGBA RenderTexture. Uses YUVToRGBAComputeShader if not specified here.
public ComputeShader Shader { get; set; }
Property Value
- ComputeShader
Methods
Dispose()
Releases the frame RenderTexture and buffers.
public void Dispose()
~YUVToRGBAConverter()
protected ~YUVToRGBAConverter()
GetNextFrameAsync(CancellationToken)
Returns the next frame to be received by this processor.
public Task<(RenderTexture, long)> GetNextFrameAsync(CancellationToken token = default)
Parameters
tokenCancellationToken
Returns
- Task<(RenderTexture, long)>
The frame's RenderTexture and capture timestamp, in nanoseconds..
OnFrameReady(nint, long, nint, nint, long, int, int, int, long)
Processes a frame received from the native capture session.
public virtual void OnFrameReady(nint yBuffer, long yBufferSize, nint uBuffer, nint vBuffer, long uvBufferSize, int yRowStride, int uvRowStride, int uvPixelStride, long timestamp)
Parameters
yBuffernintThe pointer to this frame's Y (luminance) data.
yBufferSizelongThe size of the Y buffer in bytes.
uBuffernintThe pointer to this frame's U (color) data.
vBuffernintThe pointer to this frame's V (color) data.
uvBufferSizelongThe size of the U and V buffers in bytes.
yRowStrideintThe size of each row of the image in
yBufferin bytes.uvRowStrideintThe size of each row of the image in
uBufferandvBufferin bytes.uvPixelStrideintThe size of a pixel in a row of the image in
uBufferandvBufferin bytes.timestamplongThe timestamp the frame was captured at in nanoseconds.
PrepareDataForComputeBuffer(CPUDepthFrame, int, int, int, long)
Copies the given data into the shader's buffers and dispatches it.
protected virtual Task PrepareDataForComputeBuffer(YUVToRGBAConverter.CPUDepthFrame frame, int yRowStride, int uvRowStride, int uvPixelStride, long timestamp)
Parameters
frameYUVToRGBAConverter.CPUDepthFrameThe frame data on the CPU.
yRowStrideintThe size of each row of the image in _yComputeBuffer in bytes.
uvRowStrideintThe size of each row of the image in _uComputeBuffer and _vComputeBuffer in bytes.
uvPixelStrideintThe size of a pixel in a row of the image in _uComputeBuffer and _vComputeBuffer in bytes.
timestamplongThe timestamp the frame was captured at in nanoseconds.
Returns
- Task
Events
OnFrameProcessed
Called when a capture is dispatched for conversion to RGBA, with the capture's timestamp in nanoseconds.
public event Action<RenderTexture, long>? OnFrameProcessed
Event Type
- Action<RenderTexture, long>