mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 03:01:03 +00:00
structure: Support stepped ranges when fixating
The step restriction was completely ignored until now.
This commit is contained in:
parent
b77f7b6820
commit
c5eddea72a
1 changed files with 8 additions and 1 deletions
|
@ -2208,12 +2208,19 @@ gst_structure_fixate_field_nearest_int (GstStructure * structure,
|
|||
/* already fixed */
|
||||
return FALSE;
|
||||
} else if (G_VALUE_TYPE (value) == GST_TYPE_INT_RANGE) {
|
||||
int min, max;
|
||||
int min, max, step;
|
||||
|
||||
min = gst_value_get_int_range_min (value);
|
||||
max = gst_value_get_int_range_max (value);
|
||||
step = gst_value_get_int_range_step (value);
|
||||
|
||||
target = CLAMP (target, min, max);
|
||||
if (G_UNLIKELY (step != 1)) {
|
||||
gint rem = target % step;
|
||||
target -= rem;
|
||||
if (rem > step / 2)
|
||||
target += step;
|
||||
}
|
||||
|
||||
gst_structure_set (structure, field_name, G_TYPE_INT, target, NULL);
|
||||
return TRUE;
|
||||
|
|
Loading…
Reference in a new issue