source: trunk/indexers/mg/src/images/arithcode.h@ 3745

Last change on this file since 3745 was 3745, checked in by mdewsnip, 21 years ago

Addition of MG package for search and retrieval

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1/**************************************************************************
2 *
3 * arithcode.h -- Arithmetic coding
4 * Copyright (C) 1994 Alistair Moffat
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * $Id: arithcode.h 3745 2003-02-20 21:20:24Z mdewsnip $
21 *
22 **************************************************************************/
23
24#ifndef _arithcode_h
25#define _arithcode_h
26
27extern FILE *arith_in, *arith_out;
28
29#define codevaluebits 16
30#if (codevaluebits<16)
31typedef unsigned short codevalue;
32#else
33typedef unsigned long codevalue;
34#endif
35
36#define topvalue ((codevalue)((1<<codevaluebits)-1))
37#define maxfrequency ((topvalue+1)/4 + 1)
38
39#define firstqtr (topvalue/4+1)
40#define half (2*firstqtr)
41#define thirdqtr (3*firstqtr)
42
43#define escape_event U->totalcnt-U->notfound, U->totalcnt, U->totalcnt
44
45void arithmetic_encode ();
46codevalue arithmetic_decode_target ();
47
48#define arithmetic_decode_target(totl) \
49 ( ((S_value-S_low+1)*(totl)-1) / (S_high-S_low+1) )
50
51void arithmetic_decode ();
52
53
54extern codevalue S_low, S_high, S_value;
55extern long S_bitstofollow;
56extern int S_buffer, S_bitstogo;
57
58extern long cmpbytes, rawbytes;
59
60extern long CountOfBitsOut;
61
62void EncodeGammaDist (int Off);
63int DecodeGammaDist ();
64
65void EncodeGammaSigned (int snum, int *pos, int *neg);
66int DecodeGammaSigned (int *pos, int *neg);
67
68
69void InitArithEncoding (void);
70void InitArithDecoding (void);
71
72void CloseDownArithEncoding (void);
73void CloseDownArithDecoding (void);
74
75void EncodeChecksum ();
76void DecodeChecksum (char str[]);
77
78#endif
Note: See TracBrowser for help on using the repository browser.