Ejemplo n.º 1
0
def main(file, file_com_rl, file_dec_rl):

    print '\033[94m' + "\n\nRun Length Encoding" + '\033[0m'

    print "Codifica"
    now = time.time()
    #compressione del file
    erle = rle()
    erle.encode(file, file_com_rl)
    print "\t" + str('%.5f' % (time.time() - now)) + "\tseconds"
    all.dim(file_com_rl)
    all.perc_comp(file,file_com_rl)

    print "Decodifica"
    now = time.time()
    #decompressione del file
    drle = rle()
    drle.decode(file_com_rl, file_dec_rl)
    print "\t" + str('%.5f' % (time.time() - now)) + "\tseconds"
    all.dim(file_dec_rl)

    all.check(file,file_dec_rl)
Ejemplo n.º 2
0
def main(file, file_com_huf, file_dec_huf, language=""): #language e' "" se calcolo frequenze io, "qualcosa" se uso le statistiche

    if language=="":
        print '\033[94m' + "\n\nHuffman con calcolo delle frequenze" + '\033[0m'
    else:
        print '\033[94m' + "\n\nHuffman con uso di statistiche" + '\033[0m'

    print "Codifica"
    now = time.time()
    #compressione del file
    Huff(file, file_com_huf, language)
    print "\t" + str('%.5f' % (time.time() - now)) + "\tseconds"
    all.dim(file_com_huf)
    all.perc_comp(file,file_com_huf)

    print "Decodifica"
    now = time.time()
    #decompressione del file
    Unhuff(file_com_huf, file_dec_huf, language)
    print "\t" + str('%.5f' % (time.time() - now)) + "\tseconds"
    all.dim(file_dec_huf)

    all.check(file,file_dec_huf)