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))
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,)))
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
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, )))
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)