diff mbox series

[FFmpeg-devel,2/2] avfilter/vf_tpad: accept hardware frames in clone-only mode

Message ID 20230419104250.21354-2-epirat07@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,1/2] avfilter/vf_tpad: use enum for start/stop_mode | 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 April 19, 2023, 10:42 a.m. UTC
When no drawing is to be performed, tpad can work fine with
hardware frames, so advertise this in the query_formats
callback and ensure the drawing context is never initialized
when just cloning frames.
---
 libavfilter/vf_tpad.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Marvin Scholz April 19, 2023, 10:45 a.m. UTC | #1
On 19 Apr 2023, at 12:42, Marvin Scholz wrote:

> When no drawing is to be performed, tpad can work fine with
> hardware frames, so advertise this in the query_formats
> callback and ensure the drawing context is never initialized
> when just cloning frames.
> ---
>  libavfilter/vf_tpad.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
> index 88c3c99de4..9a9d06a8b8 100644
> --- a/libavfilter/vf_tpad.c
> +++ b/libavfilter/vf_tpad.c
> @@ -71,7 +71,13 @@ AVFILTER_DEFINE_CLASS(tpad);
>
>  static int query_formats(AVFilterContext *ctx)
>  {
> -    return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
> +    TPadContext *s = ctx->priv;
> +    if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
> +        (s->start_mode == MODE_ADD && s->pad_start != 0))
> +        return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
> +
> +    fprintf(stderr, "ONLY COPY\n");

Apparently I am not fully awake yet and forgot to update the commit with the removal
of this debug output… Will obviously be removed in the next iteration.

> +    return ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_VIDEO));
>  }
>
>  static int activate(AVFilterContext *ctx)
> @@ -190,8 +196,11 @@ static int config_input(AVFilterLink *inlink)
>      AVFilterContext *ctx = inlink->dst;
>      TPadContext *s = ctx->priv;
>
> -    ff_draw_init(&s->draw, inlink->format, 0);
> -    ff_draw_color(&s->draw, &s->color, s->rgba_color);
> +    if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
> +        (s->start_mode == MODE_ADD && s->pad_start != 0)) {
> +        ff_draw_init(&s->draw, inlink->format, 0);
> +        ff_draw_color(&s->draw, &s->color, s->rgba_color);
> +    }
>
>      if (s->start_duration)
>          s->pad_start = av_rescale_q(s->start_duration, inlink->frame_rate, av_inv_q(AV_TIME_BASE_Q));
> -- 
> 2.37.0 (Apple Git-136)
diff mbox series

Patch

diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c
index 88c3c99de4..9a9d06a8b8 100644
--- a/libavfilter/vf_tpad.c
+++ b/libavfilter/vf_tpad.c
@@ -71,7 +71,13 @@  AVFILTER_DEFINE_CLASS(tpad);
 
 static int query_formats(AVFilterContext *ctx)
 {
-    return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
+    TPadContext *s = ctx->priv;
+    if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
+        (s->start_mode == MODE_ADD && s->pad_start != 0))
+        return ff_set_common_formats(ctx, ff_draw_supported_pixel_formats(0));
+
+    fprintf(stderr, "ONLY COPY\n");
+    return ff_set_common_formats(ctx, ff_all_formats(AVMEDIA_TYPE_VIDEO));
 }
 
 static int activate(AVFilterContext *ctx)
@@ -190,8 +196,11 @@  static int config_input(AVFilterLink *inlink)
     AVFilterContext *ctx = inlink->dst;
     TPadContext *s = ctx->priv;
 
-    ff_draw_init(&s->draw, inlink->format, 0);
-    ff_draw_color(&s->draw, &s->color, s->rgba_color);
+    if ((s->stop_mode == MODE_ADD && s->pad_stop != 0) ||
+        (s->start_mode == MODE_ADD && s->pad_start != 0)) {
+        ff_draw_init(&s->draw, inlink->format, 0);
+        ff_draw_color(&s->draw, &s->color, s->rgba_color);
+    }
 
     if (s->start_duration)
         s->pad_start = av_rescale_q(s->start_duration, inlink->frame_rate, av_inv_q(AV_TIME_BASE_Q));