From c2737fadc1c159af45417cc5f9334e46a765b989 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 11 May 2016 08:55:09 +0530 Subject: [PATCH] Fixes for compilation on Visual Studio 2015 --- src/calibre/utils/imageops/quantize.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/calibre/utils/imageops/quantize.cpp b/src/calibre/utils/imageops/quantize.cpp index dfc7c20a92..55a6369659 100644 --- a/src/calibre/utils/imageops/quantize.cpp +++ b/src/calibre/utils/imageops/quantize.cpp @@ -22,13 +22,11 @@ // Increasing this number improves quality but also increases running time and memory consumption static const size_t MAX_LEAVES = 2000; -#ifdef _MSC_VER +#if defined _MSC_VER && _MSC_VER < 1700 typedef unsigned __int64 uint64_t; typedef __int64 int64_t; #define UINT64_MAX _UI64_MAX -#ifndef log2 static inline double log2(double x) { return log(x) / log((double)2) ; } -#endif #else #include #ifndef UINT64_MAX @@ -56,8 +54,8 @@ private: T *first_available; public: - Pool(size_t size) : nodes(size), first_available(nodes.data()) { - for (size_t i = 0; i < size - 1; i++) this->nodes[i].next_available_in_pool = &this->nodes[i+1]; + Pool(int size) : nodes(size), first_available(nodes.data()) { + for (int i = 0; i < size - 1; i++) this->nodes[i].next_available_in_pool = &this->nodes[i+1]; } T* checkout() { @@ -243,7 +241,7 @@ public: unsigned char index = get_index(r, g, b, level); if (this->children[index] == NULL) { uint64_t min_distance = UINT64_MAX, distance; - for(size_t i = 0; i < MAX_DEPTH; i++) { + for(unsigned char i = 0; i < MAX_DEPTH; i++) { if ((child = this->children[i]) != NULL) { distance = euclidean_distance(r, g, b, child->avg.red, child->avg.green, child->avg.blue); if (distance < min_distance) { min_distance = distance; index = i; }