DDNet documentation
Loading...
Searching...
No Matches
huffman.cpp File Reference
#include "huffman.h"
#include <base/dbg.h>
#include <base/mem.h>
#include <algorithm>
#include <cstdint>
Include dependency graph for huffman.cpp:

Classes

class  CHuffmanConstructNode

Macros

#define HUFFMAN_MACRO_LOADSYMBOL(Sym)
#define HUFFMAN_MACRO_WRITE()

Functions

static bool CompareNodesByFrequencyDesc (const CHuffmanConstructNode *pNode1, const CHuffmanConstructNode *pNode2)

Macro Definition Documentation

◆ HUFFMAN_MACRO_LOADSYMBOL

#define HUFFMAN_MACRO_LOADSYMBOL ( Sym)
Value:
do \
{ \
Bits |= (uint64_t)m_aNodes[Sym].m_Bits << Bitcount; \
Bitcount += m_aNodes[Sym].m_NumBits; \
} while(0)

◆ HUFFMAN_MACRO_WRITE

#define HUFFMAN_MACRO_WRITE ( )
Value:
do \
{ \
if(pDstEnd - pDst >= 8) \
{ \
for(unsigned i = 0; i < 8; i++) \
pDst[i] = (unsigned char)(Bits >> (i * 8)); \
pDst += Bitcount >> 3; \
Bits >>= (Bitcount >> 3) * 8; \
Bitcount &= 7; \
} \
else \
{ \
while(Bitcount >= 8) \
{ \
if(pDst == pDstEnd) \
return -1; \
*pDst++ = (unsigned char)(Bits & 0xff); \
Bits >>= 8; \
Bitcount -= 8; \
} \
} \
} while(0)

Function Documentation

◆ CompareNodesByFrequencyDesc()

bool CompareNodesByFrequencyDesc ( const CHuffmanConstructNode * pNode1,
const CHuffmanConstructNode * pNode2 )
static