Skip to content

Add a color matrix option to YUV texture shaders - #381

Merged
john-preston merged 1 commit into
desktop-app:masterfrom
meh7an:fix/yuv-color-matrix
Oct 22, 2026
Merged

john-preston merged 1 commit into
desktop-app:masterfrom
meh7an:fix/yuv-color-matrix

Conversation

@meh7an

@meh7an meh7an commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

FragmentSampleYUV420Texture() and FragmentSampleNV12Texture() convert YUV to RGB with fixed BT.601 limited range constants, so HD (BT.709), BT.2020 and full range videos get wrong colors.

Both now take an optional colorMatrix flag. With it the shader declares uniform mat4 yuvToRgb and converts with yuvToRgb * vec4(y, u, v, 1.), so the caller passes the matrix for the frame's coefficients, range and bit depth. Without it the conversion is the same as before; the offsets only moved from the sampling lines into FragmentYUV2RGB().

Used by telegramdesktop/tdesktop#31408.

@meh7an
meh7an force-pushed the fix/yuv-color-matrix branch from 2c6fe11 to a4f5bd5 Compare October 22, 2026 13:33
@john-preston
john-preston merged commit e5279ea into desktop-app:master Oct 22, 2026
@john-preston

Copy link
Copy Markdown
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants