@@ -14,7 +14,7 @@ internal static class LossyUtils
14
14
{
15
15
// Note: method name in libwebp reference implementation is called VP8SSE16x16.
16
16
[ MethodImpl ( InliningOptions . ShortMethod ) ]
17
- public static int Vp8_Sse16X16 ( Span < byte > a , Span < byte > b )
17
+ public static int Vp8_Sse16x16 ( Span < byte > a , Span < byte > b )
18
18
{
19
19
if ( Avx2 . IsSupported )
20
20
{
@@ -31,7 +31,7 @@ public static int Vp8_Sse16X16(Span<byte> a, Span<byte> b)
31
31
32
32
// Note: method name in libwebp reference implementation is called VP8SSE16x8.
33
33
[ MethodImpl ( InliningOptions . ShortMethod ) ]
34
- public static int Vp8_Sse16X8 ( Span < byte > a , Span < byte > b )
34
+ public static int Vp8_Sse16x8 ( Span < byte > a , Span < byte > b )
35
35
{
36
36
if ( Avx2 . IsSupported )
37
37
{
@@ -48,7 +48,7 @@ public static int Vp8_Sse16X8(Span<byte> a, Span<byte> b)
48
48
49
49
// Note: method name in libwebp reference implementation is called VP8SSE4x4.
50
50
[ MethodImpl ( InliningOptions . ShortMethod ) ]
51
- public static int Vp8_Sse4X4 ( Span < byte > a , Span < byte > b )
51
+ public static int Vp8_Sse4x4 ( Span < byte > a , Span < byte > b )
52
52
{
53
53
if ( Avx2 . IsSupported )
54
54
{
@@ -77,8 +77,8 @@ public static int Vp8_Sse4X4(Span<byte> a, Span<byte> b)
77
77
Vector256 < byte > b01s = Avx2 . UnpackLow ( b01 . AsByte ( ) , Vector256 < byte > . Zero ) ;
78
78
79
79
// subtract, square and accumulate.
80
- Vector256 < byte > d0 = Avx2 . SubtractSaturate ( a01s , b01s ) ;
81
- Vector256 < int > e0 = Avx2 . MultiplyAddAdjacent ( d0 . AsInt16 ( ) , d0 . AsInt16 ( ) ) ;
80
+ Vector256 < short > d0 = Avx2 . SubtractSaturate ( a01s . AsInt16 ( ) , b01s . AsInt16 ( ) ) ;
81
+ Vector256 < int > e0 = Avx2 . MultiplyAddAdjacent ( d0 , d0 ) ;
82
82
83
83
return Numerics . ReduceSum ( e0 ) ;
84
84
}
@@ -110,10 +110,10 @@ public static int Vp8_Sse4X4(Span<byte> a, Span<byte> b)
110
110
Vector128 < byte > b23s = Sse2 . UnpackLow ( b23 . AsByte ( ) , Vector128 < byte > . Zero ) ;
111
111
112
112
// subtract, square and accumulate.
113
- Vector128 < byte > d0 = Sse2 . SubtractSaturate ( a01s , b01s ) ;
114
- Vector128 < byte > d1 = Sse2 . SubtractSaturate ( a23s , b23s ) ;
115
- Vector128 < int > e0 = Sse2 . MultiplyAddAdjacent ( d0 . AsInt16 ( ) , d0 . AsInt16 ( ) ) ;
116
- Vector128 < int > e1 = Sse2 . MultiplyAddAdjacent ( d1 . AsInt16 ( ) , d1 . AsInt16 ( ) ) ;
113
+ Vector128 < short > d0 = Sse2 . SubtractSaturate ( a01s . AsInt16 ( ) , b01s . AsInt16 ( ) ) ;
114
+ Vector128 < short > d1 = Sse2 . SubtractSaturate ( a23s . AsInt16 ( ) , b23s . AsInt16 ( ) ) ;
115
+ Vector128 < int > e0 = Sse2 . MultiplyAddAdjacent ( d0 , d0 ) ;
116
+ Vector128 < int > e1 = Sse2 . MultiplyAddAdjacent ( d1 , d1 ) ;
117
117
Vector128 < int > sum = Sse2 . Add ( e0 , e1 ) ;
118
118
119
119
return Numerics . ReduceSum ( sum ) ;
@@ -126,18 +126,16 @@ public static int Vp8_Sse4X4(Span<byte> a, Span<byte> b)
126
126
public static int Vp8_SseNxN ( Span < byte > a , Span < byte > b , int w , int h )
127
127
{
128
128
int count = 0 ;
129
- int aOffset = 0 ;
130
- int bOffset = 0 ;
129
+ int offset = 0 ;
131
130
for ( int y = 0 ; y < h ; y ++ )
132
131
{
133
132
for ( int x = 0 ; x < w ; x ++ )
134
133
{
135
- int diff = a [ aOffset + x ] - b [ bOffset + x ] ;
134
+ int diff = a [ offset + x ] - b [ offset + x ] ;
136
135
count += diff * diff ;
137
136
}
138
137
139
- aOffset += WebpConstants . Bps ;
140
- bOffset += WebpConstants . Bps ;
138
+ offset += WebpConstants . Bps ;
141
139
}
142
140
143
141
return count ;
0 commit comments