From f7016445c4bb130cdac76e0131064d471b771c31 Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 24 Nov 2018 15:05:40 -0500 Subject: [PATCH] ... --- MagickCore/enhance.c | 128 +++++++++++++++++++++---------------------- coders/heic.c | 2 +- 2 files changed, 64 insertions(+), 66 deletions(-) diff --git a/MagickCore/enhance.c b/MagickCore/enhance.c index 0538f842f..1a49698cd 100644 --- a/MagickCore/enhance.c +++ b/MagickCore/enhance.c @@ -612,6 +612,12 @@ MagickExport MagickBooleanType CLAHEImage(Image *image,const size_t x_tiles, { #define CLAHEImageTag "CLAHE/Image" + CacheView + *image_view; + + ColorspaceType + colorspace; + MagickBooleanType status; @@ -624,14 +630,12 @@ MagickExport MagickBooleanType CLAHEImage(Image *image,const size_t x_tiles, OffsetInfo tile; - register ssize_t - i; - ssize_t y; size_t height, + n, width; unsigned short @@ -644,7 +648,8 @@ MagickExport MagickBooleanType CLAHEImage(Image *image,const size_t x_tiles, assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); - if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse) + colorspace=image->colorspace; + if (TransformImageColorspace(image,LabColorspace,exception) == MagickFalse) return(MagickFalse); status=MagickTrue; tile.x=(ssize_t) (x_tiles < 2 ? 2 : x_tiles >= MaxCLAHETiles ? @@ -658,83 +663,75 @@ MagickExport MagickBooleanType CLAHEImage(Image *image,const size_t x_tiles, ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); pixels=(unsigned short *) GetVirtualMemoryBlob(pixel_cache); -#if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static) shared(progress,status) \ - magick_number_threads(image,image,GetPixelChannels(image),1) -#endif - for (i=0; i < (ssize_t) GetPixelChannels(image); i++) + image_view=AcquireVirtualCacheView(image,exception); + n=0; + for (y=0; y < (ssize_t) height; y++) { - CacheView - *image_view; + register const Quantum + *magick_restrict p; register ssize_t x; - size_t - n; - - PixelChannel channel = GetPixelChannelChannel(image,i); - PixelTrait traits = GetPixelChannelTraits(image,channel); - if ((traits & UpdatePixelTrait) == 0) - continue; if (status == MagickFalse) continue; - image_view=AcquireVirtualCacheView(image,exception); - n=0; - for (y=0; y < (ssize_t) height; y++) + p=GetCacheViewVirtualPixels(image_view,0,y,width,1,exception); + if (p == (const Quantum *) NULL) + { + status=MagickFalse; + continue; + } + for (x=0; x < (ssize_t) image->columns; x++) { - register const Quantum - *magick_restrict p; + pixels[n++]=ScaleQuantumToShort(p[0]); + p+=GetPixelChannels(image); + } + if (image->progress_monitor != (MagickProgressMonitor) NULL) + { + MagickBooleanType + proceed; - if (status == MagickFalse) - continue; - p=GetCacheViewVirtualPixels(image_view,0,y,width,1,exception); - if (p == (const Quantum *) NULL) - { +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp atomic +#endif + progress++; + proceed=SetImageProgress(image,CLAHEImageTag,progress,2* + GetPixelChannels(image)); + if (proceed == MagickFalse) status=MagickFalse; - continue; - } - for (x=0; x < (ssize_t) image->columns; x++) - { - pixels[n++]=ScaleQuantumToShort(p[i]); - p+=GetPixelChannels(image); } - } - image_view=DestroyCacheView(image_view); + } + image_view=DestroyCacheView(image_view); + status=CLAHE(width,height,0,65535,(size_t) tile.x,(size_t) tile.y, + number_bins == 0 ? (size_t) 128 : number_bins,clip_limit,pixels); + if (status == MagickFalse) + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); + image_view=AcquireAuthenticCacheView(image,exception); + n=0; + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *magick_restrict q; + + register ssize_t + x; + if (status == MagickFalse) continue; - status=CLAHE(width,height,0,65535,(size_t) tile.x,(size_t) tile.y, - number_bins == 0 ? (size_t) 128 : number_bins,clip_limit,pixels); - if (status == MagickFalse) + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) { - (void) ThrowMagickException(exception,GetMagickModule(), - ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename); + status=MagickFalse; continue; } - image_view=AcquireAuthenticCacheView(image,exception); - n=0; - for (y=0; y < (ssize_t) image->rows; y++) + for (x=0; x < (ssize_t) image->columns; x++) { - register Quantum - *magick_restrict q; - - 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++) - { - q[i]=ScaleShortToQuantum(pixels[n++]); - q+=GetPixelChannels(image); - } - if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) - status=MagickFalse; + q[0]=ScaleShortToQuantum(pixels[n++]); + q+=GetPixelChannels(image); } - image_view=DestroyCacheView(image_view); + if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + status=MagickFalse; if (image->progress_monitor != (MagickProgressMonitor) NULL) { MagickBooleanType @@ -744,14 +741,15 @@ MagickExport MagickBooleanType CLAHEImage(Image *image,const size_t x_tiles, #pragma omp atomic #endif progress++; - proceed=SetImageProgress(image,CLAHEImageTag,progress, + proceed=SetImageProgress(image,CLAHEImageTag,progress,2* GetPixelChannels(image)); if (proceed == MagickFalse) status=MagickFalse; } } + image_view=DestroyCacheView(image_view); pixel_cache=RelinquishVirtualMemory(pixel_cache); - return(status); + return(TransformImageColorspace(image,colorspace,exception)); } /* diff --git a/coders/heic.c b/coders/heic.c index cb11db7f9..2883f313b 100644 --- a/coders/heic.c +++ b/coders/heic.c @@ -646,7 +646,7 @@ static MagickBooleanType WriteHEICImage(const ImageInfo *image_info,Image *image p)); p+=GetPixelChannels(image); - if (x+1 < (lont) image->columns) + if (x+1 < (long) image->columns) { p_y[y*stride_y + x+1]=ScaleQuantumToChar(GetPixelRed(image, p)); -- 2.40.0