Coverage Report

Created: 2026-10-28 07:26

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
354k
               pixel_type* out2, size_t w) {
33
354k
  static_assert(transform_type >= 0 && transform_type < 7,
34
354k
                "Invalid transform type");
35
354k
  int second = transform_type >> 1;
36
354k
  int third = transform_type & 1;
37
38
354k
  size_t x = 0;
39
354k
  const HWY_FULL(pixel_type) d;
40
354k
  const size_t N = Lanes(d);
41
4.31M
  for (; x + N - 1 < w; x += N) {
42
3.96M
    if (transform_type == 6) {
43
2.62M
      auto Y = Load(d, in0 + x);
44
2.62M
      auto Co = Load(d, in1 + x);
45
2.62M
      auto Cg = Load(d, in2 + x);
46
2.62M
      Y = Sub(Y, ShiftRight<1>(Cg));
47
2.62M
      auto G = Add(Cg, Y);
48
2.62M
      Y = Sub(Y, ShiftRight<1>(Co));
49
2.62M
      auto R = Add(Y, Co);
50
2.62M
      Store(R, d, out0 + x);
51
2.62M
      Store(G, d, out1 + x);
52
2.62M
      Store(Y, d, out2 + x);
53
2.62M
    } else {
54
1.34M
      auto First = Load(d, in0 + x);
55
1.34M
      auto Second = Load(d, in1 + x);
56
1.34M
      auto Third = Load(d, in2 + x);
57
1.34M
      if (third) Third = Add(Third, First);
58
1.34M
      if (second == 1) {
59
720k
        Second = Add(Second, First);
60
720k
      } else if (second == 2) {
61
522k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
522k
      }
63
1.34M
      Store(First, d, out0 + x);
64
1.34M
      Store(Second, d, out1 + x);
65
1.34M
      Store(Third, d, out2 + x);
66
1.34M
    }
67
3.96M
  }
68
1.11M
  for (; x < w; x++) {
69
755k
    if (transform_type == 6) {
70
660k
      pixel_type Y = in0[x];
71
660k
      pixel_type Co = in1[x];
72
660k
      pixel_type Cg = in2[x];
73
660k
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
660k
      pixel_type G = PixelAdd(Cg, tmp);
75
660k
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
660k
      pixel_type R = PixelAdd(B, Co);
77
660k
      out0[x] = R;
78
660k
      out1[x] = G;
79
660k
      out2[x] = B;
80
660k
    } else {
81
94.8k
      pixel_type First = in0[x];
82
94.8k
      pixel_type Second = in1[x];
83
94.8k
      pixel_type Third = in2[x];
84
94.8k
      if (third) Third = PixelAdd(Third, First);
85
94.8k
      if (second == 1) {
86
49.1k
        Second = PixelAdd(Second, First);
87
49.1k
      } else if (second == 2) {
88
27.6k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
27.6k
      }
90
94.8k
      out0[x] = First;
91
94.8k
      out1[x] = Second;
92
94.8k
      out2[x] = Third;
93
94.8k
    }
94
755k
  }
95
354k
}
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
8.20k
               pixel_type* out2, size_t w) {
33
8.20k
  static_assert(transform_type >= 0 && transform_type < 7,
34
8.20k
                "Invalid transform type");
35
8.20k
  int second = transform_type >> 1;
36
8.20k
  int third = transform_type & 1;
37
38
8.20k
  size_t x = 0;
39
8.20k
  const HWY_FULL(pixel_type) d;
40
8.20k
  const size_t N = Lanes(d);
41
107k
  for (; x + N - 1 < w; x += N) {
42
98.9k
    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
98.9k
    } else {
54
98.9k
      auto First = Load(d, in0 + x);
55
98.9k
      auto Second = Load(d, in1 + x);
56
98.9k
      auto Third = Load(d, in2 + x);
57
98.9k
      if (third) Third = Add(Third, First);
58
98.9k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
98.9k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
98.9k
      Store(First, d, out0 + x);
64
98.9k
      Store(Second, d, out1 + x);
65
98.9k
      Store(Third, d, out2 + x);
66
98.9k
    }
67
98.9k
  }
68
26.2k
  for (; x < w; x++) {
69
18.0k
    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
18.0k
    } else {
81
18.0k
      pixel_type First = in0[x];
82
18.0k
      pixel_type Second = in1[x];
83
18.0k
      pixel_type Third = in2[x];
84
18.0k
      if (third) Third = PixelAdd(Third, First);
85
18.0k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
18.0k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
18.0k
      out0[x] = First;
91
18.0k
      out1[x] = Second;
92
18.0k
      out2[x] = Third;
93
18.0k
    }
94
18.0k
  }
95
8.20k
}
void jxl::N_AVX2::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
6.79k
               pixel_type* out2, size_t w) {
33
6.79k
  static_assert(transform_type >= 0 && transform_type < 7,
34
6.79k
                "Invalid transform type");
35
6.79k
  int second = transform_type >> 1;
36
6.79k
  int third = transform_type & 1;
37
38
6.79k
  size_t x = 0;
39
6.79k
  const HWY_FULL(pixel_type) d;
40
6.79k
  const size_t N = Lanes(d);
41
107k
  for (; x + N - 1 < w; x += N) {
42
100k
    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
100k
    } else {
54
100k
      auto First = Load(d, in0 + x);
55
100k
      auto Second = Load(d, in1 + x);
56
100k
      auto Third = Load(d, in2 + x);
57
100k
      if (third) Third = Add(Third, First);
58
100k
      if (second == 1) {
59
100k
        Second = Add(Second, First);
60
100k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
100k
      Store(First, d, out0 + x);
64
100k
      Store(Second, d, out1 + x);
65
100k
      Store(Third, d, out2 + x);
66
100k
    }
67
100k
  }
68
21.9k
  for (; x < w; x++) {
69
15.1k
    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
15.1k
    } else {
81
15.1k
      pixel_type First = in0[x];
82
15.1k
      pixel_type Second = in1[x];
83
15.1k
      pixel_type Third = in2[x];
84
15.1k
      if (third) Third = PixelAdd(Third, First);
85
15.1k
      if (second == 1) {
86
15.1k
        Second = PixelAdd(Second, First);
87
15.1k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
15.1k
      out0[x] = First;
91
15.1k
      out1[x] = Second;
92
15.1k
      out2[x] = Third;
93
15.1k
    }
94
15.1k
  }
95
6.79k
}
void jxl::N_AVX2::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
28.3k
               pixel_type* out2, size_t w) {
33
28.3k
  static_assert(transform_type >= 0 && transform_type < 7,
34
28.3k
                "Invalid transform type");
35
28.3k
  int second = transform_type >> 1;
36
28.3k
  int third = transform_type & 1;
37
38
28.3k
  size_t x = 0;
39
28.3k
  const HWY_FULL(pixel_type) d;
40
28.3k
  const size_t N = Lanes(d);
41
648k
  for (; x + N - 1 < w; x += N) {
42
619k
    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
619k
    } else {
54
619k
      auto First = Load(d, in0 + x);
55
619k
      auto Second = Load(d, in1 + x);
56
619k
      auto Third = Load(d, in2 + x);
57
619k
      if (third) Third = Add(Third, First);
58
619k
      if (second == 1) {
59
619k
        Second = Add(Second, First);
60
619k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
619k
      Store(First, d, out0 + x);
64
619k
      Store(Second, d, out1 + x);
65
619k
      Store(Third, d, out2 + x);
66
619k
    }
67
619k
  }
68
62.3k
  for (; x < w; x++) {
69
33.9k
    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
33.9k
    } else {
81
33.9k
      pixel_type First = in0[x];
82
33.9k
      pixel_type Second = in1[x];
83
33.9k
      pixel_type Third = in2[x];
84
33.9k
      if (third) Third = PixelAdd(Third, First);
85
33.9k
      if (second == 1) {
86
33.9k
        Second = PixelAdd(Second, First);
87
33.9k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
33.9k
      out0[x] = First;
91
33.9k
      out1[x] = Second;
92
33.9k
      out2[x] = Third;
93
33.9k
    }
94
33.9k
  }
95
28.3k
}
void jxl::N_AVX2::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
5.69k
               pixel_type* out2, size_t w) {
33
5.69k
  static_assert(transform_type >= 0 && transform_type < 7,
34
5.69k
                "Invalid transform type");
35
5.69k
  int second = transform_type >> 1;
36
5.69k
  int third = transform_type & 1;
37
38
5.69k
  size_t x = 0;
39
5.69k
  const HWY_FULL(pixel_type) d;
40
5.69k
  const size_t N = Lanes(d);
41
190k
  for (; x + N - 1 < w; x += N) {
42
185k
    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
185k
    } else {
54
185k
      auto First = Load(d, in0 + x);
55
185k
      auto Second = Load(d, in1 + x);
56
185k
      auto Third = Load(d, in2 + x);
57
185k
      if (third) Third = Add(Third, First);
58
185k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
185k
      } else if (second == 2) {
61
185k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
185k
      }
63
185k
      Store(First, d, out0 + x);
64
185k
      Store(Second, d, out1 + x);
65
185k
      Store(Third, d, out2 + x);
66
185k
    }
67
185k
  }
68
20.6k
  for (; x < w; x++) {
69
14.9k
    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
14.9k
    } else {
81
14.9k
      pixel_type First = in0[x];
82
14.9k
      pixel_type Second = in1[x];
83
14.9k
      pixel_type Third = in2[x];
84
14.9k
      if (third) Third = PixelAdd(Third, First);
85
14.9k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
14.9k
      } else if (second == 2) {
88
14.9k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
14.9k
      }
90
14.9k
      out0[x] = First;
91
14.9k
      out1[x] = Second;
92
14.9k
      out2[x] = Third;
93
14.9k
    }
94
14.9k
  }
95
5.69k
}
void jxl::N_AVX2::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
18.7k
               pixel_type* out2, size_t w) {
33
18.7k
  static_assert(transform_type >= 0 && transform_type < 7,
34
18.7k
                "Invalid transform type");
35
18.7k
  int second = transform_type >> 1;
36
18.7k
  int third = transform_type & 1;
37
38
18.7k
  size_t x = 0;
39
18.7k
  const HWY_FULL(pixel_type) d;
40
18.7k
  const size_t N = Lanes(d);
41
355k
  for (; x + N - 1 < w; x += N) {
42
337k
    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
337k
    } else {
54
337k
      auto First = Load(d, in0 + x);
55
337k
      auto Second = Load(d, in1 + x);
56
337k
      auto Third = Load(d, in2 + x);
57
337k
      if (third) Third = Add(Third, First);
58
337k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
337k
      } else if (second == 2) {
61
337k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
337k
      }
63
337k
      Store(First, d, out0 + x);
64
337k
      Store(Second, d, out1 + x);
65
337k
      Store(Third, d, out2 + x);
66
337k
    }
67
337k
  }
68
31.4k
  for (; x < w; x++) {
69
12.6k
    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
12.6k
    } else {
81
12.6k
      pixel_type First = in0[x];
82
12.6k
      pixel_type Second = in1[x];
83
12.6k
      pixel_type Third = in2[x];
84
12.6k
      if (third) Third = PixelAdd(Third, First);
85
12.6k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
12.6k
      } else if (second == 2) {
88
12.6k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
12.6k
      }
90
12.6k
      out0[x] = First;
91
12.6k
      out1[x] = Second;
92
12.6k
      out2[x] = Third;
93
12.6k
    }
94
12.6k
  }
95
18.7k
}
void jxl::N_AVX2::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
286k
               pixel_type* out2, size_t w) {
33
286k
  static_assert(transform_type >= 0 && transform_type < 7,
34
286k
                "Invalid transform type");
35
286k
  int second = transform_type >> 1;
36
286k
  int third = transform_type & 1;
37
38
286k
  size_t x = 0;
39
286k
  const HWY_FULL(pixel_type) d;
40
286k
  const size_t N = Lanes(d);
41
2.90M
  for (; x + N - 1 < w; x += N) {
42
2.62M
    if (transform_type == 6) {
43
2.62M
      auto Y = Load(d, in0 + x);
44
2.62M
      auto Co = Load(d, in1 + x);
45
2.62M
      auto Cg = Load(d, in2 + x);
46
2.62M
      Y = Sub(Y, ShiftRight<1>(Cg));
47
2.62M
      auto G = Add(Cg, Y);
48
2.62M
      Y = Sub(Y, ShiftRight<1>(Co));
49
2.62M
      auto R = Add(Y, Co);
50
2.62M
      Store(R, d, out0 + x);
51
2.62M
      Store(G, d, out1 + x);
52
2.62M
      Store(Y, d, out2 + x);
53
2.62M
    } 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
2.62M
  }
68
947k
  for (; x < w; x++) {
69
660k
    if (transform_type == 6) {
70
660k
      pixel_type Y = in0[x];
71
660k
      pixel_type Co = in1[x];
72
660k
      pixel_type Cg = in2[x];
73
660k
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
660k
      pixel_type G = PixelAdd(Cg, tmp);
75
660k
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
660k
      pixel_type R = PixelAdd(B, Co);
77
660k
      out0[x] = R;
78
660k
      out1[x] = G;
79
660k
      out2[x] = B;
80
660k
    } 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
660k
  }
95
286k
}
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
12.7k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
98
12.7k
  JXL_RETURN_IF_ERROR(CheckEqualChannels(input, begin_c, begin_c + 2));
99
12.7k
  size_t m = begin_c;
100
12.7k
  Channel& c0 = input.channel[m + 0];
101
12.7k
  size_t w = c0.w;
102
12.7k
  size_t h = c0.h;
103
12.7k
  if (rct_type == 0) {  // noop
104
5.35k
    return true;
105
5.35k
  }
106
  // Permutation: 0=RGB, 1=GBR, 2=BRG, 3=RBG, 4=GRB, 5=BGR
107
7.39k
  int permutation = rct_type / 7;
108
7.39k
  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
7.39k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
7.39k
  if (custom == 0) {
118
2.32k
    Channel ch0 = std::move(input.channel[m]);
119
2.32k
    Channel ch1 = std::move(input.channel[m + 1]);
120
2.32k
    Channel ch2 = std::move(input.channel[m + 2]);
121
2.32k
    input.channel[m + (permutation % 3)] = std::move(ch0);
122
2.32k
    input.channel[m + ((permutation + 1 + permutation / 3) % 3)] =
123
2.32k
        std::move(ch1);
124
2.32k
    input.channel[m + ((permutation + 2 - permutation / 3) % 3)] =
125
2.32k
        std::move(ch2);
126
2.32k
    return true;
127
2.32k
  }
128
5.07k
  constexpr decltype(&InvRCTRow<0>) inv_rct_row[] = {
129
5.07k
      InvRCTRow<0>, InvRCTRow<1>, InvRCTRow<2>, InvRCTRow<3>,
130
5.07k
      InvRCTRow<4>, InvRCTRow<5>, InvRCTRow<6>};
131
5.07k
  const auto process_row = [&](const uint32_t task,
132
354k
                               size_t /* thread */) -> Status {
133
354k
    const size_t y = task;
134
354k
    const pixel_type* in0 = input.channel[m].Row(y);
135
354k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
354k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
354k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
354k
    pixel_type* out1 =
139
354k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
354k
    pixel_type* out2 =
141
354k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
354k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
354k
    return true;
144
354k
  };
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
354k
                               size_t /* thread */) -> Status {
133
354k
    const size_t y = task;
134
354k
    const pixel_type* in0 = input.channel[m].Row(y);
135
354k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
354k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
354k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
354k
    pixel_type* out1 =
139
354k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
354k
    pixel_type* out2 =
141
354k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
354k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
354k
    return true;
144
354k
  };
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
5.07k
  JXL_RETURN_IF_ERROR(
146
5.07k
      RunOnPool(pool, 0, h, ThreadPool::NoInit, process_row, "InvRCT"));
147
5.07k
  return true;
148
5.07k
}
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
12.7k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
98
12.7k
  JXL_RETURN_IF_ERROR(CheckEqualChannels(input, begin_c, begin_c + 2));
99
12.7k
  size_t m = begin_c;
100
12.7k
  Channel& c0 = input.channel[m + 0];
101
12.7k
  size_t w = c0.w;
102
12.7k
  size_t h = c0.h;
103
12.7k
  if (rct_type == 0) {  // noop
104
5.35k
    return true;
105
5.35k
  }
106
  // Permutation: 0=RGB, 1=GBR, 2=BRG, 3=RBG, 4=GRB, 5=BGR
107
7.39k
  int permutation = rct_type / 7;
108
7.39k
  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
7.39k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
7.39k
  if (custom == 0) {
118
2.32k
    Channel ch0 = std::move(input.channel[m]);
119
2.32k
    Channel ch1 = std::move(input.channel[m + 1]);
120
2.32k
    Channel ch2 = std::move(input.channel[m + 2]);
121
2.32k
    input.channel[m + (permutation % 3)] = std::move(ch0);
122
2.32k
    input.channel[m + ((permutation + 1 + permutation / 3) % 3)] =
123
2.32k
        std::move(ch1);
124
2.32k
    input.channel[m + ((permutation + 2 - permutation / 3) % 3)] =
125
2.32k
        std::move(ch2);
126
2.32k
    return true;
127
2.32k
  }
128
5.07k
  constexpr decltype(&InvRCTRow<0>) inv_rct_row[] = {
129
5.07k
      InvRCTRow<0>, InvRCTRow<1>, InvRCTRow<2>, InvRCTRow<3>,
130
5.07k
      InvRCTRow<4>, InvRCTRow<5>, InvRCTRow<6>};
131
5.07k
  const auto process_row = [&](const uint32_t task,
132
5.07k
                               size_t /* thread */) -> Status {
133
5.07k
    const size_t y = task;
134
5.07k
    const pixel_type* in0 = input.channel[m].Row(y);
135
5.07k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
5.07k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
5.07k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
5.07k
    pixel_type* out1 =
139
5.07k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
5.07k
    pixel_type* out2 =
141
5.07k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
5.07k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
5.07k
    return true;
144
5.07k
  };
145
5.07k
  JXL_RETURN_IF_ERROR(
146
5.07k
      RunOnPool(pool, 0, h, ThreadPool::NoInit, process_row, "InvRCT"));
147
5.07k
  return true;
148
5.07k
}
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
12.7k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
159
12.7k
  return HWY_DYNAMIC_DISPATCH(InvRCT)(input, begin_c, rct_type, pool);
160
12.7k
}
161
162
}  // namespace jxl
163
#endif