Is there a name for this compression algorithm? -


say have 4 byte integer , want compress fewer bytes. able compress because smaller values more probable larger values (i.e., probability of value decreases magnitude). apply following scheme, produce 1, 2, 3 or 4 byte result:

note in description below (the bits one-based , go significant least significant), i.e., first bit refers significant bit, second bit next significant bit, etc...)

  1. if n<128, encode single byte first bit set 0
  2. if n>=128 , n<16,384 , use 2 byte integer. set first bit one, indicate , second bit zero. use remaining 14 bits encode number n.
  3. if n>16,384 , n<2,097,152 , use 3 byte integer. set first bit one, second bit one, , third bit zero. use remaining 21 bits, encode n.
  4. if n>2,097,152 , n<268,435,456 , use 4 byte integer. set first 3 bits 1 , fourth bit zero. use remaining 28 bits encode n.
  5. if n>=268,435,456 , n<4,294,967,296, use 5 byte integer. set first 4 bits 1 , use following 32-bits set exact value of n, 4 byte integer. remainder of bits unused.

is there name algorithm?

this quite close variable-length quantity encoding or base-128. latter name stems fact each 7-bit unit in encoding can considered base-128 digit.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -