+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:
/* 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) \
{ \
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); \
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,