44 { int score = FFABS(cur[mrefs - 1 + (j)] - cur[prefs - 1 - (j)])\
45 + FFABS(cur[mrefs +(j)] - cur[prefs -(j)])\
46 + FFABS(cur[mrefs + 1 + (j)] - cur[prefs + 1 - (j)]);\
47 if (score < spatial_score) {\
48 spatial_score= score;\
49 spatial_pred= (cur[mrefs +(j)] + cur[prefs -(j)])>>1;\
54 #define FILTER(start, end, is_not_edge) \
55 for (x = start; x < end; x++) { \
57 int d = (prev2[0] + next2[0])>>1; \
59 int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
60 int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \
61 int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
62 int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
63 int spatial_pred = (c+e) >> 1; \
66 int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
67 + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
68 CHECK(-1) CHECK(-2) }} }} \
69 CHECK( 1) CHECK( 2) }} }} \
73 int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
74 int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \
75 int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \
76 int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \
78 diff = FFMAX3(diff, min, -max); \
81 if (spatial_pred > d + diff) \
82 spatial_pred = d + diff; \
83 else if (spatial_pred < d - diff) \
84 spatial_pred = d - diff; \
86 dst[0] = spatial_pred; \
97 void *prev1,
void *cur1,
void *next1,
98 int w,
int prefs,
int mrefs,
int parity,
int mode)
105 uint8_t *prev2 = parity ? prev : cur ;
106 uint8_t *next2 = parity ? cur : next;
115 static void filter_edges(
void *dst1,
void *prev1,
void *cur1,
void *next1,
116 int w,
int prefs,
int mrefs,
int parity,
int mode)
123 uint8_t *prev2 = parity ? prev : cur ;
124 uint8_t *next2 = parity ? cur : next;
131 prev = (
uint8_t*)prev1 + w - 3;
133 next = (
uint8_t*)next1 + w - 3;
134 prev2 = (
uint8_t*)(parity ? prev : cur);
135 next2 = (
uint8_t*)(parity ? cur : next);
142 void *prev1,
void *cur1,
void *next1,
143 int w,
int prefs,
int mrefs,
int parity,
146 uint16_t *dst = dst1;
147 uint16_t *prev = prev1;
148 uint16_t *cur = cur1;
149 uint16_t *next = next1;
151 uint16_t *prev2 = parity ? prev : cur ;
152 uint16_t *next2 = parity ? cur : next;
160 int w,
int prefs,
int mrefs,
int parity,
int mode)
162 uint16_t *dst = dst1;
163 uint16_t *prev = prev1;
164 uint16_t *cur = cur1;
165 uint16_t *next = next1;
167 uint16_t *prev2 = parity ? prev : cur ;
168 uint16_t *next2 = parity ? cur : next;
174 dst = (uint16_t*)dst1 + w - 3;
175 prev = (uint16_t*)prev1 + w - 3;
176 cur = (uint16_t*)cur1 + w - 3;
177 next = (uint16_t*)next1 + w - 3;
178 prev2 = (uint16_t*)(parity ? prev : cur);
179 next2 = (uint16_t*)(parity ? cur : next);
191 int slice_h = td->
h / nb_jobs;
192 int slice_start = jobnr * slice_h;
193 int slice_end = (jobnr == nb_jobs - 1) ? td->
h : (jobnr + 1) * slice_h;
199 for (y = slice_start; y <
slice_end; y++) {
200 if ((y ^ td->
parity) & 1) {
205 int mode = y == 1 || y + 2 == td->
h ? 2 : s->
mode;
206 s->
filter_line(dst + pix_3, prev + pix_3, cur + pix_3,
207 next + pix_3, td->
w - 6,
208 y + 1 < td->
h ? refs : -refs,
212 y + 1 < td->
h ? refs : -refs,
231 int w = dstpic->
width;
234 if (i == 1 || i == 2) {
262 for (i = 0; i < 3; i++)
274 if (yadif->
parity == -1) {
290 filter(ctx, yadif->
out, tff ^ !is_second, tff);
293 int64_t cur_pts = yadif->
cur->
pts;
294 int64_t next_pts = yadif->
next->
pts;
297 yadif->
out->
pts = cur_pts + next_pts;
381 }
else if (ret < 0) {
384 }
while (!yadif->
cur);
402 if (val == 1 && !yadif->
next) {
409 assert(yadif->
next || !val);
414 return val * ((yadif->
mode&1)+1);
480 #define OFFSET(x) offsetof(YADIFContext, x)
481 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM
525 .priv_class = &yadif_class,
529 .
inputs = avfilter_vf_yadif_inputs,
531 .
outputs = avfilter_vf_yadif_outputs,