KiCad PCB EDA Suite
Loading...
Searching...
No Matches
U3D::CONTEXT_MANAGER Class Reference

Class for managing static and dynamic contexts used in reading and writing compressed data. More...

#include <context_manager.h>

Public Member Functions

 CONTEXT_MANAGER ()
 
void AddSymbol (uint32_t aContext, uint32_t aSymbol)
 Add an occurrence of the symbol to the specified context.
 
uint32_t GetSymbolFrequency (uint32_t aContext, uint32_t aSymbol)
 Get the number of occurrences of the given symbol in the context.
 
uint32_t GetCumulativeSymbolFrequency (uint32_t aContext, uint32_t aSymbol)
 Get the total number of occurrences for all symbols less than the given symbol in the context.
 
uint32_t GetTotalSymbolFrequency (uint32_t aContext)
 Get the total occurrences of all the symbols in this context.
 
uint32_t GetSymbolFromFrequency (uint32_t aContext, uint32_t symbolFrequency)
 Find the symbol in a histogram that has the specified cumulative frequency.
 

Private Attributes

std::vector< std::vector< std::uint32_t > > m_symbolCount
 
std::vector< std::vector< std::uint32_t > > m_cumulativeCount
 
const uint32_t m_elephant
 Elephant determines the number of symbol occurences that are stored in each histogram.
 
const uint32_t m_maximumSymbolInHistogram
 the maximum value that is stored in a histogram
 
const uint32_t m_arraySizeIncr
 the ammount to increase the size of an array when reallocating an array.
 

Detailed Description

Class for managing static and dynamic contexts used in reading and writing compressed data.

  • Dynamic Context: Dynamic contexts are specified as 0x0001 through 0x3FFF. Dynamic contexts keep a histogram that stores the number of occurrences of symbols that are added through the AddSymbol method.
  • Static Context: Static contexts are specified as 0x4000 through 0x7FFF. Static contexts represent histograms where each value between 0 and (context - 0x4000) are equally likely. Static context histograms are not changed by the AddSymbol method.
  • Context 0 or Context8: Context 0 is a shortcut to context 0x40FF, which corresponds to values from 0 through 255.
  • When a histogram for a dynamic context is initialized, the symbol frequency of the escape symbol is initialized to 1.
  • Symbols larger than 0xFFFF are treated as static.
  • The ContextManager class implements this interface.

Definition at line 47 of file context_manager.h.

Constructor & Destructor Documentation

◆ CONTEXT_MANAGER()

CONTEXT_MANAGER::CONTEXT_MANAGER ( )

Member Function Documentation

◆ AddSymbol()

void CONTEXT_MANAGER::AddSymbol ( uint32_t aContext,
uint32_t aSymbol )

Add an occurrence of the symbol to the specified context.

Parameters
aContextAdd the occurrence to this context's histogram.
aSymbolAdd an occurrence of this symbol to the histogram.

Definition at line 36 of file context_manager.cpp.

References U3D::CONSTANTS::Context8, m_arraySizeIncr, m_cumulativeCount, m_elephant, m_maximumSymbolInHistogram, m_symbolCount, and U3D::CONSTANTS::StaticFull.

◆ GetCumulativeSymbolFrequency()

uint32_t CONTEXT_MANAGER::GetCumulativeSymbolFrequency ( uint32_t aContext,
uint32_t aSymbol )

Get the total number of occurrences for all symbols less than the given symbol in the context.

Parameters
aContextUse this context's histogram.
aSymbolUse this symbol.
Returns
Sum of all symbol frequencies for symbols less than the given symbol in the given context.

Definition at line 110 of file context_manager.cpp.

References U3D::CONSTANTS::Context8, empty(), m_cumulativeCount, and U3D::CONSTANTS::StaticFull.

Referenced by GetSymbolFromFrequency().

◆ GetSymbolFrequency()

uint32_t CONTEXT_MANAGER::GetSymbolFrequency ( uint32_t aContext,
uint32_t aSymbol )

Get the number of occurrences of the given symbol in the context.

Definition at line 91 of file context_manager.cpp.

References U3D::CONSTANTS::Context8, empty(), m_symbolCount, and U3D::CONSTANTS::StaticFull.

◆ GetSymbolFromFrequency()

uint32_t CONTEXT_MANAGER::GetSymbolFromFrequency ( uint32_t aContext,
uint32_t symbolFrequency )

Find the symbol in a histogram that has the specified cumulative frequency.

Parameters
aContextUse this context's histogram.
symbolFrequencyUse this frequency.
Returns
The symbol that corresponds to the given cumulative frequency and context.

Definition at line 153 of file context_manager.cpp.

References U3D::CONSTANTS::Context8, empty(), GetCumulativeSymbolFrequency(), m_cumulativeCount, and U3D::CONSTANTS::StaticFull.

◆ GetTotalSymbolFrequency()

uint32_t CONTEXT_MANAGER::GetTotalSymbolFrequency ( uint32_t aContext)

Get the total occurrences of all the symbols in this context.

Parameters
aContextUse this context's histogram.
Returns
Total occurrences of all symbols for the given context.

Definition at line 132 of file context_manager.cpp.

References U3D::CONSTANTS::Context8, empty(), m_cumulativeCount, and U3D::CONSTANTS::StaticFull.

Member Data Documentation

◆ m_arraySizeIncr

const uint32_t U3D::CONTEXT_MANAGER::m_arraySizeIncr
private

the ammount to increase the size of an array when reallocating an array.

Definition at line 102 of file context_manager.h.

Referenced by AddSymbol(), and CONTEXT_MANAGER().

◆ m_cumulativeCount

std::vector<std::vector<std::uint32_t> > U3D::CONTEXT_MANAGER::m_cumulativeCount
private

◆ m_elephant

const uint32_t U3D::CONTEXT_MANAGER::m_elephant
private

Elephant determines the number of symbol occurences that are stored in each histogram.

Definition at line 94 of file context_manager.h.

Referenced by AddSymbol(), and CONTEXT_MANAGER().

◆ m_maximumSymbolInHistogram

const uint32_t U3D::CONTEXT_MANAGER::m_maximumSymbolInHistogram
private

the maximum value that is stored in a histogram

Definition at line 98 of file context_manager.h.

Referenced by AddSymbol(), and CONTEXT_MANAGER().

◆ m_symbolCount

std::vector<std::vector<std::uint32_t> > U3D::CONTEXT_MANAGER::m_symbolCount
private

Definition at line 88 of file context_manager.h.

Referenced by AddSymbol(), CONTEXT_MANAGER(), and GetSymbolFrequency().


The documentation for this class was generated from the following files: