Difference between revisions of "BEAR4 compression"

From ScienceZero
Jump to: navigation, search
Line 19: Line 19:
 
     read symbol
 
     read symbol
 
     output symbol
 
     output symbol
    decompressedSize += 1
 
 
   else
 
   else
 
     read index, count
 
     read index, count
 +
    for each count
 +
      read symbolFromDecompressed
 +
      output symbol
 +
    next
 
   endif
 
   endif
 
  loop
 
  loop

Revision as of 12:26, 1 February 2011

WORK IN PROGRESS...

BEAR2 is designed for microcontrollers that has little RAM. It uses the data decompressed so far as the dictionary.

Header

BEAR2 (used in files)
ssssss - symbol size (1-64) 
iiiii - maximum index size (1-32)
cccc - maximum count size (1-16)
0 <symbol>
1 <index> <count>
do
  indexSize = min(log2(decompressedSize), maximumIndexSize)
  countSize = min(indexSize, maximumCountSize)
  read classBit
  if classBit = 0 then
    read symbol
    output symbol
  else
    read index, count
    for each count
      read symbolFromDecompressed
      output symbol
    next
  endif
loop