Skip to content

Commit

Permalink
TF_SRGB: use HWY_REP4 (#3587)
Browse files Browse the repository at this point in the history
  • Loading branch information
sboukortt committed May 15, 2024
1 parent 715b442 commit 64b12f0
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions lib/jxl/cms/transfer_functions-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,20 +199,14 @@ class TF_SRGB {
// TODO(janwas): range reduction
// Computed via af_cheb_rational (k=100); replicated 4x.
HWY_ALIGN constexpr float p[(4 + 1) * 4] = {
2.200248328e-04f, 2.200248328e-04f, 2.200248328e-04f, 2.200248328e-04f,
1.043637593e-02f, 1.043637593e-02f, 1.043637593e-02f, 1.043637593e-02f,
1.624820318e-01f, 1.624820318e-01f, 1.624820318e-01f, 1.624820318e-01f,
7.961564959e-01f, 7.961564959e-01f, 7.961564959e-01f, 7.961564959e-01f,
8.210152774e-01f, 8.210152774e-01f, 8.210152774e-01f, 8.210152774e-01f,
HWY_REP4(2.200248328e-04f), HWY_REP4(1.043637593e-02f),
HWY_REP4(1.624820318e-01f), HWY_REP4(7.961564959e-01f),
HWY_REP4(8.210152774e-01f),
};
HWY_ALIGN constexpr float q[(4 + 1) * 4] = {
2.631846970e-01f, 2.631846970e-01f, 2.631846970e-01f,
2.631846970e-01f, 1.076976492e+00f, 1.076976492e+00f,
1.076976492e+00f, 1.076976492e+00f, 4.987528350e-01f,
4.987528350e-01f, 4.987528350e-01f, 4.987528350e-01f,
-5.512498495e-02f, -5.512498495e-02f, -5.512498495e-02f,
-5.512498495e-02f, 6.521209011e-03f, 6.521209011e-03f,
6.521209011e-03f, 6.521209011e-03f,
HWY_REP4(2.631846970e-01f), HWY_REP4(1.076976492e+00f),
HWY_REP4(4.987528350e-01f), HWY_REP4(-5.512498495e-02f),
HWY_REP4(6.521209011e-03f),
};
const V linear = Mul(x, Set(d, kLowDivInv));
const V poly = EvalRationalPolynomial(d, x, p, q);
Expand All @@ -231,20 +225,14 @@ class TF_SRGB {

// Computed via af_cheb_rational (k=100); replicated 4x.
HWY_ALIGN constexpr float p[(4 + 1) * 4] = {
-5.135152395e-04f, -5.135152395e-04f, -5.135152395e-04f,
-5.135152395e-04f, 5.287254571e-03f, 5.287254571e-03f,
5.287254571e-03f, 5.287254571e-03f, 3.903842876e-01f,
3.903842876e-01f, 3.903842876e-01f, 3.903842876e-01f,
1.474205315e+00f, 1.474205315e+00f, 1.474205315e+00f,
1.474205315e+00f, 7.352629620e-01f, 7.352629620e-01f,
7.352629620e-01f, 7.352629620e-01f,
HWY_REP4(-5.135152395e-04f), HWY_REP4(5.287254571e-03f),
HWY_REP4(3.903842876e-01f), HWY_REP4(1.474205315e+00f),
HWY_REP4(7.352629620e-01f),
};
HWY_ALIGN constexpr float q[(4 + 1) * 4] = {
1.004519624e-02f, 1.004519624e-02f, 1.004519624e-02f, 1.004519624e-02f,
3.036675394e-01f, 3.036675394e-01f, 3.036675394e-01f, 3.036675394e-01f,
1.340816930e+00f, 1.340816930e+00f, 1.340816930e+00f, 1.340816930e+00f,
9.258482155e-01f, 9.258482155e-01f, 9.258482155e-01f, 9.258482155e-01f,
2.424867759e-02f, 2.424867759e-02f, 2.424867759e-02f, 2.424867759e-02f,
HWY_REP4(1.004519624e-02f), HWY_REP4(3.036675394e-01f),
HWY_REP4(1.340816930e+00f), HWY_REP4(9.258482155e-01f),
HWY_REP4(2.424867759e-02f),
};
const V linear = Mul(x, Set(d, kLowDiv));
const V poly = EvalRationalPolynomial(d, Sqrt(x), p, q);
Expand Down

0 comments on commit 64b12f0

Please sign in to comment.