diff mbox series

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

Message ID PR3PR03MB66650B5B483803AF2350975A8FAA9@PR3PR03MB6665.eurprd03.prod.outlook.com
State Accepted
Commit a26efeb121a8db26ca31727204b23ef77f2f898b
Headers show
Series [FFmpeg-devel,001/218] avfilter/f_reverse: Don't use redundant query_formats function | expand

Commit Message

Andreas Rheinhardt Sept. 30, 2021, 1:40 p.m. UTC
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@outlook.com>
---
 libavfilter/vf_hsvkey.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
diff mbox series

Patch

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