Coverage Report

Created: 2025-07-23 08:18

/src/libjxl/lib/jxl/compressed_dc.cc
Line
Count
Source
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/compressed_dc.h"
7
8
#include <jxl/memory_manager.h>
9
10
#include <algorithm>
11
#include <cstdint>
12
#include <cstdlib>
13
#include <cstring>
14
#include <vector>
15
16
#include "lib/jxl/ac_context.h"
17
#include "lib/jxl/frame_header.h"
18
#include "lib/jxl/modular/modular_image.h"
19
20
#undef HWY_TARGET_INCLUDE
21
#define HWY_TARGET_INCLUDE "lib/jxl/compressed_dc.cc"
22
#include <hwy/foreach_target.h>
23
#include <hwy/highway.h>
24
25
#include "lib/jxl/base/compiler_specific.h"
26
#include "lib/jxl/base/data_parallel.h"
27
#include "lib/jxl/base/rect.h"
28
#include "lib/jxl/base/status.h"
29
#include "lib/jxl/image.h"
30
HWY_BEFORE_NAMESPACE();
31
namespace jxl {
32
namespace HWY_NAMESPACE {
33
34
using D = HWY_FULL(float);
35
using DScalar = HWY_CAPPED(float, 1);
36
37
// These templates are not found via ADL.
38
using hwy::HWY_NAMESPACE::Abs;
39
using hwy::HWY_NAMESPACE::Add;
40
using hwy::HWY_NAMESPACE::Div;
41
using hwy::HWY_NAMESPACE::Max;
42
using hwy::HWY_NAMESPACE::Mul;
43
using hwy::HWY_NAMESPACE::MulAdd;
44
using hwy::HWY_NAMESPACE::Rebind;
45
using hwy::HWY_NAMESPACE::Sub;
46
using hwy::HWY_NAMESPACE::Vec;
47
using hwy::HWY_NAMESPACE::ZeroIfNegative;
48
49
// TODO(veluca): optimize constants.
50
const float w1 = 0.20345139757231578f;
51
const float w2 = 0.0334829185968739f;
52
const float w0 = 1.0f - 4.0f * (w1 + w2);
53
54
template <class V>
55
2.77M
V MaxWorkaround(V a, V b) {
56
#if (HWY_TARGET == HWY_AVX3) && HWY_COMPILER_CLANG <= 800
57
  // Prevents "Do not know how to split the result of this operator" error
58
  return IfThenElse(a > b, a, b);
59
#else
60
2.77M
  return Max(a, b);
61
2.77M
#endif
62
2.77M
}
Unexecuted instantiation: hwy::N_SSE4::Vec128<float, 1ul> jxl::N_SSE4::MaxWorkaround<hwy::N_SSE4::Vec128<float, 1ul> >(hwy::N_SSE4::Vec128<float, 1ul>, hwy::N_SSE4::Vec128<float, 1ul>)
Unexecuted instantiation: hwy::N_SSE4::Vec128<float, 4ul> jxl::N_SSE4::MaxWorkaround<hwy::N_SSE4::Vec128<float, 4ul> >(hwy::N_SSE4::Vec128<float, 4ul>, hwy::N_SSE4::Vec128<float, 4ul>)
hwy::N_AVX2::Vec128<float, 1ul> jxl::N_AVX2::MaxWorkaround<hwy::N_AVX2::Vec128<float, 1ul> >(hwy::N_AVX2::Vec128<float, 1ul>, hwy::N_AVX2::Vec128<float, 1ul>)
Line
Count
Source
55
1.95M
V MaxWorkaround(V a, V b) {
56
#if (HWY_TARGET == HWY_AVX3) && HWY_COMPILER_CLANG <= 800
57
  // Prevents "Do not know how to split the result of this operator" error
58
  return IfThenElse(a > b, a, b);
59
#else
60
1.95M
  return Max(a, b);
61
1.95M
#endif
62
1.95M
}
hwy::N_AVX2::Vec256<float> jxl::N_AVX2::MaxWorkaround<hwy::N_AVX2::Vec256<float> >(hwy::N_AVX2::Vec256<float>, hwy::N_AVX2::Vec256<float>)
Line
Count
Source
55
817k
V MaxWorkaround(V a, V b) {
56
#if (HWY_TARGET == HWY_AVX3) && HWY_COMPILER_CLANG <= 800
57
  // Prevents "Do not know how to split the result of this operator" error
58
  return IfThenElse(a > b, a, b);
59
#else
60
817k
  return Max(a, b);
61
817k
#endif
62
817k
}
Unexecuted instantiation: hwy::N_AVX3::Vec128<float, 1ul> jxl::N_AVX3::MaxWorkaround<hwy::N_AVX3::Vec128<float, 1ul> >(hwy::N_AVX3::Vec128<float, 1ul>, hwy::N_AVX3::Vec128<float, 1ul>)
Unexecuted instantiation: hwy::N_AVX3::Vec512<float> jxl::N_AVX3::MaxWorkaround<hwy::N_AVX3::Vec512<float> >(hwy::N_AVX3::Vec512<float>, hwy::N_AVX3::Vec512<float>)
Unexecuted instantiation: hwy::N_AVX3_ZEN4::Vec128<float, 1ul> jxl::N_AVX3_ZEN4::MaxWorkaround<hwy::N_AVX3_ZEN4::Vec128<float, 1ul> >(hwy::N_AVX3_ZEN4::Vec128<float, 1ul>, hwy::N_AVX3_ZEN4::Vec128<float, 1ul>)
Unexecuted instantiation: hwy::N_AVX3_ZEN4::Vec512<float> jxl::N_AVX3_ZEN4::MaxWorkaround<hwy::N_AVX3_ZEN4::Vec512<float> >(hwy::N_AVX3_ZEN4::Vec512<float>, hwy::N_AVX3_ZEN4::Vec512<float>)
Unexecuted instantiation: hwy::N_AVX3_SPR::Vec128<float, 1ul> jxl::N_AVX3_SPR::MaxWorkaround<hwy::N_AVX3_SPR::Vec128<float, 1ul> >(hwy::N_AVX3_SPR::Vec128<float, 1ul>, hwy::N_AVX3_SPR::Vec128<float, 1ul>)
Unexecuted instantiation: hwy::N_AVX3_SPR::Vec512<float> jxl::N_AVX3_SPR::MaxWorkaround<hwy::N_AVX3_SPR::Vec512<float> >(hwy::N_AVX3_SPR::Vec512<float>, hwy::N_AVX3_SPR::Vec512<float>)
Unexecuted instantiation: hwy::N_SSE2::Vec128<float, 1ul> jxl::N_SSE2::MaxWorkaround<hwy::N_SSE2::Vec128<float, 1ul> >(hwy::N_SSE2::Vec128<float, 1ul>, hwy::N_SSE2::Vec128<float, 1ul>)
Unexecuted instantiation: hwy::N_SSE2::Vec128<float, 4ul> jxl::N_SSE2::MaxWorkaround<hwy::N_SSE2::Vec128<float, 4ul> >(hwy::N_SSE2::Vec128<float, 4ul>, hwy::N_SSE2::Vec128<float, 4ul>)
63
64
template <typename D>
65
JXL_INLINE void ComputePixelChannel(const D d, const float dc_factor,
66
                                    const float* JXL_RESTRICT row_top,
67
                                    const float* JXL_RESTRICT row,
68
                                    const float* JXL_RESTRICT row_bottom,
69
                                    Vec<D>* JXL_RESTRICT mc,
70
                                    Vec<D>* JXL_RESTRICT sm,
71
2.77M
                                    Vec<D>* JXL_RESTRICT gap, size_t x) {
72
2.77M
  const auto tl = LoadU(d, row_top + x - 1);
73
2.77M
  const auto tc = Load(d, row_top + x);
74
2.77M
  const auto tr = LoadU(d, row_top + x + 1);
75
76
2.77M
  const auto ml = LoadU(d, row + x - 1);
77
2.77M
  *mc = Load(d, row + x);
78
2.77M
  const auto mr = LoadU(d, row + x + 1);
79
80
2.77M
  const auto bl = LoadU(d, row_bottom + x - 1);
81
2.77M
  const auto bc = Load(d, row_bottom + x);
82
2.77M
  const auto br = LoadU(d, row_bottom + x + 1);
83
84
2.77M
  const auto w_center = Set(d, w0);
85
2.77M
  const auto w_side = Set(d, w1);
86
2.77M
  const auto w_corner = Set(d, w2);
87
88
2.77M
  const auto corner = Add(Add(tl, tr), Add(bl, br));
89
2.77M
  const auto side = Add(Add(ml, mr), Add(tc, bc));
90
2.77M
  *sm = MulAdd(corner, w_corner, MulAdd(side, w_side, Mul(*mc, w_center)));
91
92
2.77M
  const auto dc_quant = Set(d, dc_factor);
93
2.77M
  *gap = MaxWorkaround(*gap, Abs(Div(Sub(*mc, *sm), dc_quant)));
94
2.77M
}
Unexecuted instantiation: void jxl::N_SSE4::ComputePixelChannel<hwy::N_SSE4::Simd<float, 1ul, 0> >(hwy::N_SSE4::Simd<float, 1ul, 0>, float, float const*, float const*, float const*, decltype (Zero((hwy::N_SSE4::Simd<float, 1ul, 0>)()))*, decltype (Zero((hwy::N_SSE4::Simd<float, 1ul, 0>)()))*, decltype (Zero((hwy::N_SSE4::Simd<float, 1ul, 0>)()))*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE4::ComputePixelChannel<hwy::N_SSE4::Simd<float, 4ul, 0> >(hwy::N_SSE4::Simd<float, 4ul, 0>, float, float const*, float const*, float const*, decltype (Zero((hwy::N_SSE4::Simd<float, 4ul, 0>)()))*, decltype (Zero((hwy::N_SSE4::Simd<float, 4ul, 0>)()))*, decltype (Zero((hwy::N_SSE4::Simd<float, 4ul, 0>)()))*, unsigned long)
void jxl::N_AVX2::ComputePixelChannel<hwy::N_AVX2::Simd<float, 1ul, 0> >(hwy::N_AVX2::Simd<float, 1ul, 0>, float, float const*, float const*, float const*, decltype (Zero((hwy::N_AVX2::Simd<float, 1ul, 0>)()))*, decltype (Zero((hwy::N_AVX2::Simd<float, 1ul, 0>)()))*, decltype (Zero((hwy::N_AVX2::Simd<float, 1ul, 0>)()))*, unsigned long)
Line
Count
Source
71
1.95M
                                    Vec<D>* JXL_RESTRICT gap, size_t x) {
72
1.95M
  const auto tl = LoadU(d, row_top + x - 1);
73
1.95M
  const auto tc = Load(d, row_top + x);
74
1.95M
  const auto tr = LoadU(d, row_top + x + 1);
75
76
1.95M
  const auto ml = LoadU(d, row + x - 1);
77
1.95M
  *mc = Load(d, row + x);
78
1.95M
  const auto mr = LoadU(d, row + x + 1);
79
80
1.95M
  const auto bl = LoadU(d, row_bottom + x - 1);
81
1.95M
  const auto bc = Load(d, row_bottom + x);
82
1.95M
  const auto br = LoadU(d, row_bottom + x + 1);
83
84
1.95M
  const auto w_center = Set(d, w0);
85
1.95M
  const auto w_side = Set(d, w1);
86
1.95M
  const auto w_corner = Set(d, w2);
87
88
1.95M
  const auto corner = Add(Add(tl, tr), Add(bl, br));
89
1.95M
  const auto side = Add(Add(ml, mr), Add(tc, bc));
90
1.95M
  *sm = MulAdd(corner, w_corner, MulAdd(side, w_side, Mul(*mc, w_center)));
91
92
1.95M
  const auto dc_quant = Set(d, dc_factor);
93
1.95M
  *gap = MaxWorkaround(*gap, Abs(Div(Sub(*mc, *sm), dc_quant)));
94
1.95M
}
void jxl::N_AVX2::ComputePixelChannel<hwy::N_AVX2::Simd<float, 8ul, 0> >(hwy::N_AVX2::Simd<float, 8ul, 0>, float, float const*, float const*, float const*, decltype (Zero((hwy::N_AVX2::Simd<float, 8ul, 0>)()))*, decltype (Zero((hwy::N_AVX2::Simd<float, 8ul, 0>)()))*, decltype (Zero((hwy::N_AVX2::Simd<float, 8ul, 0>)()))*, unsigned long)
Line
Count
Source
71
817k
                                    Vec<D>* JXL_RESTRICT gap, size_t x) {
72
817k
  const auto tl = LoadU(d, row_top + x - 1);
73
817k
  const auto tc = Load(d, row_top + x);
74
817k
  const auto tr = LoadU(d, row_top + x + 1);
75
76
817k
  const auto ml = LoadU(d, row + x - 1);
77
817k
  *mc = Load(d, row + x);
78
817k
  const auto mr = LoadU(d, row + x + 1);
79
80
817k
  const auto bl = LoadU(d, row_bottom + x - 1);
81
817k
  const auto bc = Load(d, row_bottom + x);
82
817k
  const auto br = LoadU(d, row_bottom + x + 1);
83
84
817k
  const auto w_center = Set(d, w0);
85
817k
  const auto w_side = Set(d, w1);
86
817k
  const auto w_corner = Set(d, w2);
87
88
817k
  const auto corner = Add(Add(tl, tr), Add(bl, br));
89
817k
  const auto side = Add(Add(ml, mr), Add(tc, bc));
90
817k
  *sm = MulAdd(corner, w_corner, MulAdd(side, w_side, Mul(*mc, w_center)));
91
92
817k
  const auto dc_quant = Set(d, dc_factor);
93
817k
  *gap = MaxWorkaround(*gap, Abs(Div(Sub(*mc, *sm), dc_quant)));
94
817k
}
Unexecuted instantiation: void jxl::N_AVX3::ComputePixelChannel<hwy::N_AVX3::Simd<float, 1ul, 0> >(hwy::N_AVX3::Simd<float, 1ul, 0>, float, float const*, float const*, float const*, decltype (Zero((hwy::N_AVX3::Simd<float, 1ul, 0>)()))*, decltype (Zero((hwy::N_AVX3::Simd<float, 1ul, 0>)()))*, decltype (Zero((hwy::N_AVX3::Simd<float, 1ul, 0>)()))*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::ComputePixelChannel<hwy::N_AVX3::Simd<float, 16ul, 0> >(hwy::N_AVX3::Simd<float, 16ul, 0>, float, float const*, float const*, float const*, decltype (Zero((hwy::N_AVX3::Simd<float, 16ul, 0>)()))*, decltype (Zero((hwy::N_AVX3::Simd<float, 16ul, 0>)()))*, decltype (Zero((hwy::N_AVX3::Simd<float, 16ul, 0>)()))*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::ComputePixelChannel<hwy::N_AVX3_ZEN4::Simd<float, 1ul, 0> >(hwy::N_AVX3_ZEN4::Simd<float, 1ul, 0>, float, float const*, float const*, float const*, decltype (Zero((hwy::N_AVX3_ZEN4::Simd<float, 1ul, 0>)()))*, decltype (Zero((hwy::N_AVX3_ZEN4::Simd<float, 1ul, 0>)()))*, decltype (Zero((hwy::N_AVX3_ZEN4::Simd<float, 1ul, 0>)()))*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::ComputePixelChannel<hwy::N_AVX3_ZEN4::Simd<float, 16ul, 0> >(hwy::N_AVX3_ZEN4::Simd<float, 16ul, 0>, float, float const*, float const*, float const*, decltype (Zero((hwy::N_AVX3_ZEN4::Simd<float, 16ul, 0>)()))*, decltype (Zero((hwy::N_AVX3_ZEN4::Simd<float, 16ul, 0>)()))*, decltype (Zero((hwy::N_AVX3_ZEN4::Simd<float, 16ul, 0>)()))*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::ComputePixelChannel<hwy::N_AVX3_SPR::Simd<float, 1ul, 0> >(hwy::N_AVX3_SPR::Simd<float, 1ul, 0>, float, float const*, float const*, float const*, decltype (Zero((hwy::N_AVX3_SPR::Simd<float, 1ul, 0>)()))*, decltype (Zero((hwy::N_AVX3_SPR::Simd<float, 1ul, 0>)()))*, decltype (Zero((hwy::N_AVX3_SPR::Simd<float, 1ul, 0>)()))*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::ComputePixelChannel<hwy::N_AVX3_SPR::Simd<float, 16ul, 0> >(hwy::N_AVX3_SPR::Simd<float, 16ul, 0>, float, float const*, float const*, float const*, decltype (Zero((hwy::N_AVX3_SPR::Simd<float, 16ul, 0>)()))*, decltype (Zero((hwy::N_AVX3_SPR::Simd<float, 16ul, 0>)()))*, decltype (Zero((hwy::N_AVX3_SPR::Simd<float, 16ul, 0>)()))*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::ComputePixelChannel<hwy::N_SSE2::Simd<float, 1ul, 0> >(hwy::N_SSE2::Simd<float, 1ul, 0>, float, float const*, float const*, float const*, decltype (Zero((hwy::N_SSE2::Simd<float, 1ul, 0>)()))*, decltype (Zero((hwy::N_SSE2::Simd<float, 1ul, 0>)()))*, decltype (Zero((hwy::N_SSE2::Simd<float, 1ul, 0>)()))*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::ComputePixelChannel<hwy::N_SSE2::Simd<float, 4ul, 0> >(hwy::N_SSE2::Simd<float, 4ul, 0>, float, float const*, float const*, float const*, decltype (Zero((hwy::N_SSE2::Simd<float, 4ul, 0>)()))*, decltype (Zero((hwy::N_SSE2::Simd<float, 4ul, 0>)()))*, decltype (Zero((hwy::N_SSE2::Simd<float, 4ul, 0>)()))*, unsigned long)
95
96
template <typename D>
97
JXL_INLINE void ComputePixel(
98
    const float* JXL_RESTRICT dc_factors,
99
    const float* JXL_RESTRICT* JXL_RESTRICT rows_top,
100
    const float* JXL_RESTRICT* JXL_RESTRICT rows,
101
    const float* JXL_RESTRICT* JXL_RESTRICT rows_bottom,
102
925k
    float* JXL_RESTRICT* JXL_RESTRICT out_rows, size_t x) {
103
925k
  const D d;
104
925k
  auto mc_x = Undefined(d);
105
925k
  auto mc_y = Undefined(d);
106
925k
  auto mc_b = Undefined(d);
107
925k
  auto sm_x = Undefined(d);
108
925k
  auto sm_y = Undefined(d);
109
925k
  auto sm_b = Undefined(d);
110
925k
  auto gap = Set(d, 0.5f);
111
925k
  ComputePixelChannel(d, dc_factors[0], rows_top[0], rows[0], rows_bottom[0],
112
925k
                      &mc_x, &sm_x, &gap, x);
113
925k
  ComputePixelChannel(d, dc_factors[1], rows_top[1], rows[1], rows_bottom[1],
114
925k
                      &mc_y, &sm_y, &gap, x);
115
925k
  ComputePixelChannel(d, dc_factors[2], rows_top[2], rows[2], rows_bottom[2],
116
925k
                      &mc_b, &sm_b, &gap, x);
117
925k
  auto factor = MulAdd(Set(d, -4.0f), gap, Set(d, 3.0f));
118
925k
  factor = ZeroIfNegative(factor);
119
120
925k
  auto out = MulAdd(Sub(sm_x, mc_x), factor, mc_x);
121
925k
  Store(out, d, out_rows[0] + x);
122
925k
  out = MulAdd(Sub(sm_y, mc_y), factor, mc_y);
123
925k
  Store(out, d, out_rows[1] + x);
124
925k
  out = MulAdd(Sub(sm_b, mc_b), factor, mc_b);
125
925k
  Store(out, d, out_rows[2] + x);
126
925k
}
Unexecuted instantiation: void jxl::N_SSE4::ComputePixel<hwy::N_SSE4::Simd<float, 1ul, 0> >(float const*, float const* restrict*, float const* restrict*, float const* restrict*, float* restrict*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE4::ComputePixel<hwy::N_SSE4::Simd<float, 4ul, 0> >(float const*, float const* restrict*, float const* restrict*, float const* restrict*, float* restrict*, unsigned long)
void jxl::N_AVX2::ComputePixel<hwy::N_AVX2::Simd<float, 1ul, 0> >(float const*, float const* restrict*, float const* restrict*, float const* restrict*, float* restrict*, unsigned long)
Line
Count
Source
102
652k
    float* JXL_RESTRICT* JXL_RESTRICT out_rows, size_t x) {
103
652k
  const D d;
104
652k
  auto mc_x = Undefined(d);
105
652k
  auto mc_y = Undefined(d);
106
652k
  auto mc_b = Undefined(d);
107
652k
  auto sm_x = Undefined(d);
108
652k
  auto sm_y = Undefined(d);
109
652k
  auto sm_b = Undefined(d);
110
652k
  auto gap = Set(d, 0.5f);
111
652k
  ComputePixelChannel(d, dc_factors[0], rows_top[0], rows[0], rows_bottom[0],
112
652k
                      &mc_x, &sm_x, &gap, x);
113
652k
  ComputePixelChannel(d, dc_factors[1], rows_top[1], rows[1], rows_bottom[1],
114
652k
                      &mc_y, &sm_y, &gap, x);
115
652k
  ComputePixelChannel(d, dc_factors[2], rows_top[2], rows[2], rows_bottom[2],
116
652k
                      &mc_b, &sm_b, &gap, x);
117
652k
  auto factor = MulAdd(Set(d, -4.0f), gap, Set(d, 3.0f));
118
652k
  factor = ZeroIfNegative(factor);
119
120
652k
  auto out = MulAdd(Sub(sm_x, mc_x), factor, mc_x);
121
652k
  Store(out, d, out_rows[0] + x);
122
652k
  out = MulAdd(Sub(sm_y, mc_y), factor, mc_y);
123
652k
  Store(out, d, out_rows[1] + x);
124
652k
  out = MulAdd(Sub(sm_b, mc_b), factor, mc_b);
125
652k
  Store(out, d, out_rows[2] + x);
126
652k
}
void jxl::N_AVX2::ComputePixel<hwy::N_AVX2::Simd<float, 8ul, 0> >(float const*, float const* restrict*, float const* restrict*, float const* restrict*, float* restrict*, unsigned long)
Line
Count
Source
102
272k
    float* JXL_RESTRICT* JXL_RESTRICT out_rows, size_t x) {
103
272k
  const D d;
104
272k
  auto mc_x = Undefined(d);
105
272k
  auto mc_y = Undefined(d);
106
272k
  auto mc_b = Undefined(d);
107
272k
  auto sm_x = Undefined(d);
108
272k
  auto sm_y = Undefined(d);
109
272k
  auto sm_b = Undefined(d);
110
272k
  auto gap = Set(d, 0.5f);
111
272k
  ComputePixelChannel(d, dc_factors[0], rows_top[0], rows[0], rows_bottom[0],
112
272k
                      &mc_x, &sm_x, &gap, x);
113
272k
  ComputePixelChannel(d, dc_factors[1], rows_top[1], rows[1], rows_bottom[1],
114
272k
                      &mc_y, &sm_y, &gap, x);
115
272k
  ComputePixelChannel(d, dc_factors[2], rows_top[2], rows[2], rows_bottom[2],
116
272k
                      &mc_b, &sm_b, &gap, x);
117
272k
  auto factor = MulAdd(Set(d, -4.0f), gap, Set(d, 3.0f));
118
272k
  factor = ZeroIfNegative(factor);
119
120
272k
  auto out = MulAdd(Sub(sm_x, mc_x), factor, mc_x);
121
272k
  Store(out, d, out_rows[0] + x);
122
272k
  out = MulAdd(Sub(sm_y, mc_y), factor, mc_y);
123
272k
  Store(out, d, out_rows[1] + x);
124
272k
  out = MulAdd(Sub(sm_b, mc_b), factor, mc_b);
125
272k
  Store(out, d, out_rows[2] + x);
126
272k
}
Unexecuted instantiation: void jxl::N_AVX3::ComputePixel<hwy::N_AVX3::Simd<float, 1ul, 0> >(float const*, float const* restrict*, float const* restrict*, float const* restrict*, float* restrict*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::ComputePixel<hwy::N_AVX3::Simd<float, 16ul, 0> >(float const*, float const* restrict*, float const* restrict*, float const* restrict*, float* restrict*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::ComputePixel<hwy::N_AVX3_ZEN4::Simd<float, 1ul, 0> >(float const*, float const* restrict*, float const* restrict*, float const* restrict*, float* restrict*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::ComputePixel<hwy::N_AVX3_ZEN4::Simd<float, 16ul, 0> >(float const*, float const* restrict*, float const* restrict*, float const* restrict*, float* restrict*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::ComputePixel<hwy::N_AVX3_SPR::Simd<float, 1ul, 0> >(float const*, float const* restrict*, float const* restrict*, float const* restrict*, float* restrict*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::ComputePixel<hwy::N_AVX3_SPR::Simd<float, 16ul, 0> >(float const*, float const* restrict*, float const* restrict*, float const* restrict*, float* restrict*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::ComputePixel<hwy::N_SSE2::Simd<float, 1ul, 0> >(float const*, float const* restrict*, float const* restrict*, float const* restrict*, float* restrict*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::ComputePixel<hwy::N_SSE2::Simd<float, 4ul, 0> >(float const*, float const* restrict*, float const* restrict*, float const* restrict*, float* restrict*, unsigned long)
127
128
Status AdaptiveDCSmoothing(JxlMemoryManager* memory_manager,
129
                           const float* dc_factors, Image3F* dc,
130
3.66k
                           ThreadPool* pool) {
131
3.66k
  const size_t xsize = dc->xsize();
132
3.66k
  const size_t ysize = dc->ysize();
133
3.66k
  if (ysize <= 2 || xsize <= 2) return true;
134
135
  // TODO(veluca): use tile-based processing?
136
  // TODO(veluca): decide if changes to the y channel should be propagated to
137
  // the x and b channels through color correlation.
138
2.68k
  JXL_ENSURE(w1 + w2 < 0.25f);
139
140
5.36k
  JXL_ASSIGN_OR_RETURN(Image3F smoothed,
141
5.36k
                       Image3F::Create(memory_manager, xsize, ysize));
142
  // Fill in borders that the loop below will not. First and last are unused.
143
10.7k
  for (size_t c = 0; c < 3; c++) {
144
16.0k
    for (size_t y : {static_cast<size_t>(0), ysize - 1}) {
145
16.0k
      memcpy(smoothed.PlaneRow(c, y), dc->PlaneRow(c, y),
146
16.0k
             xsize * sizeof(float));
147
16.0k
    }
148
8.04k
  }
149
65.1k
  auto process_row = [&](const uint32_t y, size_t /*thread*/) -> Status {
150
65.1k
    const float* JXL_RESTRICT rows_top[3]{
151
65.1k
        dc->ConstPlaneRow(0, y - 1),
152
65.1k
        dc->ConstPlaneRow(1, y - 1),
153
65.1k
        dc->ConstPlaneRow(2, y - 1),
154
65.1k
    };
155
65.1k
    const float* JXL_RESTRICT rows[3] = {
156
65.1k
        dc->ConstPlaneRow(0, y),
157
65.1k
        dc->ConstPlaneRow(1, y),
158
65.1k
        dc->ConstPlaneRow(2, y),
159
65.1k
    };
160
65.1k
    const float* JXL_RESTRICT rows_bottom[3] = {
161
65.1k
        dc->ConstPlaneRow(0, y + 1),
162
65.1k
        dc->ConstPlaneRow(1, y + 1),
163
65.1k
        dc->ConstPlaneRow(2, y + 1),
164
65.1k
    };
165
65.1k
    float* JXL_RESTRICT rows_out[3] = {
166
65.1k
        smoothed.PlaneRow(0, y),
167
65.1k
        smoothed.PlaneRow(1, y),
168
65.1k
        smoothed.PlaneRow(2, y),
169
65.1k
    };
170
130k
    for (size_t x : {static_cast<size_t>(0), xsize - 1}) {
171
521k
      for (size_t c = 0; c < 3; c++) {
172
390k
        rows_out[c][x] = rows[c][x];
173
390k
      }
174
130k
    }
175
176
65.1k
    size_t x = 1;
177
    // First pixels
178
65.1k
    const size_t N = Lanes(D());
179
513k
    for (; x < std::min(N, xsize - 1); x++) {
180
448k
      ComputePixel<DScalar>(dc_factors, rows_top, rows, rows_bottom, rows_out,
181
448k
                            x);
182
448k
    }
183
    // Full vectors.
184
337k
    for (; x + N <= xsize - 1; x += N) {
185
272k
      ComputePixel<D>(dc_factors, rows_top, rows, rows_bottom, rows_out, x);
186
272k
    }
187
    // Last pixels.
188
269k
    for (; x < xsize - 1; x++) {
189
204k
      ComputePixel<DScalar>(dc_factors, rows_top, rows, rows_bottom, rows_out,
190
204k
                            x);
191
204k
    }
192
65.1k
    return true;
193
65.1k
  };
Unexecuted instantiation: compressed_dc.cc:jxl::N_SSE4::AdaptiveDCSmoothing(JxlMemoryManagerStruct*, float const*, jxl::Image3<float>*, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
compressed_dc.cc:jxl::N_AVX2::AdaptiveDCSmoothing(JxlMemoryManagerStruct*, float const*, jxl::Image3<float>*, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
Line
Count
Source
149
65.1k
  auto process_row = [&](const uint32_t y, size_t /*thread*/) -> Status {
150
65.1k
    const float* JXL_RESTRICT rows_top[3]{
151
65.1k
        dc->ConstPlaneRow(0, y - 1),
152
65.1k
        dc->ConstPlaneRow(1, y - 1),
153
65.1k
        dc->ConstPlaneRow(2, y - 1),
154
65.1k
    };
155
65.1k
    const float* JXL_RESTRICT rows[3] = {
156
65.1k
        dc->ConstPlaneRow(0, y),
157
65.1k
        dc->ConstPlaneRow(1, y),
158
65.1k
        dc->ConstPlaneRow(2, y),
159
65.1k
    };
160
65.1k
    const float* JXL_RESTRICT rows_bottom[3] = {
161
65.1k
        dc->ConstPlaneRow(0, y + 1),
162
65.1k
        dc->ConstPlaneRow(1, y + 1),
163
65.1k
        dc->ConstPlaneRow(2, y + 1),
164
65.1k
    };
165
65.1k
    float* JXL_RESTRICT rows_out[3] = {
166
65.1k
        smoothed.PlaneRow(0, y),
167
65.1k
        smoothed.PlaneRow(1, y),
168
65.1k
        smoothed.PlaneRow(2, y),
169
65.1k
    };
170
130k
    for (size_t x : {static_cast<size_t>(0), xsize - 1}) {
171
521k
      for (size_t c = 0; c < 3; c++) {
172
390k
        rows_out[c][x] = rows[c][x];
173
390k
      }
174
130k
    }
175
176
65.1k
    size_t x = 1;
177
    // First pixels
178
65.1k
    const size_t N = Lanes(D());
179
513k
    for (; x < std::min(N, xsize - 1); x++) {
180
448k
      ComputePixel<DScalar>(dc_factors, rows_top, rows, rows_bottom, rows_out,
181
448k
                            x);
182
448k
    }
183
    // Full vectors.
184
337k
    for (; x + N <= xsize - 1; x += N) {
185
272k
      ComputePixel<D>(dc_factors, rows_top, rows, rows_bottom, rows_out, x);
186
272k
    }
187
    // Last pixels.
188
269k
    for (; x < xsize - 1; x++) {
189
204k
      ComputePixel<DScalar>(dc_factors, rows_top, rows, rows_bottom, rows_out,
190
204k
                            x);
191
204k
    }
192
65.1k
    return true;
193
65.1k
  };
Unexecuted instantiation: compressed_dc.cc:jxl::N_AVX3::AdaptiveDCSmoothing(JxlMemoryManagerStruct*, float const*, jxl::Image3<float>*, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
Unexecuted instantiation: compressed_dc.cc:jxl::N_AVX3_ZEN4::AdaptiveDCSmoothing(JxlMemoryManagerStruct*, float const*, jxl::Image3<float>*, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
Unexecuted instantiation: compressed_dc.cc:jxl::N_AVX3_SPR::AdaptiveDCSmoothing(JxlMemoryManagerStruct*, float const*, jxl::Image3<float>*, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
Unexecuted instantiation: compressed_dc.cc:jxl::N_SSE2::AdaptiveDCSmoothing(JxlMemoryManagerStruct*, float const*, jxl::Image3<float>*, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
194
5.36k
  JXL_RETURN_IF_ERROR(RunOnPool(pool, 1, ysize - 1, ThreadPool::NoInit,
195
5.36k
                                process_row, "DCSmoothingRow"));
196
2.68k
  dc->Swap(smoothed);
197
2.68k
  return true;
198
5.36k
}
Unexecuted instantiation: jxl::N_SSE4::AdaptiveDCSmoothing(JxlMemoryManagerStruct*, float const*, jxl::Image3<float>*, jxl::ThreadPool*)
jxl::N_AVX2::AdaptiveDCSmoothing(JxlMemoryManagerStruct*, float const*, jxl::Image3<float>*, jxl::ThreadPool*)
Line
Count
Source
130
3.66k
                           ThreadPool* pool) {
131
3.66k
  const size_t xsize = dc->xsize();
132
3.66k
  const size_t ysize = dc->ysize();
133
3.66k
  if (ysize <= 2 || xsize <= 2) return true;
134
135
  // TODO(veluca): use tile-based processing?
136
  // TODO(veluca): decide if changes to the y channel should be propagated to
137
  // the x and b channels through color correlation.
138
2.68k
  JXL_ENSURE(w1 + w2 < 0.25f);
139
140
5.36k
  JXL_ASSIGN_OR_RETURN(Image3F smoothed,
141
5.36k
                       Image3F::Create(memory_manager, xsize, ysize));
142
  // Fill in borders that the loop below will not. First and last are unused.
143
10.7k
  for (size_t c = 0; c < 3; c++) {
144
16.0k
    for (size_t y : {static_cast<size_t>(0), ysize - 1}) {
145
16.0k
      memcpy(smoothed.PlaneRow(c, y), dc->PlaneRow(c, y),
146
16.0k
             xsize * sizeof(float));
147
16.0k
    }
148
8.04k
  }
149
5.36k
  auto process_row = [&](const uint32_t y, size_t /*thread*/) -> Status {
150
5.36k
    const float* JXL_RESTRICT rows_top[3]{
151
5.36k
        dc->ConstPlaneRow(0, y - 1),
152
5.36k
        dc->ConstPlaneRow(1, y - 1),
153
5.36k
        dc->ConstPlaneRow(2, y - 1),
154
5.36k
    };
155
5.36k
    const float* JXL_RESTRICT rows[3] = {
156
5.36k
        dc->ConstPlaneRow(0, y),
157
5.36k
        dc->ConstPlaneRow(1, y),
158
5.36k
        dc->ConstPlaneRow(2, y),
159
5.36k
    };
160
5.36k
    const float* JXL_RESTRICT rows_bottom[3] = {
161
5.36k
        dc->ConstPlaneRow(0, y + 1),
162
5.36k
        dc->ConstPlaneRow(1, y + 1),
163
5.36k
        dc->ConstPlaneRow(2, y + 1),
164
5.36k
    };
165
5.36k
    float* JXL_RESTRICT rows_out[3] = {
166
5.36k
        smoothed.PlaneRow(0, y),
167
5.36k
        smoothed.PlaneRow(1, y),
168
5.36k
        smoothed.PlaneRow(2, y),
169
5.36k
    };
170
5.36k
    for (size_t x : {static_cast<size_t>(0), xsize - 1}) {
171
5.36k
      for (size_t c = 0; c < 3; c++) {
172
5.36k
        rows_out[c][x] = rows[c][x];
173
5.36k
      }
174
5.36k
    }
175
176
5.36k
    size_t x = 1;
177
    // First pixels
178
5.36k
    const size_t N = Lanes(D());
179
5.36k
    for (; x < std::min(N, xsize - 1); x++) {
180
5.36k
      ComputePixel<DScalar>(dc_factors, rows_top, rows, rows_bottom, rows_out,
181
5.36k
                            x);
182
5.36k
    }
183
    // Full vectors.
184
5.36k
    for (; x + N <= xsize - 1; x += N) {
185
5.36k
      ComputePixel<D>(dc_factors, rows_top, rows, rows_bottom, rows_out, x);
186
5.36k
    }
187
    // Last pixels.
188
5.36k
    for (; x < xsize - 1; x++) {
189
5.36k
      ComputePixel<DScalar>(dc_factors, rows_top, rows, rows_bottom, rows_out,
190
5.36k
                            x);
191
5.36k
    }
192
5.36k
    return true;
193
5.36k
  };
194
5.36k
  JXL_RETURN_IF_ERROR(RunOnPool(pool, 1, ysize - 1, ThreadPool::NoInit,
195
5.36k
                                process_row, "DCSmoothingRow"));
196
2.68k
  dc->Swap(smoothed);
197
2.68k
  return true;
198
5.36k
}
Unexecuted instantiation: jxl::N_AVX3::AdaptiveDCSmoothing(JxlMemoryManagerStruct*, float const*, jxl::Image3<float>*, jxl::ThreadPool*)
Unexecuted instantiation: jxl::N_AVX3_ZEN4::AdaptiveDCSmoothing(JxlMemoryManagerStruct*, float const*, jxl::Image3<float>*, jxl::ThreadPool*)
Unexecuted instantiation: jxl::N_AVX3_SPR::AdaptiveDCSmoothing(JxlMemoryManagerStruct*, float const*, jxl::Image3<float>*, jxl::ThreadPool*)
Unexecuted instantiation: jxl::N_SSE2::AdaptiveDCSmoothing(JxlMemoryManagerStruct*, float const*, jxl::Image3<float>*, jxl::ThreadPool*)
199
200
// DC dequantization.
201
void DequantDC(const Rect& r, Image3F* dc, ImageB* quant_dc, const Image& in,
202
               const float* dc_factors, float mul, const float* cfl_factors,
203
               const YCbCrChromaSubsampling& chroma_subsampling,
204
4.93k
               const BlockCtxMap& bctx) {
205
4.93k
  const HWY_FULL(float) df;
206
4.93k
  const Rebind<pixel_type, HWY_FULL(float)> di;  // assumes pixel_type <= float
207
4.93k
  if (chroma_subsampling.Is444()) {
208
4.90k
    const auto fac_x = Set(df, dc_factors[0] * mul);
209
4.90k
    const auto fac_y = Set(df, dc_factors[1] * mul);
210
4.90k
    const auto fac_b = Set(df, dc_factors[2] * mul);
211
4.90k
    const auto cfl_fac_x = Set(df, cfl_factors[0]);
212
4.90k
    const auto cfl_fac_b = Set(df, cfl_factors[2]);
213
92.2k
    for (size_t y = 0; y < r.ysize(); y++) {
214
87.3k
      float* dec_row_x = r.PlaneRow(dc, 0, y);
215
87.3k
      float* dec_row_y = r.PlaneRow(dc, 1, y);
216
87.3k
      float* dec_row_b = r.PlaneRow(dc, 2, y);
217
87.3k
      const int32_t* quant_row_x = in.channel[1].plane.Row(y);
218
87.3k
      const int32_t* quant_row_y = in.channel[0].plane.Row(y);
219
87.3k
      const int32_t* quant_row_b = in.channel[2].plane.Row(y);
220
548k
      for (size_t x = 0; x < r.xsize(); x += Lanes(di)) {
221
460k
        const auto in_q_x = Load(di, quant_row_x + x);
222
460k
        const auto in_q_y = Load(di, quant_row_y + x);
223
460k
        const auto in_q_b = Load(di, quant_row_b + x);
224
460k
        const auto in_x = Mul(ConvertTo(df, in_q_x), fac_x);
225
460k
        const auto in_y = Mul(ConvertTo(df, in_q_y), fac_y);
226
460k
        const auto in_b = Mul(ConvertTo(df, in_q_b), fac_b);
227
460k
        Store(in_y, df, dec_row_y + x);
228
460k
        Store(MulAdd(in_y, cfl_fac_x, in_x), df, dec_row_x + x);
229
460k
        Store(MulAdd(in_y, cfl_fac_b, in_b), df, dec_row_b + x);
230
460k
      }
231
87.3k
    }
232
4.90k
  } else {
233
78
    for (size_t c : {1, 0, 2}) {
234
78
      Rect rect(r.x0() >> chroma_subsampling.HShift(c),
235
78
                r.y0() >> chroma_subsampling.VShift(c),
236
78
                r.xsize() >> chroma_subsampling.HShift(c),
237
78
                r.ysize() >> chroma_subsampling.VShift(c));
238
78
      const auto fac = Set(df, dc_factors[c] * mul);
239
78
      const Channel& ch = in.channel[c < 2 ? c ^ 1 : c];
240
369
      for (size_t y = 0; y < rect.ysize(); y++) {
241
291
        const int32_t* quant_row = ch.plane.Row(y);
242
291
        float* row = rect.PlaneRow(dc, c, y);
243
917
        for (size_t x = 0; x < rect.xsize(); x += Lanes(di)) {
244
626
          const auto in_q = Load(di, quant_row + x);
245
626
          const auto out = Mul(ConvertTo(df, in_q), fac);
246
626
          Store(out, df, row + x);
247
626
        }
248
291
      }
249
78
    }
250
26
  }
251
4.93k
  if (bctx.num_dc_ctxs <= 1) {
252
91.0k
    for (size_t y = 0; y < r.ysize(); y++) {
253
86.3k
      uint8_t* qdc_row = r.Row(quant_dc, y);
254
86.3k
      memset(qdc_row, 0, sizeof(*qdc_row) * r.xsize());
255
86.3k
    }
256
4.71k
  } else {
257
1.35k
    for (size_t y = 0; y < r.ysize(); y++) {
258
1.12k
      uint8_t* qdc_row_val = r.Row(quant_dc, y);
259
1.12k
      const int32_t* quant_row_x =
260
1.12k
          in.channel[1].plane.Row(y >> chroma_subsampling.VShift(0));
261
1.12k
      const int32_t* quant_row_y =
262
1.12k
          in.channel[0].plane.Row(y >> chroma_subsampling.VShift(1));
263
1.12k
      const int32_t* quant_row_b =
264
1.12k
          in.channel[2].plane.Row(y >> chroma_subsampling.VShift(2));
265
23.1k
      for (size_t x = 0; x < r.xsize(); x++) {
266
21.9k
        int bucket_x = 0;
267
21.9k
        int bucket_y = 0;
268
21.9k
        int bucket_b = 0;
269
79.2k
        for (int t : bctx.dc_thresholds[0]) {
270
79.2k
          if (quant_row_x[x >> chroma_subsampling.HShift(0)] > t) bucket_x++;
271
79.2k
        }
272
21.9k
        for (int t : bctx.dc_thresholds[1]) {
273
11.3k
          if (quant_row_y[x >> chroma_subsampling.HShift(1)] > t) bucket_y++;
274
11.3k
        }
275
21.9k
        for (int t : bctx.dc_thresholds[2]) {
276
11.2k
          if (quant_row_b[x >> chroma_subsampling.HShift(2)] > t) bucket_b++;
277
11.2k
        }
278
21.9k
        int bucket = bucket_x;
279
21.9k
        bucket *= bctx.dc_thresholds[2].size() + 1;
280
21.9k
        bucket += bucket_b;
281
21.9k
        bucket *= bctx.dc_thresholds[1].size() + 1;
282
21.9k
        bucket += bucket_y;
283
21.9k
        qdc_row_val[x] = bucket;
284
21.9k
      }
285
1.12k
    }
286
224
  }
287
4.93k
}
Unexecuted instantiation: jxl::N_SSE4::DequantDC(jxl::RectT<unsigned long> const&, jxl::Image3<float>*, jxl::Plane<unsigned char>*, jxl::Image const&, float const*, float, float const*, jxl::YCbCrChromaSubsampling const&, jxl::BlockCtxMap const&)
jxl::N_AVX2::DequantDC(jxl::RectT<unsigned long> const&, jxl::Image3<float>*, jxl::Plane<unsigned char>*, jxl::Image const&, float const*, float, float const*, jxl::YCbCrChromaSubsampling const&, jxl::BlockCtxMap const&)
Line
Count
Source
204
4.93k
               const BlockCtxMap& bctx) {
205
4.93k
  const HWY_FULL(float) df;
206
4.93k
  const Rebind<pixel_type, HWY_FULL(float)> di;  // assumes pixel_type <= float
207
4.93k
  if (chroma_subsampling.Is444()) {
208
4.90k
    const auto fac_x = Set(df, dc_factors[0] * mul);
209
4.90k
    const auto fac_y = Set(df, dc_factors[1] * mul);
210
4.90k
    const auto fac_b = Set(df, dc_factors[2] * mul);
211
4.90k
    const auto cfl_fac_x = Set(df, cfl_factors[0]);
212
4.90k
    const auto cfl_fac_b = Set(df, cfl_factors[2]);
213
92.2k
    for (size_t y = 0; y < r.ysize(); y++) {
214
87.3k
      float* dec_row_x = r.PlaneRow(dc, 0, y);
215
87.3k
      float* dec_row_y = r.PlaneRow(dc, 1, y);
216
87.3k
      float* dec_row_b = r.PlaneRow(dc, 2, y);
217
87.3k
      const int32_t* quant_row_x = in.channel[1].plane.Row(y);
218
87.3k
      const int32_t* quant_row_y = in.channel[0].plane.Row(y);
219
87.3k
      const int32_t* quant_row_b = in.channel[2].plane.Row(y);
220
548k
      for (size_t x = 0; x < r.xsize(); x += Lanes(di)) {
221
460k
        const auto in_q_x = Load(di, quant_row_x + x);
222
460k
        const auto in_q_y = Load(di, quant_row_y + x);
223
460k
        const auto in_q_b = Load(di, quant_row_b + x);
224
460k
        const auto in_x = Mul(ConvertTo(df, in_q_x), fac_x);
225
460k
        const auto in_y = Mul(ConvertTo(df, in_q_y), fac_y);
226
460k
        const auto in_b = Mul(ConvertTo(df, in_q_b), fac_b);
227
460k
        Store(in_y, df, dec_row_y + x);
228
460k
        Store(MulAdd(in_y, cfl_fac_x, in_x), df, dec_row_x + x);
229
460k
        Store(MulAdd(in_y, cfl_fac_b, in_b), df, dec_row_b + x);
230
460k
      }
231
87.3k
    }
232
4.90k
  } else {
233
78
    for (size_t c : {1, 0, 2}) {
234
78
      Rect rect(r.x0() >> chroma_subsampling.HShift(c),
235
78
                r.y0() >> chroma_subsampling.VShift(c),
236
78
                r.xsize() >> chroma_subsampling.HShift(c),
237
78
                r.ysize() >> chroma_subsampling.VShift(c));
238
78
      const auto fac = Set(df, dc_factors[c] * mul);
239
78
      const Channel& ch = in.channel[c < 2 ? c ^ 1 : c];
240
369
      for (size_t y = 0; y < rect.ysize(); y++) {
241
291
        const int32_t* quant_row = ch.plane.Row(y);
242
291
        float* row = rect.PlaneRow(dc, c, y);
243
917
        for (size_t x = 0; x < rect.xsize(); x += Lanes(di)) {
244
626
          const auto in_q = Load(di, quant_row + x);
245
626
          const auto out = Mul(ConvertTo(df, in_q), fac);
246
626
          Store(out, df, row + x);
247
626
        }
248
291
      }
249
78
    }
250
26
  }
251
4.93k
  if (bctx.num_dc_ctxs <= 1) {
252
91.0k
    for (size_t y = 0; y < r.ysize(); y++) {
253
86.3k
      uint8_t* qdc_row = r.Row(quant_dc, y);
254
86.3k
      memset(qdc_row, 0, sizeof(*qdc_row) * r.xsize());
255
86.3k
    }
256
4.71k
  } else {
257
1.35k
    for (size_t y = 0; y < r.ysize(); y++) {
258
1.12k
      uint8_t* qdc_row_val = r.Row(quant_dc, y);
259
1.12k
      const int32_t* quant_row_x =
260
1.12k
          in.channel[1].plane.Row(y >> chroma_subsampling.VShift(0));
261
1.12k
      const int32_t* quant_row_y =
262
1.12k
          in.channel[0].plane.Row(y >> chroma_subsampling.VShift(1));
263
1.12k
      const int32_t* quant_row_b =
264
1.12k
          in.channel[2].plane.Row(y >> chroma_subsampling.VShift(2));
265
23.1k
      for (size_t x = 0; x < r.xsize(); x++) {
266
21.9k
        int bucket_x = 0;
267
21.9k
        int bucket_y = 0;
268
21.9k
        int bucket_b = 0;
269
79.2k
        for (int t : bctx.dc_thresholds[0]) {
270
79.2k
          if (quant_row_x[x >> chroma_subsampling.HShift(0)] > t) bucket_x++;
271
79.2k
        }
272
21.9k
        for (int t : bctx.dc_thresholds[1]) {
273
11.3k
          if (quant_row_y[x >> chroma_subsampling.HShift(1)] > t) bucket_y++;
274
11.3k
        }
275
21.9k
        for (int t : bctx.dc_thresholds[2]) {
276
11.2k
          if (quant_row_b[x >> chroma_subsampling.HShift(2)] > t) bucket_b++;
277
11.2k
        }
278
21.9k
        int bucket = bucket_x;
279
21.9k
        bucket *= bctx.dc_thresholds[2].size() + 1;
280
21.9k
        bucket += bucket_b;
281
21.9k
        bucket *= bctx.dc_thresholds[1].size() + 1;
282
21.9k
        bucket += bucket_y;
283
21.9k
        qdc_row_val[x] = bucket;
284
21.9k
      }
285
1.12k
    }
286
224
  }
287
4.93k
}
Unexecuted instantiation: jxl::N_AVX3::DequantDC(jxl::RectT<unsigned long> const&, jxl::Image3<float>*, jxl::Plane<unsigned char>*, jxl::Image const&, float const*, float, float const*, jxl::YCbCrChromaSubsampling const&, jxl::BlockCtxMap const&)
Unexecuted instantiation: jxl::N_AVX3_ZEN4::DequantDC(jxl::RectT<unsigned long> const&, jxl::Image3<float>*, jxl::Plane<unsigned char>*, jxl::Image const&, float const*, float, float const*, jxl::YCbCrChromaSubsampling const&, jxl::BlockCtxMap const&)
Unexecuted instantiation: jxl::N_AVX3_SPR::DequantDC(jxl::RectT<unsigned long> const&, jxl::Image3<float>*, jxl::Plane<unsigned char>*, jxl::Image const&, float const*, float, float const*, jxl::YCbCrChromaSubsampling const&, jxl::BlockCtxMap const&)
Unexecuted instantiation: jxl::N_SSE2::DequantDC(jxl::RectT<unsigned long> const&, jxl::Image3<float>*, jxl::Plane<unsigned char>*, jxl::Image const&, float const*, float, float const*, jxl::YCbCrChromaSubsampling const&, jxl::BlockCtxMap const&)
288
289
// NOLINTNEXTLINE(google-readability-namespace-comments)
290
}  // namespace HWY_NAMESPACE
291
}  // namespace jxl
292
HWY_AFTER_NAMESPACE();
293
294
#if HWY_ONCE
295
namespace jxl {
296
297
HWY_EXPORT(DequantDC);
298
HWY_EXPORT(AdaptiveDCSmoothing);
299
Status AdaptiveDCSmoothing(JxlMemoryManager* memory_manager,
300
                           const float* dc_factors, Image3F* dc,
301
3.66k
                           ThreadPool* pool) {
302
3.66k
  return HWY_DYNAMIC_DISPATCH(AdaptiveDCSmoothing)(memory_manager, dc_factors,
303
3.66k
                                                   dc, pool);
304
3.66k
}
305
306
void DequantDC(const Rect& r, Image3F* dc, ImageB* quant_dc, const Image& in,
307
               const float* dc_factors, float mul, const float* cfl_factors,
308
               const YCbCrChromaSubsampling& chroma_subsampling,
309
4.93k
               const BlockCtxMap& bctx) {
310
4.93k
  HWY_DYNAMIC_DISPATCH(DequantDC)
311
4.93k
  (r, dc, quant_dc, in, dc_factors, mul, cfl_factors, chroma_subsampling, bctx);
312
4.93k
}
313
314
}  // namespace jxl
315
#endif  // HWY_ONCE