question: public static byte [ ] unsynchronize ( byte [ ] abySource ) { ByteArrayInputStream input = new ByteArrayInputStream ( abySource ) ; ByteArrayOutputStream output = new ByteArrayOutputStream ( abySource . length ) ; int count = 0 ; while ( input . available ( ) > 0 ) { int firstByte = input . read ( ) ; count ++ ; output . write ( firstByte ) ; if ( ( firstByte & MPEGFrameHeader . SYNC_BYTE1 ) == MPEGFrameHeader . SYNC_BYTE1 ) { if ( input . available ( ) > 0 ) { input . mark ( 1 ) ; int secondByte = input . read ( ) ; if ( ( secondByte & MPEGFrameHeader . SYNC_BYTE2 ) == MPEGFrameHeader . SYNC_BYTE2 ) { if ( logger . isLoggable ( Level . FINEST ) ) { logger . finest ( "Writing unsynchronisation bit at:" + count ) ; } output . write ( 0 ) ; } else if ( secondByte == 0 ) { if ( logger . isLoggable ( Level . FINEST ) ) { logger . finest ( "Inserting zero unsynchronisation bit at:" + count ) ; } output . write ( 0 ) ; } input . reset ( ) ; } } } if ( ( abySource [ abySource . length - 1 ] & MPEGFrameHeader . SYNC_BYTE1 ) == MPEGFrameHeader . SYNC_BYTE1 ) { logger . finest ( "Adding unsynchronisation bit at end of stream" ) ; output . write ( 0 ) ; } return output . toByteArray ( ) ; }
target:  Unsynchronize an array of bytes, this should only be called if the decision has already been made to unsynchronize the byte array In order to prevent a media player from incorrectly interpreting the contents of a tag, all $FF bytes followed by a byte with value >=224 must be followed by a $00 byte (thus, $FF $F0 sequences become $FF $00 $F0). Additionally because unsynchronisation is being applied any existing $FF $00 have to be converted to $FF $00 $00