104 #define apply_mask_fudge_factor(x) (((x) >> 2) + x)
121 int w,
int h,
int min_val,
128 int current_pass = 0;
131 for (y = 0; y < h; y++)
132 for (x = 0; x < w; x++)
133 data[y*linesize + x] = data[y*linesize + x] > min_val;
143 int has_anything_changed = 0;
147 for (y = 1; y < h-1; y++) {
148 current_pixel = current_pixel0;
149 for (x = 1; x < w-1; x++) {
161 if ( *current_pixel >= current_pass &&
162 *(current_pixel + 1) >= current_pass &&
163 *(current_pixel - 1) >= current_pass &&
164 *(current_pixel + w) >= current_pass &&
165 *(current_pixel - w) >= current_pass) {
170 has_anything_changed = 1;
174 current_pixel0 += linesize;
176 if (!has_anything_changed)
182 for (y = 1; y < h - 1; y++)
183 for (x = 1; x < w - 1; x++)
201 const char *filename,
void *log_ctx)
205 uint8_t *src_data[4], *gray_data[4];
206 int src_linesize[4], gray_linesize[4];
209 if ((ret =
ff_load_image(src_data, src_linesize, w, h, &pix_fmt, filename, log_ctx)) < 0)
214 src_data, src_linesize, *w, *h, pix_fmt,
242 uint8_t *dst_data,
int dst_linesize,
243 int src_w,
int src_h,
250 for (y = 0; y < src_h/2; y++) {
251 for (x = 0; x < src_w/2; x++) {
254 dst_data[(y * dst_linesize) + x] =
255 src_data[((y << 1) * src_linesize) + (x << 1)] ||
256 src_data[((y << 1) * src_linesize) + (x << 1) + 1] ||
257 src_data[(((y << 1) + 1) * src_linesize) + (x << 1)] ||
258 src_data[(((y << 1) + 1) * src_linesize) + (x << 1) + 1];
259 dst_data[(y * dst_linesize) + x] =
FFMIN(1, dst_data[(y * dst_linesize) + x]);
264 src_w/2, src_h/2, 0, max_mask_size);
273 int full_max_mask_size, half_max_mask_size;
287 16, &full_max_mask_size);
294 w, h, &half_max_mask_size);
307 mask[
a] = (
int **)
av_malloc(
sizeof(
int *) * ((a * 2) + 1));
310 for (b = -a; b <=
a; b++) {
311 mask[
a][b +
a] = (
int *)
av_malloc(
sizeof(
int) * ((a * 2) + 1));
314 for (c = -a; c <=
a; c++) {
315 if ((b * b) + (c * c) <= (a * a))
316 mask[
a][b +
a][c +
a] = 1;
318 mask[
a][b +
a][c +
a] = 0;
329 #define SHOW_LOGO_INFO(mask_type) \
330 av_log(ctx, AV_LOG_VERBOSE, #mask_type " x1:%d x2:%d y1:%d y2:%d max_mask_size:%d\n", \
331 removelogo->mask_type##_mask_bbox.x1, removelogo->mask_type##_mask_bbox.x2, \
332 removelogo->mask_type##_mask_bbox.y1, removelogo->mask_type##_mask_bbox.y2, \
333 mask_type##_max_mask_size);
345 if (inlink->
w != removelogo->
mask_w || inlink->
h != removelogo->
mask_h) {
347 "Mask image size %dx%d does not match with the input video size %dx%d\n",
370 const uint8_t *mask_data,
int mask_linesize,
371 uint8_t *image_data,
int image_linesize,
372 int w,
int h,
int x,
int y)
377 int start_posx, start_posy, end_posx, end_posy;
379 unsigned int accumulator = 0, divisor = 0;
381 const uint8_t *image_read_position;
383 const uint8_t *mask_read_position;
386 mask_size = mask_data[y * mask_linesize + x];
387 start_posx =
FFMAX(0, x - mask_size);
388 start_posy =
FFMAX(0, y - mask_size);
389 end_posx =
FFMIN(w - 1, x + mask_size);
390 end_posy =
FFMIN(h - 1, y + mask_size);
392 image_read_position = image_data + image_linesize * start_posy + start_posx;
393 mask_read_position = mask_data + mask_linesize * start_posy + start_posx;
395 for (j = start_posy; j <= end_posy; j++) {
396 for (i = start_posx; i <= end_posx; i++) {
399 if (!(*mask_read_position) && mask[mask_size][i - start_posx][j - start_posy]) {
400 accumulator += *image_read_position;
404 image_read_position++;
405 mask_read_position++;
408 image_read_position += (image_linesize - ((end_posx + 1) - start_posx));
409 mask_read_position += (mask_linesize - ((end_posx + 1) - start_posx));
415 return divisor == 0 ? 255:
416 (accumulator + (divisor / 2)) / divisor;
443 const uint8_t *src_data,
int src_linesize,
444 uint8_t *dst_data,
int dst_linesize,
445 const uint8_t *mask_data,
int mask_linesize,
446 int w,
int h,
int direct,
456 for (y = bbox->
y1; y <= bbox->y2; y++) {
457 src_line = src_data + src_linesize * y;
458 dst_line = dst_data + dst_linesize * y;
460 for (x = bbox->
x1; x <= bbox->x2; x++) {
461 if (mask_data[y * mask_linesize + x]) {
464 mask_data, mask_linesize,
465 dst_data, dst_linesize,
470 dst_line[x] = src_line[x];
485 outpicref = inpicref;
525 if (removelogo->
mask) {
529 for (b = -a; b <=
a; b++) {
560 .
name =
"removelogo",
566 .
inputs = removelogo_inputs,