From 7d4aa38318c20a4309d855f45e3744c9f300f697 Mon Sep 17 00:00:00 2001 From: cristy Date: Sun, 30 Jun 2013 01:59:39 +0000 Subject: [PATCH] --- MagickCore/effect.c | 25 ++- MagickCore/enhance.c | 8 +- MagickCore/fourier.c | 316 +++++++++++++++++---------------- MagickCore/magick-baseconfig.h | 140 +++++++++++---- MagickCore/version.h | 4 +- PerlMagick/Makefile.PL | 6 +- PerlMagick/quantum/Makefile.PL | 6 +- 7 files changed, 290 insertions(+), 215 deletions(-) diff --git a/MagickCore/effect.c b/MagickCore/effect.c index 69d6d9af6..06a45f627 100644 --- a/MagickCore/effect.c +++ b/MagickCore/effect.c @@ -1021,6 +1021,10 @@ MagickExport Image *DespeckleImage(const Image *image,ExceptionInfo *exception) MagickBooleanType status; + MemoryInfo + *buffer_info, + *pixel_info; + Quantum *restrict buffer, *restrict pixels; @@ -1057,17 +1061,20 @@ MagickExport Image *DespeckleImage(const Image *image,ExceptionInfo *exception) Allocate image buffer. */ length=(size_t) ((image->columns+2)*(image->rows+2)); - pixels=(Quantum *) AcquireQuantumMemory(length,sizeof(*pixels)); - buffer=(Quantum *) AcquireQuantumMemory(length,sizeof(*buffer)); - if ((pixels == (Quantum *) NULL) || (buffer == (Quantum *) NULL)) + pixel_info=AcquireVirtualMemory(length,sizeof(*pixels)); + buffer_info=AcquireVirtualMemory(length,sizeof(*buffer)); + if ((pixel_info == (MemoryInfo *) NULL) || + (buffer_info == (MemoryInfo *) NULL)) { - if (buffer != (Quantum *) NULL) - buffer=(Quantum *) RelinquishMagickMemory(buffer); - if (pixels != (Quantum *) NULL) - pixels=(Quantum *) RelinquishMagickMemory(pixels); + if (buffer_info != (MemoryInfo *) NULL) + buffer_info=RelinquishVirtualMemory(buffer_info); + if (pixel_info != (MemoryInfo *) NULL) + pixel_info=RelinquishVirtualMemory(pixel_info); despeckle_image=DestroyImage(despeckle_image); ThrowImageException(ResourceLimitError,"MemoryAllocationFailed"); } + pixels=(Quantum *) GetVirtualMemoryBlob(pixel_info); + buffer=(Quantum *) GetVirtualMemoryBlob(buffer_info); /* Reduce speckle in the image. */ @@ -1170,8 +1177,8 @@ MagickExport Image *DespeckleImage(const Image *image,ExceptionInfo *exception) } despeckle_view=DestroyCacheView(despeckle_view); image_view=DestroyCacheView(image_view); - buffer=(Quantum *) RelinquishMagickMemory(buffer); - pixels=(Quantum *) RelinquishMagickMemory(pixels); + buffer_info=RelinquishVirtualMemory(buffer_info); + pixel_info=RelinquishVirtualMemory(pixel_info); despeckle_image->type=image->type; if (status == MagickFalse) despeckle_image=DestroyImage(despeckle_image); diff --git a/MagickCore/enhance.c b/MagickCore/enhance.c index 945d4df98..0a3b11e32 100644 --- a/MagickCore/enhance.c +++ b/MagickCore/enhance.c @@ -1513,10 +1513,10 @@ MagickExport MagickBooleanType EqualizeImage(Image *image, (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); equalize_map=(double *) AcquireQuantumMemory(MaxMap+1UL, GetPixelChannels(image)*sizeof(*equalize_map)); - histogram=(double *) AcquireQuantumMemory(MaxMap+1UL, - GetPixelChannels(image)*sizeof(*histogram)); - map=(double *) AcquireQuantumMemory(MaxMap+1UL, - GetPixelChannels(image)*sizeof(*map)); + histogram=(double *) AcquireQuantumMemory(MaxMap+1UL,GetPixelChannels(image)* + sizeof(*histogram)); + map=(double *) AcquireQuantumMemory(MaxMap+1UL,GetPixelChannels(image)* + sizeof(*map)); if ((equalize_map == (double *) NULL) || (histogram == (double *) NULL) || (map == (double *) NULL)) { diff --git a/MagickCore/fourier.c b/MagickCore/fourier.c index 41442ce71..91e2de98e 100644 --- a/MagickCore/fourier.c +++ b/MagickCore/fourier.c @@ -44,6 +44,7 @@ */ #include "MagickCore/studio.h" #include "MagickCore/attribute.h" +#include "MagickCore/blob.h" #include "MagickCore/cache.h" #include "MagickCore/image.h" #include "MagickCore/image-private.h" @@ -134,6 +135,9 @@ static MagickBooleanType RollFourier(const size_t width,const size_t height, double *roll; + MemoryInfo + *roll_info; + register ssize_t i, x; @@ -146,9 +150,10 @@ static MagickBooleanType RollFourier(const size_t width,const size_t height, /* Move zero frequency (DC, average color) from (0,0) to (width/2,height/2). */ - roll=(double *) AcquireQuantumMemory((size_t) height,width*sizeof(*roll)); - if (roll == (double *) NULL) + roll_info=AcquireVirtualMemory(height,width*sizeof(*roll)); + if (roll_info == (MemoryInfo *) NULL) return(MagickFalse); + roll=(double *) GetVirtualMemoryBlob(roll_info); i=0L; for (y=0L; y < (ssize_t) height; y++) { @@ -168,7 +173,7 @@ static MagickBooleanType RollFourier(const size_t width,const size_t height, } } (void) CopyMagickMemory(fourier,roll,height*width*sizeof(*roll)); - roll=(double *) RelinquishMagickMemory(roll); + roll_info=RelinquishVirtualMemory(roll_info); return(MagickTrue); } @@ -225,8 +230,8 @@ static MagickBooleanType ForwardFourier(const FourierInfo *fourier_info, *phase_view; double - *magnitude_source, - *phase_source; + *magnitude_pixels, + *phase_pixels; Image *magnitude_image, @@ -235,6 +240,10 @@ static MagickBooleanType ForwardFourier(const FourierInfo *fourier_info, MagickBooleanType status; + MemoryInfo + *magnitude_info, + *phase_info; + register Quantum *q; @@ -256,37 +265,41 @@ static MagickBooleanType ForwardFourier(const FourierInfo *fourier_info, /* Create "Fourier Transform" image from constituent arrays. */ - magnitude_source=(double *) AcquireQuantumMemory((size_t) - fourier_info->height,fourier_info->width*sizeof(*magnitude_source)); - if (magnitude_source == (double *) NULL) - return(MagickFalse); - (void) ResetMagickMemory(magnitude_source,0,fourier_info->height* - fourier_info->width*sizeof(*magnitude_source)); - phase_source=(double *) AcquireQuantumMemory((size_t) fourier_info->height, - fourier_info->width*sizeof(*phase_source)); - if (phase_source == (double *) NULL) + magnitude_info=AcquireVirtualMemory((size_t) fourier_info->height, + fourier_info->width*sizeof(*magnitude_pixels)); + phase_info=AcquireVirtualMemory((size_t) fourier_info->height, + fourier_info->width*sizeof(*phase_pixels)); + if ((phase_info == (MemoryInfo *) NULL) || + (magnitude_info == (MemoryInfo *) NULL)) { + if (phase_info != (MemoryInfo *) NULL) + phase_info=RelinquishVirtualMemory(phase_info); + if (magnitude_info != (MemoryInfo *) NULL) + magnitude_info=RelinquishVirtualMemory(magnitude_info); (void) ThrowMagickException(exception,GetMagickModule(), ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); - magnitude_source=(double *) RelinquishMagickMemory(magnitude_source); return(MagickFalse); } - (void) ResetMagickMemory(phase_source,0,fourier_info->height* - fourier_info->width*sizeof(*phase_source)); + magnitude_pixels=(double *) GetVirtualMemoryBlob(magnitude_info); + (void) ResetMagickMemory(magnitude_pixels,0,fourier_info->height* + fourier_info->width*sizeof(*magnitude_pixels)); + phase_pixels=(double *) GetVirtualMemoryBlob(magnitude_info); + (void) ResetMagickMemory(phase_pixels,0,fourier_info->height* + fourier_info->width*sizeof(*phase_pixels)); status=ForwardQuadrantSwap(fourier_info->height,fourier_info->height, - magnitude,magnitude_source); + magnitude,magnitude_pixels); if (status != MagickFalse) status=ForwardQuadrantSwap(fourier_info->height,fourier_info->height,phase, - phase_source); - CorrectPhaseLHS(fourier_info->height,fourier_info->height,phase_source); + phase_pixels); + CorrectPhaseLHS(fourier_info->height,fourier_info->height,phase_pixels); if (fourier_info->modulus != MagickFalse) { i=0L; for (y=0L; y < (ssize_t) fourier_info->height; y++) for (x=0L; x < (ssize_t) fourier_info->width; x++) { - phase_source[i]/=(2.0*MagickPI); - phase_source[i]+=0.5; + phase_pixels[i]/=(2.0*MagickPI); + phase_pixels[i]+=0.5; i++; } } @@ -306,31 +319,31 @@ static MagickBooleanType ForwardFourier(const FourierInfo *fourier_info, default: { SetPixelRed(magnitude_image,ClampToQuantum(QuantumRange* - magnitude_source[i]),q); + magnitude_pixels[i]),q); break; } case GreenPixelChannel: { SetPixelGreen(magnitude_image,ClampToQuantum(QuantumRange* - magnitude_source[i]),q); + magnitude_pixels[i]),q); break; } case BluePixelChannel: { SetPixelBlue(magnitude_image,ClampToQuantum(QuantumRange* - magnitude_source[i]),q); + magnitude_pixels[i]),q); break; } case BlackPixelChannel: { SetPixelBlack(magnitude_image,ClampToQuantum(QuantumRange* - magnitude_source[i]),q); + magnitude_pixels[i]),q); break; } case AlphaPixelChannel: { SetPixelAlpha(magnitude_image,ClampToQuantum(QuantumRange* - magnitude_source[i]),q); + magnitude_pixels[i]),q); break; } } @@ -358,31 +371,31 @@ static MagickBooleanType ForwardFourier(const FourierInfo *fourier_info, default: { SetPixelRed(phase_image,ClampToQuantum(QuantumRange* - phase_source[i]),q); + phase_pixels[i]),q); break; } case GreenPixelChannel: { SetPixelGreen(phase_image,ClampToQuantum(QuantumRange* - phase_source[i]),q); + phase_pixels[i]),q); break; } case BluePixelChannel: { SetPixelBlue(phase_image,ClampToQuantum(QuantumRange* - phase_source[i]),q); + phase_pixels[i]),q); break; } case BlackPixelChannel: { SetPixelBlack(phase_image,ClampToQuantum(QuantumRange* - phase_source[i]),q); + phase_pixels[i]),q); break; } case AlphaPixelChannel: { SetPixelAlpha(phase_image,ClampToQuantum(QuantumRange* - phase_source[i]),q); + phase_pixels[i]),q); break; } } @@ -394,8 +407,8 @@ static MagickBooleanType ForwardFourier(const FourierInfo *fourier_info, break; } phase_view=DestroyCacheView(phase_view); - phase_source=(double *) RelinquishMagickMemory(phase_source); - magnitude_source=(double *) RelinquishMagickMemory(magnitude_source); + phase_info=RelinquishVirtualMemory(phase_info); + magnitude_info=RelinquishVirtualMemory(magnitude_info); return(status); } @@ -415,6 +428,9 @@ static MagickBooleanType ForwardFourierTransform(FourierInfo *fourier_info, fftw_plan fftw_r2c_plan; + MemoryInfo + *source_info; + register const Quantum *p; @@ -428,14 +444,15 @@ static MagickBooleanType ForwardFourierTransform(FourierInfo *fourier_info, /* Generate the forward Fourier transform. */ - source=(double *) AcquireQuantumMemory((size_t) fourier_info->height, + source_info=AcquireVirtualMemory((size_t) fourier_info->height, fourier_info->width*sizeof(*source)); - if (source == (double *) NULL) + if (source_info == (MemoryInfo *) NULL) { (void) ThrowMagickException(exception,GetMagickModule(), ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); return(MagickFalse); } + source=(double *) GetVirtualMemoryBlob(source_info); ResetMagickMemory(source,0,fourier_info->height*fourier_info->width* sizeof(*source)); i=0L; @@ -498,7 +515,7 @@ static MagickBooleanType ForwardFourierTransform(FourierInfo *fourier_info, source,fourier,FFTW_ESTIMATE); fftw_execute(fftw_r2c_plan); fftw_destroy_plan(fftw_r2c_plan); - source=(double *) RelinquishMagickMemory(source); + source_info=RelinquishVirtualMemory(source_info); /* Normalize Fourier transform. */ @@ -547,15 +564,16 @@ static MagickBooleanType ForwardFourierTransformChannel(const Image *image, *magnitude, *phase; - fftw_complex - *fourier; - FourierInfo fourier_info; MagickBooleanType status; + MemoryInfo + *magnitude_info, + *phase_info; + size_t extent; @@ -570,40 +588,29 @@ static MagickBooleanType ForwardFourierTransformChannel(const Image *image, fourier_info.center=(ssize_t) floor((double) fourier_info.width/2L)+1L; fourier_info.channel=channel; fourier_info.modulus=modulus; - magnitude=(double *) AcquireQuantumMemory((size_t) fourier_info.height, + magnitude_info=AcquireVirtualMemory((size_t) fourier_info.height, fourier_info.center*sizeof(*magnitude)); - if (magnitude == (double *) NULL) - { - (void) ThrowMagickException(exception,GetMagickModule(), - ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); - return(MagickFalse); - } - phase=(double *) AcquireQuantumMemory((size_t) fourier_info.height, + phase_info=AcquireVirtualMemory((size_t) fourier_info.height, fourier_info.center*sizeof(*phase)); - if (phase == (double *) NULL) + if ((magnitude_info == (MemoryInfo *) NULL) || + (phase_info == (MemoryInfo *) NULL)) { + if (phase_info != (MemoryInfo *) NULL) + phase_info=RelinquishVirtualMemory(phase_info); + if (magnitude_info != (MemoryInfo *) NULL) + magnitude_info=RelinquishVirtualMemory(magnitude_info); (void) ThrowMagickException(exception,GetMagickModule(), ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); - magnitude=(double *) RelinquishMagickMemory(magnitude); - return(MagickFalse); - } - fourier=(fftw_complex *) AcquireQuantumMemory((size_t) fourier_info.height, - fourier_info.center*sizeof(*fourier)); - if (fourier == (fftw_complex *) NULL) - { - (void) ThrowMagickException(exception,GetMagickModule(), - ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); - phase=(double *) RelinquishMagickMemory(phase); - magnitude=(double *) RelinquishMagickMemory(magnitude); return(MagickFalse); } + magnitude=(double *) GetVirtualMemoryBlob(magnitude_info); + phase=(double *) GetVirtualMemoryBlob(phase_info); status=ForwardFourierTransform(&fourier_info,image,magnitude,phase,exception); if (status != MagickFalse) status=ForwardFourier(&fourier_info,fourier_image,magnitude,phase, exception); - fourier=(fftw_complex *) RelinquishMagickMemory(fourier); - phase=(double *) RelinquishMagickMemory(phase); - magnitude=(double *) RelinquishMagickMemory(magnitude); + phase_info=RelinquishVirtualMemory(phase_info); + magnitude_info=RelinquishVirtualMemory(magnitude_info); return(status); } #endif @@ -814,14 +821,18 @@ static MagickBooleanType InverseFourier(FourierInfo *fourier_info, *phase_view; double - *magnitude, - *phase, - *magnitude_source, - *phase_source; + *buffer, + *magnitude_pixels, + *phase_pixels; MagickBooleanType status; + MemoryInfo + *buffer_info, + *magnitude_info, + *phase_info; + register const Quantum *p; @@ -835,25 +846,30 @@ static MagickBooleanType InverseFourier(FourierInfo *fourier_info, /* Inverse fourier - read image and break down into a double array. */ - magnitude_source=(double *) AcquireQuantumMemory((size_t) - fourier_info->height,fourier_info->width*sizeof(*magnitude_source)); - if (magnitude_source == (double *) NULL) + magnitude_info=AcquireVirtualMemory((size_t) fourier_info->height, + fourier_info->width*sizeof(*magnitude_pixels)); + phase_info=AcquireVirtualMemory((size_t) fourier_info->height, + fourier_info->width*sizeof(*phase_pixels)); + buffer_info=AcquireVirtualMemory((size_t) fourier_info->height, + fourier_info->width*sizeof(*buffer)); + if ((phase_info == (MemoryInfo *) NULL) || + (magnitude_info == (MemoryInfo *) NULL) || + (buffer_info == (MemoryInfo *) NULL)) { + if (buffer_info != (MemoryInfo *) NULL) + buffer_info=RelinquishVirtualMemory(buffer_info); + if (phase_info != (MemoryInfo *) NULL) + phase_info=RelinquishVirtualMemory(phase_info); + if (magnitude_info != (MemoryInfo *) NULL) + magnitude_info=RelinquishVirtualMemory(magnitude_info); (void) ThrowMagickException(exception,GetMagickModule(), ResourceLimitError,"MemoryAllocationFailed","`%s'", magnitude_image->filename); return(MagickFalse); } - phase_source=(double *) AcquireQuantumMemory((size_t) fourier_info->height, - fourier_info->width*sizeof(*phase_source)); - if (phase_source == (double *) NULL) - { - (void) ThrowMagickException(exception,GetMagickModule(), - ResourceLimitError,"MemoryAllocationFailed","`%s'", - magnitude_image->filename); - magnitude_source=(double *) RelinquishMagickMemory(magnitude_source); - return(MagickFalse); - } + magnitude_pixels=(double *) GetVirtualMemoryBlob(magnitude_info); + phase_pixels=(double *) GetVirtualMemoryBlob(phase_info); + buffer=(double *) GetVirtualMemoryBlob(buffer_info); i=0L; magnitude_view=AcquireVirtualCacheView(magnitude_image,exception); for (y=0L; y < (ssize_t) fourier_info->height; y++) @@ -869,27 +885,27 @@ static MagickBooleanType InverseFourier(FourierInfo *fourier_info, case RedPixelChannel: default: { - magnitude_source[i]=QuantumScale*GetPixelRed(magnitude_image,p); + magnitude_pixels[i]=QuantumScale*GetPixelRed(magnitude_image,p); break; } case GreenPixelChannel: { - magnitude_source[i]=QuantumScale*GetPixelGreen(magnitude_image,p); + magnitude_pixels[i]=QuantumScale*GetPixelGreen(magnitude_image,p); break; } case BluePixelChannel: { - magnitude_source[i]=QuantumScale*GetPixelBlue(magnitude_image,p); + magnitude_pixels[i]=QuantumScale*GetPixelBlue(magnitude_image,p); break; } case BlackPixelChannel: { - magnitude_source[i]=QuantumScale*GetPixelBlack(magnitude_image,p); + magnitude_pixels[i]=QuantumScale*GetPixelBlack(magnitude_image,p); break; } case AlphaPixelChannel: { - magnitude_source[i]=QuantumScale*GetPixelAlpha(magnitude_image,p); + magnitude_pixels[i]=QuantumScale*GetPixelAlpha(magnitude_image,p); break; } } @@ -912,27 +928,27 @@ static MagickBooleanType InverseFourier(FourierInfo *fourier_info, case RedPixelChannel: default: { - phase_source[i]=QuantumScale*GetPixelRed(phase_image,p); + phase_pixels[i]=QuantumScale*GetPixelRed(phase_image,p); break; } case GreenPixelChannel: { - phase_source[i]=QuantumScale*GetPixelGreen(phase_image,p); + phase_pixels[i]=QuantumScale*GetPixelGreen(phase_image,p); break; } case BluePixelChannel: { - phase_source[i]=QuantumScale*GetPixelBlue(phase_image,p); + phase_pixels[i]=QuantumScale*GetPixelBlue(phase_image,p); break; } case BlackPixelChannel: { - phase_source[i]=QuantumScale*GetPixelBlack(phase_image,p); + phase_pixels[i]=QuantumScale*GetPixelBlack(phase_image,p); break; } case AlphaPixelChannel: { - phase_source[i]=QuantumScale*GetPixelAlpha(phase_image,p); + phase_pixels[i]=QuantumScale*GetPixelAlpha(phase_image,p); break; } } @@ -946,42 +962,24 @@ static MagickBooleanType InverseFourier(FourierInfo *fourier_info, for (y=0L; y < (ssize_t) fourier_info->height; y++) for (x=0L; x < (ssize_t) fourier_info->width; x++) { - phase_source[i]-=0.5; - phase_source[i]*=(2.0*MagickPI); + phase_pixels[i]-=0.5; + phase_pixels[i]*=(2.0*MagickPI); i++; } } magnitude_view=DestroyCacheView(magnitude_view); phase_view=DestroyCacheView(phase_view); - magnitude=(double *) AcquireQuantumMemory((size_t) fourier_info->height, - fourier_info->center*sizeof(*magnitude)); - if (magnitude == (double *) NULL) - { - (void) ThrowMagickException(exception,GetMagickModule(), - ResourceLimitError,"MemoryAllocationFailed","`%s'", - magnitude_image->filename); - magnitude_source=(double *) RelinquishMagickMemory(magnitude_source); - phase_source=(double *) RelinquishMagickMemory(phase_source); - return(MagickFalse); - } status=InverseQuadrantSwap(fourier_info->width,fourier_info->height, - magnitude_source,magnitude); - magnitude_source=(double *) RelinquishMagickMemory(magnitude_source); - phase=(double *) AcquireQuantumMemory((size_t) fourier_info->height, - fourier_info->width*sizeof(*phase)); - if (phase == (double *) NULL) - { - (void) ThrowMagickException(exception,GetMagickModule(), - ResourceLimitError,"MemoryAllocationFailed","`%s'", - magnitude_image->filename); - phase_source=(double *) RelinquishMagickMemory(phase_source); - return(MagickFalse); - } - CorrectPhaseLHS(fourier_info->width,fourier_info->width,phase_source); + magnitude_pixels,buffer); + (void) CopyMagickMemory(magnitude_pixels,buffer,(size_t) fourier_info->height* + fourier_info->width*sizeof(*magnitude_pixels)); + CorrectPhaseLHS(fourier_info->width,fourier_info->width,phase_pixels); if (status != MagickFalse) status=InverseQuadrantSwap(fourier_info->width,fourier_info->height, - phase_source,phase); - phase_source=(double *) RelinquishMagickMemory(phase_source); + phase_pixels,buffer); + (void) CopyMagickMemory(phase_pixels,buffer,(size_t) fourier_info->height* + fourier_info->width*sizeof(*phase_pixels)); + buffer_info=RelinquishVirtualMemory(buffer_info); /* Merge two sets. */ @@ -991,10 +989,11 @@ static MagickBooleanType InverseFourier(FourierInfo *fourier_info, for (x=0L; x < (ssize_t) fourier_info->center; x++) { #if defined(MAGICKCORE_HAVE_COMPLEX_H) - fourier[i]=magnitude[i]*cos(phase[i])+I*magnitude[i]*sin(phase[i]); + fourier[i]=magnitude_pixels[i]*cos(phase_pixels[i])+I* + magnitude_pixels[i]*sin(phase_pixels[i]); #else - fourier[i][0]=magnitude[i]*cos(phase[i]); - fourier[i][1]=magnitude[i]*sin(phase[i]); + fourier[i][0]=magnitude_pixels[i]*cos(phase_pixels[i]); + fourier[i][1]=magnitude_pixels[i]*sin(phase_pixels[i]); #endif i++; } @@ -1003,15 +1002,15 @@ static MagickBooleanType InverseFourier(FourierInfo *fourier_info, for (x=0L; x < (ssize_t) fourier_info->center; x++) { #if defined(MAGICKCORE_HAVE_COMPLEX_H) - fourier[i]=magnitude[i]+I*phase[i]; + fourier[i]=magnitude_pixels[i]+I*phase_pixels[i]; #else - fourier[i][0]=magnitude[i]; - fourier[i][1]=phase[i]; + fourier[i][0]=magnitude_pixels[i]; + fourier[i][1]=phase_pixels[i]; #endif i++; } - phase=(double *) RelinquishMagickMemory(phase); - magnitude=(double *) RelinquishMagickMemory(magnitude); + phase_info=RelinquishVirtualMemory(phase_info); + magnitude_info=RelinquishVirtualMemory(magnitude_info); return(status); } @@ -1027,6 +1026,9 @@ static MagickBooleanType InverseFourierTransform(FourierInfo *fourier_info, fftw_plan fftw_c2r_plan; + MemoryInfo + *source_info; + register Quantum *q; @@ -1037,14 +1039,15 @@ static MagickBooleanType InverseFourierTransform(FourierInfo *fourier_info, ssize_t y; - source=(double *) AcquireQuantumMemory((size_t) fourier_info->height, + source_info=AcquireVirtualMemory((size_t) fourier_info->height, fourier_info->width*sizeof(*source)); - if (source == (double *) NULL) + if (source_info == (MemoryInfo *) NULL) { (void) ThrowMagickException(exception,GetMagickModule(), ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); return(MagickFalse); } + source=(double *) GetVirtualMemoryBlob(source_info); #if defined(MAGICKCORE_OPENMP_SUPPORT) #pragma omp critical (MagickCore_InverseFourierTransform) #endif @@ -1103,7 +1106,7 @@ static MagickBooleanType InverseFourierTransform(FourierInfo *fourier_info, break; } image_view=DestroyCacheView(image_view); - source=(double *) RelinquishMagickMemory(source); + source_info=RelinquishVirtualMemory(source_info); return(MagickTrue); } @@ -1117,7 +1120,7 @@ static MagickBooleanType InverseFourierTransformChannel( *phase; fftw_complex - *fourier; + *buffer; FourierInfo fourier_info; @@ -1125,6 +1128,11 @@ static MagickBooleanType InverseFourierTransformChannel( MagickBooleanType status; + MemoryInfo + *buffer_info, + *magnitude_info, + *phase_info; + size_t extent; @@ -1141,44 +1149,38 @@ static MagickBooleanType InverseFourierTransformChannel( fourier_info.center=(ssize_t) floor((double) fourier_info.width/2L)+1L; fourier_info.channel=channel; fourier_info.modulus=modulus; - magnitude=(double *) AcquireQuantumMemory((size_t) fourier_info.height, + magnitude_info=AcquireVirtualMemory((size_t) fourier_info.height, fourier_info.center*sizeof(*magnitude)); - if (magnitude == (double *) NULL) - { - (void) ThrowMagickException(exception,GetMagickModule(), - ResourceLimitError,"MemoryAllocationFailed","`%s'", - magnitude_image->filename); - return(MagickFalse); - } - phase=(double *) AcquireQuantumMemory((size_t) fourier_info.height, + phase_info=AcquireVirtualMemory((size_t) fourier_info.height, fourier_info.center*sizeof(*phase)); - if (phase == (double *) NULL) - { - (void) ThrowMagickException(exception,GetMagickModule(), - ResourceLimitError,"MemoryAllocationFailed","`%s'", - magnitude_image->filename); - magnitude=(double *) RelinquishMagickMemory(magnitude); - return(MagickFalse); - } - fourier=(fftw_complex *) AcquireQuantumMemory((size_t) fourier_info.height, - fourier_info.center*sizeof(*fourier)); - if (fourier == (fftw_complex *) NULL) + buffer_info=AcquireVirtualMemory((size_t) fourier_info.height, + fourier_info.center*sizeof(*buffer)); + if ((magnitude_info == (MemoryInfo *) NULL) || + (phase_info == (MemoryInfo *) NULL) || + (buffer_info == (MemoryInfo *) NULL)) { + if (buffer_info != (MemoryInfo *) NULL) + buffer_info=RelinquishVirtualMemory(buffer_info); + if (phase_info != (MemoryInfo *) NULL) + phase_info=RelinquishVirtualMemory(phase_info); + if (magnitude_info != (MemoryInfo *) NULL) + magnitude_info=RelinquishVirtualMemory(magnitude_info); (void) ThrowMagickException(exception,GetMagickModule(), ResourceLimitError,"MemoryAllocationFailed","`%s'", magnitude_image->filename); - phase=(double *) RelinquishMagickMemory(phase); - magnitude=(double *) RelinquishMagickMemory(magnitude); return(MagickFalse); } - status=InverseFourier(&fourier_info,magnitude_image,phase_image,fourier, + magnitude=(double *) GetVirtualMemoryBlob(magnitude_info); + phase=(double *) GetVirtualMemoryBlob(phase_info); + buffer=(fftw_complex *) GetVirtualMemoryBlob(buffer_info); + status=InverseFourier(&fourier_info,magnitude_image,phase_image,buffer, exception); if (status != MagickFalse) - status=InverseFourierTransform(&fourier_info,fourier,fourier_image, + status=InverseFourierTransform(&fourier_info,buffer,fourier_image, exception); - fourier=(fftw_complex *) RelinquishMagickMemory(fourier); - phase=(double *) RelinquishMagickMemory(phase); - magnitude=(double *) RelinquishMagickMemory(magnitude); + buffer_info=RelinquishMagickMemory(buffer_info); + phase_info=RelinquishMagickMemory(phase_info); + magnitude_info=RelinquishMagickMemory(magnitude_info); return(status); } #endif diff --git a/MagickCore/magick-baseconfig.h b/MagickCore/magick-baseconfig.h index 4c0e1b874..4e9aed84c 100644 --- a/MagickCore/magick-baseconfig.h +++ b/MagickCore/magick-baseconfig.h @@ -15,7 +15,9 @@ /* #undef BUILD_MODULES */ /* Define if you have the bzip2 library */ -/* #undef BZLIB_DELEGATE */ +#ifndef MAGICKCORE_BZLIB_DELEGATE +#define MAGICKCORE_BZLIB_DELEGATE 1 +#endif /* Define if you have CAIRO library */ /* #undef CAIRO_DELEGATE */ @@ -45,7 +47,9 @@ #endif /* Define if you have DJVU library */ -/* #undef DJVU_DELEGATE */ +#ifndef MAGICKCORE_DJVU_DELEGATE +#define MAGICKCORE_DJVU_DELEGATE 1 +#endif /* Directory where ImageMagick documents live. */ #ifndef MAGICKCORE_DOCUMENTATION_PATH @@ -64,7 +68,9 @@ #endif /* Define if you have FFTW library */ -/* #undef FFTW_DELEGATE */ +#ifndef MAGICKCORE_FFTW_DELEGATE +#define MAGICKCORE_FFTW_DELEGATE 1 +#endif /* filter subdirectory. */ #ifndef MAGICKCORE_FILTER_DIRNAME @@ -72,13 +78,17 @@ #endif /* Define if you have FONTCONFIG library */ -/* #undef FONTCONFIG_DELEGATE */ +#ifndef MAGICKCORE_FONTCONFIG_DELEGATE +#define MAGICKCORE_FONTCONFIG_DELEGATE 1 +#endif /* Define if you have FlashPIX library */ /* #undef FPX_DELEGATE */ /* Define if you have FREETYPE library */ -/* #undef FREETYPE_DELEGATE */ +#ifndef MAGICKCORE_FREETYPE_DELEGATE +#define MAGICKCORE_FREETYPE_DELEGATE 1 +#endif /* Define if you have Ghostscript library or framework */ /* #undef GS_DELEGATE */ @@ -120,7 +130,9 @@ #endif /* define if bool is a built-in type */ -/* #undef HAVE_BOOL */ +#ifndef MAGICKCORE_HAVE_BOOL +#define MAGICKCORE_HAVE_BOOL /**/ +#endif /* Define to 1 if you have the `cabs' function. */ #ifndef MAGICKCORE_HAVE_CABS @@ -358,7 +370,9 @@ #endif /* Define if you have the header file. */ -/* #undef HAVE_LCMS2_H */ +#ifndef MAGICKCORE_HAVE_LCMS2_H +#define MAGICKCORE_HAVE_LCMS2_H 1 +#endif /* Define if you have the header file. */ /* #undef HAVE_LCMS2_LCMS2_H */ @@ -463,10 +477,14 @@ #endif /* define if the compiler implements namespaces */ -/* #undef HAVE_NAMESPACES */ +#ifndef MAGICKCORE_HAVE_NAMESPACES +#define MAGICKCORE_HAVE_NAMESPACES /**/ +#endif /* Define if g++ supports namespace std. */ -/* #undef HAVE_NAMESPACE_STD */ +#ifndef MAGICKCORE_HAVE_NAMESPACE_STD +#define MAGICKCORE_HAVE_NAMESPACE_STD /**/ +#endif /* Define to 1 if you have the `nanosleep' function. */ #ifndef MAGICKCORE_HAVE_NANOSLEEP @@ -611,10 +629,14 @@ #endif /* X11 server supports shape extension */ -/* #undef HAVE_SHAPE */ +#ifndef MAGICKCORE_HAVE_SHAPE +#define MAGICKCORE_HAVE_SHAPE 1 +#endif /* X11 server supports shared memory extension */ -/* #undef HAVE_SHARED_MEMORY */ +#ifndef MAGICKCORE_HAVE_SHARED_MEMORY +#define MAGICKCORE_HAVE_SHARED_MEMORY 1 +#endif /* Define to 1 if you have the `sigaction' function. */ #ifndef MAGICKCORE_HAVE_SIGACTION @@ -665,7 +687,9 @@ #endif /* define if the compiler supports ISO C++ standard library */ -/* #undef HAVE_STD_LIBS */ +#ifndef MAGICKCORE_HAVE_STD_LIBS +#define MAGICKCORE_HAVE_STD_LIBS /**/ +#endif /* Define to 1 if you have the `strcasecmp' function. */ #ifndef MAGICKCORE_HAVE_STRCASECMP @@ -863,31 +887,49 @@ #endif /* Define to 1 if you have the header file. */ -/* #undef HAVE_TIFFCONF_H */ +#ifndef MAGICKCORE_HAVE_TIFFCONF_H +#define MAGICKCORE_HAVE_TIFFCONF_H 1 +#endif /* Define to 1 if you have the `TIFFIsBigEndian' function. */ -/* #undef HAVE_TIFFISBIGENDIAN */ +#ifndef MAGICKCORE_HAVE_TIFFISBIGENDIAN +#define MAGICKCORE_HAVE_TIFFISBIGENDIAN 1 +#endif /* Define to 1 if you have the `TIFFIsCODECConfigured' function. */ -/* #undef HAVE_TIFFISCODECCONFIGURED */ +#ifndef MAGICKCORE_HAVE_TIFFISCODECCONFIGURED +#define MAGICKCORE_HAVE_TIFFISCODECCONFIGURED 1 +#endif /* Define to 1 if you have the `TIFFMergeFieldInfo' function. */ -/* #undef HAVE_TIFFMERGEFIELDINFO */ +#ifndef MAGICKCORE_HAVE_TIFFMERGEFIELDINFO +#define MAGICKCORE_HAVE_TIFFMERGEFIELDINFO 1 +#endif /* Define to 1 if you have the `TIFFReadEXIFDirectory' function. */ -/* #undef HAVE_TIFFREADEXIFDIRECTORY */ +#ifndef MAGICKCORE_HAVE_TIFFREADEXIFDIRECTORY +#define MAGICKCORE_HAVE_TIFFREADEXIFDIRECTORY 1 +#endif /* Define to 1 if you have the `TIFFSetErrorHandlerExt' function. */ -/* #undef HAVE_TIFFSETERRORHANDLEREXT */ +#ifndef MAGICKCORE_HAVE_TIFFSETERRORHANDLEREXT +#define MAGICKCORE_HAVE_TIFFSETERRORHANDLEREXT 1 +#endif /* Define to 1 if you have the `TIFFSetTagExtender' function. */ -/* #undef HAVE_TIFFSETTAGEXTENDER */ +#ifndef MAGICKCORE_HAVE_TIFFSETTAGEXTENDER +#define MAGICKCORE_HAVE_TIFFSETTAGEXTENDER 1 +#endif /* Define to 1 if you have the `TIFFSetWarningHandlerExt' function. */ -/* #undef HAVE_TIFFSETWARNINGHANDLEREXT */ +#ifndef MAGICKCORE_HAVE_TIFFSETWARNINGHANDLEREXT +#define MAGICKCORE_HAVE_TIFFSETWARNINGHANDLEREXT 1 +#endif /* Define to 1 if you have the `TIFFSwabArrayOfTriples' function. */ -/* #undef HAVE_TIFFSWABARRAYOFTRIPLES */ +#ifndef MAGICKCORE_HAVE_TIFFSWABARRAYOFTRIPLES +#define MAGICKCORE_HAVE_TIFFSWABARRAYOFTRIPLES 1 +#endif /* Define to 1 if you have the `times' function. */ #ifndef MAGICKCORE_HAVE_TIMES @@ -1064,13 +1106,19 @@ /* #undef JBIG_DELEGATE */ /* Define if you have JPEG version 2 "Jasper" library */ -/* #undef JP2_DELEGATE */ +#ifndef MAGICKCORE_JP2_DELEGATE +#define MAGICKCORE_JP2_DELEGATE 1 +#endif /* Define if you have JPEG library */ -/* #undef JPEG_DELEGATE */ +#ifndef MAGICKCORE_JPEG_DELEGATE +#define MAGICKCORE_JPEG_DELEGATE 1 +#endif /* Define if you have LCMS (v1.11 or later) library */ -/* #undef LCMS_DELEGATE */ +#ifndef MAGICKCORE_LCMS_DELEGATE +#define MAGICKCORE_LCMS_DELEGATE 1 +#endif /* Directory where architecture-dependent files live. */ #ifndef MAGICKCORE_LIBRARY_PATH @@ -1102,7 +1150,9 @@ #endif /* Define if you have LZMA library */ -/* #undef LZMA_DELEGATE */ +#ifndef MAGICKCORE_LZMA_DELEGATE +#define MAGICKCORE_LZMA_DELEGATE 1 +#endif /* Define to prepend to default font search path. */ /* #undef MAGICK_FONT_PATH */ @@ -1140,7 +1190,9 @@ /* #undef NO_MINUS_C_MINUS_O */ /* Define if you have OPENEXR library */ -/* #undef OPENEXR_DELEGATE */ +#ifndef MAGICKCORE_OPENEXR_DELEGATE +#define MAGICKCORE_OPENEXR_DELEGATE 1 +#endif /* Name of package */ #ifndef MAGICKCORE_PACKAGE @@ -1178,13 +1230,19 @@ #endif /* Define if you have PANGOCAIRO library */ -/* #undef PANGOCAIRO_DELEGATE */ +#ifndef MAGICKCORE_PANGOCAIRO_DELEGATE +#define MAGICKCORE_PANGOCAIRO_DELEGATE 1 +#endif /* Define if you have PANGO library */ -/* #undef PANGO_DELEGATE */ +#ifndef MAGICKCORE_PANGO_DELEGATE +#define MAGICKCORE_PANGO_DELEGATE 1 +#endif /* Define if you have PNG library */ -/* #undef PNG_DELEGATE */ +#ifndef MAGICKCORE_PNG_DELEGATE +#define MAGICKCORE_PNG_DELEGATE 1 +#endif /* Define to necessary symbol if this constant uses a non-standard name on your system. */ @@ -1344,7 +1402,9 @@ #endif /* Define if you have TIFF library */ -/* #undef TIFF_DELEGATE */ +#ifndef MAGICKCORE_TIFF_DELEGATE +#define MAGICKCORE_TIFF_DELEGATE 1 +#endif /* Define to 1 if you can safely include both and . */ #ifndef MAGICKCORE_TIME_WITH_SYS_TIME @@ -1382,7 +1442,9 @@ #endif /* Define if you have WEBP library */ -/* #undef WEBP_DELEGATE */ +#ifndef MAGICKCORE_WEBP_DELEGATE +#define MAGICKCORE_WEBP_DELEGATE 1 +#endif /* Define to use the Windows GDI32 library */ /* #undef WINGDI32_DELEGATE */ @@ -1414,21 +1476,25 @@ #endif /* Define if you have X11 library */ -/* #undef X11_DELEGATE */ +#ifndef MAGICKCORE_X11_DELEGATE +#define MAGICKCORE_X11_DELEGATE 1 +#endif /* Define if you have XML library */ -/* #undef XML_DELEGATE */ +#ifndef MAGICKCORE_XML_DELEGATE +#define MAGICKCORE_XML_DELEGATE 1 +#endif /* Define to 1 if the X Window System is missing or not being used. */ -#ifndef MAGICKCORE_X_DISPLAY_MISSING -#define MAGICKCORE_X_DISPLAY_MISSING 1 -#endif +/* #undef X_DISPLAY_MISSING */ /* Build self-contained, embeddable, zero-configuration ImageMagick */ /* #undef ZERO_CONFIGURATION_SUPPORT */ /* Define if you have zlib compression library */ -/* #undef ZLIB_DELEGATE */ +#ifndef MAGICKCORE_ZLIB_DELEGATE +#define MAGICKCORE_ZLIB_DELEGATE 1 +#endif /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _DARWIN_USE_64_BIT_INODE diff --git a/MagickCore/version.h b/MagickCore/version.h index b2cbb0a64..433e38056 100644 --- a/MagickCore/version.h +++ b/MagickCore/version.h @@ -34,11 +34,11 @@ extern "C" { #define MagickLibAddendum "-0" #define MagickLibInterface 1 #define MagickLibMinInterface 1 -#define MagickReleaseDate "2013-06-23" +#define MagickReleaseDate "2013-06-29" #define MagickChangeDate "20120427" #define MagickAuthoritativeURL "http://www.imagemagick.org" #define MagickFeatures "DPC HDRI OpenMP" -#define MagickDelegates "ps" +#define MagickDelegates "bzlib djvu fftw fontconfig freetype jng jp2 jpeg lcms lzma openexr pango png ps tiff x xml zlib" #define MagickHomeURL "file:///usr/share/doc/ImageMagick-7/index.html" #if (MAGICKCORE_QUANTUM_DEPTH == 8) #define MagickQuantumDepth "Q8" diff --git a/PerlMagick/Makefile.PL b/PerlMagick/Makefile.PL index 334111ade..ee8bef1fe 100644 --- a/PerlMagick/Makefile.PL +++ b/PerlMagick/Makefile.PL @@ -161,9 +161,9 @@ foreach my $delegate (@tested_delegates) { } # defaults for LIBS & INC & CCFLAGS params that we later pass to Writemakefile -my $INC_magick = '-I../ -I.. -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I"' . $Config{'usrinc'} . '/ImageMagick"'; +my $INC_magick = '-I../ -I.. -pthread -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/libdrm -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/libxml2 -I"' . $Config{'usrinc'} . '/ImageMagick"'; my $LIBS_magick = '-L../MagickCore/.libs -lMagickCore-7.Q16HDRI -lperl -lm'; -my $CCFLAGS_magick = "$Config{'ccflags'} -fopenmp -g -O2 -Wall -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16"; +my $CCFLAGS_magick = "$Config{'ccflags'} -pthread -I/usr/include/OpenEXR -I/usr/include/libdrm -I/usr/include/freetype2 -fopenmp -g -O2 -Wall -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16"; my $LDFLAGS_magick = "-L../MagickCore/.libs -lMagickCore-7.Q16HDRI $Config{'ldflags'} "; my $LDDLFLAGS_magick = "-L../MagickCore/.libs -lMagickCore-7.Q16HDRI $Config{'lddlflags'} "; @@ -209,7 +209,7 @@ WriteMakefile #'CC' => 'gcc -std=gnu99 -std=gnu99', # C pre-processor flags (e.g. -I & -D options) - # 'CPPFLAGS' => "$Config{'cppflags'} -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16", + # 'CPPFLAGS' => "$Config{'cppflags'} -pthread -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/libdrm -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/libxml2", # C compiler flags (e.g. -O -g) 'CCFLAGS' => $CCFLAGS_magick, diff --git a/PerlMagick/quantum/Makefile.PL b/PerlMagick/quantum/Makefile.PL index d3012aee1..570c90b1e 100644 --- a/PerlMagick/quantum/Makefile.PL +++ b/PerlMagick/quantum/Makefile.PL @@ -161,9 +161,9 @@ foreach my $delegate (@tested_delegates) { } # defaults for LIBS & INC & CCFLAGS params that we later pass to Writemakefile -my $INC_magick = '-I../ -I../.. -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I"' . $Config{'usrinc'} . '/ImageMagick"'; +my $INC_magick = '-I../ -I../.. -pthread -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/libdrm -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/libxml2 -I"' . $Config{'usrinc'} . '/ImageMagick"'; my $LIBS_magick = '-L../../MagickCore/.libs -lMagickCore-7.Q16HDRI -lperl -lm'; -my $CCFLAGS_magick = "$Config{'ccflags'} -fopenmp -g -O2 -Wall -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16"; +my $CCFLAGS_magick = "$Config{'ccflags'} -pthread -I/usr/include/OpenEXR -I/usr/include/libdrm -I/usr/include/freetype2 -fopenmp -g -O2 -Wall -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16"; my $LDFLAGS_magick = "-L../../MagickCore/.libs -lMagickCore-7.Q16HDRI $Config{'ldflags'} "; my $LDDLFLAGS_magick = "-L../../MagickCore/.libs -lMagickCore-7.Q16HDRI $Config{'lddlflags'} "; @@ -206,7 +206,7 @@ WriteMakefile #'CC' => 'gcc -std=gnu99 -std=gnu99', # C pre-processor flags (e.g. -I & -D options) - # 'CPPFLAGS' => "$Config{'cppflags'} -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16", + # 'CPPFLAGS' => "$Config{'cppflags'} -pthread -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng15 -I/usr/include/libdrm -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/libxml2", # C compiler flags (e.g. -O -g) 'CCFLAGS' => $CCFLAGS_magick, -- 2.49.0