From 733fcc462974ffad4f1483f5ff1ef4fac3d8359c Mon Sep 17 00:00:00 2001 From: David Schleef Date: Mon, 12 Jan 2004 03:21:40 +0000 Subject: Fixes to make ext/libcaca compile. Original commit message from CVS: * configure.ac: * ext/Makefile.am: Fixes to make ext/libcaca compile. * ext/divx/gstdivxdec.c: * ext/gdk_pixbuf/gstgdkpixbuf.c: (gst_gdk_pixbuf_sink_link), (gst_gdk_pixbuf_init), (gst_gdk_pixbuf_chain): Make gdkpixbufdec handle images that span multiple buffers. Now work with both filesrc ! gdkpixbufdec and qtdemux ! gdkpixbufdec. * ext/gdk_pixbuf/gstgdkpixbuf.h: * ext/libcaca/gstcacasink.h: Fixes needed due to recent video/video.h changes * ext/xvid/gstxvid.c: (gst_xvid_csp_to_caps): same * sys/v4l/gstv4lmjpegsrc.c: (gst_v4lmjpegsrc_get), (gst_v4lmjpegsrc_buffer_free): Use buffer free function instead of GstData free function. * sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get), (gst_v4lsrc_buffer_free): same. --- ext/Makefile.am | 8 +++ ext/gdk_pixbuf/gstgdkpixbuf.c | 124 ++++++++++++++++++++++++++++++------------ ext/gdk_pixbuf/gstgdkpixbuf.h | 3 + ext/libcaca/gstcacasink.h | 6 +- 4 files changed, 102 insertions(+), 39 deletions(-) (limited to 'ext') diff --git a/ext/Makefile.am b/ext/Makefile.am index ec6955bb..a5e112cb 100644 --- a/ext/Makefile.am +++ b/ext/Makefile.am @@ -154,6 +154,12 @@ else LCS_DIR= endif +if USE_LIBCACA +LIBCACA_DIR=libcaca +else +LIBCACA_DIR= +endif + if USE_LIBDV LIBDV_DIR=dv else @@ -323,6 +329,7 @@ SUBDIRS=\ $(LADSPA_DIR) \ $(LAME_DIR) \ $(LCS_DIR) \ + $(LIBCACA_DIR) \ $(LIBDV_DIR) \ $(LIBFAME_DIR) \ $(LIBPNG_DIR) \ @@ -376,6 +383,7 @@ DIST_SUBDIRS=\ ladspa \ lame \ lcs \ + libcaca \ libfame \ libpng \ librfb \ diff --git a/ext/gdk_pixbuf/gstgdkpixbuf.c b/ext/gdk_pixbuf/gstgdkpixbuf.c index d955777c..10aea2ac 100644 --- a/ext/gdk_pixbuf/gstgdkpixbuf.c +++ b/ext/gdk_pixbuf/gstgdkpixbuf.c @@ -109,7 +109,7 @@ gst_gdk_pixbuf_sink_link (GstPad *pad, const GstCaps *caps) g_return_val_if_fail (GST_IS_GDK_PIXBUF (filter), GST_PAD_LINK_REFUSED); - return GST_PAD_LINK_DELAYED; + return GST_PAD_LINK_OK; } #if GDK_PIXBUF_MAJOR == 2 && GDK_PIXBUF_MINOR < 2 @@ -226,6 +226,7 @@ gst_gdk_pixbuf_init (GstGdkPixbuf *filter) gst_static_pad_template_get( &gst_gdk_pixbuf_sink_template), "sink"); gst_pad_set_link_function (filter->sinkpad, gst_gdk_pixbuf_sink_link); gst_pad_set_getcaps_function (filter->sinkpad, gst_gdk_pixbuf_sink_getcaps); + filter->srcpad = gst_pad_new_from_template ( gst_static_pad_template_get( &gst_gdk_pixbuf_src_template), "src"); gst_pad_use_explicit_caps (filter->srcpad); @@ -234,6 +235,7 @@ gst_gdk_pixbuf_init (GstGdkPixbuf *filter) gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); gst_pad_set_chain_function (filter->sinkpad, gst_gdk_pixbuf_chain); + GST_FLAG_SET (GST_ELEMENT (filter), GST_ELEMENT_EVENT_AWARE); } static void @@ -241,10 +243,10 @@ gst_gdk_pixbuf_chain (GstPad *pad, GstData *_data) { GstBuffer *buf = GST_BUFFER (_data); GstGdkPixbuf *filter; - GdkPixbufLoader *pixbuf_loader; - GdkPixbuf *pixbuf; - GstBuffer *outbuf; GError *error = NULL; + gboolean push_buffer = FALSE; + gboolean dump_buffer = FALSE; + gboolean got_eos = FALSE; GST_DEBUG ("gst_gdk_pixbuf_chain"); @@ -254,47 +256,97 @@ gst_gdk_pixbuf_chain (GstPad *pad, GstData *_data) filter = GST_GDK_PIXBUF (GST_OBJECT_PARENT (pad)); g_return_if_fail (GST_IS_GDK_PIXBUF (filter)); - pixbuf_loader = gdk_pixbuf_loader_new(); - //pixbuf_loader = gdk_pixbuf_loader_new_with_type("gif"); - - gdk_pixbuf_loader_write(pixbuf_loader, GST_BUFFER_DATA(buf), - GST_BUFFER_SIZE(buf), &error); - gdk_pixbuf_loader_close(pixbuf_loader, &error); - pixbuf = gdk_pixbuf_loader_get_pixbuf(pixbuf_loader); + if (GST_IS_EVENT (_data)) { + GstEvent *event = GST_EVENT (buf); + + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_EOS: + push_buffer = TRUE; + got_eos = TRUE; + break; + case GST_EVENT_DISCONTINUOUS: + dump_buffer = TRUE; + break; + default: + gst_pad_event_default (pad, event); + return; + } + } - g_print("width=%d height=%d\n", gdk_pixbuf_get_width(pixbuf), - gdk_pixbuf_get_height(pixbuf)); + if (filter->last_timestamp != GST_BUFFER_TIMESTAMP (buf)) { + push_buffer = TRUE; + } - if(filter->image_size == 0){ - GstCaps *caps; + if (push_buffer) { + if (filter->pixbuf_loader != NULL) { + GstBuffer *outbuf; + GdkPixbuf *pixbuf; + + gdk_pixbuf_loader_close (filter->pixbuf_loader, NULL); +#if 0 + if (gdk_pixbuf_loader_close (filter->pixbuf_loader, NULL)) { + gst_element_error (GST_ELEMENT(filter), "error"); + return; + } +#endif - filter->width = gdk_pixbuf_get_width(pixbuf); - filter->height = gdk_pixbuf_get_height(pixbuf); - filter->rowstride = gdk_pixbuf_get_rowstride(pixbuf); - filter->image_size = filter->rowstride * filter->height; + pixbuf = gdk_pixbuf_loader_get_pixbuf (filter->pixbuf_loader); - caps = gst_pad_get_caps(filter->srcpad); - gst_caps_set_simple (caps, - "width", G_TYPE_INT, filter->width, - "height", G_TYPE_INT, filter->height, - "framerate", G_TYPE_DOUBLE, 0., NULL); + if(filter->image_size == 0){ + GstCaps *caps; - gst_pad_set_explicit_caps (filter->srcpad, caps); - } + filter->width = gdk_pixbuf_get_width(pixbuf); + filter->height = gdk_pixbuf_get_height(pixbuf); + filter->rowstride = gdk_pixbuf_get_rowstride(pixbuf); + filter->image_size = filter->rowstride * filter->height; - outbuf = gst_buffer_new(); - GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf); - GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(buf); - - GST_BUFFER_SIZE(outbuf) = filter->image_size; - GST_BUFFER_DATA(outbuf) = g_malloc(filter->image_size); + caps = gst_pad_get_caps(filter->srcpad); + gst_caps_set_simple (caps, + "width", G_TYPE_INT, filter->width, + "height", G_TYPE_INT, filter->height, + "framerate", G_TYPE_DOUBLE, 0., NULL); + + gst_pad_set_explicit_caps (filter->srcpad, caps); + } - memcpy(GST_BUFFER_DATA(outbuf), gdk_pixbuf_get_pixels(pixbuf), - filter->image_size); + outbuf = gst_pad_alloc_buffer (filter->srcpad, GST_BUFFER_OFFSET_NONE, + filter->image_size); + GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf); + GST_BUFFER_DURATION(outbuf) = GST_BUFFER_DURATION(buf); + + memcpy(GST_BUFFER_DATA(outbuf), gdk_pixbuf_get_pixels(pixbuf), + filter->image_size); - g_object_unref(G_OBJECT(pixbuf_loader)); + gst_pad_push (filter->srcpad, GST_DATA (outbuf)); - gst_pad_push (filter->srcpad, GST_DATA (outbuf)); + g_object_unref(G_OBJECT(filter->pixbuf_loader)); + filter->pixbuf_loader = NULL; + dump_buffer = FALSE; + } + } + + if (dump_buffer) { + if (filter->pixbuf_loader != NULL) { + gdk_pixbuf_loader_close (filter->pixbuf_loader, NULL); + g_object_unref(G_OBJECT(filter->pixbuf_loader)); + filter->pixbuf_loader = NULL; + } + } + + if (GST_IS_BUFFER (_data)) { + if (filter->pixbuf_loader == NULL) { + filter->pixbuf_loader = gdk_pixbuf_loader_new(); + filter->last_timestamp = GST_BUFFER_TIMESTAMP (buf); + } + + gdk_pixbuf_loader_write(filter->pixbuf_loader, GST_BUFFER_DATA(buf), + GST_BUFFER_SIZE(buf), &error); + gst_buffer_unref (buf); + } + + if (got_eos) { + gst_pad_event_default (pad, GST_EVENT (_data)); + } } static void diff --git a/ext/gdk_pixbuf/gstgdkpixbuf.h b/ext/gdk_pixbuf/gstgdkpixbuf.h index 6cfcdbc5..336c1e51 100644 --- a/ext/gdk_pixbuf/gstgdkpixbuf.h +++ b/ext/gdk_pixbuf/gstgdkpixbuf.h @@ -48,6 +48,9 @@ struct _GstGdkPixbuf GstPad *sinkpad, *srcpad; + GstClockTime last_timestamp; + GdkPixbufLoader *pixbuf_loader; + int width; int height; int rowstride; diff --git a/ext/libcaca/gstcacasink.h b/ext/libcaca/gstcacasink.h index 3a6e7bfe..4d1e1c0d 100644 --- a/ext/libcaca/gstcacasink.h +++ b/ext/libcaca/gstcacasink.h @@ -34,9 +34,9 @@ extern "C" { #define GST_CACA_DEFAULT_SCREEN_WIDTH 80 #define GST_CACA_DEFAULT_SCREEN_HEIGHT 25 #define GST_CACA_DEFAULT_BPP 24 -#define GST_CACA_DEFAULT_RED_MASK R_MASK_32_INT -#define GST_CACA_DEFAULT_GREEN_MASK G_MASK_32_INT -#define GST_CACA_DEFAULT_BLUE_MASK B_MASK_32_INT +#define GST_CACA_DEFAULT_RED_MASK GST_VIDEO_BYTE1_MASK_32_INT +#define GST_CACA_DEFAULT_GREEN_MASK GST_VIDEO_BYTE2_MASK_32_INT +#define GST_CACA_DEFAULT_BLUE_MASK GST_VIDEO_BYTE3_MASK_32_INT //#define GST_CACA_DEFAULT_RED_MASK R_MASK_32_REVERSE_INT //#define GST_CACA_DEFAULT_GREEN_MASK G_MASK_32_REVERSE_INT -- cgit