diff mbox series

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

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

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

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_chromakey.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/vf_chromakey.c b/libavfilter/vf_chromakey.c
index 532d81ecf6..d08e127445 100644
--- a/libavfilter/vf_chromakey.c
+++ b/libavfilter/vf_chromakey.c
@@ -301,9 +301,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 chromakey_fmts[] = {
         AV_PIX_FMT_YUVA420P,
         AV_PIX_FMT_YUVA422P,
         AV_PIX_FMT_YUVA444P,
@@ -332,12 +330,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, "chromahold") ? hold_pixel_fmts : pixel_fmts;
-
-    return ff_set_common_formats_from_list(avctx, pix_fmts);
-}
 
 static av_cold int config_input(AVFilterLink *inlink)
 {
@@ -401,7 +393,7 @@  const AVFilter ff_vf_chromakey = {
     .priv_class    = &chromakey_class,
     FILTER_INPUTS(chromakey_inputs),
     FILTER_OUTPUTS(chromakey_outputs),
-    FILTER_QUERY_FUNC(query_formats),
+    FILTER_PIXFMTS_ARRAY(chromakey_fmts),
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
     .process_command = process_command,
 };
@@ -441,7 +433,7 @@  const AVFilter ff_vf_chromahold = {
     .priv_class    = &chromahold_class,
     FILTER_INPUTS(chromahold_inputs),
     FILTER_OUTPUTS(chromahold_outputs),
-    FILTER_QUERY_FUNC(query_formats),
+    FILTER_PIXFMTS_ARRAY(hold_pixel_fmts),
     .flags         = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS,
     .process_command = process_command,
 };