flip R,G,a for HLG

R, G, and a currently kind of make most sense if you're
looking at the inverse HLG transfer function, but that's
no longer part of our API.  Might as well flip things so
that the one function we do expose is straightforward.

No math really changes here.

For real, this is it as far as PQ/HLG goes.

Bug: chromium:960620
Change-Id: Ia69168e4d3b137ba4d37cf09c714d82dde4ddf92
Reviewed-on: https://skia-review.googlesource.com/c/skcms/+/248550
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
diff --git a/skcms.cc b/skcms.cc
index 3873d6e..bace176 100644
--- a/skcms.cc
+++ b/skcms.cc
@@ -171,8 +171,7 @@
 bool skcms_TransferFunction_makeHLGish(skcms_TransferFunction* tf,
                                        float R, float G,
                                        float a, float b, float c) {
-    // The math for HLGish transfer functions is faster if we precompute 1/R, 1/G, 1/a.
-    *tf = { TFKind_marker(HLGish), 1.0f/R,1.0f/G, 1.0f/a,b,c, 0 };
+    *tf = { TFKind_marker(HLGish), R,G, a,b,c, 0 };
     assert(classify(*tf) == HLGish);
     return true;
 }
@@ -186,12 +185,10 @@
     switch (classify(*tf, &pq, &hlg)) {
         case Bad:       break;
 
-        // Remember that hlg.R, hlg.G, and hlg.a are holding each value's reciprocal,
-        // so the math may look a bit funny...
         case HLGish:    return sign * (x*hlg.R <= 1 ? powf_(x*hlg.R, hlg.G)
                                                     : expf_((x-hlg.c)*hlg.a) + hlg.b);
 
-        // Here all the hlg fields mean what they look like, R,G,a,b,c.
+        // skcms_TransferFunction_invert() inverts R, G, and a for HLGinvish so this math is fast.
         case HLGinvish: return sign * (x <= 1 ? hlg.R * powf_(x, hlg.G)
                                               : hlg.a * logf_(x - hlg.b) + hlg.c);
 
diff --git a/skcms.h b/skcms.h
index b73eeb3..f458784 100644
--- a/skcms.h
+++ b/skcms.h
@@ -62,8 +62,8 @@
                                                 float A, float B, float C,
                                                 float D, float E, float F);
 // HLGish:
-//            { sign(encoded) * ( (|encoded|/R)^(1/G) )        when 0 <= |encoded| <= R
-//   linear = { sign(encoded) * ( e^( (|encoded|-c)/a ) + b )  when R <  |encoded|
+//            { sign(encoded) * ( (R|encoded|)^G )          when 0   <= |encoded| <= 1/R
+//   linear = { sign(encoded) * ( e^(a(|encoded|-c)) + b )  when 1/R <  |encoded|
 SKCMS_API bool skcms_TransferFunction_makeHLGish(skcms_TransferFunction*,
                                                 float R, float G,
                                                 float a, float b, float c);
@@ -75,8 +75,8 @@
 }
 // HLG mapping encoded [0,1] to linear [0,12].
 static inline bool skcms_TransferFunction_makeHLG(skcms_TransferFunction* tf) {
-    return skcms_TransferFunction_makeHLGish(tf, 0.5f, 0.5f
-                                               , 0.17883277f, 0.28466892f, 0.55991073f);
+    return skcms_TransferFunction_makeHLGish(tf, 2.0f, 2.0f
+                                               , 1/0.17883277f, 0.28466892f, 0.55991073f);
 }
 
 // Unified representation of 'curv' or 'para' tag data, or a 1D table from 'mft1' or 'mft2'