Commit 66677410 authored by Marvin Scholz's avatar Marvin Scholz Committed by Anton Khirnov

avfilter/vf_tpad: fix check for drawing initialization

The check if drawing needs to be initialized and supported formats
should be drawable ones was flawed, as pad_stop/pad_start is only
populated from stop_duration/start_duration after these checks.

To fix that, check the _duration variants as well and for better
readability and maintainability break the check out into its own
helper.

Fixes a regression from 86b252ea
Fix #10621
Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
parent 99fcdee5
...@@ -70,11 +70,17 @@ static const AVOption tpad_options[] = { ...@@ -70,11 +70,17 @@ static const AVOption tpad_options[] = {
AVFILTER_DEFINE_CLASS(tpad); 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) static int query_formats(AVFilterContext *ctx)
{ {
TPadContext *s = ctx->priv; TPadContext *s = ctx->priv;
if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) || if (needs_drawing(s))
(s->start_mode == MODE_ADD && s->pad_start != 0))
return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0)); return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
return ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_VIDEO)); return ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_VIDEO));
...@@ -196,8 +202,7 @@ static int config_input(AVFilterLink *inlink) ...@@ -196,8 +202,7 @@ static int config_input(AVFilterLink *inlink)
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
TPadContext *s = ctx->priv; TPadContext *s = ctx->priv;
if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) || if (needs_drawing(s)) {
(s->start_mode == MODE_ADD && s->pad_start != 0)) {
ff_draw_init(&s->draw, inlink->format, 0); ff_draw_init(&s->draw, inlink->format, 0);
ff_draw_color(&s->draw, &s->color, s->rgba_color); ff_draw_color(&s->draw, &s->color, s->rgba_color);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment