42 std::vector<uint32_t>& symbolCountRef =
m_symbolCount[aContext];
44 if( cumulativeCountRef.empty() || cumulativeCountRef.size() <= aSymbol )
46 std::vector<uint32_t> newCumulativeCount( aSymbol +
m_arraySizeIncr, 0 );
49 if( cumulativeCountRef.empty() )
51 cumulativeCountRef = newCumulativeCount;
52 cumulativeCountRef[0] = 1;
54 symbolCountRef = newSymbolCount;
55 symbolCountRef[0] = 1;
59 std::copy( cumulativeCountRef.begin(), cumulativeCountRef.end(),
60 newCumulativeCount.begin() );
61 std::copy( symbolCountRef.begin(), symbolCountRef.end(),
62 newSymbolCount.begin() );
63 cumulativeCountRef = newCumulativeCount;
64 symbolCountRef = newSymbolCount;
70 size_t len = cumulativeCountRef.size();
71 uint32_t tempAccum = 0;
72 for(
int i = (int32_t)len - 1; i >= 0; i-- )
74 symbolCountRef[i] >>= 1;
75 tempAccum += symbolCountRef[i];
76 cumulativeCountRef[i] = tempAccum;
79 cumulativeCountRef[0]++;
82 symbolCountRef[aSymbol]++;
83 for( uint32_t i = 0; i <= aSymbol; i++ )
85 cumulativeCountRef[i]++;
uint32_t GetSymbolFrequency(uint32_t aContext, uint32_t aSymbol)
Get the number of occurrences of the given symbol in the context.
const uint32_t m_arraySizeIncr
the ammount to increase the size of an array when reallocating an array.
uint32_t GetSymbolFromFrequency(uint32_t aContext, uint32_t symbolFrequency)
Find the symbol in a histogram that has the specified cumulative frequency.
uint32_t GetTotalSymbolFrequency(uint32_t aContext)
Get the total occurrences of all the symbols in this context.
std::vector< std::vector< std::uint32_t > > m_cumulativeCount
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.
std::vector< std::vector< std::uint32_t > > m_symbolCount
void AddSymbol(uint32_t aContext, uint32_t aSymbol)
Add an occurrence of the symbol to the specified context.
const uint32_t m_maximumSymbolInHistogram
the maximum value that is stored in a histogram
const uint32_t m_elephant
Elephant determines the number of symbol occurences that are stored in each histogram.