You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
lavfi/vf_scale_vaapi: add scaling mode setting support.
before this change, scale_vaapi hard coding the scaling mode, add a new option "mode" to setting the scaling mode, it can be use to change scaling algorithm for performance/quality trade off. Note: VA_FILTER_SCALING_NL_ANAMORPHIC(nolinear ananorphic scaling algorithm) doesn't support by i965/iHD driver now, add this just for completeness. Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: Jun Zhao <mypopydev@gmail.com>
This commit is contained in:
@@ -35,10 +35,27 @@ typedef struct ScaleVAAPIContext {
|
|||||||
|
|
||||||
char *output_format_string;
|
char *output_format_string;
|
||||||
|
|
||||||
|
int mode;
|
||||||
|
|
||||||
char *w_expr; // width expression string
|
char *w_expr; // width expression string
|
||||||
char *h_expr; // height expression string
|
char *h_expr; // height expression string
|
||||||
} ScaleVAAPIContext;
|
} ScaleVAAPIContext;
|
||||||
|
|
||||||
|
static const char *scale_vaapi_mode_name(int mode)
|
||||||
|
{
|
||||||
|
switch (mode) {
|
||||||
|
#define D(name) case VA_FILTER_SCALING_ ## name: return #name
|
||||||
|
D(DEFAULT);
|
||||||
|
D(FAST);
|
||||||
|
D(HQ);
|
||||||
|
D(NL_ANAMORPHIC);
|
||||||
|
#undef D
|
||||||
|
default:
|
||||||
|
return "Invalid";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int scale_vaapi_config_output(AVFilterLink *outlink)
|
static int scale_vaapi_config_output(AVFilterLink *outlink)
|
||||||
{
|
{
|
||||||
AVFilterLink *inlink = outlink->src->inputs[0];
|
AVFilterLink *inlink = outlink->src->inputs[0];
|
||||||
@@ -70,6 +87,7 @@ static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
|
|||||||
AVFilterContext *avctx = inlink->dst;
|
AVFilterContext *avctx = inlink->dst;
|
||||||
AVFilterLink *outlink = avctx->outputs[0];
|
AVFilterLink *outlink = avctx->outputs[0];
|
||||||
VAAPIVPPContext *vpp_ctx = avctx->priv;
|
VAAPIVPPContext *vpp_ctx = avctx->priv;
|
||||||
|
ScaleVAAPIContext *ctx = avctx->priv;
|
||||||
AVFrame *output_frame = NULL;
|
AVFrame *output_frame = NULL;
|
||||||
VASurfaceID input_surface, output_surface;
|
VASurfaceID input_surface, output_surface;
|
||||||
VAProcPipelineParameterBuffer params;
|
VAProcPipelineParameterBuffer params;
|
||||||
@@ -119,7 +137,7 @@ static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
|
|||||||
params.output_color_standard = params.surface_color_standard;
|
params.output_color_standard = params.surface_color_standard;
|
||||||
|
|
||||||
params.pipeline_flags = 0;
|
params.pipeline_flags = 0;
|
||||||
params.filter_flags = VA_FILTER_SCALING_HQ;
|
params.filter_flags = ctx->mode;
|
||||||
|
|
||||||
err = ff_vaapi_vpp_render_picture(avctx, ¶ms, output_surface);
|
err = ff_vaapi_vpp_render_picture(avctx, ¶ms, output_surface);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
@@ -131,9 +149,10 @@ static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
|
|||||||
|
|
||||||
av_frame_free(&input_frame);
|
av_frame_free(&input_frame);
|
||||||
|
|
||||||
av_log(avctx, AV_LOG_DEBUG, "Filter output: %s, %ux%u (%"PRId64").\n",
|
av_log(avctx, AV_LOG_DEBUG, "Filter output: %s, %ux%u (%"PRId64"), mode: %s.\n",
|
||||||
av_get_pix_fmt_name(output_frame->format),
|
av_get_pix_fmt_name(output_frame->format),
|
||||||
output_frame->width, output_frame->height, output_frame->pts);
|
output_frame->width, output_frame->height, output_frame->pts,
|
||||||
|
scale_vaapi_mode_name(ctx->mode));
|
||||||
|
|
||||||
return ff_filter_frame(outlink, output_frame);
|
return ff_filter_frame(outlink, output_frame);
|
||||||
|
|
||||||
@@ -174,6 +193,17 @@ static const AVOption scale_vaapi_options[] = {
|
|||||||
OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, .flags = FLAGS },
|
OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, .flags = FLAGS },
|
||||||
{ "format", "Output video format (software format of hardware frames)",
|
{ "format", "Output video format (software format of hardware frames)",
|
||||||
OFFSET(output_format_string), AV_OPT_TYPE_STRING, .flags = FLAGS },
|
OFFSET(output_format_string), AV_OPT_TYPE_STRING, .flags = FLAGS },
|
||||||
|
{ "mode", "Scaling mode",
|
||||||
|
OFFSET(mode), AV_OPT_TYPE_INT, { .i64 = VA_FILTER_SCALING_HQ },
|
||||||
|
0, VA_FILTER_SCALING_NL_ANAMORPHIC, FLAGS, "mode" },
|
||||||
|
{ "default", "Use the default (depend on the driver) scaling algorithm",
|
||||||
|
0, AV_OPT_TYPE_CONST, { .i64 = VA_FILTER_SCALING_DEFAULT }, 0, 0, FLAGS, "mode" },
|
||||||
|
{ "fast", "Use fast scaling algorithm",
|
||||||
|
0, AV_OPT_TYPE_CONST, { .i64 = VA_FILTER_SCALING_FAST }, 0, 0, FLAGS, "mode" },
|
||||||
|
{ "hq", "Use high quality scaling algorithm",
|
||||||
|
0, AV_OPT_TYPE_CONST, { .i64 = VA_FILTER_SCALING_HQ }, 0, 0, FLAGS, "mode" },
|
||||||
|
{ "nl_anamorphic", "Use nolinear anamorphic scaling algorithm",
|
||||||
|
0, AV_OPT_TYPE_CONST, { .i64 = VA_FILTER_SCALING_NL_ANAMORPHIC }, 0, 0, FLAGS, "mode" },
|
||||||
{ NULL },
|
{ NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user