From: <wt...@ke...> - 2008-11-06 15:10:02
|
CVS Root: /cvs/gstreamer Module: gstreamer Changes by: wtay Date: Thu Nov 06 2008 15:09:48 UTC Log message: * 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. Modified files: . : ChangeLog gst : gstcaps.c gstobject.c gststructure.c gstvalue.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.4143&r2=1.4144 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstcaps.c.diff?r1=1.190&r2=1.191 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstobject.c.diff?r1=1.130&r2=1.131 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gststructure.c.diff?r1=1.101&r2=1.102 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstvalue.c.diff?r1=1.146&r2=1.147 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v retrieving revision 1.4143 retrieving revision 1.4144 diff -u -d -r1.4143 -r1.4144 --- ChangeLog 6 Nov 2008 12:03:16 -0000 1.4143 +++ ChangeLog 6 Nov 2008 15:09:31 -0000 1.4144 @@ -1,5 +1,29 @@ 2008-11-06 Wim Taymans <wim...@co...> + * 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...@co...> * gst/gstevent.h: Add a SKIP seek flag for use with advanced trickmodes. API: GstSeekFlags::GST_SEEK_FLAG_SKIP Index: gstcaps.c RCS file: /cvs/gstreamer/gstreamer/gst/gstcaps.c,v retrieving revision 1.190 retrieving revision 1.191 diff -u -d -r1.190 -r1.191 --- gstcaps.c 7 Aug 2008 12:28:27 -0000 1.190 +++ gstcaps.c 6 Nov 2008 15:09:33 -0000 1.191 @@ -91,6 +91,12 @@ #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); @@ -272,7 +278,7 @@ 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)); } @@ -289,7 +295,7 @@ * don't bother testing. */ - 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); @@ -743,7 +749,7 @@ #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; @@ -797,7 +803,7 @@ 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); } /** @@ -822,7 +828,7 @@ if (caps->structs->len > nth) { - structure = gst_caps_get_structure (caps, nth); + structure = gst_caps_get_structure_unchecked (caps, nth); @@ -870,7 +876,7 @@ 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); @@ -896,7 +902,7 @@ gst_structure_set_valist (structure, field, varargs); @@ -965,7 +971,7 @@ if (caps->structs->len != 1) return FALSE; return gst_structure_foreach (structure, gst_caps_is_fixed_foreach, NULL); @@ -988,8 +994,8 @@ 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) { @@ -1257,8 +1263,8 @@ /* 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); @@ -1371,14 +1377,14 @@ 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; @@ -1499,7 +1505,7 @@ 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)); @@ -1660,14 +1666,15 @@ 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; @@ -1806,7 +1813,9 @@ /* estimate a rough string length to avoid unnecessary reallocs in GString */ slen = 0; - 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); @@ -1818,7 +1827,7 @@ g_string_append_c (s, ' '); priv_gst_structure_append_to_gstring (structure, s); if (s->len && s->str[s->len - 1] == ';') { Index: gstobject.c RCS file: /cvs/gstreamer/gstreamer/gst/gstobject.c,v retrieving revision 1.130 retrieving revision 1.131 diff -u -d -r1.130 -r1.131 --- gstobject.c 28 Aug 2008 20:12:54 -0000 1.130 +++ gstobject.c 6 Nov 2008 15:09:33 -0000 1.131 @@ -621,7 +621,7 @@ if (strncmp (type_name, "Gst", 3) == 0) type_name += 3; tmp = g_strdup_printf ("%s%d", type_name, count); - name = g_ascii_strdown (tmp, strlen (tmp)); + name = g_ascii_strdown (tmp, -1); g_free (tmp); result = gst_object_set_name (object, name); Index: gststructure.c RCS file: /cvs/gstreamer/gstreamer/gst/gststructure.c,v retrieving revision 1.101 retrieving revision 1.102 diff -u -d -r1.101 -r1.102 --- gststructure.c 5 Nov 2008 16:57:35 -0000 1.101 +++ gststructure.c 6 Nov 2008 15:09:34 -0000 1.102 @@ -118,7 +118,7 @@ structure->name = quark; structure->parent_refcount = NULL; structure->fields = - g_array_sized_new (FALSE, TRUE, sizeof (GstStructureField), prealloc); + g_array_sized_new (FALSE, FALSE, sizeof (GstStructureField), prealloc); return structure; Index: gstvalue.c RCS file: /cvs/gstreamer/gstreamer/gst/gstvalue.c,v retrieving revision 1.146 retrieving revision 1.147 diff -u -d -r1.146 -r1.147 --- gstvalue.c 5 Nov 2008 16:57:35 -0000 1.146 +++ gstvalue.c 6 Nov 2008 15:09:34 -0000 1.147 @@ -157,7 +157,8 @@ /* our fundamental types that are certainly not fixed */ if (type == GST_TYPE_INT_RANGE || type == GST_TYPE_DOUBLE_RANGE || - type == GST_TYPE_LIST || type == GST_TYPE_FRACTION_RANGE) { + type == GST_TYPE_LIST || type == GST_TYPE_FRACTION_RANGE || + type == GST_TYPE_ARRAY) { /* other (boxed) types that are fixed */ @@ -3341,6 +3342,9 @@ { GType type = G_VALUE_TYPE (value); + if (gst_type_is_fixed (type)) + return TRUE; if (type == GST_TYPE_ARRAY) { gint size, n; const GValue *kid; @@ -3355,7 +3359,7 @@ return TRUE; - return gst_type_is_fixed (type); + return FALSE; /************ |