diff mbox series

[FFmpeg-devel,06/10] avfilter/vf_coreimage: Simplify query_formats

Message ID AM7PR03MB666003DFBFC5ED08C6CAC90A8FFC9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Headers show
Series [FFmpeg-devel,01/10] fftools/cmdutils: Use avfilter_pad_count() for AVFilter's number of pads | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Aug. 15, 2021, 9:55 a.m. UTC
Using ff_set_common_formats_from_list() avoids using different functions
depending upon how many inputs the filter has.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Untested as I don't have a mac.

 libavfilter/vf_coreimage.m | 37 ++-----------------------------------
 1 file changed, 2 insertions(+), 35 deletions(-)

Comments

Thilo Borgmann Sept. 17, 2021, 2:28 p.m. UTC | #1
Am 15.08.21 um 11:55 schrieb Andreas Rheinhardt:
> Using ff_set_common_formats_from_list() avoids using different functions
> depending upon how many inputs the filter has.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> Untested as I don't have a mac.
> 
>  libavfilter/vf_coreimage.m | 37 ++-----------------------------------
>  1 file changed, 2 insertions(+), 35 deletions(-)

LGTM.

-Thilo
diff mbox series

Patch

diff --git a/libavfilter/vf_coreimage.m b/libavfilter/vf_coreimage.m
index 2d74c0f5ce..80a7e33847 100644
--- a/libavfilter/vf_coreimage.m
+++ b/libavfilter/vf_coreimage.m
@@ -142,40 +142,7 @@  static int query_formats(AVFilterContext *fctx)
         AV_PIX_FMT_NONE
     };
 
-    AVFilterFormats *inout_formats;
-    int ret;
-
-    if (!(inout_formats = ff_make_format_list(inout_fmts_rgb))) {
-        return AVERROR(ENOMEM);
-    }
-
-    if ((ret = ff_formats_ref(inout_formats, &fctx->inputs[0]->outcfg.formats)) < 0 ||
-        (ret = ff_formats_ref(inout_formats, &fctx->outputs[0]->incfg.formats)) < 0) {
-        return ret;
-    }
-
-    return 0;
-}
-
-static int query_formats_src(AVFilterContext *fctx)
-{
-    static const enum AVPixelFormat inout_fmts_rgb[] = {
-        AV_PIX_FMT_ARGB,
-        AV_PIX_FMT_NONE
-    };
-
-    AVFilterFormats *inout_formats;
-    int ret;
-
-    if (!(inout_formats = ff_make_format_list(inout_fmts_rgb))) {
-        return AVERROR(ENOMEM);
-    }
-
-    if ((ret = ff_formats_ref(inout_formats, &fctx->outputs[0]->incfg.formats)) < 0) {
-        return ret;
-    }
-
-    return 0;
+    return ff_set_common_formats_from_list(fctx, inout_fmts_rgb);
 }
 
 static int apply_filter(CoreImageContext *ctx, AVFilterLink *link, AVFrame *frame)
@@ -683,5 +650,5 @@  const AVFilter ff_vsrc_coreimagesrc = {
     .priv_class    = &coreimagesrc_class,
     .inputs        = NULL,
     FF_FILTER_OUTPUTS(vsrc_coreimagesrc_outputs),
-    .query_formats = query_formats_src,
+    .query_formats = query_formats,
 };