mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-08 18:39:54 +00:00
libs/gst/controller/gstinterpolation.c: When linearly interpolating integer types, round to the nearest int by adding...
Original commit message from CVS: * libs/gst/controller/gstinterpolation.c: When linearly interpolating integer types, round to the nearest int by adding 0.5. Don't do it for float/double types. Fixes the failing controller test on my machine, which is somehow rounding differently than on the buildbots.
This commit is contained in:
parent
833590f239
commit
a6df9f4bac
2 changed files with 21 additions and 10 deletions
|
@ -1,3 +1,11 @@
|
|||
2007-07-19 Jan Schmidt <thaytan@noraisin.net>
|
||||
|
||||
* libs/gst/controller/gstinterpolation.c:
|
||||
When linearly interpolating integer types, round to the nearest int
|
||||
by adding 0.5. Don't do it for float/double types.
|
||||
Fixes the failing controller test on my machine, which is somehow
|
||||
rounding differently than on the buildbots.
|
||||
|
||||
2007-07-20 Stefan Kost <ensonic@users.sf.net>
|
||||
|
||||
* tools/gst-plot-timeline.py:
|
||||
|
|
|
@ -533,7 +533,7 @@ static GstInterpolateMethod interpolate_trigger = {
|
|||
/* linear interpolation */
|
||||
/* smoothes inbetween values */
|
||||
|
||||
#define DEFINE_LINEAR_GET(type) \
|
||||
#define DEFINE_LINEAR_GET(type,round) \
|
||||
static inline gboolean \
|
||||
_interpolate_linear_get_##type (GstInterpolationControlSource *self, GstClockTime timestamp, g##type *ret) \
|
||||
{ \
|
||||
|
@ -553,7 +553,10 @@ _interpolate_linear_get_##type (GstInterpolationControlSource *self, GstClockTim
|
|||
value2 = g_value_get_##type (&cp2->value); \
|
||||
slope = (gdouble) (value2 - value1) / gst_guint64_to_gdouble (cp2->timestamp - cp1->timestamp); \
|
||||
\
|
||||
*ret = (g##type) (value1 + gst_guint64_to_gdouble (timestamp - cp1->timestamp) * slope); \
|
||||
if (round) \
|
||||
*ret = (g##type) (value1 + gst_guint64_to_gdouble (timestamp - cp1->timestamp) * slope + 0.5); \
|
||||
else \
|
||||
*ret = (g##type) (value1 + gst_guint64_to_gdouble (timestamp - cp1->timestamp) * slope); \
|
||||
} \
|
||||
else { \
|
||||
*ret = g_value_get_##type (&cp1->value); \
|
||||
|
@ -603,16 +606,16 @@ interpolate_linear_get_##type##_value_array (GstInterpolationControlSource *self
|
|||
return TRUE; \
|
||||
}
|
||||
|
||||
DEFINE_LINEAR_GET (int);
|
||||
DEFINE_LINEAR_GET (int, TRUE);
|
||||
|
||||
DEFINE_LINEAR_GET (uint);
|
||||
DEFINE_LINEAR_GET (long);
|
||||
DEFINE_LINEAR_GET (uint, TRUE);
|
||||
DEFINE_LINEAR_GET (long, TRUE);
|
||||
|
||||
DEFINE_LINEAR_GET (ulong);
|
||||
DEFINE_LINEAR_GET (int64);
|
||||
DEFINE_LINEAR_GET (uint64);
|
||||
DEFINE_LINEAR_GET (float);
|
||||
DEFINE_LINEAR_GET (double);
|
||||
DEFINE_LINEAR_GET (ulong, TRUE);
|
||||
DEFINE_LINEAR_GET (int64, TRUE);
|
||||
DEFINE_LINEAR_GET (uint64, TRUE);
|
||||
DEFINE_LINEAR_GET (float, FALSE);
|
||||
DEFINE_LINEAR_GET (double, FALSE);
|
||||
|
||||
static GstInterpolateMethod interpolate_linear = {
|
||||
(GstControlSourceGetValue) interpolate_linear_get_int,
|
||||
|
|
Loading…
Reference in a new issue