diff options
author | Stefan Sauer <ensonic@users.sf.net> | 2012-04-25 09:47:10 +0200 |
---|---|---|
committer | Stefan Sauer <ensonic@users.sf.net> | 2012-04-25 20:19:23 +0200 |
commit | 772c58e255d8d0358ad21bb64b49fb49e6271bc7 (patch) | |
tree | 164741baeb36b0b618be9467b92cfd61350ad6e7 /libs/gst/controller/gstargbcontrolbinding.c | |
parent | 12eefc0442695fce2ace96ede3221b59068cd74c (diff) |
controller: expand the api to offer functions for plain and GValue arrays
Rename the _get_value_array() functions to _get_g_value_array() and reintroduce
the former to operate on plain unboxed c datatypes (like in 0.10). The _g_value
variants are for bindings while the _value ones are more suited to processing
in elements.
Diffstat (limited to 'libs/gst/controller/gstargbcontrolbinding.c')
-rw-r--r-- | libs/gst/controller/gstargbcontrolbinding.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/libs/gst/controller/gstargbcontrolbinding.c b/libs/gst/controller/gstargbcontrolbinding.c index 400dbbb0f..9e4728a60 100644 --- a/libs/gst/controller/gstargbcontrolbinding.c +++ b/libs/gst/controller/gstargbcontrolbinding.c @@ -53,6 +53,9 @@ static GValue *gst_argb_control_binding_get_value (GstControlBinding * _self, GstClockTime timestamp); static gboolean gst_argb_control_binding_get_value_array (GstControlBinding * _self, GstClockTime timestamp, GstClockTime interval, guint n_values, + gpointer values); +static gboolean gst_argb_control_binding_get_g_value_array (GstControlBinding * + _self, GstClockTime timestamp, GstClockTime interval, guint n_values, GValue * values); #define _do_init \ @@ -94,6 +97,8 @@ gst_argb_control_binding_class_init (GstARGBControlBindingClass * klass) control_binding_class->get_value = gst_argb_control_binding_get_value; control_binding_class->get_value_array = gst_argb_control_binding_get_value_array; + control_binding_class->get_g_value_array = + gst_argb_control_binding_get_g_value_array; properties[PROP_CS_A] = g_param_spec_object ("control-source-a", "ControlSource A", @@ -316,6 +321,71 @@ gst_argb_control_binding_get_value (GstControlBinding * _self, static gboolean gst_argb_control_binding_get_value_array (GstControlBinding * _self, GstClockTime timestamp, GstClockTime interval, guint n_values, + gpointer values_) +{ + GstARGBControlBinding *self = GST_ARGB_CONTROL_BINDING (_self); + gint i; + gdouble *src_val_a = NULL, *src_val_r = NULL, *src_val_g = NULL, *src_val_b = + NULL; + guint *values = (guint *) values_; + gboolean ret = TRUE; + + g_return_val_if_fail (GST_IS_ARGB_CONTROL_BINDING (self), FALSE); + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (interval), FALSE); + g_return_val_if_fail (values, FALSE); + g_return_val_if_fail (GST_CONTROL_BINDING_PSPEC (self), FALSE); + + if (self->cs_a) { + src_val_a = g_new0 (gdouble, n_values); + ret &= gst_control_source_get_value_array (self->cs_a, timestamp, + interval, n_values, src_val_a); + } + if (self->cs_r) { + src_val_r = g_new0 (gdouble, n_values); + ret &= gst_control_source_get_value_array (self->cs_r, timestamp, + interval, n_values, src_val_r); + } + if (self->cs_g) { + src_val_g = g_new0 (gdouble, n_values); + ret &= gst_control_source_get_value_array (self->cs_g, timestamp, + interval, n_values, src_val_g); + } + if (self->cs_b) { + src_val_b = g_new0 (gdouble, n_values); + ret &= gst_control_source_get_value_array (self->cs_b, timestamp, + interval, n_values, src_val_b); + } + if (G_LIKELY (ret)) { + for (i = 0; i < n_values; i++) { + gdouble a = 1.0, r = 0.0, g = 0.0, b = 0.0; + if (src_val_a && !isnan (src_val_a[i])) + a = src_val_a[i]; + if (src_val_r && !isnan (src_val_r[i])) + r = src_val_r[i]; + if (src_val_g && !isnan (src_val_g[i])) + g = src_val_g[i]; + if (src_val_b && !isnan (src_val_b[i])) + b = src_val_b[i]; + values[i] = (((guint) (CLAMP (a, 0.0, 1.0) * 255)) << 24) | + (((guint) (CLAMP (r, 0.0, 1.0) * 255)) << 16) | + (((guint) (CLAMP (g, 0.0, 1.0) * 255)) << 8) | + ((guint) (CLAMP (b, 0.0, 1.0) * 255)); + } + } else { + GST_LOG ("failed to get control value for property %s at ts %" + GST_TIME_FORMAT, _self->name, GST_TIME_ARGS (timestamp)); + } + g_free (src_val_a); + g_free (src_val_r); + g_free (src_val_g); + g_free (src_val_b); + return ret; +} + +static gboolean +gst_argb_control_binding_get_g_value_array (GstControlBinding * _self, + GstClockTime timestamp, GstClockTime interval, guint n_values, GValue * values) { GstARGBControlBinding *self = GST_ARGB_CONTROL_BINDING (_self); |