diff mbox series

[FFmpeg-devel,1/2] avfilter/vf_tpad: fix check for drawing initialization

Message ID 20231107222118.35545-1-epirat07@gmail.com
State Accepted
Commit 6667741029bce9a79b48caedf24d6cb69c5ead7d
Headers show
Series [FFmpeg-devel,1/2] avfilter/vf_tpad: fix check for drawing initialization | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Marvin Scholz Nov. 7, 2023, 10:21 p.m. UTC
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 86b252ea9dee18006910e30646ad1067f2d1323f
Fix #10621
---
 libavfilter/vf_tpad.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Anton Khirnov Nov. 9, 2023, 10:11 a.m. UTC | #1
Quoting Marvin Scholz (2023-11-07 23:21:17)
> 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 86b252ea9dee18006910e30646ad1067f2d1323f
> Fix #10621
> ---
>  libavfilter/vf_tpad.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)

Set pushed
diff mbox series

Patch

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);
     }