Coverage Report

Created: 2025-07-23 08:18

/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
106k
               pixel_type* out2, size_t w) {
33
106k
  static_assert(transform_type >= 0 && transform_type < 7,
34
106k
                "Invalid transform type");
35
106k
  int second = transform_type >> 1;
36
106k
  int third = transform_type & 1;
37
38
106k
  size_t x = 0;
39
106k
  const HWY_FULL(pixel_type) d;
40
106k
  const size_t N = Lanes(d);
41
409k
  for (; x + N - 1 < w; x += N) {
42
302k
    if (transform_type == 6) {
43
200k
      auto Y = Load(d, in0 + x);
44
200k
      auto Co = Load(d, in1 + x);
45
200k
      auto Cg = Load(d, in2 + x);
46
200k
      Y = Sub(Y, ShiftRight<1>(Cg));
47
200k
      auto G = Add(Cg, Y);
48
200k
      Y = Sub(Y, ShiftRight<1>(Co));
49
200k
      auto R = Add(Y, Co);
50
200k
      Store(R, d, out0 + x);
51
200k
      Store(G, d, out1 + x);
52
200k
      Store(Y, d, out2 + x);
53
200k
    } else {
54
102k
      auto First = Load(d, in0 + x);
55
102k
      auto Second = Load(d, in1 + x);
56
102k
      auto Third = Load(d, in2 + x);
57
102k
      if (third) Third = Add(Third, First);
58
102k
      if (second == 1) {
59
55.8k
        Second = Add(Second, First);
60
55.8k
      } else if (second == 2) {
61
35.7k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
35.7k
      }
63
102k
      Store(First, d, out0 + x);
64
102k
      Store(Second, d, out1 + x);
65
102k
      Store(Third, d, out2 + x);
66
102k
    }
67
302k
  }
68
631k
  for (; x < w; x++) {
69
525k
    if (transform_type == 6) {
70
491k
      pixel_type Y = in0[x];
71
491k
      pixel_type Co = in1[x];
72
491k
      pixel_type Cg = in2[x];
73
491k
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
491k
      pixel_type G = PixelAdd(Cg, tmp);
75
491k
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
491k
      pixel_type R = PixelAdd(B, Co);
77
491k
      out0[x] = R;
78
491k
      out1[x] = G;
79
491k
      out2[x] = B;
80
491k
    } else {
81
34.0k
      pixel_type First = in0[x];
82
34.0k
      pixel_type Second = in1[x];
83
34.0k
      pixel_type Third = in2[x];
84
34.0k
      if (third) Third = PixelAdd(Third, First);
85
34.0k
      if (second == 1) {
86
12.6k
        Second = PixelAdd(Second, First);
87
21.4k
      } else if (second == 2) {
88
16.7k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
16.7k
      }
90
34.0k
      out0[x] = First;
91
34.0k
      out1[x] = Second;
92
34.0k
      out2[x] = Third;
93
34.0k
    }
94
525k
  }
95
106k
}
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
2.09k
               pixel_type* out2, size_t w) {
33
2.09k
  static_assert(transform_type >= 0 && transform_type < 7,
34
2.09k
                "Invalid transform type");
35
2.09k
  int second = transform_type >> 1;
36
2.09k
  int third = transform_type & 1;
37
38
2.09k
  size_t x = 0;
39
2.09k
  const HWY_FULL(pixel_type) d;
40
2.09k
  const size_t N = Lanes(d);
41
13.0k
  for (; x + N - 1 < w; x += N) {
42
10.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
10.9k
    } else {
54
10.9k
      auto First = Load(d, in0 + x);
55
10.9k
      auto Second = Load(d, in1 + x);
56
10.9k
      auto Third = Load(d, in2 + x);
57
10.9k
      if (third) Third = Add(Third, First);
58
10.9k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
10.9k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
10.9k
      Store(First, d, out0 + x);
64
10.9k
      Store(Second, d, out1 + x);
65
10.9k
      Store(Third, d, out2 + x);
66
10.9k
    }
67
10.9k
  }
68
6.74k
  for (; x < w; x++) {
69
4.64k
    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
4.64k
    } else {
81
4.64k
      pixel_type First = in0[x];
82
4.64k
      pixel_type Second = in1[x];
83
4.64k
      pixel_type Third = in2[x];
84
4.64k
      if (third) Third = PixelAdd(Third, First);
85
4.64k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
4.64k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
4.64k
      out0[x] = First;
91
4.64k
      out1[x] = Second;
92
4.64k
      out2[x] = Third;
93
4.64k
    }
94
4.64k
  }
95
2.09k
}
void jxl::N_AVX2::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
1.51k
               pixel_type* out2, size_t w) {
33
1.51k
  static_assert(transform_type >= 0 && transform_type < 7,
34
1.51k
                "Invalid transform type");
35
1.51k
  int second = transform_type >> 1;
36
1.51k
  int third = transform_type & 1;
37
38
1.51k
  size_t x = 0;
39
1.51k
  const HWY_FULL(pixel_type) d;
40
1.51k
  const size_t N = Lanes(d);
41
6.32k
  for (; x + N - 1 < w; x += N) {
42
4.81k
    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
4.81k
    } else {
54
4.81k
      auto First = Load(d, in0 + x);
55
4.81k
      auto Second = Load(d, in1 + x);
56
4.81k
      auto Third = Load(d, in2 + x);
57
4.81k
      if (third) Third = Add(Third, First);
58
4.81k
      if (second == 1) {
59
4.81k
        Second = Add(Second, First);
60
4.81k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
4.81k
      Store(First, d, out0 + x);
64
4.81k
      Store(Second, d, out1 + x);
65
4.81k
      Store(Third, d, out2 + x);
66
4.81k
    }
67
4.81k
  }
68
3.96k
  for (; x < w; x++) {
69
2.45k
    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.45k
    } else {
81
2.45k
      pixel_type First = in0[x];
82
2.45k
      pixel_type Second = in1[x];
83
2.45k
      pixel_type Third = in2[x];
84
2.45k
      if (third) Third = PixelAdd(Third, First);
85
2.45k
      if (second == 1) {
86
2.45k
        Second = PixelAdd(Second, First);
87
2.45k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
2.45k
      out0[x] = First;
91
2.45k
      out1[x] = Second;
92
2.45k
      out2[x] = Third;
93
2.45k
    }
94
2.45k
  }
95
1.51k
}
void jxl::N_AVX2::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
4.48k
               pixel_type* out2, size_t w) {
33
4.48k
  static_assert(transform_type >= 0 && transform_type < 7,
34
4.48k
                "Invalid transform type");
35
4.48k
  int second = transform_type >> 1;
36
4.48k
  int third = transform_type & 1;
37
38
4.48k
  size_t x = 0;
39
4.48k
  const HWY_FULL(pixel_type) d;
40
4.48k
  const size_t N = Lanes(d);
41
55.5k
  for (; x + N - 1 < w; x += N) {
42
51.0k
    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
51.0k
    } else {
54
51.0k
      auto First = Load(d, in0 + x);
55
51.0k
      auto Second = Load(d, in1 + x);
56
51.0k
      auto Third = Load(d, in2 + x);
57
51.0k
      if (third) Third = Add(Third, First);
58
51.0k
      if (second == 1) {
59
51.0k
        Second = Add(Second, First);
60
51.0k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
51.0k
      Store(First, d, out0 + x);
64
51.0k
      Store(Second, d, out1 + x);
65
51.0k
      Store(Third, d, out2 + x);
66
51.0k
    }
67
51.0k
  }
68
14.6k
  for (; x < w; x++) {
69
10.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
10.1k
    } else {
81
10.1k
      pixel_type First = in0[x];
82
10.1k
      pixel_type Second = in1[x];
83
10.1k
      pixel_type Third = in2[x];
84
10.1k
      if (third) Third = PixelAdd(Third, First);
85
10.1k
      if (second == 1) {
86
10.1k
        Second = PixelAdd(Second, First);
87
10.1k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
10.1k
      out0[x] = First;
91
10.1k
      out1[x] = Second;
92
10.1k
      out2[x] = Third;
93
10.1k
    }
94
10.1k
  }
95
4.48k
}
void jxl::N_AVX2::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
2.16k
               pixel_type* out2, size_t w) {
33
2.16k
  static_assert(transform_type >= 0 && transform_type < 7,
34
2.16k
                "Invalid transform type");
35
2.16k
  int second = transform_type >> 1;
36
2.16k
  int third = transform_type & 1;
37
38
2.16k
  size_t x = 0;
39
2.16k
  const HWY_FULL(pixel_type) d;
40
2.16k
  const size_t N = Lanes(d);
41
24.5k
  for (; x + N - 1 < w; x += N) {
42
22.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
22.4k
    } else {
54
22.4k
      auto First = Load(d, in0 + x);
55
22.4k
      auto Second = Load(d, in1 + x);
56
22.4k
      auto Third = Load(d, in2 + x);
57
22.4k
      if (third) Third = Add(Third, First);
58
22.4k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
22.4k
      } else if (second == 2) {
61
22.4k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
22.4k
      }
63
22.4k
      Store(First, d, out0 + x);
64
22.4k
      Store(Second, d, out1 + x);
65
22.4k
      Store(Third, d, out2 + x);
66
22.4k
    }
67
22.4k
  }
68
3.44k
  for (; x < w; x++) {
69
1.28k
    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
1.28k
    } else {
81
1.28k
      pixel_type First = in0[x];
82
1.28k
      pixel_type Second = in1[x];
83
1.28k
      pixel_type Third = in2[x];
84
1.28k
      if (third) Third = PixelAdd(Third, First);
85
1.28k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
1.28k
      } else if (second == 2) {
88
1.28k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
1.28k
      }
90
1.28k
      out0[x] = First;
91
1.28k
      out1[x] = Second;
92
1.28k
      out2[x] = Third;
93
1.28k
    }
94
1.28k
  }
95
2.16k
}
void jxl::N_AVX2::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
6.54k
               pixel_type* out2, size_t w) {
33
6.54k
  static_assert(transform_type >= 0 && transform_type < 7,
34
6.54k
                "Invalid transform type");
35
6.54k
  int second = transform_type >> 1;
36
6.54k
  int third = transform_type & 1;
37
38
6.54k
  size_t x = 0;
39
6.54k
  const HWY_FULL(pixel_type) d;
40
6.54k
  const size_t N = Lanes(d);
41
19.8k
  for (; x + N - 1 < w; x += N) {
42
13.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
13.3k
    } else {
54
13.3k
      auto First = Load(d, in0 + x);
55
13.3k
      auto Second = Load(d, in1 + x);
56
13.3k
      auto Third = Load(d, in2 + x);
57
13.3k
      if (third) Third = Add(Third, First);
58
13.3k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
13.3k
      } else if (second == 2) {
61
13.3k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
13.3k
      }
63
13.3k
      Store(First, d, out0 + x);
64
13.3k
      Store(Second, d, out1 + x);
65
13.3k
      Store(Third, d, out2 + x);
66
13.3k
    }
67
13.3k
  }
68
22.0k
  for (; x < w; x++) {
69
15.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
15.4k
    } else {
81
15.4k
      pixel_type First = in0[x];
82
15.4k
      pixel_type Second = in1[x];
83
15.4k
      pixel_type Third = in2[x];
84
15.4k
      if (third) Third = PixelAdd(Third, First);
85
15.4k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
15.4k
      } else if (second == 2) {
88
15.4k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
15.4k
      }
90
15.4k
      out0[x] = First;
91
15.4k
      out1[x] = Second;
92
15.4k
      out2[x] = Third;
93
15.4k
    }
94
15.4k
  }
95
6.54k
}
void jxl::N_AVX2::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
89.8k
               pixel_type* out2, size_t w) {
33
89.8k
  static_assert(transform_type >= 0 && transform_type < 7,
34
89.8k
                "Invalid transform type");
35
89.8k
  int second = transform_type >> 1;
36
89.8k
  int third = transform_type & 1;
37
38
89.8k
  size_t x = 0;
39
89.8k
  const HWY_FULL(pixel_type) d;
40
89.8k
  const size_t N = Lanes(d);
41
289k
  for (; x + N - 1 < w; x += N) {
42
200k
    if (transform_type == 6) {
43
200k
      auto Y = Load(d, in0 + x);
44
200k
      auto Co = Load(d, in1 + x);
45
200k
      auto Cg = Load(d, in2 + x);
46
200k
      Y = Sub(Y, ShiftRight<1>(Cg));
47
200k
      auto G = Add(Cg, Y);
48
200k
      Y = Sub(Y, ShiftRight<1>(Co));
49
200k
      auto R = Add(Y, Co);
50
200k
      Store(R, d, out0 + x);
51
200k
      Store(G, d, out1 + x);
52
200k
      Store(Y, d, out2 + x);
53
200k
    } 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
200k
  }
68
580k
  for (; x < w; x++) {
69
491k
    if (transform_type == 6) {
70
491k
      pixel_type Y = in0[x];
71
491k
      pixel_type Co = in1[x];
72
491k
      pixel_type Cg = in2[x];
73
491k
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
491k
      pixel_type G = PixelAdd(Cg, tmp);
75
491k
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
491k
      pixel_type R = PixelAdd(B, Co);
77
491k
      out0[x] = R;
78
491k
      out1[x] = G;
79
491k
      out2[x] = B;
80
491k
    } 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
491k
  }
95
89.8k
}
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
1.78k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
98
1.78k
  JXL_RETURN_IF_ERROR(CheckEqualChannels(input, begin_c, begin_c + 2));
99
1.78k
  size_t m = begin_c;
100
1.78k
  Channel& c0 = input.channel[m + 0];
101
1.78k
  size_t w = c0.w;
102
1.78k
  size_t h = c0.h;
103
1.78k
  if (rct_type == 0) {  // noop
104
42
    return true;
105
42
  }
106
  // Permutation: 0=RGB, 1=GBR, 2=BRG, 3=RBG, 4=GRB, 5=BGR
107
1.73k
  int permutation = rct_type / 7;
108
1.73k
  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
1.73k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
1.73k
  if (custom == 0) {
118
61
    Channel ch0 = std::move(input.channel[m]);
119
61
    Channel ch1 = std::move(input.channel[m + 1]);
120
61
    Channel ch2 = std::move(input.channel[m + 2]);
121
61
    input.channel[m + (permutation % 3)] = std::move(ch0);
122
61
    input.channel[m + ((permutation + 1 + permutation / 3) % 3)] =
123
61
        std::move(ch1);
124
61
    input.channel[m + ((permutation + 2 - permutation / 3) % 3)] =
125
61
        std::move(ch2);
126
61
    return true;
127
61
  }
128
1.67k
  constexpr decltype(&InvRCTRow<0>) inv_rct_row[] = {
129
1.67k
      InvRCTRow<0>, InvRCTRow<1>, InvRCTRow<2>, InvRCTRow<3>,
130
1.67k
      InvRCTRow<4>, InvRCTRow<5>, InvRCTRow<6>};
131
1.67k
  const auto process_row = [&](const uint32_t task,
132
106k
                               size_t /* thread */) -> Status {
133
106k
    const size_t y = task;
134
106k
    const pixel_type* in0 = input.channel[m].Row(y);
135
106k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
106k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
106k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
106k
    pixel_type* out1 =
139
106k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
106k
    pixel_type* out2 =
141
106k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
106k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
106k
    return true;
144
106k
  };
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
106k
                               size_t /* thread */) -> Status {
133
106k
    const size_t y = task;
134
106k
    const pixel_type* in0 = input.channel[m].Row(y);
135
106k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
106k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
106k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
106k
    pixel_type* out1 =
139
106k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
106k
    pixel_type* out2 =
141
106k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
106k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
106k
    return true;
144
106k
  };
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
1.67k
  JXL_RETURN_IF_ERROR(
146
1.67k
      RunOnPool(pool, 0, h, ThreadPool::NoInit, process_row, "InvRCT"));
147
1.67k
  return true;
148
1.67k
}
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
1.78k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
98
1.78k
  JXL_RETURN_IF_ERROR(CheckEqualChannels(input, begin_c, begin_c + 2));
99
1.78k
  size_t m = begin_c;
100
1.78k
  Channel& c0 = input.channel[m + 0];
101
1.78k
  size_t w = c0.w;
102
1.78k
  size_t h = c0.h;
103
1.78k
  if (rct_type == 0) {  // noop
104
42
    return true;
105
42
  }
106
  // Permutation: 0=RGB, 1=GBR, 2=BRG, 3=RBG, 4=GRB, 5=BGR
107
1.73k
  int permutation = rct_type / 7;
108
1.73k
  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
1.73k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
1.73k
  if (custom == 0) {
118
61
    Channel ch0 = std::move(input.channel[m]);
119
61
    Channel ch1 = std::move(input.channel[m + 1]);
120
61
    Channel ch2 = std::move(input.channel[m + 2]);
121
61
    input.channel[m + (permutation % 3)] = std::move(ch0);
122
61
    input.channel[m + ((permutation + 1 + permutation / 3) % 3)] =
123
61
        std::move(ch1);
124
61
    input.channel[m + ((permutation + 2 - permutation / 3) % 3)] =
125
61
        std::move(ch2);
126
61
    return true;
127
61
  }
128
1.67k
  constexpr decltype(&InvRCTRow<0>) inv_rct_row[] = {
129
1.67k
      InvRCTRow<0>, InvRCTRow<1>, InvRCTRow<2>, InvRCTRow<3>,
130
1.67k
      InvRCTRow<4>, InvRCTRow<5>, InvRCTRow<6>};
131
1.67k
  const auto process_row = [&](const uint32_t task,
132
1.67k
                               size_t /* thread */) -> Status {
133
1.67k
    const size_t y = task;
134
1.67k
    const pixel_type* in0 = input.channel[m].Row(y);
135
1.67k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
1.67k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
1.67k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
1.67k
    pixel_type* out1 =
139
1.67k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
1.67k
    pixel_type* out2 =
141
1.67k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
1.67k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
1.67k
    return true;
144
1.67k
  };
145
1.67k
  JXL_RETURN_IF_ERROR(
146
1.67k
      RunOnPool(pool, 0, h, ThreadPool::NoInit, process_row, "InvRCT"));
147
1.67k
  return true;
148
1.67k
}
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
1.78k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
159
1.78k
  return HWY_DYNAMIC_DISPATCH(InvRCT)(input, begin_c, rct_type, pool);
160
1.78k
}
161
162
}  // namespace jxl
163
#endif