merge with dev

This commit is contained in:
Desmis 2019-02-13 11:11:34 +01:00
commit d43f6cbbf1
7 changed files with 37 additions and 32 deletions

View File

@ -139,7 +139,7 @@ protected:
AlignedBuffer<T*> ab; AlignedBuffer<T*> ab;
public: public:
#if CHECK_BOUNDS #if CHECK_BOUNDS
int width_, height_; size_t width_, height_;
#endif #endif
T** ptrs; T** ptrs;
@ -149,7 +149,7 @@ public:
PlanarPtr() : ptrs (nullptr) {} PlanarPtr() : ptrs (nullptr) {}
#endif #endif
bool resize(int newSize) bool resize(size_t newSize)
{ {
if (ab.resize(newSize)) { if (ab.resize(newSize)) {
ptrs = ab.data; ptrs = ab.data;
@ -167,7 +167,7 @@ public:
ptrs = tmpsPtrs; ptrs = tmpsPtrs;
#if CHECK_BOUNDS #if CHECK_BOUNDS
int tmp = other.width_; size_t tmp = other.width_;
other.width_ = width_; other.width_ = width_;
width_ = tmp; width_ = tmp;
tmp = other.height_; tmp = other.height_;
@ -176,7 +176,7 @@ public:
#endif #endif
} }
T*& operator() (unsigned row) T*& operator() (size_t row)
{ {
#if CHECK_BOUNDS #if CHECK_BOUNDS
assert (row < height_); assert (row < height_);
@ -184,7 +184,7 @@ public:
return ptrs[row]; return ptrs[row];
} }
// Will send back the start of a row, starting with a red, green or blue value // Will send back the start of a row, starting with a red, green or blue value
T* operator() (unsigned row) const T* operator() (size_t row) const
{ {
#if CHECK_BOUNDS #if CHECK_BOUNDS
assert (row < height_); assert (row < height_);
@ -192,14 +192,14 @@ public:
return ptrs[row]; return ptrs[row];
} }
// Will send back a value at a given row, col position // Will send back a value at a given row, col position
T& operator() (unsigned row, unsigned col) T& operator() (size_t row, size_t col)
{ {
#if CHECK_BOUNDS #if CHECK_BOUNDS
assert (row < height_ && col < width_); assert (row < height_ && col < width_);
#endif #endif
return ptrs[row][col]; return ptrs[row][col];
} }
const T operator() (unsigned row, unsigned col) const const T operator() (size_t row, size_t col) const
{ {
#if CHECK_BOUNDS #if CHECK_BOUNDS
assert (row < height_ && col < width_); assert (row < height_ && col < width_);
@ -215,7 +215,7 @@ class PlanarWhateverData : virtual public ImageDatas
private: private:
AlignedBuffer<T> abData; AlignedBuffer<T> abData;
int rowstride; // Plan size, in bytes (all padding bytes included) size_t rowstride; // Plan size, in bytes (all padding bytes included)
public: public:
T* data; T* data;
@ -228,7 +228,7 @@ public:
} }
// Send back the row stride. WARNING: unit = byte, not element! // Send back the row stride. WARNING: unit = byte, not element!
int getRowStride () const size_t getRowStride () const
{ {
return rowstride; return rowstride;
} }
@ -259,7 +259,6 @@ public:
* Can be safely used to reallocate an existing image */ * Can be safely used to reallocate an existing image */
void allocate (int W, int H) override void allocate (int W, int H) override
{ {
if (W == width && H == height) { if (W == width && H == height) {
return; return;
} }
@ -591,8 +590,8 @@ class PlanarRGBData : virtual public ImageDatas
private: private:
AlignedBuffer<T> abData; AlignedBuffer<T> abData;
int rowstride; // Plan size, in bytes (all padding bytes included) size_t rowstride; // Plan size, in bytes (all padding bytes included)
int planestride; // Row length, in bytes (padding bytes included) size_t planestride; // Row length, in bytes (padding bytes included)
protected: protected:
T* data; T* data;
@ -602,18 +601,18 @@ public:
PlanarPtr<T> b; PlanarPtr<T> b;
PlanarRGBData() : rowstride(0), planestride(0), data (nullptr) {} PlanarRGBData() : rowstride(0), planestride(0), data (nullptr) {}
PlanarRGBData(int w, int h) : rowstride(0), planestride(0), data (nullptr) PlanarRGBData(size_t w, size_t h) : rowstride(0), planestride(0), data (nullptr)
{ {
allocate(w, h); allocate(w, h);
} }
// Send back the row stride. WARNING: unit = byte, not element! // Send back the row stride. WARNING: unit = byte, not element!
int getRowStride () const size_t getRowStride () const
{ {
return rowstride; return rowstride;
} }
// Send back the plane stride. WARNING: unit = byte, not element! // Send back the plane stride. WARNING: unit = byte, not element!
int getPlaneStride () const size_t getPlaneStride () const
{ {
return planestride; return planestride;
} }
@ -710,7 +709,7 @@ public:
char *bluestart = (char*)(data) + 2 * planestride; char *bluestart = (char*)(data) + 2 * planestride;
for (int i = 0; i < height; ++i) { for (int i = 0; i < height; ++i) {
int k = i * rowstride; size_t k = i * rowstride;
r(i) = (T*)(redstart + k); r(i) = (T*)(redstart + k);
g(i) = (T*)(greenstart + k); g(i) = (T*)(greenstart + k);
b(i) = (T*)(bluestart + k); b(i) = (T*)(bluestart + k);
@ -1180,10 +1179,10 @@ class ChunkyPtr
{ {
private: private:
T* ptr; T* ptr;
int width; ssize_t width;
public: public:
#if CHECK_BOUNDS #if CHECK_BOUNDS
int width_, height_; size_t width_, height_;
#endif #endif
#if CHECK_BOUNDS #if CHECK_BOUNDS
@ -1191,7 +1190,7 @@ public:
#else #else
ChunkyPtr() : ptr (nullptr), width(-1) {} ChunkyPtr() : ptr (nullptr), width(-1) {}
#endif #endif
void init(T* base, int w = -1) void init(T* base, ssize_t w = -1)
{ {
ptr = base; ptr = base;
width = w; width = w;
@ -1202,12 +1201,12 @@ public:
other.ptr = ptr; other.ptr = ptr;
ptr = tmpsPtr; ptr = tmpsPtr;
int tmpWidth = other.width; ssize_t tmpWidth = other.width;
other.width = width; other.width = width;
width = tmpWidth; width = tmpWidth;
#if CHECK_BOUNDS #if CHECK_BOUNDS
int tmp = other.width_; size_t tmp = other.width_;
other.width_ = width_; other.width_ = width_;
width_ = tmp; width_ = tmp;
tmp = other.height_; tmp = other.height_;
@ -1218,7 +1217,7 @@ public:
} }
// Will send back the start of a row, starting with a red, green or blue value // Will send back the start of a row, starting with a red, green or blue value
T* operator() (unsigned row) const T* operator() (size_t row) const
{ {
#if CHECK_BOUNDS #if CHECK_BOUNDS
assert (row < height_); assert (row < height_);
@ -1226,14 +1225,14 @@ public:
return &ptr[3 * (row * width)]; return &ptr[3 * (row * width)];
} }
// Will send back a value at a given row, col position // Will send back a value at a given row, col position
T& operator() (unsigned row, unsigned col) T& operator() (size_t row, size_t col)
{ {
#if CHECK_BOUNDS #if CHECK_BOUNDS
assert (row < height_ && col < width_); assert (row < height_ && col < width_);
#endif #endif
return ptr[3 * (row * width + col)]; return ptr[3 * (row * width + col)];
} }
const T operator() (unsigned row, unsigned col) const const T operator() (size_t row, size_t col) const
{ {
#if CHECK_BOUNDS #if CHECK_BOUNDS
assert (row < height_ && col < width_); assert (row < height_ && col < width_);
@ -1315,7 +1314,7 @@ public:
b.height_ = height; b.height_ = height;
#endif #endif
abData.resize(width * height * 3u); abData.resize((size_t)width * (size_t)height * (size_t)3);
if (!abData.isEmpty()) { if (!abData.isEmpty()) {
data = abData.data; data = abData.data;

View File

@ -69,7 +69,7 @@ void Image8::setScanline (int row, unsigned char* buffer, int bps, unsigned int
data[row * width * 3 + 3 * i] = data[row * width * 3 + 3 * i + 1] = data[row * width * 3 + 3 * i + 2] = buffer[i]; data[row * width * 3 + 3 * i] = data[row * width * 3 + 3 * i + 1] = data[row * width * 3 + 3 * i + 2] = buffer[i];
} }
} else { } else {
memcpy (data + row * width * 3u, buffer, width * 3); memcpy (data + (uint64_t)row * (uint64_t)width * (uint64_t)3u, buffer, width * 3);
} }
break; break;

View File

@ -5546,7 +5546,7 @@ void ImProcFunctions::getAutoExp(const LUTu &histogram, int histcompr, double cl
histogram.getSumAndAverage(sum, ave); histogram.getSumAndAverage(sum, ave);
//find median of luminance //find median of luminance
int median = 0, count = histogram[0]; size_t median = 0, count = histogram[0];
while (count < sum / 2) { while (count < sum / 2) {
median++; median++;

View File

@ -64,7 +64,7 @@ void LabImage::getPipetteData (float &v1, float &v2, float &v3, int posX, int po
v3 = n ? accumulator_b / float(n) : 0.f; v3 = n ? accumulator_b / float(n) : 0.f;
} }
void LabImage::allocLab(int w, int h) void LabImage::allocLab(size_t w, size_t h)
{ {
L = new float*[h]; L = new float*[h];
a = new float*[h]; a = new float*[h];
@ -73,19 +73,19 @@ void LabImage::allocLab(int w, int h)
data = new float [w * h * 3]; data = new float [w * h * 3];
float * index = data; float * index = data;
for (int i = 0; i < h; i++) { for (size_t i = 0; i < h; i++) {
L[i] = index + i * w; L[i] = index + i * w;
} }
index += w * h; index += w * h;
for (int i = 0; i < h; i++) { for (size_t i = 0; i < h; i++) {
a[i] = index + i * w; a[i] = index + i * w;
} }
index += w * h; index += w * h;
for (int i = 0; i < h; i++) { for (size_t i = 0; i < h; i++) {
b[i] = index + i * w; b[i] = index + i * w;
} }
} }

View File

@ -25,7 +25,7 @@ namespace rtengine
class LabImage class LabImage
{ {
private: private:
void allocLab(int w, int h); void allocLab(size_t w, size_t h);
public: public:
int W, H; int W, H;

View File

@ -338,5 +338,10 @@ ColorTemp StdImageSource::getSpotWB (std::vector<Coord2D> &red, std::vector<Coor
return ColorTemp (reds / rn * img_r, greens / gn * img_g, blues / bn * img_b, equal); return ColorTemp (reds / rn * img_r, greens / gn * img_g, blues / bn * img_b, equal);
} }
void StdImageSource::flushRGB() {
img->allocate(0, 0);
};
} }

View File

@ -101,6 +101,7 @@ public:
void getRawValues(int x, int y, int rotate, int &R, int &G, int &B) override { R = G = B = 0;} void getRawValues(int x, int y, int rotate, int &R, int &G, int &B) override { R = G = B = 0;}
void flushRGB () override;
}; };
} }