Loading...
Searching...
No Matches

Decodes XYZ12LE, the DCDM X'Y'Z' of JPEG 2000 DCPs. More...

Inheritance diagram for score::gfx::XYZ12Decoder:
score::gfx::GPUVideoDecoder

Detailed Description

Decodes XYZ12LE, the DCDM X'Y'Z' of JPEG 2000 DCPs.

Packed 4:4:4, three little-endian 16-bit words per pixel, each holding a 12-bit code value in its top bits. The layout is RGB48's, so the words go into an R16 texture three texels wide per pixel and are reassembled with texelFetch.

The colour pipeline is fixed by SMPTE 428-1 rather than read from the stream: the code values are X'Y'Z' = (XYZ / 52.37)^(1/2.6), with XYZ in cd/m^2 and the reference white at Y = 48 cd/m^2. Decoding is therefore gamma 2.6 -> scale to 1.0 = 48 cd/m^2 -> XYZ to RGB (D65 primaries). No chromatic adaptation is applied: the DCDM is absolute colorimetry, so a DCI-white master keeps its slightly green-tinted white, as it does in libdcp and ffmpeg.

Public Member Functions

 XYZ12Decoder (Video::ImageFormat &d, QString f="")
 
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.
 

Static Public Member Functions

static QString colorShader (const Video::ImageFormat &d)
 
- 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 bool isTopField (const AVFrame &frame) noexcept
 Whether this frame carries the EVEN lines of its picture.
 
static PlaneRows planeRows (const Video::ImageFormat &fmt, const AVFrame &frame, int textureRows) noexcept
 
static QString vertexShader (bool invertY=false) noexcept
 

Public Attributes

Video::ImageFormat & decoder
 
QString filter
 
- Public Attributes inherited from score::gfx::GPUVideoDecoder
std::vector< Sampler > samplers
 
bool hasFrame {}
 
bool failed {}
 
bool formatChanged {}
 

Static Public Attributes

static const constexpr auto frag
 
static constexpr auto dcdm_eotf
 
static constexpr auto xyz_to_bt709
 
static constexpr auto xyz_to_bt2020
 

Member Function Documentation

◆ exec()

void score::gfx::XYZ12Decoder::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::XYZ12Decoder::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

◆ dcdm_eotf

constexpr auto score::gfx::XYZ12Decoder::dcdm_eotf
staticconstexpr
Initial value:
= R"_(
vec3 dcdmToXYZ(vec3 v) {
return pow(clamp(v, 0.0, 1.0), vec3(2.6)) * (52.37 / 48.0);
}
)_"

◆ frag

const constexpr auto score::gfx::XYZ12Decoder::frag
staticconstexpr
Initial value:
= R"_(#version 450
)_" SCORE_GFX_VIDEO_UNIFORMS R"_(
layout(binding=3) uniform sampler2D y_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 ()
{
vec2 tc = score_tc(v_texcoord);
int x = int(floor(tc.x * mat.texSz.x) * 3.);
int y = int(tc.y * mat.texSz.y);
// 12 bits at the top of the word: full scale is 4095 << 4 = 65520.
const float s = 65535.0 / 65520.0;
float X = texelFetch(y_tex, ivec2(x + 0, y), 0).r * s;
float Y = texelFetch(y_tex, ivec2(x + 1, y), 0).r * s;
float Z = texelFetch(y_tex, ivec2(x + 2, y), 0).r * s;
fragColor = processTexture(vec4(X, Y, Z, 1.));
})_"

◆ xyz_to_bt2020

constexpr auto score::gfx::XYZ12Decoder::xyz_to_bt2020
staticconstexpr
Initial value:
= R"_(
const mat3 xyzToRgb = mat3(
1.7166512, -0.6666844, 0.0176399,
-0.3556708, 1.6164812, -0.0427706,
-0.2533663, 0.0157685, 0.9421031
);
)_"

◆ xyz_to_bt709

constexpr auto score::gfx::XYZ12Decoder::xyz_to_bt709
staticconstexpr
Initial value:
= R"_(
const mat3 xyzToRgb = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
-0.4985314, 0.0415560, 1.0572252
);
)_"

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