[gst-cvs] CVS: gstreamer/plugins/videoscale Makefile.am,1.3,1.3.14.1 gstscale_x86.c,1.2,1.2.4.1 gstscale_x86.h,1.2,1.2.4.1 gstvideoscale.c,1.2,1.2.4.1 videoscale.c,1.17,1.17.4.1 videoscale.h,1.7,1.7.4.1 gstvideoscale.h,1.2,NONE

Erik Walthinsen omegahacker at users.sourceforge.net
Wed Oct 17 01:52:22 PDT 2001


Update of /cvsroot/gstreamer/gstreamer/plugins/videoscale
In directory usw-pr-cvs1:/tmp/cvs-serv20849/plugins/videoscale

Modified Files:
      Tag: BRANCH-EVENTS1
	Makefile.am gstscale_x86.c gstscale_x86.h gstvideoscale.c 
	videoscale.c videoscale.h 
Removed Files:
      Tag: BRANCH-EVENTS1
	gstvideoscale.h 
Log Message:
merge from HEAD on 20011016

Index: Makefile.am
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/plugins/videoscale/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.3.14.1
diff -u -d -r1.3 -r1.3.14.1
--- Makefile.am	2001/01/14 21:55:41	1.3
+++ Makefile.am	2001/10/17 08:51:02	1.3.14.1
@@ -2,8 +2,21 @@
 
 filter_LTLIBRARIES = libvideoscale.la
 
-libvideoscale_la_SOURCES = videoscale.c
+if HAVE_CPU_I386
+ARCHSRCS = \
+	gstscale_x86.c \
+	gstscale_x86_asm.s
+else
+ARCHSRCS =
+endif
 
-noinst_HEADERS = videoscale.h
+libvideoscale_la_SOURCES = \
+			gstvideoscale.c \
+			videoscale.c \
+			$(ARCHSRCS)
+
+libvideoscale_la_LIBADD =
+
+noinst_HEADERS = videoscale.h gstscale_x86.h
 
 CFLAGS += -O2 $(FOMIT_FRAME_POINTER) -funroll-all-loops -finline-functions -ffast-math

Index: gstscale_x86.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/plugins/videoscale/gstscale_x86.c,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -d -r1.2 -r1.2.4.1
--- gstscale_x86.c	2001/06/21 11:49:31	1.2
+++ gstscale_x86.c	2001/10/17 08:51:02	1.2.4.1
@@ -19,11 +19,11 @@
 
 //#define DEBUG_ENABLED
 
-#include "gstvideoscale.h"
+#include "videoscale.h"
 
 /* scalers */
 void gst_videoscale_generate_rowbytes_x86	(unsigned char *copy_row, int src_w, int dst_w, int bpp);
-void gst_videoscale_scale_nearest_x86		(GstVideoScale *scale,
+void gst_videoscale_scale_nearest_x86		(Videoscale *scale,
 							 unsigned char *src, unsigned char *dest,
 							 int sw, int sh, int dw, int dh);
 

Index: gstscale_x86.h
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/plugins/videoscale/gstscale_x86.h,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -d -r1.2 -r1.2.4.1
--- gstscale_x86.h	2001/06/21 11:49:31	1.2
+++ gstscale_x86.h	2001/10/17 08:51:02	1.2.4.1
@@ -24,7 +24,7 @@
 
 /* scalers */
 void gst_videoscale_generate_rowbytes_x86	(unsigned char *copy_row, int src_w, int dst_w, int bpp);
-void gst_videoscale_scale_nearest_x86		(GstVideoScale *scale,
+void gst_videoscale_scale_nearest_x86		(Videoscale *scale,
 						 unsigned char *src, unsigned char *dest,
 						 int sw, int sh, int dw, int dh);
 #endif /* __GST_VIDEOSCALE__X86_H__ */

Index: gstvideoscale.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/plugins/videoscale/gstvideoscale.c,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -d -r1.2 -r1.2.4.1
--- gstvideoscale.c	2001/06/21 11:49:31	1.2
+++ gstvideoscale.c	2001/10/17 08:51:02	1.2.4.1
@@ -17,114 +17,90 @@
  * Boston, MA 02111-1307, USA.
  */
 
-//#define DEBUG_ENABLED
+#define DEBUG_ENABLED
 #include <stdlib.h>
 #include <math.h>
 
 #include "config.h"
-#include "gstvideoscale.h"
+#include "videoscale.h"
+#undef HAVE_CPU_I386
 #ifdef HAVE_CPU_I386
 #include "gstscale_x86.h"
 #endif
 
-static void	gst_videoscale_scale_yuv		(GstVideoScale *scale, unsigned char *src, unsigned char *dest);
-static void	gst_videoscale_scale_rgb		(GstVideoScale *scale, unsigned char *src, unsigned char *dest);
+static void	gst_videoscale_scale_yuv		(Videoscale *scale, unsigned char *src, unsigned char *dest);
+static void	gst_videoscale_scale_rgb		(Videoscale *scale, unsigned char *src, unsigned char *dest);
 
 /* scalers */
-static void	gst_videoscale_scale_nearest		(GstVideoScale *scale, unsigned char *src, unsigned char *dest,
+static void	gst_videoscale_scale_nearest		(Videoscale *scale, unsigned char *src, unsigned char *dest,
 							 int sw, int sh, int dw, int dh);
-static void	gst_videoscale_scale_plane_slow		(GstVideoScale *scale, unsigned char *src, unsigned char *dest,
+static void	gst_videoscale_scale_plane_slow		(Videoscale *scale, unsigned char *src, unsigned char *dest,
 							 int sw, int sh, int dw, int dh);
-static void	gst_videoscale_scale_point_sample	(GstVideoScale *scale, unsigned char *src, unsigned char *dest,
+static void	gst_videoscale_scale_point_sample	(Videoscale *scale, unsigned char *src, unsigned char *dest,
 							 int sw, int sh, int dw, int dh);
 
 /* filters */
 static unsigned char gst_videoscale_bilinear		(unsigned char *src, double x, double y, int sw, int sh);
 static unsigned char gst_videoscale_bicubic		(unsigned char *src, double x, double y, int sw, int sh);
 
-GstVideoScale*
-gst_videoscale_new (gint sw, gint sh, gint dw, gint dh,
-		    GstColorSpaceType format, GstVideoScaleMethod method)
+void
+gst_videoscale_setup (Videoscale *scale)
 {
-  GstVideoScale *new = g_malloc(sizeof(GstVideoScale));
-
-  new->source_width = sw;
-  new->source_height = sh;
-  new->dest_width = dw;
-  new->dest_height = dh;
-  new->format = format;
-  new->method = method;
-
-
-  switch (format) {
-    case GST_COLORSPACE_YUV420P:
-      new->scale = gst_videoscale_scale_yuv;
-      new->scale_bytes = 1;
-      break;
-    case GST_COLORSPACE_RGB555:
-    case GST_COLORSPACE_RGB565:
-    case GST_COLORSPACE_BGR555:
-    case GST_COLORSPACE_BGR565:
-      new->scale = gst_videoscale_scale_rgb;
-      new->scale_bytes = 2;
+  switch (scale->format) {
+    case GST_MAKE_FOURCC('I','4','2','0'):
+      scale->scale_cc = gst_videoscale_scale_yuv;
+      scale->scale_bytes = 1;
       break;
-    case GST_COLORSPACE_RGB32:
-    case GST_COLORSPACE_BGR32:
-      new->scale = gst_videoscale_scale_rgb;
-      new->scale_bytes = 4;
+    case GST_MAKE_FOURCC('R','G','B',' '):
+      scale->scale_cc = gst_videoscale_scale_rgb;
+      /* XXX */
+      //scale->scale_bytes = gst_caps_get_int(scale->srcpad->caps,"bpp")/8;
       break;
     default:
-      g_print("videoscale: unsupported video format %d\n", format);
-      g_free(new);
-      return NULL;
+      g_print("videoscale: unsupported video format %08x\n", scale->format);
+      return; /* XXX */
   }
 
-  switch (method) {
+  switch (scale->method) {
     case GST_VIDEOSCALE_POINT_SAMPLE:
-      new->scaler = gst_videoscale_scale_point_sample;
+      scale->scaler = gst_videoscale_scale_point_sample;
       GST_DEBUG (0,"videoscale: scaling method POINT_SAMPLE\n");
       break;
     case GST_VIDEOSCALE_NEAREST:
 #ifdef HAVE_CPU_I386
-      gst_videoscale_generate_rowbytes_x86 (new->copy_row, sw, dw, new->scale_bytes);
-      new->scaler = gst_videoscale_scale_nearest_x86;
+      gst_videoscale_generate_rowbytes_x86 (scale->copy_row, scale->width,
+		      scale->targetwidth, scale->scale_bytes);
+      scale->scaler = gst_videoscale_scale_nearest_x86;
 #else
-      new->scaler = gst_videoscale_scale_nearest;
+      scale->scaler = gst_videoscale_scale_nearest;
 #endif
       GST_DEBUG (0,"videoscale: scaling method NEAREST\n");
       break;
     case GST_VIDEOSCALE_BILINEAR:
-      new->scaler = gst_videoscale_scale_plane_slow;
-      new->filter = gst_videoscale_bilinear;
+      scale->scaler = gst_videoscale_scale_plane_slow;
+      scale->filter = gst_videoscale_bilinear;
       GST_DEBUG (0,"videoscale: scaling method BILINEAR\n");
       break;
     case GST_VIDEOSCALE_BICUBIC:
-      new->scaler = gst_videoscale_scale_plane_slow;
-      new->filter = gst_videoscale_bicubic;
+      scale->scaler = gst_videoscale_scale_plane_slow;
+      scale->filter = gst_videoscale_bicubic;
       GST_DEBUG (0,"videoscale: scaling method BICUBIC\n");
       break;
     default:
-      g_print("videoscale: unsupported scaling method %d\n", method);
-      g_free(new);
-      return NULL;
+      g_print("videoscale: unsupported scaling method %d\n", scale->method);
+      return; /* XXX */
   }
-
-  return new;
-}
 
-void
-gst_videoscale_destroy (GstVideoScale *scale)
-{
-  g_free(scale);
+  return; /* XXX */
 }
 
 static void
-gst_videoscale_scale_rgb (GstVideoScale *scale, unsigned char *src, unsigned char *dest)
+gst_videoscale_scale_rgb (Videoscale *scale, unsigned char *src, unsigned char *dest)
 {
-  int sw = scale->source_width;
-  int sh = scale->source_height;
-  int dw = scale->dest_width;
-  int dh = scale->dest_height;
+  int sw = scale->width;
+  int sh = scale->height;
+  int dw = scale->targetwidth;
+  int dh = scale->targetheight;
   GST_DEBUG (0,"videoscale: scaling RGB %dx%d to %dx%d\n", sw, sh, dw, dh);
 
   switch (scale->scale_bytes) {
@@ -145,12 +121,12 @@
 }
 
 static void
-gst_videoscale_scale_yuv (GstVideoScale *scale, unsigned char *src, unsigned char *dest)
+gst_videoscale_scale_yuv (Videoscale *scale, unsigned char *src, unsigned char *dest)
 {
-  int sw = scale->source_width;
-  int sh = scale->source_height;
-  int dw = scale->dest_width;
-  int dh = scale->dest_height;
+  int sw = scale->width;
+  int sh = scale->height;
+  int dw = scale->targetwidth;
+  int dh = scale->targetheight;
 
   GST_DEBUG (0,"videoscale: scaling YUV420P %dx%d to %dx%d\n", sw, sh, dw, dh);
 
@@ -238,7 +214,7 @@
 }
 
 static void
-gst_videoscale_scale_plane_slow (GstVideoScale *scale, unsigned char *src, unsigned char *dest,
+gst_videoscale_scale_plane_slow (Videoscale *scale, unsigned char *src, unsigned char *dest,
 		                 int sw, int sh, int dw, int dh)
 {
   double zoomx = ((double)dw)/(double)sw;
@@ -268,7 +244,7 @@
 }
 
 static void
-gst_videoscale_scale_point_sample (GstVideoScale *scale, unsigned char *src, unsigned char *dest,
+gst_videoscale_scale_point_sample (Videoscale *scale, unsigned char *src, unsigned char *dest,
 		                   int sw, int sh, int dw, int dh)
 {
   int ypos, yinc, y;
@@ -316,7 +292,7 @@
 }
 
 static void
-gst_videoscale_scale_nearest (GstVideoScale *scale,
+gst_videoscale_scale_nearest (Videoscale *scale,
 		              unsigned char *src,
 			      unsigned char *dest,
 			      int sw, int sh, int dw, int dh)
@@ -391,3 +367,4 @@
     ypos += yinc;
   }
 }
+

Index: videoscale.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/plugins/videoscale/videoscale.c,v
retrieving revision 1.17
retrieving revision 1.17.4.1
diff -u -d -r1.17 -r1.17.4.1
--- videoscale.c	2001/08/21 20:16:48	1.17
+++ videoscale.c	2001/10/17 08:51:03	1.17.4.1
@@ -145,29 +145,65 @@
 
 }
 
+static GstPadNegotiateReturn
+videoscale_negotiate_src (GstPad *pad, GstCaps **caps, gpointer *data)
+{
+  Videoscale *videoscale = GST_VIDEOSCALE (gst_pad_get_parent (pad));
+  GstPadNegotiateReturn proxyresult;
+  gint format;
+
+  GST_DEBUG(0,"videoscale_negotiate_src\n");
+
+  format = gst_caps_get_int (gst_pad_get_caps(videoscale->sinkpad), "format");
+
+  //if(*caps==NULL){
+    *caps = GST_CAPS_NEW ( "videoscale_caps",
+		      "video/raw",
+		        "format",	GST_PROPS_FOURCC (videoscale->format),
+			"width",	GST_PROPS_INT (videoscale->targetwidth),
+			"height",	GST_PROPS_INT (videoscale->targetheight)
+		    );
+    //videoscale->srccaps = get_caps_ref(*caps);
+//    return GST_PAD_NEGOTIATE_TRY;
+//  }
+
+  return GST_PAD_NEGOTIATE_AGREE;
+}
+
+static GstPadNegotiateReturn
+videoscale_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data)
+{
+  Videoscale *videoscale = GST_VIDEOSCALE (gst_pad_get_parent (pad));
+
+  GST_DEBUG(0,"videoscale_negotiate_sink\n");
+
+  if (*caps==NULL)
+    return GST_PAD_NEGOTIATE_FAIL;
+  
+  return GST_PAD_NEGOTIATE_AGREE;
+  //return gst_pad_negotiate_proxy(pad,videoscale->srcpad, caps);
+}
+
 static void
 gst_videoscale_newcaps (GstPad *pad, GstCaps *caps)
 {
   Videoscale *videoscale;
 
+  GST_DEBUG(0,"gst_videoscale_newcaps\n");
   videoscale = GST_VIDEOSCALE (gst_pad_get_parent (pad));
 
-  if (videoscale->scaler) 
-    gst_videoscale_destroy(videoscale->scaler);
-
   videoscale->width = gst_caps_get_int (caps, "width");
   videoscale->height = gst_caps_get_int (caps, "height");
-  videoscale->format = GST_COLORSPACE_YUV420P;
+  videoscale->format = gst_caps_get_int (caps, "format");
 
-  videoscale->scaler = gst_videoscale_new(videoscale->width, 
-		      videoscale->height, videoscale->targetwidth, videoscale->targetheight,
-		      videoscale->format, videoscale->method);
+  gst_videoscale_setup(videoscale);
 
+  GST_DEBUG(0,"width %d\n",videoscale->targetwidth);
   gst_pad_set_caps (videoscale->srcpad, 
 		    GST_CAPS_NEW (
 		      "videoscale_src",
 		      "video/raw",
-		        "format",	GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')),
+		        "format",	GST_PROPS_FOURCC (videoscale->format),
 			"width",	GST_PROPS_INT (videoscale->targetwidth),
 			"height",	GST_PROPS_INT (videoscale->targetheight)
 		    ));
@@ -176,18 +212,21 @@
 static void
 gst_videoscale_init (Videoscale *videoscale)
 {
+  GST_DEBUG(0,"gst_videoscale_init\n");
   videoscale->sinkpad = gst_pad_new_from_template (
 		  GST_PADTEMPLATE_GET (sink_templ), "sink");
+  gst_pad_set_negotiate_function(videoscale->sinkpad,videoscale_negotiate_sink);
   gst_element_add_pad(GST_ELEMENT(videoscale),videoscale->sinkpad);
   gst_pad_set_chain_function(videoscale->sinkpad,gst_videoscale_chain);
   gst_pad_set_newcaps_function(videoscale->sinkpad,gst_videoscale_newcaps);
 
   videoscale->srcpad = gst_pad_new_from_template (
 		  GST_PADTEMPLATE_GET (src_templ), "src");
+  //gst_pad_set_negotiate_function(videoscale->srcpad,videoscale_negotiate_src);
   gst_element_add_pad(GST_ELEMENT(videoscale),videoscale->srcpad);
 
-  videoscale->targetwidth = -1;
-  videoscale->targetheight = -1;
+  //videoscale->targetwidth = -1;
+  //videoscale->targetheight = -1;
   videoscale->method = GST_VIDEOSCALE_NEAREST;
   //videoscale->method = GST_VIDEOSCALE_BILINEAR;
   //videoscale->method = GST_VIDEOSCALE_POINT_SAMPLE;
@@ -202,6 +241,7 @@
   gulong size;
   GstBuffer *outbuf;
 
+//GST_DEBUG(0,"gst_videoscale_chain\n");
   g_return_if_fail (pad != NULL);
   g_return_if_fail (GST_IS_PAD (pad));
   g_return_if_fail (buf != NULL);
@@ -210,15 +250,30 @@
   data = GST_BUFFER_DATA(buf);
   size = GST_BUFFER_SIZE(buf);
 
+  if(!videoscale->scale_cc){
+    videoscale->format = gst_caps_get_int (gst_pad_get_caps(pad), "format");
+    gst_videoscale_setup(videoscale);
+  }
   GST_DEBUG (0,"gst_videoscale_chain: got buffer of %ld bytes in '%s'\n",size,
 		              GST_OBJECT_NAME (videoscale));
+ 
+#if 0
+GST_DEBUG(0,"size=%d from=%dx%d to=%dx%d newsize=%d\n",
+	size,
+	videoscale->width, videoscale->height,
+	videoscale->targetwidth, videoscale->targetheight,
+  	videoscale->targetwidth*videoscale->targetheight + videoscale->targetwidth*videoscale->targetheight/2);
+#endif
 
   outbuf = gst_buffer_new();
+  /* XXX this is wrong */
   GST_BUFFER_SIZE(outbuf) = videoscale->targetwidth*videoscale->targetheight +
   			    videoscale->targetwidth*videoscale->targetheight/2;
   GST_BUFFER_DATA(outbuf) = g_malloc (videoscale->targetwidth*videoscale->targetheight*2);
+  GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf);
 
-  gst_videoscale_scale(videoscale->scaler, data, GST_BUFFER_DATA(outbuf));
+  //g_return_if_fail(videoscale->scale_cc != NULL);
+  videoscale->scale_cc(videoscale, data, GST_BUFFER_DATA(outbuf));
 
   GST_DEBUG (0,"gst_videoscale_chain: pushing buffer of %d bytes in '%s'\n",GST_BUFFER_SIZE(outbuf),
 		              GST_OBJECT_NAME (videoscale));
@@ -237,6 +292,7 @@
   g_return_if_fail(GST_IS_VIDEOSCALE(object));
   src = GST_VIDEOSCALE(object);
 
+  GST_DEBUG(0,"gst_videoscale_set_property\n");
   switch (prop_id) {
     case ARG_WIDTH:
       src->targetwidth = g_value_get_int (value);
@@ -282,12 +338,6 @@
 plugin_init (GModule *module, GstPlugin *plugin)
 {
   GstElementFactory *factory;
-
-  /* this filter needs the riff parser */
-  if (!gst_library_load("gstvideoscale")) {
-    gst_info("mpeg2play:: could not load support library: 'gstvideoscale'\n");
-    return FALSE;
-  }
 
   /* create an elementfactory for the videoscale element */
   factory = gst_elementfactory_new("videoscale",GST_TYPE_VIDEOSCALE,

Index: videoscale.h
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/plugins/videoscale/videoscale.h,v
retrieving revision 1.7
retrieving revision 1.7.4.1
diff -u -d -r1.7 -r1.7.4.1
--- videoscale.h	2001/06/25 01:20:11	1.7
+++ videoscale.h	2001/10/17 08:51:03	1.7.4.1
@@ -42,6 +42,13 @@
 #define GST_IS_VIDEOSCALE_CLASS(obj) \
   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEOSCALE))
 
+typedef enum {
+  GST_VIDEOSCALE_POINT_SAMPLE,
+  GST_VIDEOSCALE_NEAREST,
+  GST_VIDEOSCALE_BILINEAR,
+  GST_VIDEOSCALE_BICUBIC
+} GstVideoScaleMethod;
+
 typedef struct _Videoscale Videoscale;
 typedef struct _VideoscaleClass VideoscaleClass;
 
@@ -56,9 +63,15 @@
   gint height;
   gint targetwidth;
   gint targetheight;
-  //GstVideoScaleMethod method;
-
-  //GstVideoScale *scaler;
+  GstVideoScaleMethod method;
+  guint scale_bytes;
+  
+  /* private */
+  guchar *temp;
+  void (*scale_cc) (Videoscale *scale, guchar *src, guchar *dest);
+  void (*scaler) (Videoscale *scale, guchar *src, guchar *dest,int,int,int,int);
+  guchar (*filter) (guchar *src, gdouble x, gdouble y, gint sw, gint sh);
+  guchar copy_row[8192];
 };
 
 struct _VideoscaleClass {
@@ -67,6 +80,8 @@
 
 GType gst_videoscale_get_type(void);
 
+void gst_videoscale_setup(Videoscale *);
+#define gst_videoscale_scale(scale, src, dest) (scale)->scale_cc((scale), (src), (dest))
 
 #ifdef __cplusplus
 }

--- gstvideoscale.h DELETED ---





More information about the Gstreamer-commits mailing list