public int read ( ) { while ( rleRepeat < 1 ) { if ( bwtBytesDecoded == bwtBlockLength ) { return - 1 ; } int nextByte = decodeNextBWTByte ( ) ; if ( nextByte != rleLastDecodedByte ) { // New byte, restart accumulation rleLastDecodedByte = nextByte ; rleRepeat = 1 ; rleAccumulator = 1 ; crc . updateCRC ( nextByte ) ; } else { if ( ++ rleAccumulator == 4 ) { // Accumulation complete, start repetition int rleRepeat = decodeNextBWTByte ( ) + 1 ; this . rleRepeat = rleRepeat ; rleAccumulator = 0 ; crc . updateCRC ( nextByte , rleRepeat ) ; } else { rleRepeat = 1 ; crc . updateCRC ( nextByte ) ; } } } rleRepeat -- ; return rleLastDecodedByte ; }
Decodes a byte from the final Run - Length Encoding stage pulling a new byte from the Burrows - Wheeler Transform stage when required .