question: private void checkIfFrameSizeThatIsNotSyncSafe ( ByteBuffer byteBuffer ) throws InvalidFrameException { if ( frameSize > ID3SyncSafeInteger . MAX_SAFE_SIZE ) { int currentPosition = byteBuffer . position ( ) ; byteBuffer . position ( currentPosition - getFrameIdSize ( ) ) ; int nonSyncSafeFrameSize = byteBuffer . getInt ( ) ; byteBuffer . position ( currentPosition - getFrameIdSize ( ) ) ; boolean isNotSyncSafe = ID3SyncSafeInteger . isBufferNotSyncSafe ( byteBuffer ) ; byteBuffer . position ( currentPosition ) ; if ( isNotSyncSafe ) { logger . warning ( getLoggingFilename ( ) + ":" + "Frame size is NOT stored as a sync safe integer:" + identifier ) ; if ( nonSyncSafeFrameSize > ( byteBuffer . remaining ( ) - - getFrameFlagsSize ( ) ) ) { logger . warning ( getLoggingFilename ( ) + ":" + "Invalid Frame size larger than size before mp3 audio:" + identifier ) ; throw new InvalidFrameException ( identifier + " is invalid frame" ) ; } else { frameSize = nonSyncSafeFrameSize ; } } else { byte [ ] readAheadbuffer = new byte [ getFrameIdSize ( ) ] ; byteBuffer . position ( currentPosition + frameSize + getFrameFlagsSize ( ) ) ; if ( byteBuffer . remaining ( ) < getFrameIdSize ( ) ) { byteBuffer . position ( currentPosition ) ; } else { byteBuffer . get ( readAheadbuffer , 0 , getFrameIdSize ( ) ) ; byteBuffer . position ( currentPosition ) ; String readAheadIdentifier = new String ( readAheadbuffer ) ; if ( isValidID3v2FrameIdentifier ( readAheadIdentifier ) ) { } else if ( ID3SyncSafeInteger . isBufferEmpty ( readAheadbuffer ) ) { } else { if ( nonSyncSafeFrameSize > byteBuffer . remaining ( ) - getFrameFlagsSize ( ) ) { byteBuffer . position ( currentPosition ) ; } else { readAheadbuffer = new byte [ getFrameIdSize ( ) ] ; byteBuffer . position ( currentPosition + nonSyncSafeFrameSize + getFrameFlagsSize ( ) ) ; if ( byteBuffer . remaining ( ) >= getFrameIdSize ( ) ) { byteBuffer . get ( readAheadbuffer , 0 , getFrameIdSize ( ) ) ; readAheadIdentifier = new String ( readAheadbuffer ) ; byteBuffer . position ( currentPosition ) ; if ( isValidID3v2FrameIdentifier ( readAheadIdentifier ) ) { frameSize = nonSyncSafeFrameSize ; logger . warning ( getLoggingFilename ( ) + ":" + "Assuming frame size is NOT stored as a sync safe integer:" + identifier ) ; } else if ( ID3SyncSafeInteger . isBufferEmpty ( readAheadbuffer ) ) { frameSize = nonSyncSafeFrameSize ; logger . warning ( getLoggingFilename ( ) + ":" + "Assuming frame size is NOT stored as a sync safe integer:" + identifier ) ; } else { } } else { byteBuffer . position ( currentPosition ) ; if ( byteBuffer . remaining ( ) == 0 ) { frameSize = nonSyncSafeFrameSize ; } else { } } } } } } } }
target:  If frame is greater than certain size it will be decoded differently if unsynchronized to if synchronized Frames with certain byte sequences should be unsynchronized but sometimes editors do not unsynchronize them so this method checks both cases and goes with the option that fits best with the data