File: lzham_huffman_codes.h

package info (click to toggle)
p7zip 16.02%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 14,144 kB
  • sloc: cpp: 167,145; ansic: 14,992; python: 1,911; asm: 1,688; sh: 1,132; makefile: 701
file content (32 lines) | stat: -rw-r--r-- 999 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// File: lzham_huffman_codes.h
// See Copyright Notice and license at the end of include/lzham.h
#pragma once

namespace lzham
{
   //const uint cHuffmanMaxSupportedSyms = 600;
   const uint cHuffmanMaxSupportedSyms = 1024;

   const uint cMaxExpectedHuffCodeSize = 16;

   struct code_size_histogram
   {
      enum { cMaxUnlimitedHuffCodeSize = 32 };
      uint m_num_codes[cMaxUnlimitedHuffCodeSize + 1];

      void clear() { utils::zero_object(m_num_codes); }

      void init(uint num_syms, const uint8* pCodesizes);

      inline void init(uint code_size0, uint total_syms0, uint code_size1, uint total_syms1)
      {
         m_num_codes[code_size0] += total_syms0;
         m_num_codes[code_size1] += total_syms1;
      }
   };
   
   uint get_generate_huffman_codes_table_size();
   
   bool generate_huffman_codes(void* pContext, uint num_syms, const uint16* pFreq, uint8* pCodesizes, uint& max_code_size, uint& total_freq_ret, code_size_histogram &code_size_hist);

} // namespace lzham