diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-03-05 15:33:47 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-03-05 15:41:44 +0400 |
commit | e49e78e414d7e7b2e18cbe3fa3f7c967a54a1af3 (patch) | |
tree | bb0d1578c522b10e9fe3e90bc6c99483e87b035e /source/blender | |
parent | c169413a0f28a9683d5d703c7ead1acc652dbc40 (diff) |
Fix for negative gamma correction rounding to int
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/seqeffects.c | 22 |
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; } |