summaryrefslogtreecommitdiff
path: root/gst/interlace
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2012-06-26 16:33:54 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2012-06-26 16:39:56 +0200
commitc0cd1c43aba7a010030cf76594801d9ce39df3bb (patch)
tree0dfa51d1f5c5243db272d0a52ca4900ba0bbd9d1 /gst/interlace
parentad5b76a58d1f30a1b7c4063a3b64ce66a8e35c01 (diff)
downloadgstreamer-plugins-bad-c0cd1c43aba7a010030cf76594801d9ce39df3bb.tar.gz
interlace: port to 0.11
Diffstat (limited to 'gst/interlace')
-rw-r--r--gst/interlace/gstinterlace.c474
1 files changed, 211 insertions, 263 deletions
diff --git a/gst/interlace/gstinterlace.c b/gst/interlace/gstinterlace.c
index 9fe97e1c3..3bc0a07e4 100644
--- a/gst/interlace/gstinterlace.c
+++ b/gst/interlace/gstinterlace.c
@@ -86,7 +86,6 @@ struct _GstInterlace
GstPad *srcpad;
GstPad *sinkpad;
- GstCaps *srccaps;
/* properties */
gboolean top_field_first;
@@ -94,9 +93,7 @@ struct _GstInterlace
gboolean allow_rff;
/* state */
- int width;
- int height;
- GstVideoFormat format;
+ GstVideoInfo info;
int src_fps_n;
int src_fps_d;
@@ -158,80 +155,43 @@ static GstStaticPadTemplate gst_interlace_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE
("{AYUV,YUY2,UYVY,I420,YV12,Y42B,Y444,NV12,NV21}")
- ",interlaced=TRUE")
+ ",interlace-mode=mixed")
);
static GstStaticPadTemplate gst_interlace_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE
("{AYUV,YUY2,UYVY,I420,YV12,Y42B,Y444,NV12,NV21}")
- ",interlaced=FALSE")
+ ",interlace-mode=progressive")
);
-static void gst_interlace_base_init (gpointer g_class);
-static void gst_interlace_class_init (GstInterlaceClass * klass);
-static void gst_interlace_init (GstInterlace * interlace);
-static gboolean gst_interlace_sink_event (GstPad * pad, GstEvent * event);
-static GstFlowReturn gst_interlace_chain (GstPad * pad, GstBuffer * buffer);
+GType gst_interlace_get_type (void);
+static void gst_interlace_finalize (GObject * obj);
static void gst_interlace_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
static void gst_interlace_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
-static gboolean gst_interlace_setcaps (GstPad * pad, GstCaps * caps);
-static GstCaps *gst_interlace_getcaps (GstPad * pad);
-static GstStateChangeReturn gst_interlace_change_state (GstElement * element,
- GstStateChange transition);
-static void gst_interlace_finalize (GObject * obj);
-
-static GstElementClass *parent_class = NULL;
-
-
-static GType
-gst_interlace_get_type (void)
-{
- static GType interlace_type = 0;
-
- if (!interlace_type) {
- static const GTypeInfo interlace_info = {
- sizeof (GstInterlaceClass),
- gst_interlace_base_init,
- NULL,
- (GClassInitFunc) gst_interlace_class_init,
- NULL,
- NULL,
- sizeof (GstInterlace),
- 0,
- (GInstanceInitFunc) gst_interlace_init,
- };
-
- interlace_type = g_type_register_static (GST_TYPE_ELEMENT,
- "GstInterlace", &interlace_info, 0);
- }
-
- return interlace_type;
-}
+static gboolean gst_interlace_sink_event (GstPad * pad, GstObject * parent,
+ GstEvent * event);
+static gboolean gst_interlace_sink_query (GstPad * pad, GstObject * parent,
+ GstQuery * query);
+static GstFlowReturn gst_interlace_chain (GstPad * pad, GstObject * parent,
+ GstBuffer * buffer);
-static void
-gst_interlace_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+static gboolean gst_interlace_src_query (GstPad * pad, GstObject * parent,
+ GstQuery * query);
- gst_element_class_set_details_simple (element_class,
- "Interlace filter", "Filter/Video",
- "Creates an interlaced video from progressive frames",
- "David Schleef <ds@schleef.org>");
+static GstStateChangeReturn gst_interlace_change_state (GstElement * element,
+ GstStateChange transition);
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_interlace_sink_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_interlace_src_template));
-}
+#define gst_interlace_parent_class parent_class
+G_DEFINE_TYPE (GstInterlace, gst_interlace, GST_TYPE_ELEMENT);
static void
gst_interlace_class_init (GstInterlaceClass * klass)
@@ -245,8 +205,6 @@ gst_interlace_class_init (GstInterlaceClass * klass)
object_class->get_property = gst_interlace_get_property;
object_class->finalize = gst_interlace_finalize;
- element_class->change_state = gst_interlace_change_state;
-
g_object_class_install_property (object_class, PROP_TOP_FIELD_FIRST,
g_param_spec_boolean ("top-field-first", "top field first",
"Interlaced stream should be top field first", FALSE,
@@ -268,15 +226,22 @@ gst_interlace_class_init (GstInterlaceClass * klass)
"Allow generation of buffers with RFF flag set, i.e., duration of 3 fields",
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ gst_element_class_set_details_simple (element_class,
+ "Interlace filter", "Filter/Video",
+ "Creates an interlaced video from progressive frames",
+ "David Schleef <ds@schleef.org>");
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_interlace_sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_interlace_src_template));
+
+ element_class->change_state = gst_interlace_change_state;
}
static void
gst_interlace_finalize (GObject * obj)
{
- GstInterlace *interlace = GST_INTERLACE (obj);
-
- gst_caps_replace (&interlace->srccaps, NULL);
-
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -286,6 +251,10 @@ gst_interlace_reset (GstInterlace * interlace)
interlace->phase_index = interlace->pattern_offset;
interlace->timebase = GST_CLOCK_TIME_NONE;
interlace->field_index = 0;
+ if (interlace->stored_frame) {
+ gst_buffer_unref (interlace->stored_frame);
+ interlace->stored_frame = NULL;
+ }
}
static void
@@ -294,17 +263,15 @@ gst_interlace_init (GstInterlace * interlace)
GST_DEBUG ("gst_interlace_init");
interlace->sinkpad =
gst_pad_new_from_static_template (&gst_interlace_sink_template, "sink");
- gst_element_add_pad (GST_ELEMENT (interlace), interlace->sinkpad);
gst_pad_set_chain_function (interlace->sinkpad, gst_interlace_chain);
- gst_pad_set_setcaps_function (interlace->sinkpad, gst_interlace_setcaps);
- gst_pad_set_getcaps_function (interlace->sinkpad, gst_interlace_getcaps);
gst_pad_set_event_function (interlace->sinkpad, gst_interlace_sink_event);
+ gst_pad_set_query_function (interlace->sinkpad, gst_interlace_sink_query);
+ gst_element_add_pad (GST_ELEMENT (interlace), interlace->sinkpad);
interlace->srcpad =
gst_pad_new_from_static_template (&gst_interlace_src_template, "src");
+ gst_pad_set_query_function (interlace->srcpad, gst_interlace_src_query);
gst_element_add_pad (GST_ELEMENT (interlace), interlace->srcpad);
- gst_pad_set_setcaps_function (interlace->srcpad, gst_interlace_setcaps);
- gst_pad_set_getcaps_function (interlace->srcpad, gst_interlace_getcaps);
interlace->top_field_first = FALSE;
interlace->allow_rff = FALSE;
@@ -353,35 +320,67 @@ gst_interlace_decorate_buffer (GstInterlace * interlace, GstBuffer * buf,
gst_util_uint64_scale (GST_SECOND, interlace->src_fps_d * n_fields,
interlace->src_fps_n * 2);
}
- /* increment the buffer timestamp by duration for the next buffer */
- gst_buffer_set_caps (buf, interlace->srccaps);
if (interlace->field_index == 0) {
- GST_BUFFER_FLAG_SET (buf, GST_VIDEO_BUFFER_TFF);
+ GST_BUFFER_FLAG_SET (buf, GST_VIDEO_BUFFER_FLAG_TFF);
}
if (n_fields == 3) {
- GST_BUFFER_FLAG_SET (buf, GST_VIDEO_BUFFER_RFF);
+ GST_BUFFER_FLAG_SET (buf, GST_VIDEO_BUFFER_FLAG_RFF);
}
if (n_fields == 1) {
- GST_BUFFER_FLAG_SET (buf, GST_VIDEO_BUFFER_ONEFIELD);
+ GST_BUFFER_FLAG_SET (buf, GST_VIDEO_BUFFER_FLAG_ONEFIELD);
+ }
+}
+
+static gboolean
+gst_interlace_setcaps (GstInterlace * interlace, GstCaps * caps)
+{
+ gboolean ret;
+ GstVideoInfo info;
+ GstCaps *othercaps;
+ const PulldownFormat *pdformat;
+
+ if (!gst_video_info_from_caps (&info, caps))
+ goto caps_error;
+
+ othercaps = gst_caps_copy (caps);
+ pdformat = &formats[interlace->pattern];
+
+ interlace->phase_index = interlace->pattern_offset;
+
+ interlace->src_fps_n = info.fps_n * pdformat->ratio_n;
+ interlace->src_fps_d = info.fps_d * pdformat->ratio_d;
+
+ gst_caps_set_simple (othercaps, "interlace-mode", G_TYPE_STRING, "mixed",
+ NULL);
+ gst_caps_set_simple (othercaps, "framerate", GST_TYPE_FRACTION,
+ interlace->src_fps_n, interlace->src_fps_d, NULL);
+
+ ret = gst_pad_set_caps (interlace->srcpad, othercaps);
+ gst_caps_unref (othercaps);
+
+ interlace->info = info;
+
+ return ret;
+
+caps_error:
+ {
+ GST_DEBUG_OBJECT (interlace, "error parsing caps");
+ return FALSE;
}
}
static gboolean
-gst_interlace_sink_event (GstPad * pad, GstEvent * event)
+gst_interlace_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
gboolean ret;
GstInterlace *interlace;
- interlace = GST_INTERLACE (gst_pad_get_parent (pad));
+ interlace = GST_INTERLACE (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
GST_DEBUG_OBJECT (interlace, "handling FLUSH_START");
- if (interlace->stored_frame) {
- gst_buffer_unref (interlace->stored_frame);
- interlace->stored_frame = NULL;
- }
ret = gst_pad_push_event (interlace->srcpad, event);
break;
case GST_EVENT_FLUSH_STOP:
@@ -440,220 +439,174 @@ gst_interlace_sink_event (GstPad * pad, GstEvent * event)
ret = gst_pad_push_event (interlace->srcpad, event);
break;
+ case GST_EVENT_CAPS:
+ {
+ GstCaps *caps;
+
+ gst_event_parse_caps (event, &caps);
+ ret = gst_interlace_setcaps (interlace, caps);
+ gst_event_unref (event);
+ break;
+ }
default:
ret = gst_pad_push_event (interlace->srcpad, event);
break;
}
- g_object_unref (interlace);
-
return ret;
}
static GstCaps *
-gst_interlace_getcaps (GstPad * pad)
+gst_interlace_getcaps (GstPad * pad, GstInterlace * interlace, GstCaps * filter)
{
- GstInterlace *interlace;
GstPad *otherpad;
- GstCaps *othercaps;
+ GstCaps *othercaps, *tcaps;
GstCaps *icaps;
- interlace = GST_INTERLACE (gst_pad_get_parent (pad));
-
otherpad =
(pad == interlace->srcpad) ? interlace->sinkpad : interlace->srcpad;
- othercaps = gst_pad_peer_get_caps (otherpad);
- if (othercaps == NULL) {
- icaps = gst_caps_copy (gst_pad_get_pad_template_caps (otherpad));
- } else {
- icaps = gst_caps_intersect (othercaps,
- gst_pad_get_pad_template_caps (otherpad));
+ tcaps = gst_pad_get_pad_template_caps (otherpad);
+ othercaps = gst_pad_peer_query_caps (otherpad, filter);
+
+ if (othercaps) {
+ icaps = gst_caps_intersect (othercaps, tcaps);
gst_caps_unref (othercaps);
+ } else {
+ icaps = tcaps;
+ }
+
+ if (filter) {
+ othercaps = gst_caps_intersect (icaps, filter);
+ gst_caps_unref (icaps);
+ icaps = othercaps;
}
- gst_caps_set_simple (icaps, "interlaced", G_TYPE_BOOLEAN,
- pad == interlace->srcpad ? TRUE : FALSE, NULL);
+ icaps = gst_caps_make_writable (icaps);
+ gst_caps_set_simple (icaps, "interlace-mode", G_TYPE_STRING,
+ pad == interlace->srcpad ? "mixed" : "progressive", NULL);
- gst_object_unref (interlace);
+ gst_caps_unref (tcaps);
return icaps;
}
static gboolean
-gst_interlace_setcaps (GstPad * pad, GstCaps * caps)
+gst_interlace_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
- GstInterlace *interlace;
gboolean ret;
- int width, height;
- GstVideoFormat format;
- gboolean interlaced = TRUE;
- int fps_n, fps_d;
- GstPad *otherpad;
- GstCaps *othercaps = NULL;
- const PulldownFormat *pdformat;
-
- interlace = GST_INTERLACE (gst_pad_get_parent (pad));
-
- otherpad =
- (pad == interlace->srcpad) ? interlace->sinkpad : interlace->srcpad;
-
- ret = gst_video_format_parse_caps (caps, &format, &width, &height);
- gst_video_format_parse_caps_interlaced (caps, &interlaced);
- ret &= gst_video_parse_caps_framerate (caps, &fps_n, &fps_d);
+ GstInterlace *interlace;
- if (!ret)
- goto error;
+ interlace = GST_INTERLACE (parent);
- othercaps = gst_caps_copy (caps);
- pdformat = &formats[interlace->pattern];
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
- if (pad == interlace->srcpad) {
- gst_caps_set_simple (othercaps, "interlaced", G_TYPE_BOOLEAN, FALSE, NULL);
- gst_caps_set_simple (othercaps, "framerate", GST_TYPE_FRACTION,
- fps_n * pdformat->ratio_d, fps_d * pdformat->ratio_n, NULL);
- } else {
- gst_caps_set_simple (othercaps, "interlaced", G_TYPE_BOOLEAN, TRUE, NULL);
- gst_caps_set_simple (othercaps, "framerate", GST_TYPE_FRACTION,
- fps_n * pdformat->ratio_n, fps_d * pdformat->ratio_d, NULL);
+ gst_query_parse_caps (query, &filter);
+ caps = gst_interlace_getcaps (pad, interlace, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+ ret = TRUE;
+ break;
+ }
+ default:
+ ret = gst_pad_query_default (pad, parent, query);
+ break;
}
+ return ret;
+}
- ret = gst_pad_set_caps (otherpad, othercaps);
- if (!ret)
- goto error;
+static gboolean
+gst_interlace_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
+{
+ gboolean ret;
+ GstInterlace *interlace;
- interlace->format = format;
- interlace->width = width;
- interlace->height = height;
+ interlace = GST_INTERLACE (parent);
- interlace->phase_index = interlace->pattern_offset;
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_CAPS:
+ {
+ GstCaps *filter, *caps;
- if (pad == interlace->sinkpad) {
- gst_caps_replace (&interlace->srccaps, othercaps);
- interlace->src_fps_n = fps_n * pdformat->ratio_n;
- interlace->src_fps_d = fps_d * pdformat->ratio_d;
- } else {
- gst_caps_replace (&interlace->srccaps, caps);
- interlace->src_fps_n = fps_n;
- interlace->src_fps_d = fps_d;
+ gst_query_parse_caps (query, &filter);
+ caps = gst_interlace_getcaps (pad, interlace, filter);
+ gst_query_set_caps_result (query, caps);
+ gst_caps_unref (caps);
+ ret = TRUE;
+ break;
+ }
+ default:
+ ret = gst_pad_query_default (pad, parent, query);
+ break;
}
-
-error:
- if (othercaps)
- gst_caps_unref (othercaps);
- g_object_unref (interlace);
-
return ret;
}
static void
-copy_field (GstInterlace * interlace, GstBuffer * d, GstBuffer * s,
+copy_field (GstInterlace * interlace, GstBuffer * dest, GstBuffer * src,
int field_index)
{
- int j;
- guint8 *dest;
- guint8 *src;
- int width = interlace->width;
- int height = interlace->height;
-
- if (interlace->format == GST_VIDEO_FORMAT_I420 ||
- interlace->format == GST_VIDEO_FORMAT_YV12) {
- /* planar 4:2:0 */
- for (j = field_index; j < height; j += 2) {
- dest = GST_BUFFER_DATA (d) + j * width;
- src = GST_BUFFER_DATA (s) + j * width;
- memcpy (dest, src, width);
- }
- for (j = field_index; j < height / 2; j += 2) {
- dest = GST_BUFFER_DATA (d) + width * height + j * width / 2;
- src = GST_BUFFER_DATA (s) + width * height + j * width / 2;
- memcpy (dest, src, width / 2);
- }
- for (j = field_index; j < height / 2; j += 2) {
- dest =
- GST_BUFFER_DATA (d) + width * height + width / 2 * height / 2 +
- j * width / 2;
- src =
- GST_BUFFER_DATA (s) + width * height + width / 2 * height / 2 +
- j * width / 2;
- memcpy (dest, src, width / 2);
- }
- } else if (interlace->format == GST_VIDEO_FORMAT_UYVY ||
- interlace->format == GST_VIDEO_FORMAT_YUY2) {
- /* packed 4:2:2 */
- for (j = field_index; j < height; j += 2) {
- dest = GST_BUFFER_DATA (d) + j * width * 2;
- src = GST_BUFFER_DATA (s) + j * width * 2;
- memcpy (dest, src, width * 2);
- }
- } else if (interlace->format == GST_VIDEO_FORMAT_AYUV) {
- /* packed 4:4:4 */
- for (j = field_index; j < height; j += 2) {
- dest = GST_BUFFER_DATA (d) + j * width * 4;
- src = GST_BUFFER_DATA (s) + j * width * 4;
- memcpy (dest, src, width * 4);
- }
- } else if (interlace->format == GST_VIDEO_FORMAT_Y42B) {
- /* planar 4:2:2 */
- for (j = field_index; j < height; j += 2) {
- dest = GST_BUFFER_DATA (d) + j * width;
- src = GST_BUFFER_DATA (s) + j * width;
- memcpy (dest, src, width);
- }
- for (j = field_index; j < height; j += 2) {
- dest = GST_BUFFER_DATA (d) + width * height + j * width / 2;
- src = GST_BUFFER_DATA (s) + width * height + j * width / 2;
- memcpy (dest, src, width / 2);
- }
- for (j = field_index; j < height; j += 2) {
- dest =
- GST_BUFFER_DATA (d) + width * height + width / 2 * height +
- j * width / 2;
- src =
- GST_BUFFER_DATA (s) + width * height + width / 2 * height +
- j * width / 2;
- memcpy (dest, src, width / 2);
- }
- } else if (interlace->format == GST_VIDEO_FORMAT_Y444) {
- /* planar 4:4:4 */
- for (j = field_index; j < height; j += 2) {
- dest = GST_BUFFER_DATA (d) + j * width;
- src = GST_BUFFER_DATA (s) + j * width;
- memcpy (dest, src, width);
- }
- for (j = field_index; j < height; j += 2) {
- dest = GST_BUFFER_DATA (d) + width * height + j * width;
- src = GST_BUFFER_DATA (s) + width * height + j * width;
- memcpy (dest, src, width);
- }
- for (j = field_index; j < height; j += 2) {
- dest = GST_BUFFER_DATA (d) + width * height + width * height + j * width;
- src = GST_BUFFER_DATA (s) + width * height + width * height + j * width;
- memcpy (dest, src, width);
- }
- } else if (interlace->format == GST_VIDEO_FORMAT_NV12 ||
- interlace->format == GST_VIDEO_FORMAT_NV21) {
- /* planar/packed 4:2:0 */
- for (j = field_index; j < height; j += 2) {
- dest = GST_BUFFER_DATA (d) + j * width;
- src = GST_BUFFER_DATA (s) + j * width;
- memcpy (dest, src, width);
- }
- for (j = field_index; j < height / 2; j += 2) {
- dest = GST_BUFFER_DATA (d) + width * height + j * width;
- src = GST_BUFFER_DATA (s) + width * height + j * width;
- memcpy (dest, src, width);
+ GstVideoInfo *info = &interlace->info;
+ gint i, j, n_planes;
+ guint8 *d, *s;
+ GstVideoFrame dframe, sframe;
+
+ if (!gst_video_frame_map (&dframe, info, dest, GST_MAP_WRITE))
+ goto dest_map_failed;
+
+ if (!gst_video_frame_map (&sframe, info, src, GST_MAP_READ))
+ goto src_map_failed;
+
+ n_planes = GST_VIDEO_FRAME_N_PLANES (&dframe);
+
+ for (i = 0; i < n_planes; i++) {
+ gint cheight, cwidth;
+ gint ss, ds;
+
+ d = GST_VIDEO_FRAME_PLANE_DATA (&dframe, i);
+ s = GST_VIDEO_FRAME_PLANE_DATA (&sframe, i);
+
+ ds = GST_VIDEO_FRAME_PLANE_STRIDE (&dframe, i);
+ ss = GST_VIDEO_FRAME_PLANE_STRIDE (&sframe, i);
+
+ d += field_index * ds;
+ s += field_index * ss;
+
+ cheight = GST_VIDEO_FRAME_COMP_HEIGHT (&dframe, i);
+ cwidth = MIN (ABS (ss), ABS (ds));
+
+ for (j = field_index; j < cheight; j += 2) {
+ memcpy (d, s, cwidth);
+ d += ds * 2;
+ s += ss * 2;
}
- } else {
- g_assert_not_reached ();
+ }
+
+ gst_video_frame_unmap (&dframe);
+ gst_video_frame_unmap (&sframe);
+ return;
+
+dest_map_failed:
+ {
+ GST_ERROR_OBJECT (interlace, "failed to map dest");
+ return;
+ }
+src_map_failed:
+ {
+ GST_ERROR_OBJECT (interlace, "failed to map src");
+ gst_video_frame_unmap (&dframe);
+ return;
}
}
static GstFlowReturn
-gst_interlace_chain (GstPad * pad, GstBuffer * buffer)
+gst_interlace_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
- GstInterlace *interlace = GST_INTERLACE (gst_pad_get_parent (pad));
+ GstInterlace *interlace = GST_INTERLACE (parent);
GstFlowReturn ret = GST_FLOW_OK;
gint num_fields = 0;
int current_fields;
@@ -668,10 +621,10 @@ gst_interlace_chain (GstPad * pad, GstBuffer * buffer)
GST_DEBUG ("duration %" GST_TIME_FORMAT " flags %04x %s %s %s",
GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)),
GST_BUFFER_FLAGS (buffer),
- (GST_BUFFER_FLAGS (buffer) & GST_VIDEO_BUFFER_TFF) ? "tff" : "",
- (GST_BUFFER_FLAGS (buffer) & GST_VIDEO_BUFFER_RFF) ? "rff" : "",
- (GST_BUFFER_FLAGS (buffer) & GST_VIDEO_BUFFER_ONEFIELD) ? "onefield" :
- "");
+ (GST_BUFFER_FLAGS (buffer) & GST_VIDEO_BUFFER_FLAG_TFF) ? "tff" : "",
+ (GST_BUFFER_FLAGS (buffer) & GST_VIDEO_BUFFER_FLAG_RFF) ? "rff" : "",
+ (GST_BUFFER_FLAGS (buffer) & GST_VIDEO_BUFFER_FLAG_ONEFIELD) ? "onefield"
+ : "");
if (GST_BUFFER_FLAGS (buffer) & GST_BUFFER_FLAG_DISCONT) {
GST_DEBUG ("discont");
@@ -723,7 +676,7 @@ gst_interlace_chain (GstPad * pad, GstBuffer * buffer)
if (interlace->stored_fields > 0) {
GST_DEBUG ("1 field from stored, 1 from current");
- output_buffer = gst_buffer_new_and_alloc (GST_BUFFER_SIZE (buffer));
+ output_buffer = gst_buffer_new_and_alloc (gst_buffer_get_size (buffer));
/* take the first field from the stored frame */
copy_field (interlace, output_buffer, interlace->stored_frame,
interlace->field_index);
@@ -733,8 +686,7 @@ gst_interlace_chain (GstPad * pad, GstBuffer * buffer)
current_fields--;
n_output_fields = 2;
} else {
- output_buffer =
- gst_buffer_make_metadata_writable (gst_buffer_ref (buffer));
+ output_buffer = gst_buffer_make_writable (gst_buffer_ref (buffer));
if (num_fields >= 3 && interlace->allow_rff) {
GST_DEBUG ("3 fields from current");
/* take both fields from incoming buffer */
@@ -758,9 +710,11 @@ gst_interlace_chain (GstPad * pad, GstBuffer * buffer)
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (output_buffer)),
GST_TIME_ARGS (GST_BUFFER_DURATION (output_buffer)),
GST_BUFFER_FLAGS (output_buffer),
- (GST_BUFFER_FLAGS (output_buffer) & GST_VIDEO_BUFFER_TFF) ? "tff" : "",
- (GST_BUFFER_FLAGS (output_buffer) & GST_VIDEO_BUFFER_RFF) ? "rff" : "",
- (GST_BUFFER_FLAGS (output_buffer) & GST_VIDEO_BUFFER_ONEFIELD) ?
+ (GST_BUFFER_FLAGS (output_buffer) & GST_VIDEO_BUFFER_FLAG_TFF) ? "tff" :
+ "",
+ (GST_BUFFER_FLAGS (output_buffer) & GST_VIDEO_BUFFER_FLAG_RFF) ? "rff" :
+ "",
+ (GST_BUFFER_FLAGS (output_buffer) & GST_VIDEO_BUFFER_FLAG_ONEFIELD) ?
"onefield" : "");
ret = gst_pad_push (interlace->srcpad, output_buffer);
@@ -784,9 +738,6 @@ gst_interlace_chain (GstPad * pad, GstBuffer * buffer)
} else {
gst_buffer_unref (buffer);
}
-
- gst_object_unref (interlace);
-
return ret;
}
@@ -853,10 +804,7 @@ gst_interlace_change_state (GstElement * element, GstStateChange transition)
break;
}
- if (parent_class->change_state)
- return parent_class->change_state (element, transition);
-
- return GST_STATE_CHANGE_SUCCESS;
+ return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
}
static gboolean