From b09aeaa6ae9552dada335b4d049a382f70c730ad Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Wed, 31 Jan 2018 17:06:39 +0100 Subject: [PATCH] avoid one useless copy if no cropping is required --- rtengine/histmatching.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/rtengine/histmatching.cc b/rtengine/histmatching.cc index b17eff5f5..e496f6f82 100644 --- a/rtengine/histmatching.cc +++ b/rtengine/histmatching.cc @@ -257,18 +257,20 @@ void RawImageSource::getAutoMatchedToneCurve(std::vector &outCurve) std::cout << "histogram matching: cropping target to get an aspect ratio of " << round(thumb_ratio * 100)/100.0 << ":1, new size is " << tw << "x" << th << std::endl; } - Image8 *tmp = new Image8(tw, th); + if (cx || cy) { + Image8 *tmp = new Image8(tw, th); #ifdef _OPENMP - #pragma omp parallel for + #pragma omp parallel for #endif - for (int y = 0; y < th; ++y) { - for (int x = 0; x < tw; ++x) { - tmp->r(y, x) = target->r(y+cy, x+cx); - tmp->g(y, x) = target->g(y+cy, x+cx); - tmp->b(y, x) = target->b(y+cy, x+cx); + for (int y = 0; y < th; ++y) { + for (int x = 0; x < tw; ++x) { + tmp->r(y, x) = target->r(y+cy, x+cx); + tmp->g(y, x) = target->g(y+cy, x+cx); + tmp->b(y, x) = target->b(y+cy, x+cx); + } } + target.reset(tmp); } - target.reset(tmp); } if (settings->verbose) {