Coverage Report

Created: 2026-01-20 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
327k
               pixel_type* out2, size_t w) {
33
327k
  static_assert(transform_type >= 0 && transform_type < 7,
34
327k
                "Invalid transform type");
35
327k
  int second = transform_type >> 1;
36
327k
  int third = transform_type & 1;
37
38
327k
  size_t x = 0;
39
327k
  const HWY_FULL(pixel_type) d;
40
327k
  const size_t N = Lanes(d);
41
2.15M
  for (; x + N - 1 < w; x += N) {
42
1.82M
    if (transform_type == 6) {
43
897k
      auto Y = Load(d, in0 + x);
44
897k
      auto Co = Load(d, in1 + x);
45
897k
      auto Cg = Load(d, in2 + x);
46
897k
      Y = Sub(Y, ShiftRight<1>(Cg));
47
897k
      auto G = Add(Cg, Y);
48
897k
      Y = Sub(Y, ShiftRight<1>(Co));
49
897k
      auto R = Add(Y, Co);
50
897k
      Store(R, d, out0 + x);
51
897k
      Store(G, d, out1 + x);
52
897k
      Store(Y, d, out2 + x);
53
927k
    } else {
54
927k
      auto First = Load(d, in0 + x);
55
927k
      auto Second = Load(d, in1 + x);
56
927k
      auto Third = Load(d, in2 + x);
57
927k
      if (third) Third = Add(Third, First);
58
927k
      if (second == 1) {
59
690k
        Second = Add(Second, First);
60
690k
      } else if (second == 2) {
61
164k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
164k
      }
63
927k
      Store(First, d, out0 + x);
64
927k
      Store(Second, d, out1 + x);
65
927k
      Store(Third, d, out2 + x);
66
927k
    }
67
1.82M
  }
68
1.26M
  for (; x < w; x++) {
69
940k
    if (transform_type == 6) {
70
862k
      pixel_type Y = in0[x];
71
862k
      pixel_type Co = in1[x];
72
862k
      pixel_type Cg = in2[x];
73
862k
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
862k
      pixel_type G = PixelAdd(Cg, tmp);
75
862k
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
862k
      pixel_type R = PixelAdd(B, Co);
77
862k
      out0[x] = R;
78
862k
      out1[x] = G;
79
862k
      out2[x] = B;
80
862k
    } else {
81
78.0k
      pixel_type First = in0[x];
82
78.0k
      pixel_type Second = in1[x];
83
78.0k
      pixel_type Third = in2[x];
84
78.0k
      if (third) Third = PixelAdd(Third, First);
85
78.0k
      if (second == 1) {
86
52.2k
        Second = PixelAdd(Second, First);
87
52.2k
      } else if (second == 2) {
88
16.8k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
16.8k
      }
90
78.0k
      out0[x] = First;
91
78.0k
      out1[x] = Second;
92
78.0k
      out2[x] = Third;
93
78.0k
    }
94
940k
  }
95
327k
}
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.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
78.3k
  for (; x + N - 1 < w; x += N) {
42
72.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
72.9k
    } else {
54
72.9k
      auto First = Load(d, in0 + x);
55
72.9k
      auto Second = Load(d, in1 + x);
56
72.9k
      auto Third = Load(d, in2 + x);
57
72.9k
      if (third) Third = Add(Third, First);
58
72.9k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
72.9k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
72.9k
      Store(First, d, out0 + x);
64
72.9k
      Store(Second, d, out1 + x);
65
72.9k
      Store(Third, d, out2 + x);
66
72.9k
    }
67
72.9k
  }
68
14.4k
  for (; x < w; x++) {
69
8.98k
    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
8.98k
    } else {
81
8.98k
      pixel_type First = in0[x];
82
8.98k
      pixel_type Second = in1[x];
83
8.98k
      pixel_type Third = in2[x];
84
8.98k
      if (third) Third = PixelAdd(Third, First);
85
8.98k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
8.98k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
8.98k
      out0[x] = First;
91
8.98k
      out1[x] = Second;
92
8.98k
      out2[x] = Third;
93
8.98k
    }
94
8.98k
  }
95
5.42k
}
void jxl::N_AVX2::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
3.56k
               pixel_type* out2, size_t w) {
33
3.56k
  static_assert(transform_type >= 0 && transform_type < 7,
34
3.56k
                "Invalid transform type");
35
3.56k
  int second = transform_type >> 1;
36
3.56k
  int third = transform_type & 1;
37
38
3.56k
  size_t x = 0;
39
3.56k
  const HWY_FULL(pixel_type) d;
40
3.56k
  const size_t N = Lanes(d);
41
44.3k
  for (; x + N - 1 < w; x += N) {
42
40.8k
    if (transform_type == 6) {
43
0
      auto Y = Load(d, in0 + x);
44
0
      auto Co = Load(d, in1 + x);
45
0
      auto Cg = Load(d, in2 + x);
46
0
      Y = Sub(Y, ShiftRight<1>(Cg));
47
0
      auto G = Add(Cg, Y);
48
0
      Y = Sub(Y, ShiftRight<1>(Co));
49
0
      auto R = Add(Y, Co);
50
0
      Store(R, d, out0 + x);
51
0
      Store(G, d, out1 + x);
52
0
      Store(Y, d, out2 + x);
53
40.8k
    } else {
54
40.8k
      auto First = Load(d, in0 + x);
55
40.8k
      auto Second = Load(d, in1 + x);
56
40.8k
      auto Third = Load(d, in2 + x);
57
40.8k
      if (third) Third = Add(Third, First);
58
40.8k
      if (second == 1) {
59
40.8k
        Second = Add(Second, First);
60
40.8k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
40.8k
      Store(First, d, out0 + x);
64
40.8k
      Store(Second, d, out1 + x);
65
40.8k
      Store(Third, d, out2 + x);
66
40.8k
    }
67
40.8k
  }
68
9.17k
  for (; x < w; x++) {
69
5.61k
    if (transform_type == 6) {
70
0
      pixel_type Y = in0[x];
71
0
      pixel_type Co = in1[x];
72
0
      pixel_type Cg = in2[x];
73
0
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
0
      pixel_type G = PixelAdd(Cg, tmp);
75
0
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
0
      pixel_type R = PixelAdd(B, Co);
77
0
      out0[x] = R;
78
0
      out1[x] = G;
79
0
      out2[x] = B;
80
5.61k
    } else {
81
5.61k
      pixel_type First = in0[x];
82
5.61k
      pixel_type Second = in1[x];
83
5.61k
      pixel_type Third = in2[x];
84
5.61k
      if (third) Third = PixelAdd(Third, First);
85
5.61k
      if (second == 1) {
86
5.61k
        Second = PixelAdd(Second, First);
87
5.61k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
5.61k
      out0[x] = First;
91
5.61k
      out1[x] = Second;
92
5.61k
      out2[x] = Third;
93
5.61k
    }
94
5.61k
  }
95
3.56k
}
void jxl::N_AVX2::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
33.3k
               pixel_type* out2, size_t w) {
33
33.3k
  static_assert(transform_type >= 0 && transform_type < 7,
34
33.3k
                "Invalid transform type");
35
33.3k
  int second = transform_type >> 1;
36
33.3k
  int third = transform_type & 1;
37
38
33.3k
  size_t x = 0;
39
33.3k
  const HWY_FULL(pixel_type) d;
40
33.3k
  const size_t N = Lanes(d);
41
682k
  for (; x + N - 1 < w; x += N) {
42
649k
    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
649k
    } else {
54
649k
      auto First = Load(d, in0 + x);
55
649k
      auto Second = Load(d, in1 + x);
56
649k
      auto Third = Load(d, in2 + x);
57
649k
      if (third) Third = Add(Third, First);
58
649k
      if (second == 1) {
59
649k
        Second = Add(Second, First);
60
649k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
649k
      Store(First, d, out0 + x);
64
649k
      Store(Second, d, out1 + x);
65
649k
      Store(Third, d, out2 + x);
66
649k
    }
67
649k
  }
68
79.9k
  for (; x < w; x++) {
69
46.6k
    if (transform_type == 6) {
70
0
      pixel_type Y = in0[x];
71
0
      pixel_type Co = in1[x];
72
0
      pixel_type Cg = in2[x];
73
0
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
0
      pixel_type G = PixelAdd(Cg, tmp);
75
0
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
0
      pixel_type R = PixelAdd(B, Co);
77
0
      out0[x] = R;
78
0
      out1[x] = G;
79
0
      out2[x] = B;
80
46.6k
    } else {
81
46.6k
      pixel_type First = in0[x];
82
46.6k
      pixel_type Second = in1[x];
83
46.6k
      pixel_type Third = in2[x];
84
46.6k
      if (third) Third = PixelAdd(Third, First);
85
46.6k
      if (second == 1) {
86
46.6k
        Second = PixelAdd(Second, First);
87
46.6k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
46.6k
      out0[x] = First;
91
46.6k
      out1[x] = Second;
92
46.6k
      out2[x] = Third;
93
46.6k
    }
94
46.6k
  }
95
33.3k
}
void jxl::N_AVX2::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
5.47k
               pixel_type* out2, size_t w) {
33
5.47k
  static_assert(transform_type >= 0 && transform_type < 7,
34
5.47k
                "Invalid transform type");
35
5.47k
  int second = transform_type >> 1;
36
5.47k
  int third = transform_type & 1;
37
38
5.47k
  size_t x = 0;
39
5.47k
  const HWY_FULL(pixel_type) d;
40
5.47k
  const size_t N = Lanes(d);
41
79.4k
  for (; x + N - 1 < w; x += N) {
42
73.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
73.9k
    } else {
54
73.9k
      auto First = Load(d, in0 + x);
55
73.9k
      auto Second = Load(d, in1 + x);
56
73.9k
      auto Third = Load(d, in2 + x);
57
73.9k
      if (third) Third = Add(Third, First);
58
73.9k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
73.9k
      } else if (second == 2) {
61
73.9k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
73.9k
      }
63
73.9k
      Store(First, d, out0 + x);
64
73.9k
      Store(Second, d, out1 + x);
65
73.9k
      Store(Third, d, out2 + x);
66
73.9k
    }
67
73.9k
  }
68
12.2k
  for (; x < w; x++) {
69
6.80k
    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
6.80k
    } else {
81
6.80k
      pixel_type First = in0[x];
82
6.80k
      pixel_type Second = in1[x];
83
6.80k
      pixel_type Third = in2[x];
84
6.80k
      if (third) Third = PixelAdd(Third, First);
85
6.80k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
6.80k
      } else if (second == 2) {
88
6.80k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
6.80k
      }
90
6.80k
      out0[x] = First;
91
6.80k
      out1[x] = Second;
92
6.80k
      out2[x] = Third;
93
6.80k
    }
94
6.80k
  }
95
5.47k
}
void jxl::N_AVX2::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
10.1k
               pixel_type* out2, size_t w) {
33
10.1k
  static_assert(transform_type >= 0 && transform_type < 7,
34
10.1k
                "Invalid transform type");
35
10.1k
  int second = transform_type >> 1;
36
10.1k
  int third = transform_type & 1;
37
38
10.1k
  size_t x = 0;
39
10.1k
  const HWY_FULL(pixel_type) d;
40
10.1k
  const size_t N = Lanes(d);
41
100k
  for (; x + N - 1 < w; x += N) {
42
90.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
90.0k
    } else {
54
90.0k
      auto First = Load(d, in0 + x);
55
90.0k
      auto Second = Load(d, in1 + x);
56
90.0k
      auto Third = Load(d, in2 + x);
57
90.0k
      if (third) Third = Add(Third, First);
58
90.0k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
90.0k
      } else if (second == 2) {
61
90.0k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
90.0k
      }
63
90.0k
      Store(First, d, out0 + x);
64
90.0k
      Store(Second, d, out1 + x);
65
90.0k
      Store(Third, d, out2 + x);
66
90.0k
    }
67
90.0k
  }
68
20.1k
  for (; x < w; x++) {
69
10.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
10.0k
    } else {
81
10.0k
      pixel_type First = in0[x];
82
10.0k
      pixel_type Second = in1[x];
83
10.0k
      pixel_type Third = in2[x];
84
10.0k
      if (third) Third = PixelAdd(Third, First);
85
10.0k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
10.0k
      } else if (second == 2) {
88
10.0k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
10.0k
      }
90
10.0k
      out0[x] = First;
91
10.0k
      out1[x] = Second;
92
10.0k
      out2[x] = Third;
93
10.0k
    }
94
10.0k
  }
95
10.1k
}
void jxl::N_AVX2::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
269k
               pixel_type* out2, size_t w) {
33
269k
  static_assert(transform_type >= 0 && transform_type < 7,
34
269k
                "Invalid transform type");
35
269k
  int second = transform_type >> 1;
36
269k
  int third = transform_type & 1;
37
38
269k
  size_t x = 0;
39
269k
  const HWY_FULL(pixel_type) d;
40
269k
  const size_t N = Lanes(d);
41
1.16M
  for (; x + N - 1 < w; x += N) {
42
897k
    if (transform_type == 6) {
43
897k
      auto Y = Load(d, in0 + x);
44
897k
      auto Co = Load(d, in1 + x);
45
897k
      auto Cg = Load(d, in2 + x);
46
897k
      Y = Sub(Y, ShiftRight<1>(Cg));
47
897k
      auto G = Add(Cg, Y);
48
897k
      Y = Sub(Y, ShiftRight<1>(Co));
49
897k
      auto R = Add(Y, Co);
50
897k
      Store(R, d, out0 + x);
51
897k
      Store(G, d, out1 + x);
52
897k
      Store(Y, d, out2 + x);
53
897k
    } 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
897k
  }
68
1.13M
  for (; x < w; x++) {
69
862k
    if (transform_type == 6) {
70
862k
      pixel_type Y = in0[x];
71
862k
      pixel_type Co = in1[x];
72
862k
      pixel_type Cg = in2[x];
73
862k
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
862k
      pixel_type G = PixelAdd(Cg, tmp);
75
862k
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
862k
      pixel_type R = PixelAdd(B, Co);
77
862k
      out0[x] = R;
78
862k
      out1[x] = G;
79
862k
      out2[x] = B;
80
862k
    } 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
862k
  }
95
269k
}
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<0>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<1>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<0>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<1>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_ZEN4::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<0>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<1>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_AVX3_SPR::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<0>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<1>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Unexecuted instantiation: void jxl::N_SSE2::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
96
97
4.83k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
98
4.83k
  JXL_RETURN_IF_ERROR(CheckEqualChannels(input, begin_c, begin_c + 2));
99
4.83k
  size_t m = begin_c;
100
4.83k
  Channel& c0 = input.channel[m + 0];
101
4.83k
  size_t w = c0.w;
102
4.83k
  size_t h = c0.h;
103
4.83k
  if (rct_type == 0) {  // noop
104
146
    return true;
105
146
  }
106
  // Permutation: 0=RGB, 1=GBR, 2=BRG, 3=RBG, 4=GRB, 5=BGR
107
4.68k
  int permutation = rct_type / 7;
108
4.68k
  JXL_ENSURE(permutation < 6);
109
  // 0-5 values have the low bit corresponding to Third and the high bits
110
  // corresponding to Second. 6 corresponds to YCoCg.
111
  //
112
  // Second: 0=nop, 1=SubtractFirst, 2=SubtractAvgFirstThird
113
  //
114
  // Third: 0=nop, 1=SubtractFirst
115
4.68k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
4.68k
  if (custom == 0) {
118
214
    Channel ch0 = std::move(input.channel[m]);
119
214
    Channel ch1 = std::move(input.channel[m + 1]);
120
214
    Channel ch2 = std::move(input.channel[m + 2]);
121
214
    input.channel[m + (permutation % 3)] = std::move(ch0);
122
214
    input.channel[m + ((permutation + 1 + permutation / 3) % 3)] =
123
214
        std::move(ch1);
124
214
    input.channel[m + ((permutation + 2 - permutation / 3) % 3)] =
125
214
        std::move(ch2);
126
214
    return true;
127
214
  }
128
4.47k
  constexpr decltype(&InvRCTRow<0>) inv_rct_row[] = {
129
4.47k
      InvRCTRow<0>, InvRCTRow<1>, InvRCTRow<2>, InvRCTRow<3>,
130
4.47k
      InvRCTRow<4>, InvRCTRow<5>, InvRCTRow<6>};
131
4.47k
  const auto process_row = [&](const uint32_t task,
132
327k
                               size_t /* thread */) -> Status {
133
327k
    const size_t y = task;
134
327k
    const pixel_type* in0 = input.channel[m].Row(y);
135
327k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
327k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
327k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
327k
    pixel_type* out1 =
139
327k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
327k
    pixel_type* out2 =
141
327k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
327k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
327k
    return true;
144
327k
  };
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
327k
                               size_t /* thread */) -> Status {
133
327k
    const size_t y = task;
134
327k
    const pixel_type* in0 = input.channel[m].Row(y);
135
327k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
327k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
327k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
327k
    pixel_type* out1 =
139
327k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
327k
    pixel_type* out2 =
141
327k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
327k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
327k
    return true;
144
327k
  };
Unexecuted instantiation: rct.cc:jxl::N_AVX3::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
Unexecuted instantiation: rct.cc:jxl::N_AVX3_ZEN4::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
Unexecuted instantiation: rct.cc:jxl::N_AVX3_SPR::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
Unexecuted instantiation: rct.cc:jxl::N_SSE2::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)::$_0::operator()(unsigned int, unsigned long) const
145
4.47k
  JXL_RETURN_IF_ERROR(
146
4.47k
      RunOnPool(pool, 0, h, ThreadPool::NoInit, process_row, "InvRCT"));
147
4.47k
  return true;
148
4.47k
}
Unexecuted instantiation: jxl::N_SSE4::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)
jxl::N_AVX2::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)
Line
Count
Source
97
4.83k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
98
4.83k
  JXL_RETURN_IF_ERROR(CheckEqualChannels(input, begin_c, begin_c + 2));
99
4.83k
  size_t m = begin_c;
100
4.83k
  Channel& c0 = input.channel[m + 0];
101
4.83k
  size_t w = c0.w;
102
4.83k
  size_t h = c0.h;
103
4.83k
  if (rct_type == 0) {  // noop
104
146
    return true;
105
146
  }
106
  // Permutation: 0=RGB, 1=GBR, 2=BRG, 3=RBG, 4=GRB, 5=BGR
107
4.68k
  int permutation = rct_type / 7;
108
4.68k
  JXL_ENSURE(permutation < 6);
109
  // 0-5 values have the low bit corresponding to Third and the high bits
110
  // corresponding to Second. 6 corresponds to YCoCg.
111
  //
112
  // Second: 0=nop, 1=SubtractFirst, 2=SubtractAvgFirstThird
113
  //
114
  // Third: 0=nop, 1=SubtractFirst
115
4.68k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
4.68k
  if (custom == 0) {
118
214
    Channel ch0 = std::move(input.channel[m]);
119
214
    Channel ch1 = std::move(input.channel[m + 1]);
120
214
    Channel ch2 = std::move(input.channel[m + 2]);
121
214
    input.channel[m + (permutation % 3)] = std::move(ch0);
122
214
    input.channel[m + ((permutation + 1 + permutation / 3) % 3)] =
123
214
        std::move(ch1);
124
214
    input.channel[m + ((permutation + 2 - permutation / 3) % 3)] =
125
214
        std::move(ch2);
126
214
    return true;
127
214
  }
128
4.47k
  constexpr decltype(&InvRCTRow<0>) inv_rct_row[] = {
129
4.47k
      InvRCTRow<0>, InvRCTRow<1>, InvRCTRow<2>, InvRCTRow<3>,
130
4.47k
      InvRCTRow<4>, InvRCTRow<5>, InvRCTRow<6>};
131
4.47k
  const auto process_row = [&](const uint32_t task,
132
4.47k
                               size_t /* thread */) -> Status {
133
4.47k
    const size_t y = task;
134
4.47k
    const pixel_type* in0 = input.channel[m].Row(y);
135
4.47k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
4.47k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
4.47k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
4.47k
    pixel_type* out1 =
139
4.47k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
4.47k
    pixel_type* out2 =
141
4.47k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
4.47k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
4.47k
    return true;
144
4.47k
  };
145
4.47k
  JXL_RETURN_IF_ERROR(
146
4.47k
      RunOnPool(pool, 0, h, ThreadPool::NoInit, process_row, "InvRCT"));
147
4.47k
  return true;
148
4.47k
}
Unexecuted instantiation: jxl::N_AVX3::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)
Unexecuted instantiation: jxl::N_AVX3_ZEN4::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)
Unexecuted instantiation: jxl::N_AVX3_SPR::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)
Unexecuted instantiation: jxl::N_SSE2::InvRCT(jxl::Image&, unsigned long, unsigned long, jxl::ThreadPool*)
149
150
}  // namespace HWY_NAMESPACE
151
}  // namespace jxl
152
HWY_AFTER_NAMESPACE();
153
154
#if HWY_ONCE
155
namespace jxl {
156
157
HWY_EXPORT(InvRCT);
158
4.83k
Status InvRCT(Image& input, size_t begin_c, size_t rct_type, ThreadPool* pool) {
159
4.83k
  return HWY_DYNAMIC_DISPATCH(InvRCT)(input, begin_c, rct_type, pool);
160
4.83k
}
161
162
}  // namespace jxl
163
#endif