ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/mports/trunk/mail/faces/files/patch-ce
Revision: 16349
Committed: Sun Apr 20 18:32:36 2014 UTC (10 years ago) by laffer1
File size: 8823 byte(s)
Log Message:
remove cvs2svn:cvs-rev prop

File Contents

# Content
1 *** compface/compface.h Thu Feb 21 16:42:54 2002
2 --- /home/lkoeller/tmp/ports/mail/faces/work/faces/compface/compface.h Thu Sep 5 07:24:42 1991
3 ***************
4 *** 14,45 ****
5 * to me, then an attempt will be made to fix them.
6 */
7
8 #include <string.h>
9 #include <fcntl.h>
10 #include <setjmp.h>
11
12 ! /* Need to know how many bits per hexadecimal digit for io */
13 #define BITSPERDIG 4
14 ! extern char HexDigits[];
15
16 ! /* Define the face size - 48x48x1 */
17 #define WIDTH 48
18 #define HEIGHT WIDTH
19
20 ! /* Total number of pixels and digits */
21 #define PIXELS (WIDTH * HEIGHT)
22 #define DIGITS (PIXELS / BITSPERDIG)
23
24 ! extern char F[PIXELS];
25
26 ! /* Output formatting word lengths and line lengths */
27 #define DIGSPERWORD 4
28 #define WORDSPERLINE (WIDTH / DIGSPERWORD / BITSPERDIG)
29
30 ! /* Compressed output uses the full range of printable characters.
31 * in ascii these are in a contiguous block so we just need to know
32 ! * the first and last. The total number of printables is needed too.
33 ! */
34 #define FIRSTPRINT '!'
35 #define LASTPRINT '~'
36 #define NUMPRINTS (LASTPRINT - FIRSTPRINT + 1)
37 --- 13,64 ----
38 * to me, then an attempt will be made to fix them.
39 */
40
41 + #if defined(SYSV32) || defined(hpux)
42 #include <string.h>
43 + #else
44 + #include <strings.h>
45 + #endif /* SYSV32 || hpux */
46 #include <fcntl.h>
47 #include <setjmp.h>
48
49 ! /* For all function declarations, if ANSI then use a prototype. */
50 !
51 ! #if defined(__STDC__)
52 ! #define P(args) args
53 ! #else /* ! __STDC__ */
54 ! #define P(args) ()
55 ! #endif /* STDC */
56 !
57 ! #ifdef MAIN
58 ! #define EXTERN
59 ! #define INIT(x) = x
60 ! #else
61 ! #define EXTERN extern
62 ! #define INIT(x)
63 ! #endif
64 !
65 ! /* need to know how many bits per hexadecimal digit for io */
66 #define BITSPERDIG 4
67 ! EXTERN char HexDigits[] INIT("0123456789ABCDEF");
68
69 ! /* define the face size - 48x48x1 */
70 #define WIDTH 48
71 #define HEIGHT WIDTH
72
73 ! /* total number of pixels and digits */
74 #define PIXELS (WIDTH * HEIGHT)
75 #define DIGITS (PIXELS / BITSPERDIG)
76
77 ! /* internal face representation - 1 char per pixel is faster */
78 ! EXTERN char F[PIXELS];
79
80 ! /* output formatting word lengths and line lengths */
81 #define DIGSPERWORD 4
82 #define WORDSPERLINE (WIDTH / DIGSPERWORD / BITSPERDIG)
83
84 ! /* compressed output uses the full range of printable characters.
85 * in ascii these are in a contiguous block so we just need to know
86 ! * the first and last. The total number of printables is needed too */
87 #define FIRSTPRINT '!'
88 #define LASTPRINT '~'
89 #define NUMPRINTS (LASTPRINT - FIRSTPRINT + 1)
90 ***************
91 *** 49,56 ****
92
93 /* Portable, very large unsigned integer arithmetic is needed.
94 * Implementation uses arrays of WORDs. COMPs must have at least
95 ! * twice as many bits as WORDs to handle intermediate results.
96 ! */
97 #define WORD unsigned char
98 #define COMP unsigned long
99 #define BITSPERWORD 8
100 --- 68,74 ----
101
102 /* Portable, very large unsigned integer arithmetic is needed.
103 * Implementation uses arrays of WORDs. COMPs must have at least
104 ! * twice as many bits as WORDs to handle intermediate results */
105 #define WORD unsigned char
106 #define COMP unsigned long
107 #define BITSPERWORD 8
108 ***************
109 *** 64,76 ****
110 WORD b_word[MAXWORDS];
111 } BigInt;
112
113 ! extern BigInt B;
114
115 /* This is the guess the next pixel table. Normally there are 12 neighbour
116 * pixels used to give 1<<12 cases but in the upper left corner lesser
117 ! * numbers of neighbours are available, leading to 6231 different guesses.
118 ! */
119 ! typedef struct guesses {
120 char g_00[1<<12];
121 char g_01[1<<7];
122 char g_02[1<<2];
123 --- 82,94 ----
124 WORD b_word[MAXWORDS];
125 } BigInt;
126
127 ! EXTERN BigInt B;
128
129 /* This is the guess the next pixel table. Normally there are 12 neighbour
130 * pixels used to give 1<<12 cases but in the upper left corner lesser
131 ! * numbers of neighbours are available, leading to 6231 different guesses */
132 ! typedef struct guesses
133 ! {
134 char g_00[1<<12];
135 char g_01[1<<7];
136 char g_02[1<<2];
137 ***************
138 *** 88,155 ****
139 char g_42[1<<2];
140 } Guesses;
141
142 ! extern Guesses G;
143
144 /* Data of varying probabilities are encoded by a value in the range 0 - 255.
145 * The probability of the data determines the range of possible encodings.
146 ! * Offset gives the first possible encoding of the range.
147 ! */
148 ! typedef struct prob {
149 WORD p_range;
150 WORD p_offset;
151 } Prob;
152
153 ! extern Prob *ProbBuf[PIXELS * 2];
154 ! extern int NumProbs;
155
156 /* Each face is encoded using 9 octrees of 16x16 each. Each level of the
157 * trees has varying probabilities of being white, grey or black.
158 ! * The table below is based on sampling many faces.
159 ! */
160
161 #define BLACK 0
162 #define GREY 1
163 #define WHITE 2
164
165 ! extern Prob levels[4][3];
166 ! extern Prob freqs[16];
167
168 #define ERR_OK 0 /* successful completion */
169 #define ERR_EXCESS 1 /* completed OK but some input was ignored */
170 #define ERR_INSUFF -1 /* insufficient input. Bad face format? */
171 #define ERR_INTERNAL -2 /* Arithmetic overflow or buffer overflow */
172
173 ! extern int status;
174
175 ! extern jmp_buf comp_env;
176
177 ! int AllBlack(char *, int, int);
178 ! int AllWhite(char *, int, int);
179 ! int BigPop(Prob *);
180 ! int compface(char *);
181 ! int main(int, char *[]);
182 ! int ReadBuf();
183 ! int Same(char *, int, int);
184 ! int uncompface(char *);
185 ! int WriteBuf();
186 !
187 ! void BigAdd(WORD);
188 ! void BigClear();
189 ! void BigDiv(WORD, WORD *);
190 ! void BigMul(WORD);
191 ! void BigPrint();
192 ! void BigPush(Prob *);
193 ! void BigRead(char *);
194 ! void BigSub(WORD);
195 ! void BigWrite(char *);
196 ! void CompAll(char *);
197 ! void Compress(char *, int, int, int);
198 ! void GenFace();
199 ! void PopGreys(char *, int, int);
200 ! void PushGreys(char *, int, int);
201 ! void ReadFace(char *);
202 ! void RevPush(Prob *);
203 ! void UnCompAll(char *);
204 ! void UnCompress(char *, int, int, int);
205 ! void UnGenFace();
206 ! void WriteFace(char *);
207 --- 106,204 ----
208 char g_42[1<<2];
209 } Guesses;
210
211 ! /* data.h was established by sampling over 1000 faces and icons */
212 ! EXTERN Guesses G
213 ! #ifdef MAIN
214 ! =
215 ! #include "data.h"
216 ! #endif
217 ! ;
218
219 /* Data of varying probabilities are encoded by a value in the range 0 - 255.
220 * The probability of the data determines the range of possible encodings.
221 ! * Offset gives the first possible encoding of the range */
222 ! typedef struct prob
223 ! {
224 WORD p_range;
225 WORD p_offset;
226 } Prob;
227
228 ! /* A stack of probability values */
229 ! EXTERN Prob *ProbBuf[PIXELS * 2];
230 ! EXTERN int NumProbs INIT(0);
231
232 /* Each face is encoded using 9 octrees of 16x16 each. Each level of the
233 * trees has varying probabilities of being white, grey or black.
234 ! * The table below is based on sampling many faces */
235
236 #define BLACK 0
237 #define GREY 1
238 #define WHITE 2
239
240 ! EXTERN Prob levels[4][3]
241 ! #ifdef MAIN
242 ! =
243 ! {
244 ! {{1, 255}, {251, 0}, {4, 251}}, /* Top of tree almost always grey */
245 ! {{1, 255}, {200, 0}, {55, 200}},
246 ! {{33, 223}, {159, 0}, {64, 159}},
247 ! {{131, 0}, {0, 0}, {125, 131}} /* Grey disallowed at bottom */
248 ! }
249 ! #endif
250 ! ;
251 !
252 ! /* At the bottom of the octree 2x2 elements are considered black if any
253 ! * pixel is black. The probabilities below give the distribution of the
254 ! * 16 possible 2x2 patterns. All white is not really a possibility and
255 ! * has a probability range of zero. Again, experimentally derived data */
256 ! EXTERN Prob freqs[16]
257 ! #ifdef MAIN
258 ! =
259 ! {
260 ! {0, 0}, {38, 0}, {38, 38}, {13, 152},
261 ! {38, 76}, {13, 165}, {13, 178}, {6, 230},
262 ! {38, 114}, {13, 191}, {13, 204}, {6, 236},
263 ! {13, 217}, {6, 242}, {5, 248}, {3, 253}
264 ! }
265 ! #endif
266 ! ;
267
268 #define ERR_OK 0 /* successful completion */
269 #define ERR_EXCESS 1 /* completed OK but some input was ignored */
270 #define ERR_INSUFF -1 /* insufficient input. Bad face format? */
271 #define ERR_INTERNAL -2 /* Arithmetic overflow or buffer overflow */
272
273 ! EXTERN int status;
274
275 ! EXTERN jmp_buf comp_env;
276
277 ! int AllBlack P((char *, int, int)) ;
278 ! int AllWhite P((char *, int, int)) ;
279 ! int BigPop P((Prob *)) ;
280 ! int compface P((char *)) ;
281 ! int main P((int, char *[])) ;
282 ! int ReadBuf P(()) ;
283 ! int Same P((char *, int, int)) ;
284 ! int uncompface P((char *)) ;
285 ! int WriteBuf P(()) ;
286 !
287 ! void BigAdd P((unsigned char)) ;
288 ! void BigClear P(()) ;
289 ! void BigDiv P((unsigned char, unsigned char *)) ;
290 ! void BigMul P((unsigned char)) ;
291 ! void BigPrint P(()) ;
292 ! void BigPush P((Prob *)) ;
293 ! void BigRead P((char *)) ;
294 ! void BigSub P((unsigned int)) ;
295 ! void BigWrite P((char *)) ;
296 ! void CompAll P((char *)) ;
297 ! void Compress P((char *, int, int, int)) ;
298 ! void GenFace P(()) ;
299 ! void PopGreys P((char *, int, int)) ;
300 ! void PushGreys P((char *, int, int)) ;
301 ! void ReadFace P((char *)) ;
302 ! void RevPush P((Prob *)) ;
303 ! void UnCompAll P((char *)) ;
304 ! void UnCompress P((char *, int, int, int)) ;
305 ! void UnGenFace P(()) ;
306 ! void WriteFace P((char *)) ;