diff options
author | Linjie Fu <linjie.fu@intel.com> | 2019-10-08 21:41:02 +0800 |
---|---|---|
committer | Zhong Li <zhong.li@intel.com> | 2019-10-09 11:27:34 +0800 |
commit | 5345965b3f088ad5acd5151bec421c97470675a4 (patch) | |
tree | 55e28c563f3f87cf4627ded67ec89f34a50f5e97 /libavcodec/qsv.c | |
parent | 949a1b3e2f75338e17e446e97105e06ad6b4012a (diff) | |
download | ffmpeg-5345965b3f088ad5acd5151bec421c97470675a4.tar.gz |
lavc/qsvdec: Add GPU-accelerated memory copy support
GPU copy enables or disables GPU accelerated copying between video
and system memory. This may lead to a notable performance improvement.
Memory must be sequent and aligned with 128x64.
CMD:
ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -c:v h264_qsv
-gpu_copy on -i input.h264 -f null -
or:
ffmpeg -c:v h264_qsv -gpu_copy on -i input.h264 -f null -
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: ChaoX A Liu <chaox.a.liu@intel.com>
Signed-off-by: Zhong Li <zhong.li@intel.com>
Diffstat (limited to 'libavcodec/qsv.c')
-rw-r--r-- | libavcodec/qsv.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 81fa4a82ef..b00e427435 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -412,15 +412,21 @@ static int ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs) #endif //AVCODEC_QSV_LINUX_SESSION_HANDLE int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs, - const char *load_plugins) + const char *load_plugins, int gpu_copy) { - mfxIMPL impl = MFX_IMPL_AUTO_ANY; - mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } }; + mfxIMPL impl = MFX_IMPL_AUTO_ANY; + mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } }; + mfxInitParam init_par = { MFX_IMPL_AUTO_ANY }; const char *desc; int ret; - ret = MFXInit(impl, &ver, &qs->session); +#if QSV_VERSION_ATLEAST(1, 16) + init_par.GPUCopy = gpu_copy; +#endif + init_par.Implementation = impl; + init_par.Version = ver; + ret = MFXInitEx(init_par, &qs->session); if (ret < 0) return ff_qsv_print_error(avctx, ret, "Error initializing an internal MFX session"); @@ -712,7 +718,8 @@ static mfxStatus qsv_frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl) } int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, - AVBufferRef *device_ref, const char *load_plugins) + AVBufferRef *device_ref, const char *load_plugins, + int gpu_copy) { static const mfxHandleType handle_types[] = { MFX_HANDLE_VA_DISPLAY, @@ -722,11 +729,12 @@ int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)device_ref->data; AVQSVDeviceContext *device_hwctx = device_ctx->hwctx; mfxSession parent_session = device_hwctx->session; + mfxInitParam init_par = { MFX_IMPL_AUTO_ANY }; + mfxHDL handle = NULL; mfxSession session; mfxVersion ver; mfxIMPL impl; - mfxHDL handle = NULL; mfxHandleType handle_type; mfxStatus err; @@ -752,7 +760,12 @@ int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, "from the session\n"); } - err = MFXInit(impl, &ver, &session); +#if QSV_VERSION_ATLEAST(1, 16) + init_par.GPUCopy = gpu_copy; +#endif + init_par.Implementation = impl; + init_par.Version = ver; + err = MFXInitEx(init_par, &session); if (err != MFX_ERR_NONE) return ff_qsv_print_error(avctx, err, "Error initializing a child MFX session"); @@ -783,7 +796,7 @@ int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, int ff_qsv_init_session_frames(AVCodecContext *avctx, mfxSession *psession, QSVFramesContext *qsv_frames_ctx, - const char *load_plugins, int opaque) + const char *load_plugins, int opaque, int gpu_copy) { mfxFrameAllocator frame_allocator = { .pthis = qsv_frames_ctx, @@ -803,7 +816,7 @@ int ff_qsv_init_session_frames(AVCodecContext *avctx, mfxSession *psession, int ret; ret = ff_qsv_init_session_device(avctx, &session, - frames_ctx->device_ref, load_plugins); + frames_ctx->device_ref, load_plugins, gpu_copy); if (ret < 0) return ret; |