diff options
author | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2003-07-06 20:49:52 +0000 |
---|---|---|
committer | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2003-07-06 20:49:52 +0000 |
commit | 95011fd7e8eb3a2ec3a87ff9dad523d18005db42 (patch) | |
tree | 6e75f9139c6520126f9344e15e1dea2a49f70f9c /gst-libs/gst/video | |
parent | 85a8dd7ecb04d043be8192e27e3c89ef8ccebe55 (diff) | |
download | gst-plugins-bad-95011fd7e8eb3a2ec3a87ff9dad523d18005db42.tar.gz gst-plugins-bad-95011fd7e8eb3a2ec3a87ff9dad523d18005db42.tar.bz2 gst-plugins-bad-95011fd7e8eb3a2ec3a87ff9dad523d18005db42.zip |
New mimetypes gone into effect today - this commit changes all old mimetypes over to the new mimetypes spec as descri...
Original commit message from CVS:
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
Diffstat (limited to 'gst-libs/gst/video')
-rw-r--r-- | gst-libs/gst/video/video.c | 72 | ||||
-rw-r--r-- | gst-libs/gst/video/video.h | 150 |
2 files changed, 192 insertions, 30 deletions
diff --git a/gst-libs/gst/video/video.c b/gst-libs/gst/video/video.c index 6eba0d7b..11e26c96 100644 --- a/gst-libs/gst/video/video.c +++ b/gst-libs/gst/video/video.c @@ -20,31 +20,36 @@ #include "video.h" -#define NUM_UNITS 1000000000 - /* This is simply a convenience function, nothing more or less */ -gdouble +gfloat gst_video_frame_rate (GstPad *pad) { - GstFormat dest_format = GST_FORMAT_DEFAULT; - gint64 dest_value = 0; - gdouble fps; - - /* do a convert request on the source pad */ - if (!gst_pad_convert(pad, - GST_FORMAT_TIME, GST_SECOND * NUM_UNITS, - &dest_format, &dest_value)) - { - g_warning("gstvideo: pad %s:%s failed to convert time to unit!\n", - GST_ELEMENT_NAME(gst_pad_get_parent (pad)), GST_PAD_NAME(pad)); + gfloat fps = 0.; + GstCaps *caps; + + /* get pad caps */ + caps = GST_PAD_CAPS (pad); + if (caps == NULL) { + g_warning ("gstvideo: failed to get caps of pad %s:%s", + GST_ELEMENT_NAME (gst_pad_get_parent (pad)), + GST_PAD_NAME(pad)); + return 0.; + } + + if (!gst_caps_has_property_typed (caps, "framerate", + GST_PROPS_FLOAT_TYPE)) { + g_warning ("gstvideo: failed to get framerate property of pad %s:%s", + GST_ELEMENT_NAME (gst_pad_get_parent (pad)), + GST_PAD_NAME (pad)); return 0.; } - fps = ((gdouble) dest_value) / NUM_UNITS; + gst_caps_get_float (caps, "framerate", &fps); - GST_DEBUG ("Framerate request on pad %s:%s - %f fps", - GST_ELEMENT_NAME(gst_pad_get_parent (pad)), GST_PAD_NAME(pad), fps); + GST_DEBUG ("Framerate request on pad %s:%s: %f", + GST_ELEMENT_NAME (gst_pad_get_parent (pad)), + GST_PAD_NAME(pad), fps); return fps; } @@ -56,28 +61,37 @@ gst_video_get_size (GstPad *pad, { GstCaps *caps; - g_return_val_if_fail(pad != NULL, FALSE); + g_return_val_if_fail (pad != NULL, FALSE); - caps = GST_PAD_CAPS(pad); - if (!caps) { - g_warning("gstvideo: failed to get caps of pad %s:%s", - GST_ELEMENT_NAME(gst_pad_get_parent (pad)), GST_PAD_NAME(pad)); + caps = GST_PAD_CAPS (pad); + + if (caps == NULL) { + g_warning ("gstvideo: failed to get caps of pad %s:%s", + GST_ELEMENT_NAME (gst_pad_get_parent (pad)), + GST_PAD_NAME(pad)); return FALSE; } - if (!gst_caps_has_property(caps, "width") || - !gst_caps_has_property(caps, "height")) { - g_warning("gstvideo: resulting caps doesn't have width/height properties"); + + if (!gst_caps_has_property_typed (caps, "width", + GST_PROPS_INT_TYPE) || + !gst_caps_has_property_typed (caps, "height", + GST_PROPS_FLOAT_TYPE)) { + g_warning ("gstvideo: failed to get size properties on pad %s:%s", + GST_ELEMENT_NAME (gst_pad_get_parent (pad)), + GST_PAD_NAME(pad)); return FALSE; } if (width) - gst_caps_get_int(caps, "width", width); + gst_caps_get_int (caps, "width", width); if (height) - gst_caps_get_int(caps, "height", height); + gst_caps_get_int (caps, "height", height); GST_DEBUG ("size request on pad %s:%s: %dx%d", - GST_ELEMENT_NAME(gst_pad_get_parent (pad)), GST_PAD_NAME(pad), - width?*width:0, height?*height:0); + GST_ELEMENT_NAME (gst_pad_get_parent (pad)), + GST_PAD_NAME (pad), + width ? *width : -1, + height ? *height : -1); return TRUE; } diff --git a/gst-libs/gst/video/video.h b/gst-libs/gst/video/video.h index 802520da..9ff57f78 100644 --- a/gst-libs/gst/video/video.h +++ b/gst-libs/gst/video/video.h @@ -23,7 +23,155 @@ #include <gst/gst.h> -gdouble gst_video_frame_rate (GstPad *pad); +#if (G_BYTE_ORDER == G_BIG_ENDIAN) + +#define R_MASK_32 0xff000000 +#define G_MASK_32 0x00ff0000 +#define B_MASK_32 0x0000ff00 + +#define R_MASK_24 0xff0000 +#define G_MASK_24 0x00ff00 +#define B_MASK_24 0x0000ff + +#else + +#define R_MASK_32 0x000000ff +#define G_MASK_32 0x0000ff00 +#define B_MASK_32 0x00ff0000 + +#define R_MASK_24 0x0000ff +#define G_MASK_24 0x00ff00 +#define B_MASK_24 0xff0000 + +#endif + +#define R_MASK_16 0xf800 +#define G_MASK_16 0x07e0 +#define B_MASK_16 0x001f + +#define R_MASK_15 0x8c00 +#define G_MASK_15 0x03e0 +#define B_MASK_15 0x001f + +#define SIZE_RANGE GST_PROPS_INT_RANGE (16, 4096) +#define FPS_RANGE GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) + +/* properties for pad templates */ +#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32 \ + gst_props_new ( \ + "bpp", GST_PROPS_LIST ( \ + GST_PROPS_INT (24), \ + GST_PROPS_INT (32) \ + ), \ + "depth", GST_PROPS_LIST ( \ + GST_PROPS_INT (24), \ + GST_PROPS_INT (32) \ + ), \ + "endianness", GST_PROPS_INT (G_BIG_ENDIAN), \ + "red_mask", GST_PROPS_LIST ( \ + GST_PROPS_INT (R_MASK_32), \ + GST_PROPS_INT (R_MASK_24) \ + ), \ + "green_mask", GST_PROPS_LIST ( \ + GST_PROPS_INT (G_MASK_32), \ + GST_PROPS_INT (G_MASK_24) \ + ), \ + "blue_mask", GST_PROPS_LIST ( \ + GST_PROPS_INT (B_MASK_32), \ + GST_PROPS_INT (B_MASK_24) \ + ), \ + "width", SIZE_RANGE, \ + "height", SIZE_RANGE, \ + "framerate", FPS_RANGE, \ + NULL) + +#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_32 \ + gst_props_new ( \ + "bpp", GST_PROPS_INT (32), \ + "depth", GST_PROPS_INT (32), \ + "endianness", GST_PROPS_INT (G_BIG_ENDIAN), \ + "red_mask", GST_PROPS_INT (R_MASK_32), \ + "green_mask", GST_PROPS_INT (G_MASK_32), \ + "blue_mask", GST_PROPS_INT (B_MASK_32), \ + "width", SIZE_RANGE, \ + "height", SIZE_RANGE, \ + "framerate", FPS_RANGE, \ + NULL) + +#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24 \ + gst_props_new ( \ + "bpp", GST_PROPS_INT (24), \ + "depth", GST_PROPS_INT (24), \ + "endianness", GST_PROPS_INT (G_BIG_ENDIAN), \ + "red_mask", GST_PROPS_INT (R_MASK_24), \ + "green_mask", GST_PROPS_INT (G_MASK_24), \ + "blue_mask", GST_PROPS_INT (B_MASK_24), \ + "width", SIZE_RANGE, \ + "height", SIZE_RANGE, \ + "framerate", FPS_RANGE, \ + NULL) + +#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16 \ + gst_props_new ( \ + "bpp", GST_PROPS_INT (16), \ + "depth", GST_PROPS_LIST ( \ + GST_PROPS_INT (15), \ + GST_PROPS_INT (16) \ + ), \ + "endianness", GST_PROPS_INT (G_BYTE_ORDER), \ + "red_mask", GST_PROPS_LIST ( \ + GST_PROPS_INT (R_MASK_15), \ + GST_PROPS_INT (R_MASK_16) \ + ), \ + "green_mask", GST_PROPS_LIST ( \ + GST_PROPS_INT (G_MASK_15), \ + GST_PROPS_INT (G_MASK_16) \ + ), \ + "blue_mask", GST_PROPS_LIST ( \ + GST_PROPS_INT (B_MASK_15), \ + GST_PROPS_INT (B_MASK_16) \ + ), \ + "width", SIZE_RANGE, \ + "height", SIZE_RANGE, \ + "framerate", FPS_RANGE, \ + NULL) + +#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_16 \ + gst_props_new ( \ + "bpp", GST_PROPS_INT (16), \ + "depth", GST_PROPS_INT (16), \ + "endianness", GST_PROPS_INT (G_BYTE_ORDER), \ + "red_mask", GST_PROPS_INT (R_MASK_16), \ + "green_mask", GST_PROPS_INT (G_MASK_16), \ + "blue_mask", GST_PROPS_INT (B_MASK_16), \ + "width", SIZE_RANGE, \ + "height", SIZE_RANGE, \ + "framerate", FPS_RANGE, \ + NULL) + +#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15 \ + gst_props_new ( \ + "bpp", GST_PROPS_INT (15), \ + "depth", GST_PROPS_INT (15), \ + "endianness", GST_PROPS_INT (G_BYTE_ORDER), \ + "red_mask", GST_PROPS_INT (R_MASK_15), \ + "green_mask", GST_PROPS_INT (G_MASK_15), \ + "blue_mask", GST_PROPS_INT (B_MASK_15), \ + "width", SIZE_RANGE, \ + "height", SIZE_RANGE, \ + "framerate", FPS_RANGE, \ + NULL) + +#define GST_VIDEO_YUV_PAD_TEMPLATE_PROPS(fourcc) \ + gst_props_new (\ + "format", fourcc, \ + "width", SIZE_RANGE, \ + "height", SIZE_RANGE, \ + "framerate", FPS_RANGE, \ + NULL) + +/* functions */ +gfloat gst_video_frame_rate (GstPad *pad); gboolean gst_video_get_size (GstPad *pad, gint *width, gint *height); |