Coverage Report

Created: 2025-06-16 07:00

/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 <cstddef>
9
10
#include "lib/jxl/base/compiler_specific.h"
11
#include "lib/jxl/cms/opsin_params.h"
12
13
#define INVERSE_OPSIN_FROM_SPEC 1
14
15
#include "lib/jxl/base/matrix_ops.h"
16
17
namespace jxl {
18
19
0
const Matrix3x3& GetOpsinAbsorbanceInverseMatrix() {
20
0
#if INVERSE_OPSIN_FROM_SPEC
21
0
  return jxl::cms::DefaultInverseOpsinAbsorbanceMatrix();
22
#else   // INVERSE_OPSIN_FROM_SPEC
23
  // Compute the inverse opsin matrix from the forward matrix. Less precise
24
  // than taking the values from the specification, but must be used if the
25
  // forward transform is changed and the spec will require updating.
26
  static const Matrix3x3 const kInverse = [] {
27
    static Matrix3x3 inverse = kOpsinAbsorbanceMatrix;
28
    Inv3x3Matrix(inverse);
29
    return inverse;
30
  }();
31
  return kInverse;
32
#endif  // INVERSE_OPSIN_FROM_SPEC
33
0
}
34
35
void InitSIMDInverseMatrix(const Matrix3x3& inverse,
36
                           float* JXL_RESTRICT simd_inverse,
37
9.65k
                           float intensity_target) {
38
38.6k
  for (size_t j = 0; j < 3; ++j) {
39
115k
    for (size_t i = 0; i < 3; ++i) {
40
86.8k
      size_t idx = (j * 3 + i) * 4;
41
86.8k
      simd_inverse[idx] = simd_inverse[idx + 1] = simd_inverse[idx + 2] =
42
86.8k
          simd_inverse[idx + 3] = inverse[j][i] * (255.0f / intensity_target);
43
86.8k
    }
44
28.9k
  }
45
9.65k
}
46
47
}  // namespace jxl