This commit is contained in:
Andrey Gumirov
2024-01-11 02:44:53 +07:00
parent 8780822f95
commit b6a619303d
6 changed files with 201 additions and 57 deletions

View File

@ -3,6 +3,9 @@
#include "bitstream.h"
#define HEADER_SIZE 128
#define MAX_LEN 16
#ifndef HUFFMAN_TABLE
#define HUFFMAN_TABLE
@ -10,16 +13,18 @@ class HuffmanTable
{
private:
std::unordered_map<char, std::pair<int, short> > huffmanCodes;
std::vector<char> symbols;
std::array<int, 16> counts;
public:
// Given the list of code lengths length[0..n-1] representing a canonical
// Huffman code for n symbols, construct the tables required to decode those
// codes.
HuffmanTable(uint8_t *header);
HuffmanTable(const char *header);
// Build from input stream
HuffmanTable(std::basic_istream<char> &is);
uint8_t *to_header();
char *to_header();
std::pair<int, short> operator[](const char &c);