60 int logo_x,
int logo_y,
int logo_w,
int logo_h,
61 unsigned int band,
int show,
int direct)
64 uint64_t interp, weightl, weightr, weightt, weightb;
67 uint8_t *topleft, *botleft, *topright;
68 unsigned int left_sample, right_sample;
69 int xclipl, xclipr, yclipt, yclipb;
70 int logo_x1, logo_x2, logo_y1, logo_y2;
72 xclipl =
FFMAX(-logo_x, 0);
73 xclipr =
FFMAX(logo_x+logo_w-w, 0);
74 yclipt =
FFMAX(-logo_y, 0);
75 yclipb =
FFMAX(logo_y+logo_h-h, 0);
77 logo_x1 = logo_x + xclipl;
78 logo_x2 = logo_x + logo_w - xclipr;
79 logo_y1 = logo_y + yclipt;
80 logo_y2 = logo_y + logo_h - yclipb;
82 topleft = src+logo_y1 * src_linesize+logo_x1;
83 topright = src+logo_y1 * src_linesize+logo_x2-1;
84 botleft = src+(logo_y2-1) * src_linesize+logo_x1;
89 dst += (logo_y1 + 1) * dst_linesize;
90 src += (logo_y1 + 1) * src_linesize;
92 for (y = logo_y1+1; y < logo_y2-1; y++) {
93 left_sample = topleft[src_linesize*(y-logo_y1)] +
94 topleft[src_linesize*(y-logo_y1-1)] +
95 topleft[src_linesize*(y-logo_y1+1)];
96 right_sample = topright[src_linesize*(y-logo_y1)] +
97 topright[src_linesize*(y-logo_y1-1)] +
98 topright[src_linesize*(y-logo_y1+1)];
101 xdst = dst+logo_x1+1,
102 xsrc = src+logo_x1+1; x < logo_x2-1; x++, xdst++, xsrc++) {
105 weightl = (uint64_t) (logo_x2-1-x) * (y-logo_y1) * (logo_y2-1-y) * sar.
den;
106 weightr = (uint64_t)(x-logo_x1) * (y-logo_y1) * (logo_y2-1-y) * sar.
den;
107 weightt = (uint64_t)(x-logo_x1) * (logo_x2-1-x) * (logo_y2-1-y) * sar.
num;
108 weightb = (uint64_t)(x-logo_x1) * (logo_x2-1-x) * (y-logo_y1) * sar.
num;
111 left_sample * weightl
113 right_sample * weightr
115 (topleft[x-logo_x1] +
116 topleft[x-logo_x1-1] +
117 topleft[x-logo_x1+1]) * weightt
119 (botleft[x-logo_x1] +
120 botleft[x-logo_x1-1] +
121 botleft[x-logo_x1+1]) * weightb;
122 interp /= (weightl + weightr + weightt + weightb) * 3
U;
124 if (y >= logo_y+band && y < logo_y+logo_h-band &&
125 x >= logo_x+band && x < logo_x+logo_w-band) {
131 dist =
FFMAX(dist, logo_x-x+band);
132 else if (x >= logo_x+logo_w-band)
133 dist =
FFMAX(dist, x-(logo_x+logo_w-1-band));
136 dist =
FFMAX(dist, logo_y-y+band);
137 else if (y >= logo_y+logo_h-band)
138 dist =
FFMAX(dist, y-(logo_y+logo_h-1-band));
140 *xdst = (*xsrc*dist + interp*(band-dist))/
band;
141 if (show && (dist == band-1))
156 #define OFFSET(x) offsetof(DelogoContext, x)
157 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
189 #define CHECK_UNSET_OPT(opt) \
190 if (s->opt == -1) { \
191 av_log(s, AV_LOG_ERROR, "Option %s was not set.\n", #opt); \
192 return AVERROR(EINVAL); \
240 for (plane = 0; plane < 4 && in->
data[plane] && in->
linesize[plane]; plane++) {
241 int hsub = plane == 1 || plane == 2 ? hsub0 : 0;
242 int vsub = plane == 1 || plane == 2 ? vsub0 : 0;
248 sar, s->
x>>hsub, s->
y>>vsub,
284 .priv_class = &delogo_class,
287 .
inputs = avfilter_vf_delogo_inputs,
288 .
outputs = avfilter_vf_delogo_outputs,