[MPlayer-dev-eng] [PATCH] Convolution deinterlacer

James Bostick Crowson jbcrowso at unity.ncsu.edu
Sat Mar 29 06:47:36 CET 2003


This filter is a deinterlacer which tries to blur still images by a
minimal amount while still doing a good job of removing interlacing
artifacts.  In my estimation the visual quality on anime is better than
all of MPlayer's other deinterlacers.  It is used by "-vop pp=cd".

There are several problems with this filter currently:

1) It is for MPlayer 0.90rc5.  I don't know where the postprocessing code
has gone to in the CVS version - sorry.

2) It shifts the luma plane up two lines.  I think this is OK as long as
the chroma plane is shifted up one line too.  In testing I used "-vop
scale,pp=cd -ssf cvs=1".  It doesn't do it in the filter since I don't
know how.

3) It is C only, as I am not an MMX guru.

4) It suffers from clipping problems that manifest as spurious white or
black dots.  I don't know how to fix this.

Because of the number of problems with this patch that I don't know how to
fix, I understand if it's not applied, but I would appreciate if someone
were to go through and fix them, since I believe the quality really is
better in many cases.
-------------- next part --------------
diff -Naur ./postprocess.c /tmp/MPlayer-0.90rc5-mod/postproc/postprocess.c
--- ./postprocess.c	Wed Jan 22 23:19:24 2003
+++ /tmp/MPlayer-0.90rc5-mod/postproc/postprocess.c	Fri Mar 28 23:54:16 2003
@@ -125,6 +125,7 @@
 	{"fd", "ffmpegdeint", 		1, 1, 4, FFMPEG_DEINT_FILTER},
 	{"tn", "tmpnoise", 		1, 7, 8, TEMP_NOISE_FILTER},
 	{"fq", "forcequant", 		1, 0, 0, FORCE_QUANT},
+	{"cd", "convdeint",             1, 1, 4, CONV_DEINT_FILTER},
 	{NULL, NULL,0,0,0,0} //End Marker
 };
 
@@ -513,6 +514,7 @@
 "ci	cubicipoldeint				cubic interpolating deinterlacer\n"
 "md	mediandeint				median deinterlacer\n"
 "fd	ffmpegdeint				ffmpeg deinterlacer\n"
+"cd	convdeint				convolution deinterlacer\n"
 "de	default					hb:a,vb:a,dr:a,al\n"
 "fa	fast					h1:a,v1:a,dr:a,al\n"
 "tn	tmpnoise	(3 Thresholds)		Temporal Noise Reducer\n"
diff -Naur ./postprocess_internal.h /tmp/MPlayer-0.90rc5-mod/postproc/postprocess_internal.h
--- ./postprocess_internal.h	Sun Jan  5 14:10:42 2003
+++ /tmp/MPlayer-0.90rc5-mod/postproc/postprocess_internal.h	Fri Mar 28 22:00:26 2003
@@ -46,7 +46,7 @@
 #define	CUBIC_IPOL_DEINT_FILTER		0x40000	// 262144
 #define	MEDIAN_DEINT_FILTER		0x80000	// 524288
 #define	FFMPEG_DEINT_FILTER		0x400000
-
+#define CONV_DEINT_FILTER               0x800000
 #define TEMP_NOISE_FILTER		0x100000
 #define FORCE_QUANT			0x200000
 
diff -Naur ./postprocess_template.c /tmp/MPlayer-0.90rc5-mod/postproc/postprocess_template.c
--- ./postprocess_template.c	Wed Jan 22 23:19:24 2003
+++ /tmp/MPlayer-0.90rc5-mod/postproc/postprocess_template.c	Fri Mar 28 23:37:00 2003
@@ -1790,6 +1790,34 @@
 
 /**
  * Deinterlaces the given block
+ * will be called for every 8x8 block and can read & write from line 4-15
+ * lines 0-3 have been passed through the deblock / dering filters allready, but can be read too
+ * lines 4-12 will be read into the deblocking filter and should be deinterlaced
+ * will shift the image up by 2 lines (FIXME if this is a problem)
+ * FIXME: chroma needs to be shifted up one line
+ * FIXME: clipping problems
+ * this filter will read lines 4-15 and write 4-11
+ */
+static inline void RENAME(deInterlaceConv)(uint8_t src[], int stride)
+{
+	int x;
+	src+= 4*stride;
+       	for(x=0; x<8; x++)
+	{
+		src[0       ] = (-src[0       ] + 2*src[stride  ] + 6*src[stride*2] + 2*src[stride*3] -src[stride*4])>>3;
+                src[stride  ] = (-src[stride  ] + 2*src[stride*2] + 6*src[stride*3] + 2*src[stride*4] -src[stride*5])>>3;
+                src[stride*2] = (-src[stride*2] + 2*src[stride*3] + 6*src[stride*4] + 2*src[stride*5] -src[stride*6])>>3;
+                src[stride*3] = (-src[stride*3] + 2*src[stride*4] + 6*src[stride*5] + 2*src[stride*6] -src[stride*7])>>3;
+                src[stride*4] = (-src[stride*4] + 2*src[stride*5] + 6*src[stride*6] + 2*src[stride*7] -src[stride*8])>>3;
+                src[stride*5] = (-src[stride*5] + 2*src[stride*6] + 6*src[stride*7] + 2*src[stride*8] -src[stride*9])>>3;
+		src[stride*6] = (-src[stride*6] + 2*src[stride*7] + 6*src[stride*8] + 2*src[stride*9] -src[stride*10])>>3;
+                src[stride*7] = (-src[stride*7] + 2*src[stride*8] + 6*src[stride*9] + 2*src[stride*10] -src[stride*11])>>3;
+		src++;
+		}
+}
+
+/**
+ * Deinterlaces the given block
  * will be called for every 8x8 block and can read & write from line 4-15,
  * lines 0-3 have been passed through the deblock / dering filters allready, but can be read too
  * lines 4-12 will be read into the deblocking filter and should be deinterlaced
@@ -2688,7 +2716,8 @@
 	}
 #endif
 
-	if(mode & CUBIC_IPOL_DEINT_FILTER) copyAhead=16;
+	if((mode & CUBIC_IPOL_DEINT_FILTER)
+		|| (mode & CONV_DEINT_FILTER)) copyAhead=16;
 	else if(   (mode & LINEAR_BLEND_DEINT_FILTER)
 		|| (mode & FFMPEG_DEINT_FILTER)) copyAhead=14;
 	else if(   (mode & V_DEBLOCK)
@@ -2826,6 +2855,10 @@
 				RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);
 			else if(mode & FFMPEG_DEINT_FILTER)
 				RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x);
+
+			else if(mode & CONV_DEINT_FILTER)
+				RENAME(deInterlaceConv)(dstBlock, dstStride);
+
 /*			else if(mode & CUBIC_BLEND_DEINT_FILTER)
 				RENAME(deInterlaceBlendCubic)(dstBlock, dstStride);
 */
@@ -2968,6 +3001,10 @@
 				RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride);
 			else if(mode & FFMPEG_DEINT_FILTER)
 				RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x);
+
+			else if(mode & CONV_DEINT_FILTER)
+				RENAME(deInterlaceConv)(dstBlock, dstStride);
+
 /*			else if(mode & CUBIC_BLEND_DEINT_FILTER)
 				RENAME(deInterlaceBlendCubic)(dstBlock, dstStride);
 */


More information about the MPlayer-dev-eng mailing list