开发者

On compressing series of ones and zeroes

I'm in need of compressing a series of 1 and 0 like this one

http://cid-f328e92ab80e3d64.office.live.com/self.aspx/.Public/bits.txt

Can anyone suggest me what coder to user to achieve best compression(Huffman, arithme开发者_开发问答tic, BWT, LZW, RLE, PAQ ...)

Any help is appreciated and thank you in advance.

With respect, Chuckie

P.S. I found that bwtmix goes down to 577 bytes, but it is written in c++ and i need it in c.


This Python program, by simply converting the ones and zeros into bytes, compresses it down to 715 bytes including a 16-bit leading count. Unfortunately, then standard compression programs zip, gzip, and bzip2 don't seem to be able to get any more compression out of it.


import sys, struct
i, n, b, count = 0, 0, '', 0
for byte in open('/tmp/binary.txt').read().rstrip():
 n = (n << 1) | (ord(byte) & 1)
 i = (i + 1) % 8
 if i == 0:
  n, b = 0, b + chr(n)
 count += 1
sys.stdout.write(struct.pack('<h', count) + b)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜