2008-11-06 Wim Taymans <wim.taymans@collabora.co.uk>
+ * gst/gstcaps.c: (gst_caps_copy), (_gst_caps_free),
+ (gst_caps_merge_structure), (gst_caps_get_structure),
+ (gst_caps_copy_nth), (gst_caps_set_simple),
+ (gst_caps_set_simple_valist), (gst_caps_is_fixed),
+ (gst_caps_is_equal_fixed), (gst_caps_intersect),
+ (gst_caps_subtract), (gst_caps_normalize), (gst_caps_do_simplify),
+ (gst_caps_to_string):
+ Callgrind micro optimisations.
+ Avoid array bounds checks and force inline of trivial function.
+
+ * gst/gstobject.c: (gst_object_set_name_default):
+ -1 is equivalent to letting glib to the strlen but then there is more
+ room for optimisations and it's not our fault.
+
+ * gst/gststructure.c: (gst_structure_id_empty_new_with_size):
+ no need to clear the array, we're cool.
+
+ * gst/gstvalue.c: (gst_type_is_fixed), (gst_value_is_fixed):
+ The most common _is_fixed() check is done on fundamental glib base
+ types so we check this first instead of doing a huge amount of
+ useless GST_TYPE_ARRAY calls.
+
+2008-11-06 Wim Taymans <wim.taymans@collabora.co.uk>
+
* gst/gstevent.h:
Add a SKIP seek flag for use with advanced trickmodes.
API: GstSeekFlags::GST_SEEK_FLAG_SKIP
#define IS_WRITABLE(caps) \
(g_atomic_int_get (&(caps)->refcount) == 1)
+/* quick way to get a caps structure at an index without doing a type or array
+ * length check */
+#define gst_caps_get_structure_unchecked(caps, index) \
+ ((GstStructure *)g_ptr_array_index ((caps)->structs, (index)))
+
+
/* lock to protect multiple invocations of static caps to caps conversion */
G_LOCK_DEFINE_STATIC (static_caps_lock);
newcaps->flags = caps->flags;
for (i = 0; i < caps->structs->len; i++) {
- structure = gst_caps_get_structure (caps, i);
+ structure = gst_caps_get_structure_unchecked (caps, i);
gst_caps_append_structure (newcaps, gst_structure_copy (structure));
}
* don't bother testing. */
for (i = 0; i < caps->structs->len; i++) {
- structure = (GstStructure *) gst_caps_get_structure (caps, i);
+ structure = (GstStructure *) gst_caps_get_structure_unchecked (caps, i);
gst_structure_set_parent_refcount (structure, NULL);
gst_structure_free (structure);
}
#endif
/* check each structure */
for (i = caps->structs->len - 1; i >= 0; i--) {
- structure1 = gst_caps_get_structure (caps, i);
+ structure1 = gst_caps_get_structure_unchecked (caps, i);
/* if structure is a subset of structure1, then skip it */
if (gst_caps_structure_is_subset (structure1, structure)) {
unique = FALSE;
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
g_return_val_if_fail (index < caps->structs->len, NULL);
- return g_ptr_array_index (caps->structs, index);
+ return gst_caps_get_structure_unchecked (caps, index);
}
/**
newcaps->flags = caps->flags;
if (caps->structs->len > nth) {
- structure = gst_caps_get_structure (caps, nth);
+ structure = gst_caps_get_structure_unchecked (caps, nth);
gst_caps_append_structure (newcaps, gst_structure_copy (structure));
}
g_return_if_fail (caps->structs->len == 1);
g_return_if_fail (IS_WRITABLE (caps));
- structure = gst_caps_get_structure (caps, 0);
+ structure = gst_caps_get_structure_unchecked (caps, 0);
va_start (var_args, field);
gst_structure_set_valist (structure, field, var_args);
g_return_if_fail (caps->structs->len == 1);
g_return_if_fail (IS_WRITABLE (caps));
- structure = gst_caps_get_structure (caps, 0);
+ structure = gst_caps_get_structure_unchecked (caps, 0);
gst_structure_set_valist (structure, field, varargs);
}
if (caps->structs->len != 1)
return FALSE;
- structure = gst_caps_get_structure (caps, 0);
+ structure = gst_caps_get_structure_unchecked (caps, 0);
return gst_structure_foreach (structure, gst_caps_is_fixed_foreach, NULL);
}
g_return_val_if_fail (gst_caps_is_fixed (caps1), FALSE);
g_return_val_if_fail (gst_caps_is_fixed (caps2), FALSE);
- struct1 = gst_caps_get_structure (caps1, 0);
- struct2 = gst_caps_get_structure (caps2, 0);
+ struct1 = gst_caps_get_structure_unchecked (caps1, 0);
+ struct2 = gst_caps_get_structure_unchecked (caps2, 0);
if (struct1->name != struct2->name) {
return FALSE;
/* now run the diagonal line, end condition is the left or bottom
* border */
while (k < caps2->structs->len) {
- struct1 = gst_caps_get_structure (caps1, j);
- struct2 = gst_caps_get_structure (caps2, k);
+ struct1 = gst_caps_get_structure_unchecked (caps1, j);
+ struct2 = gst_caps_get_structure_unchecked (caps2, k);
istruct = gst_caps_structure_intersect (struct1, struct2);
src = gst_caps_copy (minuend);
for (i = 0; i < subtrahend->structs->len; i++) {
- sub = gst_caps_get_structure (subtrahend, i);
+ sub = gst_caps_get_structure_unchecked (subtrahend, i);
if (dest) {
gst_caps_unref (src);
src = dest;
}
dest = gst_caps_new_empty ();
for (j = 0; j < src->structs->len; j++) {
- min = gst_caps_get_structure (src, j);
+ min = gst_caps_get_structure_unchecked (src, j);
if (gst_structure_get_name_id (min) == gst_structure_get_name_id (sub)) {
GSList *list;
nf.caps = newcaps;
for (i = 0; i < newcaps->structs->len; i++) {
- nf.structure = gst_caps_get_structure (newcaps, i);
+ nf.structure = gst_caps_get_structure_unchecked (newcaps, i);
while (!gst_structure_foreach (nf.structure,
gst_caps_normalize_foreach, &nf));
start = caps->structs->len - 1;
for (i = caps->structs->len - 1; i >= 0; i--) {
- simplify = gst_caps_get_structure (caps, i);
+ simplify = gst_caps_get_structure_unchecked (caps, i);
if (gst_structure_get_name_id (simplify) !=
- gst_structure_get_name_id (gst_caps_get_structure (caps, start)))
+ gst_structure_get_name_id (gst_caps_get_structure_unchecked (caps,
+ start)))
start = i;
for (j = start; j >= 0; j--) {
if (j == i)
continue;
- compare = gst_caps_get_structure (caps, j);
+ compare = gst_caps_get_structure_unchecked (caps, j);
if (gst_structure_get_name_id (simplify) !=
gst_structure_get_name_id (compare)) {
break;
/* estimate a rough string length to avoid unnecessary reallocs in GString */
slen = 0;
for (i = 0; i < caps->structs->len; i++) {
- slen += STRUCTURE_ESTIMATED_STRING_LEN (gst_caps_get_structure (caps, i));
+ slen +=
+ STRUCTURE_ESTIMATED_STRING_LEN (gst_caps_get_structure_unchecked (caps,
+ i));
}
s = g_string_sized_new (slen);
g_string_append_c (s, ' ');
}
- structure = gst_caps_get_structure (caps, i);
+ structure = gst_caps_get_structure_unchecked (caps, i);
priv_gst_structure_append_to_gstring (structure, s);
}
if (s->len && s->str[s->len - 1] == ';') {