Loading...
Searching...
No Matches

Cross-backend RGBA -> v210 encoder. More...

Inheritance diagram for score::gfx::V210Encoder:
score::gfx::GPUVideoEncoder

Detailed Description

Cross-backend RGBA -> v210 encoder.

v210 packs 6 source pixels into 4 little-endian 32-bit words (16 bytes): word 0: Cb01 (10b) | Y0 (10b) | Cr01 (10b) | 2b pad word 1: Y1 (10b) | Cb23 (10b) | Y2 (10b) | 2b pad word 2: Cr23 (10b) | Y3 (10b) | Cb45 (10b) | 2b pad word 3: Y4 (10b) | Cr45 (10b) | Y5 (10b) | 2b pad (4:2:2 chroma subsampling - chroma averaged across adjacent pairs.)

Output: RGBA8 texture sized (width/6 * 4) x height. Each output texel is one v210 ULWord, with its 4 bytes laid out as R, G, B, A (= bytes 0..3 of the ULWord on little-endian hosts). The readback bytes are therefore in exact v210 line order and can be DMA'd to the AJA card directly (modulo row-stride padding handled outside this encoder).

Source width must be a multiple of 6. For non-multiples use UYVYEncoder

  • CPU v210 packing instead, or pad the input texture.

Single render pass, single readback. Same Y-flip convention as the other encoders (Metal/HLSL no flip, GLSL/SPIRV flip).

Public Member Functions

void init (QRhi &rhi, const RenderState &state, QRhiTexture *inputRGBA, int width, int height, const QString &colorConversion=colorMatrixOut()) override
 
void exec (QRhi &rhi, QRhiCommandBuffer &cb) override
 
int planeCount () const override
 Number of readback planes (1 for UYVY, 2 for NV12, 3 for I420).
 
const QRhiReadbackResult & readback (int) const override
 Get the readback result for a given plane. Valid after endOffscreenFrame.
 
void release () override
 Release all GPU resources.
 

Public Attributes

QRhiTexture * m_outTexture {}
 
QRhiTextureRenderTarget * m_renderTarget {}
 
QRhiRenderPassDescriptor * m_rpDesc {}
 
QRhiSampler * m_sampler {}
 
QRhiShaderResourceBindings * m_srb {}
 
QRhiGraphicsPipeline * m_pipeline {}
 
QRhiReadbackResult m_readback {}
 
int m_width {}
 
int m_height {}
 
int m_outW {}
 

Static Public Attributes

static constexpr const char * frag
 
- Static Public Attributes inherited from score::gfx::GPUVideoEncoder
static constexpr const char * vertex_shader
 
static constexpr const char * rgb_to_yuv_glsl
 
static constexpr const char * y_flip_glsl
 Fragment shader Y-flip: on GL, flip v_texcoord.y. On Metal/HLSL, no flip.
 

Member Function Documentation

◆ exec()

void score::gfx::V210Encoder::exec ( QRhi &  rhi,
QRhiCommandBuffer &  cb 
)
inlineoverridevirtual

Execute the conversion pass. Call inside beginOffscreenFrame/endOffscreenFrame. Renders the conversion shader and schedules GPU->CPU readback(s).

Implements score::gfx::GPUVideoEncoder.

◆ init()

void score::gfx::V210Encoder::init ( QRhi &  rhi,
const RenderState state,
QRhiTexture *  inputRGBA,
int  width,
int  height,
const QString &  colorConversion = colorMatrixOut() 
)
inlineoverridevirtual

Create render targets, textures, samplers, and the graphics pipeline.

Parameters
rhiThe QRhi instance.
stateThe render state (for shader compilation).
inputRGBAThe scene RGBA texture to read from.
widthSource width in pixels.
heightSource height in pixels.
colorConversionGLSL code from colorMatrixOut() defining convert_from_rgb(). If empty, defaults to BT.709 full range.

Implements score::gfx::GPUVideoEncoder.

◆ planeCount()

int score::gfx::V210Encoder::planeCount ( ) const
inlineoverridevirtual

Number of readback planes (1 for UYVY, 2 for NV12, 3 for I420).

Implements score::gfx::GPUVideoEncoder.

◆ readback()

const QRhiReadbackResult & score::gfx::V210Encoder::readback ( int  plane) const
inlineoverridevirtual

Get the readback result for a given plane. Valid after endOffscreenFrame.

Implements score::gfx::GPUVideoEncoder.

◆ release()

void score::gfx::V210Encoder::release ( )
inlineoverridevirtual

Release all GPU resources.

Implements score::gfx::GPUVideoEncoder.


The documentation for this struct was generated from the following file: