Single threaded unless workload justifies the threading overhead.
*/
#define magick_threads(source,destination,chunk,expression) \
- num_threads((expression) == 0 ? 1 : \
- ((chunk) > (32*GetMagickResourceLimit(ThreadResource))) && \
- ((GetImagePixelCacheType(source) == MemoryCache) || \
- (GetImagePixelCacheType(source) == MapCache)) && \
- ((GetImagePixelCacheType(destination) == MemoryCache) || \
- (GetImagePixelCacheType(destination) == MapCache)) ? \
- GetMagickResourceLimit(ThreadResource) : \
- GetMagickResourceLimit(ThreadResource) < 2 ? 1 : 2)
+ num_threads((expression) != 0 && \
+ ((GetImagePixelCacheType(source) == MemoryCache) || \
+ (GetImagePixelCacheType(source) == MapCache)) && \
+ ((GetImagePixelCacheType(destination) == MemoryCache) || \
+ (GetImagePixelCacheType(destination) == MapCache)) ? \
+ max(1,min(GetMagickResourceLimit(ThreadResource),(chunk) / 16)) : 1)
#if defined(__clang__) || (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 10))
#define MagickCachePrefetch(address,mode,locality) \