Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-03-05 15:33:47 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-03-05 15:41:44 +0400
commite49e78e414d7e7b2e18cbe3fa3f7c967a54a1af3 (patch)
treebb0d1578c522b10e9fe3e90bc6c99483e87b035e
parentc169413a0f28a9683d5d703c7ead1acc652dbc40 (diff)
Fix for negative gamma correction rounding to int
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 145b6954eb0..e491661d5b1 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -635,33 +635,35 @@ static void makeGammaTables(float gamma)
static float gammaCorrect(float c)
{
int i;
- float res = 0.0;
+ float res;
- i = floor(c * inv_color_step);
+ i = floorf(c * inv_color_step);
/* Clip to range [0, 1]: outside, just do the complete calculation.
* We may have some performance problems here. Stretching up the LUT
* may help solve that, by exchanging LUT size for the interpolation.
* Negative colors are explicitly handled.
*/
- if (i < 0) res = -pow(abs(c), valid_gamma);
- else if (i >= RE_GAMMA_TABLE_SIZE) res = pow(c, valid_gamma);
- else res = gamma_range_table[i] + ( (c - color_domain_table[i]) * gamfactor_table[i]);
+ if (UNLIKELY(i < 0)) res = -powf(-c, valid_gamma);
+ else if (i >= RE_GAMMA_TABLE_SIZE) res = powf(c, valid_gamma);
+ else res = gamma_range_table[i] +
+ ((c - color_domain_table[i]) * gamfactor_table[i]);
return res;
}
/* ------------------------------------------------------------------------- */
-static float invGammaCorrect(float col)
+static float invGammaCorrect(float c)
{
int i;
float res = 0.0;
- i = floor(col * inv_color_step);
+ i = floorf(c * inv_color_step);
/* Negative colors are explicitly handled */
- if (i < 0) res = -pow(abs(col), valid_inv_gamma);
- else if (i >= RE_GAMMA_TABLE_SIZE) res = pow(col, valid_inv_gamma);
- else res = inv_gamma_range_table[i] + ( (col - color_domain_table[i]) * inv_gamfactor_table[i]);
+ if (UNLIKELY(i < 0)) res = -powf(-c, valid_inv_gamma);
+ else if (i >= RE_GAMMA_TABLE_SIZE) res = powf(c, valid_inv_gamma);
+ else res = inv_gamma_range_table[i] +
+ ((c - color_domain_table[i]) * inv_gamfactor_table[i]);
return res;
}