mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 21:21:12 +00:00
d3d11: Don't use g_alloca()
_alloca CRT function is deprecated. Moreover, stack allocation for string is not a good idea. We can use _malloca inline function instead, but all use of _alloca in d3d11 library/plugin are not performance critical path at all. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3652>
This commit is contained in:
parent
21cad29bcd
commit
2e574a80d9
3 changed files with 30 additions and 17 deletions
|
@ -225,7 +225,7 @@ gst_d3d11_device_d3d11_debug (GstD3D11Device * device,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = (D3D11_MESSAGE *) g_alloca (msg_len);
|
msg = (D3D11_MESSAGE *) g_malloc0 (msg_len);
|
||||||
hr = info_queue->GetMessage (i, msg, &msg_len);
|
hr = info_queue->GetMessage (i, msg, &msg_len);
|
||||||
|
|
||||||
level = d3d11_message_severity_to_gst (msg->Severity);
|
level = d3d11_message_severity_to_gst (msg->Severity);
|
||||||
|
@ -238,6 +238,7 @@ gst_d3d11_device_d3d11_debug (GstD3D11Device * device,
|
||||||
|
|
||||||
gst_debug_log (gst_d3d11_debug_layer_debug, level, file, function, line,
|
gst_debug_log (gst_d3d11_debug_layer_debug, level, file, function, line,
|
||||||
G_OBJECT (device), "D3D11InfoQueue: %s", msg->pDescription);
|
G_OBJECT (device), "D3D11InfoQueue: %s", msg->pDescription);
|
||||||
|
g_free (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
info_queue->ClearStoredMessages ();
|
info_queue->ClearStoredMessages ();
|
||||||
|
@ -336,12 +337,13 @@ gst_d3d11_device_dxgi_debug (GstD3D11Device * device,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg = (DXGI_INFO_QUEUE_MESSAGE *) g_alloca (msg_len);
|
msg = (DXGI_INFO_QUEUE_MESSAGE *) g_malloc0 (msg_len);
|
||||||
hr = info_queue->GetMessage (DXGI_DEBUG_ALL, i, msg, &msg_len);
|
hr = info_queue->GetMessage (DXGI_DEBUG_ALL, i, msg, &msg_len);
|
||||||
|
|
||||||
level = dxgi_info_queue_message_severity_to_gst (msg->Severity);
|
level = dxgi_info_queue_message_severity_to_gst (msg->Severity);
|
||||||
gst_debug_log (gst_d3d11_debug_layer_debug, level, file, function, line,
|
gst_debug_log (gst_d3d11_debug_layer_debug, level, file, function, line,
|
||||||
G_OBJECT (device), "DXGIInfoQueue: %s", msg->pDescription);
|
G_OBJECT (device), "DXGIInfoQueue: %s", msg->pDescription);
|
||||||
|
g_free (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
info_queue->ClearStoredMessages (DXGI_DEBUG_ALL);
|
info_queue->ClearStoredMessages (DXGI_DEBUG_ALL);
|
||||||
|
|
|
@ -644,6 +644,7 @@ gst_d3d11_decoder_get_supported_decoder_profile (GstD3D11Device * device,
|
||||||
ID3D11VideoDevice *video_device;
|
ID3D11VideoDevice *video_device;
|
||||||
const GUID **profile_list = nullptr;
|
const GUID **profile_list = nullptr;
|
||||||
guint profile_size = 0;
|
guint profile_size = 0;
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), FALSE);
|
g_return_val_if_fail (GST_IS_D3D11_DEVICE (device), FALSE);
|
||||||
g_return_val_if_fail (selected_profile != nullptr, FALSE);
|
g_return_val_if_fail (selected_profile != nullptr, FALSE);
|
||||||
|
@ -713,13 +714,13 @@ gst_d3d11_decoder_get_supported_decoder_profile (GstD3D11Device * device,
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (device,
|
GST_DEBUG_OBJECT (device,
|
||||||
"Have %u available decoder profiles", available_profile_count);
|
"Have %u available decoder profiles", available_profile_count);
|
||||||
guid_list = (GUID *) g_alloca (sizeof (GUID) * available_profile_count);
|
guid_list = g_new0 (GUID, available_profile_count);
|
||||||
|
|
||||||
for (i = 0; i < available_profile_count; i++) {
|
for (i = 0; i < available_profile_count; i++) {
|
||||||
hr = video_device->GetVideoDecoderProfile (i, &guid_list[i]);
|
hr = video_device->GetVideoDecoderProfile (i, &guid_list[i]);
|
||||||
if (!gst_d3d11_result (hr, device)) {
|
if (!gst_d3d11_result (hr, device)) {
|
||||||
GST_WARNING_OBJECT (device, "Failed to get %d th decoder profile", i);
|
GST_WARNING_OBJECT (device, "Failed to get %d th decoder profile", i);
|
||||||
return FALSE;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -759,7 +760,7 @@ gst_d3d11_decoder_get_supported_decoder_profile (GstD3D11Device * device,
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
GST_INFO_OBJECT (device, "No supported decoder profile for %s codec",
|
GST_INFO_OBJECT (device, "No supported decoder profile for %s codec",
|
||||||
gst_dxva_codec_to_string (codec));
|
gst_dxva_codec_to_string (codec));
|
||||||
return FALSE;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
*selected_profile = profile;
|
*selected_profile = profile;
|
||||||
|
@ -772,7 +773,11 @@ gst_d3d11_decoder_get_supported_decoder_profile (GstD3D11Device * device,
|
||||||
profile->Data4[3], profile->Data4[4], profile->Data4[5],
|
profile->Data4[3], profile->Data4[4], profile->Data4[5],
|
||||||
profile->Data4[6], profile->Data4[7]);
|
profile->Data4[6], profile->Data4[7]);
|
||||||
|
|
||||||
return TRUE;
|
ret = TRUE;
|
||||||
|
|
||||||
|
out:
|
||||||
|
g_free (guid_list);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -894,7 +899,7 @@ gst_d3d11_decoder_open (GstD3D11Decoder * self)
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
BOOL can_support = FALSE;
|
BOOL can_support = FALSE;
|
||||||
guint config_count;
|
guint config_count;
|
||||||
D3D11_VIDEO_DECODER_CONFIG *config_list;
|
D3D11_VIDEO_DECODER_CONFIG *config_list = NULL;
|
||||||
D3D11_VIDEO_DECODER_CONFIG *best_config = NULL;
|
D3D11_VIDEO_DECODER_CONFIG *best_config = NULL;
|
||||||
D3D11_VIDEO_DECODER_DESC decoder_desc = { 0, };
|
D3D11_VIDEO_DECODER_DESC decoder_desc = { 0, };
|
||||||
const GUID *selected_profile = NULL;
|
const GUID *selected_profile = NULL;
|
||||||
|
@ -995,9 +1000,7 @@ gst_d3d11_decoder_open (GstD3D11Decoder * self)
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (self, "Total %d config available", config_count);
|
GST_DEBUG_OBJECT (self, "Total %d config available", config_count);
|
||||||
|
|
||||||
config_list = (D3D11_VIDEO_DECODER_CONFIG *)
|
config_list = g_new0 (D3D11_VIDEO_DECODER_CONFIG, config_count);
|
||||||
g_alloca (sizeof (D3D11_VIDEO_DECODER_CONFIG) * config_count);
|
|
||||||
|
|
||||||
for (i = 0; i < config_count; i++) {
|
for (i = 0; i < config_count; i++) {
|
||||||
hr = video_device->GetVideoDecoderConfig (&decoder_desc, i,
|
hr = video_device->GetVideoDecoderConfig (&decoder_desc, i,
|
||||||
&config_list[i]);
|
&config_list[i]);
|
||||||
|
@ -1074,10 +1077,12 @@ gst_d3d11_decoder_open (GstD3D11Decoder * self)
|
||||||
self->opened = TRUE;
|
self->opened = TRUE;
|
||||||
|
|
||||||
gst_d3d11_decoder_enable_high_precision_timer (self);
|
gst_d3d11_decoder_enable_high_precision_timer (self);
|
||||||
|
g_free (config_list);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
g_free (config_list);
|
||||||
gst_d3d11_decoder_reset (self);
|
gst_d3d11_decoder_reset (self);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -175,6 +175,9 @@ get_monitor_name (const MONITORINFOEXW * info,
|
||||||
UINT32 num_path = 0;
|
UINT32 num_path = 0;
|
||||||
UINT32 num_mode = 0;
|
UINT32 num_mode = 0;
|
||||||
LONG query_ret;
|
LONG query_ret;
|
||||||
|
DISPLAYCONFIG_PATH_INFO *path_infos = nullptr;
|
||||||
|
DISPLAYCONFIG_MODE_INFO *mode_infos = nullptr;
|
||||||
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
memset (target, 0, sizeof (DISPLAYCONFIG_TARGET_DEVICE_NAME));
|
memset (target, 0, sizeof (DISPLAYCONFIG_TARGET_DEVICE_NAME));
|
||||||
|
|
||||||
|
@ -183,15 +186,13 @@ get_monitor_name (const MONITORINFOEXW * info,
|
||||||
if (query_ret != ERROR_SUCCESS || num_path == 0 || num_mode == 0)
|
if (query_ret != ERROR_SUCCESS || num_path == 0 || num_mode == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
DISPLAYCONFIG_PATH_INFO *path_infos = (DISPLAYCONFIG_PATH_INFO *)
|
path_infos = g_new0 (DISPLAYCONFIG_PATH_INFO, num_path);
|
||||||
g_alloca (num_path * sizeof (DISPLAYCONFIG_PATH_INFO));
|
mode_infos = g_new0 (DISPLAYCONFIG_MODE_INFO, num_mode);
|
||||||
DISPLAYCONFIG_MODE_INFO *mode_infos = (DISPLAYCONFIG_MODE_INFO *)
|
|
||||||
g_alloca (num_mode * sizeof (DISPLAYCONFIG_MODE_INFO));
|
|
||||||
|
|
||||||
query_ret = QueryDisplayConfig (QDC_ONLY_ACTIVE_PATHS, &num_path,
|
query_ret = QueryDisplayConfig (QDC_ONLY_ACTIVE_PATHS, &num_path,
|
||||||
path_infos, &num_mode, mode_infos, nullptr);
|
path_infos, &num_mode, mode_infos, nullptr);
|
||||||
if (query_ret != ERROR_SUCCESS)
|
if (query_ret != ERROR_SUCCESS)
|
||||||
return FALSE;
|
goto out;
|
||||||
|
|
||||||
for (UINT32 i = 0; i < num_path; i++) {
|
for (UINT32 i = 0; i < num_path; i++) {
|
||||||
DISPLAYCONFIG_PATH_INFO *p = &path_infos[i];
|
DISPLAYCONFIG_PATH_INFO *p = &path_infos[i];
|
||||||
|
@ -226,10 +227,15 @@ get_monitor_name (const MONITORINFOEXW * info,
|
||||||
|
|
||||||
memcpy (target, &tmp, sizeof (DISPLAYCONFIG_TARGET_DEVICE_NAME));
|
memcpy (target, &tmp, sizeof (DISPLAYCONFIG_TARGET_DEVICE_NAME));
|
||||||
|
|
||||||
return TRUE;
|
ret = TRUE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
out:
|
||||||
|
g_free (path_infos);
|
||||||
|
g_free (mode_infos);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: please bump MinGW toolchain version,
|
/* XXX: please bump MinGW toolchain version,
|
||||||
|
|
Loading…
Reference in a new issue