GPU RGBA->NV12 encoder (semi-planar 4:2:0). More...
Detailed Description
GPU RGBA->NV12 encoder (semi-planar 4:2:0).
Two render passes: Pass 1: Y plane -> R8 texture at full resolution Pass 2: UV plane -> interleaved chroma at half vertical resolution
Two readbacks. The caller concatenates Y + UV data for GStreamer video/x-raw,format=NV12.
The UV plane renders into an R8 target of width x height/2, one byte per texel: U in even columns, V in odd ones – the same byte layout an RG8 target at width/2 x height/2 produces.
It must not be RG8. An RG8 row here is (w/2) * 2 = w bytes, and where that is not 4-byte aligned the readback comes back the right total SIZE with its rows progressively shifted: row 0 correct, the rest drifting. 722 and 1922 are even, so 4:2:0 can express them, and both are real NDI sizes. Measured against a source varying only vertically, where every chroma row must be one repeated value, 287 of 288 rows came back non-constant on OpenGL and on Vulkan; against ffmpeg's own nv12 at 722x576, 30% of bytes differed.
Sampling is unchanged – one bilinear tap at the centre of the 2x2 block – so the values match the RG8 path wherever it was readable at all.
Public Member Functions | |
| 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. | |
| void | release () override |
| Release all GPU resources. | |
Public Member Functions inherited from score::gfx::GPUVideoEncoder | |
| virtual QRhiTexture * | outputTexture () const noexcept |
| virtual void | setReadbackEnabled (bool) 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.
◆ 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.
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