Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

context.cpp File Reference

Definitions of class Context methods. More...

#include "context.h"

Go to the source code of this file.

Defines

#define MIN(a, b)   ((a) < (b) ? (a) : (b))
 Returns minimum of a and b.

#define INCR_SYMBOL_PROB_ACTUAL(symbol, inc)
 Increments the specified symbol probability by the inc amount. More...

#define INCR_SYMBOL_PROB_MPS(symbol)
#define INCR_SYMBOL_PROB(symbol, low1, high1, inc1)
#define GET_COUNT(symbol, c)
#define ADJUST_ZERO_FREQ()
#define ZERO_FREQ_PROB   ((FreqValue)nSingletons)
 Defines the count for the escape symbol. More...


Detailed Description

Definitions of class Context methods.

This file contains definitions of class Context methods.

Definition in file context.cpp.


Define Documentation

 
#define ADJUST_ZERO_FREQ  
 

Value:

{                                               \
  FreqValue diff;                               \
  diff = ZERO_FREQ_PROB - tree[1];              \
  if (diff != 0)                                \
    INCR_SYMBOL_PROB(1, 0, tree[1], diff);      \
}
Zero frequency probability is specified as a count out of the total frequency count. It is stored as the first item in the tree (item 1). Luckily, a Moffat tree is defined such that we can read the value of item 1 directly (tree[1]), although it cannot be updated directly. After each symbol is coded, ADJUST_ZERO_FREQ() is called to ensure that the zero frequency probability stored in the tree is still accurate (and changes it if it has changed).

Definition at line 141 of file context.cpp.

Referenced by Context::decode, Context::encode, Context::halveContext, Context::installSymbol, Context::purgeContext, and Context::setType.

#define GET_COUNT symbol,
 
 

Value:

{                                               \
  if ((symbol) & 1)                             \
    c = tree[symbol];                           \
  else                                          \
    {                                           \
      int q = symbol + 1;                       \
      int z = MIN(FORW(symbol), maxLength + 1); \
      c = tree[symbol];                         \
      while (q < z)                             \
        {                                       \
          c -= tree[q];                         \
          q  = FORW(q);                         \
        }                                       \
    }                                           \
}
Get cumulative frequency of symbol
Parameters:
symbol  Symbol.
c  Resulting cumulative frequency.

Definition at line 119 of file context.cpp.

Referenced by Context::decode, and Context::getInterval.

#define INCR_SYMBOL_PROB symbol,
low1,
high1,
inc1   
 

Value:

{                                                       \
  FreqValue _low = low1;                                \
  FreqValue _high = high1;                              \
  INCR_SYMBOL_PROB_ACTUAL(symbol, inc1)                 \
  INCR_SYMBOL_PROB_MPS(symbol)                          \
}
Increase symbol probability. Definition depends on whether most probable symbol needs to be remembered.

Definition at line 89 of file context.cpp.

Referenced by Context::decode, Context::encode, and Context::installSymbol.

#define INCR_SYMBOL_PROB_ACTUAL symbol,
inc   
 

Value:

FreqValue _inc = (inc);                 \
  int p = symbol;                               \
                                \
  while (p > 0)                                 \
    {                                           \
      tree[p] += _inc;                          \
      p = BACK(p);                              \
    }                                           \
  total += _inc;                                \
Increments the specified symbol probability by the inc amount.

If the most probable symbol is maintined at the end of the coding range (MOST_PROB_AT_END defined), then both INCR_SYMBOL_PROB_ACTUAL and INCR_SYMBOL_PROB_MPS are used. Otherwise, just INCR_SYMBOL_PROB_ACTUAL is used.

Parameters:
symbol  Symbol.
inc  Increment.

Definition at line 49 of file context.cpp.

#define INCR_SYMBOL_PROB_MPS symbol   
 

Value:

{                                                       \
    if (symbol == mostFreqSymbol)                       \
      mostFreqCount += _inc;                            \
    else                                                \
      if ((_high) - (_low) + (_inc) > mostFreqCount)    \
        {                                               \
          mostFreqSymbol = symbol;                      \
          mostFreqCount = (_high) - (_low) + (_inc);    \
          mostFreqPos   = _low;                         \
        }                                               \
      else                                              \
        if (symbol < mostFreqSymbol)                    \
          mostFreqPos += _inc;                          \
  }
Update most frequent symbol, assuming symbol was just incremented.
Parameters:
symbol  Incremented symbol.

Definition at line 67 of file context.cpp.

#define ZERO_FREQ_PROB   ((FreqValue)nSingletons)
 

Defines the count for the escape symbol.

We implemented a variation of the XC method (which we call AX). We create a special escape symbol, which we keep up to date with the count of "number of singletons + 1". To achieve this, but still be efficient with static contexts, we falsely increment the number of singletons at the start of modeling for dynamic contexts, and keep it at 0 for static contexts. This way, nSingletons is always our zero frequency probability, without the need to check if the context is static or dynamic (remember that this operation would be done for each symbol coded).

Definition at line 156 of file context.cpp.

Referenced by Context::encode, and Context::halveContext.


Generated on Wed Feb 5 10:43:03 2003 for Exalt by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002