int syncHeader(byte syncmode) throws IOException {
        if((bytesread = source.read(syncbuf,0,3))!= 3)
            return -1;
        // return 0;
        
        headerstring = syncbuf[0] << 16 & 0xff0000 | syncbuf[1] << 8 & 0xff00 | syncbuf[2] << 0 & 0xff;
        
        if(first_call){
            id_v2 [0] = syncbuf[0];
            id_v2 [1] = syncbuf[1];
            id_v2 [2] = syncbuf[2];
            first_call = false;
        }
        //id_v2 [3] = syncbuf[3];
        
        // off = 4;
        
        do{
            headerstring <<= 8;
            if(source.read(syncbuf,3,1) != 1)
                //return 0;
                return -1;
            
            headerstring |= syncbuf[3] & 0xff;
            if(!first_sync){
                if(off+1 > id_v2.length){
                    temp = new byte [off + 4];
                    
                    System.arraycopy(id_v2, 0, temp, 0, id_v2.length);
                    id_v2 = temp;
                }
                
                id_v2 [off] = syncbuf[3];
                off ++;
            }
            
        }while(!isSyncMark(headerstring,syncmode,syncword));
        
        return headerstring;
    }