30 #define accumulator int
32 #define pixel uint16_t
33 #define accumulator int64_t
36 #define fn3(a,b) a##_##b
37 #define fn2(a,b) fn3(a,b)
38 #define fn(a) fn2(a, DEPTH)
48 #define DIFF(a, as, b, bs) ((t) = ((*(a) - (b)[bs]) * 4) + (a)[(as) * 2] - (b)[-(bs)], (t) * (t))
56 double bdiff, tdiff, pdiff;
67 bdiff = pdiff = tdiff = 65536.0;
70 const int ns =
new->linesize[0] /
sizeof(
pixel);
71 const int os = old->linesize[0] /
sizeof(
pixel);
74 const int h =
new->height;
75 const int w =
new->width;
80 const pixel *rend, *end = nptr + (
h - 2) *
ns;
82 bdiff = pdiff = tdiff = 0.0;
87 pdif = tdif = bdif = 0;
92 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
94 tdif +=
DIFF(nptr,
ns, optr, os);
97 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
99 tdif +=
DIFF(optr, os, nptr,
ns);
105 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
107 bdif +=
DIFF(optr, os, nptr,
ns);
110 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
112 bdif +=
DIFF(nptr,
ns, optr, os);
118 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
119 tdif +=
DIFF(nptr,
ns, optr, os);
120 bdif +=
DIFF(optr, os, nptr,
ns);
123 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
124 bdif +=
DIFF(nptr,
ns, optr, os);
125 tdif +=
DIFF(optr, os, nptr,
ns);
131 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
133 tdif +=
DIFF(nptr,
ns, optr, os);
134 bdif +=
DIFF(optr, os, nptr,
ns);
137 for (rend = nptr +
w; nptr < rend; nptr++, optr++) {
139 bdif +=
DIFF(nptr,
ns, optr, os);
140 tdif +=
DIFF(optr, os, nptr,
ns);
169 if (bdiff < pdiff && bdiff < tdiff) {
171 }
else if (tdiff < pdiff && tdiff < bdiff) {
180 tdiff, bdiff, pdiff);