[FFmpeg-devel] [PATCH 078/218] avfilter/vf_hsvkey: Use formats list instead of query function

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Thu Sep 30 16:40:19 EEST 2021


In this case it also allows to avoid a runtime check to which filter
an AVFilterContext belongs to.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavfilter/vf_hsvkey.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/libavfilter/vf_hsvkey.c b/libavfilter/vf_hsvkey.c
index 30dcbfc029..7f2f191baf 100644
--- a/libavfilter/vf_hsvkey.c
+++ b/libavfilter/vf_hsvkey.c
@@ -244,9 +244,7 @@ static av_cold int config_output(AVFilterLink *outlink)
     return 0;
 }
 
-static av_cold int query_formats(AVFilterContext *avctx)
-{
-    static const enum AVPixelFormat pixel_fmts[] = {
+static const enum AVPixelFormat key_pixel_fmts[] = {
         AV_PIX_FMT_YUVA420P,
         AV_PIX_FMT_YUVA422P,
         AV_PIX_FMT_YUVA444P,
@@ -275,12 +273,6 @@ static av_cold int query_formats(AVFilterContext *avctx)
         AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16,
         AV_PIX_FMT_NONE
     };
-    const enum AVPixelFormat *pix_fmts;
-
-    pix_fmts = !strcmp(avctx->filter->name, "hsvhold") ? hold_pixel_fmts : pixel_fmts;
-
-    return ff_set_common_formats_from_list(avctx, pix_fmts);
-}
 
 static av_cold int config_input(AVFilterLink *inlink)
 {
@@ -333,7 +325,7 @@ const AVFilter ff_vf_hsvkey = {
     .priv_class    = &hsvkey_class,
     FILTER_INPUTS(hsvkey_inputs),
     FILTER_OUTPUTS(hsvkey_outputs),
-    FILTER_QUERY_FUNC(query_formats),
+    FILTER_PIXFMTS_ARRAY(key_pixel_fmts),
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
     .process_command = ff_filter_process_command,
 };
@@ -374,7 +366,7 @@ const AVFilter ff_vf_hsvhold = {
     .priv_class    = &hsvhold_class,
     FILTER_INPUTS(hsvhold_inputs),
     FILTER_OUTPUTS(hsvhold_outputs),
-    FILTER_QUERY_FUNC(query_formats),
+    FILTER_PIXFMTS_ARRAY(hold_pixel_fmts),
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
     .process_command = ff_filter_process_command,
 };
-- 
2.30.2



More information about the ffmpeg-devel mailing list