From f4248304babcac38483977d94e24b8fb84a06bb0 Mon Sep 17 00:00:00 2001 From: papadanku Date: Sat, 30 Mar 2024 17:18:55 -0700 Subject: [PATCH] Update .gitignore --- docs/source/blog/opticalflow.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/source/blog/opticalflow.rst b/docs/source/blog/opticalflow.rst index affa5b3..c82bde2 100644 --- a/docs/source/blog/opticalflow.rst +++ b/docs/source/blog/opticalflow.rst @@ -46,10 +46,10 @@ Source Code const int Exponent = exp2(ExponentBits); const int Significand = exp2(SignificandBits); - const float MaxExponent = (Exponent - exp2(1)) + Bias; + const float MaxExponent = ((float)Exponent - (float)exp2(1)) + (float)Bias; const float MaxSignificand = 1.0 + (((float)Significand - 1.0) / (float)Significand); - return pow(-1, SignBit) * exp2(MaxExponent) * MaxSignificand; + return (float)pow(-1, SignBit) * (float)exp2(MaxExponent) * MaxSignificand; } // [-Half, Half] -> [-1.0, 1.0] @@ -170,9 +170,12 @@ Source Code // Calculate A^T*B float2 Flow = (D == 0.0) ? 0.0 : mul(B, A); - // Propagate motion vectors to Half format + // Propagate normalized motion vectors Vectors += NormalizeMotionVectors(Flow, PixelSize); + // Clamp motion vectors to restrict range to valid lengths + Vectors = clamp(Vectors, -1.0, 1.0); + // Pack motion vectors to Half format return PackMotionVectors(Vectors); }