43 { int score = FFABS(cur[mrefs - 1 + (j)] - cur[prefs - 1 - (j)])\
44 + FFABS(cur[mrefs +(j)] - cur[prefs -(j)])\
45 + FFABS(cur[mrefs + 1 + (j)] - cur[prefs + 1 - (j)]);\
46 if (score < spatial_score) {\
47 spatial_score= score;\
48 spatial_pred= (cur[mrefs +(j)] + cur[prefs -(j)])>>1;\
53 #define FILTER(start, end, is_not_edge) \
54 for (x = start; x < end; x++) { \
56 int d = (prev2[0] + next2[0])>>1; \
58 int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
59 int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \
60 int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
61 int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
62 int spatial_pred = (c+e) >> 1; \
65 int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
66 + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
67 CHECK(-1) CHECK(-2) }} }} \
68 CHECK( 1) CHECK( 2) }} }} \
72 int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
73 int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \
74 int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \
75 int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \
77 diff = FFMAX3(diff, min, -max); \
80 if (spatial_pred > d + diff) \
81 spatial_pred = d + diff; \
82 else if (spatial_pred < d - diff) \
83 spatial_pred = d - diff; \
85 dst[0] = spatial_pred; \
96 void *prev1,
void *cur1,
void *next1,
97 int w,
int prefs,
int mrefs,
int parity,
int mode)
104 uint8_t *prev2 = parity ? prev : cur ;
105 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;
134 prev2 = (
uint8_t*)(parity ? prev : cur);
135 next2 = (
uint8_t*)(parity ? cur : next);
143 void *prev1,
void *cur1,
void *next1,
144 int w,
int prefs,
int mrefs,
int parity,
147 uint16_t *dst = dst1;
148 uint16_t *prev = prev1;
149 uint16_t *cur = cur1;
150 uint16_t *next = next1;
152 uint16_t *prev2 = parity ? prev : cur ;
153 uint16_t *next2 = parity ? cur : next;
161 int w,
int prefs,
int mrefs,
int parity,
int mode)
163 uint16_t *dst = dst1;
164 uint16_t *prev = prev1;
165 uint16_t *cur = cur1;
166 uint16_t *next = next1;
168 uint16_t *prev2 = parity ? prev : cur ;
169 uint16_t *next2 = parity ? cur : next;
175 dst = (uint16_t*)dst1 + w - (
MAX_ALIGN/2-1);
176 prev = (uint16_t*)prev1 + w - (
MAX_ALIGN/2-1);
177 cur = (uint16_t*)cur1 + w - (
MAX_ALIGN/2-1);
178 next = (uint16_t*)next1 + w - (
MAX_ALIGN/2-1);
179 prev2 = (uint16_t*)(parity ? prev : cur);
180 next2 = (uint16_t*)(parity ? cur : next);
193 int slice_start = (td->
h * jobnr ) / nb_jobs;
194 int slice_end = (td->
h * (jobnr+1)) / nb_jobs;
200 for (y = slice_start; y <
slice_end; y++) {
201 if ((y ^ td->
parity) & 1) {
206 int mode = y == 1 || y + 2 == td->
h ? 2 : s->
mode;
207 s->
filter_line(dst + pix_3, prev + pix_3, cur + pix_3,
209 y + 1 < td->
h ? refs : -refs,
213 y + 1 < td->
h ? refs : -refs,
232 int w = dstpic->
width;
235 if (i == 1 || i == 2) {
257 if (yadif->
parity == -1) {
273 filter(ctx, yadif->
out, tff ^ !is_second, tff);
276 int64_t cur_pts = yadif->
cur->
pts;
277 int64_t next_pts = yadif->
next->
pts;
280 yadif->
out->
pts = cur_pts + next_pts;
366 }
else if (ret < 0) {
369 }
while (!yadif->
cur);
437 if (link->w < 3 || link->h < 3) {
438 av_log(ctx,
AV_LOG_ERROR,
"Video of less than 3 columns or lines is not supported\n");
443 if (
s->csp->comp[0].depth_minus1 / 8 == 1) {
458 #define OFFSET(x) offsetof(YADIFContext, x)
459 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
461 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
508 .priv_class = &yadif_class,
512 .
inputs = avfilter_vf_yadif_inputs,
513 .
outputs = avfilter_vf_yadif_outputs,