[vlc-commits] variables: apply step-wise rounding after min-max boundaries
Rémi Denis-Courmont
git at videolan.org
Sat Oct 22 11:14:46 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct 22 11:16:26 2016 +0300| [c3901e4fa254b6cafda176536bbf09fa32e18e67] | committer: Rémi Denis-Courmont
variables: apply step-wise rounding after min-max boundaries
This ensures that the value is always on a valid multiple, even if
the minimum boundary is not a multiple itself.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c3901e4fa254b6cafda176536bbf09fa32e18e67
---
src/misc/variables.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/misc/variables.c b/src/misc/variables.c
index 66c94f6..a09e848 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -215,26 +215,26 @@ static void CheckValue(variable_t *var, vlc_value_t *val)
switch (var->i_type & VLC_VAR_TYPE)
{
case VLC_VAR_INTEGER:
- if ((var->i_type & VLC_VAR_HASSTEP) && var->step.i_int
- && (val->i_int % var->step.i_int))
- val->i_int = (val->i_int + (var->step.i_int / 2))
- / var->step.i_int * var->step.i_int;
if ((var->i_type & VLC_VAR_HASMIN) && val->i_int < var->min.i_int)
val->i_int = var->min.i_int;
if ((var->i_type & VLC_VAR_HASMAX) && val->i_int > var->max.i_int)
val->i_int = var->max.i_int;
+ if ((var->i_type & VLC_VAR_HASSTEP) && var->step.i_int
+ && (val->i_int % var->step.i_int))
+ val->i_int = (val->i_int + (var->step.i_int / 2))
+ / var->step.i_int * var->step.i_int;
break;
case VLC_VAR_FLOAT:
- if ((var->i_type & VLC_VAR_HASSTEP) && var->step.f_float)
- val->f_float = var->step.f_float
- * roundf(val->f_float / var->step.f_float);
if ((var->i_type & VLC_VAR_HASMIN)
- && val->f_float < var->min.f_float)
+ && isless(val->f_float, var->min.f_float))
val->f_float = var->min.f_float;
if ((var->i_type & VLC_VAR_HASMAX)
- && val->f_float > var->max.f_float)
+ && isgreater(val->f_float, var->max.f_float))
val->f_float = var->max.f_float;
+ if ((var->i_type & VLC_VAR_HASSTEP) && var->step.f_float)
+ val->f_float = var->step.f_float
+ * roundf(val->f_float / var->step.f_float);
break;
}
}
More information about the vlc-commits
mailing list