58 int logo_x,
int logo_y,
int logo_w,
int logo_h,
59 int band,
int show,
int direct)
65 uint8_t *topleft, *botleft, *topright;
66 int xclipl, xclipr, yclipt, yclipb;
67 int logo_x1, logo_x2, logo_y1, logo_y2;
69 xclipl =
FFMAX(-logo_x, 0);
70 xclipr =
FFMAX(logo_x+logo_w-w, 0);
71 yclipt =
FFMAX(-logo_y, 0);
72 yclipb =
FFMAX(logo_y+logo_h-h, 0);
74 logo_x1 = logo_x + xclipl;
75 logo_x2 = logo_x + logo_w - xclipr;
76 logo_y1 = logo_y + yclipt;
77 logo_y2 = logo_y + logo_h - yclipb;
79 topleft = src+logo_y1 * src_linesize+logo_x1;
80 topright = src+logo_y1 * src_linesize+logo_x2-1;
81 botleft = src+(logo_y2-1) * src_linesize+logo_x1;
86 dst += (logo_y1 + 1) * dst_linesize;
87 src += (logo_y1 + 1) * src_linesize;
89 for (y = logo_y1+1; y < logo_y2-1; y++) {
92 xsrc = src+logo_x1+1; x < logo_x2-1; x++, xdst++, xsrc++) {
93 interp = (topleft[src_linesize*(y-logo_y -yclipt)] +
94 topleft[src_linesize*(y-logo_y-1-yclipt)] +
95 topleft[src_linesize*(y-logo_y+1-yclipt)]) * (logo_w-(x-logo_x))/logo_w
96 + (topright[src_linesize*(y-logo_y-yclipt)] +
97 topright[src_linesize*(y-logo_y-1-yclipt)] +
98 topright[src_linesize*(y-logo_y+1-yclipt)]) * (x-logo_x)/logo_w
99 + (topleft[x-logo_x-xclipl] +
100 topleft[x-logo_x-1-xclipl] +
101 topleft[x-logo_x+1-xclipl]) * (logo_h-(y-logo_y))/logo_h
102 + (botleft[x-logo_x-xclipl] +
103 botleft[x-logo_x-1-xclipl] +
104 botleft[x-logo_x+1-xclipl]) * (y-logo_y)/logo_h;
107 if (y >= logo_y+band && y < logo_y+logo_h-band &&
108 x >= logo_x+band && x < logo_x+logo_w-band) {
113 dist =
FFMAX(dist, logo_x-x+band);
114 else if (x >= logo_x+logo_w-band)
115 dist =
FFMAX(dist, x-(logo_x+logo_w-1-band));
118 dist =
FFMAX(dist, logo_y-y+band);
119 else if (y >= logo_y+logo_h-band)
120 dist =
FFMAX(dist, y-(logo_y+logo_h-1-band));
122 *xdst = (*xsrc*dist + interp*(band-dist))/band;
123 if (show && (dist == band-1))
135 int x,
y, w, h, band, show;
138 #define OFFSET(x) offsetof(DelogoContext, x)
184 ret = sscanf(args,
"%d:%d:%d:%d:%d",
185 &delogo->
x, &delogo->
y, &delogo->
w, &delogo->
h, &delogo->
band);
187 if (delogo->
band < 0)
194 #define CHECK_UNSET_OPT(opt) \
195 if (delogo->opt == -1) { \
196 av_log(delogo, AV_LOG_ERROR, "Option %s was not set.\n", #opt); \
197 return AVERROR(EINVAL); \
208 delogo->
x, delogo->
y, delogo->
w, delogo->
h, delogo->
band, delogo->
show);
210 delogo->
w += delogo->
band*2;
211 delogo->
h += delogo->
band*2;
212 delogo->
x -= delogo->
band;
213 delogo->
y -= delogo->
band;
244 for (plane = 0; plane < 4 && in->
data[plane]; plane++) {
245 int hsub = plane == 1 || plane == 2 ? hsub0 : 0;
246 int vsub = plane == 1 || plane == 2 ? vsub0 : 0;
250 inlink->
w>>hsub, inlink->
h>>vsub,
251 delogo->
x>>hsub, delogo->
y>>vsub,
252 delogo->
w>>hsub, delogo->
h>>vsub,
254 delogo->
show, direct);
290 .
inputs = avfilter_vf_delogo_inputs,
291 .
outputs = avfilter_vf_delogo_outputs,
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
AVFilterBufferRefVideoProps * video
video buffer specific properties
int linesize[8]
number of bytes per line
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static const AVFilterPad outputs[]
int h
agreed upon image height
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int ff_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame)
Send a frame of data to the next filter.
static int query_formats(AVFilterContext *ctx)
int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
Parse the key/value pairs list in opts.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
#define AV_PERM_READ
can read from the buffer
const char * name
Pad name.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static const AVClass delogo_class
void avfilter_unref_bufferp(AVFilterBufferRef **ref)
Remove a reference to a buffer and set the pointer to NULL.
static av_cold int init(AVFilterContext *ctx, const char *args)
AVFilter avfilter_vf_delogo
A filter pad used for either input or output.
A link between two filters.
AVFilterBufferRef * ff_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static const AVFilterPad avfilter_vf_delogo_outputs[]
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
void av_log(void *avcl, int level, const char *fmt,...)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
int format
agreed upon media format
A reference to an AVFilterBuffer.
int perms
permissions, see the AV_PERM_* flags
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static const char * delogo_get_name(void *ctx)
static const AVOption delogo_options[]
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.
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
const char * name
filter name
AVFilterLink ** outputs
array of pointers to output links
#define AV_PERM_PRESERVE
nobody else can overwrite the buffer
#define CHECK_UNSET_OPT(opt)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal and external API header
void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
Copy properties of src to dst, without copying the actual data.
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
#define AV_PERM_WRITE
can write to the buffer
AVFilterContext * dst
dest filter
uint8_t * data[8]
picture/audio data for each plane
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
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 const AVFilterPad avfilter_vf_delogo_inputs[]
AVFilterBufferRef * ff_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
AVPixelFormat
Pixel format.