From: cristy Date: Thu, 12 Jan 2012 12:07:45 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~6395 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5293620ec3efd1c46de6621bd3bb4ee45a99fb1e;p=imagemagick --- diff --git a/MagickCore/attribute.c b/MagickCore/attribute.c index 0c71ee840..dc65d795e 100644 --- a/MagickCore/attribute.c +++ b/MagickCore/attribute.c @@ -348,94 +348,95 @@ MagickExport size_t GetImageDepth(const Image *image,ExceptionInfo *exception) return(depth); } image_view=AcquireCacheView(image); -#if (QuantumRange <= MaxMap) && !defined(MAGICKCORE_HDRI_SUPPORT) - { - register ssize_t - i; - - size_t - *depth_map; - - /* - Scale pixels to desired (optimized with depth map). - */ - depth_map=(size_t *) AcquireQuantumMemory(MaxMap+1,sizeof(*depth_map)); - if (depth_map == (size_t *) NULL) - ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); - for (i=0; i <= (ssize_t) MaxMap; i++) +#if !defined(MAGICKCORE_HDRI_SUPPORT) + if (QuantumRange <= MaxMap) { - unsigned int - depth; + register ssize_t + i; + + size_t + *depth_map; - for (depth=1; depth < MAGICKCORE_QUANTUM_DEPTH; depth++) + /* + Scale pixels to desired (optimized with depth map). + */ + depth_map=(size_t *) AcquireQuantumMemory(MaxMap+1,sizeof(*depth_map)); + if (depth_map == (size_t *) NULL) + ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); + for (i=0; i <= (ssize_t) MaxMap; i++) { - Quantum - pixel; + unsigned int + depth; - QuantumAny - range; + for (depth=1; depth < MAGICKCORE_QUANTUM_DEPTH; depth++) + { + Quantum + pixel; - range=GetQuantumRange(depth); - pixel=(Quantum) i; - if (pixel == ScaleAnyToQuantum(ScaleQuantumToAny(pixel,range),range)) - break; + QuantumAny + range; + + range=GetQuantumRange(depth); + pixel=(Quantum) i; + if (pixel == ScaleAnyToQuantum(ScaleQuantumToAny(pixel,range),range)) + break; + } + depth_map[i]=depth; } - depth_map[i]=depth; - } #if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,4) shared(status) + #pragma omp parallel for schedule(static,4) shared(status) #endif - for (y=0; y < (ssize_t) image->rows; y++) - { - const int - id = GetOpenMPThreadId(); - - register const Quantum - *restrict p; + for (y=0; y < (ssize_t) image->rows; y++) + { + const int + id = GetOpenMPThreadId(); - register ssize_t - x; + register const Quantum + *restrict p; - if (status == MagickFalse) - continue; - p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception); - if (p == (const Quantum *) NULL) - continue; - for (x=0; x < (ssize_t) image->columns; x++) - { register ssize_t - i; + x; - for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + if (status == MagickFalse) + continue; + p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception); + if (p == (const Quantum *) NULL) + continue; + for (x=0; x < (ssize_t) image->columns; x++) { - PixelChannel - channel; - - PixelTrait - traits; - - channel=GetPixelChannelMapChannel(image,i); - traits=GetPixelChannelMapTraits(image,channel); - if ((traits == UndefinedPixelTrait) || - (channel == IndexPixelChannel)) - continue; - if (depth_map[ScaleQuantumToMap(p[i])] > current_depth[id]) - current_depth[id]=depth_map[ScaleQuantumToMap(p[i])]; + register ssize_t + i; + + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel + channel; + + PixelTrait + traits; + + channel=GetPixelChannelMapChannel(image,i); + traits=GetPixelChannelMapTraits(image,channel); + if ((traits == UndefinedPixelTrait) || + (channel == IndexPixelChannel)) + continue; + if (depth_map[ScaleQuantumToMap(p[i])] > current_depth[id]) + current_depth[id]=depth_map[ScaleQuantumToMap(p[i])]; + } + p+=GetPixelChannels(image); } - p+=GetPixelChannels(image); + if (current_depth[id] == MAGICKCORE_QUANTUM_DEPTH) + status=MagickFalse; } - if (current_depth[id] == MAGICKCORE_QUANTUM_DEPTH) - status=MagickFalse; + image_view=DestroyCacheView(image_view); + depth=current_depth[0]; + for (id=1; id < (ssize_t) number_threads; id++) + if (depth < current_depth[id]) + depth=current_depth[id]; + depth_map=(size_t *) RelinquishMagickMemory(depth_map); + current_depth=(size_t *) RelinquishMagickMemory(current_depth); + return(depth); } - image_view=DestroyCacheView(image_view); - depth=current_depth[0]; - for (id=1; id < (ssize_t) number_threads; id++) - if (depth < current_depth[id]) - depth=current_depth[id]; - depth_map=(size_t *) RelinquishMagickMemory(depth_map); - current_depth=(size_t *) RelinquishMagickMemory(current_depth); - return(depth); - } #endif /* Compute pixel depth. @@ -938,73 +939,75 @@ MagickExport MagickBooleanType SetImageDepth(Image *image, } status=MagickTrue; image_view=AcquireCacheView(image); -#if (QuantumRange <= MaxMap) && !defined(MAGICKCORE_HDRI_SUPPORT) - { - Quantum - *depth_map; - - register ssize_t - i; - - /* - Scale pixels to desired (optimized with depth map). - */ - depth_map=(Quantum *) AcquireQuantumMemory(MaxMap+1,sizeof(*depth_map)); - if (depth_map == (Quantum *) NULL) - ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); - for (i=0; i <= (ssize_t) MaxMap; i++) - depth_map[i]=ScaleAnyToQuantum(ScaleQuantumToAny((Quantum) i,range), - range); -#if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,4) shared(status) -#endif - for (y=0; y < (ssize_t) image->rows; y++) +#if !defined(MAGICKCORE_HDRI_SUPPORT) + if (QuantumRange <= MaxMap) { - register ssize_t - x; + Quantum + *depth_map; - register Quantum - *restrict q; + register ssize_t + i; - if (status == MagickFalse) - continue; - q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); - if (q == (Quantum *) NULL) - { - status=MagickFalse; - continue; - } - for (x=0; x < (ssize_t) image->columns; x++) + /* + Scale pixels to desired (optimized with depth map). + */ + depth_map=(Quantum *) AcquireQuantumMemory(MaxMap+1,sizeof(*depth_map)); + if (depth_map == (Quantum *) NULL) + ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); + for (i=0; i <= (ssize_t) MaxMap; i++) + depth_map[i]=ScaleAnyToQuantum(ScaleQuantumToAny((Quantum) i,range), + range); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static,4) shared(status) +#endif + for (y=0; y < (ssize_t) image->rows; y++) { - for (i=0; i < (ssize_t) GetPixelChannels(image); i++) - { - PixelChannel - channel; + register ssize_t + x; - PixelTrait - traits; + register Quantum + *restrict q; - channel=GetPixelChannelMapChannel(image,i); - traits=GetPixelChannelMapTraits(image,channel); - if ((traits == UndefinedPixelTrait) || - (channel == IndexPixelChannel)) + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1, + exception); + if (q == (Quantum *) NULL) + { + status=MagickFalse; continue; - q[i]=depth_map[ScaleQuantumToMap(q[i])]; - } - q+=GetPixelChannels(image); - } - if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + } + for (x=0; x < (ssize_t) image->columns; x++) { - status=MagickFalse; - continue; + for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + { + PixelChannel + channel; + + PixelTrait + traits; + + channel=GetPixelChannelMapChannel(image,i); + traits=GetPixelChannelMapTraits(image,channel); + if ((traits == UndefinedPixelTrait) || + (channel == IndexPixelChannel)) + continue; + q[i]=depth_map[ScaleQuantumToMap(q[i])]; + } + q+=GetPixelChannels(image); } + if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + { + status=MagickFalse; + continue; + } + } + image_view=DestroyCacheView(image_view); + depth_map=(Quantum *) RelinquishMagickMemory(depth_map); + if (status != MagickFalse) + image->depth=depth; + return(status); } - image_view=DestroyCacheView(image_view); - depth_map=(Quantum *) RelinquishMagickMemory(depth_map); - if (status != MagickFalse) - image->depth=depth; - return(status); - } #endif /* Scale pixels to desired depth. diff --git a/MagickCore/image.c b/MagickCore/image.c index d2cacbdad..e8f896324 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -1804,9 +1804,6 @@ MagickExport MagickBooleanType IsHighDynamicRangeImage(const Image *image, #endif for (y=0; y < (ssize_t) image->rows; y++) { - PixelInfo - pixel; - register const Quantum *p;