@@ -34,7 +34,7 @@ impl Unpredict for NoPredictor {
34
34
fix_endianness (
35
35
& mut res[ ..] ,
36
36
predictor_info. endianness ,
37
- predictor_info. bits_per_sample [ 0 ] ,
37
+ predictor_info. bits_per_sample ,
38
38
) ;
39
39
Ok ( res. into ( ) )
40
40
}
@@ -54,7 +54,7 @@ impl Unpredict for HorizontalPredictor {
54
54
) -> AsyncTiffResult < Bytes > {
55
55
let output_row_stride = predictor_info. output_row_stride ( tile_x) ?;
56
56
let samples = predictor_info. samples_per_pixel as usize ;
57
- let bit_depth = predictor_info. bits_per_sample [ 0 ] ;
57
+ let bit_depth = predictor_info. bits_per_sample ;
58
58
59
59
let mut res = BytesMut :: from ( buffer) ;
60
60
fix_endianness ( & mut res[ ..] , predictor_info. endianness , bit_depth) ;
@@ -152,7 +152,7 @@ impl Unpredict for FloatingPointPredictor {
152
152
let mut res: BytesMut = BytesMut :: zeroed (
153
153
output_row_stride * predictor_info. chunk_height_pixels ( tile_y) ? as usize ,
154
154
) ;
155
- let bit_depth = predictor_info. bits_per_sample [ 0 ] as usize ;
155
+ let bit_depth = predictor_info. bits_per_sample ;
156
156
if predictor_info. chunk_width_pixels ( tile_x) ? == predictor_info. chunk_width {
157
157
// no special padding handling
158
158
let mut input = BytesMut :: from ( buffer) ;
@@ -173,7 +173,7 @@ impl Unpredict for FloatingPointPredictor {
173
173
let mut input = BytesMut :: from ( buffer) ;
174
174
175
175
let input_row_stride =
176
- predictor_info. chunk_width as usize * predictor_info. bits_per_pixel ( ) / 8 ;
176
+ predictor_info. chunk_width as usize * predictor_info. bits_per_sample as usize / 8 ;
177
177
for ( in_buf, out_buf) in input
178
178
. chunks_mut ( input_row_stride)
179
179
. zip ( res. chunks_mut ( output_row_stride) )
@@ -297,7 +297,7 @@ mod test {
297
297
image_height : 7 ,
298
298
chunk_width : 4 ,
299
299
chunk_height : 4 ,
300
- bits_per_sample : & [ 8 ] ,
300
+ bits_per_sample : 8 ,
301
301
samples_per_pixel : 1 ,
302
302
planar_configuration : crate :: tiff:: tags:: PlanarConfiguration :: Chunky ,
303
303
} ;
@@ -379,104 +379,104 @@ mod test {
379
379
for ( x, y, input, expected) in cases {
380
380
println ! ( "uints littleendian" ) ;
381
381
predictor_info. endianness = Endianness :: LittleEndian ;
382
- predictor_info. bits_per_sample = & [ 8 ] ;
382
+ predictor_info. bits_per_sample = 8 ;
383
383
assert_eq ! ( -1i32 as u8 , 255 ) ;
384
384
println ! ( "testing u8" ) ;
385
385
let buffer = Bytes :: from ( input. iter ( ) . map ( |v| * v as u8 ) . collect :: < Vec < _ > > ( ) ) ;
386
386
let res = Bytes :: from ( expected. clone ( ) ) ;
387
387
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
388
388
assert_eq ! ( -1i32 as u16 , u16 :: MAX ) ;
389
389
println ! ( "testing u16" ) ;
390
- predictor_info. bits_per_sample = & [ 16 ] ;
390
+ predictor_info. bits_per_sample = 16 ;
391
391
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as u16 ) . to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
392
392
let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as u16 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
393
393
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
394
394
assert_eq ! ( -1i32 as u32 , u32 :: MAX ) ;
395
395
println ! ( "testing u32" ) ;
396
- predictor_info. bits_per_sample = & [ 32 ] ;
396
+ predictor_info. bits_per_sample = 32 ;
397
397
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as u32 ) . to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
398
398
let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as u32 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
399
399
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
400
400
assert_eq ! ( -1i32 as u64 , u64 :: MAX ) ;
401
401
println ! ( "testing u64" ) ;
402
- predictor_info. bits_per_sample = & [ 64 ] ;
402
+ predictor_info. bits_per_sample = 64 ;
403
403
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as u64 ) . to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
404
404
let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as u64 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
405
405
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
406
406
407
407
println ! ( "ints littleendian" ) ;
408
- predictor_info. bits_per_sample = & [ 8 ] ;
408
+ predictor_info. bits_per_sample = 8 ;
409
409
println ! ( "testing i8" ) ;
410
410
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i8 ) . to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
411
411
println ! ( "{:?}" , & buffer[ ..] ) ;
412
412
let res = Bytes :: from ( expected. clone ( ) ) ;
413
413
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) [ ..] , res[ ..] ) ;
414
414
println ! ( "testing i16" ) ;
415
- predictor_info. bits_per_sample = & [ 16 ] ;
415
+ predictor_info. bits_per_sample = 16 ;
416
416
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i16 ) . to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
417
417
let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as i16 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
418
418
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
419
419
println ! ( "testing i32" ) ;
420
- predictor_info. bits_per_sample = & [ 32 ] ;
420
+ predictor_info. bits_per_sample = 32 ;
421
421
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| v. to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
422
422
let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as i32 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
423
423
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
424
424
println ! ( "testing i64" ) ;
425
- predictor_info. bits_per_sample = & [ 64 ] ;
425
+ predictor_info. bits_per_sample = 64 ;
426
426
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i64 ) . to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
427
427
let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as i64 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
428
428
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
429
429
430
430
println ! ( "uints bigendian" ) ;
431
431
predictor_info. endianness = Endianness :: BigEndian ;
432
- predictor_info. bits_per_sample = & [ 8 ] ;
432
+ predictor_info. bits_per_sample = 8 ;
433
433
assert_eq ! ( -1i32 as u8 , 255 ) ;
434
434
println ! ( "testing u8" ) ;
435
435
let buffer = Bytes :: from ( input. iter ( ) . map ( |v| * v as u8 ) . collect :: < Vec < _ > > ( ) ) ;
436
436
let res = Bytes :: from ( expected. clone ( ) ) ;
437
437
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
438
438
assert_eq ! ( -1i32 as u16 , u16 :: MAX ) ;
439
439
println ! ( "testing u16" ) ;
440
- predictor_info. bits_per_sample = & [ 16 ] ;
440
+ predictor_info. bits_per_sample = 16 ;
441
441
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as u16 ) . to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
442
442
let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as u16 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
443
443
println ! ( "buffer: {:?}" , & buffer[ ..] ) ;
444
444
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) [ ..] , res[ ..] ) ;
445
445
assert_eq ! ( -1i32 as u32 , u32 :: MAX ) ;
446
446
println ! ( "testing u32" ) ;
447
- predictor_info. bits_per_sample = & [ 32 ] ;
447
+ predictor_info. bits_per_sample = 32 ;
448
448
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as u32 ) . to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
449
449
let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as u32 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
450
450
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
451
451
assert_eq ! ( -1i32 as u64 , u64 :: MAX ) ;
452
452
println ! ( "testing u64" ) ;
453
- predictor_info. bits_per_sample = & [ 64 ] ;
453
+ predictor_info. bits_per_sample = 64 ;
454
454
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as u64 ) . to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
455
455
let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as u64 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
456
456
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
457
457
458
458
println ! ( "ints bigendian" ) ;
459
- predictor_info. bits_per_sample = & [ 8 ] ;
459
+ predictor_info. bits_per_sample = 8 ;
460
460
assert_eq ! ( -1i32 as u8 , 255 ) ;
461
461
println ! ( "testing i8" ) ;
462
462
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i8 ) . to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
463
463
let res = Bytes :: from ( expected. clone ( ) ) ;
464
464
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
465
465
assert_eq ! ( -1i32 as u16 , u16 :: MAX ) ;
466
466
println ! ( "testing i16" ) ;
467
- predictor_info. bits_per_sample = & [ 16 ] ;
467
+ predictor_info. bits_per_sample = 16 ;
468
468
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i16 ) . to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
469
469
let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as i16 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
470
470
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
471
471
assert_eq ! ( -1i32 as u32 , u32 :: MAX ) ;
472
472
println ! ( "testing i32" ) ;
473
- predictor_info. bits_per_sample = & [ 32 ] ;
473
+ predictor_info. bits_per_sample = 32 ;
474
474
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| v. to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
475
475
let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as i32 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
476
476
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
477
477
assert_eq ! ( -1i32 as u64 , u64 :: MAX ) ;
478
478
println ! ( "testing i64" ) ;
479
- predictor_info. bits_per_sample = & [ 64 ] ;
479
+ predictor_info. bits_per_sample = 64 ;
480
480
let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i64 ) . to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
481
481
let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as i64 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
482
482
assert_eq ! ( p. fix_endianness_and_unpredict( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
@@ -501,7 +501,7 @@ mod test {
501
501
image_height : 4 +1 ,
502
502
chunk_width : 4 ,
503
503
chunk_height : 4 ,
504
- bits_per_sample : & [ 16 ] ,
504
+ bits_per_sample : 16 ,
505
505
samples_per_pixel : 1 ,
506
506
planar_configuration : PlanarConfiguration :: Chunky ,
507
507
} ;
@@ -530,7 +530,7 @@ mod test {
530
530
image_height : 4 +1 ,
531
531
chunk_width : 4 ,
532
532
chunk_height : 4 ,
533
- bits_per_sample : & [ 16 ] ,
533
+ bits_per_sample : 16 ,
534
534
samples_per_pixel : 1 ,
535
535
planar_configuration : PlanarConfiguration :: Chunky ,
536
536
} ;
@@ -558,7 +558,7 @@ mod test {
558
558
image_height : 2 + 1 ,
559
559
chunk_width : 2 ,
560
560
chunk_height : 2 ,
561
- bits_per_sample : & [ 32 ] ,
561
+ bits_per_sample : 32 ,
562
562
samples_per_pixel : 1 ,
563
563
planar_configuration : PlanarConfiguration :: Chunky ,
564
564
} ;
@@ -592,7 +592,7 @@ mod test {
592
592
image_height : 2 + 1 ,
593
593
chunk_width : 2 ,
594
594
chunk_height : 2 ,
595
- bits_per_sample : & [ 64 ] ,
595
+ bits_per_sample : 64 ,
596
596
samples_per_pixel : 1 ,
597
597
planar_configuration : PlanarConfiguration :: Chunky ,
598
598
} ;
0 commit comments