annotate src/dmzlib.h @ 2294:7f6ba3b32f54

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 03 Jul 2019 10:28:43 +0300
parents 043b5942fdb6
children 9807ae37ad69
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
1069
b20922f4746f Comments, cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1062
diff changeset
24
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 typedef struct
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 {
1062
d36bf7514614 Add some constants and make initialization one-time only.
Matti Hamalainen <ccr@tnsp.org>
parents: 1061
diff changeset
27 BOOL initialized;
d36bf7514614 Add some constants and make initialization one-time only.
Matti Hamalainen <ccr@tnsp.org>
parents: 1061
diff changeset
28
1060
5006cfe66250 Rename constants.
Matti Hamalainen <ccr@tnsp.org>
parents: 1054
diff changeset
29 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
30 Uint16 firstCode[16];
1061
43905dacb365 Clarify.
Matti Hamalainen <ccr@tnsp.org>
parents: 1060
diff changeset
31 int maxCode[16 + 1];
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 Uint16 firstSymbol[16];
1062
d36bf7514614 Add some constants and make initialization one-time only.
Matti Hamalainen <ccr@tnsp.org>
parents: 1061
diff changeset
33
d36bf7514614 Add some constants and make initialization one-time only.
Matti Hamalainen <ccr@tnsp.org>
parents: 1061
diff changeset
34 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
35 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
36 } DMZHuffmanContext;
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
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 typedef struct
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 {
1074
e98bc627ad08 Rename dmzlib structure members.
Matti Hamalainen <ccr@tnsp.org>
parents: 1069
diff changeset
41 Uint8 *inBuffer, *inBufferStart, *inBufferEnd;
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42
1005
36add4215cdd Oops, missed this.
Matti Hamalainen <ccr@tnsp.org>
parents: 997
diff changeset
43 int window;
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
44 int numBits;
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
45 Uint32 codeBuffer;
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46
1074
e98bc627ad08 Rename dmzlib structure members.
Matti Hamalainen <ccr@tnsp.org>
parents: 1069
diff changeset
47 Uint8 *outBuffer, *outBufferStart, *outBufferEnd;
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
48 BOOL expandable;
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 949
diff changeset
50 DMZHuffmanContext zlength, zdistance;
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 } DMZLibContext;
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53
1054
d98fcb10df6a Work on dmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1005
diff changeset
54 int dmZLibInit();
d98fcb10df6a Work on dmzlib.
Matti Hamalainen <ccr@tnsp.org>
parents: 1005
diff changeset
55 void dmZLibClose();
1121
043b5942fdb6 Rename some dmzlib functions and add context init/close functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1074
diff changeset
56
043b5942fdb6 Rename some dmzlib functions and add context init/close functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1074
diff changeset
57 int dmZLibInitInflate(DMZLibContext *ctx);
043b5942fdb6 Rename some dmzlib functions and add context init/close functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1074
diff changeset
58 void dmZLibCloseInflate(DMZLibContext *ctx);
997
cd0e0270e1ce Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 970
diff changeset
59 int dmZLibParseHeader(DMZLibContext * ctx, BOOL checkPNG);
1121
043b5942fdb6 Rename some dmzlib functions and add context init/close functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 1074
diff changeset
60 int dmZLibInflate(DMZLibContext * ctx);
949
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
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 #ifdef __cplusplus
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 }
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 #endif
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66
6ed9465f3913 Initial import of separated zlib decoding routines lifted from
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 #endif // DMZLIB_H