Bug 100854 - YUV to RGB Color Space Conversion result is not precise
Summary: YUV to RGB Color Space Conversion result is not precise
Alias: None
Product: Mesa
Classification: Unclassified
Component: glsl-compiler (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact: Intel 3D Bugs Mailing List
Depends on:
Reported: 2017-04-27 16:32 UTC by johnson.lin
Modified: 2017-05-15 06:45 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Description johnson.lin 2017-04-27 16:32:00 UTC
Use Y value 0x42, Cb Value 0x65, Cr Value 0x5E
The resulted RGB value should be 0x04, 0x60, 0x04, which is according to https://en.wikipedia.org/wiki/YCbCr

But Shader CSC result is 0x05, 0x60, 0x05.
In some situation, it has a bit difference with what is precise
Seems the matrix it is using has some problem
Comment 1 Matt Turner 2017-04-27 22:12:43 UTC
Do you have a test program that shows the issue?
Comment 2 johnson.lin 2017-04-29 14:12:17 UTC
@Matt Turner
Yes I have.
Also piglit test has YUV2RGB test
Comment 3 Kristian Høgsberg 2017-05-01 17:21:05 UTC
You can extend this with the problematic YUV value:

Comment 4 Kenneth Graunke 2017-05-04 06:53:46 UTC
Fixed by:

commit a6fb943f3eb86ca501a7e7b8d4621ba215f91133
Author: Johnson Lin <johnson.lin@intel.com>
Date:   Thu May 4 14:37:52 2017 +0800

    nir/lower_tex: Fix minor error in YUV color conversion matrix
    The matrix used for YCbCr to RGB is listed in:
    There was an error in converting the offsets from integers to unorm
    values: 0.0625=16/256 should be 16.0/255,and 0.5=128.0/256 should be
    128.0/255.  With this fix, the CSC result is bit aligned with wikipedia's
    conversion result and FFMPeg's result.
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100854
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.