Coverage Report

Created: 2026-09-14 07:37

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
374k
               pixel_type* out2, size_t w) {
33
374k
  static_assert(transform_type >= 0 && transform_type < 7,
34
374k
                "Invalid transform type");
35
374k
  int second = transform_type >> 1;
36
374k
  int third = transform_type & 1;
37
38
374k
  size_t x = 0;
39
374k
  const HWY_FULL(pixel_type) d;
40
374k
  const size_t N = Lanes(d);
41
4.23M
  for (; x + N - 1 < w; x += N) {
42
3.86M
    if (transform_type == 6) {
43
2.56M
      auto Y = Load(d, in0 + x);
44
2.56M
      auto Co = Load(d, in1 + x);
45
2.56M
      auto Cg = Load(d, in2 + x);
46
2.56M
      Y = Sub(Y, ShiftRight<1>(Cg));
47
2.56M
      auto G = Add(Cg, Y);
48
2.56M
      Y = Sub(Y, ShiftRight<1>(Co));
49
2.56M
      auto R = Add(Y, Co);
50
2.56M
      Store(R, d, out0 + x);
51
2.56M
      Store(G, d, out1 + x);
52
2.56M
      Store(Y, d, out2 + x);
53
2.56M
    } else {
54
1.29M
      auto First = Load(d, in0 + x);
55
1.29M
      auto Second = Load(d, in1 + x);
56
1.29M
      auto Third = Load(d, in2 + x);
57
1.29M
      if (third) Third = Add(Third, First);
58
1.29M
      if (second == 1) {
59
699k
        Second = Add(Second, First);
60
699k
      } else if (second == 2) {
61
528k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
528k
      }
63
1.29M
      Store(First, d, out0 + x);
64
1.29M
      Store(Second, d, out1 + x);
65
1.29M
      Store(Third, d, out2 + x);
66
1.29M
    }
67
3.86M
  }
68
1.26M
  for (; x < w; x++) {
69
892k
    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
74.8k
      pixel_type First = in0[x];
82
74.8k
      pixel_type Second = in1[x];
83
74.8k
      pixel_type Third = in2[x];
84
74.8k
      if (third) Third = PixelAdd(Third, First);
85
74.8k
      if (second == 1) {
86
40.0k
        Second = PixelAdd(Second, First);
87
40.0k
      } else if (second == 2) {
88
22.6k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
22.6k
      }
90
74.8k
      out0[x] = First;
91
74.8k
      out1[x] = Second;
92
74.8k
      out2[x] = Third;
93
74.8k
    }
94
892k
  }
95
374k
}
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
5.54k
               pixel_type* out2, size_t w) {
33
5.54k
  static_assert(transform_type >= 0 && transform_type < 7,
34
5.54k
                "Invalid transform type");
35
5.54k
  int second = transform_type >> 1;
36
5.54k
  int third = transform_type & 1;
37
38
5.54k
  size_t x = 0;
39
5.54k
  const HWY_FULL(pixel_type) d;
40
5.54k
  const size_t N = Lanes(d);
41
72.3k
  for (; x + N - 1 < w; x += N) {
42
66.7k
    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
66.7k
    } else {
54
66.7k
      auto First = Load(d, in0 + x);
55
66.7k
      auto Second = Load(d, in1 + x);
56
66.7k
      auto Third = Load(d, in2 + x);
57
66.7k
      if (third) Third = Add(Third, First);
58
66.7k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
66.7k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
66.7k
      Store(First, d, out0 + x);
64
66.7k
      Store(Second, d, out1 + x);
65
66.7k
      Store(Third, d, out2 + x);
66
66.7k
    }
67
66.7k
  }
68
17.7k
  for (; x < w; x++) {
69
12.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
12.1k
    } else {
81
12.1k
      pixel_type First = in0[x];
82
12.1k
      pixel_type Second = in1[x];
83
12.1k
      pixel_type Third = in2[x];
84
12.1k
      if (third) Third = PixelAdd(Third, First);
85
12.1k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
12.1k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
12.1k
      out0[x] = First;
91
12.1k
      out1[x] = Second;
92
12.1k
      out2[x] = Third;
93
12.1k
    }
94
12.1k
  }
95
5.54k
}
void jxl::N_AVX2::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
5.36k
               pixel_type* out2, size_t w) {
33
5.36k
  static_assert(transform_type >= 0 && transform_type < 7,
34
5.36k
                "Invalid transform type");
35
5.36k
  int second = transform_type >> 1;
36
5.36k
  int third = transform_type & 1;
37
38
5.36k
  size_t x = 0;
39
5.36k
  const HWY_FULL(pixel_type) d;
40
5.36k
  const size_t N = Lanes(d);
41
82.4k
  for (; x + N - 1 < w; x += N) {
42
77.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
77.0k
    } else {
54
77.0k
      auto First = Load(d, in0 + x);
55
77.0k
      auto Second = Load(d, in1 + x);
56
77.0k
      auto Third = Load(d, in2 + x);
57
77.0k
      if (third) Third = Add(Third, First);
58
77.0k
      if (second == 1) {
59
77.0k
        Second = Add(Second, First);
60
77.0k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
77.0k
      Store(First, d, out0 + x);
64
77.0k
      Store(Second, d, out1 + x);
65
77.0k
      Store(Third, d, out2 + x);
66
77.0k
    }
67
77.0k
  }
68
14.4k
  for (; x < w; x++) {
69
9.11k
    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.11k
    } else {
81
9.11k
      pixel_type First = in0[x];
82
9.11k
      pixel_type Second = in1[x];
83
9.11k
      pixel_type Third = in2[x];
84
9.11k
      if (third) Third = PixelAdd(Third, First);
85
9.11k
      if (second == 1) {
86
9.11k
        Second = PixelAdd(Second, First);
87
9.11k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
9.11k
      out0[x] = First;
91
9.11k
      out1[x] = Second;
92
9.11k
      out2[x] = Third;
93
9.11k
    }
94
9.11k
  }
95
5.36k
}
void jxl::N_AVX2::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
26.8k
               pixel_type* out2, size_t w) {
33
26.8k
  static_assert(transform_type >= 0 && transform_type < 7,
34
26.8k
                "Invalid transform type");
35
26.8k
  int second = transform_type >> 1;
36
26.8k
  int third = transform_type & 1;
37
38
26.8k
  size_t x = 0;
39
26.8k
  const HWY_FULL(pixel_type) d;
40
26.8k
  const size_t N = Lanes(d);
41
649k
  for (; x + N - 1 < w; x += N) {
42
622k
    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
622k
    } else {
54
622k
      auto First = Load(d, in0 + x);
55
622k
      auto Second = Load(d, in1 + x);
56
622k
      auto Third = Load(d, in2 + x);
57
622k
      if (third) Third = Add(Third, First);
58
622k
      if (second == 1) {
59
622k
        Second = Add(Second, First);
60
622k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
622k
      Store(First, d, out0 + x);
64
622k
      Store(Second, d, out1 + x);
65
622k
      Store(Third, d, out2 + x);
66
622k
    }
67
622k
  }
68
57.7k
  for (; x < w; x++) {
69
30.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
30.9k
    } else {
81
30.9k
      pixel_type First = in0[x];
82
30.9k
      pixel_type Second = in1[x];
83
30.9k
      pixel_type Third = in2[x];
84
30.9k
      if (third) Third = PixelAdd(Third, First);
85
30.9k
      if (second == 1) {
86
30.9k
        Second = PixelAdd(Second, First);
87
30.9k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
30.9k
      out0[x] = First;
91
30.9k
      out1[x] = Second;
92
30.9k
      out2[x] = Third;
93
30.9k
    }
94
30.9k
  }
95
26.8k
}
void jxl::N_AVX2::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
6.13k
               pixel_type* out2, size_t w) {
33
6.13k
  static_assert(transform_type >= 0 && transform_type < 7,
34
6.13k
                "Invalid transform type");
35
6.13k
  int second = transform_type >> 1;
36
6.13k
  int third = transform_type & 1;
37
38
6.13k
  size_t x = 0;
39
6.13k
  const HWY_FULL(pixel_type) d;
40
6.13k
  const size_t N = Lanes(d);
41
217k
  for (; x + N - 1 < w; x += N) {
42
211k
    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
211k
    } else {
54
211k
      auto First = Load(d, in0 + x);
55
211k
      auto Second = Load(d, in1 + x);
56
211k
      auto Third = Load(d, in2 + x);
57
211k
      if (third) Third = Add(Third, First);
58
211k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
211k
      } else if (second == 2) {
61
211k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
211k
      }
63
211k
      Store(First, d, out0 + x);
64
211k
      Store(Second, d, out1 + x);
65
211k
      Store(Third, d, out2 + x);
66
211k
    }
67
211k
  }
68
18.8k
  for (; x < w; x++) {
69
12.7k
    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.7k
    } else {
81
12.7k
      pixel_type First = in0[x];
82
12.7k
      pixel_type Second = in1[x];
83
12.7k
      pixel_type Third = in2[x];
84
12.7k
      if (third) Third = PixelAdd(Third, First);
85
12.7k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
12.7k
      } else if (second == 2) {
88
12.7k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
12.7k
      }
90
12.7k
      out0[x] = First;
91
12.7k
      out1[x] = Second;
92
12.7k
      out2[x] = Third;
93
12.7k
    }
94
12.7k
  }
95
6.13k
}
void jxl::N_AVX2::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
17.2k
               pixel_type* out2, size_t w) {
33
17.2k
  static_assert(transform_type >= 0 && transform_type < 7,
34
17.2k
                "Invalid transform type");
35
17.2k
  int second = transform_type >> 1;
36
17.2k
  int third = transform_type & 1;
37
38
17.2k
  size_t x = 0;
39
17.2k
  const HWY_FULL(pixel_type) d;
40
17.2k
  const size_t N = Lanes(d);
41
334k
  for (; x + N - 1 < w; x += N) {
42
317k
    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
317k
    } else {
54
317k
      auto First = Load(d, in0 + x);
55
317k
      auto Second = Load(d, in1 + x);
56
317k
      auto Third = Load(d, in2 + x);
57
317k
      if (third) Third = Add(Third, First);
58
317k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
317k
      } else if (second == 2) {
61
317k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
317k
      }
63
317k
      Store(First, d, out0 + x);
64
317k
      Store(Second, d, out1 + x);
65
317k
      Store(Third, d, out2 + x);
66
317k
    }
67
317k
  }
68
27.0k
  for (; x < w; x++) {
69
9.87k
    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.87k
    } else {
81
9.87k
      pixel_type First = in0[x];
82
9.87k
      pixel_type Second = in1[x];
83
9.87k
      pixel_type Third = in2[x];
84
9.87k
      if (third) Third = PixelAdd(Third, First);
85
9.87k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
9.87k
      } else if (second == 2) {
88
9.87k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
9.87k
      }
90
9.87k
      out0[x] = First;
91
9.87k
      out1[x] = Second;
92
9.87k
      out2[x] = Third;
93
9.87k
    }
94
9.87k
  }
95
17.2k
}
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.56M
    if (transform_type == 6) {
43
2.56M
      auto Y = Load(d, in0 + x);
44
2.56M
      auto Co = Load(d, in1 + x);
45
2.56M
      auto Cg = Load(d, in2 + x);
46
2.56M
      Y = Sub(Y, ShiftRight<1>(Cg));
47
2.56M
      auto G = Add(Cg, Y);
48
2.56M
      Y = Sub(Y, ShiftRight<1>(Co));
49
2.56M
      auto R = Add(Y, Co);
50
2.56M
      Store(R, d, out0 + x);
51
2.56M
      Store(G, d, out1 + x);
52
2.56M
      Store(Y, d, out2 + x);
53
2.56M
    } 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.56M
  }
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.3k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
98
12.3k
  JXL_RETURN_IF_ERROR(CheckEqualChannels(input, begin_c, begin_c + 2));
99
12.3k
  size_t m = begin_c;
100
12.3k
  Channel& c0 = input.channel[m + 0];
101
12.3k
  size_t w = c0.w;
102
12.3k
  size_t h = c0.h;
103
12.3k
  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.18k
  int permutation = rct_type / 7;
108
7.18k
  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.18k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
7.18k
  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.36k
  constexpr decltype(&InvRCTRow<0>) inv_rct_row[] = {
129
5.36k
      InvRCTRow<0>, InvRCTRow<1>, InvRCTRow<2>, InvRCTRow<3>,
130
5.36k
      InvRCTRow<4>, InvRCTRow<5>, InvRCTRow<6>};
131
5.36k
  const auto process_row = [&](const uint32_t task,
132
374k
                               size_t /* thread */) -> Status {
133
374k
    const size_t y = task;
134
374k
    const pixel_type* in0 = input.channel[m].Row(y);
135
374k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
374k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
374k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
374k
    pixel_type* out1 =
139
374k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
374k
    pixel_type* out2 =
141
374k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
374k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
374k
    return true;
144
374k
  };
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
374k
                               size_t /* thread */) -> Status {
133
374k
    const size_t y = task;
134
374k
    const pixel_type* in0 = input.channel[m].Row(y);
135
374k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
374k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
374k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
374k
    pixel_type* out1 =
139
374k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
374k
    pixel_type* out2 =
141
374k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
374k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
374k
    return true;
144
374k
  };
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.36k
  JXL_RETURN_IF_ERROR(
146
5.36k
      RunOnPool(pool, 0, h, ThreadPool::NoInit, process_row, "InvRCT"));
147
5.36k
  return true;
148
5.36k
}
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.3k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
98
12.3k
  JXL_RETURN_IF_ERROR(CheckEqualChannels(input, begin_c, begin_c + 2));
99
12.3k
  size_t m = begin_c;
100
12.3k
  Channel& c0 = input.channel[m + 0];
101
12.3k
  size_t w = c0.w;
102
12.3k
  size_t h = c0.h;
103
12.3k
  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.18k
  int permutation = rct_type / 7;
108
7.18k
  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.18k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
7.18k
  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.36k
  constexpr decltype(&InvRCTRow<0>) inv_rct_row[] = {
129
5.36k
      InvRCTRow<0>, InvRCTRow<1>, InvRCTRow<2>, InvRCTRow<3>,
130
5.36k
      InvRCTRow<4>, InvRCTRow<5>, InvRCTRow<6>};
131
5.36k
  const auto process_row = [&](const uint32_t task,
132
5.36k
                               size_t /* thread */) -> Status {
133
5.36k
    const size_t y = task;
134
5.36k
    const pixel_type* in0 = input.channel[m].Row(y);
135
5.36k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
5.36k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
5.36k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
5.36k
    pixel_type* out1 =
139
5.36k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
5.36k
    pixel_type* out2 =
141
5.36k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
5.36k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
5.36k
    return true;
144
5.36k
  };
145
5.36k
  JXL_RETURN_IF_ERROR(
146
5.36k
      RunOnPool(pool, 0, h, ThreadPool::NoInit, process_row, "InvRCT"));
147
5.36k
  return true;
148
5.36k
}
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.3k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
159
12.3k
  return HWY_DYNAMIC_DISPATCH(InvRCT)(input, begin_c, rct_type, pool);
160
12.3k
}
161
162
}  // namespace jxl
163
#endif