[Mplayer-cvslog] CVS: 0_90/libmpcodecs vf_detc.c,1.2,1.3

Alex Beregszaszi alex at mplayerhq.hu
Tue Apr 8 19:22:22 CEST 2003


Update of /cvsroot/mplayer/0_90/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv2531

Modified Files:
	vf_detc.c 
Log Message:
backport: improvements to detc filter (...)

Index: vf_detc.c
===================================================================
RCS file: /cvsroot/mplayer/0_90/libmpcodecs/vf_detc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- vf_detc.c	22 Mar 2003 15:42:30 -0000	1.2
+++ vf_detc.c	8 Apr 2003 17:22:20 -0000	1.3
@@ -22,7 +22,7 @@
 	int frame;
 	int drop, lastdrop;
 	struct metrics pm;
-	int thres[4];
+	int thres[5];
 	int inframes, outframes;
 	int mode;
 	int (*analyze)(struct vf_priv_s *, mp_image_t *, mp_image_t *);
@@ -92,11 +92,11 @@
 	int x, y, even=0, odd=0, noise, temp;
 	unsigned char *oldp, *newp;
 	m->noise = m->temp = 0;
-	for (x = 15; x; x--) {
+	for (x = 8; x; x--) {
 		oldp = old++;
 		newp = new++;
 		noise = temp = 0;
-		for (y = 8; y; y--) {
+		for (y = 4; y; y--) {
 			even += abs(newp[0]-oldp[0]);
 			odd += abs(newp[ns]-oldp[os]);
 			noise += newp[ns]-newp[0];
@@ -115,8 +115,8 @@
 {
 	int x, y, me=0, mo=0, mn=0, mt=0;
 	struct metrics l;
-	for (y = 0; y < h-15; y += 16) {
-		for (x = 0; x < w-15; x += 16) {
+	for (y = 0; y < h-7; y += 8) {
+		for (x = 0; x < w-7; x += 8) {
 			block_diffs(&l, old+x+y*os, new+x+y*ns, os, ns);
 			if (l.even > me) me = l.even;
 			if (l.odd > mo) mo = l.odd;
@@ -190,8 +190,16 @@
 	p->pm = m;
 
 	if (p->frame == 4) {
-		if (2*m.noise > m.temp) {
-			if (VERYCLOSE(m.even, pm.odd)) {
+		/* We need to break at scene changes, but is this a valid test? */
+		if ((m.even > p->thres[2]) && (m.odd > p->thres[2]) && (m.temp > p->thres[3])
+			&& (m.temp > 5*pm.temp) && (m.temp*2 > m.noise)) {
+			mp_msg(MSGT_VFILTER, MSGL_V, "scene change breaking telecine!\n");
+			p->frame = -1;
+			return TC_DROP;
+		}
+		/* Thres. is to compensate for quantization errors when noise is low */
+		if (m.noise - m.temp > -p->thres[4]) {
+			if (COMPARABLE(m.even, pm.odd)) {
 				//mp_msg(MSGT_VFILTER, MSGL_V, "confirmed field match!\n");
 				return TC_IL2;
 			} else if ((m.even < p->thres[0]) && (m.odd < p->thres[0]) && VERYCLOSE(m.even, m.odd)
@@ -207,9 +215,7 @@
 		}
 	}
 
-	if (((2*m.even < m.odd) && (5*m.temp < 4*m.noise))
-		|| ((5*m.even < 4*m.odd) && (2*m.temp < m.noise))
-		|| (m.even*m.temp < 2*m.odd*m.noise/5) /* ok? */ ) {
+	if (2*m.even*m.temp < m.odd*m.noise) {
 		mp_msg(MSGT_VFILTER, MSGL_V, "caught telecine sync!\n");
 		p->frame = 3;
 		return TC_IL1;
@@ -239,7 +245,7 @@
 	case 2:
 		return TC_PROG;
 	case 3:
-		if ((m.even > p->thres[1]) && (5*m.even > 4*m.odd) && (5*m.temp > 4*m.noise)) {
+		if ((m.even > p->thres[1]) && (m.even > m.odd) && (m.temp > m.noise)) {
 			mp_msg(MSGT_VFILTER, MSGL_V, "lost telecine tracking!\n");
 			p->frame = -1;
 			return TC_PROG;
@@ -415,6 +421,7 @@
 	GETVAR(var, "t1", p->thres[1], atoi);
 	GETVAR(var, "t2", p->thres[2], atoi);
 	GETVAR(var, "t3", p->thres[3], atoi);
+	GETVAR(var, "t4", p->thres[4], atoi);
 	GETVAR(var, "fr", p->frame, atoi);
 	GETVAR(var, "am", p->mode, atoi);
 }
@@ -440,10 +447,11 @@
 	vf->default_reqs = VFCAP_ACCEPT_STRIDE;
 	vf->priv = p = calloc(1, sizeof(struct vf_priv_s));
 	p->frame = -1;
-	p->thres[0] = 1760;
-	p->thres[1] = 2880;
-	p->thres[2] = 10000;
-	p->thres[3] = 10000;
+	p->thres[0] = 440;
+	p->thres[1] = 720;
+	p->thres[2] = 2500;
+	p->thres[3] = 2500;
+	p->thres[4] = 800;
 	p->drop = 0;
 	p->mode = 1;
 	if (args) parse_args(p, args);



More information about the MPlayer-cvslog mailing list