Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ OPENCL_INCLUDE_PATH := $(OPENCL_PATH)/qualcomm/include

LTDL_LIB_PATH := $(LOCAL_PATH)/libltdl-2.4.6

IMAGE_MAGICK_BASEDIR := ImageMagick-7.1.2-0
IMAGE_MAGICK_BASEDIR := ImageMagick-7.1.2-1
IMAGE_MAGICK := $(LOCAL_PATH)/$(IMAGE_MAGICK_BASEDIR)

JPEG_LIB_PATH := $(LOCAL_PATH)/libjpeg-turbo-2.0.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@
% o clone_image: the source image for artifacts to clone.
%
*/

typedef char
*(*CloneKeyFunc)(const char *),
*(*CloneValueFunc)(const char *);

static inline void *CloneArtifactKey(void *key)
{
return((void *) ((CloneKeyFunc) ConstantString)((const char *) key));
}

static inline void *CloneArtifactValue(void *value)
{
return((void *) ((CloneValueFunc) ConstantString)((const char *) value));
}

MagickExport MagickBooleanType CloneImageArtifacts(Image *image,
const Image *clone_image)
{
Expand All @@ -117,7 +132,7 @@ MagickExport MagickBooleanType CloneImageArtifacts(Image *image,
if (image->artifacts != (void *) NULL)
DestroyImageArtifacts(image);
image->artifacts=CloneSplayTree((SplayTreeInfo *) clone_image->artifacts,
(void *(*)(void *)) ConstantString,(void *(*)(void *)) ConstantString);
CloneArtifactKey,CloneArtifactValue);
}
return(MagickTrue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,27 @@ MagickExport MagickSizeType GetImageExtent(const Image *image)
%
*/

static MagickBooleanType GetDynamicThrottlePolicy(void)
{
static MagickBooleanType
check_policy = MagickTrue;

static MagickBooleanType
dynamic_throttle = MagickFalse;

if (check_policy != MagickFalse)
{
char *value = GetPolicyValue("resource:dynamic-throttle");
if (value != (char *) NULL)
{
dynamic_throttle=IsStringTrue(value);
value=DestroyString(value);
}
check_policy=MagickFalse;
}
return(dynamic_throttle);
}

static inline MagickBooleanType ValidatePixelCacheMorphology(
const Image *magick_restrict image)
{
Expand Down Expand Up @@ -1720,8 +1741,29 @@ static Cache GetImagePixelCache(Image *image,const MagickBooleanType clone,
}
if (cpu_throttle == MagickResourceInfinity)
cpu_throttle=GetMagickResourceLimit(ThrottleResource);
if ((cpu_throttle != 0) && ((cycles++ % 4096) == 0))
if ((GetDynamicThrottlePolicy() != MagickFalse) && ((cycles % 65536) == 0))
{
const double
max_delay = 50.0,
sensitivity = 0.3;

double
load,
load_average = 0.0;

/*
Dynamically throttle the CPU relative to the load average.
*/
#if defined(MAGICKCORE_HAVE_GETLOADAVG)
if (getloadavg(&load_average,1) != 1)
load_average=0.0;
#endif
load=MagickMax(load_average-GetOpenMPMaximumThreads(),0.0);
cpu_throttle=(MagickSizeType) (max_delay*(1.0-exp(-sensitivity*load)));
}
if ((cpu_throttle != 0) && ((cycles % 4096) == 0))
MagickDelay(cpu_throttle);
cycles++;
LockSemaphoreInfo(image->semaphore);
assert(image->cache != (Cache) NULL);
cache_info=(CacheInfo *) image->cache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ MagickPrivate MagickBooleanType IsEquivalentAlpha(const Image *image,
return(MagickTrue);
fuzz=p->fuzz*p->fuzz+q->fuzz*q->fuzz;
pixel=(double) p->alpha-(double) q->alpha;
if ((pixel*pixel) > fuzz)
if (MagickSafeSignificantError(pixel*pixel,fuzz) != MagickFalse)
return(MagickFalse);
return(MagickTrue);
}
Expand Down Expand Up @@ -1855,7 +1855,7 @@ MagickPrivate MagickBooleanType IsEquivalentIntensity(const Image *image,
return(MagickTrue);
fuzz=p->fuzz*p->fuzz+q->fuzz*q->fuzz;
pixel=GetPixelInfoIntensity(image,p)-GetPixelInfoIntensity(image,q);
if ((pixel*pixel) > fuzz)
if (MagickSafeSignificantError(pixel*pixel,fuzz) != MagickFalse)
return(MagickFalse);
return(MagickTrue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
#include "MagickCore/string-private.h"
#include "MagickCore/utility.h"

/*
Define declarations.
*/
#define MaximumLogarithmicColorspace 1024.0

/*
Typedef declarations.
*/
Expand Down Expand Up @@ -1106,7 +1111,7 @@ static MagickBooleanType sRGBTransformImage(Image *image,
for (i=0; i <= (ssize_t) MaxMap; i++)
logmap[i]=ScaleMapToQuantum(((double) MaxMap*(reference_white+
log10(black+(1.0*i/MaxMap)*(1.0-black))/((gamma/density)*0.002*
MagickSafeReciprocal(film_gamma)))/1024.0));
MagickSafeReciprocal(film_gamma)))/MaximumLogarithmicColorspace));
image_view=AcquireAuthenticCacheView(image,exception);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(static) shared(status) \
Expand Down Expand Up @@ -2420,23 +2425,29 @@ static MagickBooleanType TransformsRGBImage(Image *image,
value=GetImageProperty(image,"reference-black",exception);
if (value != (const char *) NULL)
reference_black=StringToDouble(value,(char **) NULL);
if (reference_black > MaximumLogarithmicColorspace)
reference_black=MaximumLogarithmicColorspace;
reference_white=ReferenceWhite;
value=GetImageProperty(image,"reference-white",exception);
if (value != (const char *) NULL)
reference_white=StringToDouble(value,(char **) NULL);
if (reference_white > MaximumLogarithmicColorspace)
reference_white=MaximumLogarithmicColorspace;
if (reference_black > reference_white)
reference_black=reference_white;
logmap=(Quantum *) AcquireQuantumMemory((size_t) MaxMap+1UL,
sizeof(*logmap));
if (logmap == (Quantum *) NULL)
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
black=pow(10.0,(reference_black-reference_white)*(gamma/density)*0.002*
MagickSafeReciprocal(film_gamma));
for (i=0; i <= (ssize_t) (reference_black*MaxMap/1024.0); i++)
for (i=0; i <= (ssize_t) (reference_black*MaxMap/MaximumLogarithmicColorspace); i++)
logmap[i]=(Quantum) 0;
for ( ; i < (ssize_t) (reference_white*MaxMap/1024.0); i++)
for ( ; i < (ssize_t) (reference_white*MaxMap/MaximumLogarithmicColorspace); i++)
logmap[i]=ClampToQuantum((double) QuantumRange/(1.0-black)*
(pow(10.0,(1024.0*i/MaxMap-reference_white)*(gamma/density)*0.002*
MagickSafeReciprocal(film_gamma))-black));
(pow(10.0,(MaximumLogarithmicColorspace*i/MaxMap-reference_white)*
(gamma/density)*0.002*MagickSafeReciprocal(film_gamma))-black));
for ( ; i <= (ssize_t) MaxMap; i++)
logmap[i]=QuantumRange;
if (image->storage_class == PseudoClass)
Expand Down Expand Up @@ -2787,12 +2798,12 @@ static MagickBooleanType TransformsRGBImage(Image *image,
pixel.blue=x_map[red].z+y_map[green].z+z_map[blue].z;
if (image->colorspace == YCCColorspace)
{
pixel.red=(double) QuantumRange*(double)
YCCMap[RoundToYCC(1024.0*pixel.red/(double) MaxMap)];
pixel.green=(double) QuantumRange*(double)
YCCMap[RoundToYCC(1024.0*pixel.green/(double) MaxMap)];
pixel.blue=(double) QuantumRange*(double)
YCCMap[RoundToYCC(1024.0*pixel.blue/(double) MaxMap)];
pixel.red=(double) QuantumRange*(double) YCCMap[RoundToYCC(
MaximumLogarithmicColorspace*pixel.red/(double) MaxMap)];
pixel.green=(double) QuantumRange*(double) YCCMap[RoundToYCC(
MaximumLogarithmicColorspace*pixel.green/(double) MaxMap)];
pixel.blue=(double) QuantumRange*(double) YCCMap[RoundToYCC(
MaximumLogarithmicColorspace*pixel.blue/(double) MaxMap)];
}
else
{
Expand Down Expand Up @@ -2853,12 +2864,12 @@ static MagickBooleanType TransformsRGBImage(Image *image,
pixel.blue=x_map[red].z+y_map[green].z+z_map[blue].z;
if (image->colorspace == YCCColorspace)
{
pixel.red=(double) QuantumRange*(double) YCCMap[RoundToYCC(1024.0*
pixel.red/(double) MaxMap)];
pixel.green=(double) QuantumRange*(double) YCCMap[RoundToYCC(1024.0*
pixel.green/(double) MaxMap)];
pixel.blue=(double) QuantumRange*(double) YCCMap[RoundToYCC(1024.0*
pixel.blue/(double) MaxMap)];
pixel.red=(double) QuantumRange*(double) YCCMap[RoundToYCC(
MaximumLogarithmicColorspace*pixel.red/(double) MaxMap)];
pixel.green=(double) QuantumRange*(double) YCCMap[RoundToYCC(
MaximumLogarithmicColorspace*pixel.green/(double) MaxMap)];
pixel.blue=(double) QuantumRange*(double) YCCMap[RoundToYCC(
MaximumLogarithmicColorspace*pixel.blue/(double) MaxMap)];
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ static MagickBooleanType GetAESimilarity(const Image *image,
channel,q);
else
error=Sa*p[i]-Da*GetPixelChannel(reconstruct_image,channel,q);
if ((error*error) > fuzz)
if (MagickSafeSignificantError(error*error,fuzz) != MagickFalse)
{
channel_similarity[i]++;
count++;
Expand Down Expand Up @@ -724,7 +724,7 @@ static MagickBooleanType GetFUZZSimilarity(const Image *image,
channel,q);
else
error=Sa*p[i]-Da*GetPixelChannel(reconstruct_image,channel,q);
if ((error*error) > fuzz)
if (MagickSafeSignificantError(error*error,fuzz) != MagickFalse)
{
channel_similarity[i]+=QuantumScale*error*QuantumScale*error;
channel_similarity[CompositePixelChannel]+=QuantumScale*error*
Expand Down
Loading
Loading