Matchbox Shader converting to Luma/Chroma formats for delivery

If you’re anything like me, delivering compressed consumer formats from Flame has always been a thorn in the side.

Usually, when exporting to mathematically lossless integer RGB intermediates, these require further processing for at least chroma subsampling and the application of the colourmatrix; hence introducing generational loss due to rounding error. The severity of it depending on the difference of bit-depths of target & intermediate.
Even worse for colourmatrices requiring reversal & re-application of transfer characteristics, such as ICTCP, IPT-C2 and any Constant Luminance one.

This shader solves that issue, performing all steps of the Luma/Chroma conversion in full 32fp precision, allowing for storing an intermediate of the same integer bit-depth as the desired target format, holding the absolute final true image information, to be passed straight to encoding without any additional manipulation.

The output planes (be that YCBCR, ICTCP, IPT, …) are stored to the green, blue and red channels, respectively; top-left-justified for chroma-subsampled formats. A representation not universally usable, but feasible to read and correctly interpret with FFmpeg. The role of which is limited to decoding the intermediate (video or image sequence), casting the data to the true pixel-format, passing it to the encoder, and optionally muxing to the chosen container format.
Notably, it circumvents any occurrence or the need for autoscale, zscale and alike.

More usage details and examples are provided in the shader’s description.

Questions or feedback? Drop them below or PM me.