Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/GStreamer/gstreamer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@centricular.com>2022-11-12 13:35:58 +0300
committerEdward Hervey <bilboed@bilboed.com>2022-11-13 08:59:11 +0300
commit7988144048f47dee4b5f0cf6ec4e5243a03e6499 (patch)
treeda436c0f8e2bd44c75806c171370d3e56253d7d6
parent6582cd514a6b52a5d9ea89d05ee41e3da1b2d4fb (diff)
pbutils/encoding-profile: Streamline cleanup
Cleanup all local variables in one place, and ensure failure cases go through there. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3390>
-rw-r--r--subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c
index 4ff1275c98..390f9e171b 100644
--- a/subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c
+++ b/subprojects/gst-plugins-base/gst-libs/gst/pbutils/encoding-profile.c
@@ -1826,9 +1826,9 @@ create_encoding_stream_profile (gchar * serialized_profile,
GstCaps *caps;
guint presence = 0;
gboolean single_segment = FALSE;
- gchar *strcaps, *strpresence, **strprops_v, **restriction_format,
- **preset_v, *preset_name = NULL, *factory_name = NULL,
- *variable_framerate = NULL;
+ gchar *strcaps = NULL, *strpresence, **strprops_v =
+ NULL, **restriction_format, **preset_v = NULL, *preset_name =
+ NULL, *factory_name = NULL, *variable_framerate = NULL;
GstStructure *element_properties = NULL;
GstCaps *restrictioncaps = NULL;
GstEncodingProfile *profile = NULL;
@@ -1886,7 +1886,7 @@ create_encoding_stream_profile (gchar * serialized_profile,
g_warning ("Wrong format for property: %s, only 1 `=` is expected",
prop);
g_strfreev (propv);
- return NULL;
+ goto cleanup;
}
if (!propv[1]) {
@@ -1903,7 +1903,7 @@ create_encoding_stream_profile (gchar * serialized_profile,
g_warning ("Invalid value for property 'single-segment': %s",
propv[1]);
g_strfreev (propv);
- return NULL;
+ goto cleanup;
}
single_segment = g_value_get_boolean (&v);
@@ -1911,7 +1911,7 @@ create_encoding_stream_profile (gchar * serialized_profile,
} else {
g_warning ("Unsupported property: %s", propv[0]);
g_strfreev (propv);
- return NULL;
+ goto cleanup;
}
if (presence_str) {
@@ -1920,7 +1920,7 @@ create_encoding_stream_profile (gchar * serialized_profile,
if (endptr == strprops_v[1]) {
g_warning ("Wrong presence %s", presence_str);
g_strfreev (propv);
- return NULL;
+ goto cleanup;
}
}
g_strfreev (propv);
@@ -1932,8 +1932,6 @@ create_encoding_stream_profile (gchar * serialized_profile,
strcaps = g_strdup (preset_v[0]);
} /* Else we have no presence nor preset */
}
- g_strfreev (strprops_v);
- g_strfreev (preset_v);
GST_DEBUG ("Creating preset with restrictions: %" GST_PTR_FORMAT
", caps: %s, preset %s, presence %d", restrictioncaps, strcaps,
@@ -1961,11 +1959,6 @@ create_encoding_stream_profile (gchar * serialized_profile,
gst_caps_unref (caps);
}
}
- g_free (preset_name);
- g_free (strcaps);
-
- if (restrictioncaps)
- gst_caps_unref (restrictioncaps);
if (variable_framerate) {
if (GST_IS_ENCODING_VIDEO_PROFILE (profile)) {
@@ -1986,19 +1979,26 @@ create_encoding_stream_profile (gchar * serialized_profile,
GST_WARNING
("Variable framerate specified on a non video encoding profile");
}
-
- g_free (variable_framerate);
}
if (profile == NULL) {
GST_ERROR ("No way to create a profile for description: %s",
serialized_profile);
-
- return NULL;
+ } else if (element_properties) {
+ gst_encoding_profile_set_element_properties (profile,
+ g_steal_pointer (&element_properties));
}
+cleanup:
+ g_free (strcaps);
+ g_free (variable_framerate);
+ g_strfreev (strprops_v);
+ g_strfreev (preset_v);
+ g_free (preset_name);
if (element_properties)
- gst_encoding_profile_set_element_properties (profile, element_properties);
+ gst_structure_free (element_properties);
+ if (restrictioncaps)
+ gst_caps_unref (restrictioncaps);
return profile;
}