void
QccENTArithmeticFreeModel(QccENTArithmeticModel *model);
int QccENTArithmeticSetModelContext(QccENTArithmeticModel
*model, int current_context);
void QccENTArithmeticSetModelAdaption(QccENTArithmeticModel
*model, int adaptive);
int QccENTArithmeticSetModelProbabilities(QccENTArithmeticModel
*model, double *probabilities, int context);
int QccENTArithmeticResetModel(QccENTArithmeticModel
*model, int context);
CAVEAT: The QccENTArithmeticModel data structure contains a number of variables and arrays which are used internally in the arithmetic encoding and decoding routines; these variables and arrays are described briefly below, but they should under no circumstances be accessed or modified by the user directly, as this will likely result in erroneous operation of the coder. Users who are interested in modifying the internal structure of the QccPack arithmetic-coder code should consult the paper by Witten et al. for details on the internal operation of the QccPack arithmetic coder and a thorough description of the variables and arrays internal to the QccENTArithmeticModel structure.
typedef struct
{
int num_contexts;
int *num_symbols;
int **translate_symbol_to_index;
int **translate_index_to_symbol;
int **cumulative_frequencies;
int **frequencies;
QccENTCodeValue low, high;
long bits_to_follow;
int garbage_bits;
int target_num_bits;
int adaptive_model;
QccENTArithmeticGetContext context_function;
int current_context;
QccENTCodeValue current_code_value;
} QccENTArithmeticModel;
The fields of QccENTArithmeticModel are as follows:
QccENTArithmeticSetModelContext() sets the current-context field of model to current_context. current_context must be greater than or equal to zero, and less than or equal to model->num_contexts. QccENTArithmeticSetModelContext() returns 0 on success, or 1 if current_context is an invalid context number.
QccENTArithmeticSetModelAdaption() changes the adaption state of the model. If adaptive is QCCENT_NONADAPTIVE, the model is made nonadaptive; otherwise, if adaptive is QCCENT_ADAPTIVE, the model becomes adaptive. The adaption mode of the model can be changed at any time during encoding, as long as the same changes to the adaption state are made during decoding as well. When model is initially created, the model is set to be adaptive.
QccENTArithmeticSetModelProbabilities() can be use to manually set the frequency counts in a particular context in a nonadaptive model according to any desired probability distribution. probabilities is a list of probability values, double-precision floating point numbers each greater than or equal to 0.0 and less than or equal to 1.0. There should be as many values in probabilities as there are symbols in context (not including the EOF symbol automatically added to the context during the call to QccENTArithmeticCreateModel(3) ; the frequency of the EOF symbol is set to automatically set to 1 by QccENTArithmeticSetModelProbabilities()). Additionally, the probability values should form a valid probability mass function; i.e., they should sum to 1.0. QccENTArithmeticSetModelProbabilities() updates model->cumulative_frequencies and model->frequencies to approximate the distribution specified by probabilities. QccENTArithmeticSetModelProbabilities() returns in error if model is not nonadaptive.
QccENTArithmeticResetModel() manually resets the frequency counts in a particular context back to their initial values; i.e., all frequency counts in the context are set to 1. Unlike QccENTArithmeticSetModelProbabilities(), model may be either adaptive or nonadaptive.
I. H. Witten, R. M. Neal, and J. G. Cleary, "Arithmetic Coding for Data Compression," Communications of the ACM, vol. 30, no. 6, pp. 520-540, June 1987.