diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2015-03-29 23:07:03 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2015-03-29 23:07:03 +0000 |
commit | dd2bedb00517b296115cc56a66300194ab9a25d9 (patch) | |
tree | 7a68e60481770e1d0dd7d03c229d96d42cd93e13 /editor/pnmgamma.c | |
parent | 04c4c8a3ce3ccb391877c25039c52a1a9cc07bd4 (diff) | |
download | netpbm-mirror-dd2bedb00517b296115cc56a66300194ab9a25d9.tar.gz netpbm-mirror-dd2bedb00517b296115cc56a66300194ab9a25d9.tar.xz netpbm-mirror-dd2bedb00517b296115cc56a66300194ab9a25d9.zip |
Release 10.70.00
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@2442 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/pnmgamma.c')
-rw-r--r-- | editor/pnmgamma.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/editor/pnmgamma.c b/editor/pnmgamma.c index 96068bfe..b357b0d8 100644 --- a/editor/pnmgamma.c +++ b/editor/pnmgamma.c @@ -10,6 +10,7 @@ ** implied warranty. */ +#include <assert.h> #include <math.h> #include <ctype.h> @@ -308,6 +309,7 @@ buildPowGamma(xelval table[], double const normalized = ((double) i) / maxval; /* Xel sample value normalized to 0..1 */ double const v = pow(normalized, oneOverGamma); + table[i] = MIN((xelval)(v * newMaxval + 0.5), newMaxval); /* denormalize, round and clip */ } @@ -509,11 +511,15 @@ buildBt709ToSrgbGamma(xelval table[], else radiance = pow((normalized + 0.099) / 1.099, gamma709); + assert(radiance <= 1.0); + if (radiance < linearCutoffSrgb * normalizer) srgb = radiance * linearExpansionSrgb; else srgb = 1.055 * pow(normalized, oneOverGammaSrgb) - 0.055; + assert(srgb <= 1.0); + table[i] = srgb * newMaxval + 0.5; } } @@ -563,11 +569,15 @@ buildSrgbToBt709Gamma(xelval table[], else radiance = pow((normalized + 0.099) / 1.099, gammaSrgb); + assert(radiance <= 1.0); + if (radiance < linearCutoff709 * normalizer) bt709 = radiance * linearExpansion709; else bt709 = 1.055 * pow(normalized, oneOverGamma709) - 0.055; + assert(bt709 <= 1.0); + table[i] = bt709 * newMaxval + 0.5; } } |