diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c index 7990403e81..1efe4ec479 100644 --- a/libavfilter/vf_tpad.c +++ b/libavfilter/vf_tpad.c @@ -70,11 +70,17 @@ static const AVOption tpad_options[] = { AVFILTER_DEFINE_CLASS(tpad); +static int needs_drawing(const TPadContext *s) { + return ( + (s->stop_mode == MODE_ADD && (s->pad_stop != 0 || s->stop_duration != 0)) || + (s->start_mode == MODE_ADD && (s->pad_start != 0 || s->start_duration != 0)) + ); +} + static int query_formats(AVFilterContext *ctx) { TPadContext *s = ctx->priv; - if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) || - (s->start_mode == MODE_ADD && s->pad_start != 0)) + if (needs_drawing(s)) return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0)); return ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_VIDEO)); @@ -196,8 +202,7 @@ static int config_input(AVFilterLink *inlink) AVFilterContext *ctx = inlink->dst; TPadContext *s = ctx->priv; - if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) || - (s->start_mode == MODE_ADD && s->pad_start != 0)) { + if (needs_drawing(s)) { ff_draw_init(&s->draw, inlink->format, 0); ff_draw_color(&s->draw, &s->color, s->rgba_color); }