about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-04-09 18:08:18 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-04-09 18:08:18 +0000
commitdd63dfa08670e787738e11c84d99e86514347346 (patch)
treea9f0070f80d8eaf19822267b9fb3b39f338aa8f7
parentd4162bb3114ed587e9219f34133556f50ce24cef (diff)
downloadnetpbm-mirror-dd63dfa08670e787738e11c84d99e86514347346.tar.gz
netpbm-mirror-dd63dfa08670e787738e11c84d99e86514347346.tar.xz
netpbm-mirror-dd63dfa08670e787738e11c84d99e86514347346.zip
Fix wrong bt709<->srgb gamma tables
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4323 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--doc/HISTORY4
-rw-r--r--editor/pnmgamma.c6
2 files changed, 7 insertions, 3 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index db733232..1f01d230 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -6,6 +6,10 @@ CHANGE HISTORY
 
 not yet  BJH  Release 10.99.00
 
+              pnmgamma -srgbtobt709, -bt709tosrgb: fix bug; incorrect output.
+              Always broken (These options were new in Netpbm 10.32 (February
+              2006)).
+
               pamdice: Fix incorrect output file name with PAM input.  Always
               broken (pamdice was new in Netpbm 9.25 (March 2002).
 
diff --git a/editor/pnmgamma.c b/editor/pnmgamma.c
index 1fdf20eb..e10e138b 100644
--- a/editor/pnmgamma.c
+++ b/editor/pnmgamma.c
@@ -516,7 +516,7 @@ buildBt709ToSrgbGamma(xelval       table[],
         if (radiance < linearCutoffSrgb * normalizer)
             srgb = radiance * linearExpansionSrgb;
         else
-            srgb = 1.055 * pow(normalized, oneOverGammaSrgb) - 0.055;
+            srgb = 1.055 * pow(radiance, oneOverGammaSrgb) - 0.055;
 
         assert(srgb <= 1.0);
 
@@ -567,14 +567,14 @@ buildSrgbToBt709Gamma(xelval       table[],
         if (i < linearCutoffSrgb / linearCompressionSrgb)
             radiance = normalized * linearCompressionSrgb;
         else
-            radiance = pow((normalized + 0.099) / 1.099, gammaSrgb);
+            radiance = pow((normalized + 0.055) / 1.055, gammaSrgb);
 
         assert(radiance <= 1.0);
 
         if (radiance < linearCutoff709 * normalizer)
             bt709 = radiance * linearExpansion709;
         else
-            bt709 = 1.055 * pow(normalized, oneOverGamma709) - 0.055;
+            bt709 = 1.099 * pow(radiance, oneOverGamma709) - 0.099;
 
         assert(bt709 <= 1.0);