Loading...
Searching...
No Matches

Decodes Y210 packed 4:2:2 10-bit videos. More...

Inheritance diagram for score::gfx::Y210Decoder:
score::gfx::GPUVideoDecoder

Detailed Description

Decodes Y210 packed 4:2:2 10-bit videos.

Packed as Y0 Cb Y1 Cr, each a 16-bit little-endian word with the 10 bits of data in the high end. 8 bytes per macropixel (2 pixels), so 4 * width bytes per row.

QRhi has no four-channel 16-bit UNORM format, so the samples are uploaded into an RG16 texture at {w, h}: 4 bytes per texel is exactly one luma plus one chroma sample, and texel x holds (Y of pixel x, Cb on even columns / Cr on odd columns). The shader takes the luma of its own texel and the two chroma samples of the macropixel it belongs to.

Public Member Functions

 Y210Decoder (Video::ImageFormat &d)
 
std::pair< QShader, QShader > init (RenderList &r) override
 Initialize a GPUVideoDecoder.
 
void exec (RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
 Decode and upload a video frame to the GPU.
 
- Public Member Functions inherited from score::gfx::GPUVideoDecoder
virtual void release (RenderList &)
 This method will release all the created samplers and textures.
 

Public Attributes

Video::ImageFormatdecoder
 
- Public Attributes inherited from score::gfx::GPUVideoDecoder
std::vector< Samplersamplers
 
bool hasFrame {}
 
bool failed {}
 
bool formatChanged {}
 

Static Public Attributes

static const constexpr auto frag
 

Additional Inherited Members

- Static Public Member Functions inherited from score::gfx::GPUVideoDecoder
static QRhiTextureSubresourceUploadDescription createTextureUpload (uint8_t *pixels, int w, int h, int bytesPerPixel, int stride)
 Utility method to create a QRhiTextureSubresourceUploadDescription.
 
static QString vertexShader (bool invertY=false) noexcept
 

Member Function Documentation

◆ exec()

void score::gfx::Y210Decoder::exec ( RenderList ,
QRhiResourceUpdateBatch &  res,
AVFrame &  frame 
)
inlineoverridevirtual

Decode and upload a video frame to the GPU.

Implements score::gfx::GPUVideoDecoder.

◆ init()

std::pair< QShader, QShader > score::gfx::Y210Decoder::init ( RenderList r)
inlineoverridevirtual

Initialize a GPUVideoDecoder.

This method must :

  • Create samplers and textures for the video format.
  • Create shaders that will render the data put into these textures.

It returns a {vertex, fragment} shader pair.

Implements score::gfx::GPUVideoDecoder.

Member Data Documentation

◆ frag

const constexpr auto score::gfx::Y210Decoder::frag
staticconstexpr
Initial value:
= R"_(#version 450
)_" SCORE_GFX_VIDEO_UNIFORMS R"_(
layout(binding=3) uniform sampler2D u_tex;
layout(location = 0) in vec2 v_texcoord;
layout(location = 0) out vec4 fragColor;
%2
vec4 processTexture(vec4 tex) {
vec4 processed = convert_to_rgb(tex);
{ %1 }
return processed;
}
void main()
{
int x = int(floor(v_texcoord.x * mat.texSz.x));
int y = int(floor(v_texcoord.y * mat.texSz.y));
int cx = (x / 2) * 2;
const float s = )_" SCORE_GFX_MSB_ALIGNED_SCALE R"_(;
float luma = texelFetch(u_tex, ivec2(x, y), 0).r * s;
float cb = texelFetch(u_tex, ivec2(cx, y), 0).g * s;
float cr = texelFetch(u_tex, ivec2(cx + 1, y), 0).g * s;
fragColor = processTexture(vec4(luma, cb, cr, 1.));
})_"

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