int syncHeader ( byte syncmode ) throws BitstreamException { boolean sync ; int headerstring ; // read additional 2 bytes int bytesRead = readBytes ( syncbuf , 0 , 3 ) ; if ( bytesRead != 3 ) throw newBitstreamException ( STREAM_EOF , null ) ; headerstring = ( ( syncbuf [ 0 ] << 16 ) & 0x00FF0000 ) | ( ( syncbuf [ 1 ] << 8 ) & 0x0000FF00 ) | ( ( syncbuf [ 2 ] << 0 ) & 0x000000FF ) ; do { headerstring <<= 8 ; if ( readBytes ( syncbuf , 3 , 1 ) != 1 ) throw newBitstreamException ( STREAM_EOF , null ) ; headerstring |= ( syncbuf [ 3 ] & 0x000000FF ) ; sync = isSyncMark ( headerstring , syncmode , syncword ) ; } while ( ! sync ) ; current_frame_number ++ ; if ( last_frame_number < current_frame_number ) last_frame_number = current_frame_number ; return headerstring ; }
Get next 32 bits from bitstream . They are stored in the headerstring . syncmod allows Synchro flag ID The returned value is False at the end of stream .