diff options
author | Maxym Dmytrychenko <maxim.d33@gmail.com> | 2018-04-02 15:17:23 +0200 |
---|---|---|
committer | Maxym Dmytrychenko <maxim.d33@gmail.com> | 2018-04-08 20:47:59 +0200 |
commit | cca5e4f040971db6de0bfe6968f00c021d8a9c42 (patch) | |
tree | 8d9dc68ef641717b1d91283f712da6dcb5947a7f /libavfilter | |
parent | 29a8ed766354c45c9be4b8512c5b2eb25a450cdc (diff) |
qsv: adding Multi Frame Encode support
Starting from API 1.25 helps to improve performance of the simultaneous
encode, 1:N scenario, like:
./avconv -y -hwaccel qsv -c:v h264_qsv -r 30000/1001 -i
~/bbb_sunflower_1080p_60fps_normal.mp4 -vframes 600 -an \
-filter_complex "split=2[s1][s2]; [s1]scale_qsv=1280:720[o1];
[s2]scale_qsv=960:540[o2]" \
-map [o1] -c:v h264_qsv -b:v 3200k -minrate 3200k -maxrate 3200k -f
rawvideo /tmp/3200a.264 \
-map [o2] -c:v h264_qsv -b:v 1750k -minrate 1750k -maxrate 1750k -f
rawvideo /tmp/1750a.264
Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/qsvvpp.c | 9 | ||||
-rw-r--r-- | libavfilter/qsvvpp.h | 8 | ||||
-rw-r--r-- | libavfilter/vf_deinterlace_qsv.c | 7 | ||||
-rw-r--r-- | libavfilter/vf_scale_qsv.c | 7 |
4 files changed, 28 insertions, 3 deletions
diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index a96cfa65de..f704517aee 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -515,9 +515,12 @@ static int init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s) if (ret != MFX_ERR_NONE) return AVERROR_UNKNOWN; } - ret = MFXJoinSession(device_hwctx->session, s->session); - if (ret != MFX_ERR_NONE) - return AVERROR_UNKNOWN; + + if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) { + ret = MFXJoinSession(device_hwctx->session, s->session); + if (ret != MFX_ERR_NONE) + return AVERROR_UNKNOWN; + } if (IS_OPAQUE_MEMORY(s->in_mem_mode) || IS_OPAQUE_MEMORY(s->out_mem_mode)) { s->opaque_alloc.In.Surfaces = s->surface_ptrs_in; diff --git a/libavfilter/qsvvpp.h b/libavfilter/qsvvpp.h index 082c0a8994..d25ea69e5c 100644 --- a/libavfilter/qsvvpp.h +++ b/libavfilter/qsvvpp.h @@ -31,6 +31,14 @@ #define FF_INLINK_IDX(link) ((int)((link)->dstpad - (link)->dst->input_pads)) #define FF_OUTLINK_IDX(link) ((int)((link)->srcpad - (link)->src->output_pads)) +#define QSV_VERSION_ATLEAST(MAJOR, MINOR) \ + (MFX_VERSION_MAJOR > (MAJOR) || \ + MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR)) + +#define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR) \ + (MFX_VERSION.Major > (MAJOR)) || \ + (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)) + typedef struct QSVVPPContext QSVVPPContext; typedef struct QSVVPPCrop { diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c index 2360491d3f..bb26a4dbfe 100644 --- a/libavfilter/vf_deinterlace_qsv.c +++ b/libavfilter/vf_deinterlace_qsv.c @@ -35,6 +35,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/time.h" +#include "libavfilter/qsvvpp.h" #include "avfilter.h" #include "formats.h" @@ -214,6 +215,12 @@ static int init_out_session(AVFilterContext *ctx) return AVERROR_UNKNOWN; } + if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) { + err = MFXJoinSession(device_hwctx->session, s->session); + if (err != MFX_ERR_NONE) + return AVERROR_UNKNOWN; + } + memset(&par, 0, sizeof(par)); s->deint_conf.Header.BufferId = MFX_EXTBUFF_VPP_DEINTERLACING; diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c index c568e96259..381844cdc4 100644 --- a/libavfilter/vf_scale_qsv.c +++ b/libavfilter/vf_scale_qsv.c @@ -36,6 +36,7 @@ #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/time.h" +#include "libavfilter/qsvvpp.h" #include "avfilter.h" #include "formats.h" @@ -313,6 +314,12 @@ static int init_out_session(AVFilterContext *ctx) return AVERROR_UNKNOWN; } + if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) { + err = MFXJoinSession(device_hwctx->session, s->session); + if (err != MFX_ERR_NONE) + return AVERROR_UNKNOWN; + } + memset(&par, 0, sizeof(par)); if (opaque) { |