Mercurial > mplayer.hg
annotate libmpcodecs/vf_phase.c @ 12296:1da74cbaf324
Add Fullscreen, Ontop and OSD support
author | nplourde |
---|---|
date | Mon, 26 Apr 2004 12:17:26 +0000 |
parents | e34700c872ac |
children | f60bc2314146 |
rev | line source |
---|---|
12081
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
1 #include <stdio.h> |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
2 #include <stdlib.h> |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
3 #include <string.h> |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
4 #include <limits.h> |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
5 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
6 #include "../config.h" |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
7 #include "../mp_msg.h" |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
8 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
9 #include "img_format.h" |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
10 #include "mp_image.h" |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
11 #include "vf.h" |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
12 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
13 #include "../libvo/fastmemcpy.h" |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
14 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
15 enum mode { PROGRESSIVE, TOP_FIRST, BOTTOM_FIRST, |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
16 TOP_FIRST_ANALYZE, BOTTOM_FIRST_ANALYZE, |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
17 ANALYZE, FULL_ANALYZE, AUTO, AUTO_ANALYZE }; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
18 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
19 #define fixed_mode(p) ((p)<=BOTTOM_FIRST) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
20 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
21 struct vf_priv_s |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
22 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
23 enum mode mode; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
24 int verbose; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
25 unsigned char *buf[3]; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
26 }; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
27 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
28 /* |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
29 * Copy fields from either current or buffered previous frame to the |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
30 * output and store the current frame unmodified to the buffer. |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
31 */ |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
32 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
33 static void do_plane(unsigned char *to, unsigned char *from, |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
34 int w, int h, int ts, int fs, |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
35 unsigned char **bufp, enum mode mode) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
36 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
37 unsigned char *buf, *end; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
38 int top; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
39 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
40 if(!*bufp) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
41 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
42 mode=PROGRESSIVE; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
43 if(!(*bufp=malloc(h*w))) return; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
44 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
45 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
46 for(end=to+h*ts, buf=*bufp, top=1; to<end; from+=fs, to+=ts, buf+=w, top^=1) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
47 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
48 memcpy(to, mode==(top?BOTTOM_FIRST:TOP_FIRST)?buf:from, w); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
49 memcpy(buf, from, w); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
50 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
51 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
52 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
53 /* |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
54 * This macro interpolates the value of both fields at a point halfway |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
55 * between lines and takes the squared difference. In field resolution |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
56 * the point is a quarter pixel below a line in one field and a quarter |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
57 * pixel above a line in other. |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
58 * |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
59 * (the result is actually multiplied by 25) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
60 */ |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
61 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
62 #define diff(a, as, b, bs) (t=(*a-b[bs]<<2)+a[as<<1]-b[-bs], t*t) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
63 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
64 /* |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
65 * Find which field combination has the smallest average squared difference |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
66 * between the fields. |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
67 */ |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
68 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
69 static enum mode analyze_plane(unsigned char *old, unsigned char *new, |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
70 int w, int h, int os, int ns, enum mode mode, |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
71 int verbose, int fields) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
72 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
73 double bdiff, pdiff, tdiff, scale; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
74 int bdif, tdif, pdif; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
75 int top, t; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
76 unsigned char *end, *rend; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
77 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
78 if(mode==AUTO) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
79 mode=fields&MP_IMGFIELD_ORDERED?fields&MP_IMGFIELD_TOP_FIRST? |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
80 TOP_FIRST:BOTTOM_FIRST:PROGRESSIVE; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
81 else if(mode==AUTO_ANALYZE) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
82 mode=fields&MP_IMGFIELD_ORDERED?fields&MP_IMGFIELD_TOP_FIRST? |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
83 TOP_FIRST_ANALYZE:BOTTOM_FIRST_ANALYZE:FULL_ANALYZE; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
84 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
85 if(fixed_mode(mode)) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
86 bdiff=pdiff=tdiff=65536.0; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
87 else |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
88 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
89 bdiff=pdiff=tdiff=0.0; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
90 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
91 for(end=new+(h-2)*ns, new+=ns, old+=os, top=0; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
92 new<end; new+=ns-w, old+=os-w, top^=1) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
93 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
94 pdif=tdif=bdif=0; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
95 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
96 switch(mode) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
97 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
98 case TOP_FIRST_ANALYZE: |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
99 if(top) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
100 for(rend=new+w; new<rend; new++, old++) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
101 pdif+=diff(new, ns, new, ns), |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
102 tdif+=diff(new, ns, old, os); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
103 else |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
104 for(rend=new+w; new<rend; new++, old++) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
105 pdif+=diff(new, ns, new, ns), |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
106 tdif+=diff(old, os, new, ns); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
107 break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
108 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
109 case BOTTOM_FIRST_ANALYZE: |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
110 if(top) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
111 for(rend=new+w; new<rend; new++, old++) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
112 pdif+=diff(new, ns, new, ns), |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
113 bdif+=diff(old, os, new, ns); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
114 else |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
115 for(rend=new+w; new<rend; new++, old++) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
116 pdif+=diff(new, ns, new, ns), |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
117 bdif+=diff(new, ns, old, os); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
118 break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
119 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
120 case ANALYZE: |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
121 if(top) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
122 for(rend=new+w; new<rend; new++, old++) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
123 tdif+=diff(new, ns, old, os), |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
124 bdif+=diff(old, os, new, ns); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
125 else |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
126 for(rend=new+w; new<rend; new++, old++) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
127 bdif+=diff(new, ns, old, os), |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
128 tdif+=diff(old, os, new, ns); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
129 break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
130 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
131 default: /* FULL_ANALYZE */ |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
132 if(top) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
133 for(rend=new+w; new<rend; new++, old++) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
134 pdif+=diff(new, ns, new, ns), |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
135 tdif+=diff(new, ns, old, os), |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
136 bdif+=diff(old, os, new, ns); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
137 else |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
138 for(rend=new+w; new<rend; new++, old++) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
139 pdif+=diff(new, ns, new, ns), |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
140 bdif+=diff(new, ns, old, os), |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
141 tdif+=diff(old, os, new, ns); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
142 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
143 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
144 pdiff+=(double)pdif; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
145 tdiff+=(double)tdif; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
146 bdiff+=(double)bdif; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
147 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
148 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
149 scale=1.0/(w*(h-3))/25.0; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
150 pdiff*=scale; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
151 tdiff*=scale; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
152 bdiff*=scale; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
153 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
154 if(mode==TOP_FIRST_ANALYZE) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
155 bdiff=65536.0; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
156 else if(mode==BOTTOM_FIRST_ANALYZE) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
157 tdiff=65536.0; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
158 else if(mode==ANALYZE) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
159 pdiff=65536.0; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
160 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
161 if(bdiff<pdiff && bdiff<tdiff) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
162 mode=BOTTOM_FIRST; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
163 else if(tdiff<pdiff && tdiff<bdiff) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
164 mode=TOP_FIRST; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
165 else |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
166 mode=PROGRESSIVE; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
167 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
168 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
169 if(verbose) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
170 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
171 printf("%c", mode==BOTTOM_FIRST?'b':mode==TOP_FIRST?'t':'p'); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
172 if(tdiff==65536.0) printf(" N/A "); else printf(" %8.2f", tdiff); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
173 if(bdiff==65536.0) printf(" N/A "); else printf(" %8.2f", bdiff); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
174 if(pdiff==65536.0) printf(" N/A "); else printf(" %8.2f", pdiff); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
175 printf(" \n"); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
176 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
177 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
178 return mode; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
179 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
180 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
181 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
182 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
183 mp_image_t *dmpi; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
184 int w; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
185 enum mode mode; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
186 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
187 if(!(dmpi=vf_get_image(vf->next, mpi->imgfmt, |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
188 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
189 mpi->w, mpi->h))) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
190 return 0; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
191 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
192 w=dmpi->w; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
193 if(!(dmpi->flags&MP_IMGFLAG_PLANAR)) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
194 w*=dmpi->bpp/8; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
195 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
196 mode=vf->priv->mode; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
197 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
198 if(!vf->priv->buf[0]) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
199 mode=PROGRESSIVE; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
200 else |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
201 mode=analyze_plane(vf->priv->buf[0], mpi->planes[0], |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
202 w, dmpi->h, w, mpi->stride[0], mode, |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
203 vf->priv->verbose, mpi->fields); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
204 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
205 do_plane(dmpi->planes[0], mpi->planes[0], |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
206 w, dmpi->h, |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
207 dmpi->stride[0], mpi->stride[0], |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
208 &vf->priv->buf[0], mode); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
209 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
210 if(dmpi->flags&MP_IMGFLAG_PLANAR) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
211 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
212 do_plane(dmpi->planes[1], mpi->planes[1], |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
213 dmpi->chroma_width, dmpi->chroma_height, |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
214 dmpi->stride[1], mpi->stride[1], |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
215 &vf->priv->buf[1], mode); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
216 do_plane(dmpi->planes[2], mpi->planes[2], |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
217 dmpi->chroma_width, dmpi->chroma_height, |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
218 dmpi->stride[2], mpi->stride[2], |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
219 &vf->priv->buf[2], mode); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
220 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
221 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
222 return vf_next_put_image(vf, dmpi); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
223 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
224 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
225 static void uninit(struct vf_instance_s* vf) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
226 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
227 free(vf->priv->buf[0]); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
228 free(vf->priv->buf[1]); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
229 free(vf->priv->buf[2]); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
230 free(vf->priv); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
231 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
232 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
233 static int open(vf_instance_t *vf, char* args) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
234 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
235 vf->put_image = put_image; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
236 vf->uninit = uninit; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
237 vf->default_reqs = VFCAP_ACCEPT_STRIDE; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
238 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
239 if(!(vf->priv = calloc(1, sizeof(struct vf_priv_s)))) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
240 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
241 uninit(vf); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
242 return 0; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
243 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
244 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
245 vf->priv->mode=AUTO_ANALYZE; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
246 vf->priv->verbose=0; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
247 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
248 while(args && *args) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
249 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
250 switch(*args) |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
251 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
252 case 't': vf->priv->mode=TOP_FIRST; break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
253 case 'a': vf->priv->mode=AUTO; break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
254 case 'b': vf->priv->mode=BOTTOM_FIRST; break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
255 case 'u': vf->priv->mode=ANALYZE; break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
256 case 'T': vf->priv->mode=TOP_FIRST_ANALYZE; break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
257 case 'A': vf->priv->mode=AUTO_ANALYZE; break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
258 case 'B': vf->priv->mode=BOTTOM_FIRST_ANALYZE; break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
259 case 'U': vf->priv->mode=FULL_ANALYZE; break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
260 case 'p': vf->priv->mode=PROGRESSIVE; break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
261 case 'v': vf->priv->verbose=1; break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
262 case ':': break; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
263 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
264 default: |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
265 uninit(vf); |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
266 return 0; /* bad args */ |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
267 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
268 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
269 if(args=strchr(args, ':')) args++; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
270 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
271 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
272 return 1; |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
273 } |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
274 |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
275 vf_info_t vf_info_phase = |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
276 { |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
277 "phase shift fields", |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
278 "phase", |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
279 "Ville Saari", |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
280 "", |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
281 open, |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
282 NULL |
e34700c872ac
vf_phase filter by Ville Saari (114263 at foo dot bar dot org)
rfelker
parents:
diff
changeset
|
283 }; |