Variable Bit Count (VBC)

This is another simple compression method, it will allocate smaller bit length for smaller value.

This method should be run after the content being sorted and swapped, otherwise it will not be able to compress the content, also after sorted and swapped the result is better (smaller).

This method (VBC) do not build or use dictionary, therefore it uses very small memory required, also it is not depends on repetition of ASCII or words, this method is one of the random data compression, but it could not recursively recompress, that is what I get through my research only though, perhaps somebody else could do it recursively, so if anyone could do it recursively with quite much gain ratio, say more than 1% then please contact me.

It uses a flag to determine how long is the ASCII value bit required.
The flag length can be varies, it is depends on your preferences, it could be 4 bit or 3 bit.
This flag bit is for every byte in the content
I use 3 bit (8 kinds) length for flag in my program, the description is in the table below:

  Total bit value length Start Finish Gain / Loss (bit)
0 0 = last ASCII = last ASCII +5
1 3 0 7 +2
2 3 8 15 +2
3 4 16 31 +1
4 4 32 47 +1
5 4 48 63 +1
6 6 64 127 -1
7 7 128 255 -2

Compress algorithm:
1. Determine which group the value is, eg: if value = 3 then flag = 1, value bit length = 3
2. Store the flag value, it is always 3 bits long
3. Subtract / minus the value by Start value
4. Store the Binary Value Bit, remember the value bit length is varies.
5. Loop until finish.

Original ASCII Value Flag Value Value Bit Length Value - Start (Binary) Value Bit
3 1 (100) 3 3 110
13 2 (010) 3 5 101
23 3 (110) 4 7 1110
103 6 (011) 6 39 111001
203 7 (111) 7 75 1101001
203 0 (000) 0 (none) (none)

Result flag bit = 10001011-00111110-00
Total flag bit = 18
Result value bit = 11010111-10111001-1101001
Total value bit = 23
Compressed bit required = (6 char * 3 bit flag) + 23 = 18 + 23 = 41 bits
Original bit required = 6 char * 8 bit = 48 bits
Total gain bit = 48 - 41 = 7 bits

I think these result is not bad, considering only a few bytes here.

Decompress algorithm:
1. Get flag value (always get 3 bit)
2. Get Value (determined from flag value), if flag value = 3 then get 4 bits
3. Output the Value + Start value, eg: Value + Start = 3 + 16 = 18
4. Loop until finish.

Flag Value Value Bit Length Value Start Value + Start
1 (100) 3 3 0 3
2 (010) 3 5 8 13
3 (110) 4 7 16 23
6 (011) 6 39 64 103
7 (111) 7 75 128 203
0 (000) 0 (none) (none) 203 (= last)

I think this is very easy, not so complex, you can do more research to better result, the key to get better result are:
1. Determine flag bit length and its value.
2. Determine value bit length and its value.
3. Determine Start and Finish value.
4. Calculate the gain/loss ratio.

As always, if you do not understand some of the part in this article, please contact me, I will more than happy to give more information until you fully understand this method.

Grouping


Author Site Map Disclaimer
HMaxF Ultimate Recursive Lossless Compression Research
2001 - 2003 (c) All Rights Reserved.