The YUV offset is 16 / 255, not 16 / 256
authorAlfred Reynolds <alfred@valvesoftware.com>
Thu, 03 Jul 2014 10:22:12 -0700
changeset 89697fb90df60b99
parent 8968 47decd0106f8
child 8970 c566c1634307
The YUV offset is 16 / 255, not 16 / 256
src/render/direct3d/SDL_render_d3d.c
src/render/direct3d11/SDL_render_d3d11.c
src/render/opengl/SDL_shaders_gl.c
     1.1 --- a/src/render/direct3d/SDL_render_d3d.c	Mon Jun 30 17:22:08 2014 -0700
     1.2 +++ b/src/render/direct3d/SDL_render_d3d.c	Thu Jul 03 10:22:12 2014 -0700
     1.3 @@ -41,6 +41,8 @@
     1.4  
     1.5  
     1.6  #ifdef ASSEMBLE_SHADER
     1.7 +#pragma comment(lib, "d3dx9.lib")
     1.8 +
     1.9  /**************************************************************************
    1.10   * ID3DXBuffer:
    1.11   * ------------
    1.12 @@ -689,7 +691,7 @@
    1.13  
    1.14             PS_OUTPUT YUV420( VS_OUTPUT In ) 
    1.15             {
    1.16 -               const float3 offset = {-0.0625, -0.5, -0.5};
    1.17 +               const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
    1.18                 const float3 Rcoeff = {1.164,  0.000,  1.596};
    1.19                 const float3 Gcoeff = {1.164, -0.391, -0.813};
    1.20                 const float3 Bcoeff = {1.164,  2.018,  0.000};
    1.21 @@ -721,7 +723,7 @@
    1.22          */
    1.23          const char *shader_text =
    1.24              "ps_2_0\n"
    1.25 -            "def c0, -0.0625, -0.5, -0.5, 1\n"
    1.26 +            "def c0, -0.0627451017, -0.501960814, -0.501960814, 1\n"
    1.27              "def c1, 1.16400003, 0, 1.59599996, 0\n"
    1.28              "def c2, 1.16400003, -0.391000003, -0.813000023, 0\n"
    1.29              "def c3, 1.16400003, 2.01799989, 0, 0\n"
    1.30 @@ -758,7 +760,7 @@
    1.31          }
    1.32  #else
    1.33          const DWORD shader_data[] = {
    1.34 -            0xffff0200, 0x05000051, 0xa00f0000, 0xbd800000, 0xbf000000, 0xbf000000,
    1.35 +            0xffff0200, 0x05000051, 0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081,
    1.36              0x3f800000, 0x05000051, 0xa00f0001, 0x3f94fdf4, 0x00000000, 0x3fcc49ba,
    1.37              0x00000000, 0x05000051, 0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5,
    1.38              0x00000000, 0x05000051, 0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000,
     2.1 --- a/src/render/direct3d11/SDL_render_d3d11.c	Mon Jun 30 17:22:08 2014 -0700
     2.2 +++ b/src/render/direct3d11/SDL_render_d3d11.c	Thu Jul 03 10:22:12 2014 -0700
     2.3 @@ -363,7 +363,7 @@
     2.4  
     2.5      float4 main(PixelShaderInput input) : SV_TARGET
     2.6      {
     2.7 -        const float3 offset = {-0.0625, -0.5, -0.5};
     2.8 +        const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
     2.9          const float3 Rcoeff = {1.164,  0.000,  1.596};
    2.10          const float3 Gcoeff = {1.164, -0.391, -0.813};
    2.11          const float3 Bcoeff = {1.164,  2.018,  0.000};
    2.12 @@ -387,12 +387,12 @@
    2.13  */
    2.14  #if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
    2.15  static const DWORD D3D11_PixelShader_YUV[] = {
    2.16 -    0x43425844, 0x04e69cba, 0x74ce6dd2, 0x7fcf84cb, 0x3003d677, 0x00000001,
    2.17 +    0x43425844, 0x2321c6c6, 0xf14df2d1, 0xc79d068d, 0x8e672abf, 0x00000001,
    2.18      0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438,
    2.19      0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200,
    2.20      0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
    2.21      0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051,
    2.22 -    0xa00f0000, 0xbd800000, 0xbf000000, 0xbf000000, 0x3f800000, 0x05000051,
    2.23 +    0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051,
    2.24      0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051,
    2.25      0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x05000051,
    2.26      0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x0200001f,
    2.27 @@ -419,7 +419,7 @@
    2.28      0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000,
    2.29      0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001,
    2.30      0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002,
    2.31 -    0xbd800000, 0xbf000000, 0xbf000000, 0x00000000, 0x0a00000f, 0x00100012,
    2.32 +    0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012,
    2.33      0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f94fdf4, 0x3fcc49ba,
    2.34      0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246,
    2.35      0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000,
    2.36 @@ -453,12 +453,12 @@
    2.37  };
    2.38  #elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
    2.39  static const DWORD D3D11_PixelShader_YUV[] = {
    2.40 -    0x43425844, 0xe6d969fc, 0x63cac33c, 0xa4926502, 0x5d788135, 0x00000001,
    2.41 +    0x43425844, 0x6ede7360, 0x45ff5f8a, 0x34ac92ba, 0xb865f5e0, 0x00000001,
    2.42      0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410,
    2.43      0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200,
    2.44      0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
    2.45      0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051,
    2.46 -    0xa00f0000, 0xbd800000, 0xbf000000, 0x3f800000, 0x00000000, 0x05000051,
    2.47 +    0xa00f0000, 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051,
    2.48      0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x400126e9, 0x05000051,
    2.49      0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x0200001f,
    2.50      0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
    2.51 @@ -483,7 +483,7 @@
    2.52      0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
    2.53      0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000,
    2.54      0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246,
    2.55 -    0x00000000, 0x00004002, 0xbd800000, 0xbf000000, 0xbf000000, 0x00000000,
    2.56 +    0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000,
    2.57      0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002,
    2.58      0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, 0x00100022,
    2.59      0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127,
     3.1 --- a/src/render/opengl/SDL_shaders_gl.c	Mon Jun 30 17:22:08 2014 -0700
     3.2 +++ b/src/render/opengl/SDL_shaders_gl.c	Thu Jul 03 10:22:12 2014 -0700
     3.3 @@ -133,7 +133,7 @@
     3.4  "uniform sampler2D tex2; // V \n"
     3.5  "\n"
     3.6  "// YUV offset \n"
     3.7 -"const vec3 offset = vec3(-0.0625, -0.5, -0.5);\n"
     3.8 +"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n"
     3.9  "\n"
    3.10  "// RGB coefficients \n"
    3.11  "const vec3 Rcoeff = vec3(1.164,  0.000,  1.596);\n"