@@ -12,7 +12,7 @@ use half::f16;
1212
1313use  self :: ifd:: Directory ; 
1414use  self :: image:: Image ; 
15- use  self :: stream:: { ByteOrder ,  EndianReader ,   SmartReader } ; 
15+ use  self :: stream:: { ByteOrder ,  EndianReader } ; 
1616
1717pub  mod  ifd; 
1818mod  image; 
@@ -260,7 +260,7 @@ pub struct Decoder<R>
260260where 
261261    R :  Read  + Seek , 
262262{ 
263-     reader :  SmartReader < R > , 
263+     reader :  EndianReader < R > , 
264264    bigtiff :  bool , 
265265    limits :  Limits , 
266266    next_ifd :  Option < u64 > , 
@@ -462,7 +462,7 @@ impl<R: Read + Seek> Decoder<R> {
462462                ) ) 
463463            } 
464464        } ; 
465-         let  mut  reader = SmartReader :: wrap ( r,  byte_order) ; 
465+         let  mut  reader = EndianReader :: new ( r,  byte_order) ; 
466466
467467        let  bigtiff = match  reader. read_u16 ( ) ? { 
468468            42  => false , 
@@ -640,7 +640,7 @@ impl<R: Read + Seek> Decoder<R> {
640640     #[ inline]  
641641    pub  fn  read_byte ( & mut  self )  -> Result < u8 ,  io:: Error >  { 
642642        let  mut  buf = [ 0 ;  1 ] ; 
643-         self . reader . read_exact ( & mut  buf) ?; 
643+         self . reader . inner ( ) . read_exact ( & mut  buf) ?; 
644644        Ok ( buf[ 0 ] ) 
645645    } 
646646
@@ -694,7 +694,7 @@ impl<R: Read + Seek> Decoder<R> {
694694     #[ inline]  
695695    pub  fn  read_string ( & mut  self ,  length :  usize )  -> TiffResult < String >  { 
696696        let  mut  out = vec ! [ 0 ;  length] ; 
697-         self . reader . read_exact ( & mut  out) ?; 
697+         self . reader . inner ( ) . read_exact ( & mut  out) ?; 
698698        // Strings may be null-terminated, so we trim anything downstream of the null byte 
699699        if  let  Some ( first)  = out. iter ( ) . position ( |& b| b == 0 )  { 
700700            out. truncate ( first) ; 
@@ -711,15 +711,15 @@ impl<R: Read + Seek> Decoder<R> {
711711            ) ) ; 
712712        } 
713713        let  mut  val = [ 0 ;  4 ] ; 
714-         self . reader . read_exact ( & mut  val) ?; 
714+         self . reader . inner ( ) . read_exact ( & mut  val) ?; 
715715        Ok ( val) 
716716    } 
717717
718718    /// Reads a TIFF IFA offset/value field 
719719     #[ inline]  
720720    pub  fn  read_offset_u64 ( & mut  self )  -> Result < [ u8 ;  8 ] ,  io:: Error >  { 
721721        let  mut  val = [ 0 ;  8 ] ; 
722-         self . reader . read_exact ( & mut  val) ?; 
722+         self . reader . inner ( ) . read_exact ( & mut  val) ?; 
723723        Ok ( val) 
724724    } 
725725
@@ -731,7 +731,7 @@ impl<R: Read + Seek> Decoder<R> {
731731
732732    #[ inline]  
733733    pub  fn  goto_offset_u64 ( & mut  self ,  offset :  u64 )  -> io:: Result < ( ) >  { 
734-         self . reader . seek ( io :: SeekFrom :: Start ( offset) ) . map ( |_|  ( ) ) 
734+         self . reader . goto_offset ( offset) 
735735    } 
736736
737737    /// Reads a IFD entry. 
@@ -742,7 +742,7 @@ impl<R: Read + Seek> Decoder<R> {
742742    // Count 4 bytes 
743743    // Value 4 bytes either a pointer the value itself 
744744    fn  read_entry ( 
745-         reader :  & mut  SmartReader < R > , 
745+         reader :  & mut  EndianReader < R > , 
746746        bigtiff :  bool , 
747747    )  -> TiffResult < Option < ( Tag ,  ifd:: Entry ) > >  { 
748748        let  tag = Tag :: from_u16_exhaustive ( reader. read_u16 ( ) ?) ; 
@@ -759,21 +759,21 @@ impl<R: Read + Seek> Decoder<R> {
759759            let  mut  offset = [ 0 ;  8 ] ; 
760760
761761            let  count = reader. read_u64 ( ) ?; 
762-             reader. read_exact ( & mut  offset) ?; 
762+             reader. inner ( ) . read_exact ( & mut  offset) ?; 
763763            ifd:: Entry :: new_u64 ( type_,  count,  offset) 
764764        }  else  { 
765765            let  mut  offset = [ 0 ;  4 ] ; 
766766
767767            let  count = reader. read_u32 ( ) ?; 
768-             reader. read_exact ( & mut  offset) ?; 
768+             reader. inner ( ) . read_exact ( & mut  offset) ?; 
769769            ifd:: Entry :: new ( type_,  count,  offset) 
770770        } ; 
771771        Ok ( Some ( ( tag,  entry) ) ) 
772772    } 
773773
774774    /// Reads the IFD starting at the indicated location. 
775775     fn  read_ifd ( 
776-         reader :  & mut  SmartReader < R > , 
776+         reader :  & mut  EndianReader < R > , 
777777        bigtiff :  bool , 
778778        ifd_location :  u64 , 
779779    )  -> TiffResult < ( Directory ,  Option < u64 > ) >  { 
@@ -984,7 +984,7 @@ impl<R: Read + Seek> Decoder<R> {
984984        output_width :  usize , 
985985    )  -> TiffResult < ( ) >  { 
986986        let  offset = self . image . chunk_file_range ( chunk_index) ?. 0 ; 
987-         self . goto_offset_u64 ( offset) ?; 
987+         self . reader . goto_offset ( offset) ?; 
988988
989989        let  byte_order = self . reader . byte_order ; 
990990
@@ -994,7 +994,7 @@ impl<R: Read + Seek> Decoder<R> {
994994            / 8 ; 
995995
996996        self . image . expand_chunk ( 
997-             & mut   self . reader , 
997+             self . reader . inner ( ) , 
998998            buffer. as_bytes_mut ( ) , 
999999            output_row_stride. try_into ( ) ?, 
10001000            byte_order, 
@@ -1129,15 +1129,15 @@ impl<R: Read + Seek> Decoder<R> {
11291129        // * pass requested band as parameter 
11301130        // * collect bands to a RGB encoding result in case of RGB bands 
11311131        for  chunk in  0 ..image_chunks { 
1132-             self . goto_offset_u64 ( self . image ( ) . chunk_offsets [ chunk] ) ?; 
1132+             self . reader . goto_offset ( self . image ( ) . chunk_offsets [ chunk] ) ?; 
11331133
11341134            let  x = chunk % chunks_across; 
11351135            let  y = chunk / chunks_across; 
11361136            let  buffer_offset =
11371137                y *  output_row_stride *  chunk_dimensions. 1  as  usize  + x *  chunk_row_bytes; 
11381138            let  byte_order = self . reader . byte_order ; 
11391139            self . image . expand_chunk ( 
1140-                 & mut   self . reader , 
1140+                 self . reader . inner ( ) , 
11411141                & mut  result. as_buffer ( 0 ) . as_bytes_mut ( ) [ buffer_offset..] , 
11421142                output_row_stride, 
11431143                byte_order, 
0 commit comments