It is needed to have the calls to MFXJoinSession succeed.
---
 libavutil/hwcontext_qsv.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index e0f6875b40..b7ed79cad4 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -1029,6 +1029,24 @@ static int 
qsv_device_derive_from_child(AVHWDeviceContext *ctx,
         goto fail;
     }
 
+    err = MFXQueryVersion(hwctx->session, &ver);
+    if (err != MFX_ERR_NONE) {
+        av_log(ctx, AV_LOG_ERROR, "Error querying an MFX session: "
+                "%d.\n", err);
+        ret = AVERROR_UNKNOWN;
+        goto fail;
+    }
+
+    MFXClose(hwctx->session);
+
+    err = MFXInit(implementation, &ver, &hwctx->session);
+    if (err != MFX_ERR_NONE) {
+        av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: "
+                                  "%d.\n", err);
+        ret = AVERROR_UNKNOWN;
+        goto fail;
+    }
+
     err = MFXVideoCORE_SetHandle(hwctx->session, handle_type, handle);
     if (err != MFX_ERR_NONE) {
         av_log(ctx, AV_LOG_ERROR, "Error setting child device handle: "
-- 
2.11.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to