From 8619fd8a0b789c4fa284ee262da91d238e638d27 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Sat, 5 Mar 2016 18:50:26 +0100 Subject: [PATCH] 25% speedup for raw false colour suppression --- rtengine/median.h | 29 +++++++---------------------- rtengine/rawimagesource.h | 4 ++-- rtengine/rawimagesource_i.h | 16 ++++++++-------- 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/rtengine/median.h b/rtengine/median.h index 61da0d5a0..4171bb299 100644 --- a/rtengine/median.h +++ b/rtengine/median.h @@ -16,30 +16,15 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ +#include "rt_math.h" + #define SORT3(a1,a2,a3,b1,b2,b3) \ { \ - if ((a1)<(a2)) { \ - if ((a2)<(a3)) { \ - (b1) = (a1); (b2) = (a2); (b3) = (a3); \ - } \ - else if ((a1)<(a3)) { \ - (b1) = (a1); (b2) = (a3); (b3) = (a2); \ - } \ - else { \ - (b1) = (a3); (b2) = (a1); (b3) = (a2); \ - } \ - } \ - else { \ - if ((a3)<(a2)) { \ - (b1) = (a3); (b2) = (a2); (b3) = (a1); \ - } \ - else if ((a3)<(a1)) { \ - (b1) = (a2); (b2) = (a3); (b3) = (a1); \ - } \ - else { \ - (b1) = (a2); (b2) = (a1); (b3) = (a3); \ - } \ - } \ + b2 = min(a1,a2);\ + b1 = min(b2,a3);\ + b3 = max(a1,a2);\ + b2 = max(b2, min(b3,a3));\ + b3 = max(b3,a3);\ } #define MERGESORT(a1,a2,a3,b1,b2,b3,c1,c2,c3,c4,c5,c6) \ diff --git a/rtengine/rawimagesource.h b/rtengine/rawimagesource.h index 3cb345536..d2f524f8a 100644 --- a/rtengine/rawimagesource.h +++ b/rtengine/rawimagesource.h @@ -207,8 +207,8 @@ public: protected: typedef unsigned short ushort; void processFalseColorCorrection (Imagefloat* i, int steps); - inline void convert_row_to_YIQ (float* r, float* g, float* b, float* Y, float* I, float* Q, int W); - inline void convert_row_to_RGB (float* r, float* g, float* b, float* Y, float* I, float* Q, int W); + inline void convert_row_to_YIQ (const float* const r, const float* const g, const float* const b, float* Y, float* I, float* Q, const int W); + inline void convert_row_to_RGB (float* r, float* g, float* b, const float* const Y, const float* const I, const float* const Q, const int W); inline void convert_to_cielab_row (float* ar, float* ag, float* ab, float* oL, float* oa, float* ob); inline void interpolate_row_g (float* agh, float* agv, int i); diff --git a/rtengine/rawimagesource_i.h b/rtengine/rawimagesource_i.h index a3cd28253..8ef2e435f 100644 --- a/rtengine/rawimagesource_i.h +++ b/rtengine/rawimagesource_i.h @@ -27,21 +27,21 @@ namespace rtengine { -inline void RawImageSource::convert_row_to_YIQ (float* r, float* g, float* b, float* Y, float* I, float* Q, int W) +inline void RawImageSource::convert_row_to_YIQ (const float* const r, const float* const g, const float* const b, float* Y, float* I, float* Q, const int W) { for (int j = 0; j < W; j++) { - Y[j] = .299 * r[j] + .587 * g[j] + .114 * b[j]; - I[j] = .596 * r[j] - .275 * g[j] - .321 * b[j]; - Q[j] = .212 * r[j] - .523 * g[j] + .311 * b[j]; + Y[j] = .299f * r[j] + .587f * g[j] + .114f * b[j]; + I[j] = .596f * r[j] - .275f * g[j] - .321f * b[j]; + Q[j] = .212f * r[j] - .523f * g[j] + .311f * b[j]; } } -inline void RawImageSource::convert_row_to_RGB (float* r, float* g, float* b, float* Y, float* I, float* Q, int W) +inline void RawImageSource::convert_row_to_RGB (float* r, float* g, float* b, const float* const Y, const float* const I, const float* const Q, const int W) { for (int j = 1; j < W - 1; j++) { - r[j] = Y[j] + 0.956 * I[j] + 0.621 * Q[j]; - g[j] = Y[j] - 0.272 * I[j] - 0.647 * Q[j]; - b[j] = Y[j] - 1.105 * I[j] + 1.702 * Q[j]; + r[j] = Y[j] + 0.956f * I[j] + 0.621f * Q[j]; + g[j] = Y[j] - 0.272f * I[j] - 0.647f * Q[j]; + b[j] = Y[j] - 1.105f * I[j] + 1.702f * Q[j]; } }