/src/libjxl/lib/jxl/opsin_params.cc
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) the JPEG XL Project Authors. All rights reserved. |
2 | | // |
3 | | // Use of this source code is governed by a BSD-style |
4 | | // license that can be found in the LICENSE file. |
5 | | |
6 | | #include "lib/jxl/opsin_params.h" |
7 | | |
8 | | #include <stdlib.h> |
9 | | |
10 | | #include "lib/jxl/linalg.h" |
11 | | |
12 | | namespace jxl { |
13 | | |
14 | | #define INVERSE_OPSIN_FROM_SPEC 1 |
15 | | |
16 | 0 | const float* GetOpsinAbsorbanceInverseMatrix() { |
17 | 0 | #if INVERSE_OPSIN_FROM_SPEC |
18 | 0 | return DefaultInverseOpsinAbsorbanceMatrix(); |
19 | | #else // INVERSE_OPSIN_FROM_SPEC |
20 | | // Compute the inverse opsin matrix from the forward matrix. Less precise |
21 | | // than taking the values from the specification, but must be used if the |
22 | | // forward transform is changed and the spec will require updating. |
23 | | static const float* const kInverse = [] { |
24 | | static float inverse[9]; |
25 | | for (int i = 0; i < 9; i++) { |
26 | | inverse[i] = kOpsinAbsorbanceMatrix[i]; |
27 | | } |
28 | | Inv3x3Matrix(inverse); |
29 | | return inverse; |
30 | | }(); |
31 | | return kInverse; |
32 | | #endif // INVERSE_OPSIN_FROM_SPEC |
33 | 0 | } |
34 | | |
35 | | void InitSIMDInverseMatrix(const float* JXL_RESTRICT inverse, |
36 | | float* JXL_RESTRICT simd_inverse, |
37 | 0 | float intensity_target) { |
38 | 0 | for (size_t i = 0; i < 9; ++i) { |
39 | 0 | simd_inverse[4 * i] = simd_inverse[4 * i + 1] = simd_inverse[4 * i + 2] = |
40 | 0 | simd_inverse[4 * i + 3] = inverse[i] * (255.0f / intensity_target); |
41 | 0 | } |
42 | 0 | } |
43 | | |
44 | | } // namespace jxl |