37 #define fixed_mode(p) ((p)<=BOTTOM_FIRST)
43 unsigned char *
buf[3];
52 int w,
int h,
int ts,
int fs,
53 unsigned char **bufp,
enum mode mode)
61 if(!(*bufp=malloc(h*w)))
return;
64 for(end=to+h*ts, buf=*bufp, top=1; to<
end; from+=fs, to+=ts, buf+=w, top^=1)
80 #define diff(a, as, b, bs) (t=((*a-b[bs])<<2)+a[as<<1]-b[-bs], t*t)
88 int w,
int h,
int os,
int ns,
enum mode mode,
89 int verbose,
int fields)
91 double bdiff, pdiff, tdiff,
scale;
94 unsigned char *
end, *rend;
104 bdiff=pdiff=tdiff=65536.0;
107 bdiff=pdiff=tdiff=0.0;
109 for(end=
new+(h-2)*ns,
new+=ns, old+=os, top=0;
110 new<
end;
new+=ns-w, old+=os-w, top^=1)
118 for(rend=
new+w;
new<rend;
new++, old++)
119 pdif+=
diff(
new, ns,
new, ns),
120 tdif+=
diff(
new, ns, old, os);
122 for(rend=
new+w;
new<rend;
new++, old++)
123 pdif+=
diff(
new, ns,
new, ns),
124 tdif+=
diff(old, os,
new, ns);
129 for(rend=
new+w;
new<rend;
new++, old++)
130 pdif+=
diff(
new, ns,
new, ns),
131 bdif+=
diff(old, os,
new, ns);
133 for(rend=
new+w;
new<rend;
new++, old++)
134 pdif+=
diff(
new, ns,
new, ns),
135 bdif+=
diff(
new, ns, old, os);
140 for(rend=
new+w;
new<rend;
new++, old++)
141 tdif+=
diff(
new, ns, old, os),
142 bdif+=
diff(old, os,
new, ns);
144 for(rend=
new+w;
new<rend;
new++, old++)
145 bdif+=
diff(
new, ns, old, os),
146 tdif+=
diff(old, os,
new, ns);
151 for(rend=
new+w;
new<rend;
new++, old++)
152 pdif+=
diff(
new, ns,
new, ns),
153 tdif+=
diff(
new, ns, old, os),
154 bdif+=
diff(old, os,
new, ns);
156 for(rend=
new+w;
new<rend;
new++, old++)
157 pdif+=
diff(
new, ns,
new, ns),
158 bdif+=
diff(
new, ns, old, os),
159 tdif+=
diff(old, os,
new, ns);
167 scale=1.0/(w*(h-3))/25.0;
179 if(bdiff<pdiff && bdiff<tdiff)
181 else if(tdiff<pdiff && tdiff<bdiff)
216 if(!vf->priv->buf[0])
220 w, dmpi->
h, w, mpi->
stride[0], mode,
221 vf->priv->verbose, mpi->
fields);
226 &vf->priv->buf[0], mode);
233 &vf->priv->buf[1], mode);
237 &vf->priv->buf[2], mode);
243 static void uninit(
struct vf_instance *vf)
247 free(vf->priv->buf[0]);
248 free(vf->priv->buf[1]);
249 free(vf->priv->buf[2]);
289 if( (args=strchr(args,
':')) ) args++;
297 "phase shift fields",