lavfi/vpp_qsv: factor out the code for filter definition

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
release/6.0
Haihao Xiang 2 years ago
parent 9c09fb232b
commit 2d202985b7
  1. 126
      libavfilter/vf_vpp_qsv.c

@ -615,36 +615,31 @@ static const AVFilterPad vpp_outputs[] = {
}, },
}; };
#if CONFIG_VPP_QSV_FILTER #define DEFINE_QSV_FILTER(x, sn, ln, fmts) \
static const AVClass x##_class = { \
static int query_formats(AVFilterContext *ctx) .class_name = #sn "_qsv", \
{ .item_name = av_default_item_name, \
int ret; .option = x##_options, \
static const enum AVPixelFormat in_pix_fmts[] = { .version = LIBAVUTIL_VERSION_INT, \
AV_PIX_FMT_YUV420P, }; \
AV_PIX_FMT_NV12, const AVFilter ff_vf_##sn##_qsv = { \
AV_PIX_FMT_YUYV422, .name = #sn "_qsv", \
AV_PIX_FMT_RGB32, .description = NULL_IF_CONFIG_SMALL("Quick Sync Video " #ln), \
AV_PIX_FMT_P010, .preinit = x##_preinit, \
AV_PIX_FMT_QSV, .init = vpp_init, \
AV_PIX_FMT_NONE .uninit = vpp_uninit, \
}; .priv_size = sizeof(VPPContext), \
static const enum AVPixelFormat out_pix_fmts[] = { .priv_class = &x##_class, \
AV_PIX_FMT_NV12, FILTER_INPUTS(vpp_inputs), \
AV_PIX_FMT_P010, FILTER_OUTPUTS(vpp_outputs), \
AV_PIX_FMT_QSV, fmts, \
AV_PIX_FMT_NONE .activate = activate, \
}; .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, \
};
ret = ff_formats_ref(ff_make_format_list(in_pix_fmts), #if CONFIG_VPP_QSV_FILTER
&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);
}
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" }, { "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" }, { "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" }, { "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 } { NULL }
}; };
static const AVClass vpp_class = { static int vpp_query_formats(AVFilterContext *ctx)
.class_name = "vpp_qsv", {
.item_name = av_default_item_name, int ret;
.option = options, static const enum AVPixelFormat in_pix_fmts[] = {
.version = LIBAVUTIL_VERSION_INT, 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 = { ret = ff_formats_ref(ff_make_format_list(in_pix_fmts),
.name = "vpp_qsv", &ctx->inputs[0]->outcfg.formats);
.description = NULL_IF_CONFIG_SMALL("Quick Sync Video VPP."), if (ret < 0)
.priv_size = sizeof(VPPContext), return ret;
.preinit = vpp_preinit, return ff_formats_ref(ff_make_format_list(out_pix_fmts),
.init = vpp_init, &ctx->outputs[0]->incfg.formats);
.uninit = vpp_uninit, }
FILTER_INPUTS(vpp_inputs),
FILTER_OUTPUTS(vpp_outputs), DEFINE_QSV_FILTER(vpp, vpp, "VPP", FILTER_QUERY_FUNC(vpp_query_formats));
FILTER_QUERY_FUNC(query_formats),
.activate = activate,
.priv_class = &vpp_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
};
#endif #endif
@ -734,32 +736,6 @@ static av_cold int qsvscale_preinit(AVFilterContext *ctx)
return 0; return 0;
} }
static const AVClass qsvscale_class = { DEFINE_QSV_FILTER(qsvscale, scale, "scaling and format conversion", FILTER_SINGLE_PIXFMT(AV_PIX_FMT_QSV));
.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,
};
#endif #endif

Loading…
Cancel
Save