2005-08-05 12:59:46 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* Copyright (C) <2005> Stefan Kost <ensonic at users dot sf dot net>
|
2007-06-06 14:01:56 +00:00
|
|
|
* Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
|
2005-08-05 12:59:46 +00:00
|
|
|
*
|
2005-09-09 13:26:54 +00:00
|
|
|
* gstinterpolation.c: Interpolation methods for dynamic properties
|
2005-08-05 12:59:46 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
2005-08-02 21:35:34 +00:00
|
|
|
*/
|
|
|
|
|
2005-12-01 09:23:20 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2006-01-13 14:21:48 +00:00
|
|
|
#include "gstcontrollerprivate.h"
|
2005-09-09 13:26:54 +00:00
|
|
|
#include "gstcontroller.h"
|
2005-08-02 21:35:34 +00:00
|
|
|
|
|
|
|
#define GST_CAT_DEFAULT gst_controller_debug
|
|
|
|
GST_DEBUG_CATEGORY_EXTERN (GST_CAT_DEFAULT);
|
|
|
|
|
2005-09-09 13:26:54 +00:00
|
|
|
/* common helper */
|
2005-08-02 21:35:34 +00:00
|
|
|
|
|
|
|
/*
|
libs/gst/controller/: Add a new private GstControlPoint struct which "inherits" from
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
(gst_control_point_find), (gst_controlled_property_new),
(gst_control_point_free), (gst_controlled_property_free),
(gst_controller_set), (gst_controller_set_from_list),
(gst_controller_unset), (gst_controller_unset_all),
(gst_controller_sync_values):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node),
(interpolate_none_get), (interpolate_trigger_get):
Add a new private GstControlPoint struct which "inherits" from
GstTimedValue to allow different interpolators to store internal
values next to each control point. From the outside everything is
still a GstControlPoint so we don't loose binary compatibility.
Also fixup all the GValue handling to not leak GValues or list nodes.
* tests/check/libs/controller.c: (GST_START_TEST):
Free the list nodes and GValues in the controller_misc test.
2007-05-17 17:05:36 +00:00
|
|
|
* gst_controlled_property_find_control_point_node:
|
2005-08-02 21:35:34 +00:00
|
|
|
* @prop: the controlled property to search in
|
|
|
|
* @timestamp: the search key
|
|
|
|
*
|
libs/gst/controller/: Add a new private GstControlPoint struct which "inherits" from
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
(gst_control_point_find), (gst_controlled_property_new),
(gst_control_point_free), (gst_controlled_property_free),
(gst_controller_set), (gst_controller_set_from_list),
(gst_controller_unset), (gst_controller_unset_all),
(gst_controller_sync_values):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node),
(interpolate_none_get), (interpolate_trigger_get):
Add a new private GstControlPoint struct which "inherits" from
GstTimedValue to allow different interpolators to store internal
values next to each control point. From the outside everything is
still a GstControlPoint so we don't loose binary compatibility.
Also fixup all the GValue handling to not leak GValues or list nodes.
* tests/check/libs/controller.c: (GST_START_TEST):
Free the list nodes and GValues in the controller_misc test.
2007-05-17 17:05:36 +00:00
|
|
|
* Find last value before given timestamp in control point list.
|
2005-08-02 21:35:34 +00:00
|
|
|
*
|
|
|
|
* Returns: the found #GList node or %NULL
|
|
|
|
*/
|
|
|
|
GList *
|
libs/gst/controller/: Add a new private GstControlPoint struct which "inherits" from
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
(gst_control_point_find), (gst_controlled_property_new),
(gst_control_point_free), (gst_controlled_property_free),
(gst_controller_set), (gst_controller_set_from_list),
(gst_controller_unset), (gst_controller_unset_all),
(gst_controller_sync_values):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node),
(interpolate_none_get), (interpolate_trigger_get):
Add a new private GstControlPoint struct which "inherits" from
GstTimedValue to allow different interpolators to store internal
values next to each control point. From the outside everything is
still a GstControlPoint so we don't loose binary compatibility.
Also fixup all the GValue handling to not leak GValues or list nodes.
* tests/check/libs/controller.c: (GST_START_TEST):
Free the list nodes and GValues in the controller_misc test.
2007-05-17 17:05:36 +00:00
|
|
|
gst_controlled_property_find_control_point_node (GstControlledProperty * prop,
|
2005-08-02 21:35:34 +00:00
|
|
|
GstClockTime timestamp)
|
|
|
|
{
|
|
|
|
GList *prev_node = g_list_last (prop->values);
|
|
|
|
GList *node;
|
libs/gst/controller/: Add a new private GstControlPoint struct which "inherits" from
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
(gst_control_point_find), (gst_controlled_property_new),
(gst_control_point_free), (gst_controlled_property_free),
(gst_controller_set), (gst_controller_set_from_list),
(gst_controller_unset), (gst_controller_unset_all),
(gst_controller_sync_values):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node),
(interpolate_none_get), (interpolate_trigger_get):
Add a new private GstControlPoint struct which "inherits" from
GstTimedValue to allow different interpolators to store internal
values next to each control point. From the outside everything is
still a GstControlPoint so we don't loose binary compatibility.
Also fixup all the GValue handling to not leak GValues or list nodes.
* tests/check/libs/controller.c: (GST_START_TEST):
Free the list nodes and GValues in the controller_misc test.
2007-05-17 17:05:36 +00:00
|
|
|
GstControlPoint *cp;
|
2005-08-02 21:35:34 +00:00
|
|
|
|
2007-05-17 17:16:09 +00:00
|
|
|
node = prop->values;
|
|
|
|
if (prop->last_requested_value) {
|
|
|
|
GstControlPoint *last_cp = prop->last_requested_value->data;
|
|
|
|
|
|
|
|
if (timestamp > last_cp->timestamp)
|
|
|
|
node = prop->last_requested_value;
|
|
|
|
}
|
2005-08-02 21:35:34 +00:00
|
|
|
|
|
|
|
/* iterate over timed value list */
|
2007-05-17 17:16:09 +00:00
|
|
|
for (; node; node = g_list_next (node)) {
|
libs/gst/controller/: Add a new private GstControlPoint struct which "inherits" from
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
(gst_control_point_find), (gst_controlled_property_new),
(gst_control_point_free), (gst_controlled_property_free),
(gst_controller_set), (gst_controller_set_from_list),
(gst_controller_unset), (gst_controller_unset_all),
(gst_controller_sync_values):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node),
(interpolate_none_get), (interpolate_trigger_get):
Add a new private GstControlPoint struct which "inherits" from
GstTimedValue to allow different interpolators to store internal
values next to each control point. From the outside everything is
still a GstControlPoint so we don't loose binary compatibility.
Also fixup all the GValue handling to not leak GValues or list nodes.
* tests/check/libs/controller.c: (GST_START_TEST):
Free the list nodes and GValues in the controller_misc test.
2007-05-17 17:05:36 +00:00
|
|
|
cp = node->data;
|
2005-08-02 21:35:34 +00:00
|
|
|
/* this timestamp is newer that the one we look for */
|
libs/gst/controller/: Add a new private GstControlPoint struct which "inherits" from
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
(gst_control_point_find), (gst_controlled_property_new),
(gst_control_point_free), (gst_controlled_property_free),
(gst_controller_set), (gst_controller_set_from_list),
(gst_controller_unset), (gst_controller_unset_all),
(gst_controller_sync_values):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node),
(interpolate_none_get), (interpolate_trigger_get):
Add a new private GstControlPoint struct which "inherits" from
GstTimedValue to allow different interpolators to store internal
values next to each control point. From the outside everything is
still a GstControlPoint so we don't loose binary compatibility.
Also fixup all the GValue handling to not leak GValues or list nodes.
* tests/check/libs/controller.c: (GST_START_TEST):
Free the list nodes and GValues in the controller_misc test.
2007-05-17 17:05:36 +00:00
|
|
|
if (timestamp < cp->timestamp) {
|
2005-08-02 21:35:34 +00:00
|
|
|
/* get previous one again */
|
|
|
|
prev_node = g_list_previous (node);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-05-17 17:16:09 +00:00
|
|
|
|
|
|
|
if (prev_node)
|
|
|
|
prop->last_requested_value = prev_node;
|
|
|
|
|
2007-06-09 16:58:30 +00:00
|
|
|
return prev_node;
|
2005-08-02 21:35:34 +00:00
|
|
|
}
|
|
|
|
|
gst/gstinfo.c: don't do dummy g_strdup()s
Original commit message from CVS:
* gst/gstinfo.c: (gst_debug_log_default):
don't do dummy g_strdup()s
* libs/gst/controller/gstcontroller.c:
(on_object_controlled_property_changed),
(gst_controlled_property_new), (gst_controller_new_valist),
(gst_controller_new_list),
(gst_controller_remove_properties_valist), (gst_controller_set),
(gst_controller_get), (gst_controller_sync_values),
(gst_controller_get_value_array), (_gst_controller_class_init),
(gst_controller_get_type):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_timed_value_node):
convert // to /**/ comments
2005-09-28 17:30:13 +00:00
|
|
|
/* steps-like (no-)interpolation, default */
|
|
|
|
/* just returns the value for the most recent key-frame */
|
2005-08-02 21:35:34 +00:00
|
|
|
|
|
|
|
static GValue *
|
|
|
|
interpolate_none_get (GstControlledProperty * prop, GstClockTime timestamp)
|
|
|
|
{
|
|
|
|
GList *node;
|
|
|
|
|
libs/gst/controller/: Add a new private GstControlPoint struct which "inherits" from
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
(gst_control_point_find), (gst_controlled_property_new),
(gst_control_point_free), (gst_controlled_property_free),
(gst_controller_set), (gst_controller_set_from_list),
(gst_controller_unset), (gst_controller_unset_all),
(gst_controller_sync_values):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node),
(interpolate_none_get), (interpolate_trigger_get):
Add a new private GstControlPoint struct which "inherits" from
GstTimedValue to allow different interpolators to store internal
values next to each control point. From the outside everything is
still a GstControlPoint so we don't loose binary compatibility.
Also fixup all the GValue handling to not leak GValues or list nodes.
* tests/check/libs/controller.c: (GST_START_TEST):
Free the list nodes and GValues in the controller_misc test.
2007-05-17 17:05:36 +00:00
|
|
|
if ((node =
|
|
|
|
gst_controlled_property_find_control_point_node (prop, timestamp))) {
|
|
|
|
GstControlPoint *cp = node->data;
|
2005-08-02 21:35:34 +00:00
|
|
|
|
2007-06-09 16:58:30 +00:00
|
|
|
return &cp->value;
|
2005-08-02 21:35:34 +00:00
|
|
|
}
|
2007-06-09 16:58:30 +00:00
|
|
|
return &prop->default_value;
|
2005-08-02 21:35:34 +00:00
|
|
|
}
|
|
|
|
|
2007-06-09 16:58:30 +00:00
|
|
|
#define interpolate_none_get_boolean interpolate_none_get
|
|
|
|
|
2005-08-02 21:35:34 +00:00
|
|
|
#define DEFINE_NONE_GET(type) \
|
2007-06-09 16:58:30 +00:00
|
|
|
static GValue * \
|
|
|
|
interpolate_none_get_##type (GstControlledProperty * prop, GstClockTime timestamp) \
|
|
|
|
{ \
|
|
|
|
GList *node; \
|
|
|
|
\
|
|
|
|
if ((node = \
|
|
|
|
gst_controlled_property_find_control_point_node (prop, timestamp))) { \
|
|
|
|
GstControlPoint *cp = node->data; \
|
|
|
|
g##type ret = g_value_get_##type (&cp->value); \
|
|
|
|
if (g_value_get_##type (&prop->min_value) > ret) \
|
|
|
|
return &prop->min_value; \
|
|
|
|
else if (g_value_get_##type (&prop->max_value) < ret) \
|
|
|
|
return &prop->max_value; \
|
|
|
|
return &cp->value; \
|
|
|
|
} \
|
|
|
|
return &prop->default_value; \
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_NONE_GET (int);
|
|
|
|
DEFINE_NONE_GET (uint);
|
|
|
|
DEFINE_NONE_GET (long);
|
|
|
|
|
|
|
|
DEFINE_NONE_GET (ulong);
|
|
|
|
DEFINE_NONE_GET (float);
|
|
|
|
DEFINE_NONE_GET (double);
|
|
|
|
|
|
|
|
#define DEFINE_NONE_GET_VALUE_ARRAY(type) \
|
2005-08-02 21:35:34 +00:00
|
|
|
static gboolean \
|
|
|
|
interpolate_none_get_##type##_value_array (GstControlledProperty * prop, \
|
|
|
|
GstClockTime timestamp, GstValueArray * value_array) \
|
|
|
|
{ \
|
|
|
|
gint i; \
|
2005-12-01 09:54:56 +00:00
|
|
|
GstClockTime ts = timestamp; \
|
|
|
|
g##type *values = (g##type *) value_array->values; \
|
2005-08-02 21:35:34 +00:00
|
|
|
\
|
2005-12-01 09:54:56 +00:00
|
|
|
for(i = 0; i < value_array->nbsamples; i++) { \
|
2007-06-09 16:58:30 +00:00
|
|
|
*values = g_value_get_##type (interpolate_none_get_##type (prop,ts)); \
|
2005-12-01 09:54:56 +00:00
|
|
|
ts += value_array->sample_interval; \
|
2005-08-02 21:35:34 +00:00
|
|
|
values++; \
|
|
|
|
} \
|
2007-06-09 16:58:30 +00:00
|
|
|
return TRUE; \
|
2005-08-02 21:35:34 +00:00
|
|
|
}
|
|
|
|
|
2007-06-09 16:58:30 +00:00
|
|
|
DEFINE_NONE_GET_VALUE_ARRAY (int);
|
2005-08-02 21:35:34 +00:00
|
|
|
|
2007-06-09 16:58:30 +00:00
|
|
|
DEFINE_NONE_GET_VALUE_ARRAY (uint);
|
|
|
|
DEFINE_NONE_GET_VALUE_ARRAY (long);
|
|
|
|
|
|
|
|
DEFINE_NONE_GET_VALUE_ARRAY (ulong);
|
|
|
|
DEFINE_NONE_GET_VALUE_ARRAY (float);
|
|
|
|
DEFINE_NONE_GET_VALUE_ARRAY (double);
|
2005-12-01 09:54:56 +00:00
|
|
|
|
2007-06-09 16:58:30 +00:00
|
|
|
DEFINE_NONE_GET_VALUE_ARRAY (boolean);
|
2005-12-01 09:54:56 +00:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
interpolate_none_get_enum_value_array (GstControlledProperty * prop,
|
2005-11-27 22:43:08 +00:00
|
|
|
GstClockTime timestamp, GstValueArray * value_array)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GstClockTime ts = timestamp;
|
|
|
|
gint *values = (gint *) value_array->values;
|
|
|
|
|
|
|
|
for (i = 0; i < value_array->nbsamples; i++) {
|
|
|
|
*values = g_value_get_enum (interpolate_none_get (prop, ts));
|
|
|
|
ts += value_array->sample_interval;
|
|
|
|
values++;
|
|
|
|
}
|
2007-06-09 16:58:30 +00:00
|
|
|
return TRUE;
|
2005-11-27 22:43:08 +00:00
|
|
|
}
|
|
|
|
|
2006-01-12 21:55:42 +00:00
|
|
|
static gboolean
|
|
|
|
interpolate_none_get_string_value_array (GstControlledProperty * prop,
|
|
|
|
GstClockTime timestamp, GstValueArray * value_array)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GstClockTime ts = timestamp;
|
|
|
|
gchar **values = (gchar **) value_array->values;
|
|
|
|
|
|
|
|
for (i = 0; i < value_array->nbsamples; i++) {
|
|
|
|
*values = (gchar *) g_value_get_string (interpolate_none_get (prop, ts));
|
|
|
|
ts += value_array->sample_interval;
|
|
|
|
values++;
|
|
|
|
}
|
2007-06-09 16:58:30 +00:00
|
|
|
return TRUE;
|
2006-01-12 21:55:42 +00:00
|
|
|
}
|
2005-11-27 22:43:08 +00:00
|
|
|
|
|
|
|
static GstInterpolateMethod interpolate_none = {
|
|
|
|
interpolate_none_get,
|
|
|
|
interpolate_none_get_int_value_array,
|
|
|
|
interpolate_none_get,
|
|
|
|
interpolate_none_get_uint_value_array,
|
|
|
|
interpolate_none_get,
|
|
|
|
interpolate_none_get_long_value_array,
|
|
|
|
interpolate_none_get,
|
|
|
|
interpolate_none_get_ulong_value_array,
|
|
|
|
interpolate_none_get,
|
|
|
|
interpolate_none_get_float_value_array,
|
|
|
|
interpolate_none_get,
|
|
|
|
interpolate_none_get_double_value_array,
|
|
|
|
interpolate_none_get,
|
|
|
|
interpolate_none_get_boolean_value_array,
|
|
|
|
interpolate_none_get,
|
2006-01-12 21:55:42 +00:00
|
|
|
interpolate_none_get_enum_value_array,
|
|
|
|
interpolate_none_get,
|
|
|
|
interpolate_none_get_string_value_array
|
2005-11-27 22:43:08 +00:00
|
|
|
};
|
2005-08-02 21:35:34 +00:00
|
|
|
|
gst/gstinfo.c: don't do dummy g_strdup()s
Original commit message from CVS:
* gst/gstinfo.c: (gst_debug_log_default):
don't do dummy g_strdup()s
* libs/gst/controller/gstcontroller.c:
(on_object_controlled_property_changed),
(gst_controlled_property_new), (gst_controller_new_valist),
(gst_controller_new_list),
(gst_controller_remove_properties_valist), (gst_controller_set),
(gst_controller_get), (gst_controller_sync_values),
(gst_controller_get_value_array), (_gst_controller_class_init),
(gst_controller_get_type):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_timed_value_node):
convert // to /**/ comments
2005-09-28 17:30:13 +00:00
|
|
|
/* returns the default value of the property, except for times with specific values */
|
|
|
|
/* needed for one-shot events, such as notes and triggers */
|
2005-08-02 21:35:34 +00:00
|
|
|
|
|
|
|
static GValue *
|
|
|
|
interpolate_trigger_get (GstControlledProperty * prop, GstClockTime timestamp)
|
|
|
|
{
|
|
|
|
GList *node;
|
libs/gst/controller/: Add a new private GstControlPoint struct which "inherits" from
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
(gst_control_point_find), (gst_controlled_property_new),
(gst_control_point_free), (gst_controlled_property_free),
(gst_controller_set), (gst_controller_set_from_list),
(gst_controller_unset), (gst_controller_unset_all),
(gst_controller_sync_values):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node),
(interpolate_none_get), (interpolate_trigger_get):
Add a new private GstControlPoint struct which "inherits" from
GstTimedValue to allow different interpolators to store internal
values next to each control point. From the outside everything is
still a GstControlPoint so we don't loose binary compatibility.
Also fixup all the GValue handling to not leak GValues or list nodes.
* tests/check/libs/controller.c: (GST_START_TEST):
Free the list nodes and GValues in the controller_misc test.
2007-05-17 17:05:36 +00:00
|
|
|
GstControlPoint *cp;
|
2005-08-02 21:35:34 +00:00
|
|
|
|
|
|
|
/* check if there is a value at the registered timestamp */
|
2007-06-09 16:58:30 +00:00
|
|
|
if ((node =
|
|
|
|
gst_controlled_property_find_control_point_node (prop, timestamp))) {
|
libs/gst/controller/: Add a new private GstControlPoint struct which "inherits" from
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
(gst_control_point_find), (gst_controlled_property_new),
(gst_control_point_free), (gst_controlled_property_free),
(gst_controller_set), (gst_controller_set_from_list),
(gst_controller_unset), (gst_controller_unset_all),
(gst_controller_sync_values):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node),
(interpolate_none_get), (interpolate_trigger_get):
Add a new private GstControlPoint struct which "inherits" from
GstTimedValue to allow different interpolators to store internal
values next to each control point. From the outside everything is
still a GstControlPoint so we don't loose binary compatibility.
Also fixup all the GValue handling to not leak GValues or list nodes.
* tests/check/libs/controller.c: (GST_START_TEST):
Free the list nodes and GValues in the controller_misc test.
2007-05-17 17:05:36 +00:00
|
|
|
cp = node->data;
|
|
|
|
if (timestamp == cp->timestamp) {
|
2007-06-09 16:58:30 +00:00
|
|
|
return &cp->value;
|
2005-08-02 21:35:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-09 16:58:30 +00:00
|
|
|
return &prop->default_value;
|
2005-08-02 21:35:34 +00:00
|
|
|
}
|
|
|
|
|
2007-06-09 16:58:30 +00:00
|
|
|
#define interpolate_trigger_get_boolean interpolate_trigger_get
|
|
|
|
|
2007-05-21 21:48:07 +00:00
|
|
|
#define DEFINE_TRIGGER_GET(type) \
|
2007-06-09 16:58:30 +00:00
|
|
|
static GValue * \
|
|
|
|
interpolate_trigger_get_##type (GstControlledProperty * prop, GstClockTime timestamp) \
|
|
|
|
{ \
|
|
|
|
GList *node; \
|
|
|
|
GstControlPoint *cp; \
|
|
|
|
\
|
|
|
|
/* check if there is a value at the registered timestamp */ \
|
|
|
|
if ((node = \
|
|
|
|
gst_controlled_property_find_control_point_node (prop, timestamp))) { \
|
|
|
|
cp = node->data; \
|
|
|
|
if (timestamp == cp->timestamp) { \
|
|
|
|
g##type ret = g_value_get_##type (&cp->value); \
|
|
|
|
if (g_value_get_##type (&prop->min_value) > ret) \
|
|
|
|
return &prop->min_value; \
|
|
|
|
else if (g_value_get_##type (&prop->max_value) < ret) \
|
|
|
|
return &prop->max_value; \
|
|
|
|
return &cp->value; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
return &prop->default_value; \
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_TRIGGER_GET (int);
|
|
|
|
DEFINE_TRIGGER_GET (uint);
|
|
|
|
DEFINE_TRIGGER_GET (long);
|
|
|
|
|
|
|
|
DEFINE_TRIGGER_GET (ulong);
|
|
|
|
DEFINE_TRIGGER_GET (float);
|
|
|
|
DEFINE_TRIGGER_GET (double);
|
|
|
|
|
|
|
|
#define DEFINE_TRIGGER_GET_VALUE_ARRAY(type) \
|
2007-05-21 21:48:07 +00:00
|
|
|
static gboolean \
|
|
|
|
interpolate_trigger_get_##type##_value_array (GstControlledProperty * prop, \
|
|
|
|
GstClockTime timestamp, GstValueArray * value_array) \
|
|
|
|
{ \
|
|
|
|
gint i; \
|
|
|
|
GstClockTime ts = timestamp; \
|
|
|
|
g##type *values = (g##type *) value_array->values; \
|
|
|
|
\
|
|
|
|
for(i = 0; i < value_array->nbsamples; i++) { \
|
2007-06-09 16:58:30 +00:00
|
|
|
*values = g_value_get_##type (interpolate_trigger_get_##type (prop,ts)); \
|
2007-05-21 21:48:07 +00:00
|
|
|
ts += value_array->sample_interval; \
|
|
|
|
values++; \
|
|
|
|
} \
|
2007-06-09 16:58:30 +00:00
|
|
|
return TRUE; \
|
2007-05-21 21:48:07 +00:00
|
|
|
}
|
|
|
|
|
2007-06-09 16:58:30 +00:00
|
|
|
DEFINE_TRIGGER_GET_VALUE_ARRAY (int);
|
2007-05-21 21:48:07 +00:00
|
|
|
|
2007-06-09 16:58:30 +00:00
|
|
|
DEFINE_TRIGGER_GET_VALUE_ARRAY (uint);
|
|
|
|
DEFINE_TRIGGER_GET_VALUE_ARRAY (long);
|
|
|
|
|
|
|
|
DEFINE_TRIGGER_GET_VALUE_ARRAY (ulong);
|
|
|
|
DEFINE_TRIGGER_GET_VALUE_ARRAY (float);
|
|
|
|
DEFINE_TRIGGER_GET_VALUE_ARRAY (double);
|
2007-05-21 21:48:07 +00:00
|
|
|
|
2007-06-09 16:58:30 +00:00
|
|
|
DEFINE_TRIGGER_GET_VALUE_ARRAY (boolean);
|
2007-05-21 21:48:07 +00:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
interpolate_trigger_get_enum_value_array (GstControlledProperty * prop,
|
|
|
|
GstClockTime timestamp, GstValueArray * value_array)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
GstClockTime ts = timestamp;
|
|
|
|
gint *values = (gint *) value_array->values;
|
|
|
|
|
|
|
|
for (i = 0; i < value_array->nbsamples; i++) {
|
|
|
|
*values = g_value_get_enum (interpolate_trigger_get (prop, ts));
|
|
|
|
ts += value_array->sample_interval;
|
|
|
|
values++;
|
|
|
|
}
|
2007-06-09 16:58:30 +00:00
|
|
|
return TRUE;
|
2007-05-21 21:48:07 +00:00
|
|
|
}
|
|
|
|
|
2005-08-02 21:35:34 +00:00
|
|
|
static gboolean
|
2007-05-21 21:48:07 +00:00
|
|
|
interpolate_trigger_get_string_value_array (GstControlledProperty * prop,
|
2005-08-02 21:35:34 +00:00
|
|
|
GstClockTime timestamp, GstValueArray * value_array)
|
|
|
|
{
|
2007-05-21 21:48:07 +00:00
|
|
|
gint i;
|
|
|
|
GstClockTime ts = timestamp;
|
|
|
|
gchar **values = (gchar **) value_array->values;
|
|
|
|
|
|
|
|
for (i = 0; i < value_array->nbsamples; i++) {
|
|
|
|
*values = (gchar *) g_value_get_string (interpolate_trigger_get (prop, ts));
|
|
|
|
ts += value_array->sample_interval;
|
|
|
|
values++;
|
|
|
|
}
|
2007-06-09 16:58:30 +00:00
|
|
|
return TRUE;
|
2005-08-02 21:35:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstInterpolateMethod interpolate_trigger = {
|
|
|
|
interpolate_trigger_get,
|
2007-05-21 21:48:07 +00:00
|
|
|
interpolate_trigger_get_int_value_array,
|
2005-08-02 21:35:34 +00:00
|
|
|
interpolate_trigger_get,
|
2007-05-21 21:48:07 +00:00
|
|
|
interpolate_trigger_get_uint_value_array,
|
2005-08-02 21:35:34 +00:00
|
|
|
interpolate_trigger_get,
|
2007-05-21 21:48:07 +00:00
|
|
|
interpolate_trigger_get_long_value_array,
|
2005-08-02 21:35:34 +00:00
|
|
|
interpolate_trigger_get,
|
2007-05-21 21:48:07 +00:00
|
|
|
interpolate_trigger_get_ulong_value_array,
|
2005-08-31 10:00:08 +00:00
|
|
|
interpolate_trigger_get,
|
2007-05-21 21:48:07 +00:00
|
|
|
interpolate_trigger_get_float_value_array,
|
2005-10-17 17:05:38 +00:00
|
|
|
interpolate_trigger_get,
|
2007-05-21 21:48:07 +00:00
|
|
|
interpolate_trigger_get_double_value_array,
|
2005-10-17 17:05:38 +00:00
|
|
|
interpolate_trigger_get,
|
2007-05-21 21:48:07 +00:00
|
|
|
interpolate_trigger_get_boolean_value_array,
|
2005-11-27 22:43:08 +00:00
|
|
|
interpolate_trigger_get,
|
2007-05-21 21:48:07 +00:00
|
|
|
interpolate_trigger_get_enum_value_array,
|
2006-01-12 21:55:42 +00:00
|
|
|
interpolate_trigger_get,
|
2007-05-21 21:48:07 +00:00
|
|
|
interpolate_trigger_get_string_value_array
|
2005-08-02 21:35:34 +00:00
|
|
|
};
|
|
|
|
|
gst/gstinfo.c: don't do dummy g_strdup()s
Original commit message from CVS:
* gst/gstinfo.c: (gst_debug_log_default):
don't do dummy g_strdup()s
* libs/gst/controller/gstcontroller.c:
(on_object_controlled_property_changed),
(gst_controlled_property_new), (gst_controller_new_valist),
(gst_controller_new_list),
(gst_controller_remove_properties_valist), (gst_controller_set),
(gst_controller_get), (gst_controller_sync_values),
(gst_controller_get_value_array), (_gst_controller_class_init),
(gst_controller_get_type):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_timed_value_node):
convert // to /**/ comments
2005-09-28 17:30:13 +00:00
|
|
|
/* linear interpolation */
|
|
|
|
/* smoothes inbetween values */
|
2005-08-02 21:35:34 +00:00
|
|
|
|
|
|
|
#define DEFINE_LINEAR_GET(type) \
|
|
|
|
static g##type \
|
|
|
|
_interpolate_linear_get_##type (GstControlledProperty * prop, GstClockTime timestamp) \
|
|
|
|
{ \
|
|
|
|
GList *node; \
|
2007-06-09 16:58:30 +00:00
|
|
|
g##type ret; \
|
2005-08-02 21:35:34 +00:00
|
|
|
\
|
libs/gst/controller/: Add a new private GstControlPoint struct which "inherits" from
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
(gst_control_point_find), (gst_controlled_property_new),
(gst_control_point_free), (gst_controlled_property_free),
(gst_controller_set), (gst_controller_set_from_list),
(gst_controller_unset), (gst_controller_unset_all),
(gst_controller_sync_values):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node),
(interpolate_none_get), (interpolate_trigger_get):
Add a new private GstControlPoint struct which "inherits" from
GstTimedValue to allow different interpolators to store internal
values next to each control point. From the outside everything is
still a GstControlPoint so we don't loose binary compatibility.
Also fixup all the GValue handling to not leak GValues or list nodes.
* tests/check/libs/controller.c: (GST_START_TEST):
Free the list nodes and GValues in the controller_misc test.
2007-05-17 17:05:36 +00:00
|
|
|
if ((node = gst_controlled_property_find_control_point_node (prop, timestamp))) { \
|
|
|
|
GstControlPoint *cp1, *cp2; \
|
2005-08-02 21:35:34 +00:00
|
|
|
\
|
libs/gst/controller/: Add a new private GstControlPoint struct which "inherits" from
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
(gst_control_point_find), (gst_controlled_property_new),
(gst_control_point_free), (gst_controlled_property_free),
(gst_controller_set), (gst_controller_set_from_list),
(gst_controller_unset), (gst_controller_unset_all),
(gst_controller_sync_values):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node),
(interpolate_none_get), (interpolate_trigger_get):
Add a new private GstControlPoint struct which "inherits" from
GstTimedValue to allow different interpolators to store internal
values next to each control point. From the outside everything is
still a GstControlPoint so we don't loose binary compatibility.
Also fixup all the GValue handling to not leak GValues or list nodes.
* tests/check/libs/controller.c: (GST_START_TEST):
Free the list nodes and GValues in the controller_misc test.
2007-05-17 17:05:36 +00:00
|
|
|
cp1 = node->data; \
|
2005-08-02 21:35:34 +00:00
|
|
|
if ((node = g_list_next (node))) { \
|
2007-06-06 14:01:56 +00:00
|
|
|
gdouble slope; \
|
2005-08-02 21:35:34 +00:00
|
|
|
g##type value1,value2; \
|
|
|
|
\
|
libs/gst/controller/: Add a new private GstControlPoint struct which "inherits" from
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
(gst_control_point_find), (gst_controlled_property_new),
(gst_control_point_free), (gst_controlled_property_free),
(gst_controller_set), (gst_controller_set_from_list),
(gst_controller_unset), (gst_controller_unset_all),
(gst_controller_sync_values):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node),
(interpolate_none_get), (interpolate_trigger_get):
Add a new private GstControlPoint struct which "inherits" from
GstTimedValue to allow different interpolators to store internal
values next to each control point. From the outside everything is
still a GstControlPoint so we don't loose binary compatibility.
Also fixup all the GValue handling to not leak GValues or list nodes.
* tests/check/libs/controller.c: (GST_START_TEST):
Free the list nodes and GValues in the controller_misc test.
2007-05-17 17:05:36 +00:00
|
|
|
cp2 = node->data; \
|
2005-08-02 21:35:34 +00:00
|
|
|
\
|
libs/gst/controller/: Add a new private GstControlPoint struct which "inherits" from
Original commit message from CVS:
reviewed by: Stefan Kost <ensonic@users.sf.net>
* libs/gst/controller/gstcontroller.c: (gst_control_point_compare),
(gst_control_point_find), (gst_controlled_property_new),
(gst_control_point_free), (gst_controlled_property_free),
(gst_controller_set), (gst_controller_set_from_list),
(gst_controller_unset), (gst_controller_unset_all),
(gst_controller_sync_values):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstcontrollerprivate.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_control_point_node),
(interpolate_none_get), (interpolate_trigger_get):
Add a new private GstControlPoint struct which "inherits" from
GstTimedValue to allow different interpolators to store internal
values next to each control point. From the outside everything is
still a GstControlPoint so we don't loose binary compatibility.
Also fixup all the GValue handling to not leak GValues or list nodes.
* tests/check/libs/controller.c: (GST_START_TEST):
Free the list nodes and GValues in the controller_misc test.
2007-05-17 17:05:36 +00:00
|
|
|
value1 = g_value_get_##type (&cp1->value); \
|
|
|
|
value2 = g_value_get_##type (&cp2->value); \
|
2007-06-06 14:01:56 +00:00
|
|
|
slope = (gdouble) (value2 - value1) / gst_guint64_to_gdouble (cp2->timestamp - cp1->timestamp); \
|
2005-08-02 21:35:34 +00:00
|
|
|
\
|
2007-06-09 16:58:30 +00:00
|
|
|
ret = (g##type) (value1 + gst_guint64_to_gdouble (timestamp - cp1->timestamp) * slope); \
|
2005-08-02 21:35:34 +00:00
|
|
|
} \
|
|
|
|
else { \
|
2007-06-09 16:58:30 +00:00
|
|
|
ret = g_value_get_##type (&cp1->value); \
|
2005-08-02 21:35:34 +00:00
|
|
|
} \
|
2007-06-09 16:58:30 +00:00
|
|
|
} else { \
|
|
|
|
ret = g_value_get_##type (&prop->default_value); \
|
2005-08-02 21:35:34 +00:00
|
|
|
} \
|
2007-06-09 16:58:30 +00:00
|
|
|
ret = CLAMP (ret, g_value_get_##type (&prop->min_value), g_value_get_##type (&prop->max_value)); \
|
|
|
|
return ret; \
|
2005-08-02 21:35:34 +00:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static GValue * \
|
|
|
|
interpolate_linear_get_##type (GstControlledProperty * prop, GstClockTime timestamp) \
|
|
|
|
{ \
|
|
|
|
g_value_set_##type (&prop->result_value,_interpolate_linear_get_##type (prop,timestamp)); \
|
2007-06-09 16:58:30 +00:00
|
|
|
return &prop->result_value; \
|
2005-08-02 21:35:34 +00:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static gboolean \
|
|
|
|
interpolate_linear_get_##type##_value_array (GstControlledProperty * prop, \
|
|
|
|
GstClockTime timestamp, GstValueArray * value_array) \
|
|
|
|
{ \
|
|
|
|
gint i; \
|
2005-12-01 09:54:56 +00:00
|
|
|
GstClockTime ts = timestamp; \
|
2007-05-22 09:56:25 +00:00
|
|
|
g##type *values = (g##type *) value_array->values; \
|
2005-08-02 21:35:34 +00:00
|
|
|
\
|
2005-12-01 09:54:56 +00:00
|
|
|
for(i = 0; i < value_array->nbsamples; i++) { \
|
|
|
|
*values = _interpolate_linear_get_##type (prop, ts); \
|
|
|
|
ts += value_array->sample_interval; \
|
2005-08-02 21:35:34 +00:00
|
|
|
values++; \
|
|
|
|
} \
|
2007-06-09 16:58:30 +00:00
|
|
|
return TRUE; \
|
2005-08-02 21:35:34 +00:00
|
|
|
}
|
|
|
|
|
2005-12-01 09:54:56 +00:00
|
|
|
DEFINE_LINEAR_GET (int);
|
|
|
|
|
|
|
|
DEFINE_LINEAR_GET (uint);
|
|
|
|
DEFINE_LINEAR_GET (long);
|
|
|
|
|
|
|
|
DEFINE_LINEAR_GET (ulong);
|
|
|
|
DEFINE_LINEAR_GET (float);
|
|
|
|
DEFINE_LINEAR_GET (double);
|
|
|
|
|
|
|
|
static GstInterpolateMethod interpolate_linear = {
|
|
|
|
interpolate_linear_get_int,
|
|
|
|
interpolate_linear_get_int_value_array,
|
|
|
|
interpolate_linear_get_uint,
|
|
|
|
interpolate_linear_get_uint_value_array,
|
|
|
|
interpolate_linear_get_long,
|
|
|
|
interpolate_linear_get_long_value_array,
|
|
|
|
interpolate_linear_get_ulong,
|
|
|
|
interpolate_linear_get_ulong_value_array,
|
|
|
|
interpolate_linear_get_float,
|
|
|
|
interpolate_linear_get_float_value_array,
|
|
|
|
interpolate_linear_get_double,
|
|
|
|
interpolate_linear_get_double_value_array,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2006-01-12 21:55:42 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2005-12-01 09:54:56 +00:00
|
|
|
NULL
|
|
|
|
};
|
2005-08-02 21:35:34 +00:00
|
|
|
|
gst/gstinfo.c: don't do dummy g_strdup()s
Original commit message from CVS:
* gst/gstinfo.c: (gst_debug_log_default):
don't do dummy g_strdup()s
* libs/gst/controller/gstcontroller.c:
(on_object_controlled_property_changed),
(gst_controlled_property_new), (gst_controller_new_valist),
(gst_controller_new_list),
(gst_controller_remove_properties_valist), (gst_controller_set),
(gst_controller_get), (gst_controller_sync_values),
(gst_controller_get_value_array), (_gst_controller_class_init),
(gst_controller_get_type):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_timed_value_node):
convert // to /**/ comments
2005-09-28 17:30:13 +00:00
|
|
|
/* square interpolation */
|
2005-08-02 21:35:34 +00:00
|
|
|
|
gst/gstinfo.c: don't do dummy g_strdup()s
Original commit message from CVS:
* gst/gstinfo.c: (gst_debug_log_default):
don't do dummy g_strdup()s
* libs/gst/controller/gstcontroller.c:
(on_object_controlled_property_changed),
(gst_controlled_property_new), (gst_controller_new_valist),
(gst_controller_new_list),
(gst_controller_remove_properties_valist), (gst_controller_set),
(gst_controller_get), (gst_controller_sync_values),
(gst_controller_get_value_array), (_gst_controller_class_init),
(gst_controller_get_type):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_timed_value_node):
convert // to /**/ comments
2005-09-28 17:30:13 +00:00
|
|
|
/* cubic interpolation */
|
2005-08-02 21:35:34 +00:00
|
|
|
|
2007-06-06 14:01:56 +00:00
|
|
|
/* The following functions implement a natural cubic spline interpolator.
|
|
|
|
* For details look at http://en.wikipedia.org/wiki/Spline_interpolation
|
|
|
|
*
|
|
|
|
* Instead of using a real matrix with n^2 elements for the linear system
|
|
|
|
* of equations we use three arrays o, p, q to hold the tridiagonal matrix
|
|
|
|
* as following to save memory:
|
|
|
|
*
|
|
|
|
* p[0] q[0] 0 0 0
|
|
|
|
* o[1] p[1] q[1] 0 0
|
|
|
|
* 0 o[2] p[2] q[2] .
|
|
|
|
* . . . . .
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEFINE_CUBIC_GET(type) \
|
|
|
|
static void \
|
|
|
|
_interpolate_cubic_update_cache_##type (GstControlledProperty *prop) \
|
|
|
|
{ \
|
|
|
|
gint i, n = prop->nvalues; \
|
|
|
|
gdouble *o = g_new0 (gdouble, n); \
|
|
|
|
gdouble *p = g_new0 (gdouble, n); \
|
|
|
|
gdouble *q = g_new0 (gdouble, n); \
|
|
|
|
\
|
|
|
|
gdouble *h = g_new0 (gdouble, n); \
|
|
|
|
gdouble *b = g_new0 (gdouble, n); \
|
|
|
|
gdouble *z = g_new0 (gdouble, n); \
|
|
|
|
\
|
|
|
|
GList *node; \
|
|
|
|
GstControlPoint *cp; \
|
|
|
|
GstClockTime x_prev, x, x_next; \
|
|
|
|
g##type y_prev, y, y_next; \
|
|
|
|
\
|
|
|
|
/* Fill linear system of equations */ \
|
|
|
|
node = prop->values; \
|
|
|
|
cp = node->data; \
|
|
|
|
x = cp->timestamp; \
|
|
|
|
y = g_value_get_##type (&cp->value); \
|
|
|
|
\
|
|
|
|
p[0] = 1.0; \
|
|
|
|
\
|
|
|
|
node = node->next; \
|
|
|
|
cp = node->data; \
|
|
|
|
x_next = cp->timestamp; \
|
|
|
|
y_next = g_value_get_##type (&cp->value); \
|
2007-06-07 20:51:35 +00:00
|
|
|
h[0] = gst_util_guint64_to_gdouble (x_next - x); \
|
2007-06-06 14:01:56 +00:00
|
|
|
\
|
|
|
|
for (i = 1; i < n-1; i++) { \
|
|
|
|
/* Shuffle x and y values */ \
|
|
|
|
x_prev = x; \
|
|
|
|
y_prev = y; \
|
|
|
|
x = x_next; \
|
|
|
|
y = y_next; \
|
|
|
|
node = node->next; \
|
|
|
|
cp = node->data; \
|
|
|
|
x_next = cp->timestamp; \
|
|
|
|
y_next = g_value_get_##type (&cp->value); \
|
|
|
|
\
|
2007-06-07 20:51:35 +00:00
|
|
|
h[i] = gst_util_guint64_to_gdouble (x_next - x); \
|
2007-06-06 14:01:56 +00:00
|
|
|
o[i] = h[i-1]; \
|
|
|
|
p[i] = 2.0 * (h[i-1] + h[i]); \
|
|
|
|
q[i] = h[i]; \
|
|
|
|
b[i] = (y_next - y) / h[i] - (y - y_prev) / h[i-1]; \
|
|
|
|
} \
|
|
|
|
p[n-1] = 1.0; \
|
|
|
|
\
|
|
|
|
/* Use Gauss elimination to set everything below the \
|
|
|
|
* diagonal to zero */ \
|
|
|
|
for (i = 1; i < n-1; i++) { \
|
|
|
|
gdouble a = o[i] / p[i-1]; \
|
|
|
|
p[i] -= a * q[i-1]; \
|
|
|
|
b[i] -= a * b[i-1]; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
/* Solve everything else from bottom to top */ \
|
|
|
|
for (i = n-2; i > 0; i--) \
|
|
|
|
z[i] = (b[i] - q[i] * z[i+1]) / p[i]; \
|
|
|
|
\
|
|
|
|
/* Save cache next in the GstControlPoint */ \
|
|
|
|
\
|
|
|
|
node = prop->values; \
|
|
|
|
for (i = 0; i < n; i++) { \
|
|
|
|
cp = node->data; \
|
|
|
|
cp->cache.cubic.h = h[i]; \
|
|
|
|
cp->cache.cubic.z = z[i]; \
|
|
|
|
node = node->next; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
/* Free our temporary arrays */ \
|
|
|
|
g_free (o); \
|
|
|
|
g_free (p); \
|
|
|
|
g_free (q); \
|
|
|
|
g_free (h); \
|
|
|
|
g_free (b); \
|
|
|
|
g_free (z); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static g##type \
|
|
|
|
_interpolate_cubic_get_##type (GstControlledProperty * prop, GstClockTime timestamp) \
|
|
|
|
{ \
|
|
|
|
GList *node; \
|
2007-06-09 16:58:30 +00:00
|
|
|
g##type ret; \
|
2007-06-06 14:01:56 +00:00
|
|
|
\
|
|
|
|
if (prop->nvalues <= 2) \
|
|
|
|
return _interpolate_linear_get_##type (prop, timestamp); \
|
|
|
|
\
|
|
|
|
if (!prop->valid_cache) { \
|
|
|
|
_interpolate_cubic_update_cache_##type (prop); \
|
|
|
|
prop->valid_cache = TRUE; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
if ((node = gst_controlled_property_find_control_point_node (prop, timestamp))) { \
|
|
|
|
GstControlPoint *cp1, *cp2; \
|
|
|
|
\
|
|
|
|
cp1 = node->data; \
|
|
|
|
if ((node = g_list_next (node))) { \
|
|
|
|
gdouble diff1, diff2; \
|
|
|
|
g##type value1,value2; \
|
2007-06-09 16:58:30 +00:00
|
|
|
gdouble out; \
|
2007-06-06 14:01:56 +00:00
|
|
|
\
|
|
|
|
cp2 = node->data; \
|
|
|
|
\
|
|
|
|
value1 = g_value_get_##type (&cp1->value); \
|
|
|
|
value2 = g_value_get_##type (&cp2->value); \
|
|
|
|
\
|
|
|
|
diff1 = gst_guint64_to_gdouble (timestamp - cp1->timestamp); \
|
|
|
|
diff2 = gst_guint64_to_gdouble (cp2->timestamp - timestamp); \
|
|
|
|
\
|
2007-06-09 16:58:30 +00:00
|
|
|
out = (cp2->cache.cubic.z * diff1 * diff1 * diff1 + cp1->cache.cubic.z * diff2 * diff2 * diff2) / cp1->cache.cubic.h; \
|
|
|
|
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; \
|
2007-06-06 14:01:56 +00:00
|
|
|
\
|
2007-06-09 16:58:30 +00:00
|
|
|
ret = (g##type) out; \
|
2007-06-06 14:01:56 +00:00
|
|
|
} \
|
|
|
|
else { \
|
2007-06-09 16:58:30 +00:00
|
|
|
ret = g_value_get_##type (&cp1->value); \
|
2007-06-06 14:01:56 +00:00
|
|
|
} \
|
2007-06-09 16:58:30 +00:00
|
|
|
} else {\
|
|
|
|
ret = g_value_get_##type (&prop->default_value); \
|
2007-06-06 14:01:56 +00:00
|
|
|
} \
|
2007-06-09 16:58:30 +00:00
|
|
|
ret = CLAMP (ret, g_value_get_##type (&prop->min_value), g_value_get_##type (&prop->max_value)); \
|
|
|
|
return ret; \
|
2007-06-06 14:01:56 +00:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static GValue * \
|
|
|
|
interpolate_cubic_get_##type (GstControlledProperty * prop, GstClockTime timestamp) \
|
|
|
|
{ \
|
|
|
|
g_value_set_##type (&prop->result_value,_interpolate_cubic_get_##type (prop,timestamp)); \
|
2007-06-09 16:58:30 +00:00
|
|
|
return &prop->result_value; \
|
2007-06-06 14:01:56 +00:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static gboolean \
|
|
|
|
interpolate_cubic_get_##type##_value_array (GstControlledProperty * prop, \
|
|
|
|
GstClockTime timestamp, GstValueArray * value_array) \
|
|
|
|
{ \
|
|
|
|
gint i; \
|
|
|
|
GstClockTime ts = timestamp; \
|
|
|
|
g##type *values = (g##type *) value_array->values; \
|
|
|
|
\
|
|
|
|
for(i = 0; i < value_array->nbsamples; i++) { \
|
|
|
|
*values = _interpolate_cubic_get_##type (prop, ts); \
|
|
|
|
ts += value_array->sample_interval; \
|
|
|
|
values++; \
|
|
|
|
} \
|
2007-06-09 16:58:30 +00:00
|
|
|
return TRUE; \
|
2007-06-06 14:01:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_CUBIC_GET (int);
|
|
|
|
|
|
|
|
DEFINE_CUBIC_GET (uint);
|
|
|
|
DEFINE_CUBIC_GET (long);
|
|
|
|
|
|
|
|
DEFINE_CUBIC_GET (ulong);
|
|
|
|
DEFINE_CUBIC_GET (float);
|
|
|
|
DEFINE_CUBIC_GET (double);
|
|
|
|
|
|
|
|
static GstInterpolateMethod interpolate_cubic = {
|
|
|
|
interpolate_cubic_get_int,
|
|
|
|
interpolate_cubic_get_int_value_array,
|
|
|
|
interpolate_cubic_get_uint,
|
|
|
|
interpolate_cubic_get_uint_value_array,
|
|
|
|
interpolate_cubic_get_long,
|
|
|
|
interpolate_cubic_get_long_value_array,
|
|
|
|
interpolate_cubic_get_ulong,
|
|
|
|
interpolate_cubic_get_ulong_value_array,
|
|
|
|
interpolate_cubic_get_float,
|
|
|
|
interpolate_cubic_get_float_value_array,
|
|
|
|
interpolate_cubic_get_double,
|
|
|
|
interpolate_cubic_get_double_value_array,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
gst/gstinfo.c: don't do dummy g_strdup()s
Original commit message from CVS:
* gst/gstinfo.c: (gst_debug_log_default):
don't do dummy g_strdup()s
* libs/gst/controller/gstcontroller.c:
(on_object_controlled_property_changed),
(gst_controlled_property_new), (gst_controller_new_valist),
(gst_controller_new_list),
(gst_controller_remove_properties_valist), (gst_controller_set),
(gst_controller_get), (gst_controller_sync_values),
(gst_controller_get_value_array), (_gst_controller_class_init),
(gst_controller_get_type):
* libs/gst/controller/gstcontroller.h:
* libs/gst/controller/gstinterpolation.c:
(gst_controlled_property_find_timed_value_node):
convert // to /**/ comments
2005-09-28 17:30:13 +00:00
|
|
|
/* register all interpolation methods */
|
2005-08-02 21:35:34 +00:00
|
|
|
GstInterpolateMethod *interpolation_methods[] = {
|
|
|
|
&interpolate_none,
|
|
|
|
&interpolate_trigger,
|
|
|
|
&interpolate_linear,
|
2007-06-06 14:01:56 +00:00
|
|
|
&interpolate_cubic,
|
|
|
|
&interpolate_cubic
|
2005-08-02 21:35:34 +00:00
|
|
|
};
|
2007-05-04 12:37:01 +00:00
|
|
|
|
|
|
|
guint num_interpolation_methods = G_N_ELEMENTS (interpolation_methods);
|