summaryrefslogtreecommitdiff
path: root/plugins/FreeImage/src/LibMNG/libmng_chunk_io.h
blob: b47f8639b9580505ac625d8d695b54af7c716f95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
/* ************************************************************************** */
/* *             For conditions of distribution and use,                    * */
/* *                see copyright notice in libmng.h                        * */
/* ************************************************************************** */
/* *                                                                        * */
/* * project   : libmng                                                     * */
/* * file      : libmng_chunk_io.h         copyright (c) 2000-2007 G.Juyn   * */
/* * version   : 1.0.109                                                      * */
/* *                                                                        * */
/* * purpose   : Chunk I/O routines (definition)                            * */
/* *                                                                        * */
/* * author    : G.Juyn                                                     * */
/* *                                                                        * */
/* * comment   : Definition of the chunk input/output routines              * */
/* *                                                                        * */
/* * changes   : 0.5.1 - 05/04/2000 - G.Juyn                                * */
/* *             - changed CRC initialization to use dynamic structure      * */
/* *               (wasn't thread-safe the old way !)                       * */
/* *             0.5.1 - 05/08/2000 - G.Juyn                                * */
/* *             - changed write routines definition                        * */
/* *             - changed strict-ANSI stuff                                * */
/* *                                                                        * */
/* *             0.9.2 - 08/05/2000 - G.Juyn                                * */
/* *             - changed file-prefixes                                    * */
/* *                                                                        * */
/* *             0.9.3 - 08/26/2000 - G.Juyn                                * */
/* *             - added MAGN chunk                                         * */
/* *             0.9.3 - 10/16/2000 - G.Juyn                                * */
/* *             - added support for JDAA                                   * */
/* *                                                                        * */
/* *             1.0.5 - 08/19/2002 - G.Juyn                                * */
/* *             - B597134 - libmng pollutes the linker namespace           * */
/* *             1.0.5 - 09/14/2002 - G.Juyn                                * */
/* *             - added event handling for dynamic MNG                     * */
/* *                                                                        * */
/* *             1.0.6 - 07/07/2003 - G.R-P                                 * */
/* *             - added SKIP_CHUNK and NO_DELTA_PNG support                * */
/* *             1.0.6 - 07/29/2003 - G.R-P                                 * */
/* *             - added conditionals around PAST chunk support             * */
/* *                                                                        * */
/* *             1.0.7 - 03/24/2004 - G.R-P                                 * */
/* *             - fixed SKIPCHUNK_itXT and SKIPCHUNK_ztXT typos            * */
/* *                                                                        * */
/* *             1.0.9 - 12/07/2004 - G.Juyn                                * */
/* *             - added conditional MNG_OPTIMIZE_CHUNKREADER               * */
/* *                                                                        * */
/* *             1.0.10 - 04/08/2007 - G.Juyn                               * */
/* *             - added support for mPNG proposal                          * */
/* *             1.0.10 - 04/12/2007 - G.Juyn                               * */
/* *             - added support for ANG proposal                           * */
/* *                                                                        * */
/* ************************************************************************** */

#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
#pragma option -A                      /* force ANSI-C */
#endif

#ifndef _libmng_chunk_io_h_
#define _libmng_chunk_io_h_

/* ************************************************************************** */

mng_uint32 mng_crc (mng_datap  pData,
                    mng_uint8p buf,
                    mng_int32  len);

/* ************************************************************************** */

#ifdef MNG_INCLUDE_READ_PROCS

/* ************************************************************************** */

mng_retcode mng_inflate_buffer (mng_datap  pData,
                                mng_uint8p pInbuf,
                                mng_uint32 iInsize,
                                mng_uint8p *pOutbuf,
                                mng_uint32 *iOutsize,
                                mng_uint32 *iRealsize);

/* ************************************************************************** */

#define READ_CHUNK(n) mng_retcode n (mng_datap   pData,    \
                                     mng_chunkp  pHeader,  \
                                     mng_uint32  iRawlen,  \
                                     mng_uint8p  pRawdata, \
                                     mng_chunkp* ppChunk)

#ifdef MNG_OPTIMIZE_CHUNKREADER
READ_CHUNK (mng_read_general) ;
#endif

READ_CHUNK (mng_read_ihdr) ;
READ_CHUNK (mng_read_plte) ;
READ_CHUNK (mng_read_idat) ;
READ_CHUNK (mng_read_iend) ;
READ_CHUNK (mng_read_trns) ;
READ_CHUNK (mng_read_gama) ;
READ_CHUNK (mng_read_chrm) ;
READ_CHUNK (mng_read_srgb) ;
#ifndef MNG_SKIPCHUNK_iCCP
READ_CHUNK (mng_read_iccp) ;
#endif
#ifndef MNG_SKIPCHUNK_tEXt
READ_CHUNK (mng_read_text) ;
#endif
#ifndef MNG_SKIPCHUNK_zTXt
READ_CHUNK (mng_read_ztxt) ;
#endif
#ifndef MNG_SKIPCHUNK_iTXt
READ_CHUNK (mng_read_itxt) ;
#endif
#ifndef MNG_SKIPCHUNK_bKGD
READ_CHUNK (mng_read_bkgd) ;
#endif
#ifndef MNG_SKIPCHUNK_pHYs
READ_CHUNK (mng_read_phys) ;
#endif
#ifndef MNG_SKIPCHUNK_sBIT
READ_CHUNK (mng_read_sbit) ;
#endif
#ifndef MNG_SKIPCHUNK_sPLT
READ_CHUNK (mng_read_splt) ;
#endif
#ifndef MNG_SKIPCHUNK_hIST
READ_CHUNK (mng_read_hist) ;
#endif
#ifndef MNG_SKIPCHUNK_tIME
READ_CHUNK (mng_read_time) ;
#endif
READ_CHUNK (mng_read_mhdr) ;
READ_CHUNK (mng_read_mend) ;
READ_CHUNK (mng_read_loop) ;
READ_CHUNK (mng_read_endl) ;
READ_CHUNK (mng_read_defi) ;
READ_CHUNK (mng_read_basi) ;
READ_CHUNK (mng_read_clon) ;
#ifndef MNG_SKIPCHUNK_PAST
READ_CHUNK (mng_read_past) ;
#endif
READ_CHUNK (mng_read_disc) ;
READ_CHUNK (mng_read_back) ;
READ_CHUNK (mng_read_fram) ;
READ_CHUNK (mng_read_move) ;
READ_CHUNK (mng_read_clip) ;
READ_CHUNK (mng_read_show) ;
READ_CHUNK (mng_read_term) ;
READ_CHUNK (mng_read_save) ;
READ_CHUNK (mng_read_seek) ;
#ifndef MNG_SKIPCHUNK_eXPI
READ_CHUNK (mng_read_expi) ;
#endif
#ifndef MNG_SKIPCHUNK_fPRI
READ_CHUNK (mng_read_fpri) ;
#endif
#ifndef MNG_SKIPCHUNK_pHYg
READ_CHUNK (mng_read_phyg) ;
#endif
#ifdef MNG_INCLUDE_JNG
READ_CHUNK (mng_read_jhdr) ;
READ_CHUNK (mng_read_jdaa) ;
READ_CHUNK (mng_read_jdat) ;
READ_CHUNK (mng_read_jsep) ;
#endif
#ifndef MNG_NO_DELTA_PNG
READ_CHUNK (mng_read_dhdr) ;
READ_CHUNK (mng_read_prom) ;
READ_CHUNK (mng_read_ipng) ;
READ_CHUNK (mng_read_pplt) ;
#ifdef MNG_INCLUDE_JNG
READ_CHUNK (mng_read_ijng) ;
#endif
READ_CHUNK (mng_read_drop) ;
READ_CHUNK (mng_read_dbyk) ;
READ_CHUNK (mng_read_ordr) ;
#endif
READ_CHUNK (mng_read_magn) ;
#ifndef MNG_SKIPCHUNK_nEED
READ_CHUNK (mng_read_need) ;
#endif
#ifdef MNG_INCLUDE_MPNG_PROPOSAL
READ_CHUNK (mng_read_mpng) ;
#endif
#ifndef MNG_SKIPCHUNK_evNT
READ_CHUNK (mng_read_evnt) ;
#endif
READ_CHUNK (mng_read_unknown) ;

/* ************************************************************************** */

#else /* MNG_INCLUDE_READ_PROCS */
#define mng_read_ihdr 0
#define mng_read_plte 0
#define mng_read_idat 0
#define mng_read_iend 0
#define mng_read_trns 0
#define mng_read_gama 0
#define mng_read_chrm 0
#define mng_read_srgb 0
#define mng_read_iccp 0
#define mng_read_text 0
#define mng_read_ztxt 0
#define mng_read_itxt 0
#define mng_read_bkgd 0
#define mng_read_phys 0
#define mng_read_sbit 0
#define mng_read_splt 0
#define mng_read_hist 0
#define mng_read_time 0
#define mng_read_mhdr 0
#define mng_read_mend 0
#define mng_read_loop 0
#define mng_read_endl 0
#define mng_read_defi 0
#define mng_read_basi 0
#define mng_read_clon 0
#ifndef MNG_SKIPCHUNK_PAST
#define mng_read_past 0
#endif
#define mng_read_disc 0
#define mng_read_back 0
#define mng_read_fram 0
#define mng_read_move 0
#define mng_read_clip 0
#define mng_read_show 0
#define mng_read_term 0
#define mng_read_save 0
#define mng_read_seek 0
#define mng_read_expi 0
#define mng_read_fpri 0
#define mng_read_phyg 0
#ifdef MNG_INCLUDE_JNG
#define mng_read_jhdr 0
#define mng_read_jdaa 0
#define mng_read_jdat 0
#define mng_read_jsep 0
#endif
#ifndef MNG_NO_DELTA_PNG
#define mng_read_dhdr 0
#define mng_read_prom 0
#define mng_read_ipng 0
#define mng_read_pplt 0
#ifdef MNG_INCLUDE_JNG
#define mng_read_ijng 0
#endif
#define mng_read_drop 0
#define mng_read_dbyk 0
#define mng_read_ordr 0
#endif
#define mng_read_magn 0
#define mng_read_need 0
#ifdef MNG_INCLUDE_MPNG_PROPOSAL
#define mng_read_mpng 0
#endif
#define mng_read_evnt 0
#define mng_read_unknown 0
#endif /* MNG_INCLUDE_READ_PROCS */

/* ************************************************************************** */

#ifdef MNG_INCLUDE_WRITE_PROCS

#define WRITE_CHUNK(n) mng_retcode n (mng_datap  pData,   \
                                      mng_chunkp pChunk)

WRITE_CHUNK (mng_write_ihdr) ;
WRITE_CHUNK (mng_write_plte) ;
WRITE_CHUNK (mng_write_idat) ;
WRITE_CHUNK (mng_write_iend) ;
WRITE_CHUNK (mng_write_trns) ;
WRITE_CHUNK (mng_write_gama) ;
WRITE_CHUNK (mng_write_chrm) ;
WRITE_CHUNK (mng_write_srgb) ;
WRITE_CHUNK (mng_write_iccp) ;
WRITE_CHUNK (mng_write_text) ;
WRITE_CHUNK (mng_write_ztxt) ;
WRITE_CHUNK (mng_write_itxt) ;
WRITE_CHUNK (mng_write_bkgd) ;
WRITE_CHUNK (mng_write_phys) ;
WRITE_CHUNK (mng_write_sbit) ;
WRITE_CHUNK (mng_write_splt) ;
WRITE_CHUNK (mng_write_hist) ;
WRITE_CHUNK (mng_write_time) ;
WRITE_CHUNK (mng_write_mhdr) ;
WRITE_CHUNK (mng_write_mend) ;
WRITE_CHUNK (mng_write_loop) ;
WRITE_CHUNK (mng_write_endl) ;
WRITE_CHUNK (mng_write_defi) ;
WRITE_CHUNK (mng_write_basi) ;
WRITE_CHUNK (mng_write_clon) ;
#ifndef MNG_SKIPCHUNK_PAST
WRITE_CHUNK (mng_write_past) ;
#endif
WRITE_CHUNK (mng_write_disc) ;
WRITE_CHUNK (mng_write_back) ;
WRITE_CHUNK (mng_write_fram) ;
WRITE_CHUNK (mng_write_move) ;
WRITE_CHUNK (mng_write_clip) ;
WRITE_CHUNK (mng_write_show) ;
WRITE_CHUNK (mng_write_term) ;
WRITE_CHUNK (mng_write_save) ;
WRITE_CHUNK (mng_write_seek) ;
WRITE_CHUNK (mng_write_expi) ;
WRITE_CHUNK (mng_write_fpri) ;
WRITE_CHUNK (mng_write_phyg) ;
#ifdef MNG_INCLUDE_JNG
WRITE_CHUNK (mng_write_jhdr) ;
WRITE_CHUNK (mng_write_jdaa) ;
WRITE_CHUNK (mng_write_jdat) ;
WRITE_CHUNK (mng_write_jsep) ;
#endif
#ifndef MNG_NO_DELTA_PNG
WRITE_CHUNK (mng_write_dhdr) ;
WRITE_CHUNK (mng_write_prom) ;
WRITE_CHUNK (mng_write_ipng) ;
WRITE_CHUNK (mng_write_pplt) ;
#ifdef MNG_INCLUDE_JNG
WRITE_CHUNK (mng_write_ijng) ;
#endif
WRITE_CHUNK (mng_write_drop) ;
WRITE_CHUNK (mng_write_dbyk) ;
WRITE_CHUNK (mng_write_ordr) ;
#endif
WRITE_CHUNK (mng_write_magn) ;
WRITE_CHUNK (mng_write_need) ;
#ifdef MNG_INCLUDE_MPNG_PROPOSAL
WRITE_CHUNK (mng_write_mpng) ;
#endif
#ifdef MNG_INCLUDE_ANG_PROPOSAL
WRITE_CHUNK (mng_write_ahdr) ;
WRITE_CHUNK (mng_write_adat) ;
#endif
WRITE_CHUNK (mng_write_evnt) ;
WRITE_CHUNK (mng_write_unknown) ;

/* ************************************************************************** */

#else /* MNG_INCLUDE_WRITE_PROCS */
#define mng_write_ihdr 0
#define mng_write_plte 0
#define mng_write_idat 0
#define mng_write_iend 0
#define mng_write_trns 0
#define mng_write_gama 0
#define mng_write_chrm 0
#define mng_write_srgb 0
#define mng_write_iccp 0
#define mng_write_text 0
#define mng_write_ztxt 0
#define mng_write_itxt 0
#define mng_write_bkgd 0
#define mng_write_phys 0
#define mng_write_sbit 0
#define mng_write_splt 0
#define mng_write_hist 0
#define mng_write_time 0
#define mng_write_mhdr 0
#define mng_write_mend 0
#define mng_write_loop 0
#define mng_write_endl 0
#define mng_write_defi 0
#define mng_write_basi 0
#define mng_write_clon 0
#ifndef MNG_SKIPCHUNK_PAST
#define mng_write_past 0
#endif
#define mng_write_disc 0
#define mng_write_back 0
#define mng_write_fram 0
#define mng_write_move 0
#define mng_write_clip 0
#define mng_write_show 0
#define mng_write_term 0
#define mng_write_save 0
#define mng_write_seek 0
#define mng_write_expi 0
#define mng_write_fpri 0
#define mng_write_phyg 0
#ifdef MNG_INCLUDE_JNG
#define mng_write_jhdr 0
#define mng_write_jdaa 0
#define mng_write_jdat 0
#define mng_write_jsep 0
#endif
#ifndef MNG_NO_DELTA_PNG
#define mng_write_dhdr 0
#define mng_write_prom 0
#define mng_write_ipng 0
#define mng_write_pplt 0
#ifdef MNG_INCLUDE_JNG
#define mng_write_ijng 0
#endif
#define mng_write_drop 0
#define mng_write_dbyk 0
#define mng_write_ordr 0
#endif
#define mng_write_magn 0
#define mng_write_need 0
#ifdef MNG_INCLUDE_MPNG_PROPOSAL
#define mng_write_mpng 0
#endif
#ifdef MNG_INCLUDE_ANG_PROPOSAL
#define mng_write_adat 0
#define mng_write_ahdr 0
#endif
#define mng_write_evnt 0
#define mng_write_unknown 0
#endif /* MNG_INCLUDE_WRITE_PROCS */

/* ************************************************************************** */

#endif /* _libmng_chunk_io_h_ */

/* ************************************************************************** */
/* * end of file                                                            * */
/* ************************************************************************** */