summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2008-06-27 13:22:34 +0000
committerSebastian Dröge <slomo@circular-chaos.org>2008-06-27 13:22:34 +0000
commitb1bc42dda060735f8795ebb5a21fc68e26261b2a (patch)
tree7bec8fd4025acb5f6c51d1fcca908a4c7510d14d /gst
parented52aa4949339123e81c530cebdb91ee28529479 (diff)
downloadgst-plugins-bad-b1bc42dda060735f8795ebb5a21fc68e26261b2a.tar.gz
gst-plugins-bad-b1bc42dda060735f8795ebb5a21fc68e26261b2a.tar.bz2
gst-plugins-bad-b1bc42dda060735f8795ebb5a21fc68e26261b2a.zip
gst/deinterlace2/gstdeinterlace2.c: If we're outputting all fields the framerate has to be doubled.
Original commit message from CVS: * gst/deinterlace2/gstdeinterlace2.c: (gst_deinterlace2_set_property), (gst_deinterlace2_chain), (gst_deinterlace2_setcaps): If we're outputting all fields the framerate has to be doubled. Set duration on the outgoing buffers.
Diffstat (limited to 'gst')
-rw-r--r--gst/deinterlace2/gstdeinterlace2.c59
1 files changed, 46 insertions, 13 deletions
diff --git a/gst/deinterlace2/gstdeinterlace2.c b/gst/deinterlace2/gstdeinterlace2.c
index a19ecda3..04ba4f01 100644
--- a/gst/deinterlace2/gstdeinterlace2.c
+++ b/gst/deinterlace2/gstdeinterlace2.c
@@ -337,9 +337,18 @@ gst_deinterlace2_set_property (GObject * _object, guint prop_id,
case ARG_METHOD:
gst_deinterlace2_set_method (object, g_value_get_enum (value));
break;
- case ARG_FIELDS:
+ case ARG_FIELDS:{
+ gint oldfields;
+
+ GST_OBJECT_LOCK (object);
+ oldfields = object->fields;
object->fields = g_value_get_enum (value);
+ if (object->fields != oldfields && GST_PAD_CAPS (object->srcpad))
+ gst_deinterlace2_setcaps (object->sinkpad,
+ GST_PAD_CAPS (object->sinkpad));
+ GST_OBJECT_UNLOCK (object);
break;
+ }
case ARG_FIELD_LAYOUT:
object->field_layout = g_value_get_enum (value);
break;
@@ -624,6 +633,12 @@ gst_deinterlace2_chain (GstPad * pad, GstBuffer * buf)
gst_buffer_unref (buf);
GST_BUFFER_TIMESTAMP (object->out_buf) = timestamp;
+ GST_BUFFER_DURATION (object->out_buf) =
+ GST_SECOND / object->frame_rate_d / object->frame_rate_n;
+ if (object->fields == GST_DEINTERLACE2_ALL)
+ GST_BUFFER_DURATION (object->out_buf) =
+ GST_BUFFER_DURATION (object->out_buf) / 2;
+
ret = gst_pad_push (object->srcpad, object->out_buf);
object->out_buf = NULL;
if (ret != GST_FLOW_OK)
@@ -662,6 +677,12 @@ gst_deinterlace2_chain (GstPad * pad, GstBuffer * buf)
gst_buffer_unref (buf);
GST_BUFFER_TIMESTAMP (object->out_buf) = timestamp;
+ GST_BUFFER_DURATION (object->out_buf) =
+ GST_SECOND / object->frame_rate_d / object->frame_rate_n;
+ if (object->fields == GST_DEINTERLACE2_ALL)
+ GST_BUFFER_DURATION (object->out_buf) =
+ GST_BUFFER_DURATION (object->out_buf) / 2;
+
ret = gst_pad_push (object->srcpad, object->out_buf);
object->out_buf = NULL;
@@ -676,8 +697,6 @@ gst_deinterlace2_chain (GstPad * pad, GstBuffer * buf)
buf = gst_deinterlace2_pop_history (object);
gst_buffer_unref (buf);
}
-
-
} else {
object->out_buf = gst_deinterlace2_pop_history (object);
ret = gst_pad_push (object->srcpad, object->out_buf);
@@ -694,23 +713,15 @@ static gboolean
gst_deinterlace2_setcaps (GstPad * pad, GstCaps * caps)
{
gboolean res = TRUE;
-
GstDeinterlace2 *object = GST_DEINTERLACE2 (gst_pad_get_parent (pad));
-
GstPad *otherpad;
-
GstStructure *structure;
-
GstVideoFormat fmt;
-
guint32 fourcc;
+ GstCaps *othercaps;
otherpad = (pad == object->srcpad) ? object->sinkpad : object->srcpad;
- if (!gst_pad_accept_caps (otherpad, caps)
- || !gst_pad_set_caps (otherpad, caps))
- goto caps_not_accepted;
-
structure = gst_caps_get_structure (caps, 0);
res = gst_structure_get_int (structure, "width", &object->frame_width);
@@ -723,6 +734,27 @@ gst_deinterlace2_setcaps (GstPad * pad, GstCaps * caps)
if (!res)
goto invalid_caps;
+ if (object->fields == GST_DEINTERLACE2_ALL) {
+ gint fps_n = object->frame_rate_n, fps_d = object->frame_rate_d;
+
+ othercaps = gst_caps_copy (caps);
+
+ if (otherpad == object->srcpad)
+ fps_n *= 2;
+ else
+ fps_d *= 2;
+
+ gst_caps_set_simple (othercaps, "framerate", GST_TYPE_FRACTION, fps_n,
+ fps_d, NULL);
+ } else {
+ othercaps = gst_caps_ref (caps);
+ }
+
+ if ( /*!gst_pad_accept_caps (otherpad, othercaps)
+ || */ !gst_pad_set_caps (otherpad, othercaps))
+ goto caps_not_accepted;
+ gst_caps_unref (othercaps);
+
/* TODO: introduce object->field_stride */
object->field_height = object->frame_height / 2;
@@ -756,7 +788,8 @@ invalid_caps:
caps_not_accepted:
res = FALSE;
- GST_ERROR_OBJECT (object, "Caps not accepted: %" GST_PTR_FORMAT, caps);
+ GST_ERROR_OBJECT (object, "Caps not accepted: %" GST_PTR_FORMAT, othercaps);
+ gst_caps_unref (othercaps);
goto done;
}