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:
Jan Schmidt 2007-07-21 21:20:37 +00:00
parent 833590f239
commit a6df9f4bac
2 changed files with 21 additions and 10 deletions

View file

@ -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> 2007-07-20 Stefan Kost <ensonic@users.sf.net>
* tools/gst-plot-timeline.py: * tools/gst-plot-timeline.py:

View file

@ -533,7 +533,7 @@ static GstInterpolateMethod interpolate_trigger = {
/* linear interpolation */ /* linear interpolation */
/* smoothes inbetween values */ /* smoothes inbetween values */
#define DEFINE_LINEAR_GET(type) \ #define DEFINE_LINEAR_GET(type,round) \
static inline gboolean \ static inline gboolean \
_interpolate_linear_get_##type (GstInterpolationControlSource *self, GstClockTime timestamp, g##type *ret) \ _interpolate_linear_get_##type (GstInterpolationControlSource *self, GstClockTime timestamp, g##type *ret) \
{ \ { \
@ -553,6 +553,9 @@ _interpolate_linear_get_##type (GstInterpolationControlSource *self, GstClockTim
value2 = g_value_get_##type (&cp2->value); \ value2 = g_value_get_##type (&cp2->value); \
slope = (gdouble) (value2 - value1) / gst_guint64_to_gdouble (cp2->timestamp - cp1->timestamp); \ slope = (gdouble) (value2 - value1) / gst_guint64_to_gdouble (cp2->timestamp - cp1->timestamp); \
\ \
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); \ *ret = (g##type) (value1 + gst_guint64_to_gdouble (timestamp - cp1->timestamp) * slope); \
} \ } \
else { \ else { \
@ -603,16 +606,16 @@ interpolate_linear_get_##type##_value_array (GstInterpolationControlSource *self
return TRUE; \ return TRUE; \
} }
DEFINE_LINEAR_GET (int); DEFINE_LINEAR_GET (int, TRUE);
DEFINE_LINEAR_GET (uint); DEFINE_LINEAR_GET (uint, TRUE);
DEFINE_LINEAR_GET (long); DEFINE_LINEAR_GET (long, TRUE);
DEFINE_LINEAR_GET (ulong); DEFINE_LINEAR_GET (ulong, TRUE);
DEFINE_LINEAR_GET (int64); DEFINE_LINEAR_GET (int64, TRUE);
DEFINE_LINEAR_GET (uint64); DEFINE_LINEAR_GET (uint64, TRUE);
DEFINE_LINEAR_GET (float); DEFINE_LINEAR_GET (float, FALSE);
DEFINE_LINEAR_GET (double); DEFINE_LINEAR_GET (double, FALSE);
static GstInterpolateMethod interpolate_linear = { static GstInterpolateMethod interpolate_linear = {
(GstControlSourceGetValue) interpolate_linear_get_int, (GstControlSourceGetValue) interpolate_linear_get_int,