From 123c8d14c13b832c498fd1693a05dd14d3bbd2f7 Mon Sep 17 00:00:00 2001 From: Tong Wu Date: Thu, 17 Nov 2022 10:41:10 +0800 Subject: [PATCH] msdkallocator_d3d: add gst_msdk_frame_free callback function Part-of: --- .../sys/msdk/gstmsdkallocator_d3d.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkallocator_d3d.c b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkallocator_d3d.c index 65475f12be..4dcf154f48 100644 --- a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkallocator_d3d.c +++ b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkallocator_d3d.c @@ -191,6 +191,22 @@ error_alloc: mfxStatus gst_msdk_frame_free (mfxHDL pthis, mfxFrameAllocResponse * resp) { + GstMsdkContext *context = (GstMsdkContext *) pthis; + GstMsdkAllocResponse *cached = NULL; + + cached = gst_msdk_context_get_cached_alloc_responses (context, resp); + + if (cached) { + if (!g_atomic_int_dec_and_test (&cached->refcount)) + return MFX_ERR_NONE; + } else + return MFX_ERR_NONE; + + if (!gst_msdk_context_remove_alloc_response (context, resp)) + return MFX_ERR_NONE; + + g_slice_free1 (resp->NumFrameActual * sizeof (mfxMemId), resp->mids); + return MFX_ERR_NONE; }