35 { int score = FFABS(cur[mrefs - 1 + (j)] - cur[prefs - 1 - (j)])\
36 + FFABS(cur[mrefs +(j)] - cur[prefs -(j)])\
37 + FFABS(cur[mrefs + 1 + (j)] - cur[prefs + 1 - (j)]);\
38 if (score < spatial_score) {\
39 spatial_score= score;\
40 spatial_pred= (cur[mrefs +(j)] + cur[prefs -(j)])>>1;\
45 #define FILTER(start, end, is_not_edge) \
46 for (x = start; x < end; x++) { \
48 int d = (prev2[0] + next2[0])>>1; \
50 int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
51 int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \
52 int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
53 int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
54 int spatial_pred = (c+e) >> 1; \
57 int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
58 + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
59 CHECK(-1) CHECK(-2) }} }} \
60 CHECK( 1) CHECK( 2) }} }} \
64 int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
65 int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \
66 int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \
67 int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \
69 diff = FFMAX3(diff, min, -max); \
72 if (spatial_pred > d + diff) \
73 spatial_pred = d + diff; \
74 else if (spatial_pred < d - diff) \
75 spatial_pred = d - diff; \
77 dst[0] = spatial_pred; \
88 void *prev1,
void *cur1,
void *next1,
89 int w,
int prefs,
int mrefs,
int parity,
int mode)
96 uint8_t *prev2 = parity ? prev : cur ;
97 uint8_t *next2 = parity ? cur : next;
106 static void filter_edges(
void *dst1,
void *prev1,
void *cur1,
void *next1,
107 int w,
int prefs,
int mrefs,
int parity,
int mode)
114 uint8_t *prev2 = parity ? prev : cur ;
115 uint8_t *next2 = parity ? cur : next;
122 prev = (
uint8_t*)prev1 + w - 3;
124 next = (
uint8_t*)next1 + w - 3;
125 prev2 = (
uint8_t*)(parity ? prev : cur);
126 next2 = (
uint8_t*)(parity ? cur : next);
133 void *prev1,
void *cur1,
void *next1,
134 int w,
int prefs,
int mrefs,
int parity,
137 uint16_t *
dst = dst1;
138 uint16_t *prev = prev1;
139 uint16_t *cur = cur1;
140 uint16_t *next = next1;
142 uint16_t *prev2 = parity ? prev : cur ;
143 uint16_t *next2 = parity ? cur : next;
151 int w,
int prefs,
int mrefs,
int parity,
int mode)
153 uint16_t *
dst = dst1;
154 uint16_t *prev = prev1;
155 uint16_t *cur = cur1;
156 uint16_t *next = next1;
158 uint16_t *prev2 = parity ? prev : cur ;
159 uint16_t *next2 = parity ? cur : next;
165 dst = (uint16_t*)dst1 + w - 3;
166 prev = (uint16_t*)prev1 + w - 3;
167 cur = (uint16_t*)cur1 + w - 3;
168 next = (uint16_t*)next1 + w - 3;
169 prev2 = (uint16_t*)(parity ? prev : cur);
170 next2 = (uint16_t*)(parity ? cur : next);
182 int w = dstpic->
width;
188 if (i == 1 || i == 2) {
198 for (y = 0; y < h; y++) {
199 if ((y ^ parity) & 1) {
204 int mode = y == 1 || y + 2 == h ? 2 : yadif->
mode;
205 yadif->
filter_line(dst + pix_3, prev + pix_3, cur + pix_3,
207 y + 1 < h ? refs : -refs,
211 y + 1 < h ? refs : -refs,
216 &yadif->
cur->
data[i][y * refs], w * df);
230 if (yadif->
parity == -1) {
246 filter(ctx, yadif->
out, tff ^ !is_second, tff);
249 int64_t cur_pts = yadif->
cur->
pts;
250 int64_t next_pts = yadif->
next->
pts;
253 yadif->
out->
pts = cur_pts + next_pts;
339 }
else if (ret < 0) {
342 }
while (!yadif->
cur);
410 if (link->w < 3 || link->h < 3) {
411 av_log(ctx,
AV_LOG_ERROR,
"Video of less than 3 columns or lines is not supported\n");
416 if (
s->csp->comp[0].depth_minus1 / 8 == 1) {
431 #define OFFSET(x) offsetof(YADIFContext, x)
432 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
434 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
481 .priv_class = &yadif_class,
485 .
inputs = avfilter_vf_yadif_inputs,
486 .
outputs = avfilter_vf_yadif_outputs,