summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d9901a6)
raw | patch | inline | side by side (parent: d9901a6)
author | Vincent Penquerc'h <vincent.penquerch@collabora.co.uk> | |
Thu, 27 Oct 2011 11:24:13 +0000 (12:24 +0100) | ||
committer | Vincent Penquerc'h <vincent.penquerch@collabora.co.uk> | |
Mon, 7 Nov 2011 15:17:19 +0000 (15:17 +0000) |
https://bugzilla.gnome.org/show_bug.cgi?id=662777
gst/gststructure.c | patch | blob | history | |
gst/gstvalue.c | patch | blob | history |
diff --git a/gst/gststructure.c b/gst/gststructure.c
index b2b5d2e5dae5c42d7393bd9e70f624626c60eb28..3db8ea3743bffa97cbeab2327be3876283738981 100644 (file)
--- a/gst/gststructure.c
+++ b/gst/gststructure.c
if (eq == GST_VALUE_UNORDERED) {
/* we need to try interseting */
- GValue dest_value = { 0 };
- if (gst_value_intersect (&dest_value, val1, val2)) {
- g_value_unset (&dest_value);
- } else {
+ if (!gst_value_intersect (NULL, val1, val2)) {
return FALSE;
}
} else if (eq != GST_VALUE_EQUAL) {
diff --git a/gst/gstvalue.c b/gst/gstvalue.c
index 19d7e5fd6d22a036fdb31f59edb3768b951372bf..0e02039b9563d93f5f64aa63115761307c2ef998 100644 (file)
--- a/gst/gstvalue.c
+++ b/gst/gstvalue.c
{
if (src2->data[0].v_int <= src1->data[0].v_int &&
src2->data[1].v_int >= src1->data[0].v_int) {
- gst_value_init_and_copy (dest, src1);
+ if (dest)
+ gst_value_init_and_copy (dest, src1);
return TRUE;
}
@@ -2620,13 +2621,17 @@ gst_value_intersect_int_range_int_range (GValue * dest, const GValue * src1,
max = MIN (src1->data[1].v_int, src2->data[1].v_int);
if (min < max) {
- g_value_init (dest, GST_TYPE_INT_RANGE);
- gst_value_set_int_range (dest, min, max);
+ if (dest) {
+ g_value_init (dest, GST_TYPE_INT_RANGE);
+ gst_value_set_int_range (dest, min, max);
+ }
return TRUE;
}
if (min == max) {
- g_value_init (dest, G_TYPE_INT);
- g_value_set_int (dest, min);
+ if (dest) {
+ g_value_init (dest, G_TYPE_INT);
+ g_value_set_int (dest, min);
+ }
return TRUE;
}
{
if (src2->data[0].v_int64 <= src1->data[0].v_int64 &&
src2->data[1].v_int64 >= src1->data[0].v_int64) {
- gst_value_init_and_copy (dest, src1);
+ if (dest)
+ gst_value_init_and_copy (dest, src1);
return TRUE;
}
@@ -2657,13 +2663,17 @@ gst_value_intersect_int64_range_int64_range (GValue * dest, const GValue * src1,
max = MIN (src1->data[1].v_int64, src2->data[1].v_int64);
if (min < max) {
- g_value_init (dest, GST_TYPE_INT64_RANGE);
- gst_value_set_int64_range (dest, min, max);
+ if (dest) {
+ g_value_init (dest, GST_TYPE_INT64_RANGE);
+ gst_value_set_int64_range (dest, min, max);
+ }
return TRUE;
}
if (min == max) {
- g_value_init (dest, G_TYPE_INT64);
- g_value_set_int64 (dest, min);
+ if (dest) {
+ g_value_init (dest, G_TYPE_INT64);
+ g_value_set_int64 (dest, min);
+ }
return TRUE;
}
{
if (src2->data[0].v_double <= src1->data[0].v_double &&
src2->data[1].v_double >= src1->data[0].v_double) {
- gst_value_init_and_copy (dest, src1);
+ if (dest)
+ gst_value_init_and_copy (dest, src1);
return TRUE;
}
max = MIN (src1->data[1].v_double, src2->data[1].v_double);
if (min < max) {
- g_value_init (dest, GST_TYPE_DOUBLE_RANGE);
- gst_value_set_double_range (dest, min, max);
+ if (dest) {
+ g_value_init (dest, GST_TYPE_DOUBLE_RANGE);
+ gst_value_set_double_range (dest, min, max);
+ }
return TRUE;
}
if (min == max) {
- g_value_init (dest, G_TYPE_DOUBLE);
- g_value_set_int (dest, (int) min);
+ if (dest) {
+ g_value_init (dest, G_TYPE_DOUBLE);
+ g_value_set_int (dest, (int) min);
+ }
return TRUE;
}
for (i = 0; i < size; i++) {
const GValue *cur = VALUE_LIST_GET_VALUE (value1, i);
+ /* quicker version when we don't need the resulting set */
+ if (!dest) {
+ if (gst_value_intersect (NULL, cur, value2)) {
+ ret = TRUE;
+ break;
+ }
+ continue;
+ }
+
if (gst_value_intersect (&intersection, cur, value2)) {
/* append value */
if (!ret) {
size = gst_value_array_get_size (src1);
if (size != gst_value_array_get_size (src2))
return FALSE;
+
+ /* quicker value when we don't need the resulting set */
+ if (!dest) {
+ for (n = 0; n < size; n++) {
+ if (!gst_value_intersect (NULL, gst_value_array_get_value (src1, n),
+ gst_value_array_get_value (src2, n))) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+ }
+
g_value_init (dest, GST_TYPE_ARRAY);
for (n = 0; n < size; n++) {
@@ -2787,7 +2823,8 @@ gst_value_intersect_fraction_fraction_range (GValue * dest, const GValue * src1,
if ((res1 == GST_VALUE_EQUAL || res1 == GST_VALUE_LESS_THAN) &&
(res2 == GST_VALUE_EQUAL || res2 == GST_VALUE_GREATER_THAN)) {
- gst_value_init_and_copy (dest, src1);
+ if (dest)
+ gst_value_init_and_copy (dest, src1);
return TRUE;
}
}
res = gst_value_compare_with_func (min, max, compare);
g_return_val_if_fail (res != GST_VALUE_UNORDERED, FALSE);
if (res == GST_VALUE_LESS_THAN) {
- g_value_init (dest, GST_TYPE_FRACTION_RANGE);
- vals1 = dest->data[0].v_pointer;
- g_value_copy (min, &vals1[0]);
- g_value_copy (max, &vals1[1]);
+ if (dest) {
+ g_value_init (dest, GST_TYPE_FRACTION_RANGE);
+ vals1 = dest->data[0].v_pointer;
+ g_value_copy (min, &vals1[0]);
+ g_value_copy (max, &vals1[1]);
+ }
return TRUE;
}
if (res == GST_VALUE_EQUAL) {
- gst_value_init_and_copy (dest, min);
+ if (dest)
+ gst_value_init_and_copy (dest, min);
return TRUE;
}
}
/**
* gst_value_intersect:
* @dest: (out caller-allocates): a uninitialized #GValue that will hold the calculated
- * intersection value
+ * intersection value. May be NULL if the resulting set if not needed.
* @value1: a value to intersect
* @value2: another value to intersect
*
* Calculates the intersection of two values. If the values have
* a non-empty intersection, the value representing the intersection
- * is placed in @dest. If the intersection is non-empty, @dest is
- * not modified.
+ * is placed in @dest, unless NULL. If the intersection is non-empty,
+ * @dest is not modified.
*
* Returns: TRUE if the intersection is non-empty
*/
guint i, len;
GType ltype, type1, type2;
- g_return_val_if_fail (dest != NULL, FALSE);
g_return_val_if_fail (G_IS_VALUE (value1), FALSE);
g_return_val_if_fail (G_IS_VALUE (value2), FALSE);
return gst_value_intersect_list (dest, value2, value1);
if (gst_value_compare (value1, value2) == GST_VALUE_EQUAL) {
- gst_value_init_and_copy (dest, value1);
+ if (dest)
+ gst_value_init_and_copy (dest, value1);
return TRUE;
}
return FALSE;
}
+
+
/**
* gst_value_register_intersect_func:
* @type1: the first type to intersect