Mercurial > hg > dmlib
annotate src/dmzlib.h @ 997:cd0e0270e1ce
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 01 Mar 2015 02:58:53 +0200 |
parents | 6c33c92de066 |
children | 36add4215cdd |
rev | line source |
---|---|
949
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * DMLib |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * -- ZLib implementation |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 * Public domain zlib decode v0.2 by Sean Barrett 2006-11-18 |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * Modified and reformatted for DMLib by Matti 'ccr' Hamalainen |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 */ |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 #ifndef DMZLIB_H |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 #define DMZLIB_H |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 #include "dmlib.h" |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 #ifdef __cplusplus |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 extern "C" { |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 #endif |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 |
970 | 16 |
17 #define STBI__ZFAST_BITS 9 // accelerate all cases in default tables | |
949
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 #define STBI__ZFAST_SIZE (1 << STBI__ZFAST_BITS) |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 #define STBI__ZFAST_MASK (STBI__ZFAST_SIZE - 1) |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 typedef struct |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 { |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 Uint16 fast[STBI__ZFAST_SIZE]; |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 Uint16 firstCode[16]; |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 int maxCode[17]; |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 Uint16 firstSymbol[16]; |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 Uint8 size[288]; |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 Uint16 value[288]; |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 } DMZHuffmanContext; |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 typedef struct |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
949
diff
changeset
|
35 Uint8 *zbuffer, *zbufferEnd; |
949
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
949
diff
changeset
|
37 int numBits; |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
949
diff
changeset
|
38 Uint32 codeBuffer; |
949
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
949
diff
changeset
|
40 Uint8 *zout, *zoutStart, *zoutEnd; |
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
949
diff
changeset
|
41 BOOL expandable; |
949
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
949
diff
changeset
|
43 DMZHuffmanContext zlength, zdistance; |
949
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 } DMZLibContext; |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 |
997 | 47 void dmZLibInit(); |
48 int dmZLibParseHeader(DMZLibContext * ctx, BOOL checkPNG); | |
49 int dmZLibDecode(DMZLibContext * ctx); | |
949
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 #ifdef __cplusplus |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 } |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 #endif |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 |
6ed9465f3913
Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 #endif // DMZLIB_H |