gegl r1932 - in trunk: . operations/blur operations/enhance operations/io



Author: neo
Date: Tue Jan 29 07:33:13 2008
New Revision: 1932
URL: http://svn.gnome.org/viewvc/gegl?rev=1932&view=rev

Log:
2008-01-29  Sven Neumann  <sven gimp org>

	* operations/enhance/bilateral-filter.c
	* operations/enhance/snn-mean.c
	* operations/io/ff-load.c: use g_new() instead of g_malloc().

	* operations/io/load.c (prepare): fixed bug in error handling.



Modified:
   trunk/ChangeLog
   trunk/operations/blur/gaussian-blur.c
   trunk/operations/enhance/bilateral-filter.c
   trunk/operations/enhance/snn-mean.c
   trunk/operations/io/ff-load.c
   trunk/operations/io/load.c

Modified: trunk/operations/blur/gaussian-blur.c
==============================================================================
--- trunk/operations/blur/gaussian-blur.c	(original)
+++ trunk/operations/blur/gaussian-blur.c	Tue Jan 29 07:33:13 2008
@@ -321,8 +321,8 @@
   gfloat *src_buf;
   gfloat *dst_buf;
 
-  src_buf = g_malloc0 (gegl_buffer_get_pixel_count (src) * 4 * 4);
-  dst_buf = g_malloc0 (gegl_buffer_get_pixel_count (dst) * 4 * 4);
+  src_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (src) * 4);
+  dst_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (dst) * 4);
 
   gegl_buffer_get (src, 1.0, NULL, babl_format ("RaGaBaA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
 
@@ -363,8 +363,8 @@
   gfloat *src_buf;
   gfloat *dst_buf;
 
-  src_buf = g_malloc0 (gegl_buffer_get_pixel_count (src) * 4 * 4);
-  dst_buf = g_malloc0 (gegl_buffer_get_pixel_count (dst) * 4 * 4);
+  src_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (src) * 4);
+  dst_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (dst) * 4);
 
   gegl_buffer_get (src, 1.0, NULL, babl_format ("RaGaBaA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
 

Modified: trunk/operations/enhance/bilateral-filter.c
==============================================================================
--- trunk/operations/enhance/bilateral-filter.c	(original)
+++ trunk/operations/enhance/bilateral-filter.c	Tue Jan 29 07:33:13 2008
@@ -87,11 +87,11 @@
   gint offset;
   gfloat *src_buf;
   gfloat *dst_buf;
-  gint width = (int)radius*2+1;
+  gint width = (gint) radius * 2 + 1;
 
-  gauss = g_alloca (width*width*sizeof(gfloat));
-  src_buf = g_malloc0 (gegl_buffer_get_pixel_count(src) * 4 *4);
-  dst_buf = g_malloc0 (gegl_buffer_get_pixel_count(dst) * 4 * 4);
+  gauss = g_newa (gfloat, width * width);
+  src_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count(src) * 4);
+  dst_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count(dst) * 4);
 
   gegl_buffer_get (src, 1.0, NULL, babl_format ("RGBA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
 

Modified: trunk/operations/enhance/snn-mean.c
==============================================================================
--- trunk/operations/enhance/snn-mean.c	(original)
+++ trunk/operations/enhance/snn-mean.c	Tue Jan 29 07:33:13 2008
@@ -107,8 +107,8 @@
   gfloat *src_buf;
   gfloat *dst_buf;
 
-  src_buf = g_malloc0 (gegl_buffer_get_pixel_count (src) * 4 * 4);
-  dst_buf = g_malloc0 (gegl_buffer_get_pixel_count (dst) * 4 * 4);
+  src_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (src) * 4);
+  dst_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (dst) * 4);
 
   gegl_buffer_get (src, 1.0, NULL, babl_format ("RGBA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
 

Modified: trunk/operations/io/ff-load.c
==============================================================================
--- trunk/operations/io/ff-load.c	(original)
+++ trunk/operations/io/ff-load.c	Tue Jan 29 07:33:13 2008
@@ -354,17 +354,19 @@
   {
     if (p->ic && !decode_frame (self, self->frame))
       {
-        gint pxsize;
-        gchar *buf;
-        gint x,y;
+        guchar *buf;
+        gint    pxsize;
+        gint    x,y;
+
         g_object_get (output, "px-size", &pxsize, NULL);
-        buf = g_malloc (p->width * p->height * pxsize);
+        buf = g_new (guchar, p->width * p->height * pxsize);
+
         for (y=0; y < p->height; y++)
           {
-            guchar *dst = (guchar*)buf + y * p->width * 4;
-            guchar *ysrc = (guchar*) (p->lavc_frame->data[0] + y * p->lavc_frame->linesize[0]);
-            guchar *usrc = (guchar*) (p->lavc_frame->data[1] + y/2 * p->lavc_frame->linesize[1]);
-            guchar *vsrc = (guchar*) (p->lavc_frame->data[2] + y/2 * p->lavc_frame->linesize[2]);
+            guchar       *dst  = buf + y * p->width * 4;
+            const guchar *ysrc = p->lavc_frame->data[0] + y * p->lavc_frame->linesize[0];
+            const guchar *usrc = p->lavc_frame->data[1] + y/2 * p->lavc_frame->linesize[1];
+            const guchar *vsrc = p->lavc_frame->data[2] + y/2 * p->lavc_frame->linesize[2];
 
             for (x=0;x < p->width; x++)
               {
@@ -379,7 +381,7 @@
                 byteclamp(R);\
                 byteclamp(G);\
                 byteclamp(B);\
-              }while(0)
+              } while(0)
 
               YUV82RGB8 (*ysrc, *usrc, *vsrc, R, G, B);
 
@@ -388,8 +390,8 @@
               ysrc ++;
               if (x % 2)
                 {
-                  usrc ++;
-                  vsrc ++;
+                  usrc++;
+                  vsrc++;
                 }
               }
           }

Modified: trunk/operations/io/load.c
==============================================================================
--- trunk/operations/io/load.c	(original)
+++ trunk/operations/io/load.c	Tue Jan 29 07:33:13 2008
@@ -96,8 +96,9 @@
 
           if (!g_file_test (self->path, G_FILE_TEST_EXISTS))
             {
-              gchar *tmp = g_malloc(strlen (self->path) + 100);
-              sprintf (tmp, "File '%s' does not exist", self->path);
+              gchar *name = g_filename_display_name (filename);
+              gchar *tmp  = g_strdup_printf ("File '%s' does not exist", name);
+              g_free (name);
               g_warning ("load: %s", tmp);
               gegl_node_set (priv->load,
                              "operation", "text",
@@ -110,10 +111,10 @@
             {
               if (extension)
                 handler = gegl_extension_handler_get (extension);
-              gegl_node_set (priv->load, 
+              gegl_node_set (priv->load,
                              "operation", handler,
                              NULL);
-              gegl_node_set (priv->load, 
+              gegl_node_set (priv->load,
                              "path",  self->path,
                              NULL);
             }
@@ -177,7 +178,7 @@
   klass->prepare = prepare;
   klass->attach = attach;
   klass->detect = detect;
-  
+
   G_OBJECT_CLASS (klass)->dispose = dispose;
   G_OBJECT_CLASS (klass)->finalize = finalize;
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]