- g_value_init (&videofilter->framerate, GST_TYPE_FRACTION);
-}
-
-static GstFlowReturn
-gst_videofilter_chain (GstPad * pad, GstBuffer * buf)
-{
- GstVideofilter *videofilter;
- guchar *data;
- gulong size;
- GstBuffer *outbuf;
- GstFlowReturn ret;
-
- videofilter = GST_VIDEOFILTER (GST_PAD_PARENT (pad));
- GST_DEBUG_OBJECT (videofilter, "gst_videofilter_chain");
-
- if (videofilter->passthru) {
- return gst_pad_push (videofilter->srcpad, buf);
- }
-
- if (GST_PAD_CAPS (pad) == NULL) {
- return GST_FLOW_NOT_NEGOTIATED;
- }
-
- data = GST_BUFFER_DATA (buf);
- size = GST_BUFFER_SIZE (buf);
-
- GST_LOG_OBJECT (videofilter, "got buffer of %ld bytes in '%s'", size,
- GST_OBJECT_NAME (videofilter));
-
- GST_LOG_OBJECT (videofilter,
- "size=%ld from=%dx%d to=%dx%d fromsize=%ld (should be %d) tosize=%d",
- size, videofilter->from_width, videofilter->from_height,
- videofilter->to_width, videofilter->to_height, size,
- videofilter->from_buf_size, videofilter->to_buf_size);
-
-
- if (size > videofilter->from_buf_size) {
- GST_INFO_OBJECT (videofilter, "buffer size %ld larger than expected (%d)",
- size, videofilter->from_buf_size);
- return GST_FLOW_ERROR;
- }
-
- 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;
-
- g_return_val_if_fail (GST_BUFFER_DATA (outbuf), GST_FLOW_ERROR);
-
- GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
- GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
-
- g_return_val_if_fail (videofilter->format, GST_FLOW_ERROR);
- GST_DEBUG_OBJECT (videofilter, "format %s", videofilter->format->fourcc);
-
- videofilter->in_buf = buf;
- videofilter->out_buf = outbuf;
-
- videofilter->format->filter_func (videofilter, GST_BUFFER_DATA (outbuf),
- data);
- gst_buffer_unref (buf);
-
- GST_LOG_OBJECT (videofilter, "pushing buffer of %d bytes in '%s'",
- GST_BUFFER_SIZE (outbuf), GST_OBJECT_NAME (videofilter));
-
- ret = gst_pad_push (videofilter->srcpad, outbuf);
-
- return ret;
-
-no_buffer:
- {
- return ret;
- }
-}
-
-static void
-gst_videofilter_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstVideofilter *videofilter;
-
- g_return_if_fail (GST_IS_VIDEOFILTER (object));
- videofilter = GST_VIDEOFILTER (object);
-
- GST_DEBUG_OBJECT (videofilter, "gst_videofilter_set_property");
- switch (prop_id) {
- default:
- break;
- }
-}
-
-static void
-gst_videofilter_get_property (GObject * object, guint prop_id, GValue * value,
- GParamSpec * pspec)
-{
- GstVideofilter *videofilter;
-
- g_return_if_fail (GST_IS_VIDEOFILTER (object));
- videofilter = GST_VIDEOFILTER (object);
-
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-int
-gst_videofilter_get_input_width (GstVideofilter * videofilter)
-{
- g_return_val_if_fail (GST_IS_VIDEOFILTER (videofilter), 0);
-
- return videofilter->from_width;
-}
-
-int
-gst_videofilter_get_input_height (GstVideofilter * videofilter)
-{
- g_return_val_if_fail (GST_IS_VIDEOFILTER (videofilter), 0);
-
- return videofilter->from_height;
-}
-
-void
-gst_videofilter_set_output_size (GstVideofilter * videofilter,
- int width, int height)
-{
- GstCaps *srccaps;
- GstStructure *structure;
-
- g_return_if_fail (GST_IS_VIDEOFILTER (videofilter));
-
- videofilter->to_width = width;
- videofilter->to_height = height;
-
- videofilter->to_buf_size = (videofilter->to_width * videofilter->to_height
- * videofilter->format->bpp) / 8;
-
- //srccaps = gst_caps_copy (gst_pad_get_negotiated_caps (videofilter->srcpad));
- srccaps = gst_caps_copy (GST_PAD_CAPS (videofilter->srcpad));
- structure = gst_caps_get_structure (srccaps, 0);
-
- gst_structure_set (structure, "width", G_TYPE_INT, width,
- "height", G_TYPE_INT, height, NULL);
-
- gst_pad_set_caps (videofilter->srcpad, srccaps);
-}
-
-void
-gst_videofilter_setup (GstVideofilter * videofilter)
-{
- GstVideofilterClass *klass;
-
- GST_DEBUG_OBJECT (videofilter, "setup");
-
- klass = GST_VIDEOFILTER_CLASS (G_OBJECT_GET_CLASS (videofilter));
-
- if (klass->setup) {
- GST_DEBUG_OBJECT (videofilter, "calling class setup method");
- klass->setup (videofilter);
- }
-
- if (videofilter->to_width == 0) {
- videofilter->to_width = videofilter->from_width;
- }
- if (videofilter->to_height == 0) {
- videofilter->to_height = videofilter->from_height;
- }
-
- g_return_if_fail (videofilter->format != NULL);
- g_return_if_fail (videofilter->from_width > 0);
- g_return_if_fail (videofilter->from_height > 0);
- g_return_if_fail (videofilter->to_width > 0);
- g_return_if_fail (videofilter->to_height > 0);
-
- videofilter->from_buf_size =
- (videofilter->from_width * videofilter->from_height *
- videofilter->format->bpp) / 8;
- videofilter->to_buf_size =
- (videofilter->to_width * videofilter->to_height *
- videofilter->format->bpp) / 8;
-
- GST_DEBUG_OBJECT (videofilter, "from_buf_size %d to_buf_size %d",
- videofilter->from_buf_size, videofilter->to_buf_size);
- videofilter->inited = TRUE;
-}
-
-GstVideofilterFormat *
-gst_videofilter_find_format_by_structure (GstVideofilter * videofilter,
- const GstStructure * structure)
-{
- int i;
- GstVideofilterClass *klass;
- GstVideofilterFormat *format;
- gboolean ret;
-
- klass = GST_VIDEOFILTER_CLASS (G_OBJECT_GET_CLASS (videofilter));
-
- g_return_val_if_fail (structure != NULL, NULL);
-
- if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
- guint32 fourcc;
-
- ret = gst_structure_get_fourcc (structure, "format", &fourcc);
- if (!ret)
- return NULL;
- for (i = 0; i < klass->formats->len; i++) {
- guint32 format_fourcc;
-
- format = g_ptr_array_index (klass->formats, i);
- format_fourcc = GST_STR_FOURCC (format->fourcc);
- if (format->depth == 0 && format_fourcc == fourcc) {
- return format;
- }
- }
- } else if (strcmp (gst_structure_get_name (structure), "video/x-raw-rgb")
- == 0) {
- int bpp;
- int depth;
- int endianness;
- int red_mask;
- int green_mask;
- int blue_mask;
-
- ret = gst_structure_get_int (structure, "bpp", &bpp);
- ret &= gst_structure_get_int (structure, "depth", &depth);
- ret &= gst_structure_get_int (structure, "endianness", &endianness);
- ret &= gst_structure_get_int (structure, "red_mask", &red_mask);
- ret &= gst_structure_get_int (structure, "green_mask", &green_mask);
- ret &= gst_structure_get_int (structure, "blue_mask", &blue_mask);
- if (!ret)
- return NULL;
- for (i = 0; i < klass->formats->len; i++) {
- format = g_ptr_array_index (klass->formats, i);
- if (format->bpp == bpp && format->depth == depth &&
- format->endianness == endianness && format->red_mask == red_mask &&
- format->green_mask == green_mask && format->blue_mask == blue_mask) {
- return format;
- }
- }
- }
-
- return NULL;
-}
-
-void
-gst_videofilter_class_add_format (GstVideofilterClass * videofilterclass,
- GstVideofilterFormat * format)
-{
- g_ptr_array_add (videofilterclass->formats, format);
-}
-
-void
-gst_videofilter_class_add_pad_templates (GstVideofilterClass *
- videofilter_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (videofilter_class);
-
- gst_element_class_add_pad_template (element_class,
- gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
- gst_videofilter_class_get_capslist (videofilter_class)));
-
- gst_element_class_add_pad_template (element_class,
- gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
- gst_videofilter_class_get_capslist (videofilter_class)));