mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1033124 - Use correct and more precise coeffs for YCbCr->RGB conversion. - r=mattwoodrow,r=bas
This commit is contained in:
parent
92d2115403
commit
d220b95c03
@ -136,7 +136,7 @@ float4 TransformedPostion(float2 aInPosition)
|
||||
{
|
||||
// the current vertex's position on the quad
|
||||
float4 position = float4(0, 0, 0, 1);
|
||||
|
||||
|
||||
// We use 4 component floats to uniquely describe a rectangle, by the structure
|
||||
// of x, y, width, height. This allows us to easily generate the 4 corners
|
||||
// of any rectangle from the 4 corners of the 0,0-1,1 quad that we use as the
|
||||
@ -159,7 +159,7 @@ float4 VertexPosition(float4 aTransformedPosition)
|
||||
result.xyz = aTransformedPosition.xyz / aTransformedPosition.w;
|
||||
result -= vRenderTargetOffset;
|
||||
result.xyz *= result.w;
|
||||
|
||||
|
||||
result = mul(mProjection, result);
|
||||
|
||||
return result;
|
||||
@ -244,18 +244,29 @@ float4 RGBShaderMask(const VS_MASK_OUTPUT aVertex, uniform sampler aSampler) : S
|
||||
return result * mask;
|
||||
}
|
||||
|
||||
/* 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]
|
||||
*/
|
||||
|
||||
float4 CalculateYCbCrColor(const float2 aTexCoords)
|
||||
{
|
||||
float4 yuv;
|
||||
float4 color;
|
||||
|
||||
yuv.r = tCr.Sample(LayerTextureSamplerLinear, aTexCoords).a - 0.5;
|
||||
yuv.g = tY.Sample(LayerTextureSamplerLinear, aTexCoords).a - 0.0625;
|
||||
yuv.b = tCb.Sample(LayerTextureSamplerLinear, aTexCoords).a - 0.5;
|
||||
yuv.r = tCr.Sample(LayerTextureSamplerLinear, aTexCoords).a - 0.50196;
|
||||
yuv.g = tY.Sample(LayerTextureSamplerLinear, aTexCoords).a - 0.06275;
|
||||
yuv.b = tCb.Sample(LayerTextureSamplerLinear, aTexCoords).a - 0.50196;
|
||||
|
||||
color.r = yuv.g * 1.164 + yuv.r * 1.596;
|
||||
color.g = yuv.g * 1.164 - 0.813 * yuv.r - 0.391 * yuv.b;
|
||||
color.b = yuv.g * 1.164 + yuv.b * 2.018;
|
||||
color.r = yuv.g * 1.16438 + yuv.r * 1.59603;
|
||||
color.g = yuv.g * 1.16438 - 0.81297 * yuv.r - 0.39176 * yuv.b;
|
||||
color.b = yuv.g * 1.16438 + yuv.b * 2.01723;
|
||||
color.a = 1.0f;
|
||||
|
||||
return color;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -180,18 +180,28 @@ float4 RGBShaderMask(const VS_MASK_OUTPUT aVertex) : SV_Target
|
||||
return result * mask;
|
||||
}
|
||||
|
||||
/* 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]
|
||||
*/
|
||||
float4 CalculateYCbCrColor(const float2 aTexCoords)
|
||||
{
|
||||
float4 yuv;
|
||||
float4 color;
|
||||
|
||||
yuv.r = tCr.Sample(sSampler, aTexCoords).a - 0.5;
|
||||
yuv.g = tY.Sample(sSampler, aTexCoords).a - 0.0625;
|
||||
yuv.b = tCb.Sample(sSampler, aTexCoords).a - 0.5;
|
||||
yuv.r = tCr.Sample(sSampler, aTexCoords).a - 0.50196;
|
||||
yuv.g = tY.Sample(sSampler, aTexCoords).a - 0.06275;
|
||||
yuv.b = tCb.Sample(sSampler, aTexCoords).a - 0.50196;
|
||||
|
||||
color.r = yuv.g * 1.164 + yuv.r * 1.596;
|
||||
color.g = yuv.g * 1.164 - 0.813 * yuv.r - 0.391 * yuv.b;
|
||||
color.b = yuv.g * 1.164 + yuv.b * 2.018;
|
||||
color.r = yuv.g * 1.16438 + yuv.r * 1.59603;
|
||||
color.g = yuv.g * 1.16438 - 0.81297 * yuv.r - 0.39176 * yuv.b;
|
||||
color.b = yuv.g * 1.16438 + yuv.b * 2.01723;
|
||||
color.a = 1.0f;
|
||||
|
||||
return color;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -32,3 +32,4 @@ fxc CompositorD3D11.fx -EYCbCrShaderMask -Tps_4_0_level_9_3 -nologo -Fh$tempfile
|
||||
cat $tempfile >> CompositorD3D11Shaders.h
|
||||
fxc CompositorD3D11.fx -EComponentAlphaShaderMask -Tps_4_0_level_9_3 -nologo -Fh$tempfile -VnComponentAlphaShaderMask
|
||||
cat $tempfile >> CompositorD3D11Shaders.h
|
||||
rm $tempfile
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,7 @@ sampler s2DWhite;
|
||||
sampler s2DY;
|
||||
sampler s2DCb;
|
||||
sampler s2DCr;
|
||||
sampler s2DMask;
|
||||
sampler s2DMask;
|
||||
|
||||
|
||||
float fLayerOpacity;
|
||||
@ -44,7 +44,7 @@ VS_OUTPUT LayerQuadVS(const VS_INPUT aVertex)
|
||||
{
|
||||
VS_OUTPUT outp;
|
||||
outp.vPosition = aVertex.vPosition;
|
||||
|
||||
|
||||
// We use 4 component floats to uniquely describe a rectangle, by the structure
|
||||
// of x, y, width, height. This allows us to easily generate the 4 corners
|
||||
// of any rectangle from the 4 corners of the 0,0-1,1 quad that we use as the
|
||||
@ -55,16 +55,16 @@ VS_OUTPUT LayerQuadVS(const VS_INPUT aVertex)
|
||||
float2 size = vLayerQuad.zw;
|
||||
outp.vPosition.x = position.x + outp.vPosition.x * size.x;
|
||||
outp.vPosition.y = position.y + outp.vPosition.y * size.y;
|
||||
|
||||
|
||||
outp.vPosition = mul(mLayerTransform, outp.vPosition);
|
||||
outp.vPosition.xyz /= outp.vPosition.w;
|
||||
outp.vPosition = outp.vPosition - vRenderTargetOffset;
|
||||
outp.vPosition.xyz *= outp.vPosition.w;
|
||||
|
||||
|
||||
// adjust our vertices to match d3d9's pixel coordinate system
|
||||
// which has pixel centers at integer locations
|
||||
outp.vPosition.xy -= 0.5;
|
||||
|
||||
|
||||
outp.vPosition = mul(mProjection, outp.vPosition);
|
||||
|
||||
position = vTextureCoords.xy;
|
||||
@ -79,7 +79,7 @@ VS_OUTPUT_MASK LayerQuadVSMask(const VS_INPUT aVertex)
|
||||
{
|
||||
VS_OUTPUT_MASK outp;
|
||||
float4 position = float4(0, 0, 0, 1);
|
||||
|
||||
|
||||
// We use 4 component floats to uniquely describe a rectangle, by the structure
|
||||
// of x, y, width, height. This allows us to easily generate the 4 corners
|
||||
// of any rectangle from the 4 corners of the 0,0-1,1 quad that we use as the
|
||||
@ -89,17 +89,17 @@ VS_OUTPUT_MASK LayerQuadVSMask(const VS_INPUT aVertex)
|
||||
float2 size = vLayerQuad.zw;
|
||||
position.x = vLayerQuad.x + aVertex.vPosition.x * size.x;
|
||||
position.y = vLayerQuad.y + aVertex.vPosition.y * size.y;
|
||||
|
||||
|
||||
position = mul(mLayerTransform, position);
|
||||
outp.vPosition.w = position.w;
|
||||
outp.vPosition.xyz = position.xyz / position.w;
|
||||
outp.vPosition = outp.vPosition - vRenderTargetOffset;
|
||||
outp.vPosition.xyz *= outp.vPosition.w;
|
||||
|
||||
|
||||
// adjust our vertices to match d3d9's pixel coordinate system
|
||||
// which has pixel centers at integer locations
|
||||
outp.vPosition.xy -= 0.5;
|
||||
|
||||
|
||||
outp.vPosition = mul(mProjection, outp.vPosition);
|
||||
|
||||
// calculate the position on the mask texture
|
||||
@ -117,7 +117,7 @@ VS_OUTPUT_MASK_3D LayerQuadVSMask3D(const VS_INPUT aVertex)
|
||||
{
|
||||
VS_OUTPUT_MASK_3D outp;
|
||||
float4 position = float4(0, 0, 0, 1);
|
||||
|
||||
|
||||
// We use 4 component floats to uniquely describe a rectangle, by the structure
|
||||
// of x, y, width, height. This allows us to easily generate the 4 corners
|
||||
// of any rectangle from the 4 corners of the 0,0-1,1 quad that we use as the
|
||||
@ -127,17 +127,17 @@ VS_OUTPUT_MASK_3D LayerQuadVSMask3D(const VS_INPUT aVertex)
|
||||
float2 size = vLayerQuad.zw;
|
||||
position.x = vLayerQuad.x + aVertex.vPosition.x * size.x;
|
||||
position.y = vLayerQuad.y + aVertex.vPosition.y * size.y;
|
||||
|
||||
|
||||
position = mul(mLayerTransform, position);
|
||||
outp.vPosition.w = position.w;
|
||||
outp.vPosition.xyz = position.xyz / position.w;
|
||||
outp.vPosition = outp.vPosition - vRenderTargetOffset;
|
||||
outp.vPosition.xyz *= outp.vPosition.w;
|
||||
|
||||
|
||||
// adjust our vertices to match d3d9's pixel coordinate system
|
||||
// which has pixel centers at integer locations
|
||||
outp.vPosition.xy -= 0.5;
|
||||
|
||||
|
||||
outp.vPosition = mul(mProjection, outp.vPosition);
|
||||
|
||||
// calculate the position on the mask texture
|
||||
@ -197,7 +197,7 @@ float4 YCbCrShader(const VS_OUTPUT aVertex) : COLOR
|
||||
color.g = yuv.g * 1.164 - 0.813 * yuv.r - 0.391 * yuv.b;
|
||||
color.b = yuv.g * 1.164 + yuv.b * 2.018;
|
||||
color.a = 1.0f;
|
||||
|
||||
|
||||
return color * fLayerOpacity;
|
||||
}
|
||||
|
||||
@ -250,20 +250,30 @@ float4 RGBShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR
|
||||
return result * fLayerOpacity * mask;
|
||||
}
|
||||
|
||||
/* 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]
|
||||
*/
|
||||
float4 YCbCrShaderMask(const VS_OUTPUT_MASK aVertex) : COLOR
|
||||
{
|
||||
float4 yuv;
|
||||
float4 color;
|
||||
|
||||
yuv.r = tex2D(s2DCr, aVertex.vTexCoords).a - 0.5;
|
||||
yuv.g = tex2D(s2DY, aVertex.vTexCoords).a - 0.0625;
|
||||
yuv.b = tex2D(s2DCb, aVertex.vTexCoords).a - 0.5;
|
||||
yuv.r = tex2D(s2DCr, aVertex.vTexCoords).a - 0.50196;
|
||||
yuv.g = tex2D(s2DY, aVertex.vTexCoords).a - 0.06275;
|
||||
yuv.b = tex2D(s2DCb, aVertex.vTexCoords).a - 0.50196;
|
||||
|
||||
color.r = yuv.g * 1.164 + yuv.r * 1.596;
|
||||
color.g = yuv.g * 1.164 - 0.813 * yuv.r - 0.391 * yuv.b;
|
||||
color.b = yuv.g * 1.164 + yuv.b * 2.018;
|
||||
color.r = yuv.g * 1.16438 + yuv.r * 1.59603;
|
||||
color.g = yuv.g * 1.16438 - 0.81297 * yuv.r - 0.39176 * yuv.b;
|
||||
color.b = yuv.g * 1.16438 + yuv.b * 2.01723;
|
||||
color.a = 1.0f;
|
||||
|
||||
|
||||
float2 maskCoords = aVertex.vMaskCoords;
|
||||
float mask = tex2D(s2DMask, maskCoords).a;
|
||||
return color * fLayerOpacity * mask;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user