aboutsummaryrefslogtreecommitdiffhomepage
path: root/video/filter
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2014-04-13 18:00:51 +0200
committerGravatar wm4 <wm4@nowhere>2014-04-13 18:03:01 +0200
commit78128bddda4bcea1f256fc13cc33fa2652ed277c (patch)
tree35bf6596cb8e2d7927618845833c3ee36534f890 /video/filter
parent44f382cf98564c0fe08bdc78579c284362cd6f3c (diff)
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 (queue_length(c->first, c->last) < 4) return 0;
- foo(c);
-
- if (f0->affinity == -1) return 1;
-
- l = find_first_break(f0, 3);
- if (l == 1 && c->strict_breaks < 0) l = 0;
-
- switch (l) {
- case 1:
- if (c->strict_breaks < 1 && f0->affinity == 1 && f1->affinity == -1)
- return 2;
- else return 1;
- case 2:
- /* FIXME: strictly speaking, f0->prev is no longer valid... :) */
- if (c->strict_pairs
- && (f0->prev->breaks & BREAK_RIGHT) && (f2->breaks & BREAK_LEFT)
- && (f0->affinity != 1 || f1->affinity != -1) )
- return 1;
- if (f1->affinity == 1) return 1;
- else return 2;
- case 3:
- if (f2->affinity == 1) return 2;
- else return 3;
- default:
- /* 9 possibilities covered before switch */
- if (f1->affinity == 1) return 1; /* covers 6 */
- else if (f1->affinity == -1) return 2; /* covers 6 */
- else if (f2->affinity == -1) { /* covers 2 */
- if (f0->affinity == 1) return 3;
- else return 1;
- }
- else return 2; /* the remaining 6 */
- }
+ struct pullup_field *f0 = c->first;
+ struct pullup_field *f1 = f0->next;
+ struct pullup_field *f2 = f1->next;
+ int l;
+
+ if (queue_length(c->first, c->last) < 4) return 0;
+ foo(c);
+
+ if (f0->affinity == -1) return 1;
+
+ l = find_first_break(f0, 3);
+ if (l == 1 && c->strict_breaks < 0) l = 0;
+
+ switch (l) {
+ case 1:
+ if (c->strict_breaks < 1 && f0->affinity == 1 && f1->affinity == -1)
+ return 2;
+ else return 1;
+ case 2:
+ /* FIXME: strictly speaking, f0->prev is no longer valid... :) */
+ if (c->strict_pairs
+ && (f0->prev->breaks & BREAK_RIGHT) && (f2->breaks & BREAK_LEFT)
+ && (f0->affinity != 1 || f1->affinity != -1) )
+ return 1;
+ if (f1->affinity == 1) return 1;
+ else return 2;
+ case 3:
+ if (f2->affinity == 1) return 2;
+ else return 3;
+ default:
+ /* 9 possibilities covered before switch */
+ if (f1->affinity == 1) return 1; /* covers 6 */
+ else if (f1->affinity == -1) return 2; /* covers 6 */
+ else if (f2->affinity == -1) { /* covers 2 */
+ if (f0->affinity == 1) return 3;
+ else return 1;
+ }
+ else return 2; /* the remaining 6 */
+ }
}
static void print_aff_and_breaks(struct pullup_context *c, struct pullup_field *f)
{
- int i;
- struct pullup_field *f0 = f;
- const char aff_l[] = "+..", aff_r[] = "..+";
- printf("\naffinity: ");
- for (i = 0; i < 4; i++) {
- printf("%c%d%c", aff_l[1+f->affinity], i, aff_r[1+f->affinity]);
- f = f->next;
- }
- f = f0;
- printf("\nbreaks: ");
- for (i=0; i<4; i++) {
- printf("%c%d%c", f->breaks & BREAK_LEFT ? '|' : '.', i, f->breaks & BREAK_RIGHT ? '|' : '.');
- f = f->next;
- }
- printf("\n");
+ int i;
+ struct pullup_field *f0 = f;
+ const char aff_l[] = "+..", aff_r[] = "..+";
+ printf("\naffinity: ");
+ for (i = 0; i < 4; i++) {
+ printf("%c%d%c", aff_l[1+f->affinity], i, aff_r[1+f->affinity]);
+ f = f->next;
+ }
+ f = f0;
+ printf("\nbreaks: ");
+ for (i=0; i<4; i++) {
+ printf("%c%d%c", f->breaks & BREAK_LEFT ? '|' : '.', i, f->breaks & BREAK_RIGHT ? '|' : '.');
+ f = f->next;
+ }
+ printf("\n");
}
@@ -634,104 +634,104 @@ static void print_aff_and_breaks(struct pullup_context *c, struct pullup_field *
struct pullup_frame *pullup_get_frame(struct pullup_context *c)
{
- int i;
- struct pullup_frame *fr = c->frame;
- int n = decide_frame_length(c);
- int aff = c->first->next->affinity;
-
- if (!n) return 0;
- if (fr->lock) return 0;
-
- if (c->verbose) {
- print_aff_and_breaks(c, c->first);
- printf("duration: %d \n", n);
- }
-
- fr->lock++;
- fr->length = n;
- fr->parity = c->first->parity;
- fr->buffer = 0;
- fr->pts = 0;
- for (i = 0; i < n; i++) {
- /* We cheat and steal the buffer without release+relock */
- fr->ifields[i] = c->first->buffer;
- c->first->buffer = 0;
- if (c->first->pts == MP_NOPTS_VALUE || fr->pts == MP_NOPTS_VALUE)
- fr->pts = MP_NOPTS_VALUE;
- else
- fr->pts += c->first->pts;
- c->first = c->first->next;
- }
- if (fr->pts != MP_NOPTS_VALUE)
- fr->pts /= n;
-
- if (n == 1) {
- fr->ofields[fr->parity] = fr->ifields[0];
- fr->ofields[fr->parity^1] = 0;
- } else if (n == 2) {
- fr->ofields[fr->parity] = fr->ifields[0];
- fr->ofields[fr->parity^1] = fr->ifields[1];
- } else if (n == 3) {
- if (aff == 0)
- aff = (fr->ifields[0] == fr->ifields[1]) ? -1 : 1;
- /* else if (c->verbose) printf("forced aff: %d \n", aff); */
- fr->ofields[fr->parity] = fr->ifields[1+aff];
- fr->ofields[fr->parity^1] = fr->ifields[1];
- }
- pullup_lock_buffer(fr->ofields[0], 0);
- pullup_lock_buffer(fr->ofields[1], 1);
-
- if (fr->ofields[0] == fr->ofields[1]) {
- fr->buffer = fr->ofields[0];
- pullup_lock_buffer(fr->buffer, 2);
- return fr;
- }
- return fr;
+ int i;
+ struct pullup_frame *fr = c->frame;
+ int n = decide_frame_length(c);
+ int aff = c->first->next->affinity;
+
+ if (!n) return 0;
+ if (fr->lock) return 0;
+
+ if (c->verbose) {
+ print_aff_and_breaks(c, c->first);
+ printf("duration: %d \n", n);
+ }
+
+ fr->lock++;
+ fr->length = n;
+ fr->parity = c->first->parity;
+ fr->buffer = 0;
+ fr->pts = 0;
+ for (i = 0; i < n; i++) {
+ /* We cheat and steal the buffer without release+relock */
+ fr->ifields[i] = c->first->buffer;
+ c->first->buffer = 0;
+ if (c->first->pts == MP_NOPTS_VALUE || fr->pts == MP_NOPTS_VALUE)
+ fr->pts = MP_NOPTS_VALUE;
+ else
+ fr->pts += c->first->pts;
+ c->first = c->first->next;
+ }
+ if (fr->pts != MP_NOPTS_VALUE)
+ fr->pts /= n;
+
+ if (n == 1) {
+ fr->ofields[fr->parity] = fr->ifields[0];
+ fr->ofields[fr->parity^1] = 0;
+ } else if (n == 2) {
+ fr->ofields[fr->parity] = fr->ifields[0];
+ fr->ofields[fr->parity^1] = fr->ifields[1];
+ } else if (n == 3) {
+ if (aff == 0)
+ aff = (fr->ifields[0] == fr->ifields[1]) ? -1 : 1;
+ /* else if (c->verbose) printf("forced aff: %d \n", aff); */
+ fr->ofields[fr->parity] = fr->ifields[1+aff];
+ fr->ofields[fr->parity^1] = fr->ifields[1];
+ }
+ pullup_lock_buffer(fr->ofields[0], 0);
+ pullup_lock_buffer(fr->ofields[1], 1);
+
+ if (fr->ofields[0] == fr->ofields[1]) {
+ fr->buffer = fr->ofields[0];
+ pullup_lock_buffer(fr->buffer, 2);
+ return fr;
+ }
+ return fr;
}
static void copy_field(struct pullup_context *c, struct pullup_buffer *dest,
- struct pullup_buffer *src, int parity)
+ struct pullup_buffer *src, int parity)
{
- int i, j;
- unsigned char *d, *s;
- for (i = 0; i < c->nplanes; i++) {
- s = src->planes[i] + parity*c->stride[i];
- d = dest->planes[i] + parity*c->stride[i];
- for (j = c->h[i]>>1; j; j--) {
- memcpy(d, s, c->stride[i]);
- s += c->stride[i]<<1;
- d += c->stride[i]<<1;
- }
- }
+ int i, j;
+ unsigned char *d, *s;
+ for (i = 0; i < c->nplanes; i++) {
+ s = src->planes[i] + parity*c->stride[i];
+ d = dest->planes[i] + parity*c->stride[i];
+ for (j = c->h[i]>>1; j; j--) {
+ memcpy(d, s, c->stride[i]);
+ s += c->stride[i]<<1;
+ d += c->stride[i]<<1;
+ }
+ }
}
void pullup_pack_frame(struct pullup_context *c, struct pullup_frame *fr)
{
- int i;
- if (fr->buffer) return;
- if (fr->length < 2) return; /* FIXME: deal with this */
- for (i = 0; i < 2; i++)
- {
- if (fr->ofields[i]->lock[i^1]) continue;
- fr->buffer = fr->ofields[i];
- pullup_lock_buffer(fr->buffer, 2);
- copy_field(c, fr->buffer, fr->ofields[i^1], i^1);
- return;
- }
- fr->buffer = pullup_get_buffer(c, 2);
- copy_field(c, fr->buffer, fr->ofields[0], 0);
- copy_field(c, fr->buffer, fr->ofields[1], 1);
+ int i;
+ if (fr->buffer) return;
+ if (fr->length < 2) return; /* FIXME: deal with this */
+ for (i = 0; i < 2; i++)
+ {
+ if (fr->ofields[i]->lock[i^1]) continue;
+ fr->buffer = fr->ofields[i];
+ pullup_lock_buffer(fr->buffer, 2);
+ copy_field(c, fr->buffer, fr->ofields[i^1], i^1);
+ return;
+ }
+ fr->buffer = pullup_get_buffer(c, 2);
+ copy_field(c, fr->buffer, fr->ofields[0], 0);
+ copy_field(c, fr->buffer, fr->ofields[1], 1);
}
void pullup_release_frame(struct pullup_frame *fr)
{
- int i;
- for (i = 0; i < fr->length; i++)
- pullup_release_buffer(fr->ifields[i], fr->parity ^ (i&1));
- pullup_release_buffer(fr->ofields[0], 0);
- pullup_release_buffer(fr->ofields[1], 1);
- if (fr->buffer) pullup_release_buffer(fr->buffer, 2);
- fr->lock--;
+ int i;
+ for (i = 0; i < fr->length; i++)
+ pullup_release_buffer(fr->ifields[i], fr->parity ^ (i&1));
+ pullup_release_buffer(fr->ofields[0], 0);
+ pullup_release_buffer(fr->ofields[1], 1);
+ if (fr->buffer) pullup_release_buffer(fr->buffer, 2);
+ fr->lock--;
}
@@ -741,77 +741,77 @@ void pullup_release_frame(struct pullup_frame *fr)
struct pullup_context *pullup_alloc_context(void)
{
- struct pullup_context *c;
+ struct pullup_context *c;
- c = calloc(1, sizeof(struct pullup_context));
+ c = calloc(1, sizeof(struct pullup_context));
- return c;
+ return c;
}
void pullup_preinit_context(struct pullup_context *c)
{
- c->bpp = calloc(c->nplanes, sizeof(int));
- c->w = calloc(c->nplanes, sizeof(int));
- c->h = calloc(c->nplanes, sizeof(int));
- c->stride = calloc(c->nplanes, sizeof(int));
- c->background = calloc(c->nplanes, sizeof(int));
+ c->bpp = calloc(c->nplanes, sizeof(int));
+ c->w = calloc(c->nplanes, sizeof(int));
+ c->h = calloc(c->nplanes, sizeof(int));
+ c->stride = calloc(c->nplanes, sizeof(int));
+ c->background = calloc(c->nplanes, sizeof(int));
}
void pullup_init_context(struct pullup_context *c)
{
- int mp = c->metric_plane;
- if (c->nbuffers < 10) c->nbuffers = 10;
- c->buffers = calloc(c->nbuffers, sizeof (struct pullup_buffer));
+ int mp = c->metric_plane;
+ if (c->nbuffers < 10) c->nbuffers = 10;
+ c->buffers = calloc(c->nbuffers, sizeof (struct pullup_buffer));
- c->metric_w = (c->w[mp] - ((c->junk_left + c->junk_right) << 3)) >> 3;
- c->metric_h = (c->h[mp] - ((c->junk_top + c->junk_bottom) << 1)) >> 3;
- c->metric_offset = c->junk_left*c->bpp[mp] + (c->junk_top<<1)*c->stride[mp];
- c->metric_len = c->metric_w * c->metric_h;
+ c->metric_w = (c->w[mp] - ((c->junk_left + c->junk_right) << 3)) >> 3;
+ c->metric_h = (c->h[mp] - ((c->junk_top + c->junk_bottom) << 1)) >> 3;
+ c->metric_offset = c->junk_left*c->bpp[mp] + (c->junk_top<<1)*c->stride[mp];
+ c->metric_len = c->metric_w * c->metric_h;
- c->head = make_field_queue(c, 8);
+ c->head = make_field_queue(c, 8);
- c->frame = calloc(1, sizeof (struct pullup_frame));
- c->frame->ifields = calloc(3, sizeof (struct pullup_buffer *));
+ c->frame = calloc(1, sizeof (struct pullup_frame));
+ c->frame->ifields = calloc(3, sizeof (struct pullup_buffer *));
- switch(c->format) {
- case PULLUP_FMT_Y:
- c->diff = diff_y;
- c->comb = licomb_y;
- c->var = var_y;
+ switch(c->format) {
+ case PULLUP_FMT_Y:
+ c->diff = diff_y;
+ c->comb = licomb_y;
+ c->var = var_y;
#if ARCH_X86
#if HAVE_MMX
- if (c->cpu & PULLUP_CPU_MMX) {
- c->diff = diff_y_mmx;
- c->comb = licomb_y_mmx;
- c->var = var_y_mmx;
- }
+ if (c->cpu & PULLUP_CPU_MMX) {
+ c->diff = diff_y_mmx;
+ c->comb = licomb_y_mmx;
+ c->var = var_y_mmx;
+ }
#endif
#endif
- /* c->comb = qpcomb_y; */
- break;
+ /* c->comb = qpcomb_y; */
+ break;
#if 0
- case PULLUP_FMT_YUY2:
- c->diff = diff_yuy2;
- break;
- case PULLUP_FMT_RGB32:
- c->diff = diff_rgb32;
- break;
+ case PULLUP_FMT_YUY2:
+ c->diff = diff_yuy2;
+ break;
+ case PULLUP_FMT_RGB32:
+ c->diff = diff_rgb32;
+ break;
#endif
- }
+ }
}
void pullup_free_context(struct pullup_context *c)
{
- struct pullup_field *f;
- free(c->buffers);
- f = c->head;
- do {
- if (!f) break;
- free(f->diffs);
- free(f->comb);
- f = f->next;
- free(f->prev);
- } while (f != c->head);
- free(c->frame);
- free(c);
+ struct pullup_field *f;
+ free(c->buffers);
+ f = c->head;
+ do {
+ if (!f) break;
+ free(f->diffs);
+ free(f->comb);
+ f = f->next;
+ free(f->prev);
+ } while (f != c->head);
+ free(c->frame);
+ free(c);
}
diff --git a/video/filter/pullup.h b/video/filter/pullup.h
index 0948737919..da94539e9a 100644
--- a/video/filter/pullup.h
+++ b/video/filter/pullup.h
@@ -31,55 +31,55 @@
struct pullup_buffer
{
- int lock[2];
- unsigned char **planes;
+ int lock[2];
+ unsigned char **planes;
};
struct pullup_field
{
- int parity;
- double pts;
- struct pullup_buffer *buffer;
- unsigned int flags;
- int breaks;
- int affinity;
- int *diffs;
- int *comb;
- int *var;
- struct pullup_field *prev, *next;
+ int parity;
+ double pts;
+ struct pullup_buffer *buffer;
+ unsigned int flags;
+ int breaks;
+ int affinity;
+ int *diffs;
+ int *comb;
+ int *var;
+ struct pullup_field *prev, *next;
};
struct pullup_frame
{
- int lock;
- int length;
- int parity;
- double pts;
- struct pullup_buffer **ifields, *ofields[2];
- struct pullup_buffer *buffer;
+ int lock;
+ int length;
+ int parity;
+ double pts;
+ struct pullup_buffer **ifields, *ofields[2];
+ struct pullup_buffer *buffer;
};
struct pullup_context
{
- /* Public interface */
- int format;
- int nplanes;
- int *bpp, *w, *h, *stride, *background;
- unsigned int cpu;
- int junk_left, junk_right, junk_top, junk_bottom;
- int verbose;
- int metric_plane;
- int strict_breaks;
- int strict_pairs;
- /* Internal data */
- struct pullup_field *first, *last, *head;
- struct pullup_buffer *buffers;
- int nbuffers;
- int (*diff)(unsigned char *, unsigned char *, int);
- int (*comb)(unsigned char *, unsigned char *, int);
- int (*var)(unsigned char *, unsigned char *, int);
- int metric_w, metric_h, metric_len, metric_offset;
- struct pullup_frame *frame;
+ /* Public interface */
+ int format;
+ int nplanes;
+ int *bpp, *w, *h, *stride, *background;
+ unsigned int cpu;
+ int junk_left, junk_right, junk_top, junk_bottom;
+ int verbose;
+ int metric_plane;
+ int strict_breaks;
+ int strict_pairs;
+ /* Internal data */
+ struct pullup_field *first, *last, *head;
+ struct pullup_buffer *buffers;
+ int nbuffers;
+ int (*diff)(unsigned char *, unsigned char *, int);
+ int (*comb)(unsigned char *, unsigned char *, int);
+ int (*var)(unsigned char *, unsigned char *, int);
+ int metric_w, metric_h, metric_len, metric_offset;
+ struct pullup_frame *frame;
};
diff --git a/video/filter/vf_crop.c b/video/filter/vf_crop.c
index 186c710d9f..23b44e0e5a 100644
--- a/video/filter/vf_crop.c
+++ b/video/filter/vf_crop.c
@@ -42,7 +42,7 @@ static const struct vf_priv_s {
static int config(struct vf_instance *vf,
int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt)
+ unsigned int flags, unsigned int outfmt)
{
// calculate the missing parameters:
if(vf->priv->crop_w<=0 || vf->priv->crop_w>width) vf->priv->crop_w=width;
@@ -59,8 +59,8 @@ static int config(struct vf_instance *vf,
// check:
if(vf->priv->crop_w+vf->priv->crop_x>width ||
vf->priv->crop_h+vf->priv->crop_y>height){
- MP_WARN(vf, "[CROP] Bad position/width/height - cropped area outside of the original!\n");
- return 0;
+ MP_WARN(vf, "[CROP] Bad position/width/height - cropped area outside of the original!\n");
+ return 0;
}
vf_rescale_dsize(&d_width, &d_height, width, height,
vf->priv->crop_w, vf->priv->crop_h);
diff --git a/video/filter/vf_divtc.c b/video/filter/vf_divtc.c
index a27f73b3ee..56901f6870 100644
--- a/video/filter/vf_divtc.c
+++ b/video/filter/vf_divtc.c
@@ -60,39 +60,39 @@ static int diff_MMX(unsigned char *old, unsigned char *new, int os, int ns)
{
volatile short out[4];
__asm__ (
- "movl $8, %%ecx \n\t"
- "pxor %%mm4, %%mm4 \n\t"
- "pxor %%mm7, %%mm7 \n\t"
-
- ".align 4 \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_b", %%"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, (%%"REG_d") \n\t"
- "emms \n\t"
- :
- : "S" (old), "D" (new), "a" ((long)os), "b" ((long)ns), "d" (out)
- : "%ecx", "memory"
- );
+ "movl $8, %%ecx \n\t"
+ "pxor %%mm4, %%mm4 \n\t"
+ "pxor %%mm7, %%mm7 \n\t"
+
+ ".align 4 \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_b", %%"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, (%%"REG_d") \n\t"
+ "emms \n\t"
+ :
+ : "S" (old), "D" (new), "a" ((long)os), "b" ((long)ns), "d" (out)
+ : "%ecx", "memory"
+ );
return out[0]+out[1]+out[2]+out[3];
}
#endif
@@ -103,7 +103,7 @@ static int diff_C(unsigned char *old, unsigned char *new, int os, int ns)
for(y=8; y; y--, new+=ns, old+=os)
for(x=8; x; x--)
- d+=abs(new[x]-old[x]);
+ d+=abs(new[x]-old[x]);
return d;
}
@@ -111,19 +111,19 @@ static int diff_C(unsigned char *old, unsigned char *new, int os, int ns)
static int (*diff)(unsigned char *, unsigned char *, int, int);
static int diff_plane(unsigned char *old, unsigned char *new,
- int w, int h, int os, int ns, int arg)
+ int w, int h, int os, int ns, int arg)
{
int x, y, d, max=0, sum=0, n=0;
for(y=0; y<h-7; y+=8)
{
for(x=0; x<w-7; x+=8)
- {
- d=diff(old+x+y*os, new+x+y*ns, os, ns);
- if(d>max) max=d;
- sum+=d;
- n++;
- }
+ {
+ d=diff(old+x+y*os, new+x+y*ns, os, ns);
+ if(d>max) max=d;
+ sum+=d;
+ n++;
+ }
}
return (sum+n*max)/2;
@@ -131,21 +131,21 @@ static int diff_plane(unsigned char *old, unsigned char *new,
/*
static unsigned int checksum_plane(unsigned char *p, unsigned char *z,
- int w, int h, int s, int zs, int arg)
+ int w, int h, int s, int zs, int arg)
{
unsigned int shift, sum;
unsigned char *e;
for(sum=0; h; h--, p+=s-w)
for(e=p+w, shift=32; p<e;)
- sum^=(*p++)<<(shift=(shift-8)&31);
+ sum^=(*p++)<<(shift=(shift-8)&31);
return sum;
}
*/
static unsigned int checksum_plane(unsigned char *p, unsigned char *z,
- int w, int h, int s, int zs, int arg)
+ int w, int h, int s, int zs, int arg)
{
unsigned int shift;
uint32_t sum, t;
@@ -160,10 +160,10 @@ static unsigned int checksum_plane(unsigned char *p, unsigned char *z,
for(sum=0; h; h--, p+=s-w)
{
for(shift=0, e=p+w; (size_t)p&(sizeof(wsum_t)-1) && p<e;)
- sum^=*p++<<(shift=(shift-8)&31);
+ sum^=*p++<<(shift=(shift-8)&31);
for(wsum=0, e2=e-sizeof(wsum_t)+1; p<e2; p+=sizeof(wsum_t))
- wsum^=*(wsum_t *)p;
+ wsum^=*(wsum_t *)p;
#if HAVE_FAST_64BIT
t=be2me_32((uint32_t)(wsum>>32^wsum));
@@ -172,22 +172,22 @@ static unsigned int checksum_plane(unsigned char *p, unsigned char *z,
#endif
for(sum^=(t<<shift|t>>(32-shift)); p<e;)
- sum^=*p++<<(shift=(shift-8)&31);
+ sum^=*p++<<(shift=(shift-8)&31);
}
return sum;
}
static int deghost_plane(unsigned char *d, unsigned char *s,
- int w, int h, int ds, int ss, int threshold)
+ int w, int h, int ds, int ss, int threshold)
{
int t;
unsigned char *e;
for(; h; h--, s+=ss-w, d+=ds-w)
for(e=d+w; d<e; d++, s++)
- if(abs(*d-*s)>=threshold)
- *d=(t=(*d<<1)-*s)<0?0:t>255?255:t;
+ if(abs(*d-*s)>=threshold)
+ *d=(t=(*d<<1)-*s)<0?0:t>255?255:t;
return 0;
}
@@ -198,8 +198,8 @@ static int copyop(unsigned char *d, unsigned char *s, int bpl, int h, int dstrid
}
static int imgop(int(*planeop)(unsigned char *, unsigned char *,
- int, int, int, int, int),
- mp_image_t *dst, mp_image_t *src, int arg)
+ int, int, int, int, int),
+ mp_image_t *dst, mp_image_t *src, int arg)
{
int sum = 0;
for (int p = 0; p < dst->num_planes; p++) {
@@ -220,7 +220,7 @@ static int imgop(int(*planeop)(unsigned char *, unsigned char *,
*/
static int match(struct vf_priv_s *p, int *diffs,
- int phase1, int phase2, double *strength)
+ int phase1, int phase2, double *strength)
{
const int pattern1[]={ -4, 1, 1, 1, 1 },
pattern2[]={ -2, -3, 4, 4, -3 }, *pattern;
@@ -231,12 +231,12 @@ static int match(struct vf_priv_s *p, int *diffs,
for(f=0; f<5; f++)
{
if(phase1<0 || phase2<0 || f==phase1 || f==phase2)
- {
- for(n=t[f]=0; n<5; n++)
- t[f]+=diffs[n]*pattern[(n-f+5)%5];
- }
+ {
+ for(n=t[f]=0; n<5; n++)
+ t[f]+=diffs[n]*pattern[(n-f+5)%5];
+ }
else
- t[f]=INT_MIN;
+ t[f]=INT_MIN;
}
/* find the best match */
@@ -247,7 +247,7 @@ static int match(struct vf_priv_s *p, int *diffs,
{
/* the second best match */
for(f=m?0:1, n=f+1; n<5; n++)
- if(n!=m && t[n]>t[f]) f=n;
+ if(n!=m && t[n]>t[f]) f=n;
*strength=(t[m]>0?(double)(t[m]-t[f])/t[m]:0.0);
}
@@ -278,70 +278,70 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
switch(p->pass)
{
case 1:
- fprintf(p->file, "%08x %d\n",
- (unsigned int)imgop((void *)checksum_plane, mpi, 0, 0),
- p->frameno?imgop(diff_plane, dmpi, mpi, 0):0);
- break;
+ fprintf(p->file, "%08x %d\n",
+ (unsigned int)imgop((void *)checksum_plane, mpi, 0, 0),
+ p->frameno?imgop(diff_plane, dmpi, mpi, 0):0);
+ break;
case 2:
- if(p->frameno/5>p->bcount)
- {
- MP_ERR(vf, "\n%s: Log file ends prematurely! "
- "Switching to one pass mode.\n", vf->info->name);
- p->pass=0;
- break;
- }
-
- checksum=(unsigned int)imgop((void *)checksum_plane, mpi, 0, 0);
-
- if(checksum!=p->csdata[p->frameno])
- {
- for(f=0; f<100; f++)
- if(p->frameno+f<p->fcount && p->csdata[p->frameno+f]==checksum)
- break;
- else if(p->frameno-f>=0 && p->csdata[p->frameno-f]==checksum)
- {
- f=-f;
- break;
- }
-
- if(f<100)
- {
- MP_INFO(vf, "\n%s: Mismatch with pass-1: %+d frame(s).\n",
- vf->info->name, f);
-
- p->frameno+=f;
- p->misscount=0;
- }
- else if(p->misscount++>=30)
- {
- MP_ERR(vf, "\n%s: Sync with pass-1 lost! "
- "Switching to one pass mode.\n", vf->info->name);
- p->pass=0;
- break;
- }
- }
-
- n=(p->frameno)/5;
- if(n>=p->bcount) n=p->bcount-1;
-
- newphase=p->bdata[n];
- break;
+ if(p->frameno/5>p->bcount)
+ {
+ MP_ERR(vf, "\n%s: Log file ends prematurely! "
+ "Switching to one pass mode.\n", vf->info->name);
+ p->pass=0;
+ break;
+ }
+
+ checksum=(unsigned int)imgop((void *)checksum_plane, mpi, 0, 0);
+
+ if(checksum!=p->csdata[p->frameno])
+ {
+ for(f=0; f<100; f++)
+ if(p->frameno+f<p->fcount && p->csdata[p->frameno+f]==checksum)
+ break;
+ else if(p->frameno-f>=0 && p->csdata[p->frameno-f]==checksum)
+ {
+ f=-f;
+ break;
+ }
+
+ if(f<100)
+ {
+ MP_INFO(vf, "\n%s: Mismatch with pass-1: %+d frame(s).\n",
+ vf->info->name, f);
+
+ p->frameno+=f;
+ p->misscount=0;
+ }
+ else if(p->misscount++>=30)
+ {
+ MP_ERR(vf, "\n%s: Sync with pass-1 lost! "
+ "Switching to one pass mode.\n", vf->info->name);
+ p->pass=0;
+ break;
+ }
+ }
+
+ n=(p->frameno)/5;
+ if(n>=p->bcount) n=p->bcount-1;
+
+ newphase=p->bdata[n];
+ break;
default:
- if(p->frameno)
- {
- int *sump=p->sum+p->frameno%5,
- *histp=p->history+p->frameno%p->window;
+ if(p->frameno)
+ {
+ int *sump=p->sum+p->frameno%5,
+ *histp=p->history+p->frameno%p->window;
- *sump-=*histp;
- *sump+=(*histp=imgop(diff_plane, dmpi, mpi, 0));
- }
+ *sump-=*histp;
+ *sump+=(*histp=imgop(diff_plane, dmpi, mpi, 0));
+ }
- m=match(p, p->sum, -1, -1, &d);
+ m=match(p, p->sum, -1, -1, &d);
- if(d>=p->threshold)
- newphase=m;
+ if(d>=p->threshold)
+ newphase=m;
}
n=p->ocount++%5;
@@ -355,21 +355,21 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
switch((p->frameno++-p->phase+10)%5)
{
case 0:
- imgop(copyop, dmpi, mpi, 0);
+ imgop(copyop, dmpi, mpi, 0);
vf_detc_adjust_pts(&p->ptsbuf, pts, 0, 1);
talloc_free(mpi);
- return 0;
+ return 0;
case 4:
- if(p->deghost>0)
- {
+ if(p->deghost>0)
+ {
imgop(copyop, dmpi, mpi, 0);
vf_make_out_image_writeable(vf, mpi);
- imgop(deghost_plane, mpi, dmpi, p->deghost);
+ imgop(deghost_plane, mpi, dmpi, p->deghost);
mpi->pts = vf_detc_adjust_pts(&p->ptsbuf, pts, 0, 0);
- return mpi;
- }
+ return mpi;
+ }
}
imgop(copyop, dmpi, mpi, 0);
@@ -393,20 +393,20 @@ static int analyze(struct vf_instance *vf)
while(fgets(lbuf, 256, p->file))
{
if(n>=bufsize-19)
- {
- bufsize=bufsize?bufsize*2:30000;
- if((bp=realloc(buf, bufsize*sizeof *buf))) buf=bp;
- if((cp=realloc(cbuf, bufsize*sizeof *cbuf))) cbuf=cp;
-
- if(!bp || !cp)
- {
- MP_FATAL(vf, "%s: Not enough memory.\n",
- vf_info_divtc.name);
- free(buf);
- free(cbuf);
- return 0;
- }
- }
+ {
+ bufsize=bufsize?bufsize*2:30000;
+ if((bp=realloc(buf, bufsize*sizeof *buf))) buf=bp;
+ if((cp=realloc(cbuf, bufsize*sizeof *cbuf))) cbuf=cp;
+
+ if(!bp || !cp)
+ {
+ MP_FATAL(vf, "%s: Not enough memory.\n",
+ vf_info_divtc.name);
+ free(buf);
+ free(cbuf);
+ return 0;
+ }
+ }
sscanf(lbuf, "%x %d", cbuf+n, buf+n);
n++;
}
@@ -414,7 +414,7 @@ static int analyze(struct vf_instance *vf)
if(n <= 15)
{
MP_FATAL(vf, "%s: Empty 2-pass log file.\n",
- vf_info_divtc.name);
+ vf_info_divtc.name);
free(buf);
free(cbuf);
return 0;
@@ -450,35 +450,35 @@ static int analyze(struct vf_instance *vf)
double s0=0.0, s1=0.0;
for(f=0; f<n; f+=5)
- {
- p->deghost=0; match(p, buf+f, -1, -1, &d); s0+=d;
- p->deghost=1; match(p, buf+f, -1, -1, &d); s1+=d;
- }
+ {
+ p->deghost=0; match(p, buf+f, -1, -1, &d); s0+=d;
+ p->deghost=1; match(p, buf+f, -1, -1, &d); s1+=d;
+ }
p->deghost=s1>s0?deghost:0;
MP_INFO(vf, "%s: Deghosting %-3s (relative pattern strength %+.2fdB).\n",
- vf_info_divtc.name,
- p->deghost?"ON":"OFF",
- 10.0*log10(s1/s0));
+ vf_info_divtc.name,
+ p->deghost?"ON":"OFF",
+ 10.0*log10(s1/s0));
}
/* analyze the data */
for(f=0; f<5; f++)
for(sum[f]=0, n=-15; n<20; n+=5)
- sum[f]+=buf[n+f];
+ sum[f]+=buf[n+f];
for(f=0; f<b; f++)
{
m=match(p, sum, -1, -1, &d);
if(d>=p->threshold)
- pbuf[f]=m;
+ pbuf[f]=m;
if(f<b-1)
- for(n=0; n<5; n++)
- sum[n]=sum[n]-buf[5*(f-3)+n]+buf[5*(f+4)+n];
+ for(n=0; n<5; n++)
+ sum[n]=sum[n]-buf[5*(f-3)+n]+buf[5*(f+4)+n];
}
/* fill in the gaps */
@@ -490,7 +490,7 @@ static int analyze(struct vf_instance *vf)
{
free(buf-15);
MP_FATAL(vf, "%s: No telecine pattern found!\n",
- vf_info_divtc.name);
+ vf_info_divtc.name);
return 0;
}
@@ -508,56 +508,56 @@ static int analyze(struct vf_instance *vf)
for(n=f; pbuf[n]==-1; n++);
if(pbuf[f-1]==pbuf[n])
- {
- /* just a gap */
- while(f<n) pbuf[f++]=pbuf[n];
- }
+ {
+ /* just a gap */
+ while(f<n) pbuf[f++]=pbuf[n];
+ }
else
- {
- /* phase change, reanalyze the original data in the gap with zero
- threshold for only the two phases that appear at the ends */
+ {
+ /* phase change, reanalyze the original data in the gap with zero
+ threshold for only the two phases that appear at the ends */
- for(i=0; i<5; i++)
- for(sum[i]=0, j=5*f-15; j<5*f; j+=5)
- sum[i]+=buf[i+j];
+ for(i=0; i<5; i++)
+ for(sum[i]=0, j=5*f-15; j<5*f; j+=5)
+ sum[i]+=buf[i+j];
- for(i=f; i<n; i++)
- {
- pbuf[i]=match(p, sum, pbuf[f-1], pbuf[n], 0);
+ for(i=f; i<n; i++)
+ {
+ pbuf[i]=match(p, sum, pbuf[f-1], pbuf[n], 0);
- for(j=0; j<5; j++)
- sum[j]=sum[j]-buf[5*(i-3)+j]+buf[5*(i+4)+j];
- }
+ for(j=0; j<5; j++)
+ sum[j]=sum[j]-buf[5*(i-3)+j]+buf[5*(i+4)+j];
+ }
- /* estimate the transition point by dividing the gap
- in the same proportion as the number of matches of each kind */
+ /* estimate the transition point by dividing the gap
+ in the same proportion as the number of matches of each kind */
- for(i=f, m=f; i<n; i++)
- if(pbuf[i]==pbuf[f-1]) m++;
+ for(i=f, m=f; i<n; i++)
+ if(pbuf[i]==pbuf[f-1]) m++;
- /* find the transition of the right direction nearest to the
- estimated point */
+ /* find the transition of the right direction nearest to the
+ estimated point */
- if(m>f && m<n)
- {
- for(j=m; j>f; j--)
- if(pbuf[j-1]==pbuf[f-1] && pbuf[j]==pbuf[n]) break;
- for(s=m; s<n; s++)
- if(pbuf[s-1]==pbuf[f-1] && pbuf[s]==pbuf[n]) break;
+ if(m>f && m<n)
+ {
+ for(j=m; j>f; j--)
+ if(pbuf[j-1]==pbuf[f-1] && pbuf[j]==pbuf[n]) break;
+ for(s=m; s<n; s++)
+ if(pbuf[s-1]==pbuf[f-1] && pbuf[s]==pbuf[n]) break;
- m=(s-m<m-j)?s:j;
- }
+ m=(s-m<m-j)?s:j;
+ }
- /* and rewrite the data to allow only this one transition */
+ /* and rewrite the data to allow only this one transition */
- for(i=f; i<m; i++)
- pbuf[i]=pbuf[f-1];
+ for(i=f; i<m; i++)
+ pbuf[i]=pbuf[f-1];
- for(; i<n; i++)
- pbuf[i]=pbuf[n];
+ for(; i<n; i++)
+ pbuf[i]=pbuf[n];
- f=n;
- }
+ f=n;
+ }
}
free(buf-15);
@@ -573,7 +573,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt)
case IMGFMT_422P: case IMGFMT_UYVY: case IMGFMT_BGR24:
case IMGFMT_411P: case IMGFMT_YUYV: case IMGFMT_410P:
case IMGFMT_420P: case IMGFMT_Y8:
- return vf_next_query_format(vf,fmt);
+ return vf_next_query_format(vf,fmt);
}
return 0;
@@ -617,27 +617,27 @@ static int vf_open(vf_instance_t *vf)
switch(p->pass)
{
case 1:
- if(!(p->file=fopen(p->filename, "w")))
- {
- MP_FATAL(vf, "%s: Can't create file %s.\n", vf->info->name, p->filename);
- goto fail;
- }
+ if(!(p->file=fopen(p->filename, "w")))
+ {
+ MP_FATAL(vf, "%s: Can't create file %s.\n", vf->info->name, p->filename);
+ goto fail;
+ }
- break;
+ break;
case 2:
- if(!(p->file=fopen(p->filename, "r")))
- {
- MP_FATAL(vf, "%s: Can't open file %s.\n", vf->info->name, p->filename);
- goto fail;
- }
-
- if(!analyze(vf))
- goto fail;
-
- fclose(p->file);
- p->file=0;
- break;
+ if(!(p->file=fopen(p->filename, "r")))
+ {
+ MP_FATAL(vf, "%s: Can't open file %s.\n", vf->info->name, p->filename);
+ goto fail;
+ }
+
+ if(!analyze(vf))
+ goto fail;
+
+ fclose(p->file);
+ p->file=0;
+ break;
}
if(!(p->history=calloc(sizeof *p->history, p->window)))
diff --git a/video/filter/vf_expand.c b/video/filter/vf_expand.c
index 2e03441757..ba636ee279 100644
--- a/video/filter/vf_expand.c
+++ b/video/filter/vf_expand.c
@@ -60,7 +60,7 @@ static struct vf_priv_s {
static int config(struct vf_instance *vf,
int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt)
+ unsigned int flags, unsigned int outfmt)
{
vf->priv->exp_x = vf->priv->cfg_exp_x;
vf->priv->exp_y = vf->priv->cfg_exp_y;
diff --git a/video/filter/vf_format.c b/video/filter/vf_format.c
index 9ac6fa9119..4342aa5bf0 100644
--- a/video/filter/vf_format.c
+++ b/video/filter/vf_format.c
@@ -44,7 +44,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt){
if(fmt==vf->priv->fmt) {
if (vf->priv->outfmt)
fmt = vf->priv->outfmt;
- return vf_next_query_format(vf,fmt);
+ return vf_next_query_format(vf,fmt);
}
return 0;
}
diff --git a/video/filter/vf_noformat.c b/video/filter/vf_noformat.c
index 1529cfadfc..504b6a0296 100644
--- a/video/filter/vf_noformat.c
+++ b/video/filter/vf_noformat.c
@@ -40,7 +40,7 @@ static struct vf_priv_s {
static int query_format(struct vf_instance *vf, unsigned int fmt){
if(fmt!=vf->priv->fmt)
- return vf_next_query_format(vf,fmt);
+ return vf_next_query_format(vf,fmt);
return 0;
}
diff --git a/video/filter/vf_noise.c b/video/filter/vf_noise.c
index 72c02b22ad..bb8fc8b426 100644
--- a/video/filter/vf_noise.c
+++ b/video/filter/vf_noise.c
@@ -50,20 +50,20 @@ static void (*lineNoise)(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int
static void (*lineNoiseAvg)(uint8_t *dst, uint8_t *src, int len, int8_t **shift)= lineNoiseAvg_C;
typedef struct FilterParam{
- int strength;
- int uniform;
- int temporal;
- int quality;
+ int strength;
+ int uniform;
+ int temporal;
+ int quality;
int averaged;
int pattern;
int shiftptr;
- int8_t *noise;
- int8_t *prev_shift[MAX_RES][3];
+ int8_t *noise;
+ int8_t *prev_shift[MAX_RES][3];
}FilterParam;
struct vf_priv_s {
- FilterParam lumaParam;
- FilterParam chromaParam;
+ FilterParam lumaParam;
+ FilterParam chromaParam;
int strength;
int averaged;
int pattern;
@@ -82,245 +82,245 @@ static int patt[4] = {
#define RAND_N(range) ((int) ((double)range*rand()/(RAND_MAX+1.0)))
static int8_t *initNoise(FilterParam *fp){
- int strength= fp->strength;
- int uniform= fp->uniform;
- int averaged= fp->averaged;
- int pattern= fp->pattern;
- int8_t *noise= av_malloc(MAX_NOISE*sizeof(int8_t));
- int i, j;
-
- srand(123457);
-
- for(i=0,j=0; i<MAX_NOISE; i++,j++)
- {
- if(uniform) {
- if (averaged) {
- if (pattern) {
- noise[i]= (RAND_N(strength) - strength/2)/6
- +patt[j%4]*strength*0.25/3;
- } else {
- noise[i]= (RAND_N(strength) - strength/2)/3;
- }
- } else {
- if (pattern) {
- noise[i]= (RAND_N(strength) - strength/2)/2
- + patt[j%4]*strength*0.25;
- } else {
- noise[i]= RAND_N(strength) - strength/2;
- }
- }
- } else {
- double x1, x2, w, y1;
- do {
- x1 = 2.0 * rand()/(float)RAND_MAX - 1.0;
- x2 = 2.0 * rand()/(float)RAND_MAX - 1.0;
- w = x1 * x1 + x2 * x2;
- } while ( w >= 1.0 );
-
- w = sqrt( (-2.0 * log( w ) ) / w );
- y1= x1 * w;
- y1*= strength / sqrt(3.0);
- if (pattern) {
- y1 /= 2;
- y1 += patt[j%4]*strength*0.35;
- }
- if (y1<-128) y1=-128;
- else if(y1> 127) y1= 127;
- if (averaged) y1 /= 3.0;
- noise[i]= (int)y1;
- }
- if (RAND_N(6) == 0) j--;
- }
-
-
- for (i = 0; i < MAX_RES; i++)
- for (j = 0; j < 3; j++)
- fp->prev_shift[i][j] = noise + (rand()&(MAX_SHIFT-1));
-
- if(!nonTempRandShift_init){
- for(i=0; i<MAX_RES; i++){
- nonTempRandShift[i]= rand()&(MAX_SHIFT-1);
- }
- nonTempRandShift_init = 1;
- }
-
- fp->noise= noise;
- fp->shiftptr= 0;
- return noise;
+ int strength= fp->strength;
+ int uniform= fp->uniform;
+ int averaged= fp->averaged;
+ int pattern= fp->pattern;
+ int8_t *noise= av_malloc(MAX_NOISE*sizeof(int8_t));
+ int i, j;
+
+ srand(123457);
+
+ for(i=0,j=0; i<MAX_NOISE; i++,j++)
+ {
+ if(uniform) {
+ if (averaged) {
+ if (pattern) {
+ noise[i]= (RAND_N(strength) - strength/2)/6
+ +patt[j%4]*strength*0.25/3;
+ } else {
+ noise[i]= (RAND_N(strength) - strength/2)/3;
+ }
+ } else {
+ if (pattern) {
+ noise[i]= (RAND_N(strength) - strength/2)/2
+ + patt[j%4]*strength*0.25;
+ } else {
+ noise[i]= RAND_N(strength) - strength/2;
+ }
+ }
+ } else {
+ double x1, x2, w, y1;
+ do {
+ x1 = 2.0 * rand()/(float)RAND_MAX - 1.0;
+ x2 = 2.0 * rand()/(float)RAND_MAX - 1.0;
+ w = x1 * x1 + x2 * x2;
+ } while ( w >= 1.0 );
+
+ w = sqrt( (-2.0 * log( w ) ) / w );
+ y1= x1 * w;
+ y1*= strength / sqrt(3.0);
+ if (pattern) {
+ y1 /= 2;
+ y1 += patt[j%4]*strength*0.35;
+ }
+ if (y1<-128) y1=-128;
+ else if(y1> 127) y1= 127;
+ if (averaged) y1 /= 3.0;
+ noise[i]= (int)y1;
+ }
+ if (RAND_N(6) == 0) j--;
+ }
+
+
+ for (i = 0; i < MAX_RES; i++)
+ for (j = 0; j < 3; j++)
+ fp->prev_shift[i][j] = noise + (rand()&(MAX_SHIFT-1));
+
+ if(!nonTempRandShift_init){
+ for(i=0; i<MAX_RES; i++){
+ nonTempRandShift[i]= rand()&(MAX_SHIFT-1);
+ }
+ nonTempRandShift_init = 1;
+ }
+
+ fp->noise= noise;
+ fp->shiftptr= 0;
+ return noise;
}
/***************************************************************************/
#if HAVE_MMX
static inline void lineNoise_MMX(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){
- x86_reg mmx_len= len&(~7);
- noise+=shift;
-
- __asm__ volatile(
- "mov %3, %%"REG_a" \n\t"
- "pcmpeqb %%mm7, %%mm7 \n\t"
- "psllw $15, %%mm7 \n\t"
- "packsswb %%mm7, %%mm7 \n\t"
- ".align 4 \n\t"
- "1: \n\t"
- "movq (%0, %%"REG_a"), %%mm0 \n\t"
- "movq (%1, %%"REG_a"), %%mm1 \n\t"
- "pxor %%mm7, %%mm0 \n\t"
- "paddsb %%mm1, %%mm0 \n\t"
- "pxor %%mm7, %%mm0 \n\t"
- "movq %%mm0, (%2, %%"REG_a") \n\t"
- "add $8, %%"REG_a" \n\t"
- " js 1b \n\t"
- :: "r" (src+mmx_len), "r" (noise+mmx_len), "r" (dst+mmx_len), "g" (-mmx_len)
- : "%"REG_a
- );
- if(mmx_len!=len)
- lineNoise_C(dst+mmx_len, src+mmx_len, noise+mmx_len, len-mmx_len, 0);
+ x86_reg mmx_len= len&(~7);
+ noise+=shift;
+
+ __asm__ volatile(
+ "mov %3, %%"REG_a" \n\t"
+ "pcmpeqb %%mm7, %%mm7 \n\t"
+ "psllw $15, %%mm7 \n\t"
+ "packsswb %%mm7, %%mm7 \n\t"
+ ".align 4 \n\t"
+ "1: \n\t"
+ "movq (%0, %%"REG_a"), %%mm0 \n\t"
+ "movq (%1, %%"REG_a"), %%mm1 \n\t"
+ "pxor %%mm7, %%mm0 \n\t"
+ "paddsb %%mm1, %%mm0 \n\t"
+ "pxor %%mm7, %%mm0 \n\t"
+ "movq %%mm0, (%2, %%"REG_a") \n\t"
+ "add $8, %%"REG_a" \n\t"
+ " js 1b \n\t"
+ :: "r" (src+mmx_len), "r" (noise+mmx_len), "r" (dst+mmx_len), "g" (-mmx_len)
+ : "%"REG_a
+ );
+ if(mmx_len!=len)
+ lineNoise_C(dst+mmx_len, src+mmx_len, noise+mmx_len, len-mmx_len, 0);
}
#endif
//duplicate of previous except movntq
#if HAVE_MMX2
static inline void lineNoise_MMX2(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){
- x86_reg mmx_len= len&(~7);
- noise+=shift;
-
- __asm__ volatile(
- "mov %3, %%"REG_a" \n\t"
- "pcmpeqb %%mm7, %%mm7 \n\t"
- "psllw $15, %%mm7 \n\t"
- "packsswb %%mm7, %%mm7 \n\t"
- ".align 4 \n\t"
- "1: \n\t"
- "movq (%0, %%"REG_a"), %%mm0 \n\t"
- "movq (%1, %%"REG_a"), %%mm1 \n\t"
- "pxor %%mm7, %%mm0 \n\t"
- "paddsb %%mm1, %%mm0 \n\t"
- "pxor %%mm7, %%mm0 \n\t"
- "movntq %%mm0, (%2, %%"REG_a") \n\t"
- "add $8, %%"REG_a" \n\t"
- " js 1b \n\t"
- :: "r" (src+mmx_len), "r" (noise+mmx_len), "r" (dst+mmx_len), "g" (-mmx_len)
- : "%"REG_a
- );
- if(mmx_len!=len)
- lineNoise_C(dst+mmx_len, src+mmx_len, noise+mmx_len, len-mmx_len, 0);
+ x86_reg mmx_len= len&(~7);
+ noise+=shift;
+
+ __asm__ volatile(
+ "mov %3, %%"REG_a" \n\t"
+ "pcmpeqb %%mm7, %%mm7 \n\t"
+ "psllw $15, %%mm7 \n\t"
+ "packsswb %%mm7, %%mm7 \n\t"
+ ".align 4 \n\t"
+ "1: \n\t"
+ "movq (%0, %%"REG_a"), %%mm0 \n\t"
+ "movq (%1, %%"REG_a"), %%mm1 \n\t"
+ "pxor %%mm7, %%mm0 \n\t"
+ "paddsb %%mm1, %%mm0 \n\t"
+ "pxor %%mm7, %%mm0 \n\t"
+ "movntq %%mm0, (%2, %%"REG_a") \n\t"
+ "add $8, %%"REG_a" \n\t"
+ " js 1b \n\t"
+ :: "r" (src+mmx_len), "r" (noise+mmx_len), "r" (dst+mmx_len), "g" (-mmx_len)
+ : "%"REG_a
+ );
+ if(mmx_len!=len)
+ lineNoise_C(dst+mmx_len, src+mmx_len, noise+mmx_len, len-mmx_len, 0);
}
#endif
static inline void lineNoise_C(uint8_t *dst, uint8_t *src, int8_t *noise, int len, int shift){
- int i;
- noise+= shift;
- for(i=0; i<len; i++)
- {
- int v= src[i]+ noise[i];
- if(v>255) dst[i]=255; //FIXME optimize
- else if(v<0) dst[i]=0;
- else dst[i]=v;
- }
+ int i;
+ noise+= shift;
+ for(i=0; i<len; i++)
+ {
+ int v= src[i]+ noise[i];
+ if(v>255) dst[i]=255; //FIXME optimize
+ else if(v<0) dst[i]=0;
+ else dst[i]=v;
+ }
}
/***************************************************************************/
#if HAVE_MMX
static inline void lineNoiseAvg_MMX(uint8_t *dst, uint8_t *src, int len, int8_t **shift){
- x86_reg mmx_len= len&(~7);
- uint8_t *src_mmx_len = src+mmx_len;
-
- __asm__ volatile(
- "push %%"REG_BP" \n\t"
- "mov %0, %%"REG_BP" \n\t"
- "mov %5, %%"REG_a" \n\t"
- ".align 4 \n\t"
- "1: \n\t"
- "movq (%1, %%"REG_a"), %%mm1 \n\t"
- "movq (%%"REG_BP", %%"REG_a"), %%mm0 \n\t"
- "paddb (%2, %%"REG_a"), %%mm1 \n\t"
- "paddb (%3, %%"REG_a"), %%mm1 \n\t"
- "movq %%mm0, %%mm2 \n\t"
- "movq %%mm1, %%mm3 \n\t"
- "punpcklbw %%mm0, %%mm0 \n\t"
- "punpckhbw %%mm2, %%mm2 \n\t"
- "punpcklbw %%mm1, %%mm1 \n\t"
- "punpckhbw %%mm3, %%mm3 \n\t"
- "pmulhw %%mm0, %%mm1 \n\t"
- "pmulhw %%mm2, %%mm3 \n\t"
- "paddw %%mm1, %%mm1 \n\t"
- "paddw %%mm3, %%mm3 \n\t"
- "paddw %%mm0, %%mm1 \n\t"
- "paddw %%mm2, %%mm3 \n\t"
- "psrlw $8, %%mm1 \n\t"
- "psrlw $8, %%mm3 \n\t"
- "packuswb %%mm3, %%mm1 \n\t"
- "movq %%mm1, (%4, %%"REG_a") \n\t"
- "add $8, %%"REG_a" \n\t"
- " js 1b \n\t"
- "pop %%"REG_BP" \n\t"
- :: "g" (src_mmx_len), "r" (shift[0]+mmx_len),
- "r" (shift[1]+mmx_len), "r" (shift[2]+mmx_len),
+ x86_reg mmx_len= len&(~7);
+ uint8_t *src_mmx_len = src+mmx_len;
+
+ __asm__ volatile(
+ "push %%"REG_BP" \n\t"
+ "mov %0, %%"REG_BP" \n\t"
+ "mov %5, %%"REG_a" \n\t"
+ ".align 4 \n\t"
+ "1: \n\t"
+ "movq (%1, %%"REG_a"), %%mm1 \n\t"
+ "movq (%%"REG_BP", %%"REG_a"), %%mm0 \n\t"
+ "paddb (%2, %%"REG_a"), %%mm1 \n\t"
+ "paddb (%3, %%"REG_a"), %%mm1 \n\t"
+ "movq %%mm0, %%mm2 \n\t"
+ "movq %%mm1, %%mm3 \n\t"
+ "punpcklbw %%mm0, %%mm0 \n\t"
+ "punpckhbw %%mm2, %%mm2 \n\t"
+ "punpcklbw %%mm1, %%mm1 \n\t"
+ "punpckhbw %%mm3, %%mm3 \n\t"
+ "pmulhw %%mm0, %%mm1 \n\t"
+ "pmulhw %%mm2, %%mm3 \n\t"
+ "paddw %%mm1, %%mm1 \n\t"
+ "paddw %%mm3, %%mm3 \n\t"
+ "paddw %%mm0, %%mm1 \n\t"
+ "paddw %%mm2, %%mm3 \n\t"
+ "psrlw $8, %%mm1 \n\t"
+ "psrlw $8, %%mm3 \n\t"
+ "packuswb %%mm3, %%mm1 \n\t"
+ "movq %%mm1, (%4, %%"REG_a") \n\t"
+ "add $8, %%"REG_a" \n\t"
+ " js 1b \n\t"
+ "pop %%"REG_BP" \n\t"
+ :: "g" (src_mmx_len), "r" (shift[0]+mmx_len),
+ "r" (shift[1]+mmx_len), "r" (shift[2]+mmx_len),
"r" (dst+mmx_len), "g" (-mmx_len)
- : "%"REG_a
- );
+ : "%"REG_a
+ );
- if(mmx_len!=len){
- int8_t *shift2[3]={shift[0]+mmx_len, shift[1]+mmx_len, shift[2]+mmx_len};
- lineNoiseAvg_C(dst+mmx_len, src+mmx_len, len-mmx_len, shift2);
- }
+ if(mmx_len!=len){
+ int8_t *shift2[3]={shift[0]+mmx_len, shift[1]+mmx_len, shift[2]+mmx_len};
+ lineNoiseAvg_C(dst+mmx_len, src+mmx_len, len-mmx_len, shift2);
+ }
}
#endif
static inline void lineNoiseAvg_C(uint8_t *dst, uint8_t *src, int len, int8_t **shift){
- int i;
+ int i;
int8_t *src2= (int8_t*)src;
- for(i=0; i<len; i++)
- {
- const int n= shift[0][i] + shift[1][i] + shift[2][i];
- dst[i]= src2[i]+((n*src2[i])>>7);
- }
+ for(i=0; i<len; i++)
+ {
+ const int n= shift[0][i] + shift[1][i] + shift[2][i];
+ dst[i]= src2[i]+((n*src2[i])>>7);
+ }
}
/***************************************************************************/
static void donoise(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int width, int height, FilterParam *fp){
- int8_t *noise= fp->noise;
- int y;
- int shift=0;
-
- if(!noise)
- {
- if(src==dst) return;
-
- if(dstStride==srcStride) memcpy(dst, src, srcStride*height);
- else
- {
- for(y=0; y<height; y++)
- {
- memcpy(dst, src, width);
- dst+= dstStride;
- src+= srcStride;
- }
- }
- return;
- }
-
- for(y=0; y<height; y++)
- {
- if(fp->temporal) shift= rand()&(MAX_SHIFT -1);
- else shift= nonTempRandShift[y];
-
- if(fp->quality==0) shift&= ~7;
- if (fp->averaged) {
- lineNoiseAvg(dst, src, width, fp->prev_shift[y]);
- fp->prev_shift[y][fp->shiftptr] = noise + shift;
- } else {
- lineNoise(dst, src, noise, width, shift);
- }
- dst+= dstStride;
- src+= srcStride;
- }
- fp->shiftptr++;
- if (fp->shiftptr == 3) fp->shiftptr = 0;
+ int8_t *noise= fp->noise;
+ int y;
+ int shift=0;
+
+ if(!noise)
+ {
+ if(src==dst) return;
+
+ if(dstStride==srcStride) memcpy(dst, src, srcStride*height);
+ else
+ {
+ for(y=0; y<height; y++)
+ {
+ memcpy(dst, src, width);
+ dst+= dstStride;
+ src+= srcStride;
+ }
+ }
+ return;
+ }
+
+ for(y=0; y<height; y++)
+ {
+ if(fp->temporal) shift= rand()&(MAX_SHIFT -1);
+ else shift= nonTempRandShift[y];
+
+ if(fp->quality==0) shift&= ~7;
+ if (fp->averaged) {
+ lineNoiseAvg(dst, src, width, fp->prev_shift[y]);
+ fp->prev_shift[y][fp->shiftptr] = noise + shift;
+ } else {
+ lineNoise(dst, src, noise, width, shift);
+ }
+ dst+= dstStride;
+ src+= srcStride;
+ }
+ fp->shiftptr++;
+ if (fp->shiftptr == 3) fp->shiftptr = 0;
}
static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
@@ -331,52 +331,52 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
mp_image_copy_attributes(dmpi, mpi);
}
- donoise(dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, &vf->priv->lumaParam);
- donoise(dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2, &vf->priv->chromaParam);
- donoise(dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w/2, mpi->h/2, &vf->priv->chromaParam);
+ donoise(dmpi->planes[0], mpi->planes[0], dmpi->stride[0], mpi->stride[0], mpi->w, mpi->h, &vf->priv->lumaParam);
+ donoise(dmpi->planes[1], mpi->planes[1], dmpi->stride[1], mpi->stride[1], mpi->w/2, mpi->h/2, &vf->priv->chromaParam);
+ donoise(dmpi->planes[2], mpi->planes[2], dmpi->stride[2], mpi->stride[2], mpi->w/2, mpi->h/2, &vf->priv->chromaParam);
#if HAVE_MMX
- if(gCpuCaps.hasMMX) __asm__ volatile ("emms\n\t");
+ if(gCpuCaps.hasMMX) __asm__ volatile ("emms\n\t");
#endif
#if HAVE_MMX2
- if(gCpuCaps.hasMMX2) __asm__ volatile ("sfence\n\t");
+ if(gCpuCaps.hasMMX2) __asm__ volatile ("sfence\n\t");
#endif
if (dmpi != mpi)
talloc_free(mpi);
- return dmpi;
+ return dmpi;
}
static void uninit(struct vf_instance *vf){
- if(!vf->priv) return;
+ if(!vf->priv) return;
- av_free(vf->priv->chromaParam.noise);
- vf->priv->chromaParam.noise= NULL;
+ av_free(vf->priv->chromaParam.noise);
+ vf->priv->chromaParam.noise= NULL;
- av_free(vf->priv->lumaParam.noise);
- vf->priv->lumaParam.noise= NULL;
+ av_free(vf->priv->lumaParam.noise);
+ vf->priv->lumaParam.noise= NULL;
}
//===========================================================================//
static int query_format(struct vf_instance *vf, unsigned int fmt){
- switch(fmt)
- {
- case IMGFMT_420P:
- return vf_next_query_format(vf,IMGFMT_420P);
- }
- return 0;
+ switch(fmt)
+ {
+ case IMGFMT_420P:
+ return vf_next_query_format(vf,IMGFMT_420P);
+ }
+ return 0;
}
static void parse(FilterParam *fp, struct vf_priv_s *p){
- fp->strength= p->strength;
- fp->uniform=p->uniform;
- fp->temporal=p->temporal;
- fp->quality=p->hq;
- fp->pattern=p->pattern;
- fp->averaged=p->averaged;
-
- if(fp->strength) initNoise(fp);
+ fp->strength= p->strength;
+ fp->uniform=p->uniform;
+ fp->temporal=p->temporal;
+ fp->quality=p->hq;
+ fp->pattern=p->pattern;
+ fp->averaged=p->averaged;
+
+ if(fp->strength) initNoise(fp);
}
static int vf_open(vf_instance_t *vf){
diff --git a/video/filter/vf_phase.c b/video/filter/vf_phase.c
index b016e66820..d0b6e33312 100644
--- a/video/filter/vf_phase.c
+++ b/video/filter/vf_phase.c
@@ -34,8 +34,8 @@
#include "vf_lavfi.h"
enum mode { PROGRESSIVE, TOP_FIRST, BOTTOM_FIRST,
- TOP_FIRST_ANALYZE, BOTTOM_FIRST_ANALYZE,
- ANALYZE, FULL_ANALYZE, AUTO, AUTO_ANALYZE };
+ TOP_FIRST_ANALYZE, BOTTOM_FIRST_ANALYZE,
+ ANALYZE, FULL_ANALYZE, AUTO, AUTO_ANALYZE };
#define fixed_mode(p) ((p)<=BOTTOM_FIRST)
@@ -53,8 +53,8 @@ struct vf_priv_s
*/
static void do_plane(unsigned char *to, unsigned char *from,
- int w, int h, int ts, int fs,
- unsigned char **bufp, enum mode mode)
+ int w, int h, int ts, int fs,
+ unsigned char **bufp, enum mode mode)
{
unsigned char *buf, *end;
int top;
@@ -90,8 +90,8 @@ static void do_plane(unsigned char *to, unsigned char *from,
static enum mode analyze_plane(struct vf_instance *vf,
unsigned char *old, unsigned char *new,
- int w, int h, int os, int ns, enum mode mode,
- int unused, int fields)
+ int w, int h, int os, int ns, enum mode mode,
+ int unused, int fields)
{
double bdiff, pdiff, tdiff, scale;
int bdif, tdif, pdif;
@@ -100,10 +100,10 @@ static enum mode analyze_plane(struct vf_instance *vf,
if(mode==AUTO)
mode=fields&MP_IMGFIELD_ORDERED?fields&MP_IMGFIELD_TOP_FIRST?
- TOP_FIRST:BOTTOM_FIRST:PROGRESSIVE;
+ TOP_FIRST:BOTTOM_FIRST:PROGRESSIVE;
else if(mode==AUTO_ANALYZE)
mode=fields&MP_IMGFIELD_ORDERED?fields&MP_IMGFIELD_TOP_FIRST?
- TOP_FIRST_ANALYZE:BOTTOM_FIRST_ANALYZE:FULL_ANALYZE;
+ TOP_FIRST_ANALYZE:BOTTOM_FIRST_ANALYZE:FULL_ANALYZE;
if(fixed_mode(mode))
bdiff=pdiff=tdiff=65536.0;
@@ -112,62 +112,62 @@ static enum mode analyze_plane(struct vf_instance *vf,
bdiff=pdiff=tdiff=0.0;
for(end=new+(h-2)*ns, new+=ns, old+=os, top=0;
- new<end; new+=ns-w, old+=os-w, top^=1)
- {
- pdif=tdif=bdif=0;
-
- switch(mode)
- {
- case TOP_FIRST_ANALYZE:
- if(top)
- for(rend=new+w; new<rend; new++, old++)
- pdif+=diff(new, ns, new, ns),
- tdif+=diff(new, ns, old, os);
- else
- for(rend=new+w; new<rend; new++, old++)
- pdif+=diff(new, ns, new, ns),
- tdif+=diff(old, os, new, ns);
- break;
-
- case BOTTOM_FIRST_ANALYZE:
- if(top)
- for(rend=new+w; new<rend; new++, old++)
- pdif+=diff(new, ns, new, ns),
- bdif+=diff(old, os, new, ns);
- else
- for(rend=new+w; new<rend; new++, old++)
- pdif+=diff(new, ns, new, ns),
- bdif+=diff(new, ns, old, os);
- break;
-
- case ANALYZE:
- if(top)
- for(rend=new+w; new<rend; new++, old++)
- tdif+=diff(new, ns, old, os),
- bdif+=diff(old, os, new, ns);
- else
- for(rend=new+w; new<rend; new++, old++)
- bdif+=diff(new, ns, old, os),
+ new<end; new+=ns-w, old+=os-w, top^=1)
+ {
+ pdif=tdif=bdif=0;
+
+ switch(mode)
+ {
+ case TOP_FIRST_ANALYZE:
+ if(top)
+ for(rend=new+w; new<rend; new++, old++)
+ pdif+=diff(new, ns, new, ns),
+ tdif+=diff(new, ns, old, os);
+ else
+ for(rend=new+w; new<rend; new++, old++)
+ pdif+=diff(new, ns, new, ns),
tdif+=diff(old, os, new, ns);
- break;
-
- default: /* FULL_ANALYZE */
- if(top)
- for(rend=new+w; new<rend; new++, old++)
- pdif+=diff(new, ns, new, ns),
- tdif+=diff(new, ns, old, os),
- bdif+=diff(old, os, new, ns);
- else
- for(rend=new+w; new<rend; new++, old++)
- pdif+=diff(new, ns, new, ns),
- bdif+=diff(new, ns, old, os),
- tdif+=diff(old, os, new, ns);
- }
-
- pdiff+=(double)pdif;
- tdiff+=(double)tdif;
- bdiff+=(double)bdif;
- }
+ break;
+
+ case BOTTOM_FIRST_ANALYZE:
+ if(top)
+ for(rend=new+w; new<rend; new++, old++)
+ pdif+=diff(new, ns, new, ns),
+ bdif+=diff(old, os, new, ns);
+ else
+ for(rend=new+w; new<rend; new++, old++)
+ pdif+=diff(new, ns, new, ns),
+ bdif+=diff(new, ns, old, os);
+ break;
+
+ case ANALYZE:
+ if(top)
+ for(rend=new+w; new<rend; new++, old++)
+ tdif+=diff(new, ns, old, os),
+ bdif+=diff(old, os, new, ns);
+ else
+ for(rend=new+w; new<rend; new++, old++)
+ bdif+=diff(new, ns, old, os),
+ tdif+=diff(old, os, new, ns);
+ break;
+
+ default: /* FULL_ANALYZE */
+ if(top)
+ for(rend=new+w; new<rend; new++, old++)
+ pdif+=diff(new, ns, new, ns),
+ tdif+=diff(new, ns, old, os),
+ bdif+=diff(old, os, new, ns);
+ else
+ for(rend=new+w; new<rend; new++, old++)
+ pdif+=diff(new, ns, new, ns),
+ bdif+=diff(new, ns, old, os),
+ tdif+=diff(old, os, new, ns);
+ }
+
+ pdiff+=(double)pdif;
+ tdiff+=(double)tdif;
+ bdiff+=(double)bdif;
+ }
scale=1.0/(w*(h-3))/25.0;
pdiff*=scale;
@@ -175,18 +175,18 @@ static enum mode analyze_plane(struct vf_instance *vf,
bdiff*=scale;
if(mode==TOP_FIRST_ANALYZE)
- bdiff=65536.0;
+ bdiff=65536.0;
else if(mode==BOTTOM_FIRST_ANALYZE)
- tdiff=65536.0;
+ tdiff=65536.0;
else if(mode==ANALYZE)
- pdiff=65536.0;
+ pdiff=65536.0;
if(bdiff<pdiff && bdiff<tdiff)
- mode=BOTTOM_FIRST;
+ mode=BOTTOM_FIRST;
else if(tdiff<pdiff && tdiff<bdiff)
- mode=TOP_FIRST;
+ mode=TOP_FIRST;
else
- mode=PROGRESSIVE;
+ mode=PROGRESSIVE;
}
MP_INFO(vf, "%c", mode==BOTTOM_FIRST?'b':mode==TOP_FIRST?'t':'p');
@@ -215,8 +215,8 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
mode=PROGRESSIVE;
else
mode=analyze_plane(vf, vf->priv->buf[0], mpi->planes[0],
- pw[0], dmpi->h, pw[0], mpi->stride[0], mode,
- vf->priv->verbose, mpi->fields);
+ pw[0], dmpi->h, pw[0], mpi->stride[0], mode,
+ vf->priv->verbose, mpi->fields);
for (int p = 0; p < mpi->num_planes; p++) {
do_plane(dmpi->planes[p], mpi->planes[p], pw[p], dmpi->plane_h[p],
diff --git a/video/filter/vf_pp.c b/video/filter/vf_pp.c
index bf1a513474..6a347bb9d9 100644
--- a/video/filter/vf_pp.c
+++ b/video/filter/vf_pp.c
@@ -44,10 +44,10 @@ struct vf_priv_s {
static int config(struct vf_instance *vf,
int width, int height, int d_width, int d_height,
- unsigned int voflags, unsigned int outfmt){
+ unsigned int voflags, unsigned int outfmt){
int flags=
(gCpuCaps.hasMMX ? PP_CPU_CAPS_MMX : 0)
- | (gCpuCaps.hasMMX2 ? PP_CPU_CAPS_MMX2 : 0);
+ | (gCpuCaps.hasMMX2 ? PP_CPU_CAPS_MMX2 : 0);
switch(outfmt){
case IMGFMT_444P: flags|= PP_FORMAT_444; break;
@@ -66,7 +66,7 @@ static void uninit(struct vf_instance *vf){
int i;
for(i=0; i<=PP_QUALITY_MAX; i++){
if(vf->priv->ppMode[i])
- pp_free_mode(vf->priv->ppMode[i]);
+ pp_free_mode(vf->priv->ppMode[i]);
}
if(vf->priv->context) pp_free_context(vf->priv->context);
}
@@ -77,7 +77,7 @@ static int query_format(struct vf_instance *vf, unsigned int fmt){
case IMGFMT_422P:
case IMGFMT_420P:
case IMGFMT_411P: ;
- return vf_next_query_format(vf,fmt);
+ return vf_next_query_format(vf,fmt);
}
return 0;
}
@@ -99,16 +99,16 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
// apparently this is required
assert(mpi->stride[0] >= ((mpi->w+7)&(~7)));
- // do the postprocessing! (or copy if no DR)
- pp_postprocess((const uint8_t **)mpi->planes, mpi->stride,
- dmpi->planes,dmpi->stride,
- (mpi->w+7)&(~7),mpi->h,
- mpi->qscale, mpi->qstride,
- vf->priv->ppMode[ vf->priv->pp ], vf->priv->context,
+ // do the postprocessing! (or copy if no DR)
+ pp_postprocess((const uint8_t **)mpi->planes, mpi->stride,
+ dmpi->planes,dmpi->stride,
+ (mpi->w+7)&(~7),mpi->h,
+ mpi->qscale, mpi->qstride,
+ vf->priv->ppMode[ vf->priv->pp ], vf->priv->context,
#ifdef PP_PICT_TYPE_QP2
- mpi->pict_type | (mpi->qscale_type ? PP_PICT_TYPE_QP2 : 0));
+ mpi->pict_type | (mpi->qscale_type ? PP_PICT_TYPE_QP2 : 0));
#else
- mpi->pict_type);
+ mpi->pict_type);
#endif
if (dmpi != mpi)
@@ -124,7 +124,7 @@ static int vf_open(vf_instance_t *vf){
vf->filter=filter;
vf->uninit=uninit;
- for(i=0; i<=PP_QUALITY_MAX; i++){
+ for(i=0; i<=PP_QUALITY_MAX; i++){
vf->priv->ppMode[i]= pp_get_mode_by_name_and_quality(vf->priv->arg, i);
if(vf->priv->ppMode[i]==NULL) return -1;
}
diff --git a/video/filter/vf_pullup.c b/video/filter/vf_pullup.c
index b59cde67a1..cf61d5a20a 100644
--- a/video/filter/vf_pullup.c
+++ b/video/filter/vf_pullup.c
@@ -38,11 +38,11 @@
#define MAX(a,b) ((a)>(b)?(a):(b))
struct vf_priv_s {
- struct pullup_context *ctx;
- int init;
- int fakecount;
- char *qbuf;
- double lastpts;
+ struct pullup_context *ctx;
+ int init;
+ int fakecount;
+ char *qbuf;
+ double lastpts;
int junk_left, junk_right, junk_top, junk_bottom;
int strict_breaks, metric_plane;
struct vf_lw_opts *lw_opts;
@@ -68,137 +68,137 @@ static void reset(struct vf_instance *vf)
static void init_pullup(struct vf_instance *vf, mp_image_t *mpi)
{
- struct pullup_context *c = vf->priv->ctx;
-
- c->format = PULLUP_FMT_Y;
- c->nplanes = 4;
- pullup_preinit_context(c);
- c->bpp[0] = c->bpp[1] = c->bpp[2] = 8;
- c->w[0] = mpi->w;
- c->h[0] = mpi->h;
- c->w[1] = c->w[2] = mpi->chroma_width;
- c->h[1] = c->h[2] = mpi->chroma_height;
- c->w[3] = ((mpi->w+15)/16) * ((mpi->h+15)/16);
- c->h[3] = 2;
- c->stride[0] = mpi->w;
- c->stride[1] = c->stride[2] = mpi->chroma_width;
- c->stride[3] = c->w[3];
- c->background[1] = c->background[2] = 128;
-
- if (gCpuCaps.hasMMX) c->cpu |= PULLUP_CPU_MMX;
- if (gCpuCaps.hasMMX2) c->cpu |= PULLUP_CPU_MMX2;
- if (gCpuCaps.hasSSE) c->cpu |= PULLUP_CPU_SSE;
- if (gCpuCaps.hasSSE2) c->cpu |= PULLUP_CPU_SSE2;
-
- pullup_init_context(c);
-
- vf->priv->init = 1;
- vf->priv->qbuf = malloc(c->w[3]);
+ struct pullup_context *c = vf->priv->ctx;
+
+ c->format = PULLUP_FMT_Y;
+ c->nplanes = 4;
+ pullup_preinit_context(c);
+ c->bpp[0] = c->bpp[1] = c->bpp[2] = 8;
+ c->w[0] = mpi->w;
+ c->h[0] = mpi->h;
+ c->w[1] = c->w[2] = mpi->chroma_width;
+ c->h[1] = c->h[2] = mpi->chroma_height;
+ c->w[3] = ((mpi->w+15)/16) * ((mpi->h+15)/16);
+ c->h[3] = 2;
+ c->stride[0] = mpi->w;
+ c->stride[1] = c->stride[2] = mpi->chroma_width;
+ c->stride[3] = c->w[3];
+ c->background[1] = c->background[2] = 128;
+
+ if (gCpuCaps.hasMMX) c->cpu |= PULLUP_CPU_MMX;
+ if (gCpuCaps.hasMMX2) c->cpu |= PULLUP_CPU_MMX2;
+ if (gCpuCaps.hasSSE) c->cpu |= PULLUP_CPU_SSE;
+ if (gCpuCaps.hasSSE2) c->cpu |= PULLUP_CPU_SSE2;
+
+ pullup_init_context(c);
+
+ vf->priv->init = 1;
+ vf->priv->qbuf = malloc(c->w[3]);
}
static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
{
- struct pullup_context *c = vf->priv->ctx;
- struct pullup_buffer *b;
- struct pullup_frame *f;
- int p;
- int i;
+ struct pullup_context *c = vf->priv->ctx;
+ struct pullup_buffer *b;
+ struct pullup_frame *f;
+ int p;
+ int i;
double pts = mpi->pts;
struct mp_image *dmpi = NULL;
- if (!vf->priv->init) init_pullup(vf, mpi);
-
- if (1) {
- b = pullup_get_buffer(c, 2);
- if (!b) {
- MP_ERR(vf, "Could not get buffer from pullup!\n");
- f = pullup_get_frame(c);
- pullup_release_frame(f);
- goto skip;
- }
- memcpy_pic(b->planes[0], mpi->planes[0], mpi->w, mpi->h,
- c->stride[0], mpi->stride[0]);
- memcpy_pic(b->planes[1], mpi->planes[1],
- mpi->chroma_width, mpi->chroma_height,
- c->stride[1], mpi->stride[1]);
- memcpy_pic(b->planes[2], mpi->planes[2],
- mpi->chroma_width, mpi->chroma_height,
- c->stride[2], mpi->stride[2]);
- }
- if (mpi->qscale) {
- memcpy(b->planes[3], mpi->qscale, c->w[3]);
- memcpy(b->planes[3]+c->w[3], mpi->qscale, c->w[3]);
- }
-
- p = mpi->fields & MP_IMGFIELD_TOP_FIRST ? 0 :
- (mpi->fields & MP_IMGFIELD_ORDERED ? 1 : 0);
-
- if (pts == MP_NOPTS_VALUE) {
- pullup_submit_field(c, b, p, MP_NOPTS_VALUE);
- pullup_submit_field(c, b, p^1, MP_NOPTS_VALUE);
- if (mpi->fields & MP_IMGFIELD_REPEAT_FIRST)
- pullup_submit_field(c, b, p, MP_NOPTS_VALUE);
- } else {
- double delta;
- if (vf->priv->lastpts == MP_NOPTS_VALUE)
- delta = 1001.0/60000.0; // delta = field time distance
- else
- delta = (pts - vf->priv->lastpts) / 2;
- if (delta <= 0.0 || delta >= 0.5)
- delta = 0.0;
- vf->priv->lastpts = pts;
- if (mpi->fields & MP_IMGFIELD_REPEAT_FIRST) {
- pullup_submit_field(c, b, p, pts - delta);
- pullup_submit_field(c, b, p^1, pts);
- pullup_submit_field(c, b, p, pts + delta);
- } else {
- pullup_submit_field(c, b, p, pts - delta * 0.5);
- pullup_submit_field(c, b, p^1, pts + delta * 0.5);
- }
- }
-
- pullup_release_buffer(b, 2);
-
- f = pullup_get_frame(c);
-
- /* Fake yes for first few frames (buffer depth) to keep from
- * breaking A/V sync with G1's bad architecture... */
- //if (!f) return vf->priv->fakecount ? (--vf->priv->fakecount,1) : 0;
- if (!f)
+ if (!vf->priv->init) init_pullup(vf, mpi);
+
+ if (1) {
+ b = pullup_get_buffer(c, 2);
+ if (!b) {
+ MP_ERR(vf, "Could not get buffer from pullup!\n");
+ f = pullup_get_frame(c);
+ pullup_release_frame(f);
+ goto skip;
+ }
+ memcpy_pic(b->planes[0], mpi->planes[0], mpi->w, mpi->h,
+ c->stride[0], mpi->stride[0]);
+ memcpy_pic(b->planes[1], mpi->planes[1],
+ mpi->chroma_width, mpi->chroma_height,
+ c->stride[1], mpi->stride[1]);
+ memcpy_pic(b->planes[2], mpi->planes[2],
+ mpi->chroma_width, mpi->chroma_height,
+ c->stride[2], mpi->stride[2]);
+ }
+ if (mpi->qscale) {
+ memcpy(b->planes[3], mpi->qscale, c->w[3]);
+ memcpy(b->planes[3]+c->w[3], mpi->qscale, c->w[3]);
+ }
+
+ p = mpi->fields & MP_IMGFIELD_TOP_FIRST ? 0 :
+ (mpi->fields & MP_IMGFIELD_ORDERED ? 1 : 0);
+
+ if (pts == MP_NOPTS_VALUE) {
+ pullup_submit_field(c, b, p, MP_NOPTS_VALUE);
+ pullup_submit_field(c, b, p^1, MP_NOPTS_VALUE);
+ if (mpi->fields & MP_IMGFIELD_REPEAT_FIRST)
+ pullup_submit_field(c, b, p, MP_NOPTS_VALUE);
+ } else {
+ double delta;
+ if (vf->priv->lastpts == MP_NOPTS_VALUE)
+ delta = 1001.0/60000.0; // delta = field time distance
+ else
+ delta = (pts - vf->priv->lastpts) / 2;
+ if (delta <= 0.0 || delta >= 0.5)
+ delta = 0.0;
+ vf->priv->lastpts = pts;
+ if (mpi->fields & MP_IMGFIELD_REPEAT_FIRST) {
+ pullup_submit_field(c, b, p, pts - delta);
+ pullup_submit_field(c, b, p^1, pts);
+ pullup_submit_field(c, b, p, pts + delta);
+ } else {
+ pullup_submit_field(c, b, p, pts - delta * 0.5);
+ pullup_submit_field(c, b, p^1, pts + delta * 0.5);
+ }
+ }
+
+ pullup_release_buffer(b, 2);
+
+ f = pullup_get_frame(c);
+
+ /* Fake yes for first few frames (buffer depth) to keep from
+ * breaking A/V sync with G1's bad architecture... */
+ //if (!f) return vf->priv->fakecount ? (--vf->priv->fakecount,1) : 0;
+ if (!f)
goto skip;
- if (f->length < 2) {
- pullup_release_frame(f);
- f = pullup_get_frame(c);
- if (!f) goto skip;
- if (f->length < 2) {
- pullup_release_frame(f);
- if (!(mpi->fields & MP_IMGFIELD_REPEAT_FIRST))
- goto skip;
- f = pullup_get_frame(c);
- if (!f) goto skip;
- if (f->length < 2) {
- pullup_release_frame(f);
- goto skip;
- }
- }
- }
+ if (f->length < 2) {
+ pullup_release_frame(f);
+ f = pullup_get_frame(c);
+ if (!f) goto skip;
+ if (f->length < 2) {
+ pullup_release_frame(f);
+ if (!(mpi->fields & MP_IMGFIELD_REPEAT_FIRST))
+ goto skip;
+ f = pullup_get_frame(c);
+ if (!f) goto skip;
+ if (f->length < 2) {
+ pullup_release_frame(f);
+ goto skip;
+ }
+ }
+ }
#if 0
- /* Average qscale tables from both frames. */
- if (mpi->qscale) {
- for (i=0; i<c->w[3]; i++) {
- vf->priv->qbuf[i] = (f->ofields[0]->planes[3][i]
- + f->ofields[1]->planes[3][i+c->w[3]])>>1;
- }
- }
+ /* Average qscale tables from both frames. */
+ if (mpi->qscale) {
+ for (i=0; i<c->w[3]; i++) {
+ vf->priv->qbuf[i] = (f->ofields[0]->planes[3][i]
+ + f->ofields[1]->planes[3][i+c->w[3]])>>1;
+ }
+ }
#else
- /* Take worst of qscale tables from both frames. */
- if (mpi->qscale) {
- for (i=0; i<c->w[3]; i++) {
- vf->priv->qbuf[i] = MAX(f->ofields[0]->planes[3][i], f->ofields[1]->planes[3][i+c->w[3]]);
- }
- }
+ /* Take worst of qscale tables from both frames. */
+ if (mpi->qscale) {
+ for (i=0; i<c->w[3]; i++) {
+ vf->priv->qbuf[i] = MAX(f->ofields[0]->planes[3][i], f->ofields[1]->planes[3][i+c->w[3]]);
+ }
+ }
#endif
/* If the frame isn't already exportable... */
@@ -214,53 +214,53 @@ static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
struct mp_image data = *dmpi;
- data.planes[0] = f->buffer->planes[0];
- data.planes[1] = f->buffer->planes[1];
- data.planes[2] = f->buffer->planes[2];
+ data.planes[0] = f->buffer->planes[0];
+ data.planes[1] = f->buffer->planes[1];
+ data.planes[2] = f->buffer->planes[2];
- data.stride[0] = c->stride[0];
- data.stride[1] = c->stride[1];
- data.stride[2] = c->stride[2];
+ data.stride[0] = c->stride[0];
+ data.stride[1] = c->stride[1];
+ data.stride[2] = c->stride[2];
mp_image_copy(dmpi, &data);
dmpi->pts = f->pts;
// Warning: entirely bogus memory management of qscale
- if (mpi->qscale) {
- dmpi->qscale = vf->priv->qbuf;
- dmpi->qstride = mpi->qstride;
- dmpi->qscale_type = mpi->qscale_type;
- }
- pullup_release_frame(f);
+ if (mpi->qscale) {
+ dmpi->qscale = vf->priv->qbuf;
+ dmpi->qstride = mpi->qstride;
+ dmpi->qscale_type = mpi->qscale_type;
+ }
+ pullup_release_frame(f);
skip:
talloc_free(mpi);
- return dmpi;
+ return dmpi;
}
static int query_format(struct vf_instance *vf, unsigned int fmt)
{
- /* FIXME - support more formats */
- switch (fmt) {
- case IMGFMT_420P:
- return vf_next_query_format(vf, fmt);
- }
- return 0;
+ /* FIXME - support more formats */
+ switch (fmt) {
+ case IMGFMT_420P:
+ return vf_next_query_format(vf, fmt);
+ }
+ return 0;
}
static int config(struct vf_instance *vf,
int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt)
+ unsigned int flags, unsigned int outfmt)
{
reset(vf);
- if (height&3) return 0;
- return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt);
+ if (height&3) return 0;
+ return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt);
}
static void uninit(struct vf_instance *vf)
{
- pullup_free_context(vf->priv->ctx);
+ pullup_free_context(vf->priv->ctx);
}
static int control(vf_instance_t *vf, int request, void *data)
@@ -275,11 +275,11 @@ static int control(vf_instance_t *vf, int request, void *data)
static int vf_open(vf_instance_t *vf)
{;
- vf->filter = filter;
- vf->config = config;
- vf->query_format = query_format;
+ vf->filter = filter;
+ vf->config = config;
+ vf->query_format = query_format;
vf->control = control;
- vf->uninit = uninit;
+ vf->uninit = uninit;
struct vf_priv_s *p = vf->priv;
const char *pname[3] = {"y", "u", "v"};
if (vf_lw_set_graph(vf, p->lw_opts, "pullup", "%d:%d:%d:%d:%d:%s",
@@ -289,7 +289,7 @@ static int vf_open(vf_instance_t *vf)
return 1;
}
reset(vf);
- return 1;
+ return 1;
}
#define OPT_BASE_STRUCT struct vf_priv_s
diff --git a/video/filter/vf_rotate.c b/video/filter/vf_rotate.c
index b767d37c4b..f2d06830bd 100644
--- a/video/filter/vf_rotate.c
+++ b/video/filter/vf_rotate.c
@@ -36,33 +36,33 @@ struct vf_priv_s {
static void rotate(unsigned char* dst,unsigned char* src,int dststride,int srcstride,int w,int h,int bpp,int dir){
int y;
if(dir&1){
- src+=srcstride*(w-1);
- srcstride*=-1;
+ src+=srcstride*(w-1);
+ srcstride*=-1;
}
if(dir&2){
- dst+=dststride*(h-1);
- dststride*=-1;
+ dst+=dststride*(h-1);
+ dststride*=-1;
}
for(y=0;y<h;y++){
- int x;
- switch(bpp){
- case 1:
- for(x=0;x<w;x++) dst[x]=src[y+x*srcstride];
- break;
- case 2:
- for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+y*2+x*srcstride));
- break;
- case 4:
- for(x=0;x<w;x++) *((int*)(dst+x*4))=*((int*)(src+y*4+x*srcstride));
+ int x;
+ switch(bpp){
+ case 1:
+ for(x=0;x<w;x++) dst[x]=src[y+x*srcstride];
+ break;
+ case 2:
+ for(x=0;x<w;x++) *((short*)(dst+x*2))=*((short*)(src+y*2+x*srcstride));
+ break;
+ case 4:
+ for(x=0;x<w;x++) *((int*)(dst+x*4))=*((int*)(src+y*4+x*srcstride));
default:
for(x=0;x<w;x++){
for (int b=0;b<bpp;b++)
dst[x*bpp+b]=src[b+y*bpp+x*srcstride];
}
break;
- }
- dst+=dststride;
+ }
+ dst+=dststride;
}
}
diff --git a/video/filter/vf_softpulldown.c b/video/filter/vf_softpulldown.c
index f1b8bdd0be..eeb2f1c863 100644
--- a/video/filter/vf_softpulldown.c
+++ b/video/filter/vf_softpulldown.c
@@ -30,11 +30,11 @@
#include "video/memcpy_pic.h"
struct vf_priv_s {
- int state;
- long long in;
- long long out;
- struct vf_detc_pts_buf ptsbuf;
- int last_frame_duration;
+ int state;
+ long long in;
+ long long out;
+ struct vf_detc_pts_buf ptsbuf;
+ int last_frame_duration;
struct mp_image *buffer;
};
@@ -50,8 +50,8 @@ static void copy_pic_field(struct mp_image *dmpi, struct mp_image *mpi, int f)
static int filter(struct vf_instance *vf, struct mp_image *mpi)
{
- int flags = mpi->fields;
- int state = vf->priv->state;
+ int flags = mpi->fields;
+ int state = vf->priv->state;
struct vf_priv_s *p = vf->priv;
if (!p->buffer || p->buffer->w != mpi->w || p->buffer->h != mpi->h ||
@@ -65,50 +65,50 @@ static int filter(struct vf_instance *vf, struct mp_image *mpi)
struct mp_image *dmpi = p->buffer;
- vf->priv->in++;
-
- if ((state == 0 &&
- !(flags & MP_IMGFIELD_TOP_FIRST)) ||
- (state == 1 &&
- flags & MP_IMGFIELD_TOP_FIRST)) {
- MP_WARN(vf, "softpulldown: Unexpected field flags: state=%d top_field_first=%d repeat_first_field=%d\n",
- state,
- (flags & MP_IMGFIELD_TOP_FIRST) != 0,
- (flags & MP_IMGFIELD_REPEAT_FIRST) != 0);
- state ^= 1;
- }
+ vf->priv->in++;
+
+ if ((state == 0 &&
+ !(flags & MP_IMGFIELD_TOP_FIRST)) ||
+ (state == 1 &&
+ flags & MP_IMGFIELD_TOP_FIRST)) {
+ MP_WARN(vf, "softpulldown: Unexpected field flags: state=%d top_field_first=%d repeat_first_field=%d\n",
+ state,
+ (flags & MP_IMGFIELD_TOP_FIRST) != 0,
+ (flags & MP_IMGFIELD_REPEAT_FIRST) != 0);
+ state ^= 1;
+ }
- if (state == 0) {
+ if (state == 0) {
struct mp_image *new = mp_image_new_ref(mpi);
new->pts = vf_softpulldown_adjust_pts(&vf->priv->ptsbuf, mpi->pts, 0, 0, vf->priv->last_frame_duration);
vf_add_output_frame(vf, new);
- vf->priv->out++;
- if (flags & MP_IMGFIELD_REPEAT_FIRST) {
- copy_pic_field(dmpi, mpi, 0);
- state=1;
- }
- } else {
- copy_pic_field(dmpi, mpi, 1);
- struct mp_image *new = mp_image_new_ref(mpi);
+ vf->priv->out++;
+ if (flags & MP_IMGFIELD_REPEAT_FIRST) {
+ copy_pic_field(dmpi, mpi, 0);
+ state=1;
+ }
+ } else {
+ copy_pic_field(dmpi, mpi, 1);
+ struct mp_image *new = mp_image_new_ref(mpi);
new->pts = vf_softpulldown_adjust_pts(&vf->priv->ptsbuf, mpi->pts, 0, 0, vf->priv->last_frame_duration);
- vf_add_output_frame(vf, new);
- vf->priv->out++;
- if (flags & MP_IMGFIELD_REPEAT_FIRST) {
+ vf_add_output_frame(vf, new);
+ vf->priv->out++;
+ if (flags & MP_IMGFIELD_REPEAT_FIRST) {
struct mp_image *new2 = mp_image_new_ref(mpi);
new2->pts = vf_softpulldown_adjust_pts(&vf->priv->ptsbuf, mpi->pts, 0, 0, 3);
vf_add_output_frame(vf, new2);
vf->priv->out++;
vf->priv->state=0;
- } else {
+ } else {
copy_pic_field(dmpi, mpi, 0);
- }
- }
+ }
+ }
- vf->priv->state = state;
- if (flags & MP_IMGFIELD_REPEAT_FIRST)
- vf->priv->last_frame_duration = 3;
- else
- vf->priv->last_frame_duration = 2;
+ vf->priv->state = state;
+ if (flags & MP_IMGFIELD_REPEAT_FIRST)
+ vf->priv->last_frame_duration = 3;
+ else
+ vf->priv->last_frame_duration = 2;
talloc_free(mpi);
@@ -127,8 +127,8 @@ static int control(vf_instance_t *vf, int request, void *data)
static void uninit(struct vf_instance *vf)
{
- MP_INFO(vf, "softpulldown: %lld frames in, %lld frames out\n", vf->priv->in, vf->priv->out);
- free(vf->priv);
+ MP_INFO(vf, "softpulldown: %lld frames in, %lld frames out\n", vf->priv->in, vf->priv->out);
+ free(vf->priv);
}
static int query_format(struct vf_instance *vf, unsigned int fmt)
diff --git a/video/filter/vf_sub.c b/video/filter/vf_sub.c
index d2b97d8e30..1f31d7b67f 100644
--- a/video/filter/vf_sub.c
+++ b/video/filter/vf_sub.c
@@ -74,7 +74,7 @@ static int config(struct vf_instance *vf,
};
return vf_next_config(vf, vf->priv->outw, vf->priv->outh, d_width,
- d_height, flags, outfmt);
+ d_height, flags, outfmt);
}
static void prepare_image(struct vf_instance *vf, struct mp_image *dmpi,