diff mbox series

[FFmpeg-devel,v4,5/5] lavfi/format: add a hwmap auto conversion filter

Message ID 20220704080957.425-5-tong1.wu@intel.com
State New
Headers show
Series [FFmpeg-devel,v4,1/5] avutil/hwcontext: add a function to get the AVHWDeviceType | 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
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Wu, Tong1 July 4, 2022, 8:09 a.m. UTC
When two formats lists cannot be merged, a scale filter is
auto-inserted. However, when it comes to hardware map, we have to
manually add a hwmap filter to do the conversion. This patch introduces
an auto hwmap filter to do the hwmap conversion automatically.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
---
 libavfilter/avfiltergraph.c | 3 ++-
 libavfilter/formats.c       | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

Comments

Wu, Tong1 July 15, 2022, 5:19 a.m. UTC | #1
Ping for the patchset. Is there any comment on adding this auto hwmap filter?

Thanks,
Tong

> -----Original Message-----
> From: Wu, Tong1 <tong1.wu@intel.com>
> Sent: Monday, July 4, 2022 4:10 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Wu, Tong1 <tong1.wu@intel.com>
> Subject: [PATCH v4 5/5] lavfi/format: add a hwmap auto conversion filter
> 
> When two formats lists cannot be merged, a scale filter is auto-inserted.
> However, when it comes to hardware map, we have to manually add a
> hwmap filter to do the conversion. This patch introduces an auto hwmap
> filter to do the hwmap conversion automatically.
> 
> Signed-off-by: Tong Wu <tong1.wu@intel.com>
> ---
>  libavfilter/avfiltergraph.c | 3 ++-
>  libavfilter/formats.c       | 4 ++++
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index
> 102c1f7693..8e63007cac 100644
> --- a/libavfilter/avfiltergraph.c
> +++ b/libavfilter/avfiltergraph.c
> @@ -402,7 +402,8 @@ static int insert_auto_filter(AVFilterContext **convert,
> AVFilterGraph *graph,
>      AVFilterContext *ctx;
>      AVFilterLink *inlink, *outlink;
>      char inst_name[30];
> -    const char *opts = FF_FIELD_AT(char *, neg-
> >conversion_filters[conv_step].conversion_opts_offset, *graph);
> +    const char *opts = neg-
> >conversion_filters[conv_step].conversion_opts_offset == 0 ? NULL :
> +                       FF_FIELD_AT(char *,
> + neg->conversion_filters[conv_step].conversion_opts_offset, *graph);
>      const char *name = neg->conversion_filters[conv_step].conversion_filter;
> 
>      if (!(filter = avfilter_get_by_name(name))) { diff --git a/libavfilter/formats.c
> b/libavfilter/formats.c index c8e20e5b20..fee10fa0ee 100644
> --- a/libavfilter/formats.c
> +++ b/libavfilter/formats.c
> @@ -331,6 +331,10 @@ static const AVFilterFormatsFilter filters_video[] = {
>          .conversion_filter = "scale",
>          .conversion_opts_offset = offsetof(AVFilterGraph, scale_sws_opts),
>      },
> +    {
> +        .conversion_filter = "hwmap",
> +        .conversion_opts_offset = 0,
> +    }
>  };
> 
>  static const AVFilterFormatsFilter filters_audio[] = {
> --
> 2.35.1.windows.2
diff mbox series

Patch

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index 102c1f7693..8e63007cac 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -402,7 +402,8 @@  static int insert_auto_filter(AVFilterContext **convert, AVFilterGraph *graph,
     AVFilterContext *ctx;
     AVFilterLink *inlink, *outlink;
     char inst_name[30];
-    const char *opts = FF_FIELD_AT(char *, neg->conversion_filters[conv_step].conversion_opts_offset, *graph);
+    const char *opts = neg->conversion_filters[conv_step].conversion_opts_offset == 0 ? NULL :
+                       FF_FIELD_AT(char *, neg->conversion_filters[conv_step].conversion_opts_offset, *graph);
     const char *name = neg->conversion_filters[conv_step].conversion_filter;
 
     if (!(filter = avfilter_get_by_name(name))) {
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index c8e20e5b20..fee10fa0ee 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -331,6 +331,10 @@  static const AVFilterFormatsFilter filters_video[] = {
         .conversion_filter = "scale",
         .conversion_opts_offset = offsetof(AVFilterGraph, scale_sws_opts),
     },
+    {
+        .conversion_filter = "hwmap",
+        .conversion_opts_offset = 0,
+    }
 };
 
 static const AVFilterFormatsFilter filters_audio[] = {