mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-28 20:53:54 +02:00
lavfi/scale_qsv: re-use VPPContext for scale_qsv filter
QSVScaleContext and VPPContext have the same base context, and all features in scale_qsv are implemented in vpp_qsv filter, so scale_qsv can be taken as a special case of vpp_qsv filter, and we may use VPPContext with a different option array, preinit callback and supported pixel formats to implement scale_qsv then remove QSVScaleContext Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
This commit is contained in:
parent
d66312cf27
commit
9c09fb232b
@ -446,7 +446,7 @@ OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o scale_eval.o
|
||||
OBJS-$(CONFIG_SCALE_CUDA_FILTER) += vf_scale_cuda.o scale_eval.o \
|
||||
vf_scale_cuda.ptx.o cuda/load_helper.o
|
||||
OBJS-$(CONFIG_SCALE_NPP_FILTER) += vf_scale_npp.o scale_eval.o
|
||||
OBJS-$(CONFIG_SCALE_QSV_FILTER) += vf_scale_qsv.o
|
||||
OBJS-$(CONFIG_SCALE_QSV_FILTER) += vf_vpp_qsv.o
|
||||
OBJS-$(CONFIG_SCALE_VAAPI_FILTER) += vf_scale_vaapi.o scale_eval.o vaapi_vpp.o
|
||||
OBJS-$(CONFIG_SCALE_VULKAN_FILTER) += vf_scale_vulkan.o vulkan.o vulkan_filter.o
|
||||
OBJS-$(CONFIG_SCALE2REF_FILTER) += vf_scale.o scale_eval.o
|
||||
|
@ -1,290 +0,0 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* scale video filter - QSV
|
||||
*/
|
||||
|
||||
#include <mfxvideo.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libavutil/avstring.h"
|
||||
#include "libavutil/common.h"
|
||||
#include "libavutil/eval.h"
|
||||
#include "libavutil/hwcontext.h"
|
||||
#include "libavutil/hwcontext_qsv.h"
|
||||
#include "libavutil/internal.h"
|
||||
#include "libavutil/mathematics.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/pixdesc.h"
|
||||
#include "libavutil/time.h"
|
||||
#include "libavfilter/qsvvpp.h"
|
||||
|
||||
#include "avfilter.h"
|
||||
#include "formats.h"
|
||||
#include "internal.h"
|
||||
#include "video.h"
|
||||
|
||||
static const char *const var_names[] = {
|
||||
"in_w", "iw",
|
||||
"in_h", "ih",
|
||||
"out_w", "ow",
|
||||
"out_h", "oh",
|
||||
"a", "dar",
|
||||
"sar",
|
||||
NULL
|
||||
};
|
||||
|
||||
enum var_name {
|
||||
VAR_IN_W, VAR_IW,
|
||||
VAR_IN_H, VAR_IH,
|
||||
VAR_OUT_W, VAR_OW,
|
||||
VAR_OUT_H, VAR_OH,
|
||||
VAR_A, VAR_DAR,
|
||||
VAR_SAR,
|
||||
VARS_NB
|
||||
};
|
||||
|
||||
#define MFX_IMPL_VIA_MASK(impl) (0x0f00 & (impl))
|
||||
|
||||
typedef struct QSVScaleContext {
|
||||
QSVVPPContext qsv;
|
||||
|
||||
mfxExtVPPScaling scale_conf;
|
||||
int mode;
|
||||
|
||||
/**
|
||||
* New dimensions. Special values are:
|
||||
* 0 = original width/height
|
||||
* -1 = keep original aspect
|
||||
*/
|
||||
int w, h;
|
||||
|
||||
/**
|
||||
* Output sw format. AV_PIX_FMT_NONE for no conversion.
|
||||
*/
|
||||
enum AVPixelFormat format;
|
||||
|
||||
char *w_expr; ///< width expression string
|
||||
char *h_expr; ///< height expression string
|
||||
char *format_str;
|
||||
} QSVScaleContext;
|
||||
|
||||
static av_cold int qsvscale_init(AVFilterContext *ctx)
|
||||
{
|
||||
QSVScaleContext *s = ctx->priv;
|
||||
|
||||
if (!strcmp(s->format_str, "same")) {
|
||||
s->format = AV_PIX_FMT_NONE;
|
||||
} else {
|
||||
s->format = av_get_pix_fmt(s->format_str);
|
||||
if (s->format == AV_PIX_FMT_NONE) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Unrecognized pixel format: %s\n", s->format_str);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static av_cold void qsvscale_uninit(AVFilterContext *ctx)
|
||||
{
|
||||
ff_qsvvpp_close(ctx);
|
||||
}
|
||||
|
||||
static int qsvscale_config_props(AVFilterLink *outlink)
|
||||
{
|
||||
AVFilterContext *ctx = outlink->src;
|
||||
AVFilterLink *inlink = outlink->src->inputs[0];
|
||||
QSVScaleContext *s = ctx->priv;
|
||||
QSVVPPParam param = { NULL };
|
||||
mfxExtBuffer *ext_buf[1];
|
||||
int64_t w, h;
|
||||
double var_values[VARS_NB], res;
|
||||
char *expr;
|
||||
int ret;
|
||||
enum AVPixelFormat in_format;
|
||||
|
||||
var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w;
|
||||
var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h;
|
||||
var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN;
|
||||
var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN;
|
||||
var_values[VAR_A] = (double) inlink->w / inlink->h;
|
||||
var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ?
|
||||
(double) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1;
|
||||
var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR];
|
||||
|
||||
/* evaluate width and height */
|
||||
av_expr_parse_and_eval(&res, (expr = s->w_expr),
|
||||
var_names, var_values,
|
||||
NULL, NULL, NULL, NULL, NULL, 0, ctx);
|
||||
s->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res;
|
||||
if ((ret = av_expr_parse_and_eval(&res, (expr = s->h_expr),
|
||||
var_names, var_values,
|
||||
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
|
||||
goto fail;
|
||||
s->h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res;
|
||||
/* evaluate again the width, as it may depend on the output height */
|
||||
if ((ret = av_expr_parse_and_eval(&res, (expr = s->w_expr),
|
||||
var_names, var_values,
|
||||
NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
|
||||
goto fail;
|
||||
s->w = res;
|
||||
|
||||
w = s->w;
|
||||
h = s->h;
|
||||
|
||||
/* sanity check params */
|
||||
if (w < -1 || h < -1) {
|
||||
av_log(ctx, AV_LOG_ERROR, "Size values less than -1 are not acceptable.\n");
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
if (w == -1 && h == -1)
|
||||
s->w = s->h = 0;
|
||||
|
||||
if (!(w = s->w))
|
||||
w = inlink->w;
|
||||
if (!(h = s->h))
|
||||
h = inlink->h;
|
||||
if (w == -1)
|
||||
w = av_rescale(h, inlink->w, inlink->h);
|
||||
if (h == -1)
|
||||
h = av_rescale(w, inlink->h, inlink->w);
|
||||
|
||||
if (w > INT_MAX || h > INT_MAX ||
|
||||
(h * inlink->w) > INT_MAX ||
|
||||
(w * inlink->h) > INT_MAX)
|
||||
av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n");
|
||||
|
||||
outlink->w = w;
|
||||
outlink->h = h;
|
||||
|
||||
if (inlink->format == AV_PIX_FMT_QSV) {
|
||||
if (!inlink->hw_frames_ctx || !inlink->hw_frames_ctx->data)
|
||||
return AVERROR(EINVAL);
|
||||
else
|
||||
in_format = ((AVHWFramesContext*)inlink->hw_frames_ctx->data)->sw_format;
|
||||
} else
|
||||
in_format = inlink->format;
|
||||
|
||||
if (s->format == AV_PIX_FMT_NONE)
|
||||
s->format = in_format;
|
||||
|
||||
outlink->frame_rate = inlink->frame_rate;
|
||||
outlink->time_base = av_inv_q(inlink->frame_rate);
|
||||
param.out_sw_format = s->format;
|
||||
|
||||
param.ext_buf = ext_buf;
|
||||
memset(&s->scale_conf, 0, sizeof(mfxExtVPPScaling));
|
||||
s->scale_conf.Header.BufferId = MFX_EXTBUFF_VPP_SCALING;
|
||||
s->scale_conf.Header.BufferSz = sizeof(mfxExtVPPScaling);
|
||||
s->scale_conf.ScalingMode = s->mode;
|
||||
param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&s->scale_conf;
|
||||
av_log(ctx, AV_LOG_VERBOSE, "Scaling mode: %d\n", s->mode);
|
||||
|
||||
ret = ff_qsvvpp_init(ctx, ¶m);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d -> w:%d h:%d\n",
|
||||
inlink->w, inlink->h, outlink->w, outlink->h);
|
||||
|
||||
if (inlink->sample_aspect_ratio.num)
|
||||
outlink->sample_aspect_ratio = av_mul_q((AVRational){outlink->h*inlink->w,
|
||||
outlink->w*inlink->h},
|
||||
inlink->sample_aspect_ratio);
|
||||
else
|
||||
outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"Error when evaluating the expression '%s'\n", expr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int qsvscale_filter_frame(AVFilterLink *link, AVFrame *in)
|
||||
{
|
||||
int ret = 0;
|
||||
AVFilterContext *ctx = link->dst;
|
||||
QSVVPPContext *qsv = ctx->priv;
|
||||
|
||||
ret = ff_qsvvpp_filter_frame(qsv, link, in);
|
||||
av_frame_free(&in);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define OFFSET(x) offsetof(QSVScaleContext, x)
|
||||
#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
|
||||
static const AVOption options[] = {
|
||||
{ "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS },
|
||||
{ "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS },
|
||||
{ "format", "Output pixel format", OFFSET(format_str), AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
|
||||
|
||||
{ "mode", "set scaling mode", OFFSET(mode), AV_OPT_TYPE_INT, { .i64 = MFX_SCALING_MODE_DEFAULT}, MFX_SCALING_MODE_DEFAULT, MFX_SCALING_MODE_QUALITY, FLAGS, "mode"},
|
||||
{ "low_power", "low power mode", 0, AV_OPT_TYPE_CONST, { .i64 = MFX_SCALING_MODE_LOWPOWER}, INT_MIN, INT_MAX, FLAGS, "mode"},
|
||||
{ "hq", "high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = MFX_SCALING_MODE_QUALITY}, INT_MIN, INT_MAX, FLAGS, "mode"},
|
||||
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
static const AVClass qsvscale_class = {
|
||||
.class_name = "scale_qsv",
|
||||
.item_name = av_default_item_name,
|
||||
.option = options,
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
static const AVFilterPad qsvscale_inputs[] = {
|
||||
{
|
||||
.name = "default",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.filter_frame = qsvscale_filter_frame,
|
||||
.get_buffer.video = ff_qsvvpp_get_video_buffer,
|
||||
},
|
||||
};
|
||||
|
||||
static const AVFilterPad qsvscale_outputs[] = {
|
||||
{
|
||||
.name = "default",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.config_props = qsvscale_config_props,
|
||||
},
|
||||
};
|
||||
|
||||
const AVFilter ff_vf_scale_qsv = {
|
||||
.name = "scale_qsv",
|
||||
.description = NULL_IF_CONFIG_SMALL("QuickSync video scaling and format conversion"),
|
||||
|
||||
.init = qsvscale_init,
|
||||
.uninit = qsvscale_uninit,
|
||||
|
||||
.priv_size = sizeof(QSVScaleContext),
|
||||
.priv_class = &qsvscale_class,
|
||||
|
||||
FILTER_INPUTS(qsvscale_inputs),
|
||||
FILTER_OUTPUTS(qsvscale_outputs),
|
||||
|
||||
FILTER_SINGLE_PIXFMT(AV_PIX_FMT_QSV),
|
||||
|
||||
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
|
||||
};
|
@ -23,6 +23,8 @@
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include "config_components.h"
|
||||
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/eval.h"
|
||||
#include "libavutil/hwcontext.h"
|
||||
@ -101,48 +103,6 @@ typedef struct VPPContext{
|
||||
int has_passthrough; /* apply pass through mode if possible */
|
||||
} VPPContext;
|
||||
|
||||
static const AVOption 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" },
|
||||
|
||||
{ "denoise", "denoise level [0, 100]", OFFSET(denoise), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, .flags = FLAGS },
|
||||
{ "detail", "enhancement level [0, 100]", OFFSET(detail), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, .flags = FLAGS },
|
||||
{ "framerate", "output framerate", OFFSET(framerate), AV_OPT_TYPE_RATIONAL, { .dbl = 0.0 },0, DBL_MAX, .flags = FLAGS },
|
||||
{ "procamp", "Enable ProcAmp", OFFSET(procamp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = FLAGS},
|
||||
{ "hue", "ProcAmp hue", OFFSET(hue), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, -180.0, 180.0, .flags = FLAGS},
|
||||
{ "saturation", "ProcAmp saturation", OFFSET(saturation), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0.0, 10.0, .flags = FLAGS},
|
||||
{ "contrast", "ProcAmp contrast", OFFSET(contrast), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0.0, 10.0, .flags = FLAGS},
|
||||
{ "brightness", "ProcAmp brightness", OFFSET(brightness), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, -100.0, 100.0, .flags = FLAGS},
|
||||
|
||||
{ "transpose", "set transpose direction", OFFSET(transpose), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 6, FLAGS, "transpose"},
|
||||
{ "cclock_hflip", "rotate counter-clockwise with horizontal flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK_FLIP }, .flags=FLAGS, .unit = "transpose" },
|
||||
{ "clock", "rotate clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK }, .flags=FLAGS, .unit = "transpose" },
|
||||
{ "cclock", "rotate counter-clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK }, .flags=FLAGS, .unit = "transpose" },
|
||||
{ "clock_hflip", "rotate clockwise with horizontal flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK_FLIP }, .flags=FLAGS, .unit = "transpose" },
|
||||
{ "reversal", "rotate by half-turn", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_REVERSAL }, .flags=FLAGS, .unit = "transpose" },
|
||||
{ "hflip", "flip horizontally", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_HFLIP }, .flags=FLAGS, .unit = "transpose" },
|
||||
{ "vflip", "flip vertically", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_VFLIP }, .flags=FLAGS, .unit = "transpose" },
|
||||
|
||||
{ "cw", "set the width crop area expression", OFFSET(cw), AV_OPT_TYPE_STRING, { .str = "iw" }, 0, 0, FLAGS },
|
||||
{ "ch", "set the height crop area expression", OFFSET(ch), AV_OPT_TYPE_STRING, { .str = "ih" }, 0, 0, FLAGS },
|
||||
{ "cx", "set the x crop area expression", OFFSET(cx), AV_OPT_TYPE_STRING, { .str = "(in_w-out_w)/2" }, 0, 0, FLAGS },
|
||||
{ "cy", "set the y crop area expression", OFFSET(cy), AV_OPT_TYPE_STRING, { .str = "(in_h-out_h)/2" }, 0, 0, FLAGS },
|
||||
|
||||
{ "w", "Output video width(0=input video width, -1=keep input video aspect)", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS },
|
||||
{ "width", "Output video width(0=input video width, -1=keep input video aspect)", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS },
|
||||
{ "h", "Output video height(0=input video height, -1=keep input video aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
|
||||
{ "height", "Output video height(0=input video height, -1=keep input video aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
|
||||
{ "format", "Output pixel format", OFFSET(output_format_str), AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
|
||||
{ "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS },
|
||||
{ "scale_mode", "scale & format conversion mode: 0=auto, 1=low power, 2=high quality", OFFSET(scale_mode), AV_OPT_TYPE_INT, { .i64 = MFX_SCALING_MODE_DEFAULT }, MFX_SCALING_MODE_DEFAULT, MFX_SCALING_MODE_QUALITY, .flags = FLAGS, "scale mode" },
|
||||
{ "auto", "auto mode", 0, AV_OPT_TYPE_CONST, { .i64 = MFX_SCALING_MODE_DEFAULT}, INT_MIN, INT_MAX, FLAGS, "scale mode"},
|
||||
{ "low_power", "low power mode", 0, AV_OPT_TYPE_CONST, { .i64 = MFX_SCALING_MODE_LOWPOWER}, INT_MIN, INT_MAX, FLAGS, "scale mode"},
|
||||
{ "hq", "high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = MFX_SCALING_MODE_QUALITY}, INT_MIN, INT_MAX, FLAGS, "scale mode"},
|
||||
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static const char *const var_names[] = {
|
||||
"iw", "in_w",
|
||||
"ih", "in_h",
|
||||
@ -633,6 +593,30 @@ eof:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static av_cold void vpp_uninit(AVFilterContext *ctx)
|
||||
{
|
||||
ff_qsvvpp_close(ctx);
|
||||
}
|
||||
|
||||
static const AVFilterPad vpp_inputs[] = {
|
||||
{
|
||||
.name = "default",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.config_props = config_input,
|
||||
.get_buffer.video = ff_qsvvpp_get_video_buffer,
|
||||
},
|
||||
};
|
||||
|
||||
static const AVFilterPad vpp_outputs[] = {
|
||||
{
|
||||
.name = "default",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.config_props = config_output,
|
||||
},
|
||||
};
|
||||
|
||||
#if CONFIG_VPP_QSV_FILTER
|
||||
|
||||
static int query_formats(AVFilterContext *ctx)
|
||||
{
|
||||
int ret;
|
||||
@ -660,10 +644,47 @@ static int query_formats(AVFilterContext *ctx)
|
||||
&ctx->outputs[0]->incfg.formats);
|
||||
}
|
||||
|
||||
static av_cold void vpp_uninit(AVFilterContext *ctx)
|
||||
{
|
||||
ff_qsvvpp_close(ctx);
|
||||
}
|
||||
static const AVOption 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" },
|
||||
|
||||
{ "denoise", "denoise level [0, 100]", OFFSET(denoise), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, .flags = FLAGS },
|
||||
{ "detail", "enhancement level [0, 100]", OFFSET(detail), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 100, .flags = FLAGS },
|
||||
{ "framerate", "output framerate", OFFSET(framerate), AV_OPT_TYPE_RATIONAL, { .dbl = 0.0 },0, DBL_MAX, .flags = FLAGS },
|
||||
{ "procamp", "Enable ProcAmp", OFFSET(procamp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, .flags = FLAGS},
|
||||
{ "hue", "ProcAmp hue", OFFSET(hue), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, -180.0, 180.0, .flags = FLAGS},
|
||||
{ "saturation", "ProcAmp saturation", OFFSET(saturation), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0.0, 10.0, .flags = FLAGS},
|
||||
{ "contrast", "ProcAmp contrast", OFFSET(contrast), AV_OPT_TYPE_FLOAT, { .dbl = 1.0 }, 0.0, 10.0, .flags = FLAGS},
|
||||
{ "brightness", "ProcAmp brightness", OFFSET(brightness), AV_OPT_TYPE_FLOAT, { .dbl = 0.0 }, -100.0, 100.0, .flags = FLAGS},
|
||||
|
||||
{ "transpose", "set transpose direction", OFFSET(transpose), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 6, FLAGS, "transpose"},
|
||||
{ "cclock_hflip", "rotate counter-clockwise with horizontal flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK_FLIP }, .flags=FLAGS, .unit = "transpose" },
|
||||
{ "clock", "rotate clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK }, .flags=FLAGS, .unit = "transpose" },
|
||||
{ "cclock", "rotate counter-clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK }, .flags=FLAGS, .unit = "transpose" },
|
||||
{ "clock_hflip", "rotate clockwise with horizontal flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK_FLIP }, .flags=FLAGS, .unit = "transpose" },
|
||||
{ "reversal", "rotate by half-turn", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_REVERSAL }, .flags=FLAGS, .unit = "transpose" },
|
||||
{ "hflip", "flip horizontally", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_HFLIP }, .flags=FLAGS, .unit = "transpose" },
|
||||
{ "vflip", "flip vertically", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_VFLIP }, .flags=FLAGS, .unit = "transpose" },
|
||||
|
||||
{ "cw", "set the width crop area expression", OFFSET(cw), AV_OPT_TYPE_STRING, { .str = "iw" }, 0, 0, FLAGS },
|
||||
{ "ch", "set the height crop area expression", OFFSET(ch), AV_OPT_TYPE_STRING, { .str = "ih" }, 0, 0, FLAGS },
|
||||
{ "cx", "set the x crop area expression", OFFSET(cx), AV_OPT_TYPE_STRING, { .str = "(in_w-out_w)/2" }, 0, 0, FLAGS },
|
||||
{ "cy", "set the y crop area expression", OFFSET(cy), AV_OPT_TYPE_STRING, { .str = "(in_h-out_h)/2" }, 0, 0, FLAGS },
|
||||
|
||||
{ "w", "Output video width(0=input video width, -1=keep input video aspect)", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS },
|
||||
{ "width", "Output video width(0=input video width, -1=keep input video aspect)", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS },
|
||||
{ "h", "Output video height(0=input video height, -1=keep input video aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
|
||||
{ "height", "Output video height(0=input video height, -1=keep input video aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
|
||||
{ "format", "Output pixel format", OFFSET(output_format_str), AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
|
||||
{ "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS },
|
||||
{ "scale_mode", "scale & format conversion mode: 0=auto, 1=low power, 2=high quality", OFFSET(scale_mode), AV_OPT_TYPE_INT, { .i64 = MFX_SCALING_MODE_DEFAULT }, MFX_SCALING_MODE_DEFAULT, MFX_SCALING_MODE_QUALITY, .flags = FLAGS, "scale mode" },
|
||||
{ "auto", "auto mode", 0, AV_OPT_TYPE_CONST, { .i64 = MFX_SCALING_MODE_DEFAULT}, INT_MIN, INT_MAX, FLAGS, "scale mode"},
|
||||
{ "low_power", "low power mode", 0, AV_OPT_TYPE_CONST, { .i64 = MFX_SCALING_MODE_LOWPOWER}, INT_MIN, INT_MAX, FLAGS, "scale mode"},
|
||||
{ "hq", "high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = MFX_SCALING_MODE_QUALITY}, INT_MIN, INT_MAX, FLAGS, "scale mode"},
|
||||
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static const AVClass vpp_class = {
|
||||
.class_name = "vpp_qsv",
|
||||
@ -672,23 +693,6 @@ static const AVClass vpp_class = {
|
||||
.version = LIBAVUTIL_VERSION_INT,
|
||||
};
|
||||
|
||||
static const AVFilterPad vpp_inputs[] = {
|
||||
{
|
||||
.name = "default",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.config_props = config_input,
|
||||
.get_buffer.video = ff_qsvvpp_get_video_buffer,
|
||||
},
|
||||
};
|
||||
|
||||
static const AVFilterPad vpp_outputs[] = {
|
||||
{
|
||||
.name = "default",
|
||||
.type = AVMEDIA_TYPE_VIDEO,
|
||||
.config_props = config_output,
|
||||
},
|
||||
};
|
||||
|
||||
const AVFilter ff_vf_vpp_qsv = {
|
||||
.name = "vpp_qsv",
|
||||
.description = NULL_IF_CONFIG_SMALL("Quick Sync Video VPP."),
|
||||
@ -703,3 +707,59 @@ const AVFilter ff_vf_vpp_qsv = {
|
||||
.priv_class = &vpp_class,
|
||||
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if CONFIG_SCALE_QSV_FILTER
|
||||
|
||||
static const AVOption qsvscale_options[] = {
|
||||
{ "w", "Output video width(0=input video width, -1=keep input video aspect)", OFFSET(ow), AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS },
|
||||
{ "h", "Output video height(0=input video height, -1=keep input video aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS },
|
||||
{ "format", "Output pixel format", OFFSET(output_format_str), AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
|
||||
|
||||
{ "mode", "set scaling mode", OFFSET(scale_mode), AV_OPT_TYPE_INT, { .i64 = MFX_SCALING_MODE_DEFAULT}, MFX_SCALING_MODE_DEFAULT, MFX_SCALING_MODE_QUALITY, FLAGS, "mode"},
|
||||
{ "low_power", "low power mode", 0, AV_OPT_TYPE_CONST, { .i64 = MFX_SCALING_MODE_LOWPOWER}, INT_MIN, INT_MAX, FLAGS, "mode"},
|
||||
{ "hq", "high quality mode", 0, AV_OPT_TYPE_CONST, { .i64 = MFX_SCALING_MODE_QUALITY}, INT_MIN, INT_MAX, FLAGS, "mode"},
|
||||
|
||||
{ NULL },
|
||||
};
|
||||
|
||||
static av_cold int qsvscale_preinit(AVFilterContext *ctx)
|
||||
{
|
||||
VPPContext *vpp = ctx->priv;
|
||||
|
||||
vpp_preinit(ctx);
|
||||
vpp->has_passthrough = 0;
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user