summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Baker <steve@stevebaker.org>2001-09-17 19:14:35 +0000
committerSteve Baker <steve@stevebaker.org>2001-09-17 19:14:35 +0000
commit312e46a540589f77b978632e2434526ad0b9e6b1 (patch)
tree8b70bded387714e414099e6a8ef0c35afda25616
parent59a47966f1db8caa17ecfc5be09af1938f4fa7f6 (diff)
downloadgstreamer-312e46a540589f77b978632e2434526ad0b9e6b1.tar.gz
smooth dparam now does log smooths when it is a log param (like frequency)
Original commit message from CVS: smooth dparam now does log smooths when it is a log param (like frequency)
-rw-r--r--gst/gstdparam.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/gst/gstdparam.c b/gst/gstdparam.c
index 824582c6f0..6b35692181 100644
--- a/gst/gstdparam.c
+++ b/gst/gstdparam.c
@@ -19,6 +19,8 @@
* Boston, MA 02111-1307, USA.
*/
+#include <math.h>
+
#include "gst_private.h"
#include "gstdparam.h"
@@ -316,22 +318,36 @@ gst_dparam_do_update_smooth (GstDParam *dparam, gint64 timestamp)
switch (G_VALUE_TYPE(GST_DPARAM_VALUE(dparam))){
case G_TYPE_FLOAT: {
- gfloat target = g_value_get_float(dparam->point[0]);
- gfloat current = g_value_get_float(GST_DPARAM_VALUE(dparam));
- gfloat max_change = time_ratio * g_value_get_float(dparam->point[1]);
+ gfloat current, target, max_change, current_diff, final_val;
- GST_DEBUG(GST_CAT_PARAMS, "target:%f current:%f max_change:%f \n",
- target, current, max_change);
+ target = g_value_get_float(dparam->point[0]);
+ current = g_value_get_float(GST_DPARAM_VALUE(dparam));
+ max_change = time_ratio * g_value_get_float(dparam->point[1]);
- if (ABS (current - target) < max_change){
- GST_DPARAM_READY_FOR_UPDATE(dparam) = FALSE;
- current = target;
- }
+ GST_DEBUG(GST_CAT_PARAMS, "target:%f current:%f max_change:%f \n",
+ target, current, max_change);
+
+ if (dparam->spec->is_log){
+ gfloat current_log;
+ current_log = log(current);
+ current_diff = ABS(current_log - log(target));
+ if (current_diff > max_change)
+ final_val = (target < current) ? exp(current_log-max_change) : exp(current_log+max_change);
+ else
+ final_val = target;
+ }
else {
- current += (target < current) ? -max_change : max_change;
+ current_diff = ABS (current - target);
+ if (current_diff > max_change)
+ final_val = (target < current) ? current-max_change : current+max_change;
+ else
+ final_val = target;
}
- g_value_set_float(GST_DPARAM_VALUE(dparam), current);
+ GST_DPARAM_READY_FOR_UPDATE(dparam) = (current_diff > max_change);
+ g_value_set_float(GST_DPARAM_VALUE(dparam), final_val);
+
+ break;
}
default:
break;