Mercurial > mplayer.hg
annotate libmpcodecs/vf_divtc.c @ 23605:cfcf3b068cdf
vo_init is x11 specific and has no place in video_out.h.
It is already in x11_common.h.
author | reimar |
---|---|
date | Sun, 24 Jun 2007 10:06:10 +0000 |
parents | fa99b3d31d13 |
children | 5c3c7efd9b75 |
rev | line source |
---|---|
12225
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
1 #include <stdio.h> |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
2 #include <stdlib.h> |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
3 #include <string.h> |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
4 #include <limits.h> |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
5 #include <math.h> |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
6 |
17012 | 7 #include "config.h" |
8 #include "mp_msg.h" | |
9 #include "cpudetect.h" | |
21372 | 10 #include "libavutil/common.h" |
21507
fa99b3d31d13
Hack around libavutil/bswap.h compilation problems due to always_inline undefined.
reimar
parents:
21372
diff
changeset
|
11 #include "mpbswap.h" |
12225
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
12 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
13 #include "img_format.h" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
14 #include "mp_image.h" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
15 #include "vf.h" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
16 |
17012 | 17 #include "libvo/fastmemcpy.h" |
12225
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
18 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
19 vf_info_t vf_info_divtc; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
20 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
21 struct vf_priv_s |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
22 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
23 int deghost, pass, phase, window, fcount, bcount, frameno, misscount, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
24 ocount, sum[5]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
25 double threshold; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
26 FILE *file; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
27 char *bdata; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
28 unsigned int *csdata; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
29 int *history; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
30 }; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
31 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
32 /* |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
33 * diff_MMX and diff_C stolen from vf_decimate.c |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
34 */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
35 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
36 #ifdef HAVE_MMX |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
37 static int diff_MMX(unsigned char *old, unsigned char *new, int os, int ns) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
38 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
39 volatile short out[4]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
40 asm ( |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
41 "movl $8, %%ecx \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
42 "pxor %%mm4, %%mm4 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
43 "pxor %%mm7, %%mm7 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
44 |
19372
6334c14b38eb
Replace asmalign.h hack by ASMALIGN cpp macros from config.h.
diego
parents:
18104
diff
changeset
|
45 ASMALIGN(4) |
12225
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
46 "1: \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
47 |
13720
821f464b4d90
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents:
12225
diff
changeset
|
48 "movq (%%"REG_S"), %%mm0 \n\t" |
821f464b4d90
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents:
12225
diff
changeset
|
49 "movq (%%"REG_S"), %%mm2 \n\t" |
821f464b4d90
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents:
12225
diff
changeset
|
50 "add %%"REG_a", %%"REG_S" \n\t" |
821f464b4d90
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents:
12225
diff
changeset
|
51 "movq (%%"REG_D"), %%mm1 \n\t" |
821f464b4d90
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents:
12225
diff
changeset
|
52 "add %%"REG_b", %%"REG_D" \n\t" |
12225
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
53 "psubusb %%mm1, %%mm2 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
54 "psubusb %%mm0, %%mm1 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
55 "movq %%mm2, %%mm0 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
56 "movq %%mm1, %%mm3 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
57 "punpcklbw %%mm7, %%mm0 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
58 "punpcklbw %%mm7, %%mm1 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
59 "punpckhbw %%mm7, %%mm2 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
60 "punpckhbw %%mm7, %%mm3 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
61 "paddw %%mm0, %%mm4 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
62 "paddw %%mm1, %%mm4 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
63 "paddw %%mm2, %%mm4 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
64 "paddw %%mm3, %%mm4 \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
65 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
66 "decl %%ecx \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
67 "jnz 1b \n\t" |
13720
821f464b4d90
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents:
12225
diff
changeset
|
68 "movq %%mm4, (%%"REG_d") \n\t" |
12225
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
69 "emms \n\t" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
70 : |
13720
821f464b4d90
adapting existing mmx/mmx2/sse/3dnow optimizations so they work on x86_64
aurel
parents:
12225
diff
changeset
|
71 : "S" (old), "D" (new), "a" ((long)os), "b" ((long)ns), "d" (out) |
12225
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
72 : "memory" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
73 ); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
74 return out[0]+out[1]+out[2]+out[3]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
75 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
76 #endif |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
77 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
78 static int diff_C(unsigned char *old, unsigned char *new, int os, int ns) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
79 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
80 int x, y, d=0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
81 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
82 for(y=8; y; y--, new+=ns, old+=os) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
83 for(x=8; x; x--) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
84 d+=abs(new[x]-old[x]); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
85 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
86 return d; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
87 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
88 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
89 static int (*diff)(unsigned char *, unsigned char *, int, int); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
90 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
91 static int diff_plane(unsigned char *old, unsigned char *new, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
92 int w, int h, int os, int ns, int arg) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
93 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
94 int x, y, d, max=0, sum=0, n=0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
95 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
96 for(y=0; y<h-7; y+=8) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
97 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
98 for(x=0; x<w-7; x+=8) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
99 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
100 d=diff(old+x+y*os, new+x+y*ns, os, ns); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
101 if(d>max) max=d; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
102 sum+=d; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
103 n++; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
104 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
105 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
106 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
107 return (sum+n*max)/2; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
108 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
109 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
110 /* |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
111 static unsigned int checksum_plane(unsigned char *p, unsigned char *z, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
112 int w, int h, int s, int zs, int arg) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
113 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
114 unsigned int shift, sum; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
115 unsigned char *e; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
116 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
117 for(sum=0; h; h--, p+=s-w) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
118 for(e=p+w, shift=32; p<e;) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
119 sum^=(*p++)<<(shift=(shift-8)&31); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
120 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
121 return sum; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
122 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
123 */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
124 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
125 static unsigned int checksum_plane(unsigned char *p, unsigned char *z, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
126 int w, int h, int s, int zs, int arg) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
127 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
128 unsigned int shift; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
129 uint32_t sum, t; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
130 unsigned char *e, *e2; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
131 #if MP_WORDSIZE==64 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
132 typedef uint64_t wsum_t; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
133 #else |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
134 typedef uint32_t wsum_t; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
135 #endif |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
136 wsum_t wsum; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
137 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
138 for(sum=0; h; h--, p+=s-w) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
139 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
140 for(shift=0, e=p+w; (int)p&(sizeof(wsum_t)-1) && p<e;) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
141 sum^=*p++<<(shift=(shift-8)&31); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
142 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
143 for(wsum=0, e2=e-sizeof(wsum_t)+1; p<e2; p+=sizeof(wsum_t)) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
144 wsum^=*(wsum_t *)p; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
145 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
146 #if MP_WORDSIZE==64 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
147 t=be2me_32((uint32_t)(wsum>>32^wsum)); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
148 #else |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
149 t=be2me_32(wsum); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
150 #endif |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
151 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
152 for(sum^=(t<<shift|t>>(32-shift)); p<e;) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
153 sum^=*p++<<(shift=(shift-8)&31); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
154 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
155 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
156 return sum; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
157 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
158 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
159 static int deghost_plane(unsigned char *d, unsigned char *s, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
160 int w, int h, int ds, int ss, int threshold) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
161 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
162 int t; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
163 unsigned char *e; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
164 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
165 for(; h; h--, s+=ss-w, d+=ds-w) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
166 for(e=d+w; d<e; d++, s++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
167 if(abs(*d-*s)>=threshold) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
168 *d=(t=(*d<<1)-*s)<0?0:t>255?255:t; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
169 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
170 return 0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
171 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
172 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
173 static int imgop(int(*planeop)(unsigned char *, unsigned char *, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
174 int, int, int, int, int), |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
175 mp_image_t *dst, mp_image_t *src, int arg) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
176 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
177 if(dst->flags&MP_IMGFLAG_PLANAR) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
178 return planeop(dst->planes[0], src?src->planes[0]:0, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
179 dst->w, dst->h, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
180 dst->stride[0], src?src->stride[0]:0, arg)+ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
181 planeop(dst->planes[1], src?src->planes[1]:0, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
182 dst->chroma_width, dst->chroma_height, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
183 dst->stride[1], src?src->stride[1]:0, arg)+ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
184 planeop(dst->planes[2], src?src->planes[2]:0, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
185 dst->chroma_width, dst->chroma_height, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
186 dst->stride[2], src?src->stride[2]:0, arg); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
187 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
188 return planeop(dst->planes[0], src?src->planes[0]:0, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
189 dst->w*(dst->bpp/8), dst->h, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
190 dst->stride[0], src?src->stride[0]:0, arg); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
191 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
192 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
193 /* |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
194 * Find the phase in which the telecine pattern fits best to the |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
195 * given 5 frame slice of frame difference measurements. |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
196 * |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
197 * If phase1 and phase2 are not negative, only the two specified |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
198 * phases are tested. |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
199 */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
200 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
201 static int cmp(int *a, int *b) { return *b-*a; } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
202 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
203 static int match(struct vf_priv_s *p, int *diffs, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
204 int phase1, int phase2, double *strength) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
205 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
206 static const int pattern1[]={ -4, 1, 1, 1, 1 }, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
207 pattern2[]={ -2, -3, 4, 4, -3 }, *pattern; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
208 int f, m, n, t[5]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
209 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
210 pattern=p->deghost>0?pattern2:pattern1; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
211 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
212 for(f=0; f<5; f++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
213 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
214 if(phase1<0 || phase2<0 || f==phase1 || f==phase2) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
215 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
216 for(n=t[f]=0; n<5; n++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
217 t[f]+=diffs[n]*pattern[(n-f+5)%5]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
218 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
219 else |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
220 t[f]=INT_MIN; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
221 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
222 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
223 /* find the best match */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
224 for(m=0, n=1; n<5; n++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
225 if(t[n]>t[m]) m=n; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
226 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
227 if(strength) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
228 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
229 /* the second best match */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
230 for(f=m?0:1, n=f+1; n<5; n++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
231 if(n!=m && t[n]>t[f]) f=n; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
232 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
233 *strength=(t[m]>0?(double)(t[m]-t[f])/t[m]:0.0); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
234 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
235 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
236 return m; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
237 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
238 |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
239 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts) |
12225
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
240 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
241 mp_image_t *dmpi, *tmpi=0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
242 int n, m, f, newphase; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
243 struct vf_priv_s *p=vf->priv; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
244 unsigned int checksum; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
245 double d; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
246 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
247 dmpi=vf_get_image(vf->next, mpi->imgfmt, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
248 MP_IMGTYPE_STATIC, MP_IMGFLAG_ACCEPT_STRIDE | |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
249 MP_IMGFLAG_PRESERVE | MP_IMGFLAG_READABLE, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
250 mpi->width, mpi->height); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
251 vf_clone_mpi_attributes(dmpi, mpi); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
252 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
253 newphase=p->phase; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
254 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
255 switch(p->pass) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
256 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
257 case 1: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
258 fprintf(p->file, "%08x %d\n", |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
259 (unsigned int)imgop((void *)checksum_plane, mpi, 0, 0), |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
260 p->frameno?imgop(diff_plane, dmpi, mpi, 0):0); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
261 break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
262 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
263 case 2: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
264 if(p->frameno/5>p->bcount) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
265 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
266 mp_msg(MSGT_VFILTER, MSGL_ERR, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
267 "\n%s: Log file ends prematurely! " |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
268 "Switching to one pass mode.\n", vf->info->name); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
269 p->pass=0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
270 break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
271 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
272 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
273 checksum=(unsigned int)imgop((void *)checksum_plane, mpi, 0, 0); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
274 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
275 if(checksum!=p->csdata[p->frameno]) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
276 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
277 for(f=0; f<100; f++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
278 if(p->frameno+f<p->fcount && p->csdata[p->frameno+f]==checksum) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
279 break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
280 else if(p->frameno-f>=0 && p->csdata[p->frameno-f]==checksum) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
281 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
282 f=-f; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
283 break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
284 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
285 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
286 if(f<100) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
287 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
288 mp_msg(MSGT_VFILTER, MSGL_INFO, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
289 "\n%s: Mismatch with pass-1: %+d frame(s).\n", |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
290 vf->info->name, f); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
291 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
292 p->frameno+=f; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
293 p->misscount=0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
294 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
295 else if(p->misscount++>=30) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
296 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
297 mp_msg(MSGT_VFILTER, MSGL_ERR, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
298 "\n%s: Sync with pass-1 lost! " |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
299 "Switching to one pass mode.\n", vf->info->name); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
300 p->pass=0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
301 break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
302 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
303 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
304 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
305 n=(p->frameno)/5; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
306 if(n>=p->bcount) n=p->bcount-1; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
307 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
308 newphase=p->bdata[n]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
309 break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
310 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
311 default: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
312 if(p->frameno) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
313 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
314 int *sump=p->sum+p->frameno%5, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
315 *histp=p->history+p->frameno%p->window; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
316 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
317 *sump-=*histp; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
318 *sump+=(*histp=imgop(diff_plane, dmpi, mpi, 0)); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
319 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
320 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
321 m=match(p, p->sum, -1, -1, &d); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
322 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
323 if(d>=p->threshold) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
324 newphase=m; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
325 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
326 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
327 n=p->ocount++%5; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
328 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
329 if(newphase!=p->phase && ((p->phase+4)%5<n)==((newphase+4)%5<n)) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
330 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
331 p->phase=newphase; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
332 mp_msg(MSGT_VFILTER, MSGL_STATUS, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
333 "\n%s: Telecine phase %d.\n", vf->info->name, p->phase); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
334 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
335 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
336 switch((p->frameno++-p->phase+10)%5) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
337 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
338 case 0: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
339 imgop((void *)memcpy_pic, dmpi, mpi, 0); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
340 return 0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
341 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
342 case 4: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
343 if(p->deghost>0) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
344 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
345 tmpi=vf_get_image(vf->next, mpi->imgfmt, |
16136
acd19cdc1b46
deghost_plane also reads from destination, so request readable buffer
reimar
parents:
13720
diff
changeset
|
346 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE | |
acd19cdc1b46
deghost_plane also reads from destination, so request readable buffer
reimar
parents:
13720
diff
changeset
|
347 MP_IMGFLAG_READABLE, |
12225
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
348 mpi->width, mpi->height); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
349 vf_clone_mpi_attributes(tmpi, mpi); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
350 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
351 imgop((void *)memcpy_pic, tmpi, mpi, 0); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
352 imgop(deghost_plane, tmpi, dmpi, p->deghost); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
353 imgop((void *)memcpy_pic, dmpi, mpi, 0); |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
354 return vf_next_put_image(vf, tmpi, MP_NOPTS_VALUE); |
12225
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
355 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
356 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
357 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
358 imgop((void *)memcpy_pic, dmpi, mpi, 0); |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
359 return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE); |
12225
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
360 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
361 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
362 static int analyze(struct vf_priv_s *p) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
363 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
364 int *buf=0, *bp, bufsize=0, n, b, f, i, j, m, s; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
365 unsigned int *cbuf=0, *cp; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
366 char *pbuf; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
367 char lbuf[256]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
368 int sum[5]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
369 double d; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
370 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
371 /* read the file */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
372 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
373 n=15; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
374 while(fgets(lbuf, 256, p->file)) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
375 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
376 if(n>=bufsize-19) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
377 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
378 bufsize=bufsize?bufsize*2:30000; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
379 if((bp=realloc(buf, bufsize*sizeof *buf))) buf=bp; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
380 if((cp=realloc(cbuf, bufsize*sizeof *cbuf))) cbuf=cp; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
381 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
382 if(!bp || !cp) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
383 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
384 mp_msg(MSGT_VFILTER, MSGL_FATAL, "%s: Not enough memory.\n", |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
385 vf_info_divtc.name); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
386 free(buf); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
387 free(cbuf); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
388 return 0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
389 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
390 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
391 sscanf(lbuf, "%x %d", cbuf+n, buf+n); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
392 n++; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
393 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
394 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
395 if(!n) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
396 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
397 mp_msg(MSGT_VFILTER, MSGL_FATAL, "%s: Empty 2-pass log file.\n", |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
398 vf_info_divtc.name); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
399 free(buf); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
400 free(cbuf); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
401 return 0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
402 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
403 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
404 /* generate some dummy data past the beginning and end of the array */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
405 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
406 buf+=15, cbuf+=15; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
407 n-=15; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
408 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
409 memcpy(buf-15, buf, 15*sizeof *buf); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
410 memset(cbuf-15, 0, 15*sizeof *cbuf); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
411 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
412 while(n%5) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
413 buf[n]=buf[n-5], cbuf[n]=0, n++; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
414 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
415 memcpy(buf+n, buf+n-15, 15*sizeof *buf); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
416 memset(cbuf+n, 0, 15*sizeof *cbuf); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
417 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
418 p->csdata=cbuf; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
419 p->fcount=n; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
420 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
421 /* array with one slot for each slice of 5 frames */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
422 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
423 p->bdata=pbuf=malloc(p->bcount=b=(n/5)); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
424 memset(pbuf, 255, b); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
425 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
426 /* resolve the automatic mode */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
427 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
428 if(p->deghost<0) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
429 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
430 int deghost=-p->deghost; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
431 double s0=0.0, s1=0.0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
432 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
433 for(f=0; f<n; f+=5) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
434 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
435 p->deghost=0; match(p, buf+f, -1, -1, &d); s0+=d; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
436 p->deghost=1; match(p, buf+f, -1, -1, &d); s1+=d; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
437 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
438 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
439 p->deghost=s1>s0?deghost:0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
440 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
441 mp_msg(MSGT_VFILTER, MSGL_INFO, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
442 "%s: Deghosting %-3s (relative pattern strength %+.2fdB).\n", |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
443 vf_info_divtc.name, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
444 p->deghost?"ON":"OFF", |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
445 10.0*log10(s1/s0)); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
446 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
447 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
448 /* analyze the data */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
449 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
450 for(f=0; f<5; f++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
451 for(sum[f]=0, n=-15; n<20; n+=5) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
452 sum[f]+=buf[n+f]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
453 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
454 for(f=0; f<b; f++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
455 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
456 m=match(p, sum, -1, -1, &d); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
457 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
458 if(d>=p->threshold) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
459 pbuf[f]=m; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
460 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
461 if(f<b-1) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
462 for(n=0; n<5; n++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
463 sum[n]=sum[n]-buf[5*(f-3)+n]+buf[5*(f+4)+n]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
464 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
465 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
466 /* fill in the gaps */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
467 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
468 /* the beginning */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
469 for(f=0; f<b && pbuf[f]==-1; f++); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
470 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
471 if(f==b) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
472 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
473 free(buf-15); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
474 mp_msg(MSGT_VFILTER, MSGL_FATAL, "%s: No telecine pattern found!\n", |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
475 vf_info_divtc.name); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
476 return 0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
477 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
478 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
479 for(n=0; n<f; pbuf[n++]=pbuf[f]); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
480 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
481 /* the end */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
482 for(f=b-1; pbuf[f]==-1; f--); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
483 for(n=f+1; n<b; pbuf[n++]=pbuf[f]); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
484 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
485 /* the rest */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
486 for(f=0;;) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
487 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
488 while(f<b && pbuf[f]!=-1) f++; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
489 if(f==b) break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
490 for(n=f; pbuf[n]==-1; n++); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
491 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
492 if(pbuf[f-1]==pbuf[n]) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
493 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
494 /* just a gap */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
495 while(f<n) pbuf[f++]=pbuf[n]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
496 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
497 else |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
498 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
499 /* phase change, reanalyze the original data in the gap with zero |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
500 threshold for only the two phases that appear at the ends */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
501 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
502 for(i=0; i<5; i++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
503 for(sum[i]=0, j=5*f-15; j<5*f; j+=5) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
504 sum[i]+=buf[i+j]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
505 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
506 for(i=f; i<n; i++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
507 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
508 pbuf[i]=match(p, sum, pbuf[f-1], pbuf[n], 0); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
509 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
510 for(j=0; j<5; j++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
511 sum[j]=sum[j]-buf[5*(i-3)+j]+buf[5*(i+4)+j]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
512 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
513 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
514 /* estimate the transition point by dividing the gap |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
515 in the same proportion as the number of matches of each kind */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
516 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
517 for(i=f, m=f; i<n; i++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
518 if(pbuf[i]==pbuf[f-1]) m++; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
519 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
520 /* find the transition of the right direction nearest to the |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
521 estimated point */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
522 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
523 if(m>f && m<n) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
524 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
525 for(j=m; j>f; j--) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
526 if(pbuf[j-1]==pbuf[f-1] && pbuf[j]==pbuf[n]) break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
527 for(s=m; s<n; s++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
528 if(pbuf[s-1]==pbuf[f-1] && pbuf[s]==pbuf[n]) break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
529 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
530 m=(s-m<m-j)?s:j; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
531 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
532 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
533 /* and rewrite the data to allow only this one transition */ |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
534 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
535 for(i=f; i<m; i++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
536 pbuf[i]=pbuf[f-1]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
537 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
538 for(; i<n; i++) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
539 pbuf[i]=pbuf[n]; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
540 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
541 f=n; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
542 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
543 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
544 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
545 free(buf-15); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
546 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
547 return 1; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
548 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
549 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
550 static int query_format(struct vf_instance_s* vf, unsigned int fmt) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
551 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
552 switch(fmt) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
553 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
554 case IMGFMT_444P: case IMGFMT_IYUV: case IMGFMT_RGB24: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
555 case IMGFMT_422P: case IMGFMT_UYVY: case IMGFMT_BGR24: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
556 case IMGFMT_411P: case IMGFMT_YUY2: case IMGFMT_IF09: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
557 case IMGFMT_YV12: case IMGFMT_I420: case IMGFMT_YVU9: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
558 case IMGFMT_IUYV: case IMGFMT_Y800: case IMGFMT_Y8: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
559 return vf_next_query_format(vf,fmt); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
560 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
561 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
562 return 0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
563 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
564 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
565 static void uninit(struct vf_instance_s* vf) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
566 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
567 if(vf->priv) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
568 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
569 if(vf->priv->file) fclose(vf->priv->file); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
570 if(vf->priv->csdata) free(vf->priv->csdata-15); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
571 free(vf->priv->bdata); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
572 free(vf->priv->history); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
573 free(vf->priv); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
574 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
575 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
576 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
577 static int open(vf_instance_t *vf, char* args) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
578 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
579 struct vf_priv_s *p; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
580 char *filename="framediff.log", *ap, *q, *a; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
581 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
582 if(args && !(args=strdup(args))) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
583 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
584 nomem: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
585 mp_msg(MSGT_VFILTER, MSGL_FATAL, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
586 "%s: Not enough memory.\n", vf->info->name); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
587 fail: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
588 uninit(vf); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
589 free(args); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
590 return 0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
591 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
592 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
593 vf->put_image=put_image; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
594 vf->uninit=uninit; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
595 vf->query_format=query_format; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
596 vf->default_reqs=VFCAP_ACCEPT_STRIDE; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
597 if(!(vf->priv=p=calloc(1, sizeof(struct vf_priv_s)))) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
598 goto nomem; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
599 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
600 p->phase=5; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
601 p->threshold=0.5; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
602 p->window=30; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
603 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
604 if((ap=args)) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
605 while(*ap) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
606 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
607 q=ap; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
608 if((ap=strchr(q, ':'))) *ap++=0; else ap=q+strlen(q); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
609 if((a=strchr(q, '='))) *a++=0; else a=q+strlen(q); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
610 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
611 switch(*q) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
612 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
613 case 0: break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
614 case 'f': filename=a; break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
615 case 't': p->threshold=atof(a); break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
616 case 'w': p->window=5*(atoi(a)+4)/5; break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
617 case 'd': p->deghost=atoi(a); break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
618 case 'p': |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
619 if(q[1]=='h') p->phase=atoi(a); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
620 else p->pass=atoi(a); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
621 break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
622 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
623 case 'h': |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
624 mp_msg(MSGT_VFILTER, MSGL_INFO, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
625 "\n%s options:\n\n" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
626 "pass=1|2 - Use 2-pass mode.\n" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
627 "file=filename - Set the 2-pass log file name " |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
628 "(default %s).\n" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
629 "threshold=value - Set the pattern recognition " |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
630 "sensitivity (default %g).\n" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
631 "deghost=value - Select deghosting threshold " |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
632 "(default %d).\n" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
633 "window=numframes - Set the statistics window " |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
634 "for 1-pass mode (default %d).\n" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
635 "phase=0|1|2|3|4 - Set the initial phase " |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
636 "for 1-pass mode (default %d).\n\n" |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
637 "The option names can be abbreviated to the shortest " |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
638 "unique prefix.\n\n", |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
639 vf->info->name, filename, p->threshold, p->deghost, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
640 p->window, p->phase%5); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
641 break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
642 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
643 default: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
644 mp_msg(MSGT_VFILTER, MSGL_FATAL, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
645 "%s: Unknown argument %s.\n", vf->info->name, q); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
646 goto fail; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
647 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
648 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
649 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
650 switch(p->pass) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
651 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
652 case 1: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
653 if(!(p->file=fopen(filename, "w"))) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
654 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
655 mp_msg(MSGT_VFILTER, MSGL_FATAL, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
656 "%s: Can't create file %s.\n", vf->info->name, filename); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
657 goto fail; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
658 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
659 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
660 break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
661 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
662 case 2: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
663 if(!(p->file=fopen(filename, "r"))) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
664 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
665 mp_msg(MSGT_VFILTER, MSGL_FATAL, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
666 "%s: Can't open file %s.\n", vf->info->name, filename); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
667 goto fail; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
668 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
669 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
670 if(!analyze(p)) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
671 goto fail; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
672 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
673 fclose(p->file); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
674 p->file=0; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
675 break; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
676 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
677 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
678 if(p->window<5) p->window=5; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
679 if(!(p->history=calloc(sizeof *p->history, p->window))) |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
680 goto nomem; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
681 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
682 diff= |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
683 #ifdef HAVE_MMX |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
684 gCpuCaps.hasMMX?diff_MMX: |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
685 #endif |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
686 diff_C; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
687 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
688 free(args); |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
689 return 1; |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
690 } |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
691 |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
692 vf_info_t vf_info_divtc = |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
693 { |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
694 "inverse telecine for deinterlaced video", |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
695 "divtc", |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
696 "Ville Saari", |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
697 "", |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
698 open, |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
699 NULL |
eb79a6192b2b
New filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
700 }; |