29 #define accumulator int
31 #define pixel uint16_t
32 #define accumulator int64_t
35 #define fn3(a,b) a##_##b
36 #define fn2(a,b) fn3(a,b)
37 #define fn(a) fn2(a, DEPTH)
47 #define DIFF(a, as, b, bs) ((t) = ((*(a) - (b)[bs]) * 4) + (a)[(as) * 2] - (b)[-(bs)], (t) * (t))
55 double bdiff, tdiff, pdiff;
66 bdiff = pdiff = tdiff = 65536.0;
69 const int ns =
new->linesize[0] /
sizeof(
pixel);
70 const int os = old->linesize[0] /
sizeof(
pixel);
73 const int h =
new->height;
74 const int w =
new->width;
79 const pixel *rend, *end = nptr + (
h - 2) *
ns;
81 bdiff = pdiff = tdiff = 0.0;
86 pdif = tdif = bdif = 0;
91 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
93 tdif +=
DIFF(nptr,
ns, optr, os);
96 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
98 tdif +=
DIFF(optr, os, nptr,
ns);
104 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
106 bdif +=
DIFF(optr, os, nptr,
ns);
109 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
111 bdif +=
DIFF(nptr,
ns, optr, os);
117 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
118 tdif +=
DIFF(nptr,
ns, optr, os);
119 bdif +=
DIFF(optr, os, nptr,
ns);
122 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
123 bdif +=
DIFF(nptr,
ns, optr, os);
124 tdif +=
DIFF(optr, os, nptr,
ns);
130 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
132 tdif +=
DIFF(nptr,
ns, optr, os);
133 bdif +=
DIFF(optr, os, nptr,
ns);
136 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
138 bdif +=
DIFF(nptr,
ns, optr, os);
139 tdif +=
DIFF(optr, os, nptr,
ns);
168 if (bdiff < pdiff && bdiff < tdiff) {
170 }
else if (tdiff < pdiff && tdiff < bdiff) {
179 tdiff, bdiff, pdiff);