The YUV offset is 16 / 255, not 16 / 256

This commit is contained in:
Alfred Reynolds 2014-07-03 10:22:12 -07:00
parent 744d4f02e6
commit 2748e28230
3 changed files with 13 additions and 11 deletions

View File

@ -41,6 +41,8 @@
#ifdef ASSEMBLE_SHADER
#pragma comment(lib, "d3dx9.lib")
/**************************************************************************
* ID3DXBuffer:
* ------------
@ -689,7 +691,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
PS_OUTPUT YUV420( VS_OUTPUT In )
{
const float3 offset = {-0.0625, -0.5, -0.5};
const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.164, 0.000, 1.596};
const float3 Gcoeff = {1.164, -0.391, -0.813};
const float3 Bcoeff = {1.164, 2.018, 0.000};
@ -721,7 +723,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
*/
const char *shader_text =
"ps_2_0\n"
"def c0, -0.0625, -0.5, -0.5, 1\n"
"def c0, -0.0627451017, -0.501960814, -0.501960814, 1\n"
"def c1, 1.16400003, 0, 1.59599996, 0\n"
"def c2, 1.16400003, -0.391000003, -0.813000023, 0\n"
"def c3, 1.16400003, 2.01799989, 0, 0\n"
@ -758,7 +760,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
}
#else
const DWORD shader_data[] = {
0xffff0200, 0x05000051, 0xa00f0000, 0xbd800000, 0xbf000000, 0xbf000000,
0xffff0200, 0x05000051, 0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081,
0x3f800000, 0x05000051, 0xa00f0001, 0x3f94fdf4, 0x00000000, 0x3fcc49ba,
0x00000000, 0x05000051, 0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5,
0x00000000, 0x05000051, 0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000,

View File

@ -363,7 +363,7 @@ static const DWORD D3D11_PixelShader_Textures[] = {
float4 main(PixelShaderInput input) : SV_TARGET
{
const float3 offset = {-0.0625, -0.5, -0.5};
const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
const float3 Rcoeff = {1.164, 0.000, 1.596};
const float3 Gcoeff = {1.164, -0.391, -0.813};
const float3 Bcoeff = {1.164, 2.018, 0.000};
@ -387,12 +387,12 @@ static const DWORD D3D11_PixelShader_Textures[] = {
*/
#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
static const DWORD D3D11_PixelShader_YUV[] = {
0x43425844, 0x04e69cba, 0x74ce6dd2, 0x7fcf84cb, 0x3003d677, 0x00000001,
0x43425844, 0x2321c6c6, 0xf14df2d1, 0xc79d068d, 0x8e672abf, 0x00000001,
0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438,
0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200,
0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051,
0xa00f0000, 0xbd800000, 0xbf000000, 0xbf000000, 0x3f800000, 0x05000051,
0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051,
0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051,
0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x05000051,
0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x0200001f,
@ -419,7 +419,7 @@ static const DWORD D3D11_PixelShader_YUV[] = {
0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000,
0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001,
0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002,
0xbd800000, 0xbf000000, 0xbf000000, 0x00000000, 0x0a00000f, 0x00100012,
0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012,
0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f94fdf4, 0x3fcc49ba,
0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246,
0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000,
@ -453,12 +453,12 @@ static const DWORD D3D11_PixelShader_YUV[] = {
};
#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
static const DWORD D3D11_PixelShader_YUV[] = {
0x43425844, 0xe6d969fc, 0x63cac33c, 0xa4926502, 0x5d788135, 0x00000001,
0x43425844, 0x6ede7360, 0x45ff5f8a, 0x34ac92ba, 0xb865f5e0, 0x00000001,
0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410,
0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200,
0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051,
0xa00f0000, 0xbd800000, 0xbf000000, 0x3f800000, 0x00000000, 0x05000051,
0xa00f0000, 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051,
0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x400126e9, 0x05000051,
0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x0200001f,
0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
@ -483,7 +483,7 @@ static const DWORD D3D11_PixelShader_YUV[] = {
0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000,
0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246,
0x00000000, 0x00004002, 0xbd800000, 0xbf000000, 0xbf000000, 0x00000000,
0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000,
0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002,
0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, 0x00100022,
0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127,

View File

@ -133,7 +133,7 @@ static const char *shader_source[NUM_SHADERS][2] =
"uniform sampler2D tex2; // V \n"
"\n"
"// YUV offset \n"
"const vec3 offset = vec3(-0.0625, -0.5, -0.5);\n"
"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n"
"\n"
"// RGB coefficients \n"
"const vec3 Rcoeff = vec3(1.164, 0.000, 1.596);\n"