mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-23 20:40:24 +00:00
c478fb4813
Original commit message from CVS: * libs/gst/controller/gstcontroller.c: (gst_controlled_property_set_interpolation_mode), (gst_controlled_property_prepend_default), (gst_controlled_property_new), (gst_controller_set_unlocked), (gst_controller_set), (gst_controller_set_from_list), (gst_controller_unset), (gst_controller_unset_all): * libs/gst/controller/gstcontrollerprivate.h: * libs/gst/controller/gstinterpolation.c: Factor out the 'set' logic into gst_controller_set_unlocked for the gst_controller_set and gst_controller_set_from_list functions. To make life of the interpolators easier always add a control point at timestamp zero with the default value. In the linear interpolator make things more obvious by better variable naming (slope). Implement cubic interpolation mode (by using a natural cubic spline) and map the quadratic interpolation mode to this too (as quadratic doesn't make much sense, see discussion on the list). * tests/check/libs/controller.c: (GST_START_TEST), (gst_controller_suite): Add unit test for the cubic interpolation mode and check everywhere if the interpolation mode could be set as expected.
126 lines
4.2 KiB
C
126 lines
4.2 KiB
C
/* GStreamer
|
|
*
|
|
* Copyright (C) <2005> Stefan Kost <ensonic at users dot sf dot net>
|
|
*
|
|
* gstcontrollerprivate.h: dynamic parameter control subsystem
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#ifndef __GST_CONTROLLER_PRIVATE_H__
|
|
#define __GST_CONTROLLER_PRIVATE_H__
|
|
|
|
#include <glib.h>
|
|
#include <glib-object.h>
|
|
#include <gst/gst.h>
|
|
|
|
#include "gstcontroller.h"
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
struct _GstControlledProperty;
|
|
|
|
typedef GValue *(*InterpolateGet) (struct _GstControlledProperty * prop,
|
|
GstClockTime timestamp);
|
|
typedef gboolean (*InterpolateGetValueArray) (struct _GstControlledProperty * prop,
|
|
GstClockTime timestamp, GstValueArray * value_array);
|
|
|
|
/**
|
|
* GstInterpolateMethod:
|
|
*
|
|
* Function pointer structure to do user-defined interpolation methods
|
|
*/
|
|
typedef struct _GstInterpolateMethod
|
|
{
|
|
InterpolateGet get_int;
|
|
InterpolateGetValueArray get_int_value_array;
|
|
InterpolateGet get_uint;
|
|
InterpolateGetValueArray get_uint_value_array;
|
|
InterpolateGet get_long;
|
|
InterpolateGetValueArray get_long_value_array;
|
|
InterpolateGet get_ulong;
|
|
InterpolateGetValueArray get_ulong_value_array;
|
|
InterpolateGet get_float;
|
|
InterpolateGetValueArray get_float_value_array;
|
|
InterpolateGet get_double;
|
|
InterpolateGetValueArray get_double_value_array;
|
|
InterpolateGet get_boolean;
|
|
InterpolateGetValueArray get_boolean_value_array;
|
|
InterpolateGet get_enum;
|
|
InterpolateGetValueArray get_enum_value_array;
|
|
InterpolateGet get_string;
|
|
InterpolateGetValueArray get_string_value_array;
|
|
} GstInterpolateMethod;
|
|
|
|
/**
|
|
* GstControlPoint:
|
|
*
|
|
* a internal structure for value+time and various temporary
|
|
* values used for interpolation. This "inherits" from
|
|
* GstTimedValue.
|
|
*/
|
|
/* FIXME 0.11: This should be merged with GstTimedValue for 0.11 */
|
|
typedef struct _GstControlPoint
|
|
{
|
|
/* fields from GstTimedValue. DO NOT CHANGE! */
|
|
GstClockTime timestamp; /* timestamp of the value change */
|
|
GValue value; /* the new value */
|
|
|
|
/* internal fields */
|
|
|
|
/* Caches for the interpolators */
|
|
union {
|
|
struct {
|
|
gdouble h;
|
|
gdouble z;
|
|
} cubic;
|
|
} cache;
|
|
|
|
} GstControlPoint;
|
|
|
|
/**
|
|
* GstControlledProperty:
|
|
*/
|
|
typedef struct _GstControlledProperty
|
|
{
|
|
gchar *name; /* name of the property */
|
|
GType type; /* type of the handled property */
|
|
GType base; /* base-type of the handled property */
|
|
GValue default_value; /* default value for the handled property */
|
|
GValue result_value; /* result value location for the interpolation method */
|
|
GstControlPoint last_value; /* the last value a _sink call wrote */
|
|
GstControlPoint live_value; /* temporary value override for live input */
|
|
gulong notify_handler_id; /* id of the notify::<name> signal handler */
|
|
GstInterpolateMode interpolation; /* Interpolation mode */
|
|
/* TODO instead of *method, have pointers to get() and get_value_array() here
|
|
gst_controller_set_interpolation_mode() will pick the right ones for the
|
|
properties value type
|
|
GstInterpolateMethod *method; // User-implemented handler (if interpolation == GST_INTERPOLATE_USER)
|
|
*/
|
|
InterpolateGet get;
|
|
InterpolateGetValueArray get_value_array;
|
|
|
|
GList *values; /* List of GstControlPoint */
|
|
gint nvalues; /* Number of control points */
|
|
GList *last_requested_value; /* last search result, can be used for incremental searches */
|
|
gboolean valid_cache;
|
|
} GstControlledProperty;
|
|
|
|
#define GST_CONTROLLED_PROPERTY(obj) ((GstControlledProperty *)(obj))
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* __GST_CONTROLLER_PRIVATE_H__ */
|