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;
119 int absrefs =
FFABS(refs);
122 if (i == 1 || i == 2) {
134 for (y = 0; y < h; y++) {
135 if ((y ^ parity) & 1) {
140 int mode = y == 1 || y + 2 == h ? 2 : yadif->
mode;
141 int prefs = y+1<h ? refs : -refs;
142 int mrefs = y ?-refs : refs;
147 memcpy(tmp+2*mrefs, cur+2*mrefs, w*df);
148 memcpy(tmp+mrefs, cur+mrefs, w*df);
149 memcpy(tmp , cur , w*df);
151 memcpy(tmp+prefs, cur+prefs, w*df);
153 memcpy(tmp+2*prefs, cur+2*prefs, w*df);
163 &yadif->
cur->
data[i][y * refs], w * df);
177 if (yadif->
parity == -1) {
198 filter(ctx, yadif->
out, tff ^ !is_second, tff);
201 int64_t cur_pts = yadif->
cur->
pts;
202 int64_t next_pts = yadif->
next->
pts;
205 yadif->
out->
pts = cur_pts + next_pts;
230 yadif->
next = picref;
292 }
else if (ret < 0) {
295 }
while (!yadif->
cur);
300 #define OFFSET(x) offsetof(YADIFContext, x)
301 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
303 #define CONST(name, help, val, unit) { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, INT_MIN, INT_MAX, FLAGS, unit }
372 static const char *shorthand[] = {
"mode",
"parity",
"deint",
NULL };
377 yadif->
class = &yadif_class;
407 if (link->w < 3 || link->h < 3) {
408 av_log(ctx,
AV_LOG_ERROR,
"Video of less than 3 columns or lines is not supported\n");
444 .
inputs = avfilter_vf_yadif_inputs,
445 .
outputs = avfilter_vf_yadif_outputs,
447 .priv_class = &yadif_class,