summaryrefslogtreecommitdiffstats
path: root/video/filter
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-04-13 18:00:51 +0200
committerwm4 <wm4@nowhere>2014-04-13 18:03:01 +0200
commit78128bddda4bcea1f256fc13cc33fa2652ed277c (patch)
tree35bf6596cb8e2d7927618845833c3ee36534f890 /video/filter
parent44f382cf98564c0fe08bdc78579c284362cd6f3c (diff)
downloadmpv-78128bddda4bcea1f256fc13cc33fa2652ed277c.tar.bz2
mpv-78128bddda4bcea1f256fc13cc33fa2652ed277c.tar.xz
Kill all tabs
I hate tabs. This replaces all tabs in all source files with spaces. The only exception is old-makefile. The replacement was made by running the GNU coreutils "expand" command on every file. Since the replacement was automatic, it's possible that some formatting was destroyed (but perhaps only if it was assuming that the end of a tab does not correspond to aligning the end to multiples of 8 spaces).
Diffstat (limited to 'video/filter')
-rw-r--r--video/filter/pullup.c1172
-rw-r--r--video/filter/pullup.h74
-rw-r--r--video/filter/vf_crop.c6
-rw-r--r--video/filter/vf_divtc.c412
-rw-r--r--video/filter/vf_expand.c2
-rw-r--r--video/filter/vf_format.c2
-rw-r--r--video/filter/vf_noformat.c2
-rw-r--r--video/filter/vf_noise.c474
-rw-r--r--video/filter/vf_phase.c142
-rw-r--r--video/filter/vf_pp.c26
-rw-r--r--video/filter/vf_pullup.c304
-rw-r--r--video/filter/vf_rotate.c32
-rw-r--r--video/filter/vf_softpulldown.c82
-rw-r--r--video/filter/vf_sub.c2
14 files changed, 1366 insertions, 1366 deletions
diff --git a/video/filter/pullup.c b/video/filter/pullup.c
index 14c31dc365..45aa74eedd 100644
--- a/video/filter/pullup.c
+++ b/video/filter/pullup.c
@@ -30,184 +30,184 @@
#if HAVE_MMX
static int diff_y_mmx(unsigned char *a, unsigned char *b, int s)
{
- int ret;
- __asm__ volatile (
- "movl $4, %%ecx \n\t"
- "pxor %%mm4, %%mm4 \n\t"
- "pxor %%mm7, %%mm7 \n\t"
-
- "1: \n\t"
-
- "movq (%%"REG_S"), %%mm0 \n\t"
- "movq (%%"REG_S"), %%mm2 \n\t"
- "add %%"REG_a", %%"REG_S" \n\t"
- "movq (%%"REG_D"), %%mm1 \n\t"
- "add %%"REG_a", %%"REG_D" \n\t"
- "psubusb %%mm1, %%mm2 \n\t"
- "psubusb %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm0 \n\t"
- "movq %%mm1, %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpckhbw %%mm7, %%mm2 \n\t"
- "punpckhbw %%mm7, %%mm3 \n\t"
- "paddw %%mm0, %%mm4 \n\t"
- "paddw %%mm1, %%mm4 \n\t"
- "paddw %%mm2, %%mm4 \n\t"
- "paddw %%mm3, %%mm4 \n\t"
-
- "decl %%ecx \n\t"
- "jnz 1b \n\t"
-
- "movq %%mm4, %%mm3 \n\t"
- "punpcklwd %%mm7, %%mm4 \n\t"
- "punpckhwd %%mm7, %%mm3 \n\t"
- "paddd %%mm4, %%mm3 \n\t"
- "movd %%mm3, %%eax \n\t"
- "psrlq $32, %%mm3 \n\t"
- "movd %%mm3, %%edx \n\t"
- "addl %%edx, %%eax \n\t"
- "emms \n\t"
- : "=a" (ret)
- : "S" (a), "D" (b), "a" (s)
- : "%ecx", "%edx"
- );
- return ret;
+ int ret;
+ __asm__ volatile (
+ "movl $4, %%ecx \n\t"
+ "pxor %%mm4, %%mm4 \n\t"
+ "pxor %%mm7, %%mm7 \n\t"
+
+ "1: \n\t"
+
+ "movq (%%"REG_S"), %%mm0 \n\t"
+ "movq (%%"REG_S"), %%mm2 \n\t"
+ "add %%"REG_a", %%"REG_S" \n\t"
+ "movq (%%"REG_D"), %%mm1 \n\t"
+ "add %%"REG_a", %%"REG_D" \n\t"
+ "psubusb %%mm1, %%mm2 \n\t"
+ "psubusb %%mm0, %%mm1 \n\t"
+ "movq %%mm2, %%mm0 \n\t"
+ "movq %%mm1, %%mm3 \n\t"
+ "punpcklbw %%mm7, %%mm0 \n\t"
+ "punpcklbw %%mm7, %%mm1 \n\t"
+ "punpckhbw %%mm7, %%mm2 \n\t"
+ "punpckhbw %%mm7, %%mm3 \n\t"
+ "paddw %%mm0, %%mm4 \n\t"
+ "paddw %%mm1, %%mm4 \n\t"
+ "paddw %%mm2, %%mm4 \n\t"
+ "paddw %%mm3, %%mm4 \n\t"
+
+ "decl %%ecx \n\t"
+ "jnz 1b \n\t"
+
+ "movq %%mm4, %%mm3 \n\t"
+ "punpcklwd %%mm7, %%mm4 \n\t"
+ "punpckhwd %%mm7, %%mm3 \n\t"
+ "paddd %%mm4, %%mm3 \n\t"
+ "movd %%mm3, %%eax \n\t"
+ "psrlq $32, %%mm3 \n\t"
+ "movd %%mm3, %%edx \n\t"
+ "addl %%edx, %%eax \n\t"
+ "emms \n\t"
+ : "=a" (ret)
+ : "S" (a), "D" (b), "a" (s)
+ : "%ecx", "%edx"
+ );
+ return ret;
}
static int licomb_y_mmx(unsigned char *a, unsigned char *b, int s)
{
- int ret;
- __asm__ volatile (
- "movl $4, %%ecx \n\t"
- "pxor %%mm6, %%mm6 \n\t"
- "pxor %%mm7, %%mm7 \n\t"
- "sub %%"REG_a", %%"REG_D" \n\t"
-
- "2: \n\t"
-
- "movq (%%"REG_D"), %%mm0 \n\t"
- "movq (%%"REG_D"), %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "movq (%%"REG_D",%%"REG_a"), %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "paddw %%mm0, %%mm0 \n\t"
- "paddw %%mm2, %%mm1 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "psubusw %%mm1, %%mm0 \n\t"
- "psubusw %%mm2, %%mm1 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
- "paddw %%mm1, %%mm6 \n\t"
-
- "movq (%%"REG_S"), %%mm0 \n\t"
- "movq (%%"REG_D"), %%mm1 \n\t"
- "punpckhbw %%mm7, %%mm0 \n\t"
- "movq (%%"REG_D",%%"REG_a"), %%mm2 \n\t"
- "punpckhbw %%mm7, %%mm1 \n\t"
- "punpckhbw %%mm7, %%mm2 \n\t"
- "paddw %%mm0, %%mm0 \n\t"
- "paddw %%mm2, %%mm1 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "psubusw %%mm1, %%mm0 \n\t"
- "psubusw %%mm2, %%mm1 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
- "paddw %%mm1, %%mm6 \n\t"
-
- "movq (%%"REG_D",%%"REG_a"), %%mm0 \n\t"
- "movq (%%"REG_S"), %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "movq (%%"REG_S",%%"REG_a"), %%mm2 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpcklbw %%mm7, %%mm2 \n\t"
- "paddw %%mm0, %%mm0 \n\t"
- "paddw %%mm2, %%mm1 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "psubusw %%mm1, %%mm0 \n\t"
- "psubusw %%mm2, %%mm1 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
- "paddw %%mm1, %%mm6 \n\t"
-
- "movq (%%"REG_D",%%"REG_a"), %%mm0 \n\t"
- "movq (%%"REG_S"), %%mm1 \n\t"
- "punpckhbw %%mm7, %%mm0 \n\t"
- "movq (%%"REG_S",%%"REG_a"), %%mm2 \n\t"
- "punpckhbw %%mm7, %%mm1 \n\t"
- "punpckhbw %%mm7, %%mm2 \n\t"
- "paddw %%mm0, %%mm0 \n\t"
- "paddw %%mm2, %%mm1 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "psubusw %%mm1, %%mm0 \n\t"
- "psubusw %%mm2, %%mm1 \n\t"
- "paddw %%mm0, %%mm6 \n\t"
- "paddw %%mm1, %%mm6 \n\t"
-
- "add %%"REG_a", %%"REG_S" \n\t"
- "add %%"REG_a", %%"REG_D" \n\t"
- "decl %%ecx \n\t"
- "jnz 2b \n\t"
-
- "movq %%mm6, %%mm5 \n\t"
- "punpcklwd %%mm7, %%mm6 \n\t"
- "punpckhwd %%mm7, %%mm5 \n\t"
- "paddd %%mm6, %%mm5 \n\t"
- "movd %%mm5, %%eax \n\t"
- "psrlq $32, %%mm5 \n\t"
- "movd %%mm5, %%edx \n\t"
- "addl %%edx, %%eax \n\t"
-
- "emms \n\t"
- : "=a" (ret)
- : "S" (a), "D" (b), "a" (s)
- : "%ecx", "%edx"
- );
- return ret;
+ int ret;
+ __asm__ volatile (
+ "movl $4, %%ecx \n\t"
+ "pxor %%mm6, %%mm6 \n\t"
+ "pxor %%mm7, %%mm7 \n\t"
+ "sub %%"REG_a", %%"REG_D" \n\t"
+
+ "2: \n\t"
+
+ "movq (%%"REG_D"), %%mm0 \n\t"
+ "movq (%%"REG_D"), %%mm1 \n\t"
+ "punpcklbw %%mm7, %%mm0 \n\t"
+ "movq (%%"REG_D",%%"REG_a"), %%mm2 \n\t"
+ "punpcklbw %%mm7, %%mm1 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
+ "paddw %%mm0, %%mm0 \n\t"
+ "paddw %%mm2, %%mm1 \n\t"
+ "movq %%mm0, %%mm2 \n\t"
+ "psubusw %%mm1, %%mm0 \n\t"
+ "psubusw %%mm2, %%mm1 \n\t"
+ "paddw %%mm0, %%mm6 \n\t"
+ "paddw %%mm1, %%mm6 \n\t"
+
+ "movq (%%"REG_S"), %%mm0 \n\t"
+ "movq (%%"REG_D"), %%mm1 \n\t"
+ "punpckhbw %%mm7, %%mm0 \n\t"
+ "movq (%%"REG_D",%%"REG_a"), %%mm2 \n\t"
+ "punpckhbw %%mm7, %%mm1 \n\t"
+ "punpckhbw %%mm7, %%mm2 \n\t"
+ "paddw %%mm0, %%mm0 \n\t"
+ "paddw %%mm2, %%mm1 \n\t"
+ "movq %%mm0, %%mm2 \n\t"
+ "psubusw %%mm1, %%mm0 \n\t"
+ "psubusw %%mm2, %%mm1 \n\t"
+ "paddw %%mm0, %%mm6 \n\t"
+ "paddw %%mm1, %%mm6 \n\t"
+
+ "movq (%%"REG_D",%%"REG_a"), %%mm0 \n\t"
+ "movq (%%"REG_S"), %%mm1 \n\t"
+ "punpcklbw %%mm7, %%mm0 \n\t"
+ "movq (%%"REG_S",%%"REG_a"), %%mm2 \n\t"
+ "punpcklbw %%mm7, %%mm1 \n\t"
+ "punpcklbw %%mm7, %%mm2 \n\t"
+ "paddw %%mm0, %%mm0 \n\t"
+ "paddw %%mm2, %%mm1 \n\t"
+ "movq %%mm0, %%mm2 \n\t"
+ "psubusw %%mm1, %%mm0 \n\t"
+ "psubusw %%mm2, %%mm1 \n\t"
+ "paddw %%mm0, %%mm6 \n\t"
+ "paddw %%mm1, %%mm6 \n\t"
+
+ "movq (%%"REG_D",%%"REG_a"), %%mm0 \n\t"
+ "movq (%%"REG_S"), %%mm1 \n\t"
+ "punpckhbw %%mm7, %%mm0 \n\t"
+ "movq (%%"REG_S",%%"REG_a"), %%mm2 \n\t"
+ "punpckhbw %%mm7, %%mm1 \n\t"
+ "punpckhbw %%mm7, %%mm2 \n\t"
+ "paddw %%mm0, %%mm0 \n\t"
+ "paddw %%mm2, %%mm1 \n\t"
+ "movq %%mm0, %%mm2 \n\t"
+ "psubusw %%mm1, %%mm0 \n\t"
+ "psubusw %%mm2, %%mm1 \n\t"
+ "paddw %%mm0, %%mm6 \n\t"
+ "paddw %%mm1, %%mm6 \n\t"
+
+ "add %%"REG_a", %%"REG_S" \n\t"
+ "add %%"REG_a", %%"REG_D" \n\t"
+ "decl %%ecx \n\t"
+ "jnz 2b \n\t"
+
+ "movq %%mm6, %%mm5 \n\t"
+ "punpcklwd %%mm7, %%mm6 \n\t"
+ "punpckhwd %%mm7, %%mm5 \n\t"
+ "paddd %%mm6, %%mm5 \n\t"
+ "movd %%mm5, %%eax \n\t"
+ "psrlq $32, %%mm5 \n\t"
+ "movd %%mm5, %%edx \n\t"
+ "addl %%edx, %%eax \n\t"
+
+ "emms \n\t"
+ : "=a" (ret)
+ : "S" (a), "D" (b), "a" (s)
+ : "%ecx", "%edx"
+ );
+ return ret;
}
static int var_y_mmx(unsigned char *a, unsigned char *b, int s)
{
- int ret;
- __asm__ volatile (
- "movl $3, %%ecx \n\t"
- "pxor %%mm4, %%mm4 \n\t"
- "pxor %%mm7, %%mm7 \n\t"
-
- "1: \n\t"
-
- "movq (%%"REG_S"), %%mm0 \n\t"
- "movq (%%"REG_S"), %%mm2 \n\t"
- "movq (%%"REG_S",%%"REG_a"), %%mm1 \n\t"
- "add %%"REG_a", %%"REG_S" \n\t"
- "psubusb %%mm1, %%mm2 \n\t"
- "psubusb %%mm0, %%mm1 \n\t"
- "movq %%mm2, %%mm0 \n\t"
- "movq %%mm1, %%mm3 \n\t"
- "punpcklbw %%mm7, %%mm0 \n\t"
- "punpcklbw %%mm7, %%mm1 \n\t"
- "punpckhbw %%mm7, %%mm2 \n\t"
- "punpckhbw %%mm7, %%mm3 \n\t"
- "paddw %%mm0, %%mm4 \n\t"
- "paddw %%mm1, %%mm4 \n\t"
- "paddw %%mm2, %%mm4 \n\t"
- "paddw %%mm3, %%mm4 \n\t"
-
- "decl %%ecx \n\t"
- "jnz 1b \n\t"
-
- "movq %%mm4, %%mm3 \n\t"
- "punpcklwd %%mm7, %%mm4 \n\t"
- "punpckhwd %%mm7, %%mm3 \n\t"
- "paddd %%mm4, %%mm3 \n\t"
- "movd %%mm3, %%eax \n\t"
- "psrlq $32, %%mm3 \n\t"
- "movd %%mm3, %%edx \n\t"
- "addl %%edx, %%eax \n\t"
- "emms \n\t"
- : "=a" (ret)
- : "S" (a), "a" (s)
- : "%ecx", "%edx"
- );
- return 4*ret;
+ int ret;
+ __asm__ volatile (
+ "movl $3, %%ecx \n\t"
+ "pxor %%mm4, %%mm4 \n\t"
+ "pxor %%mm7, %%mm7 \n\t"
+
+ "1: \n\t"
+
+ "movq (%%"REG_S"), %%mm0 \n\t"
+ "movq (%%"REG_S"), %%mm2 \n\t"
+ "movq (%%"REG_S",%%"REG_a"), %%mm1 \n\t"
+ "add %%"REG_a", %%"REG_S" \n\t"
+ "psubusb %%mm1, %%mm2 \n\t"
+ "psubusb %%mm0, %%mm1 \n\t"
+ "movq %%mm2, %%mm0 \n\t"
+ "movq %%mm1, %%mm3 \n\t"
+ "punpcklbw %%mm7, %%mm0 \n\t"
+ "punpcklbw %%mm7, %%mm1 \n\t"
+ "punpckhbw %%mm7, %%mm2 \n\t"
+ "punpckhbw %%mm7, %%mm3 \n\t"
+ "paddw %%mm0, %%mm4 \n\t"
+ "paddw %%mm1, %%mm4 \n\t"
+ "paddw %%mm2, %%mm4 \n\t"
+ "paddw %%mm3, %%mm4 \n\t"
+
+ "decl %%ecx \n\t"
+ "jnz 1b \n\t"
+
+ "movq %%mm4, %%mm3 \n\t"
+ "punpcklwd %%mm7, %%mm4 \n\t"
+ "punpckhwd %%mm7, %%mm3 \n\t"
+ "paddd %%mm4, %%mm3 \n\t"
+ "movd %%mm3, %%eax \n\t"
+ "psrlq $32, %%mm3 \n\t"
+ "movd %%mm3, %%edx \n\t"
+ "addl %%edx, %%eax \n\t"
+ "emms \n\t"
+ : "=a" (ret)
+ : "S" (a), "a" (s)
+ : "%ecx", "%edx"
+ );
+ return 4*ret;
}
#endif
#endif
@@ -216,57 +216,57 @@ static int var_y_mmx(unsigned char *a, unsigned char *b, int s)
static int diff_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]-b[j]);
- a+=s; b+=s;
- }
- return diff;
+ int i, j, diff=0;
+ for (i=4; i; i--) {
+ for (j=0; j<8; j++) diff += ABS(a[j]-b[j]);
+ a+=s; b+=s;
+ }
+ return diff;
}
static int licomb_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]<<1) - b[j-s] - b[j])
- + ABS((b[j]<<1) - a[j] - a[j+s]);
- a+=s; b+=s;
- }
- return diff;
+ int i, j, diff=0;
+ for (i=4; i; i--) {
+ for (j=0; j<8; j++)
+ diff += ABS((a[j]<<1) - b[j-s] - b[j])
+ + ABS((b[j]<<1) - a[j] - a[j+s]);
+ a+=s; b+=s;
+ }
+ return diff;
}
#if 0
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;
+ 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;
}
static int licomb_y_test(unsigned char *a, unsigned char *b, int s)
{
- int c = licomb_y(a,b,s);
- int m = licomb_y_mmx(a,b,s);
- if (c != m) printf("%d != %d\n", c, m);
- return m;
+ int c = licomb_y(a,b,s);
+ int m = licomb_y_mmx(a,b,s);
+ if (c != m) printf("%d != %d\n", c, m);
+ return m;
}
#endif
static int var_y(unsigned char *a, unsigned char *b, int s)
{
- int i, j, var=0;
- for (i=3; i; i--) {
- for (j=0; j<8; j++) {
- var += ABS(a[j]-a[j+s]);
- }
- a+=s; b+=s;
- }
- return 4*var; /* match comb scaling */
+ int i, j, var=0;
+ for (i=3; i; i--) {
+ for (j=0; j<8; j++) {
+ var += ABS(a[j]-a[j+s]);
+ }
+ a+=s; b+=s;
+ }
+ return 4*var; /* match comb scaling */
}
@@ -279,61 +279,61 @@ static int var_y(unsigned char *a, unsigned char *b, int s)
static void alloc_buffer(struct pullup_context *c, struct pullup_buffer *b)
{
- int i;
- if (b->planes) return;
- b->planes = calloc(c->nplanes, sizeof(unsigned char *));
- for (i = 0; i < c->nplanes; i++) {
- b->planes[i] = malloc(c->h[i]*c->stride[i]);
- /* Deal with idiotic 128=0 for chroma: */
- memset(b->planes[i], c->background[i], c->h[i]*c->stride[i]);
- }
+ int i;
+ if (b->planes) return;
+ b->planes = calloc(c->nplanes, sizeof(unsigned char *));
+ for (i = 0; i < c->nplanes; i++) {
+ b->planes[i] = malloc(c->h[i]*c->stride[i]);
+ /* Deal with idiotic 128=0 for chroma: */
+ memset(b->planes[i], c->background[i], c->h[i]*c->stride[i]);
+ }
}
struct pullup_buffer *pullup_lock_buffer(struct pullup_buffer *b, int parity)
{
- if (!b) return 0;
- if ((parity+1) & 1) b->lock[0]++;
- if ((parity+1) & 2) b->lock[1]++;
- return b;
+ if (!b) return 0;
+ if ((parity+1) & 1) b->lock[0]++;
+ if ((parity+1) & 2) b->lock[1]++;
+ return b;
}
void pullup_release_buffer(struct pullup_buffer *b, int parity)
{
- if (!b) return;
- if ((parity+1) & 1) b->lock[0]--;
- if ((parity+1) & 2) b->lock[1]--;
+ if (!b) return;
+ if ((parity+1) & 1) b->lock[0]--;
+ if ((parity+1) & 2) b->lock[1]--;
}
struct pullup_buffer *pullup_get_buffer(struct pullup_context *c, int parity)
{
- int i;
+ int i;
- /* Try first to get the sister buffer for the previous field */
- if (parity < 2 && c->last && parity != c->last->parity
- && !c->last->buffer->lock[parity]) {
- alloc_buffer(c, c->last->buffer);
- return pullup_lock_buffer(c->last->buffer, parity);
- }
+ /* Try first to get the sister buffer for the previous field */
+ if (parity < 2 && c->last && parity != c->last->parity
+ && !c->last->buffer->lock[parity]) {
+ alloc_buffer(c, c->last->buffer);
+ return pullup_lock_buffer(c->last->buffer, parity);
+ }
- /* Prefer a buffer with both fields open */
- for (i = 0; i < c->nbuffers; i++) {
- if (c->buffers[i].lock[0]) continue;
- if (c->buffers[i].lock[1]) continue;
- alloc_buffer(c, &c->buffers[i]);
- return pullup_lock_buffer(&c->buffers[i], parity);
- }
+ /* Prefer a buffer with both fields open */
+ for (i = 0; i < c->nbuffers; i++) {
+ if (c->buffers[i].lock[0]) continue;
+ if (c->buffers[i].lock[1]) continue;
+ alloc_buffer(c, &c->buffers[i]);
+ return pullup_lock_buffer(&c->buffers[i], parity);
+ }
- if (parity == 2) return 0;
+ if (parity == 2) return 0;
- /* Search for any half-free buffer */
- for (i = 0; i < c->nbuffers; i++) {
- if (((parity+1) & 1) && c->buffers[i].lock[0]) continue;
- if (((parity+1) & 2) && c->buffers[i].lock[1]) continue;
- alloc_buffer(c, &c->buffers[i]);
- return pullup_lock_buffer(&c->buffers[i], parity);
- }
+ /* Search for any half-free buffer */
+ for (i = 0; i < c->nbuffers; i++) {
+ if (((parity+1) & 1) && c->buffers[i].lock[0]) continue;
+ if (((parity+1) & 2) && c->buffers[i].lock[1]) continue;
+ alloc_buffer(c, &c->buffers[i]);
+ return pullup_lock_buffer(&c->buffers[i], parity);
+ }
- return 0;
+ return 0;
}
@@ -342,35 +342,35 @@ struct pullup_buffer *pullup_get_buffer(struct pullup_context *c, int parity)
static void compute_metric(struct pullup_context *c,
- struct pullup_field *fa, int pa,
- struct pullup_field *fb, int pb,
- int (*func)(unsigned char *, unsigned char *, int), int *dest)
+ struct pullup_field *fa, int pa,
+ struct pullup_field *fb, int pb,
+ int (*func)(unsigned char *, unsigned char *, int), int *dest)
{
- unsigned char *a, *b;
- int x, y;
- int mp = c->metric_plane;
- int xstep = c->bpp[mp];
- int ystep = c->stride[mp]<<3;
- int s = c->stride[mp]<<1; /* field stride */
- int w = c->metric_w*xstep;
+ unsigned char *a, *b;
+ int x, y;
+ int mp = c->metric_plane;
+ int xstep = c->bpp[mp];
+ int ystep = c->stride[mp]<<3;
+ int s = c->stride[mp]<<1; /* field stride */
+ int w = c->metric_w*xstep;
- if (!fa->buffer || !fb->buffer) return;
+ if (!fa->buffer || !fb->buffer) return;
- /* Shortcut for duplicate fields (e.g. from RFF flag) */
- if (fa->buffer == fb->buffer && pa == pb) {
- memset(dest, 0, c->metric_len * sizeof(int));
- return;
- }
+ /* Shortcut for duplicate fields (e.g. from RFF flag) */
+ if (fa->buffer == fb->buffer && pa == pb) {
+ memset(dest, 0, c->metric_len * sizeof(int));
+ return;
+ }
- a = fa->buffer->planes[mp] + pa * c->stride[mp] + c->metric_offset;
- b = fb->buffer->planes[mp] + pb * c->stride[mp] + c->metric_offset;
+ a = fa->buffer->planes[mp] + pa * c->stride[mp] + c->metric_offset;
+ b = fb->buffer->planes[mp] + pb * c->stride[mp] + c->metric_offset;
- for (y = c->metric_h; y; y--) {
- for (x = 0; x < w; x += xstep) {
- *dest++ = func(a + x, b + x, s);
- }
- a += ystep; b += ystep;
- }
+ for (y = c->metric_h; y; y--) {
+ for (x = 0; x < w; x += xstep) {
+ *dest++ = func(a + x, b + x, s);
+ }
+ a += ystep; b += ystep;
+ }
}
@@ -379,67 +379,67 @@ static void compute_metric(struct pullup_context *c,
static void alloc_metrics(struct pullup_context *c, struct pullup_field *f)
{
- f->diffs = calloc(c->metric_len, sizeof(int));
- f->comb = calloc(c->metric_len, sizeof(int));
- f->var = calloc(c->metric_len, sizeof(int));
- /* add more metrics here as needed */
+ f->diffs = calloc(c->metric_len, sizeof(int));
+ f->comb = calloc(c->metric_len, sizeof(int));
+ f->var = calloc(c->metric_len, sizeof(int));
+ /* add more metrics here as needed */
}
static struct pullup_field *make_field_queue(struct pullup_context *c, int len)
{
- struct pullup_field *head, *f;
- f = head = calloc(1, sizeof(struct pullup_field));
- alloc_metrics(c, f);
- for (; len > 0; len--) {
- f->next = calloc(1, sizeof(struct pullup_field));
- f->next->prev = f;
- f = f->next;
- alloc_metrics(c, f);
- }
- f->next = head;
- head->prev = f;
- return head;
+ struct pullup_field *head, *f;
+ f = head = calloc(1, sizeof(struct pullup_field));
+ alloc_metrics(c, f);
+ for (; len > 0; len--) {
+ f->next = calloc(1, sizeof(struct pullup_field));
+ f->next->prev = f;
+ f = f->next;
+ alloc_metrics(c, f);
+ }
+ f->next = head;
+ head->prev = f;
+ return head;
}
static void check_field_queue(struct pullup_context *c)
{
- if (c->head->next == c->first) {
- struct pullup_field *f = calloc(1, sizeof(struct pullup_field));
- alloc_metrics(c, f);
- f->prev = c->head;
- f->next = c->first;
- c->head->next = f;
- c->first->prev = f;
- }
+ if (c->head->next == c->first) {
+ struct pullup_field *f = calloc(1, sizeof(struct pullup_field));
+ alloc_metrics(c, f);
+ f->prev = c->head;
+ f->next = c->first;
+ c->head->next = f;
+ c->first->prev = f;
+ }
}
void pullup_submit_field(struct pullup_context *c, struct pullup_buffer *b,
int parity, double pts)
{
- struct pullup_field *f;
+ struct pullup_field *f;
- /* Grow the circular list if needed */
- check_field_queue(c);
+ /* Grow the circular list if needed */
+ check_field_queue(c);
- /* Cannot have two fields of same parity in a row; drop the new one */
- if (c->last && c->last->parity == parity) return;
+ /* Cannot have two fields of same parity in a row; drop the new one */
+ if (c->last && c->last->parity == parity) return;
- f = c->head;
- f->parity = parity;
- f->buffer = pullup_lock_buffer(b, parity);
- f->flags = 0;
- f->breaks = 0;
- f->affinity = 0;
- f->pts = pts;
+ f = c->head;
+ f->parity = parity;
+ f->buffer = pullup_lock_buffer(b, parity);
+ f->flags = 0;
+ f->breaks = 0;
+ f->affinity = 0;
+ f->pts = pts;
- 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->comb, f->comb);
- compute_metric(c, f, parity, f, -1, c->var, f->var);
+ 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->comb, f->comb);
+ compute_metric(c, f, parity, f, -1, c->var, f->var);
- /* Advance the circular list */
- if (!c->first) c->first = c->head;
- c->last = c->head;
- c->head = c->head->next;
+ /* Advance the circular list */
+ if (!c->first) c->first = c->head;
+ c->last = c->head;
+ c->head = c->head->next;
}
@@ -457,175 +457,175 @@ void pullup_submit_field(struct pullup_context *c, struct pullup_buffer *b,
static int queue_length(struct pullup_field *begin, struct pullup_field *end)
{
- int count = 1;
- struct pullup_field *f;
+ int count = 1;
+ struct pullup_field *f;
- if (!begin || !end) return 0;
- for (f = begin; f != end; f = f->next) count++;
- return count;
+ if (!begin || !end) return 0;
+ for (f = begin; f != end; f = f->next) count++;
+ return count;
}
static int find_first_break(struct pullup_field *f, int max)
{
- int i;
- for (i = 0; i < max; i++) {
- if (f->breaks & BREAK_RIGHT || f->next->breaks & BREAK_LEFT)
- return i+1;
- f = f->next;
- }
- return 0;
+ int i;
+ for (i = 0; i < max; i++) {
+ if (f->breaks & BREAK_RIGHT || f->next->breaks & BREAK_LEFT)
+ return i+1;
+ f = f->next;
+ }
+ return 0;
}
static void compute_breaks(struct pullup_context *c, struct pullup_field *f0)
{
- int i;
- struct pullup_field *f1 = f0->next;
- struct pullup_field *f2 = f1->next;
- struct pullup_field *f3 = f2->next;
- int l, max_l=0, max_r=0;
- //struct pullup_field *ff;
- //for (i=0, ff=c->first; ff != f0; i++, ff=ff->next);
-
- if (f0->flags & F_HAVE_BREAKS) return;
- //printf("\n%d: ", i);
- f0->flags |= F_HAVE_BREAKS;
-
- /* Special case when fields are 100% identical */
- if (f0->buffer == f2->buffer && f1->buffer != f3->buffer) {
- f2->breaks |= BREAK_RIGHT;
- return;
- }
- if (f0->buffer != f2->buffer && f1->buffer == f3->buffer) {
- f1->breaks |= BREAK_LEFT;
- return;
- }
-
- for (i = 0; i < c->metric_len; i++) {
- l = f2->diffs[i] - f3->diffs[i];
- if (l > max_l) max_l = l;
- if (-l > max_r) max_r = -l;
- }
- /* Don't get tripped up when differences are mostly quant error */
- //printf("%d %d\n", max_l, max_r);
- if (max_l + max_r < 128) return;
- if (max_l > 4*max_r) f1->breaks |= BREAK_LEFT;
- if (max_r > 4*max_l) f2->breaks |= BREAK_RIGHT;
+ int i;
+ struct pullup_field *f1 = f0->next;
+ struct pullup_field *f2 = f1->next;
+ struct pullup_field *f3 = f2->next;
+ int l, max_l=0, max_r=0;
+ //struct pullup_field *ff;
+ //for (i=0, ff=c->first; ff != f0; i++, ff=ff->next);
+
+ if (f0->flags & F_HAVE_BREAKS) return;
+ //printf("\n%d: ", i);
+ f0->flags |= F_HAVE_BREAKS;
+
+ /* Special case when fields are 100% identical */
+ if (f0->buffer == f2->buffer && f1->buffer != f3->buffer) {
+ f2->breaks |= BREAK_RIGHT;
+ return;
+ }
+ if (f0->buffer != f2->buffer && f1->buffer == f3->buffer) {
+ f1->breaks |= BREAK_LEFT;
+ return;
+ }
+
+ for (i = 0; i < c->metric_len; i++) {
+ l = f2->diffs[i] - f3->diffs[i];
+ if (l > max_l) max_l = l;
+ if (-l > max_r) max_r = -l;
+ }
+ /* Don't get tripped up when differences are mostly quant error */
+ //printf("%d %d\n", max_l, max_r);
+ if (max_l + max_r < 128) return;
+ if (max_l > 4*max_r) f1->breaks |= BREAK_LEFT;
+ if (max_r > 4*max_l) f2->breaks |= BREAK_RIGHT;
}
static void compute_affinity(struct pullup_context *c, struct pullup_field *f)
{
- int i;
- int max_l=0, max_r=0, l;
- if (f->flags & F_HAVE_AFFINITY) return;
- f->flags |= F_HAVE_AFFINITY;
- if (f->buffer == f->next->next->buffer) {
- f->affinity = 1;
- f->next->affinity = 0;
- f->next->next->affinity = -1;
- f->next->flags |= F_HAVE_AFFINITY;
- f->next->next->flags |= F_HAVE_AFFINITY;
- return;
- }
- if (1) {
- for (i = 0; i < c->metric_len; i++) {
- int lv = f->prev->var[i];
- int rv = f->next->var[i];
- int v = f->var[i];
- int lc = f->comb[i] - (v+lv) + ABS(v-lv);
- int rc = f->next->comb[i] - (v+rv) + ABS(v-rv);
- lc = lc>0 ? lc : 0;
- rc = rc>0 ? rc : 0;
- l = lc - rc;
- if (l > max_l) max_l = l;
- if (-l > max_r) max_r = -l;
- }
- if (max_l + max_r < 64) return;
- if (max_r > 6*max_l) f->affinity = -1;
- else if (max_l > 6*max_r) f->affinity = 1;
- } else {
- for (i = 0; i < c->metric_len; 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;
- if (max_r > 2*max_l) f->affinity = -1;
- else if (max_l > 2*max_r) f->affinity = 1;
- }
+ int i;
+ int max_l=0, max_r=0, l;
+ if (f->flags & F_HAVE_AFFINITY) return;
+ f->flags |= F_HAVE_AFFINITY;
+ if (f->buffer == f->next->next->buffer) {
+ f->affinity = 1;
+ f->next->affinity = 0;
+ f->next->next->affinity = -1;
+ f->next->flags |= F_HAVE_AFFINITY;
+ f->next->next->flags |= F_HAVE_AFFINITY;
+ return;
+ }
+ if (1) {
+ for (i = 0; i < c->metric_len; i++) {
+ int lv = f->prev->var[i];
+ int rv = f->next->var[i];
+ int v = f->var[i];
+ int lc = f->comb[i] - (v+lv) + ABS(v-lv);
+ int rc = f->next->comb[i] - (v+rv) + ABS(v-rv);
+ lc = lc>0 ? lc : 0;
+ rc = rc>0 ? rc : 0;
+ l = lc - rc;
+ if (l > max_l) max_l = l;
+ if (-l > max_r) max_r = -l;
+ }
+ if (max_l + max_r < 64) return;
+ if (max_r > 6*max_l) f->affinity = -1;
+ else if (max_l > 6*max_r) f->affinity = 1;
+ } else {
+ for (i = 0; i < c->metric_len; 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;
+ if (max_r > 2*max_l) f->affinity = -1;
+ else if (max_l > 2*max_r) f->affinity = 1;
+ }
}
static void foo(struct pullup_context *c)
{
- struct pullup_field *f = c->first;
- int i, n = queue_length(f, c->last);
- for (i = 0; i < n-1; i++) {
- if (i < n-3) compute_breaks(c, f);
- compute_affinity(c, f);
- f = f->next;
- }
+ struct pullup_field *f = c->first;
+ int i, n = queue_length(f, c->last);
+ for (i = 0; i < n-1; i++) {
+ if (i < n-3) compute_breaks(c, f);
+ compute_affinity(c, f);
+ f = f->next;
+ }
}
static int decide_frame_length(struct pullup_context *c)
{
- struct pullup_field *f0 = c->first;
- struct pullup_field *f1 = f0->next;
- struct pullup_field *f2 = f1->next;
- int l;
-
- if (queu