summaryrefslogtreecommitdiffstats
path: root/gst/frei0r
diff options
context:
space:
mode:
Diffstat (limited to 'gst/frei0r')
-rw-r--r--gst/frei0r/gstfrei0r.c47
-rw-r--r--gst/frei0r/gstfrei0rfilter.c27
-rw-r--r--gst/frei0r/gstfrei0rfilter.h2
-rw-r--r--gst/frei0r/gstfrei0rmixer.c29
-rw-r--r--gst/frei0r/gstfrei0rsrc.c26
5 files changed, 86 insertions, 45 deletions
diff --git a/gst/frei0r/gstfrei0r.c b/gst/frei0r/gstfrei0r.c
index 0f7ba5c5..3cfc939b 100644
--- a/gst/frei0r/gstfrei0r.c
+++ b/gst/frei0r/gstfrei0r.c
@@ -86,51 +86,71 @@ gst_frei0r_klass_install_properties (GObjectClass * gobject_class,
case F0R_PARAM_BOOL:
g_object_class_install_property (gobject_class, count++,
g_param_spec_boolean (prop_name, param_info->name,
- param_info->explanation, FALSE,
+ param_info->explanation, properties[i].default_value.data.b,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
properties[i].n_prop_ids = 1;
break;
- case F0R_PARAM_DOUBLE:
+ case F0R_PARAM_DOUBLE:{
+ gdouble def = properties[i].default_value.data.d;
+
+ /* If the default is NAN, +-INF we use 0.0 */
+ if (!(def <= G_MAXDOUBLE && def >= -G_MAXDOUBLE))
+ def = 0.0;
+
g_object_class_install_property (gobject_class, count++,
g_param_spec_double (prop_name, param_info->name,
- param_info->explanation, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
+ param_info->explanation, -G_MAXDOUBLE, G_MAXDOUBLE, def,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
properties[i].n_prop_ids = 1;
break;
+ }
case F0R_PARAM_STRING:
g_object_class_install_property (gobject_class, count++,
g_param_spec_string (prop_name, param_info->name,
- param_info->explanation, NULL,
+ param_info->explanation, properties[i].default_value.data.s,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
properties[i].n_prop_ids = 1;
break;
case F0R_PARAM_COLOR:{
gchar *prop_name_full;
gchar *prop_nick_full;
+ gdouble def;
+ def = properties[i].default_value.data.color.r;
+ /* If the default is out of range we use 0.0 */
+ if (!(def <= 1.0 && def >= 0.0))
+ def = 0.0;
prop_name_full = g_strconcat (prop_name, "-r", NULL);
prop_nick_full = g_strconcat (param_info->name, "-R", NULL);
g_object_class_install_property (gobject_class, count++,
g_param_spec_float (prop_name_full, prop_nick_full,
- param_info->explanation, 0.0, 1.0, 0.0,
+ param_info->explanation, 0.0, 1.0, def,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
g_free (prop_name_full);
g_free (prop_nick_full);
+ def = properties[i].default_value.data.color.g;
+ /* If the default is out of range we use 0.0 */
+ if (!(def <= 1.0 && def >= 0.0))
+ def = 0.0;
prop_name_full = g_strconcat (prop_name, "-g", NULL);
prop_nick_full = g_strconcat (param_info->name, "-G", NULL);
g_object_class_install_property (gobject_class, count++,
g_param_spec_float (prop_name_full, param_info->name,
- param_info->explanation, 0.0, 1.0, 0.0,
+ param_info->explanation, 0.0, 1.0, def,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
g_free (prop_name_full);
g_free (prop_nick_full);
+ def = properties[i].default_value.data.color.b;
+ /* If the default is out of range we use 0.0 */
+ if (!(def <= 1.0 && def >= 0.0))
+ def = 0.0;
prop_name_full = g_strconcat (prop_name, "-b", NULL);
prop_nick_full = g_strconcat (param_info->name, "-B", NULL);
g_object_class_install_property (gobject_class, count++,
g_param_spec_float (prop_name_full, param_info->name,
- param_info->explanation, 0.0, 1.0, 0.0,
+ param_info->explanation, 0.0, 1.0, def,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
g_free (prop_name_full);
g_free (prop_nick_full);
@@ -141,21 +161,30 @@ gst_frei0r_klass_install_properties (GObjectClass * gobject_class,
case F0R_PARAM_POSITION:{
gchar *prop_name_full;
gchar *prop_nick_full;
+ gdouble def;
+ def = properties[i].default_value.data.position.x;
+ /* If the default is out of range we use 0.0 */
+ if (!(def <= 1.0 && def >= 0.0))
+ def = 0.0;
prop_name_full = g_strconcat (prop_name, "-x", NULL);
prop_nick_full = g_strconcat (param_info->name, "-X", NULL);
g_object_class_install_property (gobject_class, count++,
g_param_spec_double (prop_name_full, param_info->name,
- param_info->explanation, 0.0, 1.0, 0.0,
+ param_info->explanation, 0.0, 1.0, def,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
g_free (prop_name_full);
g_free (prop_nick_full);
+ def = properties[i].default_value.data.position.y;
+ /* If the default is out of range we use 0.0 */
+ if (!(def <= 1.0 && def >= 0.0))
+ def = 0.0;
prop_name_full = g_strconcat (prop_name, "-Y", NULL);
prop_nick_full = g_strconcat (param_info->name, "-X", NULL);
g_object_class_install_property (gobject_class, count++,
g_param_spec_double (prop_name_full, param_info->name,
- param_info->explanation, 0.0, 1.0, 0.0,
+ param_info->explanation, 0.0, 1.0, def,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
g_free (prop_name_full);
g_free (prop_nick_full);
diff --git a/gst/frei0r/gstfrei0rfilter.c b/gst/frei0r/gstfrei0rfilter.c
index 43d8fc67..eda78adf 100644
--- a/gst/frei0r/gstfrei0rfilter.c
+++ b/gst/frei0r/gstfrei0rfilter.c
@@ -40,22 +40,11 @@ gst_frei0r_filter_set_caps (GstBaseTransform * trans, GstCaps * incaps,
GstCaps * outcaps)
{
GstFrei0rFilter *self = GST_FREI0R_FILTER (trans);
- GstFrei0rFilterClass *klass = GST_FREI0R_FILTER_GET_CLASS (trans);
GstVideoFormat fmt;
- gint width, height;
- if (!gst_video_format_parse_caps (incaps, &fmt, &width, &height))
+ if (!gst_video_format_parse_caps (incaps, &fmt, &self->width, &self->height))
return FALSE;
- if (self->f0r_instance) {
- klass->ftable->destruct (self->f0r_instance);
- self->f0r_instance = NULL;
- }
-
- self->f0r_instance =
- gst_frei0r_instance_construct (klass->ftable, klass->properties,
- klass->n_properties, self->property_cache, width, height);
-
return TRUE;
}
@@ -70,6 +59,8 @@ gst_frei0r_filter_stop (GstBaseTransform * trans)
self->f0r_instance = NULL;
}
+ self->width = self->height = 0;
+
return TRUE;
}
@@ -81,9 +72,17 @@ gst_frei0r_filter_transform (GstBaseTransform * trans, GstBuffer * inbuf,
GstFrei0rFilterClass *klass = GST_FREI0R_FILTER_GET_CLASS (trans);
gdouble time;
- if (!self->f0r_instance)
+ if (G_UNLIKELY (self->width <= 0 || self->height <= 0))
return GST_FLOW_NOT_NEGOTIATED;
+ if (G_UNLIKELY (!self->f0r_instance)) {
+ self->f0r_instance =
+ gst_frei0r_instance_construct (klass->ftable, klass->properties,
+ klass->n_properties, self->property_cache, self->width, self->height);
+ if (G_UNLIKELY (!self->f0r_instance))
+ return GST_FLOW_ERROR;
+ }
+
time = ((gdouble) GST_BUFFER_TIMESTAMP (inbuf)) / GST_SECOND;
if (klass->ftable->update2)
@@ -195,6 +194,8 @@ gst_frei0r_filter_init (GstFrei0rFilter * self, GstFrei0rFilterClass * klass)
{
self->property_cache =
gst_frei0r_property_cache_init (klass->properties, klass->n_properties);
+ gst_pad_use_fixed_caps (GST_BASE_TRANSFORM_SINK_PAD (self));
+ gst_pad_use_fixed_caps (GST_BASE_TRANSFORM_SRC_PAD (self));
}
gboolean
diff --git a/gst/frei0r/gstfrei0rfilter.h b/gst/frei0r/gstfrei0rfilter.h
index ded2172b..b85c3f6e 100644
--- a/gst/frei0r/gstfrei0rfilter.h
+++ b/gst/frei0r/gstfrei0rfilter.h
@@ -42,6 +42,8 @@ typedef struct _GstFrei0rFilterClass GstFrei0rFilterClass;
struct _GstFrei0rFilter {
GstVideoFilter parent;
+ gint width, height;
+
f0r_instance_t *f0r_instance;
GstFrei0rPropertyValue *property_cache;
};
diff --git a/gst/frei0r/gstfrei0rmixer.c b/gst/frei0r/gstfrei0rmixer.c
index 745c330e..8f3ee4ba 100644
--- a/gst/frei0r/gstfrei0rmixer.c
+++ b/gst/frei0r/gstfrei0rmixer.c
@@ -45,8 +45,16 @@ gst_frei0r_mixer_reset (GstFrei0rMixer * self)
self->f0r_instance = NULL;
}
+ if (self->property_cache)
+ gst_frei0r_property_cache_free (klass->properties, self->property_cache,
+ klass->n_properties);
+ self->property_cache = NULL;
+
gst_caps_replace (&self->caps, NULL);
gst_event_replace (&self->newseg_event, NULL);
+
+ self->fmt = GST_VIDEO_FORMAT_UNKNOWN;
+ self->width = self->height = 0;
}
static void
@@ -195,7 +203,6 @@ static gboolean
gst_frei0r_mixer_set_caps (GstPad * pad, GstCaps * caps)
{
GstFrei0rMixer *self = GST_FREI0R_MIXER (gst_pad_get_parent (pad));
- GstFrei0rMixerClass *klass = GST_FREI0R_MIXER_GET_CLASS (self);
gboolean ret = TRUE;
gst_caps_replace (&self->caps, caps);
@@ -215,16 +222,6 @@ gst_frei0r_mixer_set_caps (GstPad * pad, GstCaps * caps)
ret = FALSE;
goto out;
}
-
- if (self->f0r_instance) {
- klass->ftable->destruct (self->f0r_instance);
- self->f0r_instance = NULL;
- }
-
- self->f0r_instance =
- gst_frei0r_instance_construct (klass->ftable, klass->properties,
- klass->n_properties, self->property_cache, self->width, self->height);
-
}
out:
@@ -543,9 +540,17 @@ gst_frei0r_mixer_collected (GstCollectPads * pads, GstFrei0rMixer * self)
GstFrei0rMixerClass *klass = GST_FREI0R_MIXER_GET_CLASS (self);
gdouble time;
- if (G_UNLIKELY (!self->f0r_instance))
+ if (G_UNLIKELY (self->width <= 0 || self->height <= 0))
return GST_FLOW_NOT_NEGOTIATED;
+ if (G_UNLIKELY (!self->f0r_instance)) {
+ self->f0r_instance =
+ gst_frei0r_instance_construct (klass->ftable, klass->properties,
+ klass->n_properties, self->property_cache, self->width, self->height);
+ if (G_UNLIKELY (!self->f0r_instance))
+ return GST_FLOW_ERROR;
+ }
+
if (self->newseg_event) {
gst_pad_push_event (self->src, self->newseg_event);
self->newseg_event = NULL;
diff --git a/gst/frei0r/gstfrei0rsrc.c b/gst/frei0r/gstfrei0rsrc.c
index a713e1e9..2d637f95 100644
--- a/gst/frei0r/gstfrei0rsrc.c
+++ b/gst/frei0r/gstfrei0rsrc.c
@@ -39,22 +39,12 @@ static gboolean
gst_frei0r_src_set_caps (GstBaseSrc * src, GstCaps * caps)
{
GstFrei0rSrc *self = GST_FREI0R_SRC (src);
- GstFrei0rSrcClass *klass = GST_FREI0R_SRC_GET_CLASS (src);
if (!gst_video_format_parse_caps (caps, &self->fmt, &self->width,
&self->height)
|| !gst_video_parse_caps_framerate (caps, &self->fps_n, &self->fps_d))
return FALSE;
- if (self->f0r_instance) {
- klass->ftable->destruct (self->f0r_instance);
- self->f0r_instance = NULL;
- }
-
- self->f0r_instance =
- gst_frei0r_instance_construct (klass->ftable, klass->properties,
- klass->n_properties, self->property_cache, self->width, self->height);
-
return TRUE;
}
@@ -80,9 +70,18 @@ gst_frei0r_src_create (GstPushSrc * src, GstBuffer ** buf)
*buf = NULL;
- if (G_UNLIKELY (!self->f0r_instance))
+ if (G_UNLIKELY (self->width <= 0 || self->height <= 0))
return GST_FLOW_NOT_NEGOTIATED;
+ if (G_UNLIKELY (!self->f0r_instance)) {
+ self->f0r_instance =
+ gst_frei0r_instance_construct (klass->ftable, klass->properties,
+ klass->n_properties, self->property_cache, self->width, self->height);
+
+ if (G_UNLIKELY (!self->f0r_instance))
+ return GST_FLOW_ERROR;
+ }
+
newsize = gst_video_format_get_size (self->fmt, self->width, self->height);
ret =
@@ -147,6 +146,11 @@ gst_frei0r_src_stop (GstBaseSrc * basesrc)
self->f0r_instance = NULL;
}
+ self->fmt = GST_VIDEO_FORMAT_UNKNOWN;
+ self->width = self->height = 0;
+ self->fps_n = self->fps_d = 0;
+ self->n_frames = 0;
+
return TRUE;
}