31 #define accumulator int
33 #define pixel uint16_t
34 #define accumulator int64_t
37 #define fn3(a,b) a##_##b
38 #define fn2(a,b) fn3(a,b)
39 #define fn(a) fn2(a, DEPTH)
49 #define DIFF(a, as, b, bs) ((t) = ((*(a) - (b)[bs]) * 4) + (a)[(as) * 2] - (b)[-(bs)], (t) * (t))
57 double bdiff, tdiff, pdiff;
60 mode =
new->interlaced_frame ?
new->top_field_first ?
63 mode =
new->interlaced_frame ?
new->top_field_first ?
68 bdiff = pdiff = tdiff = 65536.0;
71 const int ns =
new->linesize[0] /
sizeof(
pixel);
72 const int os = old->linesize[0] /
sizeof(
pixel);
75 const int h =
new->height;
76 const int w =
new->width;
81 const pixel *rend, *end = nptr + (
h - 2) *
ns;
83 bdiff = pdiff = tdiff = 0.0;
88 pdif = tdif = bdif = 0;
93 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
95 tdif +=
DIFF(nptr,
ns, optr, os);
98 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
100 tdif +=
DIFF(optr, os, nptr,
ns);
106 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
108 bdif +=
DIFF(optr, os, nptr,
ns);
111 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
113 bdif +=
DIFF(nptr,
ns, optr, os);
119 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
120 tdif +=
DIFF(nptr,
ns, optr, os);
121 bdif +=
DIFF(optr, os, nptr,
ns);
124 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
125 bdif +=
DIFF(nptr,
ns, optr, os);
126 tdif +=
DIFF(optr, os, nptr,
ns);
132 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
134 tdif +=
DIFF(nptr,
ns, optr, os);
135 bdif +=
DIFF(optr, os, nptr,
ns);
138 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
140 bdif +=
DIFF(nptr,
ns, optr, os);
141 tdif +=
DIFF(optr, os, nptr,
ns);
170 if (bdiff < pdiff && bdiff < tdiff) {
172 }
else if (tdiff < pdiff && tdiff < bdiff) {
181 tdiff, bdiff, pdiff);