Author: post
Date: 2010-10-16 16:32:05 +0200 (Sat, 16 Oct 2010)
New Revision: 3564

Modified:
   trunk/plugins/denoise/complexblock.cpp
   trunk/plugins/denoise/floatimageplane.cpp
   trunk/plugins/denoise/floatplanarimage-x86.cpp
Log:
Seems like we cannot rely on fftwf_malloc always returning aligned data on all 
systems. Change allocation to posix_memalign.

Modified: trunk/plugins/denoise/complexblock.cpp
===================================================================
--- trunk/plugins/denoise/complexblock.cpp      2010-10-16 14:16:31 UTC (rev 
3563)
+++ trunk/plugins/denoise/complexblock.cpp      2010-10-16 14:32:05 UTC (rev 
3564)
@@ -20,14 +20,16 @@
 #include "complexblock.h"
 #include <math.h>
 #include "floatimageplane.h"
+#include <stdlib.h>  /* posix_memalign() */
 
+
 namespace RawStudio {
 namespace FFTFilter {
 
 ComplexBlock::ComplexBlock(int _w, int _h): w(_w), h(_h)
 {
   pitch = w * sizeof(fftwf_complex);
-  complex = (fftwf_complex*)fftwf_malloc(h*pitch); 
+  g_assert(0 == posix_memalign((void**)&complex, 16, pitch*h));
   g_assert(complex);
   temp = new FloatImagePlane(256,1);
   temp->allocateImage();
@@ -35,7 +37,7 @@
 
 ComplexBlock::~ComplexBlock(void)
 {
-  fftwf_free(complex);
+  free(complex);
   complex = 0;
   delete temp;
 }

Modified: trunk/plugins/denoise/floatimageplane.cpp
===================================================================
--- trunk/plugins/denoise/floatimageplane.cpp   2010-10-16 14:16:31 UTC (rev 
3563)
+++ trunk/plugins/denoise/floatimageplane.cpp   2010-10-16 14:32:05 UTC (rev 
3564)
@@ -20,6 +20,7 @@
 #include "floatimageplane.h"
 #include "fftw3.h"
 #include <string.h>
+#include <stdlib.h>  /* posix_memalign() */
 
 namespace RawStudio {
 namespace FFTFilter {
@@ -38,7 +39,7 @@
 FloatImagePlane::~FloatImagePlane(void)
 {
   if (allocated)
-    fftwf_free(allocated);
+    free(allocated);
   if (filter)
     delete filter;
   filter = 0;
@@ -50,7 +51,7 @@
   if (allocated)
     return;
   pitch = ((w+3)/4)*4;
-  allocated = (gfloat *) fftwf_malloc(pitch*h*sizeof(gfloat)); 
+  g_assert(0 == posix_memalign((void**)&allocated, 16, 
pitch*h*sizeof(gfloat)));
   g_assert(allocated);
   data = allocated;
 }

Modified: trunk/plugins/denoise/floatplanarimage-x86.cpp
===================================================================
--- trunk/plugins/denoise/floatplanarimage-x86.cpp      2010-10-16 14:16:31 UTC 
(rev 3563)
+++ trunk/plugins/denoise/floatplanarimage-x86.cpp      2010-10-16 14:32:05 UTC 
(rev 3564)
@@ -335,7 +335,7 @@
 void FloatPlanarImage::packInterleavedYUV_SSE2( const ImgConvertJob* j)
 {
   RS_IMAGE16* image = j->rs;
-  float* temp =  (float*)fftwf_malloc(32*sizeof(float));
+  float temp[32] __attribute__ ((aligned (16)));
   for (int i = 0; i < 4; i++) {
     temp[i] = 1.402f;       // Cr to r
     temp[i+4] = -0.714f;    // Cr to g
@@ -416,7 +416,6 @@
       : //  %0         %1       %2         %3       %4
      );
   }
-  fftwf_free(temp);
 }
 
 #endif


_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit

Reply via email to