yadif: Fix bug in C implementation of CHECK
authorVivia Nikolaidou <vivia@ahiru.eu>
Mon, 28 Feb 2022 18:39:11 +0000 (20:39 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 1 Mar 2022 07:22:10 +0000 (07:22 +0000)
It was different compared to the corresponding part in both ffmpeg and
the asm implementation. Fixing this makes videotestsrc pattern=spokes
not jump at all when not using the asm optimisations.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1816>

subprojects/gst-plugins-good/gst/deinterlace/yadif.c

index 3692e15..b224e87 100644 (file)
@@ -190,13 +190,14 @@ static void
 #define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
 #define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
 
-#define CHECK(j1, j2, j3)\
-    {   int score = FFABS(stzero[x - j1] - sbzero[x - j2])\
-                  + FFABS(stzero[x + j3] - sbzero[x - j3])\
-                  + FFABS(stzero[x + j1] - sbzero[x + j2]);\
+
+#define CHECK(j)\
+    {   int score = FFABS(stzero[x - colors2 + j] - sbzero[x - colors2 - j])\
+                  + FFABS(stzero[x  + j] - sbzero[x  - j])\
+                  + FFABS(stzero[x + colors2 + j] - sbzero[x + colors2 - j]);\
         if (score < spatial_score) {\
             spatial_score= score;\
-            spatial_pred= (stzero[x + j3] + sbzero[x - j3])>>1;\
+            spatial_pred= (stzero[x  + j] + sbzero[x - j])>>1;\
 
 /* The is_not_edge argument here controls when the code will enter a branch
  * which reads up to and including x-3 and x+3. */
@@ -219,14 +220,8 @@ static void
         if (is_not_edge) {\
             int spatial_score = FFABS(stzero[x-colors2] - sbzero[x-colors2]) + FFABS(c-e) \
                               + FFABS(stzero[x+colors2] - sbzero[x+colors2]); \
-            int twice_colors2 = colors2 << 1; \
-            int minus_colors2 = -colors2; \
-            int thrice_colors2 = colors2 * 3; \
-            int minus2_colors2 = colors2 * -2; \
-            CHECK(0, twice_colors2, minus_colors2) \
-              CHECK(-colors2, thrice_colors2, minus2_colors2) }} }} \
-            CHECK(twice_colors2, 0, colors2) \
-              CHECK(thrice_colors2, minus_colors2, twice_colors2) }} }} \
+            CHECK(-1) CHECK(-2) }} }} \
+            CHECK( 1) CHECK( 2) }} }} \
         }\
  \
         if (!(mode&2)) { \