Skip to content
Yue Wang edited this page May 5, 2015 · 13 revisions

Welcome to the Compression wiki!

  • Using std::map<Char, Freq> as frequency table.
  • Note : move to frequency map , huffman tree not tested yet.
  • class Encoder : read a file and build a vector to hold content, for now just limited characters.
  • class BitString : a sequential container to store data in bits, push back only.
  • protocol :
FrequencyTable|CompressedPart|Remainder

-->

FrequencyTable|CompressedPart|Remainder|RemainderSize

So the last bits that less than 8 should be append to Remainder part without compressing.

  • 2 4 (8) 12 16

  • Design for Version II
  1. Read file char by char and save all data as an large BitString.
  2. Split the BitString object into an unsigned[], based on the size specified, like 1, 2, 3..16.
  3. Construct a FrqMap<unsigned int, FreqType> using the unsigned[].
  4. Construct a HuffmanTree using the FrqMap.
  5. Construct a CodeMap using HuffmanTree.
  6. Traverse the unsigned[] with looking up CodeMap and save the resulted into an output BitString.
  7. Split the output BitString into char[].
  8. Output the char[] as the compressed file.
Clone this wiki locally