예제 #1
0
def decompress(code, bitin, out):
	dec = huffmancoding.HuffmanDecoder(bitin)
	dec.codetree = code
	while True:
		symbol = dec.read()
		if symbol == 256:  # simbolo EOF
			break
		out.write(bytes((symbol,)) if python3 else chr(symbol))
예제 #2
0
def decompress(code, bitin, out):
	dec = huffmancoding.HuffmanDecoder(bitin)
	dec.codetree = code
	while True:
		symbol = dec.read()
		if symbol == 256:  # EOF symbol
			break
		out.write(bytes((symbol,)))
예제 #3
0
파일: sz.py 프로젝트: szcompressor/SZ_HLS
def decompress(bit_in, code_tree, x_arr):
    dec = huffmancoding.HuffmanDecoder(bit_in)
    dec.codetree = code_tree
    b_idx = 0
    while True:
        symbol = dec.read()
        if symbol == 1024:  # EOF symbol
            break

        x_arr[b_idx] = symbol
        b_idx += 1
예제 #4
0
def decompress(code, bitin, out, files_name):
    dec = huffmancoding.HuffmanDecoder(bitin)
    dec.codetree = code
    filesname = [os.path.join(out, i) for i in files_name]
    output = [open(filename, 'wb') for filename in filesname]
    i = 0
    while True:
        symbol = dec.read()
        if symbol == 256:  # EOF symbol
            i += 1
            if i == len(output):
                break
        else:
            output[i].write(bytes((symbol, )))
예제 #5
0
def decompress(bitin, out):
	initfreqs = [1] * 257
	freqs = huffmancoding.FrequencyTable(initfreqs)
	dec = huffmancoding.HuffmanDecoder(bitin)
	dec.codetree = freqs.build_code_tree()  # Use same algorithm as the compressor
	count = 0  # Number of bytes written to the output file
	while True:
		# Decode and write one byte
		symbol = dec.read()
		if symbol == 256:  # EOF symbol
			break
		out.write(bytes((symbol,)))
		count += 1
		
		# Update the frequency table and possibly the code tree
		freqs.increment(symbol)
		if (count < 262144 and is_power_of_2(count)) or count % 262144 == 0:  # Update code tree
			dec.codetree = freqs.build_code_tree()
		if count % 262144 == 0:  # Reset frequency table
			freqs = huffmancoding.FrequencyTable(initfreqs)