tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

opsin_params.cc (1409B)


      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 const Matrix3x3& GetOpsinAbsorbanceInverseMatrix() {
     17 #if INVERSE_OPSIN_FROM_SPEC
     18  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 }
     31 
     32 void InitSIMDInverseMatrix(const Matrix3x3& inverse,
     33                           float* JXL_RESTRICT simd_inverse,
     34                           float intensity_target) {
     35  for (size_t j = 0; j < 3; ++j) {
     36    for (size_t i = 0; i < 3; ++i) {
     37      size_t idx = (j * 3 + i) * 4;
     38      simd_inverse[idx] = simd_inverse[idx + 1] = simd_inverse[idx + 2] =
     39          simd_inverse[idx + 3] = inverse[j][i] * (255.0f / intensity_target);
     40    }
     41  }
     42 }
     43 
     44 }  // namespace jxl