FACT++  1.0
void Huffman::Encoder::WriteCodeTable ( std::string &  out) const
inline

Definition at line 113 of file huffman.h.

References Huffman::Encoder::Code::bits, i, MAX_SYMBOLS, Huffman::Encoder::Code::numbits, and Huffman::numbytes_from_numbits().

Referenced by Huffman::Encode().

114  {
115  out.append((char*)&count, sizeof(size_t));
116 
117  for (uint32_t i=0; i<MAX_SYMBOLS; i++)
118  {
119  const Code &n = lut[i];
120  if (n.numbits==0)
121  continue;
122 
123  // Write the 2 byte symbol.
124  out.append((char*)&i, sizeof(uint16_t));
125  if (count==1)
126  return;
127 
128  // Write the 1 byte code bit length.
129  out.append((char*)&n.numbits, sizeof(uint8_t));
130 
131  // Write the code bytes.
132  uint32_t numbytes = numbytes_from_numbits(n.numbits);
133  out.append((char*)&n.bits, numbytes);
134  }
135  }
#define MAX_SYMBOLS
Definition: huffman.h:11
int i
Definition: db_dim_client.c:21
Code lut[1<< 16]
Definition: huffman.h:85
static unsigned long numbytes_from_numbits(unsigned long numbits)
Definition: huffman.h:17
size_t count
Definition: huffman.h:84

+ Here is the call graph for this function:

+ Here is the caller graph for this function: