diff options
author | Mark Thompson <sw@jkqxz.net> | 2017-03-04 23:57:35 +0000 |
---|---|---|
committer | Mark Thompson <sw@jkqxz.net> | 2017-06-14 22:26:32 +0100 |
commit | 91c3b50d74ba8874ea090c29063f953f4cc90ba9 (patch) | |
tree | ba018bc7f3155acc4929c609c9ea495b8665faf1 /libavcodec/qsv.c | |
parent | bff7bec1d7d0ed23f24a2c815f133d58b6b86b1e (diff) |
qsv: Add ability to create a session from a device
(cherry picked from commit 4936a48b1e6fc2147599541f8b25f43a8a9d1f16)
Diffstat (limited to 'libavcodec/qsv.c')
-rw-r--r-- | libavcodec/qsv.c | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 1284419741..b9e2cd990d 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -535,27 +535,16 @@ static mfxStatus qsv_frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl) return MFX_ERR_NONE; } -int ff_qsv_init_session_hwcontext(AVCodecContext *avctx, mfxSession *psession, - QSVFramesContext *qsv_frames_ctx, - const char *load_plugins, int opaque) +int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession, + AVBufferRef *device_ref, const char *load_plugins) { static const mfxHandleType handle_types[] = { MFX_HANDLE_VA_DISPLAY, MFX_HANDLE_D3D9_DEVICE_MANAGER, MFX_HANDLE_D3D11_DEVICE, }; - mfxFrameAllocator frame_allocator = { - .pthis = qsv_frames_ctx, - .Alloc = qsv_frame_alloc, - .Lock = qsv_frame_lock, - .Unlock = qsv_frame_unlock, - .GetHDL = qsv_frame_get_hdl, - .Free = qsv_frame_free, - }; - - AVHWFramesContext *frames_ctx = (AVHWFramesContext*)qsv_frames_ctx->hw_frames_ctx->data; - AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx; - AVQSVDeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx; + AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)device_ref->data; + AVQSVDeviceContext *device_hwctx = device_ctx->hwctx; mfxSession parent_session = device_hwctx->session; mfxSession session; @@ -605,6 +594,36 @@ int ff_qsv_init_session_hwcontext(AVCodecContext *avctx, mfxSession *psession, return ret; } + *psession = session; + return 0; +} + +int ff_qsv_init_session_frames(AVCodecContext *avctx, mfxSession *psession, + QSVFramesContext *qsv_frames_ctx, + const char *load_plugins, int opaque) +{ + mfxFrameAllocator frame_allocator = { + .pthis = qsv_frames_ctx, + .Alloc = qsv_frame_alloc, + .Lock = qsv_frame_lock, + .Unlock = qsv_frame_unlock, + .GetHDL = qsv_frame_get_hdl, + .Free = qsv_frame_free, + }; + + AVHWFramesContext *frames_ctx = (AVHWFramesContext*)qsv_frames_ctx->hw_frames_ctx->data; + AVQSVFramesContext *frames_hwctx = frames_ctx->hwctx; + + mfxSession session; + mfxStatus err; + + int ret; + + ret = ff_qsv_init_session_device(avctx, &session, + frames_ctx->device_ref, load_plugins); + if (ret < 0) + return ret; + if (!opaque) { qsv_frames_ctx->logctx = avctx; |