@@ -15,7 +15,7 @@ use crate::{
15
15
///
16
16
///
17
17
///
18
- pub struct RevPredictorRegistry ( HashMap < Predictor , Box < dyn RevPredictor > > ) ;
18
+ pub struct RevPredictorRegistry ( HashMap < Predictor , Box < dyn RevPredict > > ) ;
19
19
20
20
impl RevPredictorRegistry {
21
21
/// create a new predictor registry with no predictors registered
@@ -24,8 +24,8 @@ impl RevPredictorRegistry {
24
24
}
25
25
}
26
26
27
- impl AsRef < HashMap < Predictor , Box < dyn RevPredictor > > > for RevPredictorRegistry {
28
- fn as_ref ( & self ) -> & HashMap < Predictor , Box < dyn RevPredictor > > {
27
+ impl AsRef < HashMap < Predictor , Box < dyn RevPredict > > > for RevPredictorRegistry {
28
+ fn as_ref ( & self ) -> & HashMap < Predictor , Box < dyn RevPredict > > {
29
29
& self . 0
30
30
}
31
31
}
@@ -46,7 +46,7 @@ impl Default for RevPredictorRegistry {
46
46
/// Trait for reverse predictors to implement
47
47
///
48
48
///
49
- pub trait RevPredictor : Debug + Send + Sync {
49
+ pub trait RevPredict : Debug + Send + Sync {
50
50
/// reverse predict the decompressed bytes and fix endianness on the output
51
51
///
52
52
///
@@ -63,7 +63,7 @@ pub trait RevPredictor: Debug + Send + Sync {
63
63
#[ derive( Debug ) ]
64
64
pub struct NoPredictor ;
65
65
66
- impl RevPredictor for NoPredictor {
66
+ impl RevPredict for NoPredictor {
67
67
fn rev_predict_fix_endianness (
68
68
& self ,
69
69
buffer : Bytes ,
@@ -85,7 +85,7 @@ impl RevPredictor for NoPredictor {
85
85
#[ derive( Debug ) ]
86
86
pub struct RevHorizontalPredictor ;
87
87
88
- impl RevPredictor for RevHorizontalPredictor {
88
+ impl RevPredict for RevHorizontalPredictor {
89
89
fn rev_predict_fix_endianness (
90
90
& self ,
91
91
buffer : Bytes ,
@@ -98,12 +98,10 @@ impl RevPredictor for RevHorizontalPredictor {
98
98
let bit_depth = predictor_info. bits_per_sample [ 0 ] ;
99
99
100
100
let mut res = BytesMut :: from ( buffer) ;
101
+ fix_endianness ( & mut res[ ..] , predictor_info. endianness , bit_depth) ;
101
102
for buf in res. chunks_mut ( output_row_stride) {
102
- // this is rev_hpredict_nsamp from image-tiff
103
103
rev_hpredict_nsamp ( buf, bit_depth, samples) ;
104
- // end rev_hpredict_nsamp
105
104
}
106
- fix_endianness ( & mut res[ ..] , predictor_info. endianness , bit_depth) ;
107
105
Ok ( res. into ( ) )
108
106
}
109
107
}
@@ -181,7 +179,7 @@ pub fn fix_endianness(buf: &mut [u8], byte_order: Endianness, bit_depth: u16) {
181
179
#[ derive( Debug ) ]
182
180
pub struct RevFloatingPointPredictor ;
183
181
184
- impl RevPredictor for RevFloatingPointPredictor {
182
+ impl RevPredict for RevFloatingPointPredictor {
185
183
fn rev_predict_fix_endianness (
186
184
& self ,
187
185
buffer : Bytes ,
@@ -312,6 +310,8 @@ pub fn rev_predict_f64(input: &mut [u8], output: &mut [u8], samples: usize) {
312
310
313
311
#[ cfg( test) ]
314
312
mod test {
313
+ use std:: vec;
314
+
315
315
use bytes:: Bytes ;
316
316
317
317
use crate :: {
@@ -321,64 +321,48 @@ mod test {
321
321
tile:: PredictorInfo ,
322
322
} ;
323
323
324
- use super :: { NoPredictor , RevHorizontalPredictor , RevPredictor } ;
324
+ use super :: { NoPredictor , RevHorizontalPredictor , RevPredict } ;
325
325
326
326
const PRED_INFO : PredictorInfo = PredictorInfo {
327
327
endianness : Endianness :: LittleEndian ,
328
- image_width : 15 ,
329
- image_height : 15 ,
330
- chunk_width : 8 ,
331
- chunk_height : 8 ,
328
+ image_width : 7 ,
329
+ image_height : 7 ,
330
+ chunk_width : 4 ,
331
+ chunk_height : 4 ,
332
332
bits_per_sample : & [ 8 ] ,
333
333
samples_per_pixel : 1 ,
334
334
sample_format : & [ SampleFormat :: Uint ] ,
335
335
planar_configuration : crate :: tiff:: tags:: PlanarConfiguration :: Chunky ,
336
336
} ;
337
337
#[ rustfmt:: skip]
338
- const RES : [ u8 ; 64 ] = [
339
- 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ,
340
- 1 , 0 , 1 , 2 , 3 , 4 , 5 , 6 ,
341
- 2 , 1 , 0 , 1 , 2 , 3 , 4 , 5 ,
342
- 3 , 2 , 1 , 0 , 1 , 2 , 3 , 4 ,
343
-
344
- 4 , 3 , 2 , 1 , 0 , 1 , 2 , 3 ,
345
- 5 , 4 , 3 , 2 , 1 , 0 , 1 , 2 ,
346
- 6 , 5 , 4 , 3 , 2 , 1 , 0 , 1 ,
347
- 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 ,
338
+ const RES : [ u8 ; 16 ] = [
339
+ 0 , 1 , 2 , 3 ,
340
+ 1 , 0 , 1 , 2 ,
341
+
342
+ 2 , 1 , 0 , 1 ,
343
+ 3 , 2 , 1 , 0 ,
348
344
] ;
349
345
#[ rustfmt:: skip]
350
- const RES_RIGHT : [ u8 ; 56 ] = [
351
- 0 , 1 , 2 , 3 , 4 , 5 , 6 ,
352
- 1 , 0 , 1 , 2 , 3 , 4 , 5 ,
353
- 2 , 1 , 0 , 1 , 2 , 3 , 4 ,
354
- 3 , 2 , 1 , 0 , 1 , 2 , 3 ,
355
-
356
- 4 , 3 , 2 , 1 , 0 , 1 , 2 ,
357
- 5 , 4 , 3 , 2 , 1 , 0 , 1 ,
358
- 6 , 5 , 4 , 3 , 2 , 1 , 0 ,
359
- 7 , 6 , 5 , 4 , 3 , 2 , 1 ,
346
+ const RES_RIGHT : [ u8 ; 12 ] = [
347
+ 0 , 1 , 2 ,
348
+ 1 , 0 , 1 ,
349
+
350
+ 2 , 1 , 0 ,
351
+ 3 , 2 , 1 ,
360
352
] ;
361
353
#[ rustfmt:: skip]
362
- const RES_BOT : [ u8 ; 56 ] = [
363
- 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ,
364
- 1 , 0 , 1 , 2 , 3 , 4 , 5 , 6 ,
365
- 2 , 1 , 0 , 1 , 2 , 3 , 4 , 5 ,
366
- 3 , 2 , 1 , 0 , 1 , 2 , 3 , 4 ,
367
-
368
- 4 , 3 , 2 , 1 , 0 , 1 , 2 , 3 ,
369
- 5 , 4 , 3 , 2 , 1 , 0 , 1 , 2 ,
370
- 6 , 5 , 4 , 3 , 2 , 1 , 0 , 1 ,
354
+ const RES_BOT : [ u8 ; 12 ] = [
355
+ 0 , 1 , 2 , 3 ,
356
+ 1 , 0 , 1 , 2 ,
357
+
358
+ 2 , 1 , 0 , 1 ,
371
359
] ;
372
360
#[ rustfmt:: skip]
373
- const RES_BOT_RIGHT : [ u8 ; 49 ] = [
374
- 0 , 1 , 2 , 3 , 4 , 5 , 6 ,
375
- 1 , 0 , 1 , 2 , 3 , 4 , 5 ,
376
- 2 , 1 , 0 , 1 , 2 , 3 , 4 ,
377
- 3 , 2 , 1 , 0 , 1 , 2 , 3 ,
378
-
379
- 4 , 3 , 2 , 1 , 0 , 1 , 2 ,
380
- 5 , 4 , 3 , 2 , 1 , 0 , 1 ,
381
- 6 , 5 , 4 , 3 , 2 , 1 , 0 ,
361
+ const RES_BOT_RIGHT : [ u8 ; 9 ] = [
362
+ 0 , 1 , 2 ,
363
+ 1 , 0 , 1 ,
364
+
365
+ 2 , 1 , 0 ,
382
366
] ;
383
367
384
368
#[ rustfmt:: skip]
@@ -400,57 +384,139 @@ mod test {
400
384
#[ test]
401
385
fn test_hpredict ( ) {
402
386
let p = RevHorizontalPredictor ;
387
+ let mut predictor_info = PRED_INFO . clone ( ) ;
403
388
let cases = [
404
- ( 0 , 0 , Bytes :: from_static ( & [
405
- 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
406
- 1 , 255 , 1 , 1 , 1 , 1 , 1 , 1 ,
407
- 2 , 255 , 255 , 1 , 1 , 1 , 1 , 1 ,
408
- 3 , 255 , 255 , 255 , 1 , 1 , 1 , 1 ,
409
-
410
- 4 , 255 , 255 , 255 , 255 , 1 , 1 , 1 ,
411
- 5 , 255 , 255 , 255 , 255 , 255 , 1 , 1 ,
412
- 6 , 255 , 255 , 255 , 255 , 255 , 255 , 1 ,
413
- 7 , 255 , 255 , 255 , 255 , 255 , 255 , 255 ,
414
- ] ) , Bytes :: from_static ( & RES [ ..] ) ) ,
415
- ( 0 , 1 , Bytes :: from_static ( & [
416
- 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
417
- 1 , 255 , 1 , 1 , 1 , 1 , 1 , 1 ,
418
- 2 , 255 , 255 , 1 , 1 , 1 , 1 , 1 ,
419
- 3 , 255 , 255 , 255 , 1 , 1 , 1 , 1 ,
420
-
421
- 4 , 255 , 255 , 255 , 255 , 1 , 1 , 1 ,
422
- 5 , 255 , 255 , 255 , 255 , 255 , 1 , 1 ,
423
- 6 , 255 , 255 , 255 , 255 , 255 , 255 , 1 ,
424
- ] ) , Bytes :: from_static ( & RES_BOT [ ..] ) ) ,
425
- ( 1 , 0 , Bytes :: from_static ( & [
426
- 0 , 1 , 1 , 1 , 1 , 1 , 1 ,
427
- 1 , 255 , 1 , 1 , 1 , 1 , 1 ,
428
- 2 , 255 , 255 , 1 , 1 , 1 , 1 ,
429
- 3 , 255 , 255 , 255 , 1 , 1 , 1 ,
430
-
431
- 4 , 255 , 255 , 255 , 255 , 1 , 1 ,
432
- 5 , 255 , 255 , 255 , 255 , 255 , 1 ,
433
- 6 , 255 , 255 , 255 , 255 , 255 , 255 ,
434
- 7 , 255 , 255 , 255 , 255 , 255 , 255 ,
435
- ] ) , Bytes :: from_static ( & RES_RIGHT [ ..] ) ) ,
436
- ( 1 , 1 , Bytes :: from_static ( & [
437
- 0 , 1 , 1 , 1 , 1 , 1 , 1 ,
438
- 1 , 255 , 1 , 1 , 1 , 1 , 1 ,
439
- 2 , 255 , 255 , 1 , 1 , 1 , 1 ,
440
- 3 , 255 , 255 , 255 , 1 , 1 , 1 ,
441
-
442
- 4 , 255 , 255 , 255 , 255 , 1 , 1 ,
443
- 5 , 255 , 255 , 255 , 255 , 255 , 1 ,
444
- 6 , 255 , 255 , 255 , 255 , 255 , 255 ,
445
- ] ) , Bytes :: from_static ( & RES_BOT_RIGHT [ ..] ) )
389
+ ( 0 , 0 , vec ! [
390
+ 0i32 , 1 , 1 , 1 ,
391
+ 1 , -1 , 1 , 1 ,
392
+ 2 , -1 , -1 , 1 ,
393
+ 3 , -1 , -1 , -1 ,
394
+ ] , Vec :: from ( & RES [ ..] ) ) ,
395
+ ( 0 , 1 , vec ! [
396
+ 0 , 1 , 1 , 1 ,
397
+ 1 , -1 , 1 , 1 ,
398
+ 2 , -1 , -1 , 1 ,
399
+ ] , Vec :: from ( & RES_BOT [ ..] ) ) ,
400
+ ( 1 , 0 , vec ! [
401
+ 0 , 1 , 1 ,
402
+ 1 , -1 , 1 ,
403
+ 2 , -1 , -1 ,
404
+ 3 , -1 , -1 ,
405
+ ] , Vec :: from ( & RES_RIGHT [ ..] ) ) ,
406
+ ( 1 , 1 , vec ! [
407
+ 0 , 1 , 1 ,
408
+ 1 , -1 , 1 ,
409
+ 2 , -1 , -1 ,
410
+ ] , Vec :: from ( & RES_BOT_RIGHT [ ..] ) ) ,
446
411
] ;
447
412
for ( x, y, input, expected) in cases {
448
- let res = p. rev_predict_fix_endianness ( input. clone ( ) , & PRED_INFO , x, y) . unwrap ( ) ;
449
- println ! ( "testing ({x},{y}): {:?}?={:?}" , & res[ ..] , & expected[ ..] ) ;
450
- assert_eq ! ( res, expected) ;
451
-
452
- // also errors shouldn't crash
453
- // p.rev_predict_fix_endianness(input, &PRED_INFO, x+1, y+1).unwrap_err();
413
+ println ! ( "uints littleendian" ) ;
414
+ predictor_info. endianness = Endianness :: LittleEndian ;
415
+ predictor_info. sample_format = & [ SampleFormat :: Uint ] ;
416
+ predictor_info. bits_per_sample = & [ 8 ] ;
417
+ assert_eq ! ( -1i32 as u8 , 255 ) ;
418
+ println ! ( "testing u8" ) ;
419
+ let buffer = Bytes :: from ( input. iter ( ) . map ( |v| * v as u8 ) . collect :: < Vec < _ > > ( ) ) ;
420
+ let res = Bytes :: from ( expected. clone ( ) ) ;
421
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
422
+ assert_eq ! ( -1i32 as u16 , u16 :: MAX ) ;
423
+ println ! ( "testing u16" ) ;
424
+ predictor_info. bits_per_sample = & [ 16 ] ;
425
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as u16 ) . to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
426
+ let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as u16 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
427
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
428
+ assert_eq ! ( -1i32 as u32 , u32 :: MAX ) ;
429
+ println ! ( "testing u32" ) ;
430
+ predictor_info. bits_per_sample = & [ 32 ] ;
431
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as u32 ) . to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
432
+ let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as u32 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
433
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
434
+ assert_eq ! ( -1i32 as u64 , u64 :: MAX ) ;
435
+ println ! ( "testing u64" ) ;
436
+ predictor_info. bits_per_sample = & [ 64 ] ;
437
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as u64 ) . to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
438
+ let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as u64 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
439
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
440
+
441
+ println ! ( "ints littleendian" ) ;
442
+ predictor_info. sample_format = & [ SampleFormat :: Int ] ;
443
+ predictor_info. bits_per_sample = & [ 8 ] ;
444
+ println ! ( "testing i8" ) ;
445
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i8 ) . to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
446
+ println ! ( "{:?}" , & buffer[ ..] ) ;
447
+ let res = Bytes :: from ( expected. clone ( ) ) ;
448
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) [ ..] , res[ ..] ) ;
449
+ println ! ( "testing i16" ) ;
450
+ predictor_info. bits_per_sample = & [ 16 ] ;
451
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i16 ) . to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
452
+ let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as i16 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
453
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
454
+ println ! ( "testing i32" ) ;
455
+ predictor_info. bits_per_sample = & [ 32 ] ;
456
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i32 ) . to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
457
+ let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as i32 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
458
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
459
+ println ! ( "testing i64" ) ;
460
+ predictor_info. bits_per_sample = & [ 64 ] ;
461
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i64 ) . to_le_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
462
+ let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as i64 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
463
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
464
+
465
+ println ! ( "uints bigendian" ) ;
466
+ predictor_info. endianness = Endianness :: BigEndian ;
467
+ predictor_info. sample_format = & [ SampleFormat :: Uint ] ;
468
+ predictor_info. bits_per_sample = & [ 8 ] ;
469
+ assert_eq ! ( -1i32 as u8 , 255 ) ;
470
+ println ! ( "testing u8" ) ;
471
+ let buffer = Bytes :: from ( input. iter ( ) . map ( |v| * v as u8 ) . collect :: < Vec < _ > > ( ) ) ;
472
+ let res = Bytes :: from ( expected. clone ( ) ) ;
473
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
474
+ assert_eq ! ( -1i32 as u16 , u16 :: MAX ) ;
475
+ println ! ( "testing u16" ) ;
476
+ predictor_info. bits_per_sample = & [ 16 ] ;
477
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as u16 ) . to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
478
+ let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as u16 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
479
+ println ! ( "buffer: {:?}" , & buffer[ ..] ) ;
480
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) [ ..] , res[ ..] ) ;
481
+ assert_eq ! ( -1i32 as u32 , u32 :: MAX ) ;
482
+ println ! ( "testing u32" ) ;
483
+ predictor_info. bits_per_sample = & [ 32 ] ;
484
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as u32 ) . to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
485
+ let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as u32 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
486
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
487
+ assert_eq ! ( -1i32 as u64 , u64 :: MAX ) ;
488
+ println ! ( "testing u64" ) ;
489
+ predictor_info. bits_per_sample = & [ 64 ] ;
490
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as u64 ) . to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
491
+ let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as u64 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
492
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
493
+
494
+ println ! ( "ints bigendian" ) ;
495
+ predictor_info. sample_format = & [ SampleFormat :: Int ] ;
496
+ predictor_info. bits_per_sample = & [ 8 ] ;
497
+ assert_eq ! ( -1i32 as u8 , 255 ) ;
498
+ println ! ( "testing i8" ) ;
499
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i8 ) . to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
500
+ let res = Bytes :: from ( expected. clone ( ) ) ;
501
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
502
+ assert_eq ! ( -1i32 as u16 , u16 :: MAX ) ;
503
+ println ! ( "testing i16" ) ;
504
+ predictor_info. bits_per_sample = & [ 16 ] ;
505
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i16 ) . to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
506
+ let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as i16 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
507
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
508
+ assert_eq ! ( -1i32 as u32 , u32 :: MAX ) ;
509
+ println ! ( "testing i32" ) ;
510
+ predictor_info. bits_per_sample = & [ 32 ] ;
511
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i32 ) . to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
512
+ let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as i32 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
513
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
514
+ assert_eq ! ( -1i32 as u64 , u64 :: MAX ) ;
515
+ println ! ( "testing i64" ) ;
516
+ predictor_info. bits_per_sample = & [ 64 ] ;
517
+ let buffer = Bytes :: from ( input. iter ( ) . flat_map ( |v| ( * v as i64 ) . to_be_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
518
+ let res = Bytes :: from ( expected. iter ( ) . flat_map ( |v| ( * v as i64 ) . to_ne_bytes ( ) ) . collect :: < Vec < _ > > ( ) ) ;
519
+ assert_eq ! ( p. rev_predict_fix_endianness( buffer, & predictor_info, x, y) . unwrap( ) , res) ;
454
520
}
455
521
}
456
522
0 commit comments