Bug 1033124 - Use correct and more precise coeffs for YCbCr->RGB conversion. - r=mattwoodrow,r=bas

This commit is contained in:
Jeff Gilbert
2014-07-02 17:48:18 -07:00
parent 12f6fb2ad8
commit 8b4c5ea0cd
8 changed files with 1556 additions and 1631 deletions

View File

@@ -261,12 +261,23 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig)
fs << " COLOR_PRECISION float y = texture2D(uYTexture, coord).r;" << endl;
fs << " COLOR_PRECISION float cb = texture2D(uCbTexture, coord).r;" << endl;
fs << " COLOR_PRECISION float cr = texture2D(uCrTexture, coord).r;" << endl;
fs << " y = (y - 0.0625) * 1.164;" << endl;
fs << " cb = cb - 0.5;" << endl;
fs << " cr = cr - 0.5;" << endl;
fs << " color.r = y + cr * 1.596;" << endl;
fs << " color.g = y - 0.813 * cr - 0.391 * cb;" << endl;
fs << " color.b = y + cb * 2.018;" << endl;
/* From Rec601:
[R] [1.1643835616438356, 0.0, 1.5960267857142858] [ Y - 16]
[G] = [1.1643835616438358, -0.3917622900949137, -0.8129676472377708] x [Cb - 128]
[B] [1.1643835616438356, 2.017232142857143, 8.862867620416422e-17] [Cr - 128]
For [0,1] instead of [0,255], and to 5 places:
[R] [1.16438, 0.00000, 1.59603] [ Y - 0.06275]
[G] = [1.16438, -0.39176, -0.81297] x [Cb - 0.50196]
[B] [1.16438, 2.01723, 0.00000] [Cr - 0.50196]
*/
fs << " y = (y - 0.06275) * 1.16438;" << endl;
fs << " cb = cb - 0.50196;" << endl;
fs << " cr = cr - 0.50196;" << endl;
fs << " color.r = y + 1.59603*cr;" << endl;
fs << " color.g = y - 0.39176*cb - 0.81297*cr;" << endl;
fs << " color.b = y + 2.01723*cb;" << endl;
fs << " color.a = 1.0;" << endl;
} else if (aConfig.mFeatures & ENABLE_TEXTURE_COMPONENT_ALPHA) {
fs << " COLOR_PRECISION vec3 onBlack = texture2D(uBlackTexture, coord).rgb;" << endl;