Go to the documentation of this file.
97 #define OFFSET(x) offsetof(RemovelogoContext, x)
98 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
117 #define apply_mask_fudge_factor(x) (((x) >> 2) + (x))
134 int w,
int h,
int min_val,
141 int current_pass = 0;
144 for (y = 0; y <
h; y++)
145 for (
x = 0;
x <
w;
x++)
146 data[y*linesize +
x] =
data[y*linesize +
x] > min_val;
156 int has_anything_changed = 0;
157 uint8_t *current_pixel0 =
data + 1 + linesize, *current_pixel;
160 for (y = 1; y <
h-1; y++) {
161 current_pixel = current_pixel0;
162 for (
x = 1;
x <
w-1;
x++) {
174 if ( *current_pixel >= current_pass &&
175 *(current_pixel + 1) >= current_pass &&
176 *(current_pixel - 1) >= current_pass &&
177 *(current_pixel + linesize) >= current_pass &&
178 *(current_pixel - linesize) >= current_pass) {
183 has_anything_changed = 1;
187 current_pixel0 += linesize;
189 if (!has_anything_changed)
195 for (y = 1; y <
h - 1; y++)
196 for (
x = 1;
x <
w - 1;
x++)
216 const char *filename,
void *log_ctx)
220 uint8_t *src_data[4], *gray_data[4];
221 int src_linesize[4], gray_linesize[4];
257 uint8_t *dst_data,
int dst_linesize,
258 int src_w,
int src_h,
265 for (y = 0; y < src_h/2; y++) {
266 for (
x = 0;
x < src_w/2;
x++) {
269 dst_data[(y * dst_linesize) +
x] =
270 src_data[((y << 1) * src_linesize) + (
x << 1)] ||
271 src_data[((y << 1) * src_linesize) + (
x << 1) + 1] ||
272 src_data[(((y << 1) + 1) * src_linesize) + (
x << 1)] ||
273 src_data[(((y << 1) + 1) * src_linesize) + (
x << 1) + 1];
274 dst_data[(y * dst_linesize) +
x] =
FFMIN(1, dst_data[(y * dst_linesize) +
x]);
279 src_w/2, src_h/2, 0, max_mask_size);
288 int full_max_mask_size, half_max_mask_size;
302 16, &full_max_mask_size);
308 s->half_mask_data,
w/2,
309 w,
h, &half_max_mask_size);
311 s->max_mask_size =
FFMAX(full_max_mask_size, half_max_mask_size);
321 for (
a = 0;
a <=
s->max_mask_size;
a++) {
327 for (
b = -
a;
b <=
a;
b++) {
333 for (
c = -
a;
c <=
a;
c++) {
334 if ((
b *
b) + (
c *
c) <= (
a *
a))
348 #define SHOW_LOGO_INFO(mask_type) \
349 av_log(ctx, AV_LOG_VERBOSE, #mask_type " x1:%d x2:%d y1:%d y2:%d max_mask_size:%d\n", \
350 s->mask_type##_mask_bbox.x1, s->mask_type##_mask_bbox.x2, \
351 s->mask_type##_mask_bbox.y1, s->mask_type##_mask_bbox.y2, \
352 mask_type##_max_mask_size);
366 "Mask image size %dx%d does not match with the input video size %dx%d\n",
389 const uint8_t *mask_data,
int mask_linesize,
390 uint8_t *image_data,
int image_linesize,
391 int w,
int h,
int x,
int y)
396 int start_posx, start_posy, end_posx, end_posy;
400 const uint8_t *image_read_position;
402 const uint8_t *mask_read_position;
405 mask_size = mask_data[y * mask_linesize +
x];
406 start_posx =
FFMAX(0,
x - mask_size);
407 start_posy =
FFMAX(0, y - mask_size);
408 end_posx =
FFMIN(
w - 1,
x + mask_size);
409 end_posy =
FFMIN(
h - 1, y + mask_size);
411 image_read_position = image_data + image_linesize * start_posy + start_posx;
412 mask_read_position = mask_data + mask_linesize * start_posy + start_posx;
414 for (j = start_posy; j <= end_posy; j++) {
415 for (
i = start_posx;
i <= end_posx;
i++) {
418 if (!(*mask_read_position) &&
mask[mask_size][
i - start_posx][j - start_posy]) {
423 image_read_position++;
424 mask_read_position++;
427 image_read_position += (image_linesize - ((end_posx + 1) - start_posx));
428 mask_read_position += (mask_linesize - ((end_posx + 1) - start_posx));
434 return divisor == 0 ? 255:
462 const uint8_t *src_data,
int src_linesize,
463 uint8_t *dst_data,
int dst_linesize,
464 const uint8_t *mask_data,
int mask_linesize,
475 for (y = bbox->
y1; y <= bbox->y2; y++) {
476 src_line = src_data + src_linesize * y;
477 dst_line = dst_data + dst_linesize * y;
479 for (
x = bbox->
x1; x <= bbox->x2;
x++) {
480 if (mask_data[y * mask_linesize +
x]) {
483 mask_data, mask_linesize,
484 dst_data, dst_linesize,
489 dst_line[
x] = src_line[
x];
504 outpicref = inpicref;
522 s->half_mask_data,
inlink->w/2,
527 s->half_mask_data,
inlink->w/2,
546 for (
a = 0;
a <=
s->max_mask_size;
a++) {
548 for (
b = -
a;
b <=
a;
b++) {
577 .
name =
"removelogo",
585 .priv_class = &removelogo_class,
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
AVFILTER_DEFINE_CLASS(removelogo)
static void direct(const float *in, const FFTComplex *ir, int len, float *out)
AVPixelFormat
Pixel format.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
AVFilter ff_vf_removelogo
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static const AVFilterPad removelogo_inputs[]
static av_cold int end(AVCodecContext *avctx)
FFBoundingBox full_mask_bbox
This structure describes decoded (raw) audio or video data.
static void convert_mask_to_strength_mask(uint8_t *data, int linesize, int w, int h, int min_val, int *max_mask_size)
Pre-process an image to give distance information.
static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
const char * name
Filter name.
A link between two filters.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int config_props_input(AVFilterLink *inlink)
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
static unsigned int blur_pixel(int ***mask, const uint8_t *mask_data, int mask_linesize, uint8_t *image_data, int image_linesize, int w, int h, int x, int y)
Blur image.
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo x
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
static const AVFilterPad outputs[]
static enum AVPixelFormat pix_fmts[]
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static enum AVPixelFormat pix_fmt
static const AVOption removelogo_options[]
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Describe the class of an AVClass context structure.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define apply_mask_fudge_factor(x)
Choose a slightly larger mask size to improve performance.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
FFBoundingBox half_mask_bbox
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int query_formats(AVFilterContext *ctx)
#define SHOW_LOGO_INFO(mask_type)
static void blur_image(int ***mask, const uint8_t *src_data, int src_linesize, uint8_t *dst_data, int dst_linesize, const uint8_t *mask_data, int mask_linesize, int w, int h, int direct, FFBoundingBox *bbox)
Blur image plane using a mask.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
int ff_load_image(uint8_t *data[4], int linesize[4], int *w, int *h, enum AVPixelFormat *pix_fmt, const char *filename, void *log_ctx)
Load image from filename and put the resulting image in data.
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
#define AV_LOG_INFO
Standard information.
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
#define i(width, name, range_min, range_max)
int w
agreed upon image width
static av_cold void uninit(AVFilterContext *ctx)
#define av_malloc_array(a, b)
const char * name
Pad name.
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo ug o o w
static void generate_half_size_image(const uint8_t *src_data, int src_linesize, uint8_t *dst_data, int dst_linesize, int src_w, int src_h, int *max_mask_size)
Generate a scaled down image with half width, height, and intensity.
int h
agreed upon image height
This code implements a filter to remove annoying TV logos and other annoying images placed onto a vid...
static av_cold int init(AVFilterContext *ctx)
static const AVFilterPad removelogo_outputs[]
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int load_mask(uint8_t **mask, int *w, int *h, const char *filename, void *log_ctx)
int ff_scale_image(uint8_t *dst_data[4], int dst_linesize[4], int dst_w, int dst_h, enum AVPixelFormat dst_pix_fmt, uint8_t *const src_data[4], int src_linesize[4], int src_w, int src_h, enum AVPixelFormat src_pix_fmt, void *log_ctx)
Scale image using libswscale.
int ff_calculate_bounding_box(FFBoundingBox *bbox, const uint8_t *data, int linesize, int w, int h, int min_val)
Calculate the smallest rectangle that will encompass the region with values > min_val.