X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fqsvdec.c;h=c00817f1d93e533c75c186b3477bc83a78822aa9;hb=930fe4b1f75d4176a7226fccdcbd6c68b816a1b7;hp=d7664ce581bb16c3e140efd3d69551d48557d8e4;hpb=f78f3df7e01c266e83a98285fa3b5cd5823dab4d;p=ffmpeg diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index d7664ce581b..c00817f1d93 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -42,7 +42,7 @@ #include "qsvdec.h" static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession session, - AVBufferRef *hw_frames_ref) + AVBufferRef *hw_frames_ref, AVBufferRef *hw_device_ref) { int ret; @@ -59,14 +59,26 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses if (!q->frames_ctx.hw_frames_ctx) return AVERROR(ENOMEM); - ret = ff_qsv_init_session_hwcontext(avctx, &q->internal_session, - &q->frames_ctx, q->load_plugins, - q->iopattern == MFX_IOPATTERN_OUT_OPAQUE_MEMORY); + ret = ff_qsv_init_session_frames(avctx, &q->internal_session, + &q->frames_ctx, q->load_plugins, + q->iopattern == MFX_IOPATTERN_OUT_OPAQUE_MEMORY); if (ret < 0) { av_buffer_unref(&q->frames_ctx.hw_frames_ctx); return ret; } + q->session = q->internal_session; + } else if (hw_device_ref) { + if (q->internal_session) { + MFXClose(q->internal_session); + q->internal_session = NULL; + } + + ret = ff_qsv_init_session_device(avctx, &q->internal_session, + hw_device_ref, q->load_plugins); + if (ret < 0) + return ret; + q->session = q->internal_session; } else { if (!q->internal_session) { @@ -133,7 +145,7 @@ static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q) iopattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY; q->iopattern = iopattern; - ret = qsv_init_session(avctx, q, session, avctx->hw_frames_ctx); + ret = qsv_init_session(avctx, q, session, avctx->hw_frames_ctx, avctx->hw_device_ctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error initializing an MFX session\n"); return ret;