private void seekToSId ( final int pSId , final long pStreamSize ) throws IOException { long pos ; if ( isShortStream ( pStreamSize ) ) { // The short stream is not continuous... Entry root = getRootEntry ( ) ; if ( shortStreamSIdChain == null ) { shortStreamSIdChain = getSIdChain ( root . startSId , root . streamSize ) ; } // System.err.println("pSId: " + pSId); int shortPerSId = sectorSize / shortSectorSize ; // System.err.println("shortPerSId: " + shortPerSId); int offset = pSId / shortPerSId ; // System.err.println("offset: " + offset); int shortOffset = pSId - ( offset * shortPerSId ) ; // System.err.println("shortOffset: " + shortOffset); // System.err.println("shortStreamSIdChain.offset: " + shortStreamSIdChain.get(offset)); pos = HEADER_SIZE + ( shortStreamSIdChain . get ( offset ) * ( long ) sectorSize ) + ( shortOffset * ( long ) shortSectorSize ) ; // System.err.println("pos: " + pos); } else { pos = HEADER_SIZE + pSId * ( long ) sectorSize ; } if ( input instanceof LittleEndianRandomAccessFile ) { ( ( LittleEndianRandomAccessFile ) input ) . seek ( pos ) ; } else if ( input instanceof ImageInputStream ) { ( ( ImageInputStream ) input ) . seek ( pos ) ; } else { ( ( SeekableLittleEndianDataInputStream ) input ) . seek ( pos ) ; } }
Seeks to the start pos for the given stream Id