FFmpeg
Loading...
Searching...
No Matches
vf_delogo.c File Reference

A very simple tv station logo remover Originally imported from MPlayer libmpcodecs/vf_delogo.c, the algorithm was later improved. More...

#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/eval.h"
#include "avfilter.h"
#include "filters.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  DelogoContext
 

Macros

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

Enumerations

enum  var_name {
  VAR_X , VAR_Y , VAR_W , VAR_H ,
  VAR_N , VAR_T , VAR_VARS_NB
}
 

Functions

static int set_expr (AVExpr **pexpr, const char *expr, const char *option, void *log_ctx)
 
static void apply_delogo (uint8_t *dst, int dst_linesize, uint8_t *src, int src_linesize, int w, int h, AVRational sar, int logo_x, int logo_y, int logo_w, int logo_h, unsigned int band, int show, int direct)
 Apply a simple delogo algorithm to the image in src and put the result in dst.
 
 AVFILTER_DEFINE_CLASS (delogo)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static av_cold int init (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 

Variables

static const char *const var_names []
 
static const AVOption delogo_options []
 
static enum AVPixelFormat pix_fmts []
 
static const AVFilterPad avfilter_vf_delogo_inputs []
 
const FFFilter ff_vf_delogo
 

Detailed Description

A very simple tv station logo remover Originally imported from MPlayer libmpcodecs/vf_delogo.c, the algorithm was later improved.

Definition in file vf_delogo.c.

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 204 of file vf_delogo.c.

◆ FLAGS

Definition at line 205 of file vf_delogo.c.

◆ CHECK_UNSET_OPT

#define CHECK_UNSET_OPT ( opt)
Value:
if (s->opt == -1) { \
av_log(ctx, AV_LOG_ERROR, "Option %s was not set.\n", #opt); \
return AVERROR(EINVAL); \
}
static AVFormatContext * ctx
#define s(width, name)
Definition cbs_vp9.c:198
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210

Referenced by init().

Enumeration Type Documentation

◆ var_name

enum var_name
Enumerator
VAR_X 
VAR_Y 
VAR_W 
VAR_H 
VAR_N 
VAR_T 
VAR_VARS_NB 

Definition at line 48 of file vf_delogo.c.

Function Documentation

◆ set_expr()

static int set_expr ( AVExpr ** pexpr,
const char * expr,
const char * option,
void * log_ctx )
static

Definition at line 58 of file vf_delogo.c.

Referenced by init().

◆ apply_delogo()

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

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

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 97 of file vf_delogo.c.

Referenced by filter_frame().

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( delogo )

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 217 of file vf_delogo.c.

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 234 of file vf_delogo.c.

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 273 of file vf_delogo.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink * inlink,
AVFrame * in )
static

Definition at line 288 of file vf_delogo.c.

Variable Documentation

◆ var_names

const char* const var_names[]
static
Initial value:
= {
"x",
"y",
"w",
"h",
"n",
"t",
}
#define NULL
Definition coverity.c:32

Definition at line 38 of file vf_delogo.c.

◆ delogo_options

const AVOption delogo_options[]
static
Initial value:
= {
{ "x", "set logo x position", OFFSET(x_expr), AV_OPT_TYPE_STRING, { .str = "-1" }, 0, 0, FLAGS },
{ "y", "set logo y position", OFFSET(y_expr), AV_OPT_TYPE_STRING, { .str = "-1" }, 0, 0, FLAGS },
{ "w", "set logo width", OFFSET(w_expr), AV_OPT_TYPE_STRING, { .str = "-1" }, 0, 0, FLAGS },
{ "h", "set logo height", OFFSET(h_expr), AV_OPT_TYPE_STRING, { .str = "-1" }, 0, 0, FLAGS },
{ "show", "show delogo area", OFFSET(show), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
{ NULL }
}
#define FLAGS
Definition cmdutils.c:598
#define OFFSET(x)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275

Definition at line 207 of file vf_delogo.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
}
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition pixfmt.h:106
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition pixfmt.h:108
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition pixfmt.h:79
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition pixfmt.h:80
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78

Definition at line 227 of file vf_delogo.c.

◆ avfilter_vf_delogo_inputs

const AVFilterPad avfilter_vf_delogo_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
.config_props = config_input,
},
}
static int config_input(AVFilterLink *inlink)
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200

Definition at line 377 of file vf_delogo.c.

◆ ff_vf_delogo

const FFFilter ff_vf_delogo
Initial value:
= {
.p.name = "delogo",
.p.description = NULL_IF_CONFIG_SMALL("Remove logo from input video."),
.p.priv_class = &delogo_class,
.priv_size = sizeof(DelogoContext),
.init = init,
}
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition avfilter.h:196
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:244
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
static const AVFilterPad avfilter_vf_delogo_inputs[]
Definition vf_delogo.c:377
const AVFilterPad ff_video_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_VIDEO.
Definition video.c:37

Definition at line 386 of file vf_delogo.c.