From b77f7b68202fed86a7069f8310b4f3c4a47d5073 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Wed, 9 Jan 2019 13:37:30 +0100 Subject: [PATCH] structure: Use GLib's CLAMP macro for fixating ranges Just a bit of refactoring. --- gst/gststructure.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gst/gststructure.c b/gst/gststructure.c index d9b1dcf9ce..43686b27dc 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -2208,14 +2208,13 @@ gst_structure_fixate_field_nearest_int (GstStructure * structure, /* already fixed */ return FALSE; } 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); return TRUE; } else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {