51 #define OFFSET(x) offsetof(PhaseContext, x)
52 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
53 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, unit }
109 #define DIFF(a, as, b, bs) (t = ((*a - b[bs]) << 2) + a[as << 1] - b[-bs], t * t)
118 double bdiff, tdiff, pdiff,
scale;
119 const int ns =
new->linesize[0];
123 const int h =
new->height;
124 const int w =
new->width;
125 int bdif, tdif, pdif;
131 mode =
new->interlaced_frame ?
new->top_field_first ?
134 mode =
new->interlaced_frame ?
new->top_field_first ?
139 bdiff = pdiff = tdiff = 65536.0;
141 bdiff = pdiff = tdiff = 0.0;
143 for (end = nptr + (h - 2) * ns, nptr += ns, optr += os, top = 0;
144 nptr <
end; nptr += ns - w, optr += os - w, top ^= 1) {
145 pdif = tdif = bdif = 0;
150 for (rend = nptr + w; nptr < rend; nptr++, optr++) {
151 pdif +=
DIFF(nptr, ns, nptr, ns);
152 tdif +=
DIFF(nptr, ns, optr, os);
155 for (rend = nptr + w; nptr < rend; nptr++, optr++) {
156 pdif +=
DIFF(nptr, ns, nptr, ns);
157 tdif +=
DIFF(optr, os, nptr, ns);
163 for (rend = nptr + w; nptr < rend; nptr++, optr++) {
164 pdif +=
DIFF(nptr, ns, nptr, ns);
165 bdif +=
DIFF(optr, os, nptr, ns);
168 for (rend = nptr + w; nptr < rend; nptr++, optr++) {
169 pdif +=
DIFF(nptr, ns, nptr, ns);
170 bdif +=
DIFF(nptr, ns, optr, os);
176 for (rend = nptr + w; nptr < rend; nptr++, optr++) {
177 tdif +=
DIFF(nptr, ns, optr, os);
178 bdif +=
DIFF(optr, os, nptr, ns);
181 for (rend = nptr + w; nptr < rend; nptr++, optr++) {
182 bdif +=
DIFF(nptr, ns, optr, os);
183 tdif +=
DIFF(optr, os, nptr, ns);
189 for (rend = nptr + w; nptr < rend; nptr++, optr++) {
190 pdif +=
DIFF(nptr, ns, nptr, ns);
191 tdif +=
DIFF(nptr, ns, optr, os);
192 bdif +=
DIFF(optr, os, nptr, ns);
195 for (rend = nptr + w; nptr < rend; nptr++, optr++) {
196 pdif +=
DIFF(nptr, ns, nptr, ns);
197 bdif +=
DIFF(nptr, ns, optr, os);
198 tdif +=
DIFF(optr, os, nptr, ns);
206 pdiff += (double)pdif;
207 tdiff += (double)tdif;
208 bdiff += (double)bdif;
211 scale = 1.0 / (w * (h - 3)) / 25.0;
224 if (bdiff < pdiff && bdiff < tdiff) {
226 }
else if (tdiff < pdiff && tdiff < bdiff) {
235 tdiff, bdiff, pdiff);
267 for (plane = 0; plane < s->
nb_planes; plane++) {
272 for (y = 0, top = 1; y < s->
planeheight[plane]; y++, top ^= 1) {
274 memcpy(buf, from, s->
linesize[plane]);
315 .priv_class = &phase_class,