gst/: Bufferalloc changes.

Original commit message from CVS:
* gst/effectv/gstquark.c: (gst_quarktv_chain):
* gst/goom/gstgoom.c: (gst_goom_chain):
* gst/videobox/Makefile.am:
* gst/videobox/gstvideobox.c: (gst_video_box_class_init),
(gst_video_box_init), (gst_video_box_sink_setcaps),
(gst_video_box_chain):
* gst/videofilter/gstvideofilter.c: (gst_videofilter_chain):
* gst/videorate/gstvideorate.c: (gst_videorate_class_init),
(gst_videorate_getcaps), (gst_videorate_setcaps),
(gst_videorate_init), (gst_videorate_event), (gst_videorate_chain),
(gst_videorate_change_state):
Bufferalloc changes.
This commit is contained in:
Wim Taymans 2005-06-02 10:03:23 +00:00
parent a5d8b514c5
commit 9cc3258280
6 changed files with 77 additions and 53 deletions

View file

@ -1,3 +1,18 @@
2005-06-02 Wim Taymans <wim@fluendo.com>
* gst/effectv/gstquark.c: (gst_quarktv_chain):
* gst/goom/gstgoom.c: (gst_goom_chain):
* gst/videobox/Makefile.am:
* gst/videobox/gstvideobox.c: (gst_video_box_class_init),
(gst_video_box_init), (gst_video_box_sink_setcaps),
(gst_video_box_chain):
* gst/videofilter/gstvideofilter.c: (gst_videofilter_chain):
* gst/videorate/gstvideorate.c: (gst_videorate_class_init),
(gst_videorate_getcaps), (gst_videorate_setcaps),
(gst_videorate_init), (gst_videorate_event), (gst_videorate_chain),
(gst_videorate_change_state):
Bufferalloc changes.
2005-05-25 Wim Taymans <wim@fluendo.com>
* ext/mad/gstmad.c: (gst_mad_chain), (gst_mad_change_state):

View file

@ -237,6 +237,7 @@ gst_quarktv_chain (GstPad * pad, GstBuffer * buf)
guint32 *src, *dest;
GstBuffer *outbuf;
gint area;
GstFlowReturn ret;
filter = GST_QUARKTV (gst_pad_get_parent (pad));
@ -244,7 +245,12 @@ gst_quarktv_chain (GstPad * pad, GstBuffer * buf)
area = filter->area;
outbuf = gst_pad_alloc_buffer (filter->srcpad, 0, area, GST_PAD_CAPS (pad));
ret =
gst_pad_alloc_buffer (filter->srcpad, 0, area, GST_PAD_CAPS (pad),
&outbuf);
if (ret != GST_FLOW_OK)
goto no_buffer;
dest = (guint32 *) GST_BUFFER_DATA (outbuf);
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
@ -264,14 +270,18 @@ gst_quarktv_chain (GstPad * pad, GstBuffer * buf)
dest[area] = (rand ? ((guint32 *) GST_BUFFER_DATA (rand))[area] : 0);
}
gst_pad_push (filter->srcpad, outbuf);
ret = gst_pad_push (filter->srcpad, outbuf);
filter->current_plane--;
if (filter->current_plane < 0)
filter->current_plane = filter->planes - 1;
return GST_FLOW_OK;
return ret;
no_buffer:
{
return ret;
}
}
static GstElementStateReturn

View file

@ -391,8 +391,11 @@ gst_goom_chain (GstPad * pad, GstBuffer * bufin)
}
}
bufout = gst_pad_alloc_buffer (goom->srcpad, GST_BUFFER_OFFSET_NONE,
goom->width * goom->height * 4, GST_PAD_CAPS (goom->srcpad));
ret = gst_pad_alloc_buffer (goom->srcpad, GST_BUFFER_OFFSET_NONE,
goom->width * goom->height * 4, GST_PAD_CAPS (goom->srcpad), &bufout);
if (ret != GST_FLOW_OK)
break;
GST_BUFFER_TIMESTAMP (bufout) =
goom->audio_basetime +
(GST_SECOND * goom->samples_consumed / goom->sample_rate);

View file

@ -2,7 +2,7 @@
plugin_LTLIBRARIES = libgstvideobox.la
libgstvideobox_la_SOURCES = gstvideobox.c
libgstvideobox_la_CFLAGS = $(GST_CFLAGS)
libgstvideobox_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_LIBS_CFLAGS)
libgstvideobox_la_LIBADD =
libgstvideobox_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)

View file

@ -129,9 +129,8 @@ static void gst_video_box_set_property (GObject * object, guint prop_id,
static void gst_video_box_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstPadLinkReturn
gst_video_box_sink_link (GstPad * pad, const GstCaps * caps);
static void gst_video_box_chain (GstPad * pad, GstData * _data);
static gboolean gst_video_box_sink_setcaps (GstPad * pad, GstCaps * caps);
static GstFlowReturn gst_video_box_chain (GstPad * pad, GstBuffer * buffer);
static GstElementStateReturn gst_video_box_change_state (GstElement * element);
@ -207,6 +206,9 @@ gst_video_box_class_init (GstVideoBoxClass * klass)
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
gobject_class->set_property = gst_video_box_set_property;
gobject_class->get_property = gst_video_box_get_property;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FILL_TYPE,
g_param_spec_enum ("fill", "Fill", "How to fill the borders",
GST_TYPE_VIDEO_BOX_FILL, DEFAULT_FILL_TYPE,
@ -235,9 +237,6 @@ gst_video_box_class_init (GstVideoBoxClass * klass)
"Alpha value of the border", 0.0, 1.0, DEFAULT_BORDER_ALPHA,
G_PARAM_READWRITE));
gobject_class->set_property = gst_video_box_set_property;
gobject_class->get_property = gst_video_box_get_property;
gstelement_class->change_state = gst_video_box_change_state;
}
@ -250,7 +249,7 @@ gst_video_box_init (GstVideoBox * video_box)
(&gst_video_box_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (video_box), video_box->sinkpad);
gst_pad_set_chain_function (video_box->sinkpad, gst_video_box_chain);
gst_pad_set_link_function (video_box->sinkpad, gst_video_box_sink_link);
gst_pad_set_setcaps_function (video_box->sinkpad, gst_video_box_sink_setcaps);
video_box->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get
@ -264,8 +263,6 @@ gst_video_box_init (GstVideoBox * video_box)
video_box->fill_type = DEFAULT_FILL_TYPE;
video_box->alpha = DEFAULT_ALPHA;
video_box->border_alpha = DEFAULT_BORDER_ALPHA;
GST_FLAG_SET (video_box, GST_ELEMENT_EVENT_AWARE);
}
/* do we need this function? */
@ -374,20 +371,20 @@ gst_video_box_get_property (GObject * object, guint prop_id, GValue * value,
}
}
static GstPadLinkReturn
gst_video_box_sink_link (GstPad * pad, const GstCaps * caps)
static gboolean
gst_video_box_sink_setcaps (GstPad * pad, GstCaps * caps)
{
GstVideoBox *video_box;
GstStructure *structure;
gboolean ret;
video_box = GST_VIDEO_BOX (gst_pad_get_parent (pad));
video_box = GST_VIDEO_BOX (GST_PAD_PARENT (pad));
structure = gst_caps_get_structure (caps, 0);
ret = gst_structure_get_int (structure, "width", &video_box->in_width);
ret &= gst_structure_get_int (structure, "height", &video_box->in_height);
return GST_PAD_LINK_OK;
return ret;
}
#define ROUND_UP_2(x) (((x)+1)&~1)
@ -603,29 +600,16 @@ gst_video_box_ayuv (GstVideoBox * video_box, guint8 * src, guint8 * dest)
}
}
static void
gst_video_box_chain (GstPad * pad, GstData * _data)
static GstFlowReturn
gst_video_box_chain (GstPad * pad, GstBuffer * buffer)
{
GstBuffer *buffer;
GstVideoBox *video_box;
GstBuffer *outbuf;
gint new_width, new_height;
GstFlowReturn ret;
video_box = GST_VIDEO_BOX (gst_pad_get_parent (pad));
if (GST_IS_EVENT (_data)) {
GstEvent *event = GST_EVENT (_data);
switch (GST_EVENT_TYPE (event)) {
default:
gst_pad_event_default (pad, event);
break;
}
return;
}
buffer = GST_BUFFER (_data);
new_width =
video_box->in_width - (video_box->box_left + video_box->box_right);
new_height =
@ -665,14 +649,20 @@ gst_video_box_chain (GstPad * pad, GstData * _data)
}
if (video_box->use_alpha) {
outbuf = gst_pad_alloc_buffer (video_box->srcpad,
GST_BUFFER_OFFSET_NONE, new_width * new_height * 4);
ret = gst_pad_alloc_buffer (video_box->srcpad,
GST_BUFFER_OFFSET_NONE, new_width * new_height * 4,
GST_RPAD_CAPS (video_box->srcpad), &outbuf);
if (ret != GST_FLOW_OK)
goto done;
gst_video_box_ayuv (video_box,
GST_BUFFER_DATA (buffer), GST_BUFFER_DATA (outbuf));
} else {
outbuf = gst_pad_alloc_buffer (video_box->srcpad,
GST_BUFFER_OFFSET_NONE, GST_VIDEO_I420_SIZE (new_width, new_height));
ret = gst_pad_alloc_buffer (video_box->srcpad,
GST_BUFFER_OFFSET_NONE, GST_VIDEO_I420_SIZE (new_width, new_height),
GST_RPAD_CAPS (video_box->srcpad), &outbuf);
if (ret != GST_FLOW_OK)
goto done;
gst_video_box_i420 (video_box,
GST_BUFFER_DATA (buffer), GST_BUFFER_DATA (outbuf));
@ -680,10 +670,12 @@ gst_video_box_chain (GstPad * pad, GstData * _data)
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buffer);
ret = gst_pad_push (video_box->srcpad, outbuf);
done:
gst_buffer_unref (buffer);
gst_pad_push (video_box->srcpad, GST_DATA (outbuf));
return ret;
}
static GstElementStateReturn

View file

@ -294,18 +294,12 @@ gst_videofilter_chain (GstPad * pad, GstBuffer * buf)
guchar *data;
gulong size;
GstBuffer *outbuf;
GstFlowReturn ret;
GST_DEBUG ("gst_videofilter_chain");
g_return_val_if_fail (pad != NULL, GST_FLOW_ERROR);
g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR);
g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
videofilter = GST_VIDEOFILTER (GST_PAD_PARENT (pad));
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
if (videofilter->passthru) {
return gst_pad_push (videofilter->srcpad, buf);
}
@ -314,6 +308,9 @@ gst_videofilter_chain (GstPad * pad, GstBuffer * buf)
return GST_FLOW_NOT_NEGOTIATED;
}
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
GST_DEBUG ("gst_videofilter_chain: got buffer of %ld bytes in '%s'", size,
GST_OBJECT_NAME (videofilter));
@ -330,8 +327,11 @@ gst_videofilter_chain (GstPad * pad, GstBuffer * buf)
return GST_FLOW_ERROR;
}
outbuf = gst_pad_alloc_buffer (videofilter->srcpad, GST_BUFFER_OFFSET_NONE,
videofilter->to_buf_size, GST_RPAD_CAPS (videofilter->srcpad));
ret = gst_pad_alloc_buffer (videofilter->srcpad, GST_BUFFER_OFFSET_NONE,
videofilter->to_buf_size, GST_PAD_CAPS (videofilter->srcpad), &outbuf);
if (ret != GST_FLOW_OK)
goto no_buffer;
GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
@ -343,15 +343,19 @@ gst_videofilter_chain (GstPad * pad, GstBuffer * buf)
videofilter->format->filter_func (videofilter, GST_BUFFER_DATA (outbuf),
data);
gst_buffer_unref (buf);
GST_DEBUG ("gst_videofilter_chain: pushing buffer of %d bytes in '%s'",
GST_BUFFER_SIZE (outbuf), GST_OBJECT_NAME (videofilter));
gst_pad_push (videofilter->srcpad, outbuf);
ret = gst_pad_push (videofilter->srcpad, outbuf);
gst_buffer_unref (buf);
return ret;
return GST_FLOW_OK;
no_buffer:
{
return ret;
}
}
static void