changeset 11626:168e540bad66

allow for different combing metrics to be selected (not useful yet)
author rfelker
date Thu, 11 Dec 2003 05:06:17 +0000
parents a18a54997671
children 7737584af47a
files libmpcodecs/pullup.c libmpcodecs/pullup.h
diffstat 2 files changed, 26 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/pullup.c	Thu Dec 11 05:03:52 2003 +0000
+++ b/libmpcodecs/pullup.c	Thu Dec 11 05:06:17 2003 +0000
@@ -172,6 +172,17 @@
 	return diff;
 }
 
+static int qpcomb_y(unsigned char *a, unsigned char *b, int s)
+{
+	int i, j, diff=0;
+	for (i=4; i; i--) {
+		for (j=0; j<8; j++)
+			diff += ABS(a[j] - 3*b[j-s] + 3*a[j+s] - b[j]);
+		a+=s; b+=s;
+	}
+	return diff;
+}
+
 #if 0
 static int licomb_y_test(unsigned char *a, unsigned char *b, int s)
 {
@@ -291,7 +302,7 @@
 static void alloc_metrics(struct pullup_context *c, struct pullup_field *f)
 {
 	f->diffs = calloc(c->metric_len, sizeof(int));
-	f->licomb = calloc(c->metric_len, sizeof(int));
+	f->comb = calloc(c->metric_len, sizeof(int));
 	/* add more metrics here as needed */
 }
 
@@ -341,7 +352,7 @@
 	f->affinity = 0;
 
 	compute_metric(c, f, parity, f->prev->prev, parity, c->diff, f->diffs);
-	compute_metric(c, parity?f->prev:f, 0, parity?f:f->prev, 1, c->licomb, f->licomb);
+	compute_metric(c, parity?f->prev:f, 0, parity?f:f->prev, 1, c->comb, f->comb);
 
 	/* Advance the circular list */
 	if (!c->first) c->first = c->head;
@@ -434,18 +445,19 @@
 	if (f->flags & F_HAVE_AFFINITY) return;
 	f->flags |= F_HAVE_AFFINITY;
 	for (i = 0; i < c->metric_len; i++) {
-		l = f->licomb[i] - f->next->licomb[i];
+		l = f->comb[i] - f->next->comb[i];
 		if (l > max_l) max_l = l;
 		if (-l > max_r) max_r = -l;
 	}
-	if (max_l + max_r < 64) return;
+	printf("%d %d\n", max_l, max_r);
+	if (max_l + max_r < 32) return;
 	if (max_r > 2*max_l) f->affinity = -1;
 	else if (max_l > 2*max_r) f->affinity = 1;
-	else if (max_l + max_r > 1024) {
+	else if (max_l + max_r > 512) {
 		l = t = 0;
 		for (i = 0; i < c->metric_len; i++) {
-			l += f->licomb[i] - f->next->licomb[i];
-			t += ABS(f->licomb[i] - f->next->licomb[i]);
+			l += f->comb[i] - f->next->comb[i];
+			t += ABS(f->comb[i] - f->next->comb[i]);
 		}
 		if (-l*4 > t) f->affinity = -1;
 		else if (l*4 > t) f->affinity = 1;
@@ -496,6 +508,7 @@
 		else if (f2->affinity == 1) return 2;
 		else if (f0->affinity == 1 && f2->affinity == -1) return 3;
 		else if (f2->affinity == -1) return 1;
+		else if (f0->affinity == 1) return 2;
 		else if (f2->affinity == 0 && f3->affinity == 1) return 3;
 		else return 2;
 	}
@@ -654,13 +667,14 @@
 	switch(c->format) {
 	case PULLUP_FMT_Y:
 		c->diff = diff_y;
-		c->licomb = licomb_y;
+		c->comb = licomb_y;
 #ifdef HAVE_MMX
 		if (c->cpu & PULLUP_CPU_MMX) {
 			c->diff = diff_y_mmx;
-			c->licomb = licomb_y_mmx;
+			c->comb = licomb_y_mmx;
 		}
 #endif
+		//c->comb = qpcomb_y;
 		break;
 #if 0
 	case PULLUP_FMT_YUY2:
@@ -680,7 +694,7 @@
 	f = c->head;
 	do {
 		free(f->diffs);
-		free(f->licomb);
+		free(f->comb);
 		f = f->next;
 		free(f->prev);
 	} while (f != c->head);
--- a/libmpcodecs/pullup.h	Thu Dec 11 05:03:52 2003 +0000
+++ b/libmpcodecs/pullup.h	Thu Dec 11 05:06:17 2003 +0000
@@ -26,7 +26,7 @@
 	int breaks;
 	int affinity;
 	int *diffs;
-	int *licomb;
+	int *comb;
 	struct pullup_field *prev, *next;
 };
 
@@ -54,7 +54,7 @@
 	struct pullup_buffer *buffers;
 	int nbuffers;
 	int (*diff)(unsigned char *, unsigned char *, int);
-	int (*licomb)(unsigned char *, unsigned char *, int);
+	int (*comb)(unsigned char *, unsigned char *, int);
 	int metric_w, metric_h, metric_len, metric_offset;
 	struct pullup_frame *frame;
 };