GPU RGBA -> p216 encoder (semi-planar 4:2:2, 16-bit). More...
Detailed Description
GPU RGBA -> p216 encoder (semi-planar 4:2:2, 16-bit).
The 16-bit sibling of P010Encoder: same two-plane semi-planar shape, but the chroma plane keeps FULL vertical resolution (4:2:2, not 4:2:0) and each sample uses all 16 bits of its word rather than sitting in the high 10. Matches AV_PIX_FMT_P216LE and NDI's NDIlib_FourCC_video_type_P216.
Two planes, both 2*width bytes per row over height rows:
- Y : one 16-bit luma per pixel, width x height;
- UV: one interleaved (Cb, Cr) pair per chroma site, width/2 x height. So the two planes are the same size, and a consumer that wants them contiguous (NDI: p_uv = p_y + stride * yres) gets a framestore of 2 * 2*width * height bytes.
Feed a >8-bit source texture (RGBA16F) if you want the extra bits to mean anything: from an RGBA8 scene this produces valid P216 whose values are 8-bit quantities scaled into 16-bit words. Consumers cannot tell, and it is still the right thing to send when the wire format is 16-bit, but the precision has to come from the render target.
Two implementations selected at compile time, exactly as P010Encoder does and for the same reason (see its comment for the qtbase reference):
- Qt >= 6.10: native R16 (Y) / RG16 (UV) targets, read back tightly.
- Qt < 6.10: the GL backend reads 16-bit single/dual-channel textures back as 8-bit RGBA, so the 16-bit bytes are packed into RGBA8 here.
Both paths expose the same readback byte layout, so consumers are agnostic. Requires width % 2 == 0.
Public Member Functions | |
| void | setupPlane (QRhi &rhi, const RenderState &state, QRhiTexture *inputRGBA, QRhiTexture::Format fmt, int w, int h, const char *frag, const QString &colorConversion, QRhiTexture *&tex, QRhiTextureRenderTarget *&rt, QRhiRenderPassDescriptor *&rp, QRhiShaderResourceBindings *&srb, QRhiGraphicsPipeline *&pipeline) |
| void | init (QRhi &rhi, const RenderState &state, QRhiTexture *inputRGBA, int width, int height, const QString &colorConversion) 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 plane) const override |
| Get the readback result for a given plane. Valid after endOffscreenFrame. | |
| QRhiTexture * | planeTexture (int plane) const noexcept |
| void | setReadbackEnabled (bool e) noexcept override |
| void | release () override |
| Release all GPU resources. | |
Public Member Functions inherited from score::gfx::GPUVideoEncoder | |
| virtual QRhiTexture * | outputTexture () const noexcept |
Static Public Attributes | |
| static constexpr const char * | y_frag |
| static constexpr const char * | uv_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()
|
inlineoverridevirtual |
Execute the conversion pass. Call inside beginOffscreenFrame/endOffscreenFrame. Renders the conversion shader and schedules GPU->CPU readback(s).
Implements score::gfx::GPUVideoEncoder.
◆ init()
|
inlineoverridevirtual |
Create render targets, textures, samplers, and the graphics pipeline.
- Parameters
-
rhi The QRhi instance. state The render state (for shader compilation). inputRGBA The scene RGBA texture to read from. width Source width in pixels. height Source height in pixels. colorConversion GLSL code from colorMatrixOut() defining convert_from_rgb(). If empty, defaults to BT.709 full range.
Implements score::gfx::GPUVideoEncoder.
◆ planeCount()
|
inlineoverridevirtual |
Number of readback planes (1 for UYVY, 2 for NV12, 3 for I420).
Implements score::gfx::GPUVideoEncoder.
◆ planeTexture()
|
inlinenoexcept |
The plane textures, for consumers that read them back themselves (a contiguous framestore, a GPU-direct download). Plane 0 is Y, 1 is UV.
◆ readback()
|
inlineoverridevirtual |
Get the readback result for a given plane. Valid after endOffscreenFrame.
Implements score::gfx::GPUVideoEncoder.
◆ release()
|
inlineoverridevirtual |
Release all GPU resources.
Implements score::gfx::GPUVideoEncoder.
◆ setReadbackEnabled()
|
inlineoverridevirtualnoexcept |
Enable/disable the GPU->CPU readback scheduled in exec(). Default enabled (readback runs). Disable when a GPU-direct download reads outputTexture() directly, so exec() doesn't also pay the readback (no double transfer).
Reimplemented from score::gfx::GPUVideoEncoder.
Member Data Documentation
◆ uv_frag
|
staticconstexpr |
◆ y_frag
|
staticconstexpr |
The documentation for this struct was generated from the following file:
Public Member Functions inherited from