From 237f17eb754a6872012555873d9e3c781be90e08 Mon Sep 17 00:00:00 2001 From: Mikhail Burakov Date: Sat, 30 Nov 2024 07:05:23 +0100 Subject: Implementing actual decoding with mfx stub (WIP) --- mfx_stub/mfxsession.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'mfx_stub/mfxsession.c') diff --git a/mfx_stub/mfxsession.c b/mfx_stub/mfxsession.c index 13bf8fc..6a5cb74 100644 --- a/mfx_stub/mfxsession.c +++ b/mfx_stub/mfxsession.c @@ -15,6 +15,7 @@ * along with receiver. If not, see . */ +#include #include #include @@ -23,13 +24,36 @@ mfxStatus MFXInit(mfxIMPL impl, mfxVersion* ver, mfxSession* session) { (void)impl; (void)ver; - mfxSession result = malloc(sizeof(struct _mfxSession)); + mfxSession result = calloc(1, sizeof(struct _mfxSession)); if (!result) return MFX_ERR_MEMORY_ALLOC; + *result = (struct _mfxSession){ + .config_id = VA_INVALID_ID, + .context_id = VA_INVALID_ID, + }; *session = result; return MFX_ERR_NONE; } mfxStatus MFXClose(mfxSession session) { + if (session->mids) { + for (size_t i = 0; i < session->mids_count; i++) { + mfxFrameAllocResponse response = { + .mids = session->mids, + .NumFrameActual = (mfxU16)session->mids_count, + }; + assert(session->allocator.Free(session->allocator.pthis, &response) == + MFX_ERR_NONE); + } + free(session->mids); + } + if (session->context_id != VA_INVALID_ID) { + assert(vaDestroyContext(session->display, session->context_id) == + VA_STATUS_SUCCESS); + } + if (session->config_id != VA_INVALID_ID) { + assert(vaDestroyConfig(session->display, session->config_id) == + VA_STATUS_SUCCESS); + } free(session); return MFX_ERR_NONE; } -- cgit v1.2.3