Coverage Report

Created: 2025-06-22 08:04

/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 "lib/jxl/cms/opsin_params.h"
9
10
#define INVERSE_OPSIN_FROM_SPEC 1
11
12
#include "lib/jxl/base/matrix_ops.h"
13
14
namespace jxl {
15
16
0
const Matrix3x3& GetOpsinAbsorbanceInverseMatrix() {
17
0
#if INVERSE_OPSIN_FROM_SPEC
18
0
  return jxl::cms::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 Matrix3x3 const kInverse = [] {
24
    static Matrix3x3 inverse = kOpsinAbsorbanceMatrix;
25
    Inv3x3Matrix(inverse);
26
    return inverse;
27
  }();
28
  return kInverse;
29
#endif  // INVERSE_OPSIN_FROM_SPEC
30
0
}
31
32
void InitSIMDInverseMatrix(const Matrix3x3& inverse,
33
                           float* JXL_RESTRICT simd_inverse,
34
19.4k
                           float intensity_target) {
35
77.9k
  for (size_t j = 0; j < 3; ++j) {
36
233k
    for (size_t i = 0; i < 3; ++i) {
37
175k
      size_t idx = (j * 3 + i) * 4;
38
175k
      simd_inverse[idx] = simd_inverse[idx + 1] = simd_inverse[idx + 2] =
39
175k
          simd_inverse[idx + 3] = inverse[j][i] * (255.0f / intensity_target);
40
175k
    }
41
58.4k
  }
42
19.4k
}
43
44
}  // namespace jxl