aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/qsvdec.c
diff options
context:
space:
mode:
authorMark Thompson <sw@jkqxz.net>2017-03-04 23:57:36 +0000
committerMark Thompson <sw@jkqxz.net>2017-04-02 19:06:33 +0100
commit8848ba0bd6b035af77d4f13aa0d8aaaad9806fe8 (patch)
tree48110fb2f8c98ef09ca1b791b0b7c8798df819f4 /libavcodec/qsvdec.c
parent4936a48b1e6fc2147599541f8b25f43a8a9d1f16 (diff)
downloadffmpeg-8848ba0bd6b035af77d4f13aa0d8aaaad9806fe8.tar.gz
qsvdec: Allow use of hw_device_ctx to make the internal session
Diffstat (limited to 'libavcodec/qsvdec.c')
-rw-r--r--libavcodec/qsvdec.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 96526a100a..2c90436a17 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;
@@ -68,6 +68,18 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses
}
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) {
ret = ff_qsv_init_internal_session(avctx, &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;