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

📄 gstlfocontrolsource.c

📁 gnash 在pc和嵌入式下开发需要的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
  } \  g_mutex_unlock (self->lock); \  return TRUE; \}DEFINE_RSAW (int, TRUE, EMPTY);DEFINE_RSAW (uint, TRUE, EMPTY);DEFINE_RSAW (long, TRUE, EMPTY);DEFINE_RSAW (ulong, TRUE, EMPTY);DEFINE_RSAW (int64, TRUE, EMPTY);DEFINE_RSAW (uint64, TRUE, gst_util_guint64_to_gdouble);DEFINE_RSAW (float, FALSE, EMPTY);DEFINE_RSAW (double, FALSE, EMPTY);static GstWaveformImplementation waveform_rsaw = {  (GstControlSourceGetValue) waveform_rsaw_get_int,  (GstControlSourceGetValueArray) waveform_rsaw_get_int_value_array,  (GstControlSourceGetValue) waveform_rsaw_get_uint,  (GstControlSourceGetValueArray) waveform_rsaw_get_uint_value_array,  (GstControlSourceGetValue) waveform_rsaw_get_long,  (GstControlSourceGetValueArray) waveform_rsaw_get_long_value_array,  (GstControlSourceGetValue) waveform_rsaw_get_ulong,  (GstControlSourceGetValueArray) waveform_rsaw_get_ulong_value_array,  (GstControlSourceGetValue) waveform_rsaw_get_int64,  (GstControlSourceGetValueArray) waveform_rsaw_get_int64_value_array,  (GstControlSourceGetValue) waveform_rsaw_get_uint64,  (GstControlSourceGetValueArray) waveform_rsaw_get_uint64_value_array,  (GstControlSourceGetValue) waveform_rsaw_get_float,  (GstControlSourceGetValueArray) waveform_rsaw_get_float_value_array,  (GstControlSourceGetValue) waveform_rsaw_get_double,  (GstControlSourceGetValueArray) waveform_rsaw_get_double_value_array};#define DEFINE_TRIANGLE(type,round,convert) \\static inline g##type \_triangle_get_##type (GstLFOControlSource *self, GstClockTime timestamp) \{ \  g##type max = g_value_get_##type (&self->priv->maximum_value); \  g##type min = g_value_get_##type (&self->priv->minimum_value); \  gdouble amp = convert (g_value_get_##type (&self->priv->amplitude)); \  gdouble off = convert (g_value_get_##type (&self->priv->offset)); \  GstClockTime period = self->priv->period; \  GstClockTime pos = _calculate_pos (timestamp, self->priv->timeshift, period); \  gdouble ret; \  \  if (gst_util_guint64_to_gdouble (pos) <= gst_util_guint64_to_gdouble (period) / 4.0) \    ret = gst_util_guint64_to_gdouble (pos) * ((4.0 * amp) / gst_util_guint64_to_gdouble (period)); \  else if (gst_util_guint64_to_gdouble (pos) <= (3.0 * gst_util_guint64_to_gdouble (period)) / 4.0) \    ret = -(gst_util_guint64_to_gdouble (pos) - gst_util_guint64_to_gdouble (period) / 2.0) * ((4.0 * amp) / gst_util_guint64_to_gdouble (period)); \  else \    ret = gst_util_guint64_to_gdouble (period) - gst_util_guint64_to_gdouble (pos) * ((4.0 * amp) / gst_util_guint64_to_gdouble (period)); \  \  ret += off; \  \  if (round) \    ret += 0.5; \  \  return (g##type) CLAMP (ret, convert (min), convert (max)); \} \\static gboolean \waveform_triangle_get_##type (GstLFOControlSource *self, GstClockTime timestamp, \    GValue *value) \{ \  g##type ret; \  g_mutex_lock (self->lock); \  ret = _triangle_get_##type (self, timestamp); \  g_value_set_##type (value, ret); \  g_mutex_unlock (self->lock); \  return TRUE; \} \\static gboolean \waveform_triangle_get_##type##_value_array (GstLFOControlSource *self, \   GstClockTime timestamp, GstValueArray * value_array) \{ \  gint i; \  GstClockTime ts = timestamp; \  g##type *values = (g##type *) value_array->values; \  \  g_mutex_lock (self->lock); \  for(i = 0; i < value_array->nbsamples; i++) { \    *values = _triangle_get_##type (self, ts); \    ts += value_array->sample_interval; \    values++; \  } \  g_mutex_unlock (self->lock); \  return TRUE; \}DEFINE_TRIANGLE (int, TRUE, EMPTY);DEFINE_TRIANGLE (uint, TRUE, EMPTY);DEFINE_TRIANGLE (long, TRUE, EMPTY);DEFINE_TRIANGLE (ulong, TRUE, EMPTY);DEFINE_TRIANGLE (int64, TRUE, EMPTY);DEFINE_TRIANGLE (uint64, TRUE, gst_util_guint64_to_gdouble);DEFINE_TRIANGLE (float, FALSE, EMPTY);DEFINE_TRIANGLE (double, FALSE, EMPTY);static GstWaveformImplementation waveform_triangle = {  (GstControlSourceGetValue) waveform_triangle_get_int,  (GstControlSourceGetValueArray) waveform_triangle_get_int_value_array,  (GstControlSourceGetValue) waveform_triangle_get_uint,  (GstControlSourceGetValueArray) waveform_triangle_get_uint_value_array,  (GstControlSourceGetValue) waveform_triangle_get_long,  (GstControlSourceGetValueArray) waveform_triangle_get_long_value_array,  (GstControlSourceGetValue) waveform_triangle_get_ulong,  (GstControlSourceGetValueArray) waveform_triangle_get_ulong_value_array,  (GstControlSourceGetValue) waveform_triangle_get_int64,  (GstControlSourceGetValueArray) waveform_triangle_get_int64_value_array,  (GstControlSourceGetValue) waveform_triangle_get_uint64,  (GstControlSourceGetValueArray) waveform_triangle_get_uint64_value_array,  (GstControlSourceGetValue) waveform_triangle_get_float,  (GstControlSourceGetValueArray) waveform_triangle_get_float_value_array,  (GstControlSourceGetValue) waveform_triangle_get_double,  (GstControlSourceGetValueArray) waveform_triangle_get_double_value_array};static GstWaveformImplementation *waveforms[] = {  &waveform_sine,  &waveform_square,  &waveform_saw,  &waveform_rsaw,  &waveform_triangle};static guint num_waveforms = G_N_ELEMENTS (waveforms);enum{  PROP_WAVEFORM = 1,  PROP_FREQUENCY,  PROP_TIMESHIFT,  PROP_AMPLITUDE,  PROP_OFFSET};GTypegst_lfo_waveform_get_type (void){  static GType gtype = 0;  if (gtype == 0) {    static const GEnumValue values[] = {      {GST_LFO_WAVEFORM_SINE, "Sine waveform (default)",          "sine"},      {GST_LFO_WAVEFORM_SQUARE, "Square waveform",          "square"},      {GST_LFO_WAVEFORM_SAW, "Saw waveform",          "saw"},      {GST_LFO_WAVEFORM_REVERSE_SAW, "Reverse saw waveform",          "reverse-saw"},      {GST_LFO_WAVEFORM_TRIANGLE, "Triangle waveform",          "triangle"},      {0, NULL, NULL}    };    gtype = g_enum_register_static ("GstLFOWaveform", values);  }  return gtype;}static void gst_lfo_control_source_init (GstLFOControlSource * self);static voidgst_lfo_control_source_class_init (GstLFOControlSourceClass * klass);G_DEFINE_TYPE (GstLFOControlSource, gst_lfo_control_source,    GST_TYPE_CONTROL_SOURCE);static GObjectClass *parent_class = NULL;static voidgst_lfo_control_source_reset (GstLFOControlSource * 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->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 (G_IS_VALUE (&self->priv->amplitude))    g_value_unset (&self->priv->amplitude);  if (G_IS_VALUE (&self->priv->offset))    g_value_unset (&self->priv->offset);}/** * gst_lfo_control_source_new: * * This returns a new, unbound #GstLFOControlSource. * * Returns: a new, unbound #GstLFOControlSource. */GstLFOControlSource *gst_lfo_control_source_new (){  return g_object_new (GST_TYPE_LFO_CONTROL_SOURCE, NULL);}static gbooleangst_lfo_control_source_set_waveform (GstLFOControlSource * self,    GstLFOWaveform waveform){  GstControlSource *csource = GST_CONTROL_SOURCE (self);  gboolean ret = TRUE;  if (waveform >= num_waveforms || waveform < 0) {    GST_WARNING ("waveform %d invalid or not implemented yet", waveform);    return FALSE;  }  if (self->priv->base == G_TYPE_INVALID) {    GST_WARNING ("not bound to a property yet");    return FALSE;  }  switch (self->priv->base) {    case G_TYPE_INT:      csource->get_value = waveforms[waveform]->get_int;      csource->get_value_array = waveforms[waveform]->get_int_value_array;      break;    case G_TYPE_UINT:{      csource->get_value = waveforms[waveform]->get_uint;      csource->get_value_array = waveforms[waveform]->get_uint_value_array;      break;    }    case G_TYPE_LONG:{      csource->get_value = waveforms[waveform]->get_long;      csource->get_value_array = waveforms[waveform]->get_long_value_array;      break;    }    case G_TYPE_ULONG:{      csource->get_value = waveforms[waveform]->get_ulong;      csource->get_value_array = waveforms[waveform]->get_ulong_value_array;      break;    }    case G_TYPE_INT64:{      csource->get_value = waveforms[waveform]->get_int64;      csource->get_value_array = waveforms[waveform]->get_int64_value_array;      break;    }    case G_TYPE_UINT64:{      csource->get_value = waveforms[waveform]->get_uint64;      csource->get_value_array = waveforms[waveform]->get_uint64_value_array;      break;    }    case G_TYPE_FLOAT:{      csource->get_value = waveforms[waveform]->get_float;      csource->get_value_array = waveforms[waveform]->get_float_value_array;      break;    }    case G_TYPE_DOUBLE:{      csource->get_value = waveforms[waveform]->get_double;      csource->get_value_array = waveforms[waveform]->get_double_value_array;      break;    }    default:      ret = FALSE;      break;  }  if (ret)    self->priv->waveform = waveform;  else    GST_WARNING ("incomplete implementation for type '%s'",        GST_STR_NULL (g_type_name (self->priv->type)));  return ret;}static gbooleangst_lfo_control_source_bind (GstControlSource * source, GParamSpec * pspec){  GType type, base;  GstLFOControlSource *self = GST_LFO_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;  switch (base) {    case G_TYPE_INT:{      GParamSpecInt *tpspec = G_PARAM_SPEC_INT (pspec);      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);      if (!G_IS_VALUE (&self->priv->amplitude)) {        g_value_init (&self->priv->amplitude, type);        g_value_set_int (&self->priv->amplitude, 0);      }      if (!G_IS_VALUE (&self->priv->offset)) {        g_value_init (&self->priv->offset, type);        g_value_set_int (&self->priv->offset, tpspec->default_value);      }      break;    }    case G_TYPE_UINT:{      GParamSpecUInt *tpspec = G_PARAM_SPEC_UINT (pspec);      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);      if (!G_IS_VALUE (&self->priv->amplitude)) {        g_value_init (&self->priv->amplitude, type);        g_value_set_uint (&self->priv->amplitude, 0);      }      if (!G_IS_VALUE (&self->priv->offset)) {        g_value_init (&self->priv->offset, type);        g_value_set_uint (&self->priv->offset, tpspec->default_value);      }      break;    }    case G_TYPE_LONG:{      GParamSpecLong *tpspec = G_PARAM_SPEC_LONG (pspec);      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);      if (!G_IS_VALUE (&self->priv->amplitude)) {        g_value_init (&self->priv->amplitude, type);        g_value_set_long (&self->priv->amplitude, 0);      }      if (!G_IS_VALUE (&self->priv->offset)) {        g_value_init (&self->priv->offset, type);        g_value_set_long (&self->priv->offset, tpspec->default_value);      }      break;    }    case G_TYPE_ULONG:{      GParamSpecULong *tpspec = G_PARAM_SPEC_ULONG (pspec);      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);

⌨️ 快捷键说明

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