These are based on profiling several playback scenarios using playbin2.
GstStructure *struct1 = (GstStructure *) data;
const GValue *val1 = gst_structure_id_get_value (struct1, field_id);
- if (val1 == NULL)
+ if (G_UNLIKELY (val1 == NULL))
return FALSE;
if (gst_value_compare (val1, val2) == GST_VALUE_EQUAL) {
return TRUE;
#ifdef USE_POISONING
CAPS_POISON (caps2);
#endif
- if (gst_caps_is_any (caps1) || gst_caps_is_any (caps2)) {
+ if (G_UNLIKELY (gst_caps_is_any (caps1) || gst_caps_is_any (caps2))) {
/* FIXME: this leaks */
caps1->flags |= GST_CAPS_FLAGS_ANY;
for (i = caps2->structs->len - 1; i >= 0; i--) {
#ifdef USE_POISONING
CAPS_POISON (caps2);
#endif
- if (gst_caps_is_any (caps1)) {
+ if (G_UNLIKELY (gst_caps_is_any (caps1))) {
for (i = caps2->structs->len - 1; i >= 0; i--) {
structure = gst_caps_remove_and_get_structure (caps2, i);
gst_structure_free (structure);
}
- } else if (gst_caps_is_any (caps2)) {
+ } else if (G_UNLIKELY (gst_caps_is_any (caps2))) {
caps1->flags |= GST_CAPS_FLAGS_ANY;
for (i = caps1->structs->len - 1; i >= 0; i--) {
structure = gst_caps_remove_and_get_structure (caps1, i);
newcaps = gst_caps_new_empty ();
newcaps->flags = caps->flags;
- if (caps->structs->len > nth) {
+ if (G_LIKELY (caps->structs->len > nth)) {
structure = gst_caps_get_structure_unchecked (caps, nth);
gst_caps_append_structure (newcaps, gst_structure_copy (structure));
}
* So there should be an assertion that caps1 and caps2 != NULL */
/* NULL <-> NULL is allowed here */
- if (caps1 == caps2)
+ if (G_UNLIKELY (caps1 == caps2))
return TRUE;
/* one of them NULL => they are different (can't be both NULL because
* we checked that above) */
- if (caps1 == NULL || caps2 == NULL)
+ if (G_UNLIKELY (caps1 == NULL || caps2 == NULL))
return FALSE;
- if (gst_caps_is_fixed (caps1) && gst_caps_is_fixed (caps2))
+ if (G_UNLIKELY (gst_caps_is_fixed (caps1) && gst_caps_is_fixed (caps2)))
return gst_caps_is_equal_fixed (caps1, caps2);
return gst_caps_is_subset (caps1, caps2) && gst_caps_is_subset (caps2, caps1);
GValue dest_value = { 0 };
const GValue *val2 = gst_structure_id_get_value (idata->intersect, id);
- if (val2 == NULL) {
+ if (G_UNLIKELY (val2 == NULL)) {
gst_structure_id_set_value (idata->dest, id, val1);
} else if (idata->first_run) {
if (gst_value_intersect (&dest_value, val1, val2)) {
g_return_val_if_fail (struct1 != NULL, NULL);
g_return_val_if_fail (struct2 != NULL, NULL);
- if (struct1->name != struct2->name)
+ if (G_UNLIKELY (struct1->name != struct2->name))
return NULL;
data.dest = gst_structure_id_empty_new (struct1->name);
data.intersect = struct2;
data.first_run = TRUE;
- if (!gst_structure_foreach ((GstStructure *) struct1,
- gst_caps_structure_intersect_field, &data))
+ if (G_UNLIKELY (!gst_structure_foreach ((GstStructure *) struct1,
+ gst_caps_structure_intersect_field, &data)))
goto error;
data.intersect = struct1;
data.first_run = FALSE;
- if (!gst_structure_foreach ((GstStructure *) struct2,
- gst_caps_structure_intersect_field, &data))
+ if (G_UNLIKELY (!gst_structure_foreach ((GstStructure *) struct2,
+ gst_caps_structure_intersect_field, &data)))
goto error;
return data.dest;
g_return_val_if_fail (GST_IS_CAPS (caps2), NULL);
/* caps are exactly the same pointers, just copy one caps */
- if (caps1 == caps2)
+ if (G_UNLIKELY (caps1 == caps2))
return gst_caps_copy (caps1);
/* empty caps on either side, return empty */
- if (gst_caps_is_empty (caps1) || gst_caps_is_empty (caps2))
+ if (G_UNLIKELY (gst_caps_is_empty (caps1) || gst_caps_is_empty (caps2)))
return gst_caps_new_empty ();
/* one of the caps is any, just copy the other caps */
- if (gst_caps_is_any (caps1))
+ if (G_UNLIKELY (gst_caps_is_any (caps1)))
return gst_caps_copy (caps2);
- if (gst_caps_is_any (caps2))
+ if (G_UNLIKELY (gst_caps_is_any (caps2)))
return gst_caps_copy (caps1);
dest = gst_caps_new_empty ();
gst_caps_append_structure (dest, istruct);
/* move down left */
k++;
- if (j == 0)
+ if (G_UNLIKELY (j == 0))
break; /* so we don't roll back to G_MAXUINT */
j--;
}
/* if we have caps on both pads we can check the intersection. If one
* of the caps is NULL, we return TRUE. */
- if (srccaps == NULL || sinkcaps == NULL) {
+ if (G_UNLIKELY (srccaps == NULL || sinkcaps == NULL)) {
if (srccaps)
gst_caps_unref (srccaps);
if (sinkcaps)
GList *next = g_list_next (f);
GstPluginFeature *feature = f->data;
- if (feature && !strcmp (feature->plugin_name, name)) {
+ if (G_UNLIKELY (feature && !strcmp (feature->plugin_name, name))) {
GST_DEBUG_OBJECT (registry, "removing feature %p (%s) for plugin %s",
feature, gst_plugin_feature_get_name (feature), name);
/* FIXME: use GTree speed up lookups */
for (g = registry->plugins; g; g = g_list_next (g)) {
plugin = GST_PLUGIN_CAST (g->data);
- if (plugin->basename && strcmp (basename, plugin->basename) == 0) {
+ if (G_UNLIKELY (plugin->basename
+ && strcmp (basename, plugin->basename) == 0)) {
g_free (basename);
return plugin;
}
{
gint len = 0;
- if (len == maxlen)
+ if (G_UNLIKELY (len == maxlen))
return -1;
while (*str++ != '\0') {
len++;
- if (len == maxlen)
+ if (G_UNLIKELY (len == maxlen))
return -1;
}
return len;
/* unpack plugin feature strings */
unpack_string (*in, type_name, end, fail);
- if (!type_name) {
+ if (G_UNLIKELY (!type_name)) {
GST_ERROR ("No feature type name");
return FALSE;
}
GST_DEBUG ("Plugin '%s' feature typename : '%s'", plugin_name, type_name);
- if (!(type = g_type_from_name (type_name))) {
+ if (G_UNLIKELY (!(type = g_type_from_name (type_name)))) {
GST_ERROR ("Unknown type from typename '%s' for plugin '%s'", type_name,
plugin_name);
g_free (type_name);
return FALSE;
}
- if ((feature = g_object_new (type, NULL)) == NULL) {
+ if (G_UNLIKELY ((feature = g_object_new (type, NULL)) == NULL)) {
GST_ERROR ("Can't create feature from type");
g_free (type_name);
return FALSE;
}
- if (!GST_IS_PLUGIN_FEATURE (feature)) {
+ if (G_UNLIKELY (!GST_IS_PLUGIN_FEATURE (feature))) {
GST_ERROR ("typename : '%s' is not a plugin feature", type_name);
goto fail;
}
/* Load external plugin dependencies */
for (i = 0; i < pe->n_deps; ++i) {
- if (!gst_registry_binary_load_plugin_dep (plugin, in, end)) {
+ if (G_UNLIKELY (!gst_registry_binary_load_plugin_dep (plugin, in, end))) {
GST_ERROR_OBJECT (plugin, "Could not read external plugin dependency");
gst_registry_remove_plugin (registry, plugin);
goto fail;
#endif
mapped = g_mapped_file_new (location, FALSE, &err);
- if (err != NULL) {
+ if (G_UNLIKELY (err != NULL)) {
GST_INFO ("Unable to mmap file %s : %s", location, err->message);
g_error_free (err);
err = NULL;
return FALSE;
}
} else {
- if ((contents = g_mapped_file_get_contents (mapped)) == NULL) {
+ if (G_UNLIKELY ((contents = g_mapped_file_get_contents (mapped)) == NULL)) {
GST_ERROR ("Can't load file %s : %s", location, g_strerror (errno));
goto Error;
}
/* in is a cursor pointer, we initialize it with the begin of registry and is updated on each read */
in = contents;
GST_DEBUG ("File data at address %p", in);
- if (size < sizeof (GstBinaryRegistryMagic)) {
+ if (G_UNLIKELY (size < sizeof (GstBinaryRegistryMagic))) {
GST_ERROR ("No or broken registry header");
goto Error;
}
/* check if header is valid */
- if ((check_magic_result = gst_registry_binary_check_magic (&in, size)) < 0) {
+ if (G_UNLIKELY ((check_magic_result =
+ gst_registry_binary_check_magic (&in, size)) < 0)) {
if (check_magic_result == -1)
GST_ERROR
}
/* check if there are plugins in the file */
- if (!(((gsize) in + sizeof (GstBinaryPluginElement)) <
- (gsize) contents + size)) {
+ if (G_UNLIKELY (!(((gsize) in + sizeof (GstBinaryPluginElement)) <
+ (gsize) contents + size))) {
GST_INFO ("No binary plugins structure to read");
/* empty file, this is not an error */
} else {
g_return_val_if_fail (name != NULL, FALSE);
/* FIXME 0.11: use g_ascii_isalpha() */
- if (!g_ascii_isalnum (*name)) {
+ if (G_UNLIKELY (!g_ascii_isalnum (*name))) {
GST_WARNING ("Invalid character '%c' at offset 0 in structure name: %s",
*name, name);
return FALSE;
s = &name[1];
while (*s && (g_ascii_isalnum (*s) || strchr ("/-_.:+ ", *s) != NULL))
s++;
- if (*s != '\0') {
+ if (G_UNLIKELY (*s != '\0')) {
GST_WARNING ("Invalid character '%c' at offset %lu in structure name: %s",
*s, ((gulong) s - (gulong) name), name);
return FALSE;
type = va_arg (varargs, GType);
- if (type == G_TYPE_DATE) {
+ if (G_UNLIKELY (type == G_TYPE_DATE)) {
g_warning ("Don't use G_TYPE_DATE, use GST_TYPE_DATE instead\n");
type = GST_TYPE_DATE;
}
g_value_init (&field.value, type);
G_VALUE_COLLECT (&field.value, varargs, 0, &err);
- if (err) {
+ if (G_UNLIKELY (err)) {
g_critical ("%s", err);
return;
}
type = va_arg (varargs, GType);
- if (type == G_TYPE_DATE) {
+ if (G_UNLIKELY (type == G_TYPE_DATE)) {
g_warning ("Don't use G_TYPE_DATE, use GST_TYPE_DATE instead\n");
type = GST_TYPE_DATE;
}
g_value_init (&field.value, type);
G_VALUE_COLLECT (&field.value, varargs, 0, &err);
- if (err) {
+ if (G_UNLIKELY (err)) {
g_critical ("%s", err);
return;
}
for (i = 0; i < len; i++) {
f = GST_STRUCTURE_FIELD (structure, i);
- if (f->name == field->name) {
+ if (G_UNLIKELY (f->name == field->name)) {
g_value_unset (&f->value);
memcpy (f, field, sizeof (GstStructureField));
return;
for (i = 0; i < len; i++) {
field = GST_STRUCTURE_FIELD (structure, i);
- if (field->name == field_id)
+ if (G_UNLIKELY (field->name == field_id))
return field;
}
field = GST_STRUCTURE_FIELD (structure, i);
ret = func (field->name, &field->value, user_data);
- if (!ret)
+ if (G_UNLIKELY (!ret))
return FALSE;
}
{
char *s = str;
- while (GST_ASCII_IS_STRING (*s)) {
+ while (G_LIKELY (GST_ASCII_IS_STRING (*s))) {
s++;
}
while (g_ascii_isspace (*s) || (s[0] == '\\' && g_ascii_isspace (s[1])))
s++;
name = s;
- if (!gst_structure_parse_simple_string (s, &name_end))
+ if (G_UNLIKELY (!gst_structure_parse_simple_string (s, &name_end)))
return FALSE;
s = name_end;
while (g_ascii_isspace (*s) || (s[0] == '\\' && g_ascii_isspace (s[1])))
s++;
- if (*s != '=')
+ if (G_UNLIKELY (*s != '='))
return FALSE;
s++;
field->name = g_quark_from_string (name);
*name_end = c;
- if (!gst_structure_parse_value (s, &s, &field->value, G_TYPE_INVALID))
+ if (G_UNLIKELY (!gst_structure_parse_value (s, &s, &field->value,
+ G_TYPE_INVALID)))
return FALSE;
*after = s;
while (g_ascii_isspace (*s))
s++;
type_name = s;
- if (!gst_structure_parse_simple_string (s, &type_end))
+ if (G_UNLIKELY (!gst_structure_parse_simple_string (s, &type_end)))
return FALSE;
s = type_end;
while (g_ascii_isspace (*s))
s++;
- if (*s != ')')
+ if (G_UNLIKELY (*s != ')'))
return FALSE;
s++;
while (g_ascii_isspace (*s))
r++;
name = r;
- if (!gst_structure_parse_string (r, &w, &r)) {
+ if (G_UNLIKELY (!gst_structure_parse_string (r, &w, &r))) {
GST_WARNING ("Failed to parse structure string");
goto error;
}
/* accept \0 as end delimiter */
break;
}
- if (*r != ',') {
+ if (G_UNLIKELY (*r != ',')) {
GST_WARNING ("Failed to find delimiter, r=%s", r);
goto error;
}
r++;
memset (&field, 0, sizeof (field));
- if (!gst_structure_parse_field (r, &r, &field))
+ if (G_UNLIKELY (!gst_structure_parse_field (r, &r, &field)))
goto error;
gst_structure_set_field (structure, &field);
} while (TRUE);