aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorHaihao Xiang <haihao.xiang@intel.com>2023-01-17 14:20:27 +0800
committerHaihao Xiang <haihao.xiang@intel.com>2023-01-30 09:08:04 +0800
commit2d202985b79630cd5056c4e32f8f77f22bf1067c (patch)
tree8d38af2e966d9ed7a2151e15d6e5166d61a53f86 /libavfilter
parent9c09fb232b6863181ac1fe70647f9cbccb053d88 (diff)
downloadffmpeg-2d202985b79630cd5056c4e32f8f77f22bf1067c.tar.gz
lavfi/vpp_qsv: factor out the code for filter definition
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_vpp_qsv.c126
1 files changed, 51 insertions, 75 deletions
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 34732bb2c9..34e530e244 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -615,36 +615,31 @@ static const AVFilterPad vpp_outputs[] = {
},
};
-#if CONFIG_VPP_QSV_FILTER
-
-static int query_formats(AVFilterContext *ctx)
-{
- int ret;
- static const enum AVPixelFormat in_pix_fmts[] = {
- AV_PIX_FMT_YUV420P,
- AV_PIX_FMT_NV12,
- AV_PIX_FMT_YUYV422,
- AV_PIX_FMT_RGB32,
- AV_PIX_FMT_P010,
- AV_PIX_FMT_QSV,
- AV_PIX_FMT_NONE
- };
- static const enum AVPixelFormat out_pix_fmts[] = {
- AV_PIX_FMT_NV12,
- AV_PIX_FMT_P010,
- AV_PIX_FMT_QSV,
- AV_PIX_FMT_NONE
- };
+#define DEFINE_QSV_FILTER(x, sn, ln, fmts) \
+static const AVClass x##_class = { \
+ .class_name = #sn "_qsv", \
+ .item_name = av_default_item_name, \
+ .option = x##_options, \
+ .version = LIBAVUTIL_VERSION_INT, \
+}; \
+const AVFilter ff_vf_##sn##_qsv = { \
+ .name = #sn "_qsv", \
+ .description = NULL_IF_CONFIG_SMALL("Quick Sync Video " #ln), \
+ .preinit = x##_preinit, \
+ .init = vpp_init, \
+ .uninit = vpp_uninit, \
+ .priv_size = sizeof(VPPContext), \
+ .priv_class = &x##_class, \
+ FILTER_INPUTS(vpp_inputs), \
+ FILTER_OUTPUTS(vpp_outputs), \
+ fmts, \
+ .activate = activate, \
+ .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, \
+};
- ret = ff_formats_ref(ff_make_format_list(in_pix_fmts),
- &ctx->inputs[0]->outcfg.formats);
- if (ret < 0)
- return ret;
- return ff_formats_ref(ff_make_format_list(out_pix_fmts),
- &ctx->outputs[0]->incfg.formats);
-}
+#if CONFIG_VPP_QSV_FILTER
-static const AVOption options[] = {
+static const AVOption vpp_options[] = {
{ "deinterlace", "deinterlace mode: 0=off, 1=bob, 2=advanced", OFFSET(deinterlace), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MFX_DEINTERLACING_ADVANCED, .flags = FLAGS, "deinterlace" },
{ "bob", "Bob deinterlace mode.", 0, AV_OPT_TYPE_CONST, { .i64 = MFX_DEINTERLACING_BOB }, .flags = FLAGS, "deinterlace" },
{ "advanced", "Advanced deinterlace mode. ", 0, AV_OPT_TYPE_CONST, { .i64 = MFX_DEINTERLACING_ADVANCED }, .flags = FLAGS, "deinterlace" },
@@ -686,27 +681,34 @@ static const AVOption options[] = {
{ NULL }
};
-static const AVClass vpp_class = {
- .class_name = "vpp_qsv",
- .item_name = av_default_item_name,
- .option = options,
- .version = LIBAVUTIL_VERSION_INT,
-};
+static int vpp_query_formats(AVFilterContext *ctx)
+{
+ int ret;
+ static const enum AVPixelFormat in_pix_fmts[] = {
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NV12,
+ AV_PIX_FMT_YUYV422,
+ AV_PIX_FMT_RGB32,
+ AV_PIX_FMT_P010,
+ AV_PIX_FMT_QSV,
+ AV_PIX_FMT_NONE
+ };
+ static const enum AVPixelFormat out_pix_fmts[] = {
+ AV_PIX_FMT_NV12,
+ AV_PIX_FMT_P010,
+ AV_PIX_FMT_QSV,
+ AV_PIX_FMT_NONE
+ };
-const AVFilter ff_vf_vpp_qsv = {
- .name = "vpp_qsv",
- .description = NULL_IF_CONFIG_SMALL("Quick Sync Video VPP."),
- .priv_size = sizeof(VPPContext),
- .preinit = vpp_preinit,
- .init = vpp_init,
- .uninit = vpp_uninit,
- FILTER_INPUTS(vpp_inputs),
- FILTER_OUTPUTS(vpp_outputs),
- FILTER_QUERY_FUNC(query_formats),
- .activate = activate,
- .priv_class = &vpp_class,
- .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
-};
+ ret = ff_formats_ref(ff_make_format_list(in_pix_fmts),
+ &ctx->inputs[0]->outcfg.formats);
+ if (ret < 0)
+ return ret;
+ return ff_formats_ref(ff_make_format_list(out_pix_fmts),
+ &ctx->outputs[0]->incfg.formats);
+}
+
+DEFINE_QSV_FILTER(vpp, vpp, "VPP", FILTER_QUERY_FUNC(vpp_query_formats));
#endif
@@ -734,32 +736,6 @@ static av_cold int qsvscale_preinit(AVFilterContext *ctx)
return 0;
}
-static const AVClass qsvscale_class = {
- .class_name = "scale_qsv",
- .item_name = av_default_item_name,
- .option = qsvscale_options,
- .version = LIBAVUTIL_VERSION_INT,
-};
-
-const AVFilter ff_vf_scale_qsv = {
- .name = "scale_qsv",
- .description = NULL_IF_CONFIG_SMALL("Quick Sync Video scaling and format conversion"),
-
- .preinit = qsvscale_preinit,
- .init = vpp_init,
- .uninit = vpp_uninit,
-
- .priv_size = sizeof(VPPContext),
- .priv_class = &qsvscale_class,
-
- FILTER_INPUTS(vpp_inputs),
- FILTER_OUTPUTS(vpp_outputs),
-
- FILTER_SINGLE_PIXFMT(AV_PIX_FMT_QSV),
-
- .activate = activate,
-
- .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
-};
+DEFINE_QSV_FILTER(qsvscale, scale, "scaling and format conversion", FILTER_SINGLE_PIXFMT(AV_PIX_FMT_QSV));
#endif