www.pudn.com > EZW_.rar > ARICACM.H


#ifndef __ARICACM_H_ 
#define __ARICACM_H_ 
 
/*----------------------------------------------------------------------------*/ 
/*----------------------------------------------------------------------------*/	 
/* $Copyright Issue 
 * ---------------- 
 * Most of the code on arithemtic coding are modified from  
 * I.H. Witten, R.M. Neal, and J.G. Cleary, "Arithmetic coding for data 
 * compression," Communnication ACM, vol 30, pp. 520-540, June 1987. 
 * 
 * The statistical table is implemented using Binary Index Tree as described in 
 * P. M. Fenwick, "A new data structure for cumulative frequency tables," 
 * Softw. Pract. Exper. 24, 3 (Mar. 1994), 327-336. 
 * 
 * The idea of having the arithemetic coder to read/write bits directly was 
 * from G. Davis code in "Wavelet Compression Construction Kit". His code 
 * can only do write but has problem with synchronisation when doing read. 
 * I fixed that with a virtual table approach. 
 * 
 * Mow-Song, Ng 2/9/2002 
 * msng@mmu.edu.my 
 * http://www.pesona.mmu.edu.my/~msng 
 *  
 * I do not claim copyright to the code, but if you use them or modify them, 
 * please drop me a mail. 
 * 
 */ 
/*----------------------------------------------------------------------------*/ 
/*----------------------------------------------------------------------------*/ 
 
/*----------------------------------------------------------------------------*/ 
/*----------------------------------------------------------------------------*/	 
/*  
 * $LOG 
 * ---- 
 * Data: 07-06-2002 
 * - First version 
 * 
 * Date: 07-07-2002 
 * - Added BasicCoder 
 * - Some code shifting to arrange things better 
 * 
 * Date: 11-07-2002 
 * - Added functions for writing arbitrary size code (up to 32 bits for  
 *	  one read/write) 
 * 
 * Date: 21-07-2002 
 * - Modify the Context module. Now the maximum count is explicitly specified  
 *   by user. 
 * 
 * Date: 23-07-2002 
 * - Fixed a bug in the count of number of bits outputed in the encoder 
 * 
 * Date: 24-07-2002 
 * - Added nBitsInput to the arithmetic decoder 
 * 
 * Date: 15-08-2002 
 * - Added BasicEscapeCoder 
 * - Fixed some memory leak (pointers) 
 * 
 * Date: 16-08-2002 
 * - Remove EntropyEncoderAdaptive & EntropyEncoderEscape 
 * - Modified excape context behavior. Now we have an increasing decreament  
 *   size. 
 * 
 * $TODO 
 * ----- 
 * - Check the escape coder, some how the performance is not as good as expected. 
 *  + Checked! It seems that we have to tune the increment rate for a symbol and  
 *    the decrement rate of the escape symbol to obtain good results. 
 * 
 * - To extend BasicCoder to BasicEscapeCoder, which has an escape cotext in it 
 *  + Done! 
 *  
 * - Handle the EOF flag in the decoder. 
 * 
 * - Provide a threshold for the escape context. If the novel symbols count drop 
 *   below a certain value, we do not use escape context at all. 
 *    
 * - Order-1 coder (most likely not, the memory requirement is too high!) 
 *  
 * - Upgrade to 27 bits! 
 * 
 */ 
/*----------------------------------------------------------------------------*/ 
/*----------------------------------------------------------------------------*/ 
 
/*----------------------------------------------------------------------------*/ 
/*----------------------------------------------------------------------------*/	 
#include  
#include  
#include "bitio.h" 
#include "global.h" 
#include "memchk.h" 
 
/*----------------------------------------------------------------------------*/	 
/*----------------------------------------------------------------------------*/	 
#define CodeValueBits 16             
#define TopValue (((int)1<