From 087ca88213e67bee5b2db2bdc93db000df593ef7 Mon Sep 17 00:00:00 2001 From: Vivia Nikolaidou Date: Mon, 28 Feb 2022 20:39:11 +0200 Subject: [PATCH] yadif: Fix bug in C implementation of CHECK 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: --- .../gst-plugins-good/gst/deinterlace/yadif.c | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/deinterlace/yadif.c b/subprojects/gst-plugins-good/gst/deinterlace/yadif.c index 3692e157a3..b224e87ed6 100644 --- a/subprojects/gst-plugins-good/gst/deinterlace/yadif.c +++ b/subprojects/gst-plugins-good/gst/deinterlace/yadif.c @@ -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)) { \