⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gstinterpolationcontrolsource.c

📁 gnash 在pc和嵌入式下开发需要的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* GStreamer * * Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org> * * gstinterpolationcontrolsource.c: Control source that provides several *                                  interpolation methods * * 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. *//** * SECTION:gstinterpolationcontrolsource * @short_description: interpolation control source * * #GstInterpolationControlSource is a #GstControlSource, that interpolates values between user-given * control points. It supports several interpolation modes and property types. * * To use #GstInterpolationControlSource get a new instance by calling * gst_interpolation_control_source_new(), bind it to a #GParamSpec, select a interpolation mode with * gst_interpolation_control_source_set_interpolation_mode() and set some control points by calling * gst_interpolation_control_source_set(). * * All functions are MT-safe. * */#include <glib-object.h>#include <gst/gst.h>#include "gstcontrolsource.h"#include "gstinterpolationcontrolsource.h"#include "gstinterpolationcontrolsourceprivate.h"extern GstInterpolateMethod *interpolation_methods[];extern guint num_interpolation_methods;static void gst_interpolation_control_source_init (GstInterpolationControlSource    * self);static voidgst_interpolation_control_source_class_init (GstInterpolationControlSourceClass    * klass);G_DEFINE_TYPE (GstInterpolationControlSource, gst_interpolation_control_source,    GST_TYPE_CONTROL_SOURCE);static GObjectClass *parent_class = NULL;/* * gst_control_point_free: * @prop: the object to free * * Private method which frees all data allocated by a #GstControlPoint * instance. */static voidgst_control_point_free (GstControlPoint * cp){  g_return_if_fail (cp);  g_value_unset (&cp->value);  g_free (cp);}static voidgst_interpolation_control_source_reset (GstInterpolationControlSource * self){  GstControlSource *csource = GST_CONTROL_SOURCE (self);  csource->get_value = NULL;  csource->get_value_array = NULL;  self->priv->type = self->priv->base = G_TYPE_INVALID;  if (G_IS_VALUE (&self->priv->default_value))    g_value_unset (&self->priv->default_value);  if (G_IS_VALUE (&self->priv->minimum_value))    g_value_unset (&self->priv->minimum_value);  if (G_IS_VALUE (&self->priv->maximum_value))    g_value_unset (&self->priv->maximum_value);  if (self->priv->values) {    g_list_foreach (self->priv->values, (GFunc) gst_control_point_free, NULL);    g_list_free (self->priv->values);    self->priv->values = NULL;  }  self->priv->nvalues = 0;  self->priv->last_requested_value = NULL;  self->priv->valid_cache = FALSE;}/** * gst_interpolation_control_source_new: * * This returns a new, unbound #GstInterpolationControlSource. * * Returns: a new, unbound #GstInterpolationControlSource. */GstInterpolationControlSource *gst_interpolation_control_source_new (){  return g_object_new (GST_TYPE_INTERPOLATION_CONTROL_SOURCE, NULL);}/** * gst_interpolation_control_source_set_interpolation_mode: * @self: the #GstInterpolationControlSource object * @mode: interpolation mode * * Sets the given interpolation mode. * * <note><para>User interpolation is not yet available and quadratic interpolation * is deprecated and maps to cubic interpolation.</para></note> * * Returns: %TRUE if the interpolation mode could be set, %FALSE otherwise */gboolean    gst_interpolation_control_source_set_interpolation_mode    (GstInterpolationControlSource * self, GstInterpolateMode mode) {  gboolean ret = TRUE;  GstControlSource *csource = GST_CONTROL_SOURCE (self);  if (mode >= num_interpolation_methods || interpolation_methods[mode] == NULL) {    GST_WARNING ("interpolation mode %d invalid or not implemented yet", mode);    return FALSE;  }  if (mode == GST_INTERPOLATE_QUADRATIC) {    GST_WARNING ("Quadratic interpolation mode is deprecated, using cubic"        "interpolation mode");  }  if (mode == GST_INTERPOLATE_USER) {    GST_WARNING ("User interpolation mode is not implemented yet");    return FALSE;  }  g_mutex_lock (self->lock);  switch (self->priv->base) {    case G_TYPE_INT:      csource->get_value = interpolation_methods[mode]->get_int;      csource->get_value_array =          interpolation_methods[mode]->get_int_value_array;      break;    case G_TYPE_UINT:{      csource->get_value = interpolation_methods[mode]->get_uint;      csource->get_value_array =          interpolation_methods[mode]->get_uint_value_array;      break;    }    case G_TYPE_LONG:{      csource->get_value = interpolation_methods[mode]->get_long;      csource->get_value_array =          interpolation_methods[mode]->get_long_value_array;      break;    }    case G_TYPE_ULONG:{      csource->get_value = interpolation_methods[mode]->get_ulong;      csource->get_value_array =          interpolation_methods[mode]->get_ulong_value_array;      break;    }    case G_TYPE_INT64:{      csource->get_value = interpolation_methods[mode]->get_int64;      csource->get_value_array =          interpolation_methods[mode]->get_int64_value_array;      break;    }    case G_TYPE_UINT64:{      csource->get_value = interpolation_methods[mode]->get_uint64;      csource->get_value_array =          interpolation_methods[mode]->get_uint64_value_array;      break;    }    case G_TYPE_FLOAT:{      csource->get_value = interpolation_methods[mode]->get_float;      csource->get_value_array =          interpolation_methods[mode]->get_float_value_array;      break;    }    case G_TYPE_DOUBLE:{      csource->get_value = interpolation_methods[mode]->get_double;      csource->get_value_array =          interpolation_methods[mode]->get_double_value_array;      break;    }    case G_TYPE_BOOLEAN:{      csource->get_value = interpolation_methods[mode]->get_boolean;      csource->get_value_array =          interpolation_methods[mode]->get_boolean_value_array;      break;    }    case G_TYPE_ENUM:{      csource->get_value = interpolation_methods[mode]->get_enum;      csource->get_value_array =          interpolation_methods[mode]->get_enum_value_array;      break;    }    case G_TYPE_STRING:{      csource->get_value = interpolation_methods[mode]->get_string;      csource->get_value_array =          interpolation_methods[mode]->get_string_value_array;      break;    }    default:      ret = FALSE;      break;  }  /* Incomplete implementation */  if (!ret || !csource->get_value || !csource->get_value_array) {    gst_interpolation_control_source_reset (self);    ret = FALSE;  }  self->priv->valid_cache = FALSE;  self->priv->interpolation_mode = mode;  g_mutex_unlock (self->lock);  return ret;}static gbooleangst_interpolation_control_source_bind (GstControlSource * source,    GParamSpec * pspec){  GType type, base;  GstInterpolationControlSource *self =      GST_INTERPOLATION_CONTROL_SOURCE (source);  gboolean ret = TRUE;  /* get the fundamental base type */  self->priv->type = base = type = G_PARAM_SPEC_VALUE_TYPE (pspec);  while ((type = g_type_parent (type)))    base = type;  self->priv->base = base;  /* restore type */  type = self->priv->type;  if (!gst_interpolation_control_source_set_interpolation_mode (self,          self->priv->interpolation_mode))    return FALSE;  switch (base) {    case G_TYPE_INT:{      GParamSpecInt *tpspec = G_PARAM_SPEC_INT (pspec);      g_value_init (&self->priv->default_value, type);      g_value_set_int (&self->priv->default_value, tpspec->default_value);      g_value_init (&self->priv->minimum_value, type);      g_value_set_int (&self->priv->minimum_value, tpspec->minimum);      g_value_init (&self->priv->maximum_value, type);      g_value_set_int (&self->priv->maximum_value, tpspec->maximum);      break;    }    case G_TYPE_UINT:{      GParamSpecUInt *tpspec = G_PARAM_SPEC_UINT (pspec);      g_value_init (&self->priv->default_value, type);      g_value_set_uint (&self->priv->default_value, tpspec->default_value);      g_value_init (&self->priv->minimum_value, type);      g_value_set_uint (&self->priv->minimum_value, tpspec->minimum);      g_value_init (&self->priv->maximum_value, type);      g_value_set_uint (&self->priv->maximum_value, tpspec->maximum);      break;    }    case G_TYPE_LONG:{      GParamSpecLong *tpspec = G_PARAM_SPEC_LONG (pspec);      g_value_init (&self->priv->default_value, type);      g_value_set_long (&self->priv->default_value, tpspec->default_value);      g_value_init (&self->priv->minimum_value, type);      g_value_set_long (&self->priv->minimum_value, tpspec->minimum);      g_value_init (&self->priv->maximum_value, type);      g_value_set_long (&self->priv->maximum_value, tpspec->maximum);      break;    }    case G_TYPE_ULONG:{      GParamSpecULong *tpspec = G_PARAM_SPEC_ULONG (pspec);      g_value_init (&self->priv->default_value, type);      g_value_set_ulong (&self->priv->default_value, tpspec->default_value);      g_value_init (&self->priv->minimum_value, type);      g_value_set_ulong (&self->priv->minimum_value, tpspec->minimum);      g_value_init (&self->priv->maximum_value, type);      g_value_set_ulong (&self->priv->maximum_value, tpspec->maximum);      break;    }    case G_TYPE_INT64:{      GParamSpecInt64 *tpspec = G_PARAM_SPEC_INT64 (pspec);      g_value_init (&self->priv->default_value, type);      g_value_set_int64 (&self->priv->default_value, tpspec->default_value);      g_value_init (&self->priv->minimum_value, type);      g_value_set_int64 (&self->priv->minimum_value, tpspec->minimum);      g_value_init (&self->priv->maximum_value, type);      g_value_set_int64 (&self->priv->maximum_value, tpspec->maximum);      break;    }    case G_TYPE_UINT64:{      GParamSpecUInt64 *tpspec = G_PARAM_SPEC_UINT64 (pspec);      g_value_init (&self->priv->default_value, type);      g_value_set_uint64 (&self->priv->default_value, tpspec->default_value);      g_value_init (&self->priv->minimum_value, type);      g_value_set_uint64 (&self->priv->minimum_value, tpspec->minimum);      g_value_init (&self->priv->maximum_value, type);      g_value_set_uint64 (&self->priv->maximum_value, tpspec->maximum);      break;    }    case G_TYPE_FLOAT:{      GParamSpecFloat *tpspec = G_PARAM_SPEC_FLOAT (pspec);      g_value_init (&self->priv->default_value, type);      g_value_set_float (&self->priv->default_value, tpspec->default_value);      g_value_init (&self->priv->minimum_value, type);      g_value_set_float (&self->priv->minimum_value, tpspec->minimum);      g_value_init (&self->priv->maximum_value, type);      g_value_set_float (&self->priv->maximum_value, tpspec->maximum);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -