diff options
Diffstat (limited to 'libavfilter/vf_delogo.c')
-rw-r--r-- | libavfilter/vf_delogo.c | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/libavfilter/vf_delogo.c b/libavfilter/vf_delogo.c index 4c917baee7..4bf0867bd9 100644 --- a/libavfilter/vf_delogo.c +++ b/libavfilter/vf_delogo.c @@ -2,20 +2,20 @@ * Copyright (c) 2002 Jindrich Makovicka <makovick@gmail.com> * Copyright (c) 2011 Stefano Sabatini * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or modify + * FFmpeg is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along - * with Libav; if not, write to the Free Software Foundation, Inc., + * with FFmpeg; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ @@ -90,18 +90,22 @@ static void apply_delogo(uint8_t *dst, int dst_linesize, for (x = logo_x1+1, xdst = dst+logo_x1+1, xsrc = src+logo_x1+1; x < logo_x2-1; x++, xdst++, xsrc++) { - interp = (topleft[src_linesize*(y-logo_y -yclipt)] + - topleft[src_linesize*(y-logo_y-1-yclipt)] + - topleft[src_linesize*(y-logo_y+1-yclipt)]) * (logo_w-(x-logo_x))/logo_w - + (topright[src_linesize*(y-logo_y-yclipt)] + - topright[src_linesize*(y-logo_y-1-yclipt)] + - topright[src_linesize*(y-logo_y+1-yclipt)]) * (x-logo_x)/logo_w - + (topleft[x-logo_x-xclipl] + - topleft[x-logo_x-1-xclipl] + - topleft[x-logo_x+1-xclipl]) * (logo_h-(y-logo_y))/logo_h - + (botleft[x-logo_x-xclipl] + - botleft[x-logo_x-1-xclipl] + - botleft[x-logo_x+1-xclipl]) * (y-logo_y)/logo_h; + interp = + (topleft[src_linesize*(y-logo_y -yclipt)] + + topleft[src_linesize*(y-logo_y-1-yclipt)] + + topleft[src_linesize*(y-logo_y+1-yclipt)]) * (logo_w-(x-logo_x))/logo_w + + + (topright[src_linesize*(y-logo_y-yclipt)] + + topright[src_linesize*(y-logo_y-1-yclipt)] + + topright[src_linesize*(y-logo_y+1-yclipt)]) * (x-logo_x)/logo_w + + + (topleft[x-logo_x-xclipl] + + topleft[x-logo_x-1-xclipl] + + topleft[x-logo_x+1-xclipl]) * (logo_h-(y-logo_y))/logo_h + + + (botleft[x-logo_x-xclipl] + + botleft[x-logo_x-1-xclipl] + + botleft[x-logo_x+1-xclipl]) * (y-logo_y)/logo_h; interp /= 6; if (y >= logo_y+band && y < logo_y+logo_h-band && @@ -136,7 +140,7 @@ typedef struct { } DelogoContext; #define OFFSET(x) offsetof(DelogoContext, x) -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM +#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM static const AVOption delogo_options[]= { { "x", "set logo x position", OFFSET(x), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS }, @@ -149,20 +153,11 @@ static const AVOption delogo_options[]= { { NULL }, }; -static const char *delogo_get_name(void *ctx) -{ - return "delogo"; -} - -static const AVClass delogo_class = { - .class_name = "DelogoContext", - .item_name = delogo_get_name, - .option = delogo_options, -}; +AVFILTER_DEFINE_CLASS(delogo); static int query_formats(AVFilterContext *ctx) { - enum AVPixelFormat pix_fmts[] = { + static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_GRAY8, @@ -187,10 +182,12 @@ static av_cold int init(AVFilterContext *ctx) CHECK_UNSET_OPT(w); CHECK_UNSET_OPT(h); - if (s->show) + if (s->band < 0 || s->show) { + s->show = 1; s->band = 4; + } - av_log(ctx, AV_LOG_DEBUG, "x:%d y:%d, w:%d h:%d band:%d show:%d\n", + av_log(ctx, AV_LOG_VERBOSE, "x:%d y:%d, w:%d h:%d band:%d show:%d\n", s->x, s->y, s->w, s->h, s->band, s->show); s->w += s->band*2; @@ -223,8 +220,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } av_frame_copy_props(out, in); - out->width = outlink->w; - out->height = outlink->h; } for (plane = 0; plane < 4 && in->data[plane]; plane++) { @@ -233,9 +228,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) apply_delogo(out->data[plane], out->linesize[plane], in ->data[plane], in ->linesize[plane], - inlink->w>>hsub, inlink->h>>vsub, + FF_CEIL_RSHIFT(inlink->w, hsub), + FF_CEIL_RSHIFT(inlink->h, vsub), s->x>>hsub, s->y>>vsub, - s->w>>hsub, s->h>>vsub, + FF_CEIL_RSHIFT(s->w, hsub), + FF_CEIL_RSHIFT(s->h, vsub), s->band>>FFMIN(hsub, vsub), s->show, direct); } @@ -274,4 +271,5 @@ AVFilter avfilter_vf_delogo = { .inputs = avfilter_vf_delogo_inputs, .outputs = avfilter_vf_delogo_outputs, + .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, }; |