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

context.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     context.h  -  Definition of Context class.
00003                              -------------------
00004     begin                : June 21 2002
00005     copyright            : (C) 2003 by Vojtìch Toman
00006     email                : vtoman@lit.cz
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 /* Based on code by:                                                       */
00019 
00020 /***************************************************************************
00021 Authors:        John Carpenelli   (johnfc@ecr.mu.oz.au)
00022                 Wayne Salamonsen  (wbs@mundil.cs.mu.oz.au)
00023 
00024 Purpose:        Data compression using a word-based model and revised 
00025                 arithmetic coding method.
00026 
00027 Based on:       A. Moffat, R. Neal, I.H. Witten, "Arithmetic Coding Revisited",
00028                 Proc. IEEE Data Compression Conference, Snowbird, Utah, 
00029                 March 1995.
00030 
00031 
00032 Copyright 1995 John Carpinelli and Wayne Salamonsen, All Rights Reserved.
00033 
00034 These programs are supplied free of charge for research purposes only,
00035 and may not sold or incorporated into any commercial product.  There is
00036 ABSOLUTELY NO WARRANTY of any sort, nor any undertaking that they are
00037 fit for ANY PURPOSE WHATSOEVER.  Use them at your own risk.  If you do
00038 happen to find a bug, or have modifications to suggest, please report
00039 the same to Alistair Moffat, alistair@cs.mu.oz.au.  The copyright
00040 notice above and this statement of conditions must remain an integral
00041 part of each and every copy made of these files.
00042 ****************************************************************************/
00043 
00044 
00053 #ifndef CONTEXT_H
00054 #define CONTEXT_H
00055 
00056 
00057 #ifdef __GNUG__
00058 # pragma interface
00059 #endif
00060 
00061 
00062 #include <cstdlib>              //for free() and malloc()
00063 
00064 
00065 #include "defs.h"
00066 #include "contextbase.h"
00067 
00068 
00069 
00071 //#define CHAR_CONTEXT_LENGTH   256
00072 
00073 
00075 #define BACK(i)                 ((i) & ((i) - 1))
00076 
00078 #define FORW(i)                 ((i) + ((i) & - (i)))
00079 
00080 
00082 #define MAX_FREQUENCY           ((FreqValue) 1 << F_BITS)
00083 
00084 
00086 #define MIN_INCR                1
00087 
00088 
00089 
00095 #define MOST_PROB_AT_END        1
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00109 class Context : public ContextBase
00110 {
00111 public:
00113   Context(void);
00114 
00116   Context(int, ContextType);
00117 
00119   virtual ~Context(void);
00120 
00122   virtual void setType(int, ContextType);
00123 
00125   virtual int initialize(void);
00126 
00128   virtual int lastFixedSymbol(void);
00129 
00131   virtual int encode(int) throw (ExaltContextNotInitializedException, ExaltIOException);
00132 
00134   virtual int encodeEndOfMessage() throw (ExaltContextNotInitializedException, ExaltIOException);
00135 
00137   virtual int decode(void) throw (ExaltContextNotInitializedException, ExaltIOException);
00138 
00140   virtual void purgeContext(void);
00141 
00143   virtual int installSymbol(int);
00144 
00145 protected:
00147   int initialSize;
00148 
00150   int maxLength, length;
00151 
00153   FreqValue nSingletons;
00154 
00156   ContextType type;
00157 
00159   int nSymbols;
00160 
00162   FreqValue total;
00163 
00165   FreqValue *tree;
00166 
00168   FreqValue incr;
00169 
00171   int mostFreqSymbol;
00172 
00174   FreqValue mostFreqCount;
00175 
00177   FreqValue mostFreqPos;
00178 
00179 
00181   virtual void getInterval(FreqValue *, FreqValue *, int);
00182 
00184   virtual void halveContext(void);
00185 
00187   virtual void initZeroFreq();
00188 
00189 }; //Context
00190 
00191 
00192 #endif //CONTEXT_H

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