Coverage Report

Created: 2026-09-06 07:31

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
377k
               pixel_type* out2, size_t w) {
33
377k
  static_assert(transform_type >= 0 && transform_type < 7,
34
377k
                "Invalid transform type");
35
377k
  int second = transform_type >> 1;
36
377k
  int third = transform_type & 1;
37
38
377k
  size_t x = 0;
39
377k
  const HWY_FULL(pixel_type) d;
40
377k
  const size_t N = Lanes(d);
41
4.25M
  for (; x + N - 1 < w; x += N) {
42
3.87M
    if (transform_type == 6) {
43
2.57M
      auto Y = Load(d, in0 + x);
44
2.57M
      auto Co = Load(d, in1 + x);
45
2.57M
      auto Cg = Load(d, in2 + x);
46
2.57M
      Y = Sub(Y, ShiftRight<1>(Cg));
47
2.57M
      auto G = Add(Cg, Y);
48
2.57M
      Y = Sub(Y, ShiftRight<1>(Co));
49
2.57M
      auto R = Add(Y, Co);
50
2.57M
      Store(R, d, out0 + x);
51
2.57M
      Store(G, d, out1 + x);
52
2.57M
      Store(Y, d, out2 + x);
53
2.57M
    } else {
54
1.30M
      auto First = Load(d, in0 + x);
55
1.30M
      auto Second = Load(d, in1 + x);
56
1.30M
      auto Third = Load(d, in2 + x);
57
1.30M
      if (third) Third = Add(Third, First);
58
1.30M
      if (second == 1) {
59
704k
        Second = Add(Second, First);
60
704k
      } else if (second == 2) {
61
515k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
515k
      }
63
1.30M
      Store(First, d, out0 + x);
64
1.30M
      Store(Second, d, out1 + x);
65
1.30M
      Store(Third, d, out2 + x);
66
1.30M
    }
67
3.87M
  }
68
1.27M
  for (; x < w; x++) {
69
894k
    if (transform_type == 6) {
70
817k
      pixel_type Y = in0[x];
71
817k
      pixel_type Co = in1[x];
72
817k
      pixel_type Cg = in2[x];
73
817k
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
817k
      pixel_type G = PixelAdd(Cg, tmp);
75
817k
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
817k
      pixel_type R = PixelAdd(B, Co);
77
817k
      out0[x] = R;
78
817k
      out1[x] = G;
79
817k
      out2[x] = B;
80
817k
    } else {
81
77.2k
      pixel_type First = in0[x];
82
77.2k
      pixel_type Second = in1[x];
83
77.2k
      pixel_type Third = in2[x];
84
77.2k
      if (third) Third = PixelAdd(Third, First);
85
77.2k
      if (second == 1) {
86
42.2k
        Second = PixelAdd(Second, First);
87
42.2k
      } else if (second == 2) {
88
23.0k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
23.0k
      }
90
77.2k
      out0[x] = First;
91
77.2k
      out1[x] = Second;
92
77.2k
      out2[x] = Third;
93
77.2k
    }
94
894k
  }
95
377k
}
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
6.10k
               pixel_type* out2, size_t w) {
33
6.10k
  static_assert(transform_type >= 0 && transform_type < 7,
34
6.10k
                "Invalid transform type");
35
6.10k
  int second = transform_type >> 1;
36
6.10k
  int third = transform_type & 1;
37
38
6.10k
  size_t x = 0;
39
6.10k
  const HWY_FULL(pixel_type) d;
40
6.10k
  const size_t N = Lanes(d);
41
90.5k
  for (; x + N - 1 < w; x += N) {
42
84.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
84.4k
    } else {
54
84.4k
      auto First = Load(d, in0 + x);
55
84.4k
      auto Second = Load(d, in1 + x);
56
84.4k
      auto Third = Load(d, in2 + x);
57
84.4k
      if (third) Third = Add(Third, First);
58
84.4k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
84.4k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
84.4k
      Store(First, d, out0 + x);
64
84.4k
      Store(Second, d, out1 + x);
65
84.4k
      Store(Third, d, out2 + x);
66
84.4k
    }
67
84.4k
  }
68
18.1k
  for (; x < w; x++) {
69
12.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
12.0k
    } else {
81
12.0k
      pixel_type First = in0[x];
82
12.0k
      pixel_type Second = in1[x];
83
12.0k
      pixel_type Third = in2[x];
84
12.0k
      if (third) Third = PixelAdd(Third, First);
85
12.0k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
12.0k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
12.0k
      out0[x] = First;
91
12.0k
      out1[x] = Second;
92
12.0k
      out2[x] = Third;
93
12.0k
    }
94
12.0k
  }
95
6.10k
}
void jxl::N_AVX2::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
5.29k
               pixel_type* out2, size_t w) {
33
5.29k
  static_assert(transform_type >= 0 && transform_type < 7,
34
5.29k
                "Invalid transform type");
35
5.29k
  int second = transform_type >> 1;
36
5.29k
  int third = transform_type & 1;
37
38
5.29k
  size_t x = 0;
39
5.29k
  const HWY_FULL(pixel_type) d;
40
5.29k
  const size_t N = Lanes(d);
41
81.5k
  for (; x + N - 1 < w; x += N) {
42
76.2k
    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
76.2k
    } else {
54
76.2k
      auto First = Load(d, in0 + x);
55
76.2k
      auto Second = Load(d, in1 + x);
56
76.2k
      auto Third = Load(d, in2 + x);
57
76.2k
      if (third) Third = Add(Third, First);
58
76.2k
      if (second == 1) {
59
76.2k
        Second = Add(Second, First);
60
76.2k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
76.2k
      Store(First, d, out0 + x);
64
76.2k
      Store(Second, d, out1 + x);
65
76.2k
      Store(Third, d, out2 + x);
66
76.2k
    }
67
76.2k
  }
68
14.6k
  for (; x < w; x++) {
69
9.36k
    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
9.36k
    } else {
81
9.36k
      pixel_type First = in0[x];
82
9.36k
      pixel_type Second = in1[x];
83
9.36k
      pixel_type Third = in2[x];
84
9.36k
      if (third) Third = PixelAdd(Third, First);
85
9.36k
      if (second == 1) {
86
9.36k
        Second = PixelAdd(Second, First);
87
9.36k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
9.36k
      out0[x] = First;
91
9.36k
      out1[x] = Second;
92
9.36k
      out2[x] = Third;
93
9.36k
    }
94
9.36k
  }
95
5.29k
}
void jxl::N_AVX2::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
28.2k
               pixel_type* out2, size_t w) {
33
28.2k
  static_assert(transform_type >= 0 && transform_type < 7,
34
28.2k
                "Invalid transform type");
35
28.2k
  int second = transform_type >> 1;
36
28.2k
  int third = transform_type & 1;
37
38
28.2k
  size_t x = 0;
39
28.2k
  const HWY_FULL(pixel_type) d;
40
28.2k
  const size_t N = Lanes(d);
41
656k
  for (; x + N - 1 < w; x += N) {
42
628k
    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
628k
    } else {
54
628k
      auto First = Load(d, in0 + x);
55
628k
      auto Second = Load(d, in1 + x);
56
628k
      auto Third = Load(d, in2 + x);
57
628k
      if (third) Third = Add(Third, First);
58
628k
      if (second == 1) {
59
628k
        Second = Add(Second, First);
60
628k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
628k
      Store(First, d, out0 + x);
64
628k
      Store(Second, d, out1 + x);
65
628k
      Store(Third, d, out2 + x);
66
628k
    }
67
628k
  }
68
61.1k
  for (; x < w; x++) {
69
32.8k
    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
32.8k
    } else {
81
32.8k
      pixel_type First = in0[x];
82
32.8k
      pixel_type Second = in1[x];
83
32.8k
      pixel_type Third = in2[x];
84
32.8k
      if (third) Third = PixelAdd(Third, First);
85
32.8k
      if (second == 1) {
86
32.8k
        Second = PixelAdd(Second, First);
87
32.8k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
32.8k
      out0[x] = First;
91
32.8k
      out1[x] = Second;
92
32.8k
      out2[x] = Third;
93
32.8k
    }
94
32.8k
  }
95
28.2k
}
void jxl::N_AVX2::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
5.42k
               pixel_type* out2, size_t w) {
33
5.42k
  static_assert(transform_type >= 0 && transform_type < 7,
34
5.42k
                "Invalid transform type");
35
5.42k
  int second = transform_type >> 1;
36
5.42k
  int third = transform_type & 1;
37
38
5.42k
  size_t x = 0;
39
5.42k
  const HWY_FULL(pixel_type) d;
40
5.42k
  const size_t N = Lanes(d);
41
197k
  for (; x + N - 1 < w; x += N) {
42
192k
    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
192k
    } else {
54
192k
      auto First = Load(d, in0 + x);
55
192k
      auto Second = Load(d, in1 + x);
56
192k
      auto Third = Load(d, in2 + x);
57
192k
      if (third) Third = Add(Third, First);
58
192k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
192k
      } else if (second == 2) {
61
192k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
192k
      }
63
192k
      Store(First, d, out0 + x);
64
192k
      Store(Second, d, out1 + x);
65
192k
      Store(Third, d, out2 + x);
66
192k
    }
67
192k
  }
68
17.8k
  for (; x < w; x++) {
69
12.4k
    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.4k
    } else {
81
12.4k
      pixel_type First = in0[x];
82
12.4k
      pixel_type Second = in1[x];
83
12.4k
      pixel_type Third = in2[x];
84
12.4k
      if (third) Third = PixelAdd(Third, First);
85
12.4k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
12.4k
      } else if (second == 2) {
88
12.4k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
12.4k
      }
90
12.4k
      out0[x] = First;
91
12.4k
      out1[x] = Second;
92
12.4k
      out2[x] = Third;
93
12.4k
    }
94
12.4k
  }
95
5.42k
}
void jxl::N_AVX2::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
18.0k
               pixel_type* out2, size_t w) {
33
18.0k
  static_assert(transform_type >= 0 && transform_type < 7,
34
18.0k
                "Invalid transform type");
35
18.0k
  int second = transform_type >> 1;
36
18.0k
  int third = transform_type & 1;
37
38
18.0k
  size_t x = 0;
39
18.0k
  const HWY_FULL(pixel_type) d;
40
18.0k
  const size_t N = Lanes(d);
41
341k
  for (; x + N - 1 < w; x += N) {
42
323k
    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
323k
    } else {
54
323k
      auto First = Load(d, in0 + x);
55
323k
      auto Second = Load(d, in1 + x);
56
323k
      auto Third = Load(d, in2 + x);
57
323k
      if (third) Third = Add(Third, First);
58
323k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
323k
      } else if (second == 2) {
61
323k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
323k
      }
63
323k
      Store(First, d, out0 + x);
64
323k
      Store(Second, d, out1 + x);
65
323k
      Store(Third, d, out2 + x);
66
323k
    }
67
323k
  }
68
28.5k
  for (; x < w; x++) {
69
10.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
10.5k
    } else {
81
10.5k
      pixel_type First = in0[x];
82
10.5k
      pixel_type Second = in1[x];
83
10.5k
      pixel_type Third = in2[x];
84
10.5k
      if (third) Third = PixelAdd(Third, First);
85
10.5k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
10.5k
      } else if (second == 2) {
88
10.5k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
10.5k
      }
90
10.5k
      out0[x] = First;
91
10.5k
      out1[x] = Second;
92
10.5k
      out2[x] = Third;
93
10.5k
    }
94
10.5k
  }
95
18.0k
}
void jxl::N_AVX2::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
313k
               pixel_type* out2, size_t w) {
33
313k
  static_assert(transform_type >= 0 && transform_type < 7,
34
313k
                "Invalid transform type");
35
313k
  int second = transform_type >> 1;
36
313k
  int third = transform_type & 1;
37
38
313k
  size_t x = 0;
39
313k
  const HWY_FULL(pixel_type) d;
40
313k
  const size_t N = Lanes(d);
41
2.88M
  for (; x + N - 1 < w; x += N) {
42
2.57M
    if (transform_type == 6) {
43
2.57M
      auto Y = Load(d, in0 + x);
44
2.57M
      auto Co = Load(d, in1 + x);
45
2.57M
      auto Cg = Load(d, in2 + x);
46
2.57M
      Y = Sub(Y, ShiftRight<1>(Cg));
47
2.57M
      auto G = Add(Cg, Y);
48
2.57M
      Y = Sub(Y, ShiftRight<1>(Co));
49
2.57M
      auto R = Add(Y, Co);
50
2.57M
      Store(R, d, out0 + x);
51
2.57M
      Store(G, d, out1 + x);
52
2.57M
      Store(Y, d, out2 + x);
53
2.57M
    } 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.57M
  }
68
1.13M
  for (; x < w; x++) {
69
817k
    if (transform_type == 6) {
70
817k
      pixel_type Y = in0[x];
71
817k
      pixel_type Co = in1[x];
72
817k
      pixel_type Cg = in2[x];
73
817k
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
817k
      pixel_type G = PixelAdd(Cg, tmp);
75
817k
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
817k
      pixel_type R = PixelAdd(B, Co);
77
817k
      out0[x] = R;
78
817k
      out1[x] = G;
79
817k
      out2[x] = B;
80
817k
    } 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
817k
  }
95
313k
}
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.2k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
98
12.2k
  JXL_RETURN_IF_ERROR(CheckEqualChannels(input, begin_c, begin_c + 2));
99
12.2k
  size_t m = begin_c;
100
12.2k
  Channel& c0 = input.channel[m + 0];
101
12.2k
  size_t w = c0.w;
102
12.2k
  size_t h = c0.h;
103
12.2k
  if (rct_type == 0) {  // noop
104
5.11k
    return true;
105
5.11k
  }
106
  // Permutation: 0=RGB, 1=GBR, 2=BRG, 3=RBG, 4=GRB, 5=BGR
107
7.13k
  int permutation = rct_type / 7;
108
7.13k
  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.13k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
7.13k
  if (custom == 0) {
118
1.81k
    Channel ch0 = std::move(input.channel[m]);
119
1.81k
    Channel ch1 = std::move(input.channel[m + 1]);
120
1.81k
    Channel ch2 = std::move(input.channel[m + 2]);
121
1.81k
    input.channel[m + (permutation % 3)] = std::move(ch0);
122
1.81k
    input.channel[m + ((permutation + 1 + permutation / 3) % 3)] =
123
1.81k
        std::move(ch1);
124
1.81k
    input.channel[m + ((permutation + 2 - permutation / 3) % 3)] =
125
1.81k
        std::move(ch2);
126
1.81k
    return true;
127
1.81k
  }
128
5.31k
  constexpr decltype(&InvRCTRow<0>) inv_rct_row[] = {
129
5.31k
      InvRCTRow<0>, InvRCTRow<1>, InvRCTRow<2>, InvRCTRow<3>,
130
5.31k
      InvRCTRow<4>, InvRCTRow<5>, InvRCTRow<6>};
131
5.31k
  const auto process_row = [&](const uint32_t task,
132
377k
                               size_t /* thread */) -> Status {
133
377k
    const size_t y = task;
134
377k
    const pixel_type* in0 = input.channel[m].Row(y);
135
377k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
377k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
377k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
377k
    pixel_type* out1 =
139
377k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
377k
    pixel_type* out2 =
141
377k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
377k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
377k
    return true;
144
377k
  };
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
377k
                               size_t /* thread */) -> Status {
133
377k
    const size_t y = task;
134
377k
    const pixel_type* in0 = input.channel[m].Row(y);
135
377k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
377k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
377k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
377k
    pixel_type* out1 =
139
377k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
377k
    pixel_type* out2 =
141
377k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
377k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
377k
    return true;
144
377k
  };
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.31k
  JXL_RETURN_IF_ERROR(
146
5.31k
      RunOnPool(pool, 0, h, ThreadPool::NoInit, process_row, "InvRCT"));
147
5.31k
  return true;
148
5.31k
}
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.2k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
98
12.2k
  JXL_RETURN_IF_ERROR(CheckEqualChannels(input, begin_c, begin_c + 2));
99
12.2k
  size_t m = begin_c;
100
12.2k
  Channel& c0 = input.channel[m + 0];
101
12.2k
  size_t w = c0.w;
102
12.2k
  size_t h = c0.h;
103
12.2k
  if (rct_type == 0) {  // noop
104
5.11k
    return true;
105
5.11k
  }
106
  // Permutation: 0=RGB, 1=GBR, 2=BRG, 3=RBG, 4=GRB, 5=BGR
107
7.13k
  int permutation = rct_type / 7;
108
7.13k
  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.13k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
7.13k
  if (custom == 0) {
118
1.81k
    Channel ch0 = std::move(input.channel[m]);
119
1.81k
    Channel ch1 = std::move(input.channel[m + 1]);
120
1.81k
    Channel ch2 = std::move(input.channel[m + 2]);
121
1.81k
    input.channel[m + (permutation % 3)] = std::move(ch0);
122
1.81k
    input.channel[m + ((permutation + 1 + permutation / 3) % 3)] =
123
1.81k
        std::move(ch1);
124
1.81k
    input.channel[m + ((permutation + 2 - permutation / 3) % 3)] =
125
1.81k
        std::move(ch2);
126
1.81k
    return true;
127
1.81k
  }
128
5.31k
  constexpr decltype(&InvRCTRow<0>) inv_rct_row[] = {
129
5.31k
      InvRCTRow<0>, InvRCTRow<1>, InvRCTRow<2>, InvRCTRow<3>,
130
5.31k
      InvRCTRow<4>, InvRCTRow<5>, InvRCTRow<6>};
131
5.31k
  const auto process_row = [&](const uint32_t task,
132
5.31k
                               size_t /* thread */) -> Status {
133
5.31k
    const size_t y = task;
134
5.31k
    const pixel_type* in0 = input.channel[m].Row(y);
135
5.31k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
5.31k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
5.31k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
5.31k
    pixel_type* out1 =
139
5.31k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
5.31k
    pixel_type* out2 =
141
5.31k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
5.31k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
5.31k
    return true;
144
5.31k
  };
145
5.31k
  JXL_RETURN_IF_ERROR(
146
5.31k
      RunOnPool(pool, 0, h, ThreadPool::NoInit, process_row, "InvRCT"));
147
5.31k
  return true;
148
5.31k
}
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.2k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
159
12.2k
  return HWY_DYNAMIC_DISPATCH(InvRCT)(input, begin_c, rct_type, pool);
160
12.2k
}
161
162
}  // namespace jxl
163
#endif