52 uint8_t *src,
int src_linesize,
54 int logo_x,
int logo_y,
int logo_w,
int logo_h,
55 int band,
int show,
int direct)
61 uint8_t *topleft, *botleft, *topright;
62 int xclipl, xclipr, yclipt, yclipb;
63 int logo_x1, logo_x2, logo_y1, logo_y2;
65 xclipl =
FFMAX(-logo_x, 0);
66 xclipr =
FFMAX(logo_x+logo_w-w, 0);
67 yclipt =
FFMAX(-logo_y, 0);
68 yclipb =
FFMAX(logo_y+logo_h-h, 0);
70 logo_x1 = logo_x + xclipl;
71 logo_x2 = logo_x + logo_w - xclipr;
72 logo_y1 = logo_y + yclipt;
73 logo_y2 = logo_y + logo_h - yclipb;
75 topleft = src+logo_y1 * src_linesize+logo_x1;
76 topright = src+logo_y1 * src_linesize+logo_x2-1;
77 botleft = src+(logo_y2-1) * src_linesize+logo_x1;
79 dst += (logo_y1+1)*dst_linesize;
80 src += (logo_y1+1)*src_linesize;
85 for (y = logo_y1+1; y < logo_y2-1; y++) {
88 xsrc = src+logo_x1+1; x < logo_x2-1; x++, xdst++, xsrc++) {
89 interp = (topleft[src_linesize*(y-logo_y -yclipt)] +
90 topleft[src_linesize*(y-logo_y-1-yclipt)] +
91 topleft[src_linesize*(y-logo_y+1-yclipt)]) * (logo_w-(x-logo_x))/logo_w
92 + (topright[src_linesize*(y-logo_y-yclipt)] +
93 topright[src_linesize*(y-logo_y-1-yclipt)] +
94 topright[src_linesize*(y-logo_y+1-yclipt)]) * (x-logo_x)/logo_w
95 + (topleft[x-logo_x-xclipl] +
96 topleft[x-logo_x-1-xclipl] +
97 topleft[x-logo_x+1-xclipl]) * (logo_h-(y-logo_y))/logo_h
98 + (botleft[x-logo_x-xclipl] +
99 botleft[x-logo_x-1-xclipl] +
100 botleft[x-logo_x+1-xclipl]) * (y-logo_y)/logo_h;
103 if (y >= logo_y+band && y < logo_y+logo_h-band &&
104 x >= logo_x+band && x < logo_x+logo_w-band) {
109 dist =
FFMAX(dist, logo_x-x+band);
110 else if (x >= logo_x+logo_w-band)
111 dist =
FFMAX(dist, x-(logo_x+logo_w-1-band));
114 dist =
FFMAX(dist, logo_y-y+band);
115 else if (y >= logo_y+logo_h-band)
116 dist =
FFMAX(dist, y-(logo_y+logo_h-1-band));
118 *xdst = (*xsrc*dist + interp*(band-dist))/band;
119 if (show && (dist == band-1))
131 int x,
y, w, h, band, show;
134 #define OFFSET(x) offsetof(DelogoContext, x)
180 ret = sscanf(args,
"%d:%d:%d:%d:%d",
181 &delogo->
x, &delogo->
y, &delogo->
w, &delogo->
h, &delogo->
band);
183 if (delogo->
band < 0)
190 #define CHECK_UNSET_OPT(opt) \
191 if (delogo->opt == -1) { \
192 av_log(delogo, AV_LOG_ERROR, "Option %s was not set.\n", #opt); \
193 return AVERROR(EINVAL); \
204 delogo->
x, delogo->
y, delogo->
w, delogo->
h, delogo->
band, delogo->
show);
206 delogo->
w += delogo->
band*2;
207 delogo->
h += delogo->
band*2;
208 delogo->
x -= delogo->
band;
209 delogo->
y -= delogo->
band;
221 outlink->
w, outlink->
h);
223 outpicref->
video->
w = outlink->
w;
224 outpicref->
video->
h = outlink->
h;
226 outpicref = inpicref;
240 int direct = inpicref == outpicref;
245 for (plane = 0; plane < 4 && inpicref->
data[plane]; plane++) {
246 int hsub = plane == 1 || plane == 2 ? hsub0 : 0;
247 int vsub = plane == 1 || plane == 2 ? vsub0 : 0;
251 inlink->
w>>hsub, inlink->
h>>vsub,
252 delogo->
x>>hsub, delogo->
y>>vsub,
253 delogo->
w>>hsub, delogo->
h>>vsub,
255 delogo->
show, direct);
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
AVFilterBufferRef * avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
AVFilterBufferRefVideoProps * video
video buffer specific properties
int linesize[8]
number of bytes per line
static void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
Copy properties of src to dst, without copying the actual data.
int h
agreed upon image height
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
AVFilterBufferRef * out_buf
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.
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
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 * 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:4:0 (1 Cr & Cb sample per 1x2 Y samples)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static const AVClass delogo_class
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
void avfilter_end_frame(AVFilterLink *link)
Notifie the next filter that the current frame has finished.
AVFilter avfilter_vf_delogo
A filter pad used for either input or output.
A link between two filters.
static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#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,...)
AVFilterFormats * avfilter_make_format_list(const int *fmts)
Create a list of supported formats.
const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB]
The array of all the pixel format descriptors.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int w
agreed upon image width
static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
Send a slice to the next filter.
int format
agreed upon media format
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
A reference to an AVFilterBuffer.
static void end_frame(AVFilterLink *inlink)
int perms
permissions, see the AV_PERM_* flags
static const char * delogo_get_name(void *ctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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.
Describe the class of an AVClass context structure.
AVFilterBufferRef * avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
Add a new reference to a buffer.
void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
Notify the next filter of the start of a frame.
const char * name
filter name
AVFilterBufferRef * avfilter_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
get_video_buffer() handler for filters which simply pass video along
AVFilterLink ** outputs
array of pointers to output links
#define AV_PERM_PRESERVE
nobody else can overwrite the buffer
#define CHECK_UNSET_OPT(opt)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_PERM_WRITE
can write to the buffer
AVFilterContext * dst
dest filter
uint8_t * data[8]
picture/audio data for each plane
AVFilterBufferRef * cur_buf
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.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)