3
3
4
4
using System . Numerics ;
5
5
using System . Runtime . CompilerServices ;
6
+ using System . Runtime . Intrinsics ;
6
7
7
8
// <auto-generated />
8
9
namespace SixLabors . ImageSharp . Formats . Jpeg . Components ;
9
10
10
11
internal partial struct Block8x8F
11
12
{
12
- /// <summary>
13
+ /// <summary>
13
14
/// Level shift by +maximum/2, clip to [0, maximum]
14
15
/// </summary>
15
16
public void NormalizeColorsInPlace ( float maximum )
@@ -37,38 +38,66 @@ public void NormalizeColorsInPlace(float maximum)
37
38
}
38
39
39
40
/// <summary>
40
- /// AVX2-only variant for executing <see cref="NormalizeColorsInPlace"/> and <see cref="RoundInPlace"/> in one step .
41
+ /// <see cref="Vector256{Single}"/> version of <see cref="NormalizeColorsInPlace(float) "/> and <see cref="RoundInPlace() "/>.
41
42
/// </summary>
43
+ /// <param name="maximum">The maximum value to normalize to.</param>
42
44
[ MethodImpl ( InliningOptions . ShortMethod ) ]
43
- public void NormalizeColorsAndRoundInPlaceVector8 ( float maximum )
45
+ public void NormalizeColorsAndRoundInPlaceVector256 ( float maximum )
44
46
{
45
- var off = new Vector < float > ( MathF . Ceiling ( maximum * 0.5F ) ) ;
46
- var max = new Vector < float > ( maximum ) ;
47
-
48
- ref Vector < float > row0 = ref Unsafe . As < Vector4 , Vector < float > > ( ref this . V0L ) ;
49
- row0 = NormalizeAndRound ( row0 , off , max ) ;
50
-
51
- ref Vector < float > row1 = ref Unsafe . As < Vector4 , Vector < float > > ( ref this . V1L ) ;
52
- row1 = NormalizeAndRound ( row1 , off , max ) ;
53
-
54
- ref Vector < float > row2 = ref Unsafe . As < Vector4 , Vector < float > > ( ref this . V2L ) ;
55
- row2 = NormalizeAndRound ( row2 , off , max ) ;
56
-
57
- ref Vector < float > row3 = ref Unsafe . As < Vector4 , Vector < float > > ( ref this . V3L ) ;
58
- row3 = NormalizeAndRound ( row3 , off , max ) ;
59
-
60
- ref Vector < float > row4 = ref Unsafe . As < Vector4 , Vector < float > > ( ref this . V4L ) ;
61
- row4 = NormalizeAndRound ( row4 , off , max ) ;
62
-
63
- ref Vector < float > row5 = ref Unsafe . As < Vector4 , Vector < float > > ( ref this . V5L ) ;
64
- row5 = NormalizeAndRound ( row5 , off , max ) ;
65
-
66
- ref Vector < float > row6 = ref Unsafe . As < Vector4 , Vector < float > > ( ref this . V6L ) ;
67
- row6 = NormalizeAndRound ( row6 , off , max ) ;
68
-
69
- ref Vector < float > row7 = ref Unsafe . As < Vector4 , Vector < float > > ( ref this . V7L ) ;
70
- row7 = NormalizeAndRound ( row7 , off , max ) ;
71
-
47
+ Vector256 < float > off = Vector256 . Create ( MathF . Ceiling ( maximum * 0.5F ) ) ;
48
+ Vector256 < float > max = Vector256 . Create ( maximum ) ;
49
+
50
+ ref Vector256 < float > row0 = ref Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V0L ) ;
51
+ row0 = NormalizeAndRoundVector256 ( row0 , off , max ) ;
52
+
53
+ ref Vector256 < float > row1 = ref Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V1L ) ;
54
+ row1 = NormalizeAndRoundVector256 ( row1 , off , max ) ;
55
+
56
+ ref Vector256 < float > row2 = ref Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V2L ) ;
57
+ row2 = NormalizeAndRoundVector256 ( row2 , off , max ) ;
58
+
59
+ ref Vector256 < float > row3 = ref Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V3L ) ;
60
+ row3 = NormalizeAndRoundVector256 ( row3 , off , max ) ;
61
+
62
+ ref Vector256 < float > row4 = ref Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V4L ) ;
63
+ row4 = NormalizeAndRoundVector256 ( row4 , off , max ) ;
64
+
65
+ ref Vector256 < float > row5 = ref Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V5L ) ;
66
+ row5 = NormalizeAndRoundVector256 ( row5 , off , max ) ;
67
+
68
+ ref Vector256 < float > row6 = ref Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V6L ) ;
69
+ row6 = NormalizeAndRoundVector256 ( row6 , off , max ) ;
70
+
71
+ ref Vector256 < float > row7 = ref Unsafe . As < Vector4 , Vector256 < float > > ( ref this . V7L ) ;
72
+ row7 = NormalizeAndRoundVector256 ( row7 , off , max ) ;
73
+ }
74
+
75
+ /// <summary>
76
+ /// <see cref="Vector128{Single}"/> version of <see cref="NormalizeColorsInPlace(float)"/> and <see cref="RoundInPlace()"/>.
77
+ /// </summary>
78
+ /// <param name="maximum">The maximum value to normalize to.</param>
79
+ [ MethodImpl ( InliningOptions . ShortMethod ) ]
80
+ public void NormalizeColorsAndRoundInPlaceVector128 ( float maximum )
81
+ {
82
+ Vector128 < float > off = Vector128 . Create ( MathF . Ceiling ( maximum * 0.5F ) ) ;
83
+ Vector128 < float > max = Vector128 . Create ( maximum ) ;
84
+
85
+ this . V0L = NormalizeAndRoundVector128 ( this . V0L . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
86
+ this . V0R = NormalizeAndRoundVector128 ( this . V0R . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
87
+ this . V1L = NormalizeAndRoundVector128 ( this . V1L . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
88
+ this . V1R = NormalizeAndRoundVector128 ( this . V1R . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
89
+ this . V2L = NormalizeAndRoundVector128 ( this . V2L . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
90
+ this . V2R = NormalizeAndRoundVector128 ( this . V2R . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
91
+ this . V3L = NormalizeAndRoundVector128 ( this . V3L . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
92
+ this . V3R = NormalizeAndRoundVector128 ( this . V3R . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
93
+ this . V4L = NormalizeAndRoundVector128 ( this . V4L . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
94
+ this . V4R = NormalizeAndRoundVector128 ( this . V4R . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
95
+ this . V5L = NormalizeAndRoundVector128 ( this . V5L . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
96
+ this . V5R = NormalizeAndRoundVector128 ( this . V5R . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
97
+ this . V6L = NormalizeAndRoundVector128 ( this . V6L . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
98
+ this . V6R = NormalizeAndRoundVector128 ( this . V6R . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
99
+ this . V7L = NormalizeAndRoundVector128 ( this . V7L . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
100
+ this . V7R = NormalizeAndRoundVector128 ( this . V7R . AsVector128 ( ) , off , max ) . AsVector4 ( ) ;
72
101
}
73
102
74
103
/// <summary>
@@ -78,76 +107,76 @@ public void LoadFromInt16Scalar(ref Block8x8 source)
78
107
{
79
108
ref short selfRef = ref Unsafe . As < Block8x8 , short > ( ref source ) ;
80
109
81
- this . V0L . X = Unsafe . Add ( ref selfRef , 0 ) ;
82
- this . V0L . Y = Unsafe . Add ( ref selfRef , 1 ) ;
83
- this . V0L . Z = Unsafe . Add ( ref selfRef , 2 ) ;
84
- this . V0L . W = Unsafe . Add ( ref selfRef , 3 ) ;
85
- this . V0R . X = Unsafe . Add ( ref selfRef , 4 ) ;
86
- this . V0R . Y = Unsafe . Add ( ref selfRef , 5 ) ;
87
- this . V0R . Z = Unsafe . Add ( ref selfRef , 6 ) ;
88
- this . V0R . W = Unsafe . Add ( ref selfRef , 7 ) ;
89
-
90
- this . V1L . X = Unsafe . Add ( ref selfRef , 8 ) ;
91
- this . V1L . Y = Unsafe . Add ( ref selfRef , 9 ) ;
92
- this . V1L . Z = Unsafe . Add ( ref selfRef , 10 ) ;
93
- this . V1L . W = Unsafe . Add ( ref selfRef , 11 ) ;
94
- this . V1R . X = Unsafe . Add ( ref selfRef , 12 ) ;
95
- this . V1R . Y = Unsafe . Add ( ref selfRef , 13 ) ;
96
- this . V1R . Z = Unsafe . Add ( ref selfRef , 14 ) ;
97
- this . V1R . W = Unsafe . Add ( ref selfRef , 15 ) ;
98
-
99
- this . V2L . X = Unsafe . Add ( ref selfRef , 16 ) ;
100
- this . V2L . Y = Unsafe . Add ( ref selfRef , 17 ) ;
101
- this . V2L . Z = Unsafe . Add ( ref selfRef , 18 ) ;
102
- this . V2L . W = Unsafe . Add ( ref selfRef , 19 ) ;
103
- this . V2R . X = Unsafe . Add ( ref selfRef , 20 ) ;
104
- this . V2R . Y = Unsafe . Add ( ref selfRef , 21 ) ;
105
- this . V2R . Z = Unsafe . Add ( ref selfRef , 22 ) ;
106
- this . V2R . W = Unsafe . Add ( ref selfRef , 23 ) ;
107
-
108
- this . V3L . X = Unsafe . Add ( ref selfRef , 24 ) ;
109
- this . V3L . Y = Unsafe . Add ( ref selfRef , 25 ) ;
110
- this . V3L . Z = Unsafe . Add ( ref selfRef , 26 ) ;
111
- this . V3L . W = Unsafe . Add ( ref selfRef , 27 ) ;
112
- this . V3R . X = Unsafe . Add ( ref selfRef , 28 ) ;
113
- this . V3R . Y = Unsafe . Add ( ref selfRef , 29 ) ;
114
- this . V3R . Z = Unsafe . Add ( ref selfRef , 30 ) ;
115
- this . V3R . W = Unsafe . Add ( ref selfRef , 31 ) ;
116
-
117
- this . V4L . X = Unsafe . Add ( ref selfRef , 32 ) ;
118
- this . V4L . Y = Unsafe . Add ( ref selfRef , 33 ) ;
119
- this . V4L . Z = Unsafe . Add ( ref selfRef , 34 ) ;
120
- this . V4L . W = Unsafe . Add ( ref selfRef , 35 ) ;
121
- this . V4R . X = Unsafe . Add ( ref selfRef , 36 ) ;
122
- this . V4R . Y = Unsafe . Add ( ref selfRef , 37 ) ;
123
- this . V4R . Z = Unsafe . Add ( ref selfRef , 38 ) ;
124
- this . V4R . W = Unsafe . Add ( ref selfRef , 39 ) ;
125
-
126
- this . V5L . X = Unsafe . Add ( ref selfRef , 40 ) ;
127
- this . V5L . Y = Unsafe . Add ( ref selfRef , 41 ) ;
128
- this . V5L . Z = Unsafe . Add ( ref selfRef , 42 ) ;
129
- this . V5L . W = Unsafe . Add ( ref selfRef , 43 ) ;
130
- this . V5R . X = Unsafe . Add ( ref selfRef , 44 ) ;
131
- this . V5R . Y = Unsafe . Add ( ref selfRef , 45 ) ;
132
- this . V5R . Z = Unsafe . Add ( ref selfRef , 46 ) ;
133
- this . V5R . W = Unsafe . Add ( ref selfRef , 47 ) ;
134
-
135
- this . V6L . X = Unsafe . Add ( ref selfRef , 48 ) ;
136
- this . V6L . Y = Unsafe . Add ( ref selfRef , 49 ) ;
137
- this . V6L . Z = Unsafe . Add ( ref selfRef , 50 ) ;
138
- this . V6L . W = Unsafe . Add ( ref selfRef , 51 ) ;
139
- this . V6R . X = Unsafe . Add ( ref selfRef , 52 ) ;
140
- this . V6R . Y = Unsafe . Add ( ref selfRef , 53 ) ;
141
- this . V6R . Z = Unsafe . Add ( ref selfRef , 54 ) ;
142
- this . V6R . W = Unsafe . Add ( ref selfRef , 55 ) ;
143
-
144
- this . V7L . X = Unsafe . Add ( ref selfRef , 56 ) ;
145
- this . V7L . Y = Unsafe . Add ( ref selfRef , 57 ) ;
146
- this . V7L . Z = Unsafe . Add ( ref selfRef , 58 ) ;
147
- this . V7L . W = Unsafe . Add ( ref selfRef , 59 ) ;
148
- this . V7R . X = Unsafe . Add ( ref selfRef , 60 ) ;
149
- this . V7R . Y = Unsafe . Add ( ref selfRef , 61 ) ;
150
- this . V7R . Z = Unsafe . Add ( ref selfRef , 62 ) ;
151
- this . V7R . W = Unsafe . Add ( ref selfRef , 63 ) ;
110
+ this . V0L . X = Unsafe . Add ( ref selfRef , 0 ) ;
111
+ this . V0L . Y = Unsafe . Add ( ref selfRef , 1 ) ;
112
+ this . V0L . Z = Unsafe . Add ( ref selfRef , 2 ) ;
113
+ this . V0L . W = Unsafe . Add ( ref selfRef , 3 ) ;
114
+ this . V0R . X = Unsafe . Add ( ref selfRef , 4 ) ;
115
+ this . V0R . Y = Unsafe . Add ( ref selfRef , 5 ) ;
116
+ this . V0R . Z = Unsafe . Add ( ref selfRef , 6 ) ;
117
+ this . V0R . W = Unsafe . Add ( ref selfRef , 7 ) ;
118
+
119
+ this . V1L . X = Unsafe . Add ( ref selfRef , 8 ) ;
120
+ this . V1L . Y = Unsafe . Add ( ref selfRef , 9 ) ;
121
+ this . V1L . Z = Unsafe . Add ( ref selfRef , 10 ) ;
122
+ this . V1L . W = Unsafe . Add ( ref selfRef , 11 ) ;
123
+ this . V1R . X = Unsafe . Add ( ref selfRef , 12 ) ;
124
+ this . V1R . Y = Unsafe . Add ( ref selfRef , 13 ) ;
125
+ this . V1R . Z = Unsafe . Add ( ref selfRef , 14 ) ;
126
+ this . V1R . W = Unsafe . Add ( ref selfRef , 15 ) ;
127
+
128
+ this . V2L . X = Unsafe . Add ( ref selfRef , 16 ) ;
129
+ this . V2L . Y = Unsafe . Add ( ref selfRef , 17 ) ;
130
+ this . V2L . Z = Unsafe . Add ( ref selfRef , 18 ) ;
131
+ this . V2L . W = Unsafe . Add ( ref selfRef , 19 ) ;
132
+ this . V2R . X = Unsafe . Add ( ref selfRef , 20 ) ;
133
+ this . V2R . Y = Unsafe . Add ( ref selfRef , 21 ) ;
134
+ this . V2R . Z = Unsafe . Add ( ref selfRef , 22 ) ;
135
+ this . V2R . W = Unsafe . Add ( ref selfRef , 23 ) ;
136
+
137
+ this . V3L . X = Unsafe . Add ( ref selfRef , 24 ) ;
138
+ this . V3L . Y = Unsafe . Add ( ref selfRef , 25 ) ;
139
+ this . V3L . Z = Unsafe . Add ( ref selfRef , 26 ) ;
140
+ this . V3L . W = Unsafe . Add ( ref selfRef , 27 ) ;
141
+ this . V3R . X = Unsafe . Add ( ref selfRef , 28 ) ;
142
+ this . V3R . Y = Unsafe . Add ( ref selfRef , 29 ) ;
143
+ this . V3R . Z = Unsafe . Add ( ref selfRef , 30 ) ;
144
+ this . V3R . W = Unsafe . Add ( ref selfRef , 31 ) ;
145
+
146
+ this . V4L . X = Unsafe . Add ( ref selfRef , 32 ) ;
147
+ this . V4L . Y = Unsafe . Add ( ref selfRef , 33 ) ;
148
+ this . V4L . Z = Unsafe . Add ( ref selfRef , 34 ) ;
149
+ this . V4L . W = Unsafe . Add ( ref selfRef , 35 ) ;
150
+ this . V4R . X = Unsafe . Add ( ref selfRef , 36 ) ;
151
+ this . V4R . Y = Unsafe . Add ( ref selfRef , 37 ) ;
152
+ this . V4R . Z = Unsafe . Add ( ref selfRef , 38 ) ;
153
+ this . V4R . W = Unsafe . Add ( ref selfRef , 39 ) ;
154
+
155
+ this . V5L . X = Unsafe . Add ( ref selfRef , 40 ) ;
156
+ this . V5L . Y = Unsafe . Add ( ref selfRef , 41 ) ;
157
+ this . V5L . Z = Unsafe . Add ( ref selfRef , 42 ) ;
158
+ this . V5L . W = Unsafe . Add ( ref selfRef , 43 ) ;
159
+ this . V5R . X = Unsafe . Add ( ref selfRef , 44 ) ;
160
+ this . V5R . Y = Unsafe . Add ( ref selfRef , 45 ) ;
161
+ this . V5R . Z = Unsafe . Add ( ref selfRef , 46 ) ;
162
+ this . V5R . W = Unsafe . Add ( ref selfRef , 47 ) ;
163
+
164
+ this . V6L . X = Unsafe . Add ( ref selfRef , 48 ) ;
165
+ this . V6L . Y = Unsafe . Add ( ref selfRef , 49 ) ;
166
+ this . V6L . Z = Unsafe . Add ( ref selfRef , 50 ) ;
167
+ this . V6L . W = Unsafe . Add ( ref selfRef , 51 ) ;
168
+ this . V6R . X = Unsafe . Add ( ref selfRef , 52 ) ;
169
+ this . V6R . Y = Unsafe . Add ( ref selfRef , 53 ) ;
170
+ this . V6R . Z = Unsafe . Add ( ref selfRef , 54 ) ;
171
+ this . V6R . W = Unsafe . Add ( ref selfRef , 55 ) ;
172
+
173
+ this . V7L . X = Unsafe . Add ( ref selfRef , 56 ) ;
174
+ this . V7L . Y = Unsafe . Add ( ref selfRef , 57 ) ;
175
+ this . V7L . Z = Unsafe . Add ( ref selfRef , 58 ) ;
176
+ this . V7L . W = Unsafe . Add ( ref selfRef , 59 ) ;
177
+ this . V7R . X = Unsafe . Add ( ref selfRef , 60 ) ;
178
+ this . V7R . Y = Unsafe . Add ( ref selfRef , 61 ) ;
179
+ this . V7R . Z = Unsafe . Add ( ref selfRef , 62 ) ;
180
+ this . V7R . W = Unsafe . Add ( ref selfRef , 63 ) ;
152
181
}
153
182
}
0 commit comments