<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Please prefix with "nir/lower_tex:"  How about<br><br></div><div class="gmail_quote">nir/lower_tex: Fix minor error in YUV color conversion matrix<br></div><div class="gmail_quote"><br>On Tue, May 2, 2017 at 7:24 AM, Johnson Lin <span dir="ltr"><<a href="mailto:johnson.lin@intel.com" target="_blank">johnson.lin@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The matrix used for YCbCr to RGB is listed in Wiki <a href="https://en.wikipedia.org/
wiki/YCbCr" rel="noreferrer" target="_blank">https://en.wikipedia.org/<br>
wiki/YCbCr</a>; There is minor error in the matrix constant: 0.0625=16/256 should<br>
 be 16.0/255,and 0.5=128.0/256 should be 128.0/255.<br>
Note that conversion from a 0-255 byte number to 0-1.0 float is to divide by<br>
255 instead of 256. That's we get 255=1.0f.<br>
By the constant change we can see the CSC result is bit aligned with Wiki<br>
conversion result and FFMPeg result.Otherwise in some situation, there will be<br>
 one bit difference<br>
<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=100854" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=100854</a><br>
---<br>
 src/compiler/nir/nir_lower_<wbr>tex.c | 6 +++---<br>
 1 file changed, 3 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir_lower_<wbr>tex.c b/src/compiler/nir/nir_lower_<wbr>tex.c<br>
index 352d1499bc8d..f20425e84aab 100644<br>
--- a/src/compiler/nir/nir_lower_<wbr>tex.c<br>
+++ b/src/compiler/nir/nir_lower_<wbr>tex.c<br>
@@ -244,9 +244,9 @@ convert_yuv_to_rgb(nir_builder *b, nir_tex_instr *tex,<br>
    nir_ssa_def *yuv =<br>
       nir_vec4(b,<br>
                nir_fmul(b, nir_imm_float(b, 1.16438356f),<br>
-                        nir_fadd(b, y, nir_imm_float(b, -0.0625f))),<br>
-               nir_channel(b, nir_fadd(b, u, nir_imm_float(b, -0.5f)), 0),<br>
-               nir_channel(b, nir_fadd(b, v, nir_imm_float(b, -0.5f)), 0),<br>
+                        nir_fadd(b, y, nir_imm_float(b, -16.0f/255))),<br>
+               nir_channel(b, nir_fadd(b, u, nir_imm_float(b, -128.0f/255)), 0),<br>
+               nir_channel(b, nir_fadd(b, v, nir_imm_float(b, -128.0f/255)), 0),<br>
                nir_imm_float(b, 0.0));<br>
<br>
    nir_ssa_def *red = nir_fdot4(b, yuv, nir_build_imm(b, 4, 32, m[0]));<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.1<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>