Coverage Report

Created: 2025-12-03 07:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libjxl/lib/jxl/modular/transform/rct.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/modular/transform/rct.h"
7
8
#include <cstddef>
9
#include <cstdint>
10
#include <utility>
11
12
#include "lib/jxl/base/data_parallel.h"
13
#include "lib/jxl/base/status.h"
14
#include "lib/jxl/modular/modular_image.h"
15
#include "lib/jxl/modular/transform/transform.h"
16
#undef HWY_TARGET_INCLUDE
17
#define HWY_TARGET_INCLUDE "lib/jxl/modular/transform/rct.cc"
18
#include <hwy/foreach_target.h>
19
#include <hwy/highway.h>
20
HWY_BEFORE_NAMESPACE();
21
namespace jxl {
22
namespace HWY_NAMESPACE {
23
24
// These templates are not found via ADL.
25
using hwy::HWY_NAMESPACE::Add;
26
using hwy::HWY_NAMESPACE::ShiftRight;
27
using hwy::HWY_NAMESPACE::Sub;
28
29
template <int transform_type>
30
void InvRCTRow(const pixel_type* in0, const pixel_type* in1,
31
               const pixel_type* in2, pixel_type* out0, pixel_type* out1,
32
349k
               pixel_type* out2, size_t w) {
33
349k
  static_assert(transform_type >= 0 && transform_type < 7,
34
349k
                "Invalid transform type");
35
349k
  int second = transform_type >> 1;
36
349k
  int third = transform_type & 1;
37
38
349k
  size_t x = 0;
39
349k
  const HWY_FULL(pixel_type) d;
40
349k
  const size_t N = Lanes(d);
41
1.55M
  for (; x + N - 1 < w; x += N) {
42
1.20M
    if (transform_type == 6) {
43
580k
      auto Y = Load(d, in0 + x);
44
580k
      auto Co = Load(d, in1 + x);
45
580k
      auto Cg = Load(d, in2 + x);
46
580k
      Y = Sub(Y, ShiftRight<1>(Cg));
47
580k
      auto G = Add(Cg, Y);
48
580k
      Y = Sub(Y, ShiftRight<1>(Co));
49
580k
      auto R = Add(Y, Co);
50
580k
      Store(R, d, out0 + x);
51
580k
      Store(G, d, out1 + x);
52
580k
      Store(Y, d, out2 + x);
53
626k
    } else {
54
626k
      auto First = Load(d, in0 + x);
55
626k
      auto Second = Load(d, in1 + x);
56
626k
      auto Third = Load(d, in2 + x);
57
626k
      if (third) Third = Add(Third, First);
58
626k
      if (second == 1) {
59
467k
        Second = Add(Second, First);
60
467k
      } else if (second == 2) {
61
110k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
110k
      }
63
626k
      Store(First, d, out0 + x);
64
626k
      Store(Second, d, out1 + x);
65
626k
      Store(Third, d, out2 + x);
66
626k
    }
67
1.20M
  }
68
1.34M
  for (; x < w; x++) {
69
998k
    if (transform_type == 6) {
70
948k
      pixel_type Y = in0[x];
71
948k
      pixel_type Co = in1[x];
72
948k
      pixel_type Cg = in2[x];
73
948k
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
948k
      pixel_type G = PixelAdd(Cg, tmp);
75
948k
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
948k
      pixel_type R = PixelAdd(B, Co);
77
948k
      out0[x] = R;
78
948k
      out1[x] = G;
79
948k
      out2[x] = B;
80
948k
    } else {
81
50.0k
      pixel_type First = in0[x];
82
50.0k
      pixel_type Second = in1[x];
83
50.0k
      pixel_type Third = in2[x];
84
50.0k
      if (third) Third = PixelAdd(Third, First);
85
50.0k
      if (second == 1) {
86
32.2k
        Second = PixelAdd(Second, First);
87
32.2k
      } else if (second == 2) {
88
10.4k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
10.4k
      }
90
50.0k
      out0[x] = First;
91
50.0k
      out1[x] = Second;
92
50.0k
      out2[x] = Third;
93
50.0k
    }
94
998k
  }
95
349k
}
Unexecuted instantiation: void jxl::N_SSE4::InvRCTRow<0>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE4::InvRCTRow<1>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE4::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE4::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE4::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE4::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE4::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX2::InvRCTRow<0>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
void jxl::N_AVX2::InvRCTRow<1>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
4.29k
               pixel_type* out2, size_t w) {
33
4.29k
  static_assert(transform_type >= 0 && transform_type < 7,
34
4.29k
                "Invalid transform type");
35
4.29k
  int second = transform_type >> 1;
36
4.29k
  int third = transform_type & 1;
37
38
4.29k
  size_t x = 0;
39
4.29k
  const HWY_FULL(pixel_type) d;
40
4.29k
  const size_t N = Lanes(d);
41
52.4k
  for (; x + N - 1 < w; x += N) {
42
48.1k
    if (transform_type == 6) {
43
0
      auto Y = Load(d, in0 + x);
44
0
      auto Co = Load(d, in1 + x);
45
0
      auto Cg = Load(d, in2 + x);
46
0
      Y = Sub(Y, ShiftRight<1>(Cg));
47
0
      auto G = Add(Cg, Y);
48
0
      Y = Sub(Y, ShiftRight<1>(Co));
49
0
      auto R = Add(Y, Co);
50
0
      Store(R, d, out0 + x);
51
0
      Store(G, d, out1 + x);
52
0
      Store(Y, d, out2 + x);
53
48.1k
    } else {
54
48.1k
      auto First = Load(d, in0 + x);
55
48.1k
      auto Second = Load(d, in1 + x);
56
48.1k
      auto Third = Load(d, in2 + x);
57
48.1k
      if (third) Third = Add(Third, First);
58
48.1k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
48.1k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
48.1k
      Store(First, d, out0 + x);
64
48.1k
      Store(Second, d, out1 + x);
65
48.1k
      Store(Third, d, out2 + x);
66
48.1k
    }
67
48.1k
  }
68
11.6k
  for (; x < w; x++) {
69
7.31k
    if (transform_type == 6) {
70
0
      pixel_type Y = in0[x];
71
0
      pixel_type Co = in1[x];
72
0
      pixel_type Cg = in2[x];
73
0
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
0
      pixel_type G = PixelAdd(Cg, tmp);
75
0
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
0
      pixel_type R = PixelAdd(B, Co);
77
0
      out0[x] = R;
78
0
      out1[x] = G;
79
0
      out2[x] = B;
80
7.31k
    } else {
81
7.31k
      pixel_type First = in0[x];
82
7.31k
      pixel_type Second = in1[x];
83
7.31k
      pixel_type Third = in2[x];
84
7.31k
      if (third) Third = PixelAdd(Third, First);
85
7.31k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
7.31k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
7.31k
      out0[x] = First;
91
7.31k
      out1[x] = Second;
92
7.31k
      out2[x] = Third;
93
7.31k
    }
94
7.31k
  }
95
4.29k
}
void jxl::N_AVX2::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
3.85k
               pixel_type* out2, size_t w) {
33
3.85k
  static_assert(transform_type >= 0 && transform_type < 7,
34
3.85k
                "Invalid transform type");
35
3.85k
  int second = transform_type >> 1;
36
3.85k
  int third = transform_type & 1;
37
38
3.85k
  size_t x = 0;
39
3.85k
  const HWY_FULL(pixel_type) d;
40
3.85k
  const size_t N = Lanes(d);
41
59.3k
  for (; x + N - 1 < w; x += N) {
42
55.5k
    if (transform_type == 6) {
43
0
      auto Y = Load(d, in0 + x);
44
0
      auto Co = Load(d, in1 + x);
45
0
      auto Cg = Load(d, in2 + x);
46
0
      Y = Sub(Y, ShiftRight<1>(Cg));
47
0
      auto G = Add(Cg, Y);
48
0
      Y = Sub(Y, ShiftRight<1>(Co));
49
0
      auto R = Add(Y, Co);
50
0
      Store(R, d, out0 + x);
51
0
      Store(G, d, out1 + x);
52
0
      Store(Y, d, out2 + x);
53
55.5k
    } else {
54
55.5k
      auto First = Load(d, in0 + x);
55
55.5k
      auto Second = Load(d, in1 + x);
56
55.5k
      auto Third = Load(d, in2 + x);
57
55.5k
      if (third) Third = Add(Third, First);
58
55.5k
      if (second == 1) {
59
55.5k
        Second = Add(Second, First);
60
55.5k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
55.5k
      Store(First, d, out0 + x);
64
55.5k
      Store(Second, d, out1 + x);
65
55.5k
      Store(Third, d, out2 + x);
66
55.5k
    }
67
55.5k
  }
68
9.55k
  for (; x < w; x++) {
69
5.69k
    if (transform_type == 6) {
70
0
      pixel_type Y = in0[x];
71
0
      pixel_type Co = in1[x];
72
0
      pixel_type Cg = in2[x];
73
0
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
0
      pixel_type G = PixelAdd(Cg, tmp);
75
0
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
0
      pixel_type R = PixelAdd(B, Co);
77
0
      out0[x] = R;
78
0
      out1[x] = G;
79
0
      out2[x] = B;
80
5.69k
    } else {
81
5.69k
      pixel_type First = in0[x];
82
5.69k
      pixel_type Second = in1[x];
83
5.69k
      pixel_type Third = in2[x];
84
5.69k
      if (third) Third = PixelAdd(Third, First);
85
5.69k
      if (second == 1) {
86
5.69k
        Second = PixelAdd(Second, First);
87
5.69k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
5.69k
      out0[x] = First;
91
5.69k
      out1[x] = Second;
92
5.69k
      out2[x] = Third;
93
5.69k
    }
94
5.69k
  }
95
3.85k
}
void jxl::N_AVX2::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
22.6k
               pixel_type* out2, size_t w) {
33
22.6k
  static_assert(transform_type >= 0 && transform_type < 7,
34
22.6k
                "Invalid transform type");
35
22.6k
  int second = transform_type >> 1;
36
22.6k
  int third = transform_type & 1;
37
38
22.6k
  size_t x = 0;
39
22.6k
  const HWY_FULL(pixel_type) d;
40
22.6k
  const size_t N = Lanes(d);
41
434k
  for (; x + N - 1 < w; x += N) {
42
412k
    if (transform_type == 6) {
43
0
      auto Y = Load(d, in0 + x);
44
0
      auto Co = Load(d, in1 + x);
45
0
      auto Cg = Load(d, in2 + x);
46
0
      Y = Sub(Y, ShiftRight<1>(Cg));
47
0
      auto G = Add(Cg, Y);
48
0
      Y = Sub(Y, ShiftRight<1>(Co));
49
0
      auto R = Add(Y, Co);
50
0
      Store(R, d, out0 + x);
51
0
      Store(G, d, out1 + x);
52
0
      Store(Y, d, out2 + x);
53
412k
    } else {
54
412k
      auto First = Load(d, in0 + x);
55
412k
      auto Second = Load(d, in1 + x);
56
412k
      auto Third = Load(d, in2 + x);
57
412k
      if (third) Third = Add(Third, First);
58
412k
      if (second == 1) {
59
412k
        Second = Add(Second, First);
60
412k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
412k
      Store(First, d, out0 + x);
64
412k
      Store(Second, d, out1 + x);
65
412k
      Store(Third, d, out2 + x);
66
412k
    }
67
412k
  }
68
49.2k
  for (; x < w; x++) {
69
26.5k
    if (transform_type == 6) {
70
0
      pixel_type Y = in0[x];
71
0
      pixel_type Co = in1[x];
72
0
      pixel_type Cg = in2[x];
73
0
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
0
      pixel_type G = PixelAdd(Cg, tmp);
75
0
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
0
      pixel_type R = PixelAdd(B, Co);
77
0
      out0[x] = R;
78
0
      out1[x] = G;
79
0
      out2[x] = B;
80
26.5k
    } else {
81
26.5k
      pixel_type First = in0[x];
82
26.5k
      pixel_type Second = in1[x];
83
26.5k
      pixel_type Third = in2[x];
84
26.5k
      if (third) Third = PixelAdd(Third, First);
85
26.5k
      if (second == 1) {
86
26.5k
        Second = PixelAdd(Second, First);
87
26.5k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
26.5k
      out0[x] = First;
91
26.5k
      out1[x] = Second;
92
26.5k
      out2[x] = Third;
93
26.5k
    }
94
26.5k
  }
95
22.6k
}
void jxl::N_AVX2::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
3.37k
               pixel_type* out2, size_t w) {
33
3.37k
  static_assert(transform_type >= 0 && transform_type < 7,
34
3.37k
                "Invalid transform type");
35
3.37k
  int second = transform_type >> 1;
36
3.37k
  int third = transform_type & 1;
37
38
3.37k
  size_t x = 0;
39
3.37k
  const HWY_FULL(pixel_type) d;
40
3.37k
  const size_t N = Lanes(d);
41
43.6k
  for (; x + N - 1 < w; x += N) {
42
40.3k
    if (transform_type == 6) {
43
0
      auto Y = Load(d, in0 + x);
44
0
      auto Co = Load(d, in1 + x);
45
0
      auto Cg = Load(d, in2 + x);
46
0
      Y = Sub(Y, ShiftRight<1>(Cg));
47
0
      auto G = Add(Cg, Y);
48
0
      Y = Sub(Y, ShiftRight<1>(Co));
49
0
      auto R = Add(Y, Co);
50
0
      Store(R, d, out0 + x);
51
0
      Store(G, d, out1 + x);
52
0
      Store(Y, d, out2 + x);
53
40.3k
    } else {
54
40.3k
      auto First = Load(d, in0 + x);
55
40.3k
      auto Second = Load(d, in1 + x);
56
40.3k
      auto Third = Load(d, in2 + x);
57
40.3k
      if (third) Third = Add(Third, First);
58
40.3k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
40.3k
      } else if (second == 2) {
61
40.3k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
40.3k
      }
63
40.3k
      Store(First, d, out0 + x);
64
40.3k
      Store(Second, d, out1 + x);
65
40.3k
      Store(Third, d, out2 + x);
66
40.3k
    }
67
40.3k
  }
68
6.19k
  for (; x < w; x++) {
69
2.82k
    if (transform_type == 6) {
70
0
      pixel_type Y = in0[x];
71
0
      pixel_type Co = in1[x];
72
0
      pixel_type Cg = in2[x];
73
0
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
0
      pixel_type G = PixelAdd(Cg, tmp);
75
0
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
0
      pixel_type R = PixelAdd(B, Co);
77
0
      out0[x] = R;
78
0
      out1[x] = G;
79
0
      out2[x] = B;
80
2.82k
    } else {
81
2.82k
      pixel_type First = in0[x];
82
2.82k
      pixel_type Second = in1[x];
83
2.82k
      pixel_type Third = in2[x];
84
2.82k
      if (third) Third = PixelAdd(Third, First);
85
2.82k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
2.82k
      } else if (second == 2) {
88
2.82k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
2.82k
      }
90
2.82k
      out0[x] = First;
91
2.82k
      out1[x] = Second;
92
2.82k
      out2[x] = Third;
93
2.82k
    }
94
2.82k
  }
95
3.37k
}
void jxl::N_AVX2::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
8.96k
               pixel_type* out2, size_t w) {
33
8.96k
  static_assert(transform_type >= 0 && transform_type < 7,
34
8.96k
                "Invalid transform type");
35
8.96k
  int second = transform_type >> 1;
36
8.96k
  int third = transform_type & 1;
37
38
8.96k
  size_t x = 0;
39
8.96k
  const HWY_FULL(pixel_type) d;
40
8.96k
  const size_t N = Lanes(d);
41
79.4k
  for (; x + N - 1 < w; x += N) {
42
70.4k
    if (transform_type == 6) {
43
0
      auto Y = Load(d, in0 + x);
44
0
      auto Co = Load(d, in1 + x);
45
0
      auto Cg = Load(d, in2 + x);
46
0
      Y = Sub(Y, ShiftRight<1>(Cg));
47
0
      auto G = Add(Cg, Y);
48
0
      Y = Sub(Y, ShiftRight<1>(Co));
49
0
      auto R = Add(Y, Co);
50
0
      Store(R, d, out0 + x);
51
0
      Store(G, d, out1 + x);
52
0
      Store(Y, d, out2 + x);
53
70.4k
    } else {
54
70.4k
      auto First = Load(d, in0 + x);
55
70.4k
      auto Second = Load(d, in1 + x);
56
70.4k
      auto Third = Load(d, in2 + x);
57
70.4k
      if (third) Third = Add(Third, First);
58
70.4k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
70.4k
      } else if (second == 2) {
61
70.4k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
70.4k
      }
63
70.4k
      Store(First, d, out0 + x);
64
70.4k
      Store(Second, d, out1 + x);
65
70.4k
      Store(Third, d, out2 + x);
66
70.4k
    }
67
70.4k
  }
68
16.6k
  for (; x < w; x++) {
69
7.66k
    if (transform_type == 6) {
70
0
      pixel_type Y = in0[x];
71
0
      pixel_type Co = in1[x];
72
0
      pixel_type Cg = in2[x];
73
0
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
0
      pixel_type G = PixelAdd(Cg, tmp);
75
0
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
0
      pixel_type R = PixelAdd(B, Co);
77
0
      out0[x] = R;
78
0
      out1[x] = G;
79
0
      out2[x] = B;
80
7.66k
    } else {
81
7.66k
      pixel_type First = in0[x];
82
7.66k
      pixel_type Second = in1[x];
83
7.66k
      pixel_type Third = in2[x];
84
7.66k
      if (third) Third = PixelAdd(Third, First);
85
7.66k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
7.66k
      } else if (second == 2) {
88
7.66k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
7.66k
      }
90
7.66k
      out0[x] = First;
91
7.66k
      out1[x] = Second;
92
7.66k
      out2[x] = Third;
93
7.66k
    }
94
7.66k
  }
95
8.96k
}
void jxl::N_AVX2::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
306k
               pixel_type* out2, size_t w) {
33
306k
  static_assert(transform_type >= 0 && transform_type < 7,
34
306k
                "Invalid transform type");
35
306k
  int second = transform_type >> 1;
36
306k
  int third = transform_type & 1;
37
38
306k
  size_t x = 0;
39
306k
  const HWY_FULL(pixel_type) d;
40
306k
  const size_t N = Lanes(d);
41
886k
  for (; x + N - 1 < w; x += N) {
42
580k
    if (transform_type == 6) {
43
580k
      auto Y = Load(d, in0 + x);
44
580k
      auto Co = Load(d, in1 + x);
45
580k
      auto Cg = Load(d, in2 + x);
46
580k
      Y = Sub(Y, ShiftRight<1>(Cg));
47
580k
      auto G = Add(Cg, Y);
48
580k
      Y = Sub(Y, ShiftRight<1>(Co));
49
580k
      auto R = Add(Y, Co);
50
580k
      Store(R, d, out0 + x);
51
580k
      Store(G, d, out1 + x);
52
580k
      Store(Y, d, out2 + x);
53
580k
    } else {
54
0
      auto First = Load(d, in0 + x);
55
0
      auto Second = Load(d, in1 + x);
56
0
      auto Third = Load(d, in2 + x);
57
0
      if (third) Third = Add(Third, First);
58
0
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
0
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
0
      Store(First, d, out0 + x);
64
0
      Store(Second, d, out1 + x);
65
0
      Store(Third, d, out2 + x);
66
0
    }
67
580k
  }
68
1.25M
  for (; x < w; x++) {
69
948k
    if (transform_type == 6) {
70
948k
      pixel_type Y = in0[x];
71
948k
      pixel_type Co = in1[x];
72
948k
      pixel_type Cg = in2[x];
73
948k
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
948k
      pixel_type G = PixelAdd(Cg, tmp);
75
948k
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
948k
      pixel_type R = PixelAdd(B, Co);
77
948k
      out0[x] = R;
78
948k
      out1[x] = G;
79
948k
      out2[x] = B;
80
948k
    } else {
81
0
      pixel_type First = in0[x];
82
0
      pixel_type Second = in1[x];
83
0
      pixel_type Third = in2[x];
84
0
      if (third) Third = PixelAdd(Third, First);
85
0
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
0
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
0
      out0[x] = First;
91
0
      out1[x] = Second;
92
0
      out2[x] = Third;
93
0
    }
94
948k
  }
95
306k
}
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<0>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<1>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<0>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<1>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<0>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<1>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<0>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<1>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
96
97
4.76k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
98
4.76k
  JXL_RETURN_IF_ERROR(CheckEqualChannels(input, begin_c, begin_c + 2));
99
4.76k
  size_t m = begin_c;
100
4.76k
  Channel& c0 = input.channel[m + 0];
101
4.76k
  size_t w = c0.w;
102
4.76k
  size_t h = c0.h;
103
4.76k
  if (rct_type == 0) {  // noop
104
146
    return true;
105
146
  }
106
  // Permutation: 0=RGB, 1=GBR, 2=BRG, 3=RBG, 4=GRB, 5=BGR
107
4.62k
  int permutation = rct_type / 7;
108
4.62k
  JXL_ENSURE(permutation < 6);
109
  // 0-5 values have the low bit corresponding to Third and the high bits
110
  // corresponding to Second. 6 corresponds to YCoCg.
111
  //
112
  // Second: 0=nop, 1=SubtractFirst, 2=SubtractAvgFirstThird
113
  //
114
  // Third: 0=nop, 1=SubtractFirst
115
4.62k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
4.62k
  if (custom == 0) {
118
217
    Channel ch0 = std::move(input.channel[m]);
119
217
    Channel ch1 = std::move(input.channel[m + 1]);
120
217
    Channel ch2 = std::move(input.channel[m + 2]);
121
217
    input.channel[m + (permutation % 3)] = std::move(ch0);
122
217
    input.channel[m + ((permutation + 1 + permutation / 3) % 3)] =
123
217
        std::move(ch1);
124
217
    input.channel[m + ((permutation + 2 - permutation / 3) % 3)] =
125
217
        std::move(ch2);
126
217
    return true;
127
217
  }
128
4.40k
  constexpr decltype(&InvRCTRow<0>) inv_rct_row[] = {
129
4.40k
      InvRCTRow<0>, InvRCTRow<1>, InvRCTRow<2>, InvRCTRow<3>,
130
4.40k
      InvRCTRow<4>, InvRCTRow<5>, InvRCTRow<6>};
131
4.40k
  const auto process_row = [&](const uint32_t task,
132
349k
                               size_t /* thread */) -> Status {
133
349k
    const size_t y = task;
134
349k
    const pixel_type* in0 = input.channel[m].Row(y);
135
349k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
349k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
349k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
349k
    pixel_type* out1 =
139
349k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
349k
    pixel_type* out2 =
141
349k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
349k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
349k
    return true;
144
349k
  };
Unexecuted instantiation: rct.cc:jxl::N_SSE4::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
rct.cc:jxl::N_AVX2::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
Line
Count
Source
132
349k
                               size_t /* thread */) -> Status {
133
349k
    const size_t y = task;
134
349k
    const pixel_type* in0 = input.channel[m].Row(y);
135
349k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
349k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
349k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
349k
    pixel_type* out1 =
139
349k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
349k
    pixel_type* out2 =
141
349k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
349k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
349k
    return true;
144
349k
  };
Unexecuted instantiation: rct.cc:jxl::N_AVX3::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
Unexecuted instantiation: rct.cc:jxl::N_AVX3_ZEN4::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
Unexecuted instantiation: rct.cc:jxl::N_AVX3_SPR::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
Unexecuted instantiation: rct.cc:jxl::N_SSE2::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
145
4.40k
  JXL_RETURN_IF_ERROR(
146
4.40k
      RunOnPool(pool, 0, h, ThreadPool::NoInit, process_row, "InvRCT"));
147
4.40k
  return true;
148
4.40k
}
Unexecuted instantiation: jxl::N_SSE4::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)
jxl::N_AVX2::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)
Line
Count
Source
97
4.76k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
98
4.76k
  JXL_RETURN_IF_ERROR(CheckEqualChannels(input, begin_c, begin_c + 2));
99
4.76k
  size_t m = begin_c;
100
4.76k
  Channel& c0 = input.channel[m + 0];
101
4.76k
  size_t w = c0.w;
102
4.76k
  size_t h = c0.h;
103
4.76k
  if (rct_type == 0) {  // noop
104
146
    return true;
105
146
  }
106
  // Permutation: 0=RGB, 1=GBR, 2=BRG, 3=RBG, 4=GRB, 5=BGR
107
4.62k
  int permutation = rct_type / 7;
108
4.62k
  JXL_ENSURE(permutation < 6);
109
  // 0-5 values have the low bit corresponding to Third and the high bits
110
  // corresponding to Second. 6 corresponds to YCoCg.
111
  //
112
  // Second: 0=nop, 1=SubtractFirst, 2=SubtractAvgFirstThird
113
  //
114
  // Third: 0=nop, 1=SubtractFirst
115
4.62k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
4.62k
  if (custom == 0) {
118
217
    Channel ch0 = std::move(input.channel[m]);
119
217
    Channel ch1 = std::move(input.channel[m + 1]);
120
217
    Channel ch2 = std::move(input.channel[m + 2]);
121
217
    input.channel[m + (permutation % 3)] = std::move(ch0);
122
217
    input.channel[m + ((permutation + 1 + permutation / 3) % 3)] =
123
217
        std::move(ch1);
124
217
    input.channel[m + ((permutation + 2 - permutation / 3) % 3)] =
125
217
        std::move(ch2);
126
217
    return true;
127
217
  }
128
4.40k
  constexpr decltype(&InvRCTRow<0>) inv_rct_row[] = {
129
4.40k
      InvRCTRow<0>, InvRCTRow<1>, InvRCTRow<2>, InvRCTRow<3>,
130
4.40k
      InvRCTRow<4>, InvRCTRow<5>, InvRCTRow<6>};
131
4.40k
  const auto process_row = [&](const uint32_t task,
132
4.40k
                               size_t /* thread */) -> Status {
133
4.40k
    const size_t y = task;
134
4.40k
    const pixel_type* in0 = input.channel[m].Row(y);
135
4.40k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
4.40k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
4.40k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
4.40k
    pixel_type* out1 =
139
4.40k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
4.40k
    pixel_type* out2 =
141
4.40k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
4.40k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
4.40k
    return true;
144
4.40k
  };
145
4.40k
  JXL_RETURN_IF_ERROR(
146
4.40k
      RunOnPool(pool, 0, h, ThreadPool::NoInit, process_row, "InvRCT"));
147
4.40k
  return true;
148
4.40k
}
Unexecuted instantiation: jxl::N_AVX3::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)
Unexecuted instantiation: jxl::N_AVX3_ZEN4::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)
Unexecuted instantiation: jxl::N_AVX3_SPR::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)
Unexecuted instantiation: jxl::N_SSE2::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)
149
150
}  // namespace HWY_NAMESPACE
151
}  // namespace jxl
152
HWY_AFTER_NAMESPACE();
153
154
#if HWY_ONCE
155
namespace jxl {
156
157
HWY_EXPORT(InvRCT);
158
4.76k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
159
4.76k
  return HWY_DYNAMIC_DISPATCH(InvRCT)(input, begin_c, rct_type, pool);
160
4.76k
}
161
162
}  // namespace jxl
163
#endif