annotate src/dmzlib.h @ 1062:d36bf7514614

Add some constants and make initialization one-time only.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 02 Mar 2015 00:03:13 +0200
parents 43905dacb365
children b20922f4746f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
6c33c92de066 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 960
diff changeset
16
1060
5006cfe66250 Rename constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1054
diff changeset
17 #define DM_ZLIB_HFAST_BITS 9 // accelerate all cases in default tables
5006cfe66250 Rename constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1054
diff changeset
18 #define DM_ZLIB_HFAST_SIZE (1 << DM_ZLIB_HFAST_BITS)
5006cfe66250 Rename constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1054
diff changeset
19 #define DM_ZLIB_HFAST_MASK (DM_ZLIB_HFAST_SIZE - 1)
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20
1062
d36bf7514614 Add some constants and make initialization one-time only.
Matti Hamalainen <ccr@tnsp.org>
parents: 1061
diff changeset
21 #define DM_ZLIB_HUFF_CODES (288)
d36bf7514614 Add some constants and make initialization one-time only.
Matti Hamalainen <ccr@tnsp.org>
parents: 1061
diff changeset
22 #define DM_ZLIB_HUFF_DIST (32)
949
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 typedef struct
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 {
1062
d36bf7514614 Add some constants and make initialization one-time only.
Matti Hamalainen <ccr@tnsp.org>
parents: 1061
diff changeset
26 BOOL initialized;
d36bf7514614 Add some constants and make initialization one-time only.
Matti Hamalainen <ccr@tnsp.org>
parents: 1061
diff changeset
27
1060
5006cfe66250 Rename constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1054
diff changeset
28 Uint16 fast[DM_ZLIB_HFAST_SIZE];
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 Uint16 firstCode[16];
1061
43905dacb365 Clarify.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
30 int maxCode[16 + 1];
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 Uint16 firstSymbol[16];
1062
d36bf7514614 Add some constants and make initialization one-time only.
Matti Hamalainen <ccr@tnsp.org>
parents: 1061
diff changeset
32
d36bf7514614 Add some constants and make initialization one-time only.
Matti Hamalainen <ccr@tnsp.org>
parents: 1061
diff changeset
33 Uint8 size[DM_ZLIB_HUFF_CODES];
d36bf7514614 Add some constants and make initialization one-time only.
Matti Hamalainen <ccr@tnsp.org>
parents: 1061
diff changeset
34 Uint16 value[DM_ZLIB_HUFF_CODES];
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 } DMZHuffmanContext;
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 typedef struct
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 *zbuffer, *zbufferEnd;
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
1005
36add4215cdd Oops, missed this.
Matti Hamalainen <ccr@tnsp.org>
parents: 997
diff changeset
42 int window;
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
43 int numBits;
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
44 Uint32 codeBuffer;
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
46 Uint8 *zout, *zoutStart, *zoutEnd;
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
47 BOOL expandable;
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
49 DMZHuffmanContext zlength, zdistance;
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 } DMZLibContext;
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
1054
d98fcb10df6a Work on dmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1005
diff changeset
53 int dmZLibInit();
d98fcb10df6a Work on dmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1005
diff changeset
54 void dmZLibClose();
997
cd0e0270e1ce Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 970
diff changeset
55 int dmZLibParseHeader(DMZLibContext * ctx, BOOL checkPNG);
cd0e0270e1ce Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 970
diff changeset
56 int dmZLibDecode(DMZLibContext * ctx);
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 #ifdef __cplusplus
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 }
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 #endif
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 #endif // DMZLIB_H