@@ -140,7 +140,7 @@ private static void RunVp8Sse16X16Test()
140
140
int expected = 2063 ;
141
141
142
142
// act
143
- int actual = LossyUtils . Vp8_Sse16X16 ( a , b ) ;
143
+ int actual = LossyUtils . Vp8_Sse16x16 ( a , b ) ;
144
144
145
145
// assert
146
146
Assert . Equal ( expected , actual ) ;
@@ -186,7 +186,7 @@ private static void RunVp8Sse16X8Test()
186
186
int expected = 749 ;
187
187
188
188
// act
189
- int actual = LossyUtils . Vp8_Sse16X8 ( a , b ) ;
189
+ int actual = LossyUtils . Vp8_Sse16x8 ( a , b ) ;
190
190
191
191
// assert
192
192
Assert . Equal ( expected , actual ) ;
@@ -195,33 +195,25 @@ private static void RunVp8Sse16X8Test()
195
195
private static void RunVp8Sse4X4Test ( )
196
196
{
197
197
// arrange
198
- byte [ ] a =
198
+ Random rand = new ( 1234 ) ;
199
+ byte [ ] a = new byte [ 128 * 10 ] ;
200
+ byte [ ] b = new byte [ 128 * 10 ] ;
201
+ for ( int i = 0 ; i < a . Length ; i ++ )
199
202
{
200
- 27 , 27 , 28 , 29 , 29 , 28 , 27 , 27 , 27 , 28 , 28 , 29 , 29 , 28 , 28 , 27 , 129 , 129 , 129 , 129 , 129 , 129 , 129 ,
201
- 129 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 27 , 27 , 27 , 27 , 27 , 27 , 27 , 27 , 27 , 28 , 28 , 29 , 29 , 28 ,
202
- 28 , 27 , 129 , 129 , 129 , 129 , 129 , 129 , 129 , 129 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 27 , 27 , 26 ,
203
- 26 , 26 , 26 , 27 , 27 , 27 , 28 , 28 , 29 , 29 , 28 , 28 , 27 , 129 , 129 , 129 , 129 , 129 , 129 , 129 , 129 , 128 ,
204
- 128 , 128 , 128 , 128 , 128 , 128 , 128 , 28 , 27 , 27 , 26 , 26 , 27 , 27 , 28 , 27 , 28 , 28 , 29 , 29 , 28 , 28 , 27 ,
205
- 129 , 129 , 129 , 129 , 129 , 129 , 129 , 129 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128
206
- } ;
207
-
208
- byte [ ] b =
203
+ a [ i ] = ( byte ) rand . Next ( byte . MaxValue ) ;
204
+ b [ i ] = ( byte ) rand . Next ( byte . MaxValue ) ;
205
+ }
206
+ int [ ] expected = { 194133 , 125861 , 165966 , 195688 , 106491 , 173015 , 266960 , 200272 , 311224 , 122545 } ;
207
+
208
+ // act + assert
209
+ int offset = 0 ;
210
+ for ( int i = 0 ; i < expected . Length ; i ++ )
209
211
{
210
- 26 , 26 , 26 , 26 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 204 , 204 , 204 , 204 , 204 , 204 , 204 ,
211
- 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 26 , 26 , 26 , 26 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 ,
212
- 28 , 28 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 26 , 26 , 26 ,
213
- 26 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 ,
214
- 204 , 204 , 204 , 204 , 204 , 204 , 204 , 26 , 26 , 26 , 26 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 , 28 ,
215
- 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204 , 204
216
- } ;
212
+ int actual = LossyUtils . Vp8_Sse4x4 ( a . AsSpan ( offset ) , b . AsSpan ( offset ) ) ;
213
+ Assert . Equal ( expected [ i ] , actual ) ;
217
214
218
- int expected = 27 ;
219
-
220
- // act
221
- int actual = LossyUtils . Vp8_Sse4X4 ( a , b ) ;
222
-
223
- // assert
224
- Assert . Equal ( expected , actual ) ;
215
+ offset += 128 ;
216
+ }
225
217
}
226
218
227
219
private static void RunMean16x4Test ( )
@@ -329,12 +321,15 @@ private static void RunHadamardTransformTest()
329
321
[ Fact ]
330
322
public void Vp8Sse16X8_WithoutAVX2_Works ( ) => FeatureTestRunner . RunWithHwIntrinsicsFeature ( RunVp8Sse16X8Test , HwIntrinsics . DisableAVX2 ) ;
331
323
324
+ // This will test the AVX2 version.
332
325
[ Fact ]
333
326
public void Vp8Sse4X4_WithHardwareIntrinsics_Works ( ) => FeatureTestRunner . RunWithHwIntrinsicsFeature ( RunVp8Sse4X4Test , HwIntrinsics . AllowAll ) ;
334
327
328
+ // This will test the fallback scalar version.
335
329
[ Fact ]
336
- public void Vp8Sse4X4_WithoutSSE2_Works ( ) => FeatureTestRunner . RunWithHwIntrinsicsFeature ( RunVp8Sse4X4Test , HwIntrinsics . DisableSSE2 ) ;
330
+ public void Vp8Sse4X4_WithoutHardwareIntrinsics_Works ( ) => FeatureTestRunner . RunWithHwIntrinsicsFeature ( RunVp8Sse4X4Test , HwIntrinsics . DisableSSE2 | HwIntrinsics . DisableAVX ) ;
337
331
332
+ // This will test the SSE2 version.
338
333
[ Fact ]
339
334
public void Vp8Sse4X4_WithoutAVX2_Works ( ) => FeatureTestRunner . RunWithHwIntrinsicsFeature ( RunVp8Sse4X4Test , HwIntrinsics . DisableAVX2 ) ;
340
335
0 commit comments