Merge branch 'dev' into spot-removal-tool
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
namespace
|
||||
{
|
||||
|
||||
void getScanline8 (const uint16_t *red, const uint16_t *green, const uint16_t *blue, int width, unsigned char* buffer)
|
||||
void getScanline8(const uint16_t *red, const uint16_t *green, const uint16_t *blue, int width, unsigned char* buffer)
|
||||
{
|
||||
for (int i = 0, ix = 0; i < width; i++) {
|
||||
buffer[ix++] = rtengine::uint16ToUint8Rounded(red[i]);
|
||||
@@ -34,7 +34,7 @@ void getScanline8 (const uint16_t *red, const uint16_t *green, const uint16_t *b
|
||||
}
|
||||
}
|
||||
|
||||
void getScanline16 (const uint16_t *red, const uint16_t *green, const uint16_t *blue, int width, unsigned short* buffer)
|
||||
void getScanline16(const uint16_t *red, const uint16_t *green, const uint16_t *blue, int width, unsigned short* buffer)
|
||||
{
|
||||
for (int i = 0, ix = 0; i < width; i++) {
|
||||
buffer[ix++] = red[i];
|
||||
@@ -47,20 +47,20 @@ void getScanline16 (const uint16_t *red, const uint16_t *green, const uint16_t *
|
||||
|
||||
using namespace rtengine;
|
||||
|
||||
Image16::Image16 ()
|
||||
Image16::Image16()
|
||||
{
|
||||
}
|
||||
|
||||
Image16::Image16 (int w, int h)
|
||||
Image16::Image16(int w, int h)
|
||||
{
|
||||
allocate (w, h);
|
||||
allocate(w, h);
|
||||
}
|
||||
|
||||
Image16::~Image16 ()
|
||||
Image16::~Image16()
|
||||
{
|
||||
}
|
||||
|
||||
void Image16::getScanline (int row, unsigned char* buffer, int bps)
|
||||
void Image16::getScanline(int row, unsigned char* buffer, int bps, bool isFloat) const
|
||||
{
|
||||
|
||||
if (data == nullptr) {
|
||||
@@ -68,34 +68,33 @@ void Image16::getScanline (int row, unsigned char* buffer, int bps)
|
||||
}
|
||||
|
||||
if (bps == 16) {
|
||||
getScanline16 (r(row), g(row), b(row), width, (unsigned short*)buffer);
|
||||
getScanline16(r(row), g(row), b(row), width, (unsigned short*)buffer);
|
||||
} else if (bps == 8) {
|
||||
getScanline8 (r(row), g(row), b(row), width, buffer);
|
||||
getScanline8(r(row), g(row), b(row), width, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* void Image16::setScanline (int row, unsigned char* buffer, int bps, int minValue[3], int maxValue[3]);
|
||||
* has not been implemented yet, because as of now, this method is called for IIOSF_FLOAT sample format only
|
||||
*/
|
||||
void Image16::setScanline (int row, unsigned char* buffer, int bps, float *minValue, float *maxValue)
|
||||
void Image16::setScanline(int row, unsigned char* buffer, int bps, unsigned int numSamples)
|
||||
{
|
||||
|
||||
if (data == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// For optimization purpose, we're assuming that this class never has to provide min/max bounds
|
||||
assert(!minValue);
|
||||
|
||||
switch (sampleFormat) {
|
||||
case (IIOSF_UNSIGNED_CHAR): {
|
||||
int ix = 0;
|
||||
|
||||
for (int i = 0; i < width; ++i) {
|
||||
r(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
||||
g(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
||||
b(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
||||
if (numSamples == 1) {
|
||||
for (int i = 0; i < width; ++i) {
|
||||
r(row, i) = g(row, i) = b(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < width; ++i) {
|
||||
r(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
||||
g(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
||||
b(row, i) = static_cast<unsigned short>(buffer[ix++]) * 257;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -125,10 +124,10 @@ void Image16::setScanline (int row, unsigned char* buffer, int bps, float *minVa
|
||||
*/
|
||||
}
|
||||
|
||||
Image16* Image16::copy ()
|
||||
Image16* Image16::copy() const
|
||||
{
|
||||
|
||||
Image16* cp = new Image16 (width, height);
|
||||
Image16* cp = new Image16(width, height);
|
||||
copyData(cp);
|
||||
return cp;
|
||||
}
|
||||
@@ -147,14 +146,15 @@ Image16* Image16::copySubRegion (int x, int y, int width, int height)
|
||||
return cp;
|
||||
}
|
||||
|
||||
void Image16::getStdImage (ColorTemp ctemp, int tran, Imagefloat* image, const PreviewProps & pp, bool first, procparams::ToneCurveParams hrp)
|
||||
void Image16::getStdImage(const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp) const
|
||||
{
|
||||
|
||||
// compute channel multipliers
|
||||
float rm = 1.f, gm = 1.f, bm = 1.f;
|
||||
|
||||
if (ctemp.getTemp() >= 0) {
|
||||
double drm, dgm, dbm;
|
||||
ctemp.getMultipliers (drm, dgm, dbm);
|
||||
ctemp.getMultipliers(drm, dgm, dbm);
|
||||
rm = drm;
|
||||
gm = dgm;
|
||||
bm = dbm;
|
||||
@@ -170,7 +170,7 @@ void Image16::getStdImage (ColorTemp ctemp, int tran, Imagefloat* image, const P
|
||||
|
||||
int sx1, sy1, sx2, sy2;
|
||||
|
||||
transform (pp, tran, sx1, sy1, sx2, sy2);
|
||||
transform(pp, tran, sx1, sy1, sx2, sy2);
|
||||
|
||||
int imwidth = image->getWidth(); // Destination image
|
||||
int imheight = image->getHeight(); // Destination image
|
||||
@@ -280,25 +280,22 @@ void Image16::getStdImage (ColorTemp ctemp, int tran, Imagefloat* image, const P
|
||||
}
|
||||
}
|
||||
|
||||
if (mtran == TR_NONE)
|
||||
if (mtran == TR_NONE)
|
||||
for (int dst_x = 0, src_x = sx1; dst_x < imwidth; dst_x++, src_x += skip) {
|
||||
image->r(iy, dst_x) = lineR[dst_x];
|
||||
image->g(iy, dst_x) = lineG[dst_x];
|
||||
image->b(iy, dst_x) = lineB[dst_x];
|
||||
}
|
||||
else if (mtran == TR_R180)
|
||||
} else if (mtran == TR_R180)
|
||||
for (int dst_x = 0; dst_x < imwidth; dst_x++) {
|
||||
image->r(imheight - 1 - iy, imwidth - 1 - dst_x) = lineR[dst_x];
|
||||
image->g(imheight - 1 - iy, imwidth - 1 - dst_x) = lineG[dst_x];
|
||||
image->b(imheight - 1 - iy, imwidth - 1 - dst_x) = lineB[dst_x];
|
||||
}
|
||||
else if (mtran == TR_R90)
|
||||
} else if (mtran == TR_R90)
|
||||
for (int dst_x = 0, src_x = sx1; dst_x < imwidth; dst_x++, src_x += skip) {
|
||||
image->r(dst_x, imheight - 1 - iy) = lineR[dst_x];
|
||||
image->g(dst_x, imheight - 1 - iy) = lineG[dst_x];
|
||||
image->b(dst_x, imheight - 1 - iy) = lineB[dst_x];
|
||||
}
|
||||
else if (mtran == TR_R270)
|
||||
} else if (mtran == TR_R270)
|
||||
for (int dst_x = 0, src_x = sx1; dst_x < imwidth; dst_x++, src_x += skip) {
|
||||
image->r(imwidth - 1 - dst_x, iy) = lineR[dst_x];
|
||||
image->g(imwidth - 1 - dst_x, iy) = lineG[dst_x];
|
||||
@@ -312,8 +309,7 @@ void Image16::getStdImage (ColorTemp ctemp, int tran, Imagefloat* image, const P
|
||||
#undef GCLIP
|
||||
}
|
||||
|
||||
Image8*
|
||||
Image16::to8()
|
||||
Image8* Image16::to8() const
|
||||
{
|
||||
Image8* img8 = new Image8(width, height);
|
||||
|
||||
@@ -328,23 +324,50 @@ Image16::to8()
|
||||
return img8;
|
||||
}
|
||||
|
||||
Imagefloat*
|
||||
Image16::tofloat()
|
||||
// Parallelized transformation; create transform with cmsFLAGS_NOCACHE!
|
||||
void Image16::ExecCMSTransform(cmsHTRANSFORM hTransform)
|
||||
{
|
||||
Imagefloat* imgfloat = new Imagefloat(width, height);
|
||||
//cmsDoTransform(hTransform, data, data, planestride);
|
||||
|
||||
for (int h = 0; h < height; ++h) {
|
||||
for (int w = 0; w < width; ++w) {
|
||||
imgfloat->r(h, w) = r(h, w);
|
||||
imgfloat->g(h, w) = g(h, w);
|
||||
imgfloat->b(h, w) = b(h, w);
|
||||
}
|
||||
// LittleCMS cannot parallelize planar setups -- Hombre: LCMS2.4 can! But it we use this new feature, memory allocation have to be modified too
|
||||
// so build temporary buffers to allow multi processor execution
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel
|
||||
#endif
|
||||
{
|
||||
AlignedBuffer<unsigned short> buffer(width * 3);
|
||||
|
||||
#ifdef _OPENMP
|
||||
#pragma omp for schedule(static)
|
||||
#endif
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
unsigned short *p = buffer.data, *pR = r(y), *pG = g(y), *pB = b(y);
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
*(p++) = *(pR++);
|
||||
*(p++) = *(pG++);
|
||||
*(p++) = *(pB++);
|
||||
}
|
||||
|
||||
cmsDoTransform(hTransform, buffer.data, buffer.data, width);
|
||||
|
||||
p = buffer.data;
|
||||
pR = r(y);
|
||||
pG = g(y);
|
||||
pB = b(y);
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
*(pR++) = *(p++);
|
||||
*(pG++) = *(p++);
|
||||
*(pB++) = *(p++);
|
||||
}
|
||||
} // End of parallelization
|
||||
}
|
||||
|
||||
return imgfloat;
|
||||
}
|
||||
|
||||
// // Parallized transformation; create transform with cmsFLAGS_NOCACHE!
|
||||
// // Parallelized transformation; create transform with cmsFLAGS_NOCACHE!
|
||||
// void Image16::ExecCMSTransform(cmsHTRANSFORM hTransform, const LabImage &labImage, int cx, int cy)
|
||||
// {
|
||||
// // LittleCMS cannot parallelize planar Lab float images
|
||||
|
Reference in New Issue
Block a user