@@ -172,7 +172,9 @@ -(void)assertColor8: (NSString*)filename img:(CGImageRef)img expectedColor:(UInt
172
172
for (size_t c = 0 ; c < 3 ; ++c) {
173
173
int32_t result = pix[c];
174
174
int32_t expected = expectedColor[c];
175
- XCTAssertTrue (ok = (abs (result - expected) <= threshold8), " (x: %ld , y: %ld , c:%ld ): result=%d vs expected=%d (%@)" , x, y, c, result, expected, filename);
175
+ XCTAssertTrue (ok = (abs (result - expected) <= threshold8),
176
+ " (x: %ld , y: %ld , c:%ld ): result=%d vs expected=%d (%@)" ,
177
+ x, y, c, result, expected, filename);
176
178
}
177
179
if (!ok) {
178
180
goto end;
@@ -202,9 +204,13 @@ -(void)assertColorAlpha8: (NSString*)filename img:(CGImageRef)img expectedColor:
202
204
for (size_t c = 1 ; c < 4 ; ++c) {
203
205
int32_t result = pix[c];
204
206
int32_t expected = expectedColor[c-1 ];
205
- XCTAssertTrue (ok &= (abs (result - expected) <= threshold8), " (x: %ld , y: %ld , c:%ld ): result=%d vs expected=%d (%@)" , x, y, c, result, expected, filename);
207
+ XCTAssertTrue (ok &= (abs (result - expected) <= threshold8),
208
+ " (x: %ld , y: %ld , c:%ld ): result=%d vs expected=%d (%@)" ,
209
+ x, y, c, result, expected, filename);
206
210
}
207
- XCTAssertTrue (ok &= (pix[0 ] == (x < 128 ? 0xff : 0x00 )), " (x: %ld , y: %ld , c: alpha): result=%d vs expected=%d (%@)" , x, y, pix[0 ], x < 128 ? 0xff : 0x00 , filename);
211
+ XCTAssertTrue (ok &= (pix[0 ] == (x < 128 ? 0xff : 0x00 )),
212
+ " (x: %ld , y: %ld , c: alpha): result=%d vs expected=%d (%@)" ,
213
+ x, y, pix[0 ], x < 128 ? 0xff : 0x00 , filename);
208
214
if (!ok) {
209
215
goto end;
210
216
}
@@ -233,7 +239,9 @@ -(void)assertColor16: (NSString*)filename img:(CGImageRef)img expectedColor:(UIn
233
239
for (size_t c = 0 ; c < 3 ; ++c) {
234
240
int32_t result = pix[c];
235
241
int32_t expected = expectedColor[c];
236
- XCTAssertTrue (ok &= (abs (result - expected) <= threshold16), " (x: %ld , y: %ld , c:%ld ): result=%d vs expected=%d (%@)" , x, y, c, result, expected, filename);
242
+ XCTAssertTrue (ok &= (abs (result - expected) <= threshold16),
243
+ " (x: %ld , y: %ld , c:%ld ): result=%d vs expected=%d (%@)" ,
244
+ x, y, c, result, expected, filename);
237
245
}
238
246
if (!ok) {
239
247
goto end;
@@ -257,15 +265,19 @@ -(void)assertColorAlpha16: (NSString*)filename img:(CGImageRef)img expectedColor
257
265
XCTAssertEqual (numComponents, 4 );
258
266
XCTAssertEqual (bytesPerPixel, 8 );
259
267
for (size_t y = 0 ; y < height; ++y) {
260
- for (size_t x = 0 ; x < width; ++x ) {
268
+ for (size_t x = 64 ; x < width; x+= 128 ) {
261
269
UInt16* pix = (UInt16*)(buf + (stride * y) + (bytesPerPixel * x));
262
270
bool ok = true ;
263
271
for (size_t c = 1 ; c < 4 ; ++c) {
264
272
int32_t result = pix[c];
265
273
int32_t expected = expectedColor[c-1 ];
266
- XCTAssertTrue (ok &= (abs (result - expected) <= threshold16), " (x: %ld , y: %ld , c:%ld ): result=%d vs expected=%d (%@)" , x, y, c, result, expected, filename);
274
+ XCTAssertTrue (ok &= (abs (result - expected) <= threshold16),
275
+ " (x: %ld , y: %ld , c:%ld ): result=%d vs expected=%d (%@)" ,
276
+ x, y, c, result, expected, filename);
267
277
}
268
- XCTAssertTrue (ok &= (pix[0 ] == (x < 128 ? 0xffff : 0x0000 )), " (x: %ld , y: %ld , c: alpha): result=%d vs expected=%d (%@)" , x, y, pix[0 ], x < 128 ? 0xffff : 0x00 , filename);
278
+ XCTAssertTrue (ok &= (pix[0 ] == (x < 128 ? 0xffff : 0x0000 )),
279
+ " (x: %ld , y: %ld , c: alpha): result=%d vs expected=%d (%@)" ,
280
+ x, y, pix[0 ], x < 128 ? 0xffff : 0x00 , filename);
269
281
if (!ok) {
270
282
goto end;
271
283
}
@@ -292,7 +304,9 @@ -(void)assertMono8: (NSString*)filename img:(CGImageRef)img
292
304
for (size_t x = 0 ; x < width; ++x) {
293
305
bool ok = true ;
294
306
UInt8* pix = (buf + (stride * y) + (bytesPerPixel * x));
295
- XCTAssertTrue (ok &= (abs (pix0 - *pix) <= threshold8), " (x: %ld , y: %ld ): result=%d vs expected=%d (%@)" , x, y, *pix, pix0, filename);
307
+ XCTAssertTrue (ok &= (abs (pix0 - *pix) <= threshold8),
308
+ " (x: %ld , y: %ld ): result=%d vs expected=%d (%@)" ,
309
+ x, y, *pix, pix0, filename);
296
310
if (!ok) {
297
311
goto end;
298
312
}
@@ -319,8 +333,12 @@ -(void)assertMonoAlpha8: (NSString*)filename img:(CGImageRef)img
319
333
for (size_t x = 64 ; x < width; x+=128 ) {
320
334
bool ok = true ;
321
335
UInt8* pix = (buf + (stride * y) + (bytesPerPixel * x));
322
- XCTAssertTrue (ok &= (abs (pix0 - pix[1 ]) <= threshold8), " (x: %ld , y: %ld , c: mono): result=%d vs expected=%d (%@)" , x, y, pix[1 ], pix0, filename);
323
- XCTAssertTrue (ok &= (pix[0 ] == (x < 128 ? 0xff : 0x00 )), " (x: %ld , y: %ld , c: alpha): result=%d vs expected=%d (%@)" , x, y, pix[0 ], x < 128 ? 0xff : 0x00 , filename);
336
+ XCTAssertTrue (ok &= (abs (pix0 - pix[1 ]) <= threshold8),
337
+ " (x: %ld , y: %ld , c: mono): result=%d vs expected=%d (%@)" ,
338
+ x, y, pix[1 ], pix0, filename);
339
+ XCTAssertTrue (ok &= (pix[0 ] == (x < 128 ? 0xff : 0x00 )),
340
+ " (x: %ld , y: %ld , c: alpha): result=%d vs expected=%d (%@)" ,
341
+ x, y, pix[0 ], x < 128 ? 0xff : 0x00 , filename);
324
342
if (!ok) {
325
343
goto end;
326
344
}
@@ -348,7 +366,9 @@ -(void)assertMono16: (NSString*)filename img:(CGImageRef)img
348
366
for (size_t x = 0 ; x < width; ++x) {
349
367
UInt16* pix = (UInt16*)(buf + (stride * y) + (bytesPerPixel * x));
350
368
bool ok = true ;
351
- XCTAssertTrue (ok &= (abs (pix0 - *pix) <= threshold16), " (x: %ld , y: %ld ): result=%d vs expected=%d (%@)" , x, y, *pix, pix0, filename);
369
+ XCTAssertTrue (ok &= (abs (pix0 - *pix) <= threshold16),
370
+ " (x: %ld , y: %ld ): result=%d vs expected=%d (%@)" ,
371
+ x, y, *pix, pix0, filename);
352
372
if (!ok) {
353
373
goto end;
354
374
}
@@ -372,11 +392,15 @@ -(void)assertMonoAlpha16: (NSString*)filename img:(CGImageRef)img
372
392
XCTAssertEqual (bytesPerPixel, 4 );
373
393
UInt16 const pix0 = ((UInt16*)buf)[1 ];
374
394
for (size_t y = 0 ; y < height; ++y) {
375
- for (size_t x = 0 ; x < width; ++x ) {
395
+ for (size_t x = 64 ; x < width; x+= 128 ) {
376
396
UInt16* pix = (UInt16*)(buf + (stride * y) + (bytesPerPixel * x));
377
397
bool ok = true ;
378
- XCTAssertTrue (ok &= (abs (pix0 - pix[1 ]) <= threshold16), " (x: %ld , y: %ld ): result=%d vs expected=%d (%@)" , x, y, pix[1 ], pix0, filename);
379
- XCTAssertTrue (ok &= (pix[0 ] == (x < 128 ? 0xffff : 0x0000 )), " (x: %ld , y: %ld , c: alpha): result=%d vs expected=%d (%@)" , x, y, pix[0 ], x < 128 ? 0xffff : 0x0000 , filename);
398
+ XCTAssertTrue (ok &= (abs (pix0 - pix[1 ]) <= threshold16),
399
+ " (x: %ld , y: %ld ): result=%d vs expected=%d (%@)" ,
400
+ x, y, pix[1 ], pix0, filename);
401
+ XCTAssertTrue (ok &= (pix[0 ] == (x < 128 ? 0xffff : 0x0000 )),
402
+ " (x: %ld , y: %ld , c: alpha): result=%d vs expected=%d (%@)" ,
403
+ x, y, pix[0 ], x < 128 ? 0xffff : 0x0000 , filename);
380
404
if (!ok) {
381
405
goto end;
382
406
}
@@ -420,9 +444,7 @@ - (void)assertImages: (NSMutableArray*) list colorName:(NSString*)colorName expe
420
444
}
421
445
}else {
422
446
if ([alpha isEqualToString: @" with-alpha" ]) {
423
- // FIXME(ledyba-z): This issue blocks testing alpha plane:
424
- // https://github.com/AOMediaCodec/libavif/issues/86
425
- // [self assertMonoAlpha16: convertedFilename img:img.CGImage];
447
+ [self assertMonoAlpha16: convertedFilename img: img.CGImage];
426
448
}else {
427
449
[self assertMono16: convertedFilename img: img.CGImage];
428
450
}
@@ -436,9 +458,7 @@ - (void)assertImages: (NSMutableArray*) list colorName:(NSString*)colorName expe
436
458
}
437
459
} else {
438
460
if ([alpha isEqualToString: @" with-alpha" ]) {
439
- // FIXME(ledyba-z): This issue blocks testing alpha plane:
440
- // https://github.com/AOMediaCodec/libavif/issues/86
441
- // [self assertColorAlpha16: convertedFilename img:img.CGImage expectedColor:expectedColor16];
461
+ [self assertColorAlpha16: convertedFilename img: img.CGImage expectedColor: expectedColor16];
442
462
} else {
443
463
[self assertColor16: convertedFilename img: img.CGImage expectedColor: expectedColor16];
444
464
}
0 commit comments