The issue is that clipping the interpolated temporal sample against
the spatially predicted sample causes artifacts to appear.

Discovered while writing the Vulkan version (where I omitted the
same check).

The clipping in the code is carried over from yadif. Removing the
same code in yadif does not make any difference to the output.
I think that the check was simply ill-adapted to the new prediction
code and does more harm.

I tested replacing the range clip with only an FFMAX, and only an
FFMIN, but in both cases, artifacts still appeared.

Test sample 1: https://files.lynne.ee/testsamples/mbaff_1080i60_idx.mkvTest 
sample 2: https://files.lynne.ee/testsamples/mbaff_bdmv_1080i60_8slice.mkv

Command line:
./ffmpeg_g -cpuflags 0 -i <INPUT> -vf bwdif=mode=send_field -c:v rawvideo -y 
<OUTPUT>.nut
Make sure to disable the assembly.

Comparisons:
https://files.lynne.ee/bwdif_01_before.png
https://files.lynne.ee/bwdif_01_after.png
Generated from sample 1 via:
ffmpeg -ss 00:00:00.184 -i <INPUT>.nut -vf 
crop=w=420:h=240:x=700:y=300,scale=iw*2:ih*2 -y <OUTPUT>.png

https://files.lynne.ee/bwdif_02_before.png
https://files.lynne.ee/bwdif_02_after.pngffmpeg -ss 00:00:00.417 -i <INPUT>.nut 
-vf crop=w=420:h=240:x=1100:y=200,scale=iw*2:ih*2 -y <OUTPUT>.png
>From abda922dc040ce7237ad3048f55ab20b03f96a27 Mon Sep 17 00:00:00 2001
From: Lynne <d...@lynne.ee>
Date: Sun, 2 Jul 2023 18:10:47 +0200
Subject: [PATCH] lavfi/bwdif: remove interpolated sample clipping

The issue is that clipping the interpolated temporal sample against
the spatially predicted sample causes artifacts.
---
 libavfilter/vf_bwdif.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/libavfilter/vf_bwdif.c b/libavfilter/vf_bwdif.c
index e278cf1217..55dec526bf 100644
--- a/libavfilter/vf_bwdif.c
+++ b/libavfilter/vf_bwdif.c
@@ -106,10 +106,6 @@ typedef struct ThreadData {
             interpol = (c + e) >> 1;
 
 #define FILTER2() \
-            if (interpol > d + diff) \
-                interpol = d + diff; \
-            else if (interpol < d - diff) \
-                interpol = d - diff; \
  \
             dst[0] = av_clip(interpol, 0, clip_max); \
         } \
-- 
2.40.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to