structure: Use GLib's CLAMP macro for fixating ranges

Just a bit of refactoring.
This commit is contained in:
Jan Alexander Steffens (heftig) 2019-01-09 13:37:30 +01:00 committed by Tim-Philipp Müller
parent cacc834d8f
commit b77f7b6820

View file

@ -2208,14 +2208,13 @@ gst_structure_fixate_field_nearest_int (GstStructure * structure,
/* already fixed */ /* already fixed */
return FALSE; return FALSE;
} else if (G_VALUE_TYPE (value) == GST_TYPE_INT_RANGE) { } else if (G_VALUE_TYPE (value) == GST_TYPE_INT_RANGE) {
int x; int min, max;
min = gst_value_get_int_range_min (value);
max = gst_value_get_int_range_max (value);
target = CLAMP (target, min, max);
x = gst_value_get_int_range_min (value);
if (target < x)
target = x;
x = gst_value_get_int_range_max (value);
if (target > x)
target = x;
gst_structure_set (structure, field_name, G_TYPE_INT, target, NULL); gst_structure_set (structure, field_name, G_TYPE_INT, target, NULL);
return TRUE; return TRUE;
} else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) { } else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {