diff options
author | Ivan Uskov <ivan.uskov@nablet.com> | 2015-07-13 10:17:54 -0400 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2015-07-14 02:02:55 +0200 |
commit | ce91bab70f69acc1a7e5705af95cc6fa89765825 (patch) | |
tree | d2464e5c989adee7fc0278ae0cdef042fd80459a /libavcodec/qsv.c | |
parent | 96e1cc3f8b6b0b5b19820609b23642bde1ee7e7c (diff) | |
download | ffmpeg-ce91bab70f69acc1a7e5705af95cc6fa89765825.tar.gz |
libavcodec/qsv.c: Issue fixed: QSV engine does not release display handler under linux platform.
Reviewed-by: Gwenole Beauchesne <gb.devel@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/qsv.c')
-rw-r--r-- | libavcodec/qsv.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 697af872a6..4c8e6b01a9 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -85,7 +85,7 @@ int ff_qsv_error(int mfx_err) return AVERROR_UNKNOWN; } } -static int ff_qsv_set_display_handle(AVCodecContext *avctx, mfxSession session) +static int ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs) { // this code is only required for Linux. It searches for a valid // display handle. First in /dev/dri/renderD then in /dev/dri/card @@ -99,6 +99,9 @@ static int ff_qsv_set_display_handle(AVCodecContext *avctx, mfxSession session) char adapterpath[256]; int adapter_num; + qs->fd_display = -1; + qs->va_display = NULL; + //search for valid graphics device for (adapter_num = 0;adapter_num < 6;adapter_num++) { @@ -135,7 +138,9 @@ static int ff_qsv_set_display_handle(AVCodecContext *avctx, mfxSession session) } else { av_log(avctx, AV_LOG_VERBOSE, "mfx initialization: %s vaInitialize successful\n",adapterpath); - ret = MFXVideoCORE_SetHandle(session, + qs->fd_display = fd; + qs->va_display = va_dpy; + ret = MFXVideoCORE_SetHandle(qs->session, (mfxHandleType)MFX_HANDLE_VA_DISPLAY, (mfxHDL)va_dpy); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, @@ -163,7 +168,7 @@ static int ff_qsv_set_display_handle(AVCodecContext *avctx, mfxSession session) * @param avctx ffmpeg metadata for this codec context * @param session the MSDK session used */ -int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session, +int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs, const char *load_plugins) { mfxIMPL impl = MFX_IMPL_AUTO_ANY; @@ -172,17 +177,17 @@ int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session, const char *desc; int ret; - ret = MFXInit(impl, &ver, session); + ret = MFXInit(impl, &ver, &qs->session); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error initializing an internal MFX session\n"); return ff_qsv_error(ret); } - ret = ff_qsv_set_display_handle(avctx, *session); + ret = ff_qsv_set_display_handle(avctx, qs); if (ret < 0) return ret; - MFXQueryIMPL(*session, &impl); + MFXQueryIMPL(qs->session, &impl); switch (MFX_IMPL_BASETYPE(impl)) { case MFX_IMPL_SOFTWARE: @@ -222,7 +227,7 @@ int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session, } - ret = MFXVideoUSER_Load(*session, &uid, 1); + ret = MFXVideoUSER_Load(qs->session, &uid, 1); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Could not load the requested plugin: %s\n", plugin); @@ -243,3 +248,22 @@ load_plugin_fail: return 0; } + +int ff_qsv_close_internal_session(QSVSession *qs) +{ + if (qs->session) { + MFXClose(qs->session); + qs->session = NULL; + } +#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE + if (qs->va_display) { + vaTerminate(qs->va_display); + qs->va_display = NULL; + } + if (qs->fd_display > 0) { + close(qs->fd_display); + qs->fd_display = -1; + } +#endif + return 0; +} |