diff options
author | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2004-01-15 11:21:24 +0000 |
---|---|---|
committer | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2004-01-15 11:21:24 +0000 |
commit | d769377619a2cb5ab6a29b439000fe4a93d7c123 (patch) | |
tree | 16c1443004842f71f2dd703977f91203eaaf7be6 /ext/snapshot | |
parent | c01f7aee1dd1e3e4b03bd9b23b6927ed8cc7cd1f (diff) | |
download | gstreamer-plugins-bad-d769377619a2cb5ab6a29b439000fe4a93d7c123.tar.gz |
ext/snapshot/: This has to be a joke... Snapshot should be connected to a tee, colorspace element before it and EOS a...
Original commit message from CVS:
2004-01-15 Ronald Bultje <rbultje@ronald.bitfreak.net>
* ext/snapshot/Makefile.am:
* ext/snapshot/gstsnapshot.c: (gst_snapshot_sinkconnect),
(gst_snapshot_chain):
* ext/snapshot/gstsnapshot.h:
This has to be a joke... Snapshot should be connected to a tee,
colorspace element before it and EOS after that, where the other
src of the tee receives normal data.
The current way is *wrong*.
Diffstat (limited to 'ext/snapshot')
-rw-r--r-- | ext/snapshot/Makefile.am | 5 | ||||
-rw-r--r-- | ext/snapshot/gstsnapshot.c | 62 | ||||
-rw-r--r-- | ext/snapshot/gstsnapshot.h | 6 |
3 files changed, 10 insertions, 63 deletions
diff --git a/ext/snapshot/Makefile.am b/ext/snapshot/Makefile.am index c1542abf6..fd5f06216 100644 --- a/ext/snapshot/Makefile.am +++ b/ext/snapshot/Makefile.am @@ -1,8 +1,9 @@ plugin_LTLIBRARIES = libgstsnapshot.la -libgstsnapshot_la_SOURCES = gstsnapshot.c ../hermes/yuv2rgb.c ../hermes/yuv2yuv.c -libgstsnapshot_la_CFLAGS = $(GST_CFLAGS) +libgstsnapshot_la_SOURCES = \ + gstsnapshot.c +libgstsnapshot_la_CFLAGS = $(GST_CFLAGS) libgstsnapshot_la_LIBADD = $(GST_LIBS) $(LIBPNG_LIBS) libgstsnapshot_la_LDFLAGS = @GST_PLUGIN_LDFLAGS@ diff --git a/ext/snapshot/gstsnapshot.c b/ext/snapshot/gstsnapshot.c index 10d8e3b73..7362d56c5 100644 --- a/ext/snapshot/gstsnapshot.c +++ b/ext/snapshot/gstsnapshot.c @@ -41,7 +41,7 @@ GST_STATIC_PAD_TEMPLATE ( "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YUY2 }")) + GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR) ); static GstStaticPadTemplate snapshot_sink_factory = @@ -49,7 +49,7 @@ GST_STATIC_PAD_TEMPLATE ( "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("{ I420, YUY2 }")) + GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR) ); /* Snapshot signals and args */ @@ -167,7 +167,6 @@ static gboolean gst_snapshot_sinkconnect (GstPad *pad, const GstCaps *caps) { GstSnapshot *filter; - GstCaps *from_caps, *to_caps; gdouble fps; GstStructure *structure; @@ -180,35 +179,6 @@ gst_snapshot_sinkconnect (GstPad *pad, const GstCaps *caps) gst_structure_get_fourcc (structure, "format", &filter->format); filter->to_bpp = 24; - - to_caps = gst_caps_new_simple ("video/x-raw-rgb", - "width", G_TYPE_INT, filter->width, - "height", G_TYPE_INT, filter->height, - "red_mask", G_TYPE_INT, 0x0000FF, - "green_mask", G_TYPE_INT, 0x00FF00, - "blue_mask", G_TYPE_INT, 0xFF0000, - "bpp", G_TYPE_INT, 24, - "framerate", G_TYPE_DOUBLE, fps, - NULL); - - switch ( filter->format ) - { - case GST_MAKE_FOURCC('Y','U','Y','2'): - case GST_MAKE_FOURCC('I','4','2','0'): - from_caps = gst_caps_new_simple ("video/x-raw-yuv", - "format", GST_TYPE_FOURCC, GST_STR_FOURCC ("I420"), - "width", G_TYPE_INT, filter->width, - "height", G_TYPE_INT, filter->height, - "framerate", G_TYPE_DOUBLE, fps, - NULL); - - filter->converter = gst_colorspace_yuv2rgb_get_converter ( from_caps, to_caps ); - break; - - default : - break; - } - filter->png_struct_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, user_error_fn, user_warning_fn); if ( filter->png_struct_ptr == NULL ) g_warning( "Failed to initialize png structure"); @@ -245,9 +215,8 @@ gst_snapshot_chain (GstPad *pad, GstData *_data) { GstBuffer *buf = GST_BUFFER (_data); GstSnapshot *snapshot; - guchar *data, *data_to_convert, *buffer_i420, *data_converted; - gulong size,image_size; - GstBuffer *outbuf; + guchar *data; + gulong size; gint i; png_byte *row_pointers[ MAX_HEIGHT ]; FILE *fp; @@ -263,28 +232,11 @@ gst_snapshot_chain (GstPad *pad, GstData *_data) GST_DEBUG ("snapshot: have buffer of %d\n", GST_BUFFER_SIZE(buf)); - outbuf = gst_buffer_new(); - GST_BUFFER_DATA(outbuf) = g_malloc(GST_BUFFER_SIZE(buf)); - GST_BUFFER_SIZE(outbuf) = GST_BUFFER_SIZE(buf); - snapshot->cur_frame++; - if ( snapshot->cur_frame == snapshot->frame || snapshot->snapshot_asked == TRUE ) + if (snapshot->cur_frame == snapshot->frame || + snapshot->snapshot_asked == TRUE ) { snapshot->snapshot_asked = FALSE; - image_size = snapshot->width * snapshot->height; - data_converted = g_malloc ((image_size * (snapshot->to_bpp/8)) ); - - if ( snapshot->format == GST_MAKE_FOURCC('Y','U','Y','2') ) - { - GST_DEBUG ("YUY2 => RGB\n"); - buffer_i420 = g_malloc ((image_size * (snapshot->to_bpp/8)) ); - gst_colorspace_yuy2_to_i420( data, buffer_i420, snapshot->width, snapshot->height); - data_to_convert = buffer_i420; - } - else - data_to_convert = data; - - gst_colorspace_convert (snapshot->converter, data_to_convert, data_converted); GST_INFO ("dumpfile : %s\n", snapshot->location ); fp = fopen( snapshot->location, "wb" ); @@ -308,7 +260,7 @@ gst_snapshot_chain (GstPad *pad, GstData *_data) ); for ( i = 0; i < snapshot->height; i++ ) - row_pointers[i] = data_converted + (snapshot->width * i * snapshot->to_bpp/8 ); + row_pointers[i] = data + (snapshot->width * i * snapshot->to_bpp/8 ); png_write_info( snapshot->png_struct_ptr, snapshot->png_info_ptr ); png_write_image( snapshot->png_struct_ptr, row_pointers ); diff --git a/ext/snapshot/gstsnapshot.h b/ext/snapshot/gstsnapshot.h index e86d1aba4..0ca1fb933 100644 --- a/ext/snapshot/gstsnapshot.h +++ b/ext/snapshot/gstsnapshot.h @@ -25,10 +25,6 @@ #include <gst/gst.h> #include <png.h> -#include "../hermes/yuv2rgb.h" -#include "../hermes/yuv2yuv.h" - - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -63,8 +59,6 @@ struct _GstSnapshot { png_structp png_struct_ptr; png_infop png_info_ptr; - GstColorSpaceConverter *converter; - GstPad *sinkpad,*srcpad; }; |