From: Jan Schmidt Date: Sat, 21 Jul 2007 21:20:37 +0000 (+0000) Subject: libs/gst/controller/gstinterpolation.c: When linearly interpolating integer types... X-Git-Tag: RELEASE-0_10_14~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a6df9f4bac0f641375834da020b78a7f89320023;p=platform%2Fupstream%2Fgstreamer.git 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. --- diff --git a/ChangeLog b/ChangeLog index a6c0898..d208f80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-07-19 Jan Schmidt + + * 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 * tools/gst-plot-timeline.py: diff --git a/libs/gst/controller/gstinterpolation.c b/libs/gst/controller/gstinterpolation.c index 4a74e6b..4a7c4bc 100644 --- a/libs/gst/controller/gstinterpolation.c +++ b/libs/gst/controller/gstinterpolation.c @@ -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,