diff --git a/rtengine/rawimagesource.cc b/rtengine/rawimagesource.cc index f4ca5e100..2851dd032 100644 --- a/rtengine/rawimagesource.cc +++ b/rtengine/rawimagesource.cc @@ -173,6 +173,49 @@ void RawImageSource::transformRect (PreviewProps pp, int tran, int &ssx1, int &s } } +void RawImageSource::interpolate_image(Image16* image, HRecParams hrp, double rm, double gm, double bm, int skip, int tran, int fw, int imwidth, int imheight, int sx1, int sy1, int start, int end) +{ + + unsigned short* red = new unsigned short[imwidth]; + unsigned short* grn = new unsigned short[imwidth]; + unsigned short* blue = new unsigned short[imwidth]; + + for (int i=sy1 + start*skip ,ix=start; ixfilters && this->red && this->blue) { + for (int j=0,jx=sx1; jred[i][jx]); + grn[j] = CLIP(gm*green[i][jx]); + blue[j] = CLIP(bm*this->blue[i][jx]); + } + } else if(ri->filters) { + if (i==0) + interpolate_row_rb_mul_pp (red, blue, NULL, green[i], green[i+1], i, rm, gm, bm, sx1, imwidth, skip); + else if (i==H-1) + interpolate_row_rb_mul_pp (red, blue, green[i-1], green[i], NULL, i, rm, gm, bm, sx1, imwidth, skip); + else + interpolate_row_rb_mul_pp (red, blue, green[i-1], green[i], green[i+1], i, rm, gm, bm, sx1, imwidth, skip); + + for (int j=0,jx=sx1; jdata[i][jx*3+0]); + grn[j] = CLIP(gm*ri->data[i][jx*3+1]); + blue[j] = CLIP(bm*ri->data[i][jx*3+2]); + } + } + + if (hrp.enabled) + hlRecovery (hrp.method, red, grn, blue, i, sx1, imwidth, skip); + + transLine (red, grn, blue, ix, image, tran, imwidth, imheight, fw); + + } + delete [] red; + delete [] grn; + delete [] blue; +} + void RawImageSource::getImage (ColorTemp ctemp, int tran, Image16* image, PreviewProps pp, HRecParams hrp, ColorManagementParams cmp) { isrcMutex.lock (); @@ -227,47 +270,24 @@ void RawImageSource::getImage (ColorTemp ctemp, int tran, Image16* image, Previe imwidth = maximwidth; if (!fuji && imheight>maximheight) imheight = maximheight; - - // render the requested image part - unsigned short* red = new unsigned short[imwidth]; - unsigned short* grn = new unsigned short[imwidth]; - unsigned short* blue = new unsigned short[imwidth]; - for (int i=sy1,ix=0; ixfilters && this->red && this->blue) { - for (int j=0,jx=sx1; jred[i][jx]); - grn[j] = CLIP(gm*green[i][jx]); - blue[j] = CLIP(bm*this->blue[i][jx]); - } - } else if(ri->filters) { - if (i==0) - interpolate_row_rb_mul_pp (red, blue, NULL, green[i], green[i+1], i, rm, gm, bm, sx1, imwidth, pp.skip); - else if (i==H-1) - interpolate_row_rb_mul_pp (red, blue, green[i-1], green[i], NULL, i, rm, gm, bm, sx1, imwidth, pp.skip); - else - interpolate_row_rb_mul_pp (red, blue, green[i-1], green[i], green[i+1], i, rm, gm, bm, sx1, imwidth, pp.skip); - - for (int j=0,jx=sx1; jdata[i][jx*3+0]); - grn[j] = CLIP(gm*ri->data[i][jx*3+1]); - blue[j] = CLIP(bm*ri->data[i][jx*3+2]); - } - } - - if (hrp.enabled) - hlRecovery (hrp.method, red, grn, blue, i, sx1, imwidth, pp.skip); +#ifdef _OPENMP +#pragma omp parallel +{ + int tid = omp_get_thread_num(); + int nthreads = omp_get_num_threads(); + int blk = imheight/nthreads; - transLine (red, grn, blue, ix, image, tran, imwidth, imheight, fw); - } - delete [] red; - delete [] grn; - delete [] blue; - + if (tidwidth%2==0) || ((tran & TR_ROT) == TR_R180 && image->height%2+image->width%2==1) || ((tran & TR_ROT) == TR_R270 && image->height%2==0); // first row diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index fe6fc8b30..61a0ee574 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -97,7 +97,8 @@ class RawImageSource : public ImageSource { void updateHLRecoveryMap (std::string method, double rm, double gm, double bm); void updateHLRecoveryMap_ColorPropagation (); void HLRecovery_ColorPropagation (unsigned short* red, unsigned short* green, unsigned short* blue, int i, int sx1, int width, int skip); - + void interpolate_image(Image16* image, HRecParams hrp, double rm, double gm, double bm, int skip, int tran, int fw, int imwidth, int imheight, int sx, int sy, int start, int end); + public: RawImageSource (); ~RawImageSource ();