summaryrefslogtreecommitdiff
path: root/libavfilter/vf_vpp_qsv.c
diff options
context:
space:
mode:
authorZhong Li <zhong.li@intel.com>2018-04-04 17:51:30 +0800
committerMaxym Dmytrychenko <maxim.d33@gmail.com>2018-04-08 20:47:59 +0200
commit29a8ed766354c45c9be4b8512c5b2eb25a450cdc (patch)
tree855a34a2bcda412f5684a8a1982806d07eb984f4 /libavfilter/vf_vpp_qsv.c
parent52ed83fa1a7f5170447eff6fad0b6c57119596e9 (diff)
downloadffmpeg-29a8ed766354c45c9be4b8512c5b2eb25a450cdc.tar.gz
lavf/qsvvpp: bypass vpp if not needed.
Currently vpp pipeline is always created, even for the unnecessary cases such as setting the option "vpp_qsv=w=1280:h=720" for an input with native resolution 1280x720. Thus introduces unnecessary performance dropping, so bypass vpp if not needed. Signed-off-by: Zhong Li <zhong.li@intel.com> Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
Diffstat (limited to 'libavfilter/vf_vpp_qsv.c')
-rw-r--r--libavfilter/vf_vpp_qsv.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 610e821c1a..568dee5d29 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -27,6 +27,7 @@
#include "libavutil/eval.h"
#include "libavutil/avassert.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/mathematics.h"
#include "formats.h"
#include "internal.h"
@@ -249,6 +250,7 @@ static int config_output(AVFilterLink *outlink)
QSVVPPParam param = { NULL };
QSVVPPCrop crop = { 0 };
mfxExtBuffer *ext_buf[ENH_FILTERS_COUNT];
+ AVFilterLink *inlink = ctx->inputs[0];
outlink->w = vpp->out_width;
outlink->h = vpp->out_height;
@@ -320,14 +322,34 @@ static int config_output(AVFilterLink *outlink)
param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&vpp->procamp_conf;
}
- return ff_qsvvpp_create(ctx, &vpp->qsv, &param);
+ if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp->denoise ||
+ vpp->detail || vpp->procamp || inlink->w != outlink->w || inlink->h != outlink->h)
+ return ff_qsvvpp_create(ctx, &vpp->qsv, &param);
+ else {
+ av_log(ctx, AV_LOG_VERBOSE, "qsv vpp pass through mode.\n");
+ if (inlink->hw_frames_ctx)
+ outlink->hw_frames_ctx = av_buffer_ref(inlink->hw_frames_ctx);
+ }
+
+ return 0;
}
static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
{
- VPPContext *vpp = inlink->dst->priv;
+ int ret = 0;
+ AVFilterContext *ctx = inlink->dst;
+ VPPContext *vpp = inlink->dst->priv;
+ AVFilterLink *outlink = ctx->outputs[0];
+
+ if (vpp->qsv)
+ ret = ff_qsvvpp_filter_frame(vpp->qsv, inlink, picref);
+ else {
+ if (picref->pts != AV_NOPTS_VALUE)
+ picref->pts = av_rescale_q(picref->pts, inlink->time_base, outlink->time_base);
+ ret = ff_filter_frame(outlink, picref);
+ }
- return ff_qsvvpp_filter_frame(vpp->qsv, inlink, picref);
+ return ret;
}
static int query_formats(AVFilterContext *ctx)