Fix segfaults when processing very large files in queue, #5170
This commit is contained in:
parent
2d167d923b
commit
8eba1c40a6
@ -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);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user