vf_delogo.c File Reference

A very simple tv station logo remover Ported from MPlayer libmpcodecs/vf_delogo.c. More...

#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"
Include dependency graph for vf_delogo.c:

Go to the source code of this file.

Data Structures

struct  DelogoContext
 

Macros

#define OFFSET(x)   offsetof(DelogoContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define CHECK_UNSET_OPT(opt)
 

Functions

static void apply_delogo (uint8_t *dst, int dst_linesize, uint8_t *src, int src_linesize, int w, int h, int logo_x, int logo_y, int logo_w, int logo_h, int band, int show, int direct)
 Apply a simple delogo algorithm to the image in dst and put the result in src. More...
 
 AVFILTER_DEFINE_CLASS (delogo)
 
static int query_formats (AVFilterContext *ctx)
 
static av_cold int init (AVFilterContext *ctx)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 

Variables

static const AVOption delogo_options []
 
static const AVFilterPad avfilter_vf_delogo_inputs []
 
static const AVFilterPad avfilter_vf_delogo_outputs []
 
AVFilter avfilter_vf_delogo
 

Detailed Description

A very simple tv station logo remover Ported from MPlayer libmpcodecs/vf_delogo.c.

Definition in file vf_delogo.c.

Macro Definition Documentation

#define CHECK_UNSET_OPT (   opt)
Value:
if (delogo->opt == -1) { \
av_log(delogo, AV_LOG_ERROR, "Option %s was not set.\n", #opt); \
return AVERROR(EINVAL); \
}
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:246
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:148
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFilterBuffer 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.Buffer references ownership and permissions
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 the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame This method is called when a frame is wanted on an output For an it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return it should return

Referenced by init().

Definition at line 143 of file vf_delogo.c.

#define OFFSET (   x)    offsetof(DelogoContext, x)

Definition at line 142 of file vf_delogo.c.

Function Documentation

static void apply_delogo ( uint8_t dst,
int  dst_linesize,
uint8_t src,
int  src_linesize,
int  w,
int  h,
int  logo_x,
int  logo_y,
int  logo_w,
int  logo_h,
int  band,
int  show,
int  direct 
)
static

Apply a simple delogo algorithm to the image in dst and put the result in src.

The algorithm is only applied to the region specified by the logo parameters.

Parameters
wwidth of the input image
hheight of the input image
logo_xx coordinate of the top left corner of the logo region
logo_yy coordinate of the top left corner of the logo region
logo_wwidth of the logo
logo_hheight of the logo
bandthe size of the band around the processed area
showshow a rectangle around the processed area, useful for parameters tweaking
directif non-zero perform in-place processing

Definition at line 55 of file vf_delogo.c.

Referenced by filter_frame().

AVFILTER_DEFINE_CLASS ( delogo  )
static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 201 of file vf_delogo.c.

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 171 of file vf_delogo.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 158 of file vf_delogo.c.

Variable Documentation

AVFilter avfilter_vf_delogo
Initial value:
= {
.name = "delogo",
.description = NULL_IF_CONFIG_SMALL("Remove logo from input video."),
.priv_size = sizeof(DelogoContext),
.priv_class = &delogo_class,
.init = init,
}
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:117
static int query_formats(AVFilterContext *ctx)
Definition: vf_delogo.c:158
static const AVFilterPad avfilter_vf_delogo_outputs[]
Definition: vf_delogo.c:254
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_cold int init(AVFilterContext *ctx)
Definition: vf_delogo.c:171
static const AVFilterPad avfilter_vf_delogo_inputs[]
Definition: vf_delogo.c:244
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

Definition at line 262 of file vf_delogo.c.

const AVFilterPad avfilter_vf_delogo_inputs[]
static
Initial value:
= {
{
.name = "default",
.get_video_buffer = ff_null_get_video_buffer,
.filter_frame = filter_frame,
},
{ NULL }
}
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:35
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_delogo.c:201
NULL
Definition: eval.c:55

Definition at line 244 of file vf_delogo.c.

const AVFilterPad avfilter_vf_delogo_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
NULL
Definition: eval.c:55

Definition at line 254 of file vf_delogo.c.

const AVOption delogo_options[]
static
Initial value:
= {
{ "x", "set logo x position", OFFSET(x), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
{ "y", "set logo y position", OFFSET(y), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
{ "w", "set logo width", OFFSET(w), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
{ "h", "set logo height", OFFSET(h), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
{ "band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { .i64 = 4 }, -1, INT_MAX, FLAGS },
{ "t", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, { .i64 = 4 }, -1, INT_MAX, FLAGS },
{ "show", "show delogo area", OFFSET(show), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
{ NULL },
}
#define FLAGS
Definition: vf_delogo.c:143
output residual component w
Discrete Time axis x
#define OFFSET(x)
Definition: vf_delogo.c:142
NULL
Definition: eval.c:55
function y
Definition: D.m:1

Definition at line 145 of file vf_delogo.c.