34 #define PERM_RWP AV_PERM_WRITE | AV_PERM_PRESERVE | AV_PERM_REUSE
37 { int score = FFABS(cur[mrefs-1+(j)] - cur[prefs-1-(j)])\
38 + FFABS(cur[mrefs +(j)] - cur[prefs -(j)])\
39 + FFABS(cur[mrefs+1+(j)] - cur[prefs+1-(j)]);\
40 if (score < spatial_score) {\
41 spatial_score= score;\
42 spatial_pred= (cur[mrefs +(j)] + cur[prefs -(j)])>>1;\
45 for (x = 0; x < w; x++) { \
47 int d = (prev2[0] + next2[0])>>1; \
49 int temporal_diff0 = FFABS(prev2[0] - next2[0]); \
50 int temporal_diff1 =(FFABS(prev[mrefs] - c) + FFABS(prev[prefs] - e) )>>1; \
51 int temporal_diff2 =(FFABS(next[mrefs] - c) + FFABS(next[prefs] - e) )>>1; \
52 int diff = FFMAX3(temporal_diff0 >> 1, temporal_diff1, temporal_diff2); \
53 int spatial_pred = (c+e) >> 1; \
54 int spatial_score = FFABS(cur[mrefs - 1] - cur[prefs - 1]) + FFABS(c-e) \
55 + FFABS(cur[mrefs + 1] - cur[prefs + 1]) - 1; \
57 CHECK(-1) CHECK(-2) }} }} \
58 CHECK( 1) CHECK( 2) }} }} \
61 int b = (prev2[2 * mrefs] + next2[2 * mrefs])>>1; \
62 int f = (prev2[2 * prefs] + next2[2 * prefs])>>1; \
63 int max = FFMAX3(d - e, d - c, FFMIN(b - c, f - e)); \
64 int min = FFMIN3(d - e, d - c, FFMAX(b - c, f - e)); \
66 diff = FFMAX3(diff, min, -max); \
69 if (spatial_pred > d + diff) \
70 spatial_pred = d + diff; \
71 else if (spatial_pred < d - diff) \
72 spatial_pred = d - diff; \
74 dst[0] = spatial_pred; \
86 int w,
int prefs,
int mrefs,
int parity,
int mode)
96 uint16_t *prev, uint16_t *cur, uint16_t *next,
97 int w,
int prefs,
int mrefs,
int parity,
101 uint16_t *
prev2 = parity ? prev : cur ;
102 uint16_t *
next2 = parity ? cur : next;
121 if (i == 1 || i == 2) {
127 for (y = 0; y < h; y++) {
128 if ((y ^ parity) & 1) {
133 int mode = y == 1 || y + 2 == h ? 2 : yadif->
mode;
135 y + 1 < h ? refs : -refs,
140 &yadif->
cur->
data[i][y * refs], w * df);
161 for (i = 0; i < 3; i++)
173 if (yadif->
parity == -1) {
194 filter(ctx, yadif->
out, tff ^ !is_second, tff);
197 int64_t cur_pts = yadif->
cur->
pts;
198 int64_t next_pts = yadif->
next->
pts;
201 yadif->
out->
pts = cur_pts + next_pts;
224 yadif->
next = picref;
287 }
else if (ret < 0) {
290 }
while (!yadif->
cur);
308 if (val == 1 && !yadif->
next) {
315 assert(yadif->
next || !val);
320 return val * ((yadif->
mode&1)+1);
372 sscanf(args,
"%d:%d:%d",
426 .
inputs = avfilter_vf_yadif_inputs,
428 .
outputs = avfilter_vf_yadif_outputs,