mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
msdk: free mfx frames to avoid memory leaks in encoder and vpp
This commit is contained in:
parent
2d4b0a5649
commit
38c55de132
2 changed files with 17 additions and 3 deletions
|
@ -359,7 +359,7 @@ gst_msdkenc_init_encoder (GstMsdkEnc * thiz)
|
||||||
if (status < MFX_ERR_NONE) {
|
if (status < MFX_ERR_NONE) {
|
||||||
GST_ERROR_OBJECT (thiz, "Init failed (%s)",
|
GST_ERROR_OBJECT (thiz, "Init failed (%s)",
|
||||||
msdk_status_to_string (status));
|
msdk_status_to_string (status));
|
||||||
goto no_vpp;
|
goto no_vpp_free_resource;
|
||||||
} else if (status > MFX_ERR_NONE) {
|
} else if (status > MFX_ERR_NONE) {
|
||||||
GST_WARNING_OBJECT (thiz, "Init returned: %s",
|
GST_WARNING_OBJECT (thiz, "Init returned: %s",
|
||||||
msdk_status_to_string (status));
|
msdk_status_to_string (status));
|
||||||
|
@ -375,7 +375,7 @@ gst_msdkenc_init_encoder (GstMsdkEnc * thiz)
|
||||||
GST_WARNING_OBJECT (thiz, "VPP close failed (%s)",
|
GST_WARNING_OBJECT (thiz, "VPP close failed (%s)",
|
||||||
msdk_status_to_string (status1));
|
msdk_status_to_string (status1));
|
||||||
|
|
||||||
goto no_vpp;
|
goto no_vpp_free_resource;
|
||||||
} else if (status > MFX_ERR_NONE) {
|
} else if (status > MFX_ERR_NONE) {
|
||||||
GST_WARNING_OBJECT (thiz, "Get VPP Parameters returned: %s",
|
GST_WARNING_OBJECT (thiz, "Get VPP Parameters returned: %s",
|
||||||
msdk_status_to_string (status));
|
msdk_status_to_string (status));
|
||||||
|
@ -529,6 +529,9 @@ gst_msdkenc_init_encoder (GstMsdkEnc * thiz)
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
no_vpp_free_resource:
|
||||||
|
if (thiz->use_video_memory)
|
||||||
|
gst_msdk_frame_free (thiz->context, &thiz->vpp_alloc_resp);
|
||||||
no_vpp:
|
no_vpp:
|
||||||
failed:
|
failed:
|
||||||
GST_OBJECT_UNLOCK (thiz);
|
GST_OBJECT_UNLOCK (thiz);
|
||||||
|
|
|
@ -804,6 +804,11 @@ gst_msdkvpp_close (GstMsdkVPP * thiz)
|
||||||
if (!thiz->context)
|
if (!thiz->context)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (thiz->use_video_memory) {
|
||||||
|
gst_msdk_frame_free (thiz->context, &thiz->in_alloc_resp);
|
||||||
|
gst_msdk_frame_free (thiz->context, &thiz->out_alloc_resp);
|
||||||
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (thiz, "Closing VPP 0x%p", thiz->context);
|
GST_DEBUG_OBJECT (thiz, "Closing VPP 0x%p", thiz->context);
|
||||||
status = MFXVideoVPP_Close (gst_msdk_context_get_session (thiz->context));
|
status = MFXVideoVPP_Close (gst_msdk_context_get_session (thiz->context));
|
||||||
if (status != MFX_ERR_NONE && status != MFX_ERR_NOT_INITIALIZED) {
|
if (status != MFX_ERR_NONE && status != MFX_ERR_NOT_INITIALIZED) {
|
||||||
|
@ -956,8 +961,14 @@ gst_msdkvpp_initialize (GstMsdkVPP * thiz)
|
||||||
* otherwise the subsequent function call of MFXVideoVPP_Init() will
|
* otherwise the subsequent function call of MFXVideoVPP_Init() will
|
||||||
* fail
|
* fail
|
||||||
*/
|
*/
|
||||||
if (thiz->initialized)
|
if (thiz->initialized) {
|
||||||
|
if (thiz->use_video_memory) {
|
||||||
|
gst_msdk_frame_free (thiz->context, &thiz->in_alloc_resp);
|
||||||
|
gst_msdk_frame_free (thiz->context, &thiz->out_alloc_resp);
|
||||||
|
}
|
||||||
|
|
||||||
MFXVideoVPP_Close (session);
|
MFXVideoVPP_Close (session);
|
||||||
|
}
|
||||||
|
|
||||||
if (thiz->use_video_memory) {
|
if (thiz->use_video_memory) {
|
||||||
gst_msdk_set_frame_allocator (thiz->context);
|
gst_msdk_set_frame_allocator (thiz->context);
|
||||||
|
|
Loading…
Reference in a new issue