lib/DtHelp/il: remove register keyword
[oweals/cde.git] / cde / lib / DtHelp / il / ildecompg4.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: ildecompg4.h /main/3 1995/10/23 15:45:43 rswiston $ */
24 /**---------------------------------------------------------------------
25 ***     
26 ***    (c)Copyright 1991 Hewlett-Packard Co.
27 ***    
28 ***                             RESTRICTED RIGHTS LEGEND
29 ***    Use, duplication, or disclosure by the U.S. Government is subject to
30 ***    restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
31 ***    Technical Data and Computer Software clause in DFARS 252.227-7013.
32 ***                             Hewlett-Packard Company
33 ***                             3000 Hanover Street
34 ***                             Palo Alto, CA 94304 U.S.A.
35 ***    Rights for non-DOD U.S. Government Departments and Agencies are as set
36 ***    forth in FAR 52.227-19(c)(1,2).
37 ***
38 ***-------------------------------------------------------------------*/
39
40
41
42 /* ====================================================================================
43         -------------------- Macros --------------------
44    ==================================================================================== */
45
46 #define READ32_LSB(address) \
47    (* ((unsigned char *)(address))         + \
48    (*(((unsigned char *)(address))+1)<< 8) + \
49    (*(((unsigned char *)(address))+2)<<16) + \
50    (*(((unsigned char *)(address))+3)<<24))
51
52
53 #define READ32_MSB(address) \
54    (ilBitReverseTable[* ((unsigned char *)(address))]         + \
55    (ilBitReverseTable[*(((unsigned char *)(address))+1)] << 8) + \
56    (ilBitReverseTable[*(((unsigned char *)(address))+2)]<<16) + \
57    (ilBitReverseTable[*(((unsigned char *)(address))+3)]<<24) )
58
59
60
61 #define GET_VALUE_LSB(value,base, offset, mask) {  \
62     if (offset > pPriv->maxSrcPos) return IL_ERROR_COMPRESSED_DATA; \
63     value = (READ32_LSB((base) + ((offset) >> 3)) >> ((offset) & 7) & (mask)); \
64 }
65
66 #define GET_VALUE_MSB(value,base, offset, mask) {  \
67     if (offset > pPriv->maxSrcPos) return IL_ERROR_COMPRESSED_DATA; \
68     value = (READ32_MSB((base) + ((offset) >> 3)) >> ((offset) & 7) & (mask)); \
69 }
70  
71
72
73
74             
75 /* ====================================================================================
76         -------------------- Code table constants --------------------
77    ==================================================================================== */
78
79 #define G4K_BlackTableSize      8192
80 #define G4K_WhiteTableSize      4096
81 #define G4K_DecodeTableSize     4096
82 #define G4K_MinSrcLen             14    /* Defines the maximum codeword size in bits */
83 #define G4M_WhiteRun          0x0FFF
84 #define G4M_BlackRun          0x1FFF
85 #define G4M_Codeword          0x0FFF
86
87
88
89 /* ====================================================================================
90         -------------------- Decoding mode constants --------------------
91    ==================================================================================== */
92
93 #define G4K_ModeNewScan            1
94 #define G4K_ModeCodeword           2
95 #define G4K_ModeFirstRun           3
96 #define G4K_ModeSecondRun          4
97
98
99 /*
100     These constants define the usage of the change lists. If the change list
101     index is even, a white run is described. If a black run is being defined,
102     the changelist index will be odd.
103 */
104 #define G4K_WhiteRun               1
105 #define G4K_BlackRun               0
106
107
108 /* Code type constants */
109
110 #define G4K_CodetypeTerminator     2
111 #define G4K_CodetypeEol           -1
112 #define G4K_CodetypeMakeup         1
113
114
115 /* Code value constants */
116
117 #define G4K_CodevaluePass          4
118 #define G4K_CodevalueHoriz         5
119 #define G4K_CodevalueV0            0
120 #define G4K_CodevalueVR1           1
121 #define G4K_CodevalueVL1          -1
122 #define G4K_CodevalueVR2           2
123 #define G4K_CodevalueVL2          -2
124 #define G4K_CodevalueVR3           3
125 #define G4K_CodevalueVL3          -3
126
127
128
129 /* ====================================================================================
130         -------------------- Status code definitions --------------------
131    ==================================================================================== */
132
133 #define G4K_StsEol                -1
134 #define G4K_StsDcdErr             -2
135 #define G4K_StsSrcExh             -3
136 #define G4K_StsDstFul             -4
137 #define G4K_AlgorithmAbort        62
138
139 /* define to find out the value of the bit (1 or 0) in the image line      */
140 #define PIXEL(buf,ix)   ((((buf)[(ix)>>3]) >> (7-((ix)&7))) & 1)             
141
142 /* define to find out the value of the bit (1 or 0) in the image line      */
143 #define PIXEL_LSB(buf,ix)       ((ilBitReverseTable[((buf)[(ix)>>3])] >> (7-((ix)&7))) & 1)             
144                  
145
146
147
148 /* ========================================================================
149    Decompression private data structure definition
150    ======================================================================== */
151
152 typedef struct {
153    int                  width;         /* width of the image              */   
154    long                 compFlags;     /* flags denoting G4 comp. options */
155    ilBool               white;         /* value of the white pixel 0 or 1 */
156    ilPtr                ImageP;        /* ptr. to the Source Image begin  */
157    int                  srcpos;        /* bit position is Src image start */
158    ilBool               Is_Lsb_First;  /* true if  LSB is desired         */
159    ilPtr                gpRefLine;     /* ptr.to refrence line for 2d coding */
160    long                 nDstLineBytes; /* no.of bytes in the Image        */
161    long                 maxSrcPos;     /* size of the src Image in bits   */
162 }  ilDecompG3G4PrivRec, *ilDecompG3G4PrivPtr;
163
164 /* ====================================================================================
165    -------------------- Huffman decode table structure definition --------------------
166    ==================================================================================== */
167
168 typedef struct {
169     short           value;
170     unsigned char   length;
171     char            type;
172 } ilDecompG4HuffTableRec, *ilDecompG4HuffTablePtr;
173
174 typedef const ilDecompG4HuffTableRec*   ilDecompG4HuffTablePtrConst;
175
176 IL_EXTERN const ilDecompG4HuffTableRec ilArFax1DDecodeWhite[G4K_WhiteTableSize];
177
178 IL_EXTERN const ilDecompG4HuffTableRec ilArFax1DDecodeBlack[G4K_BlackTableSize];
179
180 IL_EXTERN const ilDecompG4HuffTableRec ilArFax2DDecodeTable[G4K_DecodeTableSize];
181
182 IL_EXTERN ilError   _ilDecompG4Line(
183 ilDecompG3G4PrivPtr  pPriv,
184 ilPtr          pRefLine,
185 ilPtr          dstImageP
186 );