mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 06:46:38 +00:00
value: Remove set-style bitmask intersection/union/subtraction functions
Set operations on the bitmasks don't make much sense and result in invalid caps when used as a channel-mask. They are now handled exactly like integers. This functionality was not used anywhere except for tests. https://bugzilla.gnome.org/show_bug.cgi?id=691370
This commit is contained in:
parent
e479d22040
commit
fb3b53328f
2 changed files with 2 additions and 95 deletions
|
@ -4756,9 +4756,6 @@ gst_value_register_subtract_func (GType minuend_type, GType subtrahend_type,
|
||||||
{
|
{
|
||||||
GstValueSubtractInfo info;
|
GstValueSubtractInfo info;
|
||||||
|
|
||||||
/* one type must be unfixed, other subtractions can be done as comparisons,
|
|
||||||
* special case: bitmasks */
|
|
||||||
if (minuend_type != GST_TYPE_BITMASK)
|
|
||||||
g_return_if_fail (!gst_type_is_fixed (minuend_type)
|
g_return_if_fail (!gst_type_is_fixed (minuend_type)
|
||||||
|| !gst_type_is_fixed (subtrahend_type));
|
|| !gst_type_is_fixed (subtrahend_type));
|
||||||
|
|
||||||
|
@ -5649,58 +5646,6 @@ gst_value_transform_bitmask_uint64 (const GValue * src_value,
|
||||||
dest_value->data[0].v_uint64 = src_value->data[0].v_uint64;
|
dest_value->data[0].v_uint64 = src_value->data[0].v_uint64;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_value_intersect_bitmask_bitmask (GValue * dest, const GValue * src1,
|
|
||||||
const GValue * src2)
|
|
||||||
{
|
|
||||||
guint64 s1, s2;
|
|
||||||
|
|
||||||
s1 = gst_value_get_bitmask (src1);
|
|
||||||
s2 = gst_value_get_bitmask (src2);
|
|
||||||
|
|
||||||
if (dest) {
|
|
||||||
g_value_init (dest, GST_TYPE_BITMASK);
|
|
||||||
gst_value_set_bitmask (dest, s1 & s2);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_value_union_bitmask_bitmask (GValue * dest, const GValue * src1,
|
|
||||||
const GValue * src2)
|
|
||||||
{
|
|
||||||
guint64 s1, s2;
|
|
||||||
|
|
||||||
s1 = gst_value_get_bitmask (src1);
|
|
||||||
s2 = gst_value_get_bitmask (src2);
|
|
||||||
|
|
||||||
g_value_init (dest, GST_TYPE_BITMASK);
|
|
||||||
gst_value_set_bitmask (dest, s1 | s2);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_value_subtract_bitmask_bitmask (GValue * dest,
|
|
||||||
const GValue * minuend, const GValue * subtrahend)
|
|
||||||
{
|
|
||||||
guint64 m, s, r;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GST_VALUE_HOLDS_BITMASK (minuend), FALSE);
|
|
||||||
g_return_val_if_fail (GST_VALUE_HOLDS_BITMASK (subtrahend), FALSE);
|
|
||||||
|
|
||||||
m = minuend->data[0].v_uint64;
|
|
||||||
s = subtrahend->data[0].v_uint64;
|
|
||||||
r = m & (~s);
|
|
||||||
|
|
||||||
if (dest) {
|
|
||||||
g_value_init (dest, GST_TYPE_BITMASK);
|
|
||||||
gst_value_set_bitmask (dest, r);
|
|
||||||
}
|
|
||||||
return (r != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
gst_value_compare_bitmask (const GValue * value1, const GValue * value2)
|
gst_value_compare_bitmask (const GValue * value1, const GValue * value2)
|
||||||
{
|
{
|
||||||
|
@ -6181,8 +6126,6 @@ _priv_gst_value_initialize (void)
|
||||||
gst_value_register_intersect_func (GST_TYPE_FRACTION_RANGE,
|
gst_value_register_intersect_func (GST_TYPE_FRACTION_RANGE,
|
||||||
GST_TYPE_FRACTION_RANGE,
|
GST_TYPE_FRACTION_RANGE,
|
||||||
gst_value_intersect_fraction_range_fraction_range);
|
gst_value_intersect_fraction_range_fraction_range);
|
||||||
gst_value_register_intersect_func (GST_TYPE_BITMASK,
|
|
||||||
GST_TYPE_BITMASK, gst_value_intersect_bitmask_bitmask);
|
|
||||||
|
|
||||||
gst_value_register_subtract_func (G_TYPE_INT, GST_TYPE_INT_RANGE,
|
gst_value_register_subtract_func (G_TYPE_INT, GST_TYPE_INT_RANGE,
|
||||||
gst_value_subtract_int_int_range);
|
gst_value_subtract_int_int_range);
|
||||||
|
@ -6209,8 +6152,6 @@ _priv_gst_value_initialize (void)
|
||||||
gst_value_register_subtract_func (GST_TYPE_FRACTION_RANGE,
|
gst_value_register_subtract_func (GST_TYPE_FRACTION_RANGE,
|
||||||
GST_TYPE_FRACTION_RANGE,
|
GST_TYPE_FRACTION_RANGE,
|
||||||
gst_value_subtract_fraction_range_fraction_range);
|
gst_value_subtract_fraction_range_fraction_range);
|
||||||
gst_value_register_subtract_func (GST_TYPE_BITMASK,
|
|
||||||
GST_TYPE_BITMASK, gst_value_subtract_bitmask_bitmask);
|
|
||||||
|
|
||||||
/* see bug #317246, #64994, #65041 */
|
/* see bug #317246, #64994, #65041 */
|
||||||
{
|
{
|
||||||
|
@ -6223,8 +6164,6 @@ _priv_gst_value_initialize (void)
|
||||||
gst_value_union_int_int_range);
|
gst_value_union_int_int_range);
|
||||||
gst_value_register_union_func (GST_TYPE_INT_RANGE, GST_TYPE_INT_RANGE,
|
gst_value_register_union_func (GST_TYPE_INT_RANGE, GST_TYPE_INT_RANGE,
|
||||||
gst_value_union_int_range_int_range);
|
gst_value_union_int_range_int_range);
|
||||||
gst_value_register_union_func (GST_TYPE_BITMASK,
|
|
||||||
GST_TYPE_BITMASK, gst_value_union_bitmask_bitmask);
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Implement these if needed */
|
/* Implement these if needed */
|
||||||
|
|
|
@ -810,16 +810,6 @@ GST_START_TEST (test_value_intersect)
|
||||||
g_value_unset (&src1);
|
g_value_unset (&src1);
|
||||||
g_value_unset (&src2);
|
g_value_unset (&src2);
|
||||||
g_value_unset (&dest);
|
g_value_unset (&dest);
|
||||||
|
|
||||||
g_value_init (&src1, GST_TYPE_BITMASK);
|
|
||||||
gst_value_set_bitmask (&src1, 0xf00f);
|
|
||||||
g_value_init (&src2, GST_TYPE_BITMASK);
|
|
||||||
gst_value_set_bitmask (&src2, 0xff00);
|
|
||||||
ret = gst_value_intersect (&dest, &src1, &src2);
|
|
||||||
fail_unless (ret == TRUE);
|
|
||||||
fail_unless_equals_uint64 (0xf000, gst_value_get_bitmask (&dest));
|
|
||||||
g_value_unset (&src1);
|
|
||||||
g_value_unset (&src2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
@ -1919,27 +1909,6 @@ GST_START_TEST (test_value_subtract_fraction_list)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_value_subtract_bitmask)
|
|
||||||
{
|
|
||||||
GValue result = { 0 };
|
|
||||||
GValue src1 = { 0 };
|
|
||||||
GValue src2 = { 0 };
|
|
||||||
|
|
||||||
/* Subtract 1/4 from 1/2 */
|
|
||||||
g_value_init (&src1, GST_TYPE_BITMASK);
|
|
||||||
g_value_init (&src2, GST_TYPE_BITMASK);
|
|
||||||
gst_value_set_bitmask (&src1, 0xffff);
|
|
||||||
gst_value_set_bitmask (&src2, 0xff00);
|
|
||||||
fail_unless (gst_value_subtract (&result, &src1, &src2) == TRUE);
|
|
||||||
fail_unless_equals_uint64 (0x00ff, gst_value_get_bitmask (&result));
|
|
||||||
|
|
||||||
g_value_unset (&src1);
|
|
||||||
g_value_unset (&src2);
|
|
||||||
g_value_unset (&result);
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_END_TEST;
|
|
||||||
|
|
||||||
GST_START_TEST (test_date)
|
GST_START_TEST (test_date)
|
||||||
{
|
{
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
|
@ -2868,7 +2837,6 @@ gst_value_suite (void)
|
||||||
tcase_add_test (tc_chain, test_value_subtract_fraction);
|
tcase_add_test (tc_chain, test_value_subtract_fraction);
|
||||||
tcase_add_test (tc_chain, test_value_subtract_fraction_range);
|
tcase_add_test (tc_chain, test_value_subtract_fraction_range);
|
||||||
tcase_add_test (tc_chain, test_value_subtract_fraction_list);
|
tcase_add_test (tc_chain, test_value_subtract_fraction_list);
|
||||||
tcase_add_test (tc_chain, test_value_subtract_bitmask);
|
|
||||||
tcase_add_test (tc_chain, test_date);
|
tcase_add_test (tc_chain, test_date);
|
||||||
tcase_add_test (tc_chain, test_date_time);
|
tcase_add_test (tc_chain, test_date_time);
|
||||||
tcase_add_test (tc_chain, test_fraction_range);
|
tcase_add_test (tc_chain, test_fraction_range);
|
||||||
|
|
Loading…
Reference in a new issue