From 4a99b7d3004041615365ff7027433a202727646c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 22 Jul 2007 12:18:46 +0000 Subject: [PATCH] libs/gst/controller/gstinterpolation.c: Also round to the nearest int when using cubic interpolation. Original commit message from CVS: * libs/gst/controller/gstinterpolation.c: Also round to the nearest int when using cubic interpolation. --- ChangeLog | 5 +++++ libs/gst/controller/gstinterpolation.c | 23 +++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index d208f808ae..5ae8b3c717 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-07-22 Sebastian Dröge + + * libs/gst/controller/gstinterpolation.c: + Also round to the nearest int when using cubic interpolation. + 2007-07-19 Jan Schmidt * libs/gst/controller/gstinterpolation.c: diff --git a/libs/gst/controller/gstinterpolation.c b/libs/gst/controller/gstinterpolation.c index 4a7c4bc083..3354eb6db8 100644 --- a/libs/gst/controller/gstinterpolation.c +++ b/libs/gst/controller/gstinterpolation.c @@ -659,7 +659,7 @@ static GstInterpolateMethod interpolate_linear = { * . . . . . */ -#define DEFINE_CUBIC_GET(type) \ +#define DEFINE_CUBIC_GET(type,round) \ static void \ _interpolate_cubic_update_cache_##type (GstInterpolationControlSource *self) \ { \ @@ -775,7 +775,10 @@ _interpolate_cubic_get_##type (GstInterpolationControlSource *self, GstClockTime out += (value2 / cp1->cache.cubic.h - cp1->cache.cubic.h * cp2->cache.cubic.z) * diff1; \ out += (value1 / cp1->cache.cubic.h - cp1->cache.cubic.h * cp1->cache.cubic.z) * diff2; \ \ - *ret = (g##type) out; \ + if (round) \ + *ret = (g##type) (out + 0.5); \ + else \ + *ret = (g##type) out; \ } \ else { \ *ret = g_value_get_##type (&cp1->value); \ @@ -825,16 +828,16 @@ interpolate_cubic_get_##type##_value_array (GstInterpolationControlSource *self, return TRUE; \ } -DEFINE_CUBIC_GET (int); +DEFINE_CUBIC_GET (int, TRUE); -DEFINE_CUBIC_GET (uint); -DEFINE_CUBIC_GET (long); +DEFINE_CUBIC_GET (uint, TRUE); +DEFINE_CUBIC_GET (long, TRUE); -DEFINE_CUBIC_GET (ulong); -DEFINE_CUBIC_GET (int64); -DEFINE_CUBIC_GET (uint64); -DEFINE_CUBIC_GET (float); -DEFINE_CUBIC_GET (double); +DEFINE_CUBIC_GET (ulong, TRUE); +DEFINE_CUBIC_GET (int64, TRUE); +DEFINE_CUBIC_GET (uint64, TRUE); +DEFINE_CUBIC_GET (float, FALSE); +DEFINE_CUBIC_GET (double, FALSE); static GstInterpolateMethod interpolate_cubic = { (GstControlSourceGetValue) interpolate_cubic_get_int,