Skip to content

Commit

Permalink
Update cVideoProcessing.fxh
Browse files Browse the repository at this point in the history
  • Loading branch information
papadanku committed Apr 3, 2024
1 parent 44cf65b commit c475097
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions shaders/shared/cVideoProcessing.fxh
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@

void SampleBlock(in sampler2D Source, in float2 Tex, in float2 Ix, in float2 Iy, in float2 PixelSize, out float2 Pixel[4])
{
float4 HalfPixel = (Tex.xxyy + float4(-0.5, 0.5, -0.5, 0.5)) * PixelSize.xxyy;
float4 HalfPixel = Tex.xxyy + (float4(-0.5, 0.5, -0.5, 0.5) * PixelSize.xxyy);
Pixel[0] = tex2Dgrad(Source, HalfPixel.xz, Ix, Iy).xy;
Pixel[1] = tex2Dgrad(Source, HalfPixel.xw, Ix, Iy).xy;
Pixel[2] = tex2Dgrad(Source, HalfPixel.yz, Ix, Iy).xy;
Expand Down Expand Up @@ -230,7 +230,7 @@
sincos(Shift, AngleShift.x, AngleShift.y);
AngleShift *= float(i);

SampleBlock(SampleImage, B.Tex.zw + AngleShift, B.TexIx.zw, B.TexIy.zw, B.PixelSize, Image);
SampleBlock(SampleImage, B.Tex.zw + (AngleShift * B.PixelSize), B.TexIx.zw, B.TexIy.zw, B.PixelSize, Image);
float SAD = GetSAD(Template, Image);
Vectors = (SAD < Minimum) ? AngleShift : Vectors;
Minimum = min(SAD, Minimum);
Expand All @@ -252,23 +252,22 @@
// Initialize data
Block B;

// Un-normalize data for processing
Vectors = UnpackMotionVectors(Vectors);

// Calculate main texel data (TexelSize, TexelLOD)
B.Tex = float4(MainTex, MainTex + Vectors);
B.TexIx = ddx(B.Tex);
B.TexIy = ddy(B.Tex);
B.PixelSize = abs(B.TexIx.xy) + abs(B.TexIy.xy);

// Un-normalize data for processing
B.Tex *= (1.0 / B.PixelSize.xyxy);
Vectors = UnpackMotionVectors(Vectors);

// Pre-calculate template
float2 Template[4];
SampleBlock(SampleTemplate, B.Tex.xy, B.TexIx.xy, B.TexIy.xy, B.PixelSize, Template);

// Calculate three-step search
// Propagate and encode vectors
Vectors += SearchArea(SampleImage, B, Template);
Vectors += NormalizeMotionVectors(SearchArea(SampleImage, B, Template), B.PixelSize);
return PackMotionVectors(Vectors);
}
#endif

0 comments on commit c475097

Please sign in to comment.