From 61eda625cbd1475063c428975e9672c3db43e245 Mon Sep 17 00:00:00 2001 From: Ryan Holtz Date: Tue, 31 May 2011 14:43:47 +0000 Subject: [PATCH] NWN: Fixing the NTSC codec. Oops. --- hlsl/yiq_decode.fx | 9 ++++++--- hlsl/yiq_encode.fx | 20 +++++++++++--------- src/osd/windows/drawd3d.c | 9 ++++++--- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/hlsl/yiq_decode.fx b/hlsl/yiq_decode.fx index a85590d998f..346f316464f 100644 --- a/hlsl/yiq_decode.fx +++ b/hlsl/yiq_decode.fx @@ -114,13 +114,16 @@ float4 ps_main(PS_INPUT Input) : COLOR float PI = 3.1415926535897932384626433832795; float PI2 = 2.0f * PI; float PI2Length = PI2 / 42.0f; + float4 NOffset = float4(0.0f, 1.0f, 2.0f, 3.0f); + float W = PI2 * CCValue * ScanTime; for(float n = -21.0f; n < 22.0f; n += 4.0f) { - float4 n4 = float4(n + 0.0f, n + 1.0f, n + 2.0f, n + 3.0f); + float4 n4 = n + NOffset; float4 CoordX = Input.Coord0.x + Input.Coord0.z * n4 * 0.25f; float4 CoordY = Input.Coord0.y; - float4 C = tex2D(CompositeSampler, float2(CoordX.r, CoordY.r)) * CRange + MinC; - float4 WT = PI2 * CCValue * ScanTime * (CoordX * WidthRatio + AValue * CoordY * 2.0f * (RawHeight / HeightRatio) + BValue) + OValue; + float2 TexCoord = float2(CoordX.r, CoordY.r); + float4 C = tex2D(CompositeSampler, TexCoord) * CRange + MinC; + float4 WT = W * (CoordX * WidthRatio + AValue * CoordY * 2.0f * (RawHeight / HeightRatio) + BValue) + OValue; float4 SincYIn = PI2 * Fc_y * n4; float4 IdealY = 2.0f * Fc_y * ((SincYIn != 0.0f) ? (sin(SincYIn) / SincYIn) : 1.0f); diff --git a/hlsl/yiq_encode.fx b/hlsl/yiq_encode.fx index 119a9169bf8..c1c0079dd1a 100644 --- a/hlsl/yiq_encode.fx +++ b/hlsl/yiq_encode.fx @@ -92,15 +92,17 @@ float4 ps_main(PS_INPUT Input) : COLOR { float2 Scaler = float2(RawWidth, RawHeight); float2 InvRatios = float2(1.0f / WidthRatio, 1.0f / HeightRatio); - float3 Texel0 = tex2D(DiffuseSampler, Input.Coord0 + float2(PValue * 0.00f + 0.5f, 0.5f) / Scaler).rgb; - float3 Texel1 = tex2D(DiffuseSampler, Input.Coord1 + float2(PValue * 0.25f + 0.5f, 0.5f) / Scaler).rgb; - float3 Texel2 = tex2D(DiffuseSampler, Input.Coord2 + float2(PValue * 0.50f + 0.5f, 0.5f) / Scaler).rgb; - float3 Texel3 = tex2D(DiffuseSampler, Input.Coord3 + float2(PValue * 0.75f + 0.5f, 0.5f) / Scaler).rgb; - - float2 Coord0 = (Input.Coord0.xy + float2(0.00f / RawWidth, 0.0f)); - float2 Coord1 = (Input.Coord1.xy + float2(0.25f / RawWidth, 0.0f)); - float2 Coord2 = (Input.Coord2.xy + float2(0.50f / RawWidth, 0.0f)); - float2 Coord3 = (Input.Coord3.xy + float2(0.75f / RawWidth, 0.0f)); + + float2 Coord0 = Input.Coord0 + float2(0.00f, 0.0f) / Scaler; + float2 Coord1 = Input.Coord1 + float2(0.25f, 0.0f) / Scaler; + float2 Coord2 = Input.Coord2 + float2(0.50f, 0.0f) / Scaler; + float2 Coord3 = Input.Coord3 + float2(0.75f, 0.0f) / Scaler; + + float2 TexelOffset = 0.5f / Scaler; + float3 Texel0 = tex2D(DiffuseSampler, Coord0 + TexelOffset).rgb; + float3 Texel1 = tex2D(DiffuseSampler, Coord1 + TexelOffset).rgb; + float3 Texel2 = tex2D(DiffuseSampler, Coord2 + TexelOffset).rgb; + float3 Texel3 = tex2D(DiffuseSampler, Coord3 + TexelOffset).rgb; float PI = 3.1415926535897932384626433832795; float W = PI * 2.0f * CCValue * ScanTime; diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c index 8bf8dcbf449..9ea51eb1484 100644 --- a/src/osd/windows/drawd3d.c +++ b/src/osd/windows/drawd3d.c @@ -2967,6 +2967,7 @@ static void primitive_flush_pending(d3d_info *d3d) (*d3dintf->effect.set_float)(curr_effect, "HeightRatio", 1.0f / (poly->texture->vstop - poly->texture->vstart)); (*d3dintf->effect.set_float)(curr_effect, "TargetWidth", (float)d3d->width); (*d3dintf->effect.set_float)(curr_effect, "TargetHeight", (float)d3d->height); + (*d3dintf->effect.set_float)(curr_effect, "Prescale", (float)d3d->hlsl_prescale_size); (*d3dintf->effect.set_float)(curr_effect, "RedFloor", options->screen_red_floor); (*d3dintf->effect.set_float)(curr_effect, "GrnFloor", options->screen_green_floor); (*d3dintf->effect.set_float)(curr_effect, "BluFloor", options->screen_blue_floor); @@ -3031,6 +3032,7 @@ static void primitive_flush_pending(d3d_info *d3d) (*d3dintf->effect.set_float)(curr_effect, "IFreqResponse", winoptions.screen_yiq_i()); (*d3dintf->effect.set_float)(curr_effect, "QFreqResponse", winoptions.screen_yiq_q()); (*d3dintf->effect.set_float)(curr_effect, "ScanTime", winoptions.screen_yiq_scan_time()); + (*d3dintf->effect.set_float)(curr_effect, "Prescale", (float)d3d->hlsl_prescale_size); result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->hlsltarget4[poly->texture->target_index]); @@ -3071,6 +3073,7 @@ static void primitive_flush_pending(d3d_info *d3d) (*d3dintf->effect.set_float)(curr_effect, "IFreqResponse", winoptions.screen_yiq_i()); (*d3dintf->effect.set_float)(curr_effect, "QFreqResponse", winoptions.screen_yiq_q()); (*d3dintf->effect.set_float)(curr_effect, "ScanTime", winoptions.screen_yiq_scan_time()); + (*d3dintf->effect.set_float)(curr_effect, "Prescale", (float)d3d->hlsl_prescale_size); result = (*d3dintf->device.set_render_target)(d3d->device, 0, d3d->hlsltarget3[poly->texture->target_index]); @@ -3993,12 +3996,12 @@ static texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsour goto error; (*d3dintf->texture.get_surface_level)(d3d->hlsltexture2[idx], 0, &d3d->hlsltarget2[idx]); - result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth * hlsl_prescale, texture->rawheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture3[idx]); + result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth, texture->rawheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture3[idx]); if (result != D3D_OK) goto error; (*d3dintf->texture.get_surface_level)(d3d->hlsltexture3[idx], 0, &d3d->hlsltarget3[idx]); - result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth * hlsl_prescale, texture->rawheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture4[idx]); + result = (*d3dintf->device.create_texture)(d3d->device, texture->rawwidth, texture->rawheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture4[idx]); if (result != D3D_OK) goto error; (*d3dintf->texture.get_surface_level)(d3d->hlsltexture4[idx], 0, &d3d->hlsltarget4[idx]); @@ -4093,7 +4096,7 @@ static texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsour goto error; (*d3dintf->texture.get_surface_level)(d3d->hlsltexture3[idx], 0, &d3d->hlsltarget3[idx]); - result = (*d3dintf->device.create_texture)(d3d->device, scwidth * hlsl_prescale, scheight * hlsl_prescale, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture4[idx]); + result = (*d3dintf->device.create_texture)(d3d->device, scwidth, scheight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3d->hlsltexture4[idx]); if (result != D3D_OK) goto error; (*d3dintf->texture.get_surface_level)(d3d->hlsltexture4[idx], 0, &d3d->hlsltarget4[idx]);