Skip to content

[Bug] ConvertRGB_YUV_HD is using BT.601 conversion matrix instead of BT.709 #84

@dimatronix

Description

@dimatronix

Unity Version

6000.2.2f1

AVPro DeckLink edition

Full

AVPro Decklink Version

1.9.9

Desktop Video version

15.1

Which Windows version(s) are you using?

Windows 10

Which graphics API(s) are you using?

Direct3D 12, Direct3D 11

Decklink device model

Decklink 8K Pro

Cables used

SDI

Video mode

YUV 10-bit 4:2:2.

The issue

I've noticed completely wrong colors while outputting from my DeckLink device. Both input and output are set to 10-bit YUV 4:2:2. To my amazement, I've discovered that the conversion matrix is completely incorrect. The matrix you are using follows the BT.601 standard: https://learn.microsoft.com/en-us/windows/win32/medfound/about-yuv-video
I'm including the code that needs to be checked:

// BT709
// from http://www.equasys.de/colorconversion.html
float3 ConvertRGB_YUV_HD(float r, float g, float b)
{
	float3x3 m = float3x3(0.299, 0.587, 0.114, -0.169, -0.331, 0.500, 0.500, -0.419, -0.081);

	float3 yuv = mul(m, float3(r, g, b));
	yuv.y += 0.5;
	yuv.z += 0.5;

	return yuv;
}

After switching to the proper BT.709 coefficients and implementing limited range scaling (which is also not covered by the shader), I managed to get correct colors. It would be great if you could fix this in an upcoming version. I'm also a bit surprised nobody has addressed this issue previously.

Log output

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriage

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions