Coverage Report

Created: 2025-12-31 07:53

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
343k
               pixel_type* out2, size_t w) {
33
343k
  static_assert(transform_type >= 0 && transform_type < 7,
34
343k
                "Invalid transform type");
35
343k
  int second = transform_type >> 1;
36
343k
  int third = transform_type & 1;
37
38
343k
  size_t x = 0;
39
343k
  const HWY_FULL(pixel_type) d;
40
343k
  const size_t N = Lanes(d);
41
2.06M
  for (; x + N - 1 < w; x += N) {
42
1.72M
    if (transform_type == 6) {
43
782k
      auto Y = Load(d, in0 + x);
44
782k
      auto Co = Load(d, in1 + x);
45
782k
      auto Cg = Load(d, in2 + x);
46
782k
      Y = Sub(Y, ShiftRight<1>(Cg));
47
782k
      auto G = Add(Cg, Y);
48
782k
      Y = Sub(Y, ShiftRight<1>(Co));
49
782k
      auto R = Add(Y, Co);
50
782k
      Store(R, d, out0 + x);
51
782k
      Store(G, d, out1 + x);
52
782k
      Store(Y, d, out2 + x);
53
938k
    } else {
54
938k
      auto First = Load(d, in0 + x);
55
938k
      auto Second = Load(d, in1 + x);
56
938k
      auto Third = Load(d, in2 + x);
57
938k
      if (third) Third = Add(Third, First);
58
938k
      if (second == 1) {
59
732k
        Second = Add(Second, First);
60
732k
      } else if (second == 2) {
61
123k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
123k
      }
63
938k
      Store(First, d, out0 + x);
64
938k
      Store(Second, d, out1 + x);
65
938k
      Store(Third, d, out2 + x);
66
938k
    }
67
1.72M
  }
68
1.29M
  for (; x < w; x++) {
69
948k
    if (transform_type == 6) {
70
880k
      pixel_type Y = in0[x];
71
880k
      pixel_type Co = in1[x];
72
880k
      pixel_type Cg = in2[x];
73
880k
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
880k
      pixel_type G = PixelAdd(Cg, tmp);
75
880k
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
880k
      pixel_type R = PixelAdd(B, Co);
77
880k
      out0[x] = R;
78
880k
      out1[x] = G;
79
880k
      out2[x] = B;
80
880k
    } else {
81
68.3k
      pixel_type First = in0[x];
82
68.3k
      pixel_type Second = in1[x];
83
68.3k
      pixel_type Third = in2[x];
84
68.3k
      if (third) Third = PixelAdd(Third, First);
85
68.3k
      if (second == 1) {
86
44.2k
        Second = PixelAdd(Second, First);
87
44.2k
      } else if (second == 2) {
88
15.3k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
15.3k
      }
90
68.3k
      out0[x] = First;
91
68.3k
      out1[x] = Second;
92
68.3k
      out2[x] = Third;
93
68.3k
    }
94
948k
  }
95
343k
}
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.84k
               pixel_type* out2, size_t w) {
33
5.84k
  static_assert(transform_type >= 0 && transform_type < 7,
34
5.84k
                "Invalid transform type");
35
5.84k
  int second = transform_type >> 1;
36
5.84k
  int third = transform_type & 1;
37
38
5.84k
  size_t x = 0;
39
5.84k
  const HWY_FULL(pixel_type) d;
40
5.84k
  const size_t N = Lanes(d);
41
88.6k
  for (; x + N - 1 < w; x += N) {
42
82.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
82.8k
    } else {
54
82.8k
      auto First = Load(d, in0 + x);
55
82.8k
      auto Second = Load(d, in1 + x);
56
82.8k
      auto Third = Load(d, in2 + x);
57
82.8k
      if (third) Third = Add(Third, First);
58
82.8k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
82.8k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
82.8k
      Store(First, d, out0 + x);
64
82.8k
      Store(Second, d, out1 + x);
65
82.8k
      Store(Third, d, out2 + x);
66
82.8k
    }
67
82.8k
  }
68
14.5k
  for (; x < w; x++) {
69
8.72k
    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.72k
    } else {
81
8.72k
      pixel_type First = in0[x];
82
8.72k
      pixel_type Second = in1[x];
83
8.72k
      pixel_type Third = in2[x];
84
8.72k
      if (third) Third = PixelAdd(Third, First);
85
8.72k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
8.72k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
8.72k
      out0[x] = First;
91
8.72k
      out1[x] = Second;
92
8.72k
      out2[x] = Third;
93
8.72k
    }
94
8.72k
  }
95
5.84k
}
void jxl::N_AVX2::InvRCTRow<2>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
4.36k
               pixel_type* out2, size_t w) {
33
4.36k
  static_assert(transform_type >= 0 && transform_type < 7,
34
4.36k
                "Invalid transform type");
35
4.36k
  int second = transform_type >> 1;
36
4.36k
  int third = transform_type & 1;
37
38
4.36k
  size_t x = 0;
39
4.36k
  const HWY_FULL(pixel_type) d;
40
4.36k
  const size_t N = Lanes(d);
41
67.3k
  for (; x + N - 1 < w; x += N) {
42
62.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
62.9k
    } else {
54
62.9k
      auto First = Load(d, in0 + x);
55
62.9k
      auto Second = Load(d, in1 + x);
56
62.9k
      auto Third = Load(d, in2 + x);
57
62.9k
      if (third) Third = Add(Third, First);
58
62.9k
      if (second == 1) {
59
62.9k
        Second = Add(Second, First);
60
62.9k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
62.9k
      Store(First, d, out0 + x);
64
62.9k
      Store(Second, d, out1 + x);
65
62.9k
      Store(Third, d, out2 + x);
66
62.9k
    }
67
62.9k
  }
68
10.0k
  for (; x < w; x++) {
69
5.69k
    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.69k
    } else {
81
5.69k
      pixel_type First = in0[x];
82
5.69k
      pixel_type Second = in1[x];
83
5.69k
      pixel_type Third = in2[x];
84
5.69k
      if (third) Third = PixelAdd(Third, First);
85
5.69k
      if (second == 1) {
86
5.69k
        Second = PixelAdd(Second, First);
87
5.69k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
5.69k
      out0[x] = First;
91
5.69k
      out1[x] = Second;
92
5.69k
      out2[x] = Third;
93
5.69k
    }
94
5.69k
  }
95
4.36k
}
void jxl::N_AVX2::InvRCTRow<3>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
35.6k
               pixel_type* out2, size_t w) {
33
35.6k
  static_assert(transform_type >= 0 && transform_type < 7,
34
35.6k
                "Invalid transform type");
35
35.6k
  int second = transform_type >> 1;
36
35.6k
  int third = transform_type & 1;
37
38
35.6k
  size_t x = 0;
39
35.6k
  const HWY_FULL(pixel_type) d;
40
35.6k
  const size_t N = Lanes(d);
41
705k
  for (; x + N - 1 < w; x += N) {
42
669k
    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
669k
    } else {
54
669k
      auto First = Load(d, in0 + x);
55
669k
      auto Second = Load(d, in1 + x);
56
669k
      auto Third = Load(d, in2 + x);
57
669k
      if (third) Third = Add(Third, First);
58
669k
      if (second == 1) {
59
669k
        Second = Add(Second, First);
60
669k
      } else if (second == 2) {
61
0
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
0
      }
63
669k
      Store(First, d, out0 + x);
64
669k
      Store(Second, d, out1 + x);
65
669k
      Store(Third, d, out2 + x);
66
669k
    }
67
669k
  }
68
74.2k
  for (; x < w; x++) {
69
38.5k
    if (transform_type == 6) {
70
0
      pixel_type Y = in0[x];
71
0
      pixel_type Co = in1[x];
72
0
      pixel_type Cg = in2[x];
73
0
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
0
      pixel_type G = PixelAdd(Cg, tmp);
75
0
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
0
      pixel_type R = PixelAdd(B, Co);
77
0
      out0[x] = R;
78
0
      out1[x] = G;
79
0
      out2[x] = B;
80
38.5k
    } else {
81
38.5k
      pixel_type First = in0[x];
82
38.5k
      pixel_type Second = in1[x];
83
38.5k
      pixel_type Third = in2[x];
84
38.5k
      if (third) Third = PixelAdd(Third, First);
85
38.5k
      if (second == 1) {
86
38.5k
        Second = PixelAdd(Second, First);
87
38.5k
      } else if (second == 2) {
88
0
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
0
      }
90
38.5k
      out0[x] = First;
91
38.5k
      out1[x] = Second;
92
38.5k
      out2[x] = Third;
93
38.5k
    }
94
38.5k
  }
95
35.6k
}
void jxl::N_AVX2::InvRCTRow<4>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
4.60k
               pixel_type* out2, size_t w) {
33
4.60k
  static_assert(transform_type >= 0 && transform_type < 7,
34
4.60k
                "Invalid transform type");
35
4.60k
  int second = transform_type >> 1;
36
4.60k
  int third = transform_type & 1;
37
38
4.60k
  size_t x = 0;
39
4.60k
  const HWY_FULL(pixel_type) d;
40
4.60k
  const size_t N = Lanes(d);
41
57.0k
  for (; x + N - 1 < w; x += N) {
42
52.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
52.4k
    } else {
54
52.4k
      auto First = Load(d, in0 + x);
55
52.4k
      auto Second = Load(d, in1 + x);
56
52.4k
      auto Third = Load(d, in2 + x);
57
52.4k
      if (third) Third = Add(Third, First);
58
52.4k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
52.4k
      } else if (second == 2) {
61
52.4k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
52.4k
      }
63
52.4k
      Store(First, d, out0 + x);
64
52.4k
      Store(Second, d, out1 + x);
65
52.4k
      Store(Third, d, out2 + x);
66
52.4k
    }
67
52.4k
  }
68
10.5k
  for (; x < w; x++) {
69
5.93k
    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.93k
    } else {
81
5.93k
      pixel_type First = in0[x];
82
5.93k
      pixel_type Second = in1[x];
83
5.93k
      pixel_type Third = in2[x];
84
5.93k
      if (third) Third = PixelAdd(Third, First);
85
5.93k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
5.93k
      } else if (second == 2) {
88
5.93k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
5.93k
      }
90
5.93k
      out0[x] = First;
91
5.93k
      out1[x] = Second;
92
5.93k
      out2[x] = Third;
93
5.93k
    }
94
5.93k
  }
95
4.60k
}
void jxl::N_AVX2::InvRCTRow<5>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
9.77k
               pixel_type* out2, size_t w) {
33
9.77k
  static_assert(transform_type >= 0 && transform_type < 7,
34
9.77k
                "Invalid transform type");
35
9.77k
  int second = transform_type >> 1;
36
9.77k
  int third = transform_type & 1;
37
38
9.77k
  size_t x = 0;
39
9.77k
  const HWY_FULL(pixel_type) d;
40
9.77k
  const size_t N = Lanes(d);
41
80.8k
  for (; x + N - 1 < w; x += N) {
42
71.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
71.0k
    } else {
54
71.0k
      auto First = Load(d, in0 + x);
55
71.0k
      auto Second = Load(d, in1 + x);
56
71.0k
      auto Third = Load(d, in2 + x);
57
71.0k
      if (third) Third = Add(Third, First);
58
71.0k
      if (second == 1) {
59
0
        Second = Add(Second, First);
60
71.0k
      } else if (second == 2) {
61
71.0k
        Second = Add(Second, ShiftRight<1>(Add(First, Third)));
62
71.0k
      }
63
71.0k
      Store(First, d, out0 + x);
64
71.0k
      Store(Second, d, out1 + x);
65
71.0k
      Store(Third, d, out2 + x);
66
71.0k
    }
67
71.0k
  }
68
19.1k
  for (; x < w; x++) {
69
9.37k
    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.37k
    } else {
81
9.37k
      pixel_type First = in0[x];
82
9.37k
      pixel_type Second = in1[x];
83
9.37k
      pixel_type Third = in2[x];
84
9.37k
      if (third) Third = PixelAdd(Third, First);
85
9.37k
      if (second == 1) {
86
0
        Second = PixelAdd(Second, First);
87
9.37k
      } else if (second == 2) {
88
9.37k
        Second = PixelAdd(Second, (PixelAdd(First, Third) >> 1));
89
9.37k
      }
90
9.37k
      out0[x] = First;
91
9.37k
      out1[x] = Second;
92
9.37k
      out2[x] = Third;
93
9.37k
    }
94
9.37k
  }
95
9.77k
}
void jxl::N_AVX2::InvRCTRow<6>(int const*, int const*, int const*, int*, int*, int*, unsigned long)
Line
Count
Source
32
283k
               pixel_type* out2, size_t w) {
33
283k
  static_assert(transform_type >= 0 && transform_type < 7,
34
283k
                "Invalid transform type");
35
283k
  int second = transform_type >> 1;
36
283k
  int third = transform_type & 1;
37
38
283k
  size_t x = 0;
39
283k
  const HWY_FULL(pixel_type) d;
40
283k
  const size_t N = Lanes(d);
41
1.06M
  for (; x + N - 1 < w; x += N) {
42
782k
    if (transform_type == 6) {
43
782k
      auto Y = Load(d, in0 + x);
44
782k
      auto Co = Load(d, in1 + x);
45
782k
      auto Cg = Load(d, in2 + x);
46
782k
      Y = Sub(Y, ShiftRight<1>(Cg));
47
782k
      auto G = Add(Cg, Y);
48
782k
      Y = Sub(Y, ShiftRight<1>(Co));
49
782k
      auto R = Add(Y, Co);
50
782k
      Store(R, d, out0 + x);
51
782k
      Store(G, d, out1 + x);
52
782k
      Store(Y, d, out2 + x);
53
782k
    } 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
782k
  }
68
1.16M
  for (; x < w; x++) {
69
880k
    if (transform_type == 6) {
70
880k
      pixel_type Y = in0[x];
71
880k
      pixel_type Co = in1[x];
72
880k
      pixel_type Cg = in2[x];
73
880k
      pixel_type tmp = PixelAdd(Y, -(Cg >> 1));
74
880k
      pixel_type G = PixelAdd(Cg, tmp);
75
880k
      pixel_type B = PixelAdd(tmp, -(Co >> 1));
76
880k
      pixel_type R = PixelAdd(B, Co);
77
880k
      out0[x] = R;
78
880k
      out1[x] = G;
79
880k
      out2[x] = B;
80
880k
    } 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
880k
  }
95
283k
}
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
142
    return true;
105
142
  }
106
  // Permutation: 0=RGB, 1=GBR, 2=BRG, 3=RBG, 4=GRB, 5=BGR
107
4.69k
  int permutation = rct_type / 7;
108
4.69k
  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.69k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
4.69k
  if (custom == 0) {
118
221
    Channel ch0 = std::move(input.channel[m]);
119
221
    Channel ch1 = std::move(input.channel[m + 1]);
120
221
    Channel ch2 = std::move(input.channel[m + 2]);
121
221
    input.channel[m + (permutation % 3)] = std::move(ch0);
122
221
    input.channel[m + ((permutation + 1 + permutation / 3) % 3)] =
123
221
        std::move(ch1);
124
221
    input.channel[m + ((permutation + 2 - permutation / 3) % 3)] =
125
221
        std::move(ch2);
126
221
    return true;
127
221
  }
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
343k
                               size_t /* thread */) -> Status {
133
343k
    const size_t y = task;
134
343k
    const pixel_type* in0 = input.channel[m].Row(y);
135
343k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
343k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
343k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
343k
    pixel_type* out1 =
139
343k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
343k
    pixel_type* out2 =
141
343k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
343k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
343k
    return true;
144
343k
  };
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
343k
                               size_t /* thread */) -> Status {
133
343k
    const size_t y = task;
134
343k
    const pixel_type* in0 = input.channel[m].Row(y);
135
343k
    const pixel_type* in1 = input.channel[m + 1].Row(y);
136
343k
    const pixel_type* in2 = input.channel[m + 2].Row(y);
137
343k
    pixel_type* out0 = input.channel[m + (permutation % 3)].Row(y);
138
343k
    pixel_type* out1 =
139
343k
        input.channel[m + ((permutation + 1 + permutation / 3) % 3)].Row(y);
140
343k
    pixel_type* out2 =
141
343k
        input.channel[m + ((permutation + 2 - permutation / 3) % 3)].Row(y);
142
343k
    inv_rct_row[custom](in0, in1, in2, out0, out1, out2, w);
143
343k
    return true;
144
343k
  };
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
142
    return true;
105
142
  }
106
  // Permutation: 0=RGB, 1=GBR, 2=BRG, 3=RBG, 4=GRB, 5=BGR
107
4.69k
  int permutation = rct_type / 7;
108
4.69k
  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.69k
  int custom = rct_type % 7;
116
  // Special case: permute-only. Swap channels around.
117
4.69k
  if (custom == 0) {
118
221
    Channel ch0 = std::move(input.channel[m]);
119
221
    Channel ch1 = std::move(input.channel[m + 1]);
120
221
    Channel ch2 = std::move(input.channel[m + 2]);
121
221
    input.channel[m + (permutation % 3)] = std::move(ch0);
122
221
    input.channel[m + ((permutation + 1 + permutation / 3) % 3)] =
123
221
        std::move(ch1);
124
221
    input.channel[m + ((permutation + 2 - permutation / 3) % 3)] =
125
221
        std::move(ch2);
126
221
    return true;
127
221
  }
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