mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 16:08:51 +00:00
msdk: Fix possible memory leaks
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6161>
This commit is contained in:
parent
697b35fe58
commit
fc38459e50
2 changed files with 21 additions and 12 deletions
|
@ -118,13 +118,16 @@ gst_msdk_frame_alloc (mfxHDL pthis, mfxFrameAllocRequest * req,
|
||||||
|
|
||||||
pool = gst_msdk_context_get_alloc_pool (context);
|
pool = gst_msdk_context_get_alloc_pool (context);
|
||||||
if (!pool) {
|
if (!pool) {
|
||||||
|
status = MFX_ERR_MEMORY_ALLOC;
|
||||||
goto error_alloc;
|
goto error_alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
config = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pool));
|
config = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pool));
|
||||||
if (!gst_buffer_pool_config_get_params (config, &caps, NULL, &min_buffers,
|
if (!gst_buffer_pool_config_get_params (config, &caps, NULL, &min_buffers,
|
||||||
&max_buffers))
|
&max_buffers)) {
|
||||||
|
status = MFX_ERR_MEMORY_ALLOC;
|
||||||
goto error_alloc;
|
goto error_alloc;
|
||||||
|
}
|
||||||
|
|
||||||
max_buffers = MAX (max_buffers, surfaces_num);
|
max_buffers = MAX (max_buffers, surfaces_num);
|
||||||
gst_buffer_pool_config_set_params (config, caps,
|
gst_buffer_pool_config_set_params (config, caps,
|
||||||
|
@ -138,12 +141,14 @@ gst_msdk_frame_alloc (mfxHDL pthis, mfxFrameAllocRequest * req,
|
||||||
if (!gst_buffer_pool_set_config (pool, config)) {
|
if (!gst_buffer_pool_set_config (pool, config)) {
|
||||||
GST_ERROR ("Failed to set pool config");
|
GST_ERROR ("Failed to set pool config");
|
||||||
gst_object_unref (pool);
|
gst_object_unref (pool);
|
||||||
|
status = MFX_ERR_MEMORY_ALLOC;
|
||||||
goto error_alloc;
|
goto error_alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gst_buffer_pool_set_active (pool, TRUE)) {
|
if (!gst_buffer_pool_set_active (pool, TRUE)) {
|
||||||
GST_ERROR ("Failed to activate pool");
|
GST_ERROR ("Failed to activate pool");
|
||||||
gst_object_unref (pool);
|
gst_object_unref (pool);
|
||||||
|
status = MFX_ERR_MEMORY_ALLOC;
|
||||||
goto error_alloc;
|
goto error_alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,6 +159,7 @@ gst_msdk_frame_alloc (mfxHDL pthis, mfxFrameAllocRequest * req,
|
||||||
GST_ERROR ("Failed to allocate buffer");
|
GST_ERROR ("Failed to allocate buffer");
|
||||||
gst_buffer_pool_set_active (pool, FALSE);
|
gst_buffer_pool_set_active (pool, FALSE);
|
||||||
gst_object_unref (pool);
|
gst_object_unref (pool);
|
||||||
|
status = MFX_ERR_MEMORY_ALLOC;
|
||||||
goto error_alloc;
|
goto error_alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +169,7 @@ gst_msdk_frame_alloc (mfxHDL pthis, mfxFrameAllocRequest * req,
|
||||||
GST_ERROR ("Failed to get GstMsdkSurface");
|
GST_ERROR ("Failed to get GstMsdkSurface");
|
||||||
gst_buffer_pool_set_active (pool, FALSE);
|
gst_buffer_pool_set_active (pool, FALSE);
|
||||||
gst_object_unref (pool);
|
gst_object_unref (pool);
|
||||||
|
status = MFX_ERR_MEMORY_ALLOC;
|
||||||
goto error_alloc;
|
goto error_alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +199,7 @@ gst_msdk_frame_alloc (mfxHDL pthis, mfxFrameAllocRequest * req,
|
||||||
status = gst_msdk_get_mfx_status_from_va_status (va_status);
|
status = gst_msdk_get_mfx_status_from_va_status (va_status);
|
||||||
if (status < MFX_ERR_NONE) {
|
if (status < MFX_ERR_NONE) {
|
||||||
GST_ERROR ("failed to create buffer");
|
GST_ERROR ("failed to create buffer");
|
||||||
return status;
|
goto error_alloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
msdk_mid.surface = coded_buf;
|
msdk_mid.surface = coded_buf;
|
||||||
|
@ -224,7 +231,7 @@ error_alloc:
|
||||||
g_slice_free (GstMsdkAllocResponse, msdk_resp);
|
g_slice_free (GstMsdkAllocResponse, msdk_resp);
|
||||||
if (tmp_list)
|
if (tmp_list)
|
||||||
g_list_free_full (tmp_list, (GDestroyNotify) gst_msdk_surface_list_free);
|
g_list_free_full (tmp_list, (GDestroyNotify) gst_msdk_surface_list_free);
|
||||||
return MFX_ERR_MEMORY_ALLOC;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
mfxStatus
|
mfxStatus
|
||||||
|
|
|
@ -865,12 +865,13 @@ gst_msdkvpp_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
||||||
in_surface->surface->Data.TimeStamp =
|
in_surface->surface->Data.TimeStamp =
|
||||||
gst_util_uint64_scale_round (inbuf->pts, 90000, GST_SECOND);
|
gst_util_uint64_scale_round (inbuf->pts, 90000, GST_SECOND);
|
||||||
|
|
||||||
out_surface = gst_msdk_import_to_msdk_surface (outbuf, thiz->context,
|
if (thiz->use_video_memory) {
|
||||||
&thiz->srcpad_info, GST_MAP_WRITE);
|
out_surface = gst_msdk_import_to_msdk_surface (outbuf, thiz->context,
|
||||||
|
&thiz->srcpad_info, GST_MAP_WRITE);
|
||||||
if (!thiz->use_video_memory)
|
} else {
|
||||||
out_surface =
|
out_surface =
|
||||||
gst_msdk_import_sys_mem_to_msdk_surface (outbuf, &thiz->srcpad_info);
|
gst_msdk_import_sys_mem_to_msdk_surface (outbuf, &thiz->srcpad_info);
|
||||||
|
}
|
||||||
|
|
||||||
if (out_surface) {
|
if (out_surface) {
|
||||||
out_surface->buf = gst_buffer_ref (outbuf);
|
out_surface->buf = gst_buffer_ref (outbuf);
|
||||||
|
@ -951,14 +952,15 @@ gst_msdkvpp_transform (GstBaseTransform * trans, GstBuffer * inbuf,
|
||||||
GST_BUFFER_DURATION (outbuf_new) = thiz->buffer_duration;
|
GST_BUFFER_DURATION (outbuf_new) = thiz->buffer_duration;
|
||||||
|
|
||||||
release_out_surface (thiz, out_surface);
|
release_out_surface (thiz, out_surface);
|
||||||
out_surface =
|
if (thiz->use_video_memory) {
|
||||||
gst_msdk_import_to_msdk_surface (outbuf_new, thiz->context,
|
out_surface =
|
||||||
&thiz->srcpad_buffer_pool_info, GST_MAP_WRITE);
|
gst_msdk_import_to_msdk_surface (outbuf_new, thiz->context,
|
||||||
|
&thiz->srcpad_buffer_pool_info, GST_MAP_WRITE);
|
||||||
if (!thiz->use_video_memory)
|
} else {
|
||||||
out_surface =
|
out_surface =
|
||||||
gst_msdk_import_sys_mem_to_msdk_surface (outbuf_new,
|
gst_msdk_import_sys_mem_to_msdk_surface (outbuf_new,
|
||||||
&thiz->srcpad_buffer_pool_info);
|
&thiz->srcpad_buffer_pool_info);
|
||||||
|
}
|
||||||
|
|
||||||
if (out_surface) {
|
if (out_surface) {
|
||||||
out_surface->buf = gst_buffer_ref (outbuf_new);
|
out_surface->buf = gst_buffer_ref (outbuf_new);
|
||||||
|
|
Loading…
Reference in a new issue