FACT++  1.0
Huffman::Decoder::Decoder ( const uint8_t *  bufin,
int64_t &  pindex 
)
inline

Definition at line 338 of file huffman.h.

References Huffman::TreeNode::count, i, Huffman::numbytes_from_numbits(), and Set().

338  : isLeaf(false), lut(NULL)
339  {
340  // FIXME: Sanity check for size missing....
341 
342  // Read the number of entries.
343  size_t count=0;
344  memcpy(&count, bufin + pindex, sizeof(count));
345  pindex += sizeof(count);
346 
347  // Read the entries.
348  for (size_t i=0; i<count; i++)
349  {
350  uint16_t sym;
351  memcpy(&sym, bufin + pindex, sizeof(uint16_t));
352  pindex += sizeof(uint16_t);
353 
354  if (count==1)
355  {
356  Set(sym);
357  break;
358  }
359 
360  uint8_t numbits;
361  memcpy(&numbits, bufin + pindex, sizeof(uint8_t));
362  pindex += sizeof(uint8_t);
363 
364  const uint8_t numbytes = numbytes_from_numbits(numbits);
365 
366 #ifdef __EXCEPTIONS
367  if (numbytes>sizeof(size_t))
368  throw std::runtime_error("Number of bytes for a single symbol exceeds maximum.");
369 #else
370  if (numbytes>sizeof(size_t))
371  {
372  pindex = -1;
373  return;
374  }
375 #endif
376  size_t bits=0;
377  memcpy(&bits, bufin+pindex, numbytes);
378  pindex += numbytes;
379 
380  Set(sym, numbits, bits);
381  }
382  }
int i
Definition: db_dim_client.c:21
static unsigned long numbytes_from_numbits(unsigned long numbits)
Definition: huffman.h:17
void Set(uint16_t sym, uint8_t n=0, size_t bits=0)
Definition: huffman.h:248
int count
Definition: db_dim_server.c:18
Decoder * lut
Definition: huffman.h:236

+ Here is the call graph for this function: