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)
117 double bdiff, tdiff, pdiff, scale;
118 const int ns =
new->linesize[0];
120 const uint8_t *nptr =
new->data[0];
122 const int h =
new->height;
123 const int w =
new->width;
124 int bdif, tdif, pdif;
127 mode =
new->interlaced_frame ?
new->top_field_first ?
130 mode =
new->interlaced_frame ?
new->top_field_first ?
135 bdiff = pdiff = tdiff = 65536.0;
138 const uint8_t *rend, *
end = nptr + (h - 2) * ns;
140 bdiff = pdiff = tdiff = 0.0;
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;
214 scale = 1.0 / (w * (h - 3)) / 25.0;
227 if (bdiff < pdiff && bdiff < tdiff) {
229 }
else if (tdiff < pdiff && tdiff < bdiff) {
238 tdiff, bdiff, pdiff);
274 for (plane = 0; plane < s->
nb_planes; plane++) {
279 for (y = 0, top = 1; y < s->
planeheight[plane]; y++, top ^= 1) {
323 .priv_class = &phase_class,