gegl r2494 - in branches/branch_zhangjb: . operations/frequency operations/frequency/tools



Author: zhangjb
Date: Sun Jun 22 15:08:00 2008
New Revision: 2494
URL: http://svn.gnome.org/viewvc/gegl?rev=2494&view=rev

Log:
* operations/frequency/dft-grey.c: deleted.
* operations/frequency/dft-inverse-grey.c: deleted.
* operations/frequency/dft.c: modified for freq-format.
* operations/frequency/preview-frequency-grey.c: deleted.
* operations/frequency/tools/component.c: add two functions.


Removed:
   branches/branch_zhangjb/operations/frequency/dft-grey.c
   branches/branch_zhangjb/operations/frequency/dft-inverse-grey.c
   branches/branch_zhangjb/operations/frequency/preview-frequency-grey.c
Modified:
   branches/branch_zhangjb/ChangeLog
   branches/branch_zhangjb/operations/frequency/dft.c
   branches/branch_zhangjb/operations/frequency/tools/component.c

Modified: branches/branch_zhangjb/operations/frequency/dft.c
==============================================================================
--- branches/branch_zhangjb/operations/frequency/dft.c	(original)
+++ branches/branch_zhangjb/operations/frequency/dft.c	Sun Jun 22 15:08:00 2008
@@ -33,10 +33,11 @@
 static GeglRectangle
 get_bounding_box (GeglOperation *operation)
 {
-  GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input");
+  GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation,
+                                                                   "input");
   GeglRectangle  result  = *in_rect;
 
-  result.width  += 2;
+  result.width = FFT_HALF(result.width);
   return result;
 }
 
@@ -57,16 +58,15 @@
   GeglRectangle *in_rect = gegl_operation_source_get_bounding_box (operation, "input");
   GeglRectangle  result  = *in_rect;
 
-  result.width  += 2;
+  result.width = FFT_HALF(result.width);
   return result;
 }
 
 static void
 prepare(GeglOperation *operation)
 {
-  Babl *format = babl_format ("RGBA double");
-  gegl_operation_set_format(operation, "input", format);
-  gegl_operation_set_format(operation, "output", format);
+  gegl_operation_set_format(operation, "input", babl_format ("RGBA double"));
+  gegl_operation_set_format(operation, "output", babl_format ("frequency double"));
 }
 
 static gboolean
@@ -85,19 +85,19 @@
 
   src_buf = g_new0(gdouble, 4*width*height);
   tmp_src_buf = g_new0(gdouble, width*height);
-  dst_buf = g_new0(gdouble, 4*2*width*FFT_HALF(height));
-  tmp_dst_buf = g_new0(gdouble, 2*width*FFT_HALF(height));
+  dst_buf = g_new0(gdouble, 8*width*FFT_HALF(width));
+  tmp_dst_buf = g_new0(gdouble, width*FFT_HALF(width));
 
   gegl_buffer_get(input, 1.0, NULL, babl_format ("RGBA double"), src_buf, GEGL_AUTO_ROWSTRIDE);
 
   for (i=0; i<4; i++)
     {
-      get_component(src_buf, tmp_src_buf, i, width*height);
+      get_rgba_component(src_buf, tmp_src_buf, i, width*height);
       dft(tmp_src_buf, (fftw_complex *)tmp_dst_buf, width, height);
-      set_component(tmp_dst_buf, dst_buf, i, (width+2)*height);
+      set_freq_component(tmp_dst_buf, dst_buf, i, FFT_HALF(width)*height);
     }
   
-  gegl_buffer_set(output, NULL, babl_format ("RGBA double"), dst_buf, GEGL_AUTO_ROWSTRIDE);
+  gegl_buffer_set(output, NULL, babl_format ("frequency double"), dst_buf, GEGL_AUTO_ROWSTRIDE);
 
   g_free(src_buf);
   g_free(dst_buf);

Modified: branches/branch_zhangjb/operations/frequency/tools/component.c
==============================================================================
--- branches/branch_zhangjb/operations/frequency/tools/component.c	(original)
+++ branches/branch_zhangjb/operations/frequency/tools/component.c	Sun Jun 22 15:08:00 2008
@@ -16,11 +16,18 @@
  * Copyright 2008 Zhang Junbo  <zhangjb svn gnome org>
  */
 
-gboolean get_component(gdouble* src_buf, gdouble* comp_buf, gint place, gint samples);
-gboolean set_component(gdouble* comp_buf, gdouble* dst_buf, gint place, gint samples);
+gboolean get_rgba_component(gdouble* src_buf, gdouble* comp_buf, gint place,
+                            gint samples);
+gboolean set_rgba_component(gdouble* comp_buf, gdouble* dst_buf, gint place,
+                            gint samples);
+gboolean get_freq_component(gdouble* src_buf, gdouble* comp_buf, gint place,
+                            gint samples);
+gboolean set_freq_component(gdouble* comp_buf, gdouble* dst_buf, gint place,
+                            gint samples);
 
 gboolean
-get_component(gdouble* src_buf, gdouble *comp_buf, gint place, gint samples)
+get_rgba_component(gdouble* src_buf, gdouble *comp_buf, gint place,
+                   gint samples)
 {
   src_buf += place;
   while (samples--)
@@ -30,10 +37,9 @@
     }
   return TRUE;
 }
-
   
 gboolean
-set_component(gdouble* comp_buf, gdouble* dst_buf, gint place, gint samples)
+set_rgba_component(gdouble* comp_buf, gdouble* dst_buf, gint place, gint samples)
 {
   dst_buf += place;
   while (samples--)
@@ -43,3 +49,31 @@
     }
   return TRUE;
 }
+
+gboolean
+get_freq_component(gdouble* src_buf, gdouble *comp_buf, gint place,
+                   gint samples)
+{
+  src_buf += place*2;
+  while (samples--)
+    {
+      *(comp_buf++) = *src_buf;
+      *(comp_buf++) = *(src_buf+1);
+      src_buf += 8;
+    }
+  return TRUE;
+}
+  
+gboolean
+set_freq_component(gdouble* comp_buf, gdouble* dst_buf, gint place,
+                   gint samples)
+{
+  dst_buf += place*2;
+  while (samples--)
+    {
+      *dst_buf = *(comp_buf++);
+      *(dst_buf+1) = *(comp_buf++);
+      dst_buf += 8;
+    }
+  return TRUE;
+}



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