From: Ronald B. <rb...@us...> - 2003-07-06 20:50:21
|
CVS Root: /cvsroot/gstreamer Module: gst-plugins Changes by: rbultje Date: Sun Jul 06 2003 13:50:19 PDT Log message: New mimetypes gone into effect today - this commit changes all old mimetypes over to the new mimetypes spec as described in the previous commit's document. Note: some plugins will break, some pipelines will break, expect HEAD to be broken or at least not 100% working for a few days, but don't forget to report bugs Modified files: ext/hermes : gstcolorspace.c gstcolorspace.h ext/ivorbis : vorbis.c vorbisfile.c ext/jack : gstjack.c gst/speed : gstspeed.c gstspeed.h gst/synaesthesia: gstsynaesthesia.c gst/videocrop : gstvideocrop.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/hermes/gstcolorspace.c.diff?r1=1.20&r2=1.21 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/hermes/gstcolorspace.h.diff?r1=1.5&r2=1.6 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/ivorbis/vorbis.c.diff?r1=1.3&r2=1.4 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/ivorbis/vorbisfile.c.diff?r1=1.4&r2=1.5 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/jack/gstjack.c.diff?r1=1.29&r2=1.30 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst/speed/gstspeed.c.diff?r1=1.17&r2=1.18 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst/speed/gstspeed.h.diff?r1=1.2&r2=1.3 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst/synaesthesia/gstsynaesthesia.c.diff?r1=1.17&r2=1.18 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/gst/videocrop/gstvideocrop.c.diff?r1=1.9&r2=1.10 ====Begin Diffs==== Index: gstcolorspace.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/hermes/gstcolorspace.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- gstcolorspace.c 29 Jun 2003 19:45:06 -0000 1.20 +++ gstcolorspace.c 6 Jul 2003 20:49:16 -0000 1.21 @@ -21,6 +21,7 @@ #include "config.h" #endif #include <gst/gst.h> +#include <gst/video/video.h> #include "gstcolorspace.h" #include "yuv2rgb.h" @@ -50,42 +51,6 @@ ARG_DEST, }; -GST_PAD_TEMPLATE_FACTORY (colorspace_src_template_factory, - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "colorspace_src", - "video/raw", - "format", GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")) - ), - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT) - ) -) - -GST_PAD_TEMPLATE_FACTORY (colorspace_sink_template_factory, - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "colorspace_sink", - "video/raw", - "format", GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")) - ), - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT) - ) -) - static void gst_colorspace_class_init (GstColorspaceClass *klass); static void gst_colorspace_init (GstColorspace *space); @@ -110,6 +75,7 @@ extern void gst_colorspace_rgb32_to_yv12 (unsigned char *src, unsigned char *dest, guint width, guint height); +static GstPadTemplate *srctempl, *sinktempl; static GstElementClass *parent_class = NULL; /*static guint gst_colorspace_signals[LAST_SIGNAL] = { 0 }; */ @@ -134,10 +100,20 @@ g_return_val_if_fail (to_caps != NULL, FALSE); g_return_val_if_fail (from_caps != NULL, FALSE); - gst_caps_get_fourcc_int (from_caps, "format", &from_space); - gst_caps_get_fourcc_int (to_caps, "format", &to_space); + if (gst_caps_has_property (from_caps, "format")) + gst_caps_get_fourcc_int (from_caps, "format", &from_space); + else + from_space = GST_MAKE_FOURCC ('R','G','B',' '); - GST_INFO ( "set up converter for %08x to %08x", from_space, to_space); + if (gst_caps_has_property (to_caps, "format")) + gst_caps_get_fourcc_int (to_caps, "format", &to_space); + else + to_space = GST_MAKE_FOURCC ('R','G','B',' '); + + GST_INFO ("set up converter for " GST_FOURCC_FORMAT + " (%08x) to " GST_FOURCC_FORMAT " (%08x)", + GST_FOURCC_ARGS (from_space), from_space, + GST_FOURCC_ARGS (to_space), to_space); switch (from_space) { case GST_MAKE_FOURCC ('R','G','B',' '): @@ -308,6 +284,7 @@ gst_caps_get_int (caps, "width", &space->width); gst_caps_get_int (caps, "height", &space->height); + gst_caps_get_float (caps, "framerate", &space->fps); GST_INFO ( "size: %dx%d", space->width, space->height); @@ -367,12 +344,20 @@ gst_caps_unref (peercaps); } - to_intersect = GST_CAPS_NEW ( + to_intersect = gst_caps_append ( + GST_CAPS_NEW ( "colorspace_filter", - "video/raw", - "width", GST_PROPS_INT (space->width), - "height", GST_PROPS_INT (space->height) - ); + "video/x-raw-yuv", + "width", GST_PROPS_INT (space->width), + "height", GST_PROPS_INT (space->height), + "framerate", GST_PROPS_FLOAT (space->fps) + ), GST_CAPS_NEW ( + "colorspace_filter", + "video/x-raw-rgb", + "width", GST_PROPS_INT (space->width), + "height", GST_PROPS_INT (space->height), + "framerate", GST_PROPS_FLOAT (space->fps) + )); /* then see what the peer has that matches the size */ peercaps = gst_caps_intersect (caps, to_intersect); @@ -456,16 +441,14 @@ static void gst_colorspace_init (GstColorspace *space) { - space->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (colorspace_sink_template_factory), "sink"); + space->sinkpad = gst_pad_new_from_template (sinktempl, "sink"); gst_pad_set_link_function (space->sinkpad, gst_colorspace_sinkconnect); gst_pad_set_getcaps_function (space->sinkpad, gst_colorspace_getcaps); gst_pad_set_bufferpool_function (space->sinkpad, colorspace_get_bufferpool); gst_pad_set_chain_function(space->sinkpad,gst_colorspace_chain); gst_element_add_pad(GST_ELEMENT(space),space->sinkpad); - space->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (colorspace_src_template_factory), "src"); + space->srcpad = gst_pad_new_from_template (srctempl, "src"); gst_element_add_pad(GST_ELEMENT(space),space->srcpad); gst_pad_set_link_function (space->srcpad, gst_colorspace_srcconnect); @@ -623,6 +606,7 @@ plugin_init (GModule *module, GstPlugin *plugin) { GstElementFactory *factory; + GstCaps *caps; #ifdef HAVE_HERMES gint hermes_res; @@ -634,11 +618,37 @@ &colorspace_details); g_return_val_if_fail (factory != NULL, FALSE); gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_PRIMARY); - - gst_element_factory_add_pad_template (factory, - GST_PAD_TEMPLATE_GET (colorspace_src_template_factory)); - gst_element_factory_add_pad_template (factory, - GST_PAD_TEMPLATE_GET (colorspace_sink_template_factory)); + + /* create caps for templates */ + caps = gst_caps_new ("csp_templ_yuv", + "video/x-raw-yuv", + GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( + GST_PROPS_LIST ( + GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), + GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")), + GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))))); + caps = gst_caps_append (caps, + gst_caps_new ("csp_templ_rgb24_32", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32)); + caps = gst_caps_append (caps, + gst_caps_new ("csp_templ_rgb15_16", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16)); + + /* build templates */ + srctempl = gst_pad_template_new ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + caps, NULL); + gst_caps_ref (caps); + sinktempl = gst_pad_template_new ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + caps, NULL); + + gst_element_factory_add_pad_template (factory, srctempl); + gst_element_factory_add_pad_template (factory, sinktempl); gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); Index: gstcolorspace.h =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/hermes/gstcolorspace.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- gstcolorspace.h 21 Jun 2002 18:29:13 -0000 1.5 +++ gstcolorspace.h 6 Jul 2003 20:49:16 -0000 1.6 @@ -76,6 +76,7 @@ GstColorSpaceConverterType type; gint width, height; + gfloat fps; gint srcbpp, destbpp; gboolean disabled; Index: gstspeed.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/gst/speed/gstspeed.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- gstspeed.c 29 Jun 2003 19:45:59 -0000 1.17 +++ gstspeed.c 6 Jul 2003 20:49:46 -0000 1.18 @@ -65,9 +65,9 @@ if (!template) { template = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - gst_caps_append(gst_caps_new ("sink_int", "audio/raw", + gst_caps_append(gst_caps_new ("sink_int", "audio/x-raw-int", GST_AUDIO_INT_MONO_PAD_TEMPLATE_PROPS), - gst_caps_new ("sink_float", "audio/raw", + gst_caps_new ("sink_float", "audio/x-raw-float", GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS)), NULL); } @@ -82,9 +82,9 @@ if (!template) template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - gst_caps_append (gst_caps_new ("src_float", "audio/raw", + gst_caps_append (gst_caps_new ("src_float", "audio/x-raw-float", GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS), - gst_caps_new ("src_int", "audio/raw", + gst_caps_new ("src_int", "audio/x-raw-int", GST_AUDIO_INT_MONO_PAD_TEMPLATE_PROPS)), NULL); @@ -138,17 +138,17 @@ static gboolean speed_parse_caps (GstSpeed *filter, GstCaps *caps) { - const gchar *format; + const gchar *mimetype; g_return_val_if_fail(filter!=NULL,-1); g_return_val_if_fail(caps!=NULL,-1); - gst_caps_get_string(caps, "format", &format); + mimetype = gst_caps_get_mime (caps); gst_caps_get_int (caps, "rate", &filter->rate); gst_caps_get_int (caps, "channels", &filter->channels); - if (strcmp(format, "int")==0) { + if (strcmp(mimetype, "audio/x-raw-int")==0) { filter->format = GST_SPEED_FORMAT_INT; gst_caps_get_int (caps, "width", &filter->width); gst_caps_get_int (caps, "depth", &filter->depth); @@ -162,17 +162,16 @@ g_print ("Speed : format int, bit width %d, endianness %d, signed %s\n", filter->width, filter->endianness, filter->is_signed ? "yes" : "no"); } - } else if (strcmp(format, "float")==0) { + } else if (strcmp(mimetype, "audio/x-raw-float")==0) { filter->format = GST_SPEED_FORMAT_FLOAT; - gst_caps_get_string (caps, "layout", &filter->layout); gst_caps_get_float (caps, "intercept", &filter->intercept); gst_caps_get_float (caps, "slope", &filter->slope); if (!filter->silent) { g_print ("Speed : channels %d, rate %d\n", filter->channels, filter->rate); - g_print ("Speed : format float, layout %s, intercept %f, slope %f\n", - filter->layout, filter->intercept, filter->slope); + g_print ("Speed : format float, intercept %f, slope %f\n", + filter->intercept, filter->slope); } } else { return FALSE; Index: gstspeed.h =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/gst/speed/gstspeed.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gstspeed.h 19 Mar 2002 04:09:58 -0000 1.2 +++ gstspeed.h 6 Jul 2003 20:49:46 -0000 1.3 @@ -85,8 +85,6 @@ /* the next three are valid only for format==GST_SPEED_FORMAT_FLOAT */ - const gchar *layout; - gfloat slope; gfloat intercept; Index: vorbis.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/ivorbis/vorbis.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- vorbis.c 7 Apr 2003 18:43:17 -0000 1.3 +++ vorbis.c 6 Jul 2003 20:49:16 -0000 1.4 @@ -37,7 +37,7 @@ return gst_caps_new ( "tremor_tremor", - "application/x-ogg", + "application/ogg", NULL); } @@ -47,10 +47,8 @@ return gst_caps_new ( "tremor_raw", - "audio/raw", + "audio/x-raw-int", gst_props_new ( - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), "endianness", GST_PROPS_INT (G_BYTE_ORDER), "signed", GST_PROPS_BOOLEAN (TRUE), "width", GST_PROPS_INT (16), @@ -66,18 +64,18 @@ return gst_caps_new ( "tremor_raw_float", - "audio/raw", + "audio/x-raw-float", gst_props_new ( - "format", GST_PROPS_STRING ("float"), - "layout", GST_PROPS_STRING ("IEEE"), + "depth", GST_PROPS_INT (32), + "endianness", GST_PROPS_INT (G_BYTE_ORDER), "rate", GST_PROPS_INT_RANGE (11025, 48000), - "channels", GST_PROPS_INT (2), + "channels", GST_PROPS_INT (2), /* ?? */ NULL)); } static GstTypeDefinition vorbisdefinition = { "tremor_audio/x-ogg", - "application/x-ogg", + "application/ogg", ".ogg", vorbis_type_find, }; @@ -90,7 +88,7 @@ if (head != 0x4F676753) return NULL; - return gst_caps_new ("vorbis_type_find", "application/x-ogg", NULL); + return gst_caps_new ("vorbis_type_find", "application/ogg", NULL); } Index: vorbisfile.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/ivorbis/vorbisfile.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- vorbisfile.c 29 Jun 2003 19:45:08 -0000 1.4 +++ vorbisfile.c 6 Jul 2003 20:49:16 -0000 1.5 @@ -82,7 +82,7 @@ "GPL", "Decodes OGG Vorbis audio using the Tremor vorbisfile API", VERSION, - "Monty <mo...@xi...>, " + "Monty <mo...@xi...>\n" "Wim Taymans <wim...@ch...>", "(C) 2000", }; @@ -448,26 +448,24 @@ gst_ivorbisfile_new_link (Ivorbisfile *ivorbisfile, gint link) { vorbis_info *vi = ov_info (&ivorbisfile->vf, link); + GstCaps *newcaps; /* new logical bitstream */ ivorbisfile->current_link = link; gst_ivorbisfile_update_metadata (ivorbisfile, link); gst_ivorbisfile_update_streaminfo (ivorbisfile, link); - - if (gst_pad_try_set_caps (ivorbisfile->srcpad, - GST_CAPS_NEW ("vorbisdec_src", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (TRUE), - "width", GST_PROPS_INT (16), - "depth", GST_PROPS_INT (16), - "rate", GST_PROPS_INT (vi->rate), - "channels", GST_PROPS_INT (vi->channels) - )) <= 0) - { + + newcaps = GST_CAPS_NEW ("vorbisdec_src", + "audio/x-raw-int", + "endianness", GST_PROPS_INT (G_BYTE_ORDER), + "signed", GST_PROPS_BOOLEAN (TRUE), + "width", GST_PROPS_INT (16), + "depth", GST_PROPS_INT (16), + "rate", GST_PROPS_INT (vi->rate), + "channels", GST_PROPS_INT (vi->channels) + ); + if (gst_pad_try_set_caps (ivorbisfile->srcpad, newcaps) <= 0) { return FALSE; } Index: gstsynaesthesia.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/gst/synaesthesia/gstsynaesthesia.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- gstsynaesthesia.c 29 Jun 2003 19:46:00 -0000 1.17 +++ gstsynaesthesia.c 6 Jul 2003 20:49:46 -0000 1.18 @@ -46,7 +46,7 @@ gint16 datain[2][512]; /* video state */ - gint fps; + gfloat fps; gint width; gint height; gboolean first_buffer; @@ -90,8 +90,7 @@ GST_PAD_ALWAYS, GST_CAPS_NEW ( "synaesthesiasrc", - "video/raw", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")), + "video/x-raw-rgb", "bpp", GST_PROPS_INT (32), "depth", GST_PROPS_INT (32), "endianness", GST_PROPS_INT (G_BYTE_ORDER), @@ -99,7 +98,8 @@ "green_mask", GST_PROPS_INT (0xff00), "blue_mask", GST_PROPS_INT (0xff), "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096) + "height", GST_PROPS_INT_RANGE (16, 4096), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) ) ) @@ -109,10 +109,8 @@ GST_PAD_ALWAYS, /* ALWAYS/SOMETIMES */ GST_CAPS_NEW ( "synaesthesiasink", /* the name of the caps */ - "audio/raw", /* the mime type of the caps */ + "audio/x-raw-int", /* the mime type of the caps */ /* Properties follow: */ - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), "endianness", GST_PROPS_INT (G_BYTE_ORDER), "signed", GST_PROPS_BOOLEAN (TRUE), "width", GST_PROPS_INT (16), @@ -181,8 +179,8 @@ g_param_spec_int ("height","Height","The height", 1, 2048, 320, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FPS, - g_param_spec_int ("fps","FPS","Frames per second", - 1, 100, 25, G_PARAM_READWRITE)); + g_param_spec_float ("fps","FPS","Frames per second", + 0., G_MAXFLOAT, 25., G_PARAM_READWRITE)); gobject_class->set_property = gst_synaesthesia_set_property; gobject_class->get_property = gst_synaesthesia_get_property; @@ -209,7 +207,7 @@ /* reset the initial video state */ synaesthesia->width = 320; synaesthesia->height = 200; - synaesthesia->fps = 25; /* desired frame rate */ + synaesthesia->fps = 25.; /* desired frame rate */ } @@ -291,7 +289,8 @@ "green_mask", GST_PROPS_INT (0x00ff00), "blue_mask", GST_PROPS_INT (0x0000ff), "width", GST_PROPS_INT (synaesthesia->width), - "height", GST_PROPS_INT (synaesthesia->height) + "height", GST_PROPS_INT (synaesthesia->height), + "framerate", GST_PROPS_FLOAT (synaesthesia->fps) ); if (gst_pad_try_set_caps (synaesthesia->srcpad, caps) <= 0) { @@ -334,7 +333,7 @@ synaesthesia->height = g_value_get_int (value); break; case ARG_FPS: - synaesthesia->fps = g_value_get_int (value); + synaesthesia->fps = g_value_get_float (value); break; default: break; @@ -358,7 +357,7 @@ g_value_set_int (value, synaesthesia->height); break; case ARG_FPS: - g_value_set_int (value, synaesthesia->fps); + g_value_set_float (value, synaesthesia->fps); break; default: break; Index: gstjack.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/jack/gstjack.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- gstjack.c 1 Jul 2003 02:27:06 -0000 1.29 +++ gstjack.c 6 Jul 2003 20:49:17 -0000 1.30 @@ -167,11 +167,14 @@ { static GstPadTemplate *template = NULL; - if (!template) - template = gst_pad_template_new("%s", GST_PAD_SRC, GST_PAD_REQUEST, - gst_caps_new("src", "audio/raw", - GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS), - NULL); + if (!template) { + GstCaps *caps; + caps = gst_caps_new("src", + "audio/x-raw-float", + GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS); + template = gst_pad_template_new("%s", GST_PAD_SRC, + GST_PAD_REQUEST, caps, NULL); + } return template; } @@ -181,11 +184,14 @@ { static GstPadTemplate *template = NULL; - if (!template) - template = gst_pad_template_new("%s", GST_PAD_SINK, GST_PAD_REQUEST, - gst_caps_new("sink", "audio/raw", - GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS), - NULL); + if (!template) { + GstCaps *caps; + caps = gst_caps_new ("sink", + "audio/x-raw-float", + GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS); + template = gst_pad_template_new("%s", GST_PAD_SINK, + GST_PAD_REQUEST, caps, NULL); + } return template; } Index: gstvideocrop.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/gst/videocrop/gstvideocrop.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- gstvideocrop.c 29 Jun 2003 19:46:03 -0000 1.9 +++ gstvideocrop.c 6 Jul 2003 20:49:47 -0000 1.10 @@ -21,6 +21,7 @@ #include "config.h" #endif #include <gst/gst.h> +#include <gst/video/video.h> #include <string.h> @@ -47,8 +48,8 @@ /* caps */ gint width, height; - gint crop_x, crop_y; - gint crop_width, crop_height; + gfloat fps; + gint crop_left, crop_right, crop_top, crop_bottom; }; struct _GstVideoCropClass { @@ -75,10 +76,10 @@ enum { ARG_0, - ARG_X, - ARG_Y, - ARG_WIDTH, - ARG_HEIGHT, + ARG_LEFT, + ARG_RIGHT, + ARG_TOP, + ARG_BOTTOM, /* FILL ME */ }; @@ -86,10 +87,11 @@ "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( + gst_caps_new ( "video_crop_src", - "video/raw", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")) + "video/x-raw-yuv", + GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( + GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) ) ) @@ -97,10 +99,11 @@ "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( + gst_caps_new ( "video_crop_sink", - "video/raw", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")) + "video/x-raw-yuv", + GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( + GST_PROPS_FOURCC (GST_STR_FOURCC ("I420"))) ) ) @@ -157,17 +160,17 @@ parent_class = g_type_class_ref(GST_TYPE_ELEMENT); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_X, - g_param_spec_int ("x", "X", "X offset of image", + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_LEFT, + g_param_spec_int ("left", "Left", "Pixels to crop at left", 0, G_MAXINT, 0, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_Y, - g_param_spec_int ("y", "Y", "Y offset of image", + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_RIGHT, + g_param_spec_int ("right", "Right", "Pixels to crop at right", 0, G_MAXINT, 0, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_WIDTH, - g_param_spec_int ("width", "Width", "Width of image", + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TOP, + g_param_spec_int ("top", "Top", "Pixels to crop at top", 0, G_MAXINT, 0, G_PARAM_READWRITE)); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HEIGHT, - g_param_spec_int ("height", "Height", "Height of image", + g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BOTTOM, + g_param_spec_int ("bottom", "Bottom", "Pixels to crop at bottom", 0, G_MAXINT, 0, G_PARAM_READWRITE)); gobject_class->set_property = gst_video_crop_set_property; @@ -190,10 +193,10 @@ GST_PAD_TEMPLATE_GET (video_crop_src_template_factory), "src"); gst_element_add_pad (GST_ELEMENT (video_crop), video_crop->srcpad); - video_crop->crop_x = 0; - video_crop->crop_y = 0; - video_crop->crop_width = 128; - video_crop->crop_height = 128; + video_crop->crop_right = 0; + video_crop->crop_left = 0; + video_crop->crop_top = 0; + video_crop->crop_bottom = 0; GST_FLAG_SET (video_crop, GST_ELEMENT_EVENT_AWARE); } @@ -210,17 +213,17 @@ video_crop = GST_VIDEO_CROP (object); switch (prop_id) { - case ARG_X: - video_crop->crop_x = g_value_get_int (value); + case ARG_LEFT: + video_crop->crop_left = g_value_get_int (value); break; - case ARG_Y: - video_crop->crop_y = g_value_get_int (value); + case ARG_RIGHT: + video_crop->crop_right = g_value_get_int (value); break; - case ARG_WIDTH: - video_crop->crop_width = g_value_get_int (value); + case ARG_TOP: + video_crop->crop_top = g_value_get_int (value); break; - case ARG_HEIGHT: - video_crop->crop_height = g_value_get_int (value); + case ARG_BOTTOM: + video_crop->crop_bottom = g_value_get_int (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -238,17 +241,17 @@ video_crop = GST_VIDEO_CROP (object); switch (prop_id) { - case ARG_X: - g_value_set_int (value, video_crop->crop_x); + case ARG_LEFT: + g_value_set_int (value, video_crop->crop_left); break; - case ARG_Y: - g_value_set_int (value, video_crop->crop_y); + case ARG_RIGHT: + g_value_set_int (value, video_crop->crop_right); break; - case ARG_WIDTH: - g_value_set_int (value, video_crop->crop_width); + case ARG_TOP: + g_value_set_int (value, video_crop->crop_top); break; - case ARG_HEIGHT: - g_value_set_int (value, video_crop->crop_height); + case ARG_BOTTOM: + g_value_set_int (value, video_crop->crop_bottom); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -269,11 +272,7 @@ gst_caps_get_int (caps, "width", &video_crop->width); gst_caps_get_int (caps, "height", &video_crop->height); - - if (video_crop->crop_width + video_crop->crop_x > video_crop->width) - video_crop->crop_width = video_crop->width - video_crop->crop_x; - if (video_crop->crop_height + video_crop->crop_y > video_crop->height) - video_crop->crop_height = video_crop->height - video_crop->crop_y; + gst_caps_get_float (caps, "framerate", &video_crop->fps); return GST_PAD_LINK_OK; } @@ -283,44 +282,48 @@ { guint8 *srcY, *srcU, *srcV; guint8 *destY, *destU, *destV; - gint width = video_crop->crop_width; - gint crop_height = video_crop->crop_height; + gint out_width = video_crop->width - + (video_crop->crop_left + video_crop->crop_right); + gint out_height = video_crop->height - + (video_crop->crop_top + video_crop->crop_bottom); gint src_stride = video_crop->width; - gint frame_size = video_crop->width * video_crop->height; + gint src_size = video_crop->width * video_crop->height; gint j; - srcY = GST_BUFFER_DATA (src_buffer) + (src_stride * video_crop->crop_y + video_crop->crop_x); + srcY = GST_BUFFER_DATA (src_buffer) + + (src_stride * video_crop->crop_top + video_crop->crop_left); destY = GST_BUFFER_DATA (dest_buffer); /* copy Y plane first */ - for (j = crop_height; j; j--) { - memcpy (destY, srcY, width); + for (j = 0; j < out_height; j++) { + memcpy (destY, srcY, out_width); srcY += src_stride; - destY += width; + destY += out_width; } - width >>= 1; + out_width >>= 1; src_stride >>= 1; - crop_height >>= 1; + out_height >>= 1; destU = destY; - destV = destU + ((video_crop->crop_width * crop_height) >> 1); + destV = destU + ((out_width * out_height) >> 1); - srcU = GST_BUFFER_DATA (src_buffer) + frame_size + ((src_stride * video_crop->crop_y + video_crop->crop_x) >> 1); - srcV = srcU + (frame_size >> 2); + srcU = GST_BUFFER_DATA (src_buffer) + src_size + + ((src_stride * video_crop->crop_top + video_crop->crop_left) >> 1); + srcV = srcU + (src_size >> 2); /* copy U plane */ - for (j = crop_height; j; j--) { - memcpy (destU, srcU, width); + for (j = 0; j < out_height; j++) { + memcpy (destU, srcU, out_width); srcU += src_stride; - destU += width; + destU += out_width; } /* copy U plane */ - for (j = crop_height; j; j--) { - memcpy (destV, srcV, width); + for (j = 0; j < out_height; j++) { + memcpy (destV, srcV, out_width); srcV += src_stride; - destV += width; + destV += out_width; } } @@ -329,6 +332,7 @@ { GstVideoCrop *video_crop; GstBuffer *outbuf; + gint new_width, new_height; video_crop = GST_VIDEO_CROP (gst_pad_get_parent (pad)); @@ -343,14 +347,20 @@ return; } + new_width = video_crop->width - + (video_crop->crop_left + video_crop->crop_right); + new_height = video_crop->height - + (video_crop->crop_top + video_crop->crop_bottom); + if (GST_PAD_CAPS (video_crop->srcpad) == NULL) { if (gst_pad_try_set_caps (video_crop->srcpad, GST_CAPS_NEW ( "video_crop_caps", "video/raw", "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - "width", GST_PROPS_INT (video_crop->crop_width), - "height", GST_PROPS_INT (video_crop->crop_height) + "width", GST_PROPS_INT (new_width), + "height", GST_PROPS_INT (new_height), + "framerate", GST_PROPS_FLOAT (video_crop->fps) )) <= 0) { gst_element_error (GST_ELEMENT (video_crop), "could not negotiate pads"); @@ -358,7 +368,7 @@ } } - outbuf = gst_buffer_new_and_alloc ((video_crop->crop_width * video_crop->crop_height * 3) / 2); + outbuf = gst_buffer_new_and_alloc ((new_width * new_height * 3) / 2); GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer); gst_video_crop_i420 (video_crop, buffer, outbuf); |