source: trunk/src/3rdparty/libmng/libmng_chunk_descr.c

Last change on this file was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 192.6 KB
Line 
1/* ************************************************************************** */
2/* * For conditions of distribution and use, * */
3/* * see copyright notice in libmng.h * */
4/* ************************************************************************** */
5/* * * */
6/* * project : libmng * */
7/* * file : libmng_chunk_descr.c copyright (c) 2005-2007 G.Juyn * */
8/* * version : 1.0.10 * */
9/* * * */
10/* * purpose : Chunk descriptor functions (implementation) * */
11/* * * */
12/* * author : G.Juyn * */
13/* * * */
14/* * comment : implementation of the chunk- anf field-descriptor * */
15/* * routines * */
16/* * * */
17/* * changes : 1.0.9 - 12/06/2004 - G.Juyn * */
18/* * - added conditional MNG_OPTIMIZE_CHUNKREADER * */
19/* * 1.0.9 - 12/11/2004 - G.Juyn * */
20/* * - made all constants 'static' * */
21/* * 1.0.9 - 12/20/2004 - G.Juyn * */
22/* * - cleaned up macro-invocations (thanks to D. Airlie) * */
23/* * 1.0.9 - 01/17/2005 - G.Juyn * */
24/* * - fixed problem with global PLTE/tRNS * */
25/* * * */
26/* * 1.0.10 - 01/17/2005 - G.R-P. * */
27/* * - added typecast to appease the compiler * */
28/* * 1.0.10 - 04/08/2007 - G.Juyn * */
29/* * - added support for mPNG proposal * */
30/* * 1.0.10 - 04/12/2007 - G.Juyn * */
31/* * - added support for ANG proposal * */
32/* * * */
33/* ************************************************************************** */
34
35#include <stddef.h> /* needed for offsetof() */
36
37#include "libmng.h"
38#include "libmng_data.h"
39#include "libmng_error.h"
40#include "libmng_trace.h"
41#ifdef __BORLANDC__
42#pragma hdrstop
43#endif
44#include "libmng_memory.h"
45#include "libmng_objects.h"
46#include "libmng_chunks.h"
47#include "libmng_chunk_descr.h"
48#include "libmng_object_prc.h"
49#include "libmng_chunk_prc.h"
50#include "libmng_chunk_io.h"
51#include "libmng_display.h"
52
53#ifdef MNG_INCLUDE_ANG_PROPOSAL
54#include "libmng_pixels.h"
55#include "libmng_filter.h"
56#endif
57
58#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
59#pragma option -A /* force ANSI-C */
60#endif
61
62/* ************************************************************************** */
63
64#ifdef MNG_OPTIMIZE_CHUNKREADER
65#if defined(MNG_INCLUDE_READ_PROCS) || defined(MNG_INCLUDE_WRITE_PROCS)
66
67/* ************************************************************************** */
68/* ************************************************************************** */
69/* PNG chunks */
70
71MNG_LOCAL mng_field_descriptor mng_fields_ihdr [] =
72 {
73 {MNG_NULL,
74 MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT,
75 1, 0, 4, 4,
76 offsetof(mng_ihdr, iWidth), MNG_NULL, MNG_NULL},
77 {MNG_NULL,
78 MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT,
79 1, 0, 4, 4,
80 offsetof(mng_ihdr, iHeight), MNG_NULL, MNG_NULL},
81 {MNG_NULL,
82 MNG_FIELD_INT,
83 1, 16, 1, 1,
84 offsetof(mng_ihdr, iBitdepth), MNG_NULL, MNG_NULL},
85 {MNG_NULL,
86 MNG_FIELD_INT,
87 0, 6, 1, 1,
88 offsetof(mng_ihdr, iColortype), MNG_NULL, MNG_NULL},
89 {MNG_NULL,
90 MNG_FIELD_INT,
91 0, 0, 1, 1,
92 offsetof(mng_ihdr, iCompression), MNG_NULL, MNG_NULL},
93 {MNG_NULL,
94 MNG_FIELD_INT,
95 0, 0, 1, 1,
96 offsetof(mng_ihdr, iFilter), MNG_NULL, MNG_NULL},
97 {MNG_NULL,
98 MNG_FIELD_INT,
99 0, 1, 1, 1,
100 offsetof(mng_ihdr, iInterlace), MNG_NULL, MNG_NULL}
101 };
102
103/* ************************************************************************** */
104
105MNG_LOCAL mng_field_descriptor mng_fields_plte [] =
106 {
107 {mng_debunk_plte,
108 MNG_NULL,
109 0, 0, 0, 0,
110 MNG_NULL, MNG_NULL, MNG_NULL}
111 };
112
113/* ************************************************************************** */
114
115MNG_LOCAL mng_field_descriptor mng_fields_idat [] =
116 {
117 {MNG_NULL,
118 MNG_NULL,
119 0, 0, 0, 0,
120 offsetof(mng_idat, pData), MNG_NULL, offsetof(mng_idat, iDatasize)}
121 };
122
123/* ************************************************************************** */
124
125MNG_LOCAL mng_field_descriptor mng_fields_trns [] =
126 {
127 {mng_debunk_trns,
128 MNG_NULL,
129 0, 0, 0, 0,
130 MNG_NULL, MNG_NULL, MNG_NULL}
131 };
132
133/* ************************************************************************** */
134
135#ifndef MNG_SKIPCHUNK_gAMA
136MNG_LOCAL mng_field_descriptor mng_fields_gama [] =
137 {
138 {MNG_NULL,
139 MNG_FIELD_INT,
140 0, 0, 4, 4,
141 offsetof(mng_gama, iGamma), MNG_NULL, MNG_NULL}
142 };
143#endif
144
145/* ************************************************************************** */
146
147#ifndef MNG_SKIPCHUNK_cHRM
148MNG_LOCAL mng_field_descriptor mng_fields_chrm [] =
149 {
150 {MNG_NULL,
151 MNG_FIELD_INT,
152 0, 0, 4, 4,
153 offsetof(mng_chrm, iWhitepointx), MNG_NULL, MNG_NULL},
154 {MNG_NULL,
155 MNG_FIELD_INT,
156 0, 0, 4, 4,
157 offsetof(mng_chrm, iWhitepointy), MNG_NULL, MNG_NULL},
158 {MNG_NULL,
159 MNG_FIELD_INT,
160 0, 0, 4, 4,
161 offsetof(mng_chrm, iRedx), MNG_NULL, MNG_NULL},
162 {MNG_NULL,
163 MNG_FIELD_INT,
164 0, 0, 4, 4,
165 offsetof(mng_chrm, iRedy), MNG_NULL, MNG_NULL},
166 {MNG_NULL,
167 MNG_FIELD_INT,
168 0, 0, 4, 4,
169 offsetof(mng_chrm, iGreeny), MNG_NULL, MNG_NULL},
170 {MNG_NULL,
171 MNG_FIELD_INT,
172 0, 0, 4, 4,
173 offsetof(mng_chrm, iGreeny), MNG_NULL, MNG_NULL},
174 {MNG_NULL,
175 MNG_FIELD_INT,
176 0, 0, 4, 4,
177 offsetof(mng_chrm, iBluex), MNG_NULL, MNG_NULL},
178 {MNG_NULL,
179 MNG_FIELD_INT,
180 0, 0, 4, 4,
181 offsetof(mng_chrm, iBluey), MNG_NULL, MNG_NULL}
182 };
183#endif
184
185/* ************************************************************************** */
186
187#ifndef MNG_SKIPCHUNK_sRGB
188MNG_LOCAL mng_field_descriptor mng_fields_srgb [] =
189 {
190 {MNG_NULL,
191 MNG_FIELD_INT,
192 0, 4, 1, 1,
193 offsetof(mng_srgb, iRenderingintent), MNG_NULL, MNG_NULL}
194 };
195#endif
196
197/* ************************************************************************** */
198
199#ifndef MNG_SKIPCHUNK_iCCP
200MNG_LOCAL mng_field_descriptor mng_fields_iccp [] =
201 {
202 {MNG_NULL,
203 MNG_FIELD_TERMINATOR,
204 0, 0, 1, 79,
205 offsetof(mng_iccp, zName), MNG_NULL, offsetof(mng_iccp, iNamesize)},
206 {MNG_NULL,
207 MNG_FIELD_INT,
208 0, 0, 1, 1,
209 offsetof(mng_iccp, iCompression), MNG_NULL, MNG_NULL},
210 {MNG_NULL,
211 MNG_FIELD_DEFLATED,
212 0, 0, 0, 0,
213 offsetof(mng_iccp, pProfile), MNG_NULL, offsetof(mng_iccp, iProfilesize)}
214 };
215#endif
216
217/* ************************************************************************** */
218
219#ifndef MNG_SKIPCHUNK_tEXt
220MNG_LOCAL mng_field_descriptor mng_fields_text [] =
221 {
222 {MNG_NULL,
223 MNG_FIELD_TERMINATOR,
224 0, 0, 1, 79,
225 offsetof(mng_text, zKeyword), MNG_NULL, offsetof(mng_text, iKeywordsize)},
226 {MNG_NULL,
227 MNG_NULL,
228 0, 0, 0, 0,
229 offsetof(mng_text, zText), MNG_NULL, offsetof(mng_text, iTextsize)}
230 };
231#endif
232
233/* ************************************************************************** */
234
235#ifndef MNG_SKIPCHUNK_zTXt
236MNG_LOCAL mng_field_descriptor mng_fields_ztxt [] =
237 {
238 {MNG_NULL,
239 MNG_FIELD_TERMINATOR,
240 0, 0, 1, 79,
241 offsetof(mng_ztxt, zKeyword), MNG_NULL, offsetof(mng_ztxt, iKeywordsize)},
242 {MNG_NULL,
243 MNG_FIELD_INT,
244 0, 0, 1, 1,
245 offsetof(mng_ztxt, iCompression), MNG_NULL, MNG_NULL},
246 {MNG_NULL,
247 MNG_FIELD_DEFLATED,
248 0, 0, 0, 0,
249 offsetof(mng_ztxt, zText), MNG_NULL, offsetof(mng_ztxt, iTextsize)}
250 };
251#endif
252
253/* ************************************************************************** */
254
255#ifndef MNG_SKIPCHUNK_iTXt
256MNG_LOCAL mng_field_descriptor mng_fields_itxt [] =
257 {
258 {MNG_NULL,
259 MNG_FIELD_TERMINATOR,
260 0, 0, 1, 79,
261 offsetof(mng_itxt, zKeyword), MNG_NULL, offsetof(mng_itxt, iKeywordsize)},
262 {MNG_NULL,
263 MNG_FIELD_INT,
264 0, 1, 1, 1,
265 offsetof(mng_itxt, iCompressionflag), MNG_NULL, MNG_NULL},
266 {MNG_NULL,
267 MNG_FIELD_INT,
268 0, 0, 1, 1,
269 offsetof(mng_itxt, iCompressionmethod), MNG_NULL, MNG_NULL},
270 {MNG_NULL,
271 MNG_FIELD_TERMINATOR,
272 0, 0, 0, 0,
273 offsetof(mng_itxt, zLanguage), MNG_NULL, offsetof(mng_itxt, iLanguagesize)},
274 {MNG_NULL,
275 MNG_FIELD_TERMINATOR,
276 0, 0, 0, 0,
277 offsetof(mng_itxt, zTranslation), MNG_NULL, offsetof(mng_itxt, iTranslationsize)},
278 {mng_deflate_itxt,
279 MNG_NULL,
280 0, 0, 0, 0,
281 MNG_NULL, MNG_NULL, MNG_NULL}
282 };
283#endif
284
285/* ************************************************************************** */
286
287#ifndef MNG_SKIPCHUNK_bKGD
288MNG_LOCAL mng_field_descriptor mng_fields_bkgd [] =
289 {
290 {MNG_NULL,
291 MNG_FIELD_INT | MNG_FIELD_PUTIMGTYPE,
292 0, 0, 0, 0,
293 offsetof(mng_bkgd, iType), MNG_NULL, MNG_NULL},
294 {MNG_NULL,
295 MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE3,
296 0, 0xFF, 1, 1,
297 offsetof(mng_bkgd, iIndex), MNG_NULL, MNG_NULL},
298 {MNG_NULL,
299 MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE0 | MNG_FIELD_IFIMGTYPE4,
300 0, 0xFFFF, 2, 2,
301 offsetof(mng_bkgd, iGray), MNG_NULL, MNG_NULL},
302 {MNG_NULL,
303 MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE6,
304 0, 0xFFFF, 2, 2,
305 offsetof(mng_bkgd, iRed), MNG_NULL, MNG_NULL},
306 {MNG_NULL,
307 MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE6,
308 0, 0xFFFF, 2, 2,
309 offsetof(mng_bkgd, iGreen), MNG_NULL, MNG_NULL},
310 {MNG_NULL,
311 MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE6,
312 0, 0xFFFF, 2, 2,
313 offsetof(mng_bkgd, iBlue), MNG_NULL, MNG_NULL}
314 };
315#endif
316
317/* ************************************************************************** */
318
319#ifndef MNG_SKIPCHUNK_pHYs
320MNG_LOCAL mng_field_descriptor mng_fields_phys [] =
321 {
322 {MNG_NULL,
323 MNG_FIELD_INT,
324 0, 0, 4, 4,
325 offsetof(mng_phys, iSizex), MNG_NULL, MNG_NULL},
326 {MNG_NULL,
327 MNG_FIELD_INT,
328 0, 0, 4, 4,
329 offsetof(mng_phys, iSizey), MNG_NULL, MNG_NULL},
330 {MNG_NULL,
331 MNG_FIELD_INT,
332 0, 1, 1, 1,
333 offsetof(mng_phys, iUnit), MNG_NULL, MNG_NULL}
334 };
335#endif
336
337/* ************************************************************************** */
338
339#ifndef MNG_SKIPCHUNK_sBIT
340MNG_LOCAL mng_field_descriptor mng_fields_sbit [] =
341 {
342 {MNG_NULL,
343 MNG_FIELD_INT | MNG_FIELD_PUTIMGTYPE,
344 0, 0, 0, 0,
345 offsetof(mng_sbit, iType), MNG_NULL, MNG_NULL},
346 {MNG_NULL,
347 MNG_FIELD_INT | MNG_FIELD_IFIMGTYPES,
348 0, 0xFF, 1, 1,
349 offsetof(mng_sbit, aBits[0]), MNG_NULL, MNG_NULL},
350 {MNG_NULL,
351 MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE3 | MNG_FIELD_IFIMGTYPE4 | MNG_FIELD_IFIMGTYPE6,
352 0, 0xFF, 1, 1,
353 offsetof(mng_sbit, aBits[1]), MNG_NULL, MNG_NULL},
354 {MNG_NULL,
355 MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE2 | MNG_FIELD_IFIMGTYPE3 | MNG_FIELD_IFIMGTYPE6,
356 0, 0xFF, 1, 1,
357 offsetof(mng_sbit, aBits[2]), MNG_NULL, MNG_NULL},
358 {MNG_NULL,
359 MNG_FIELD_INT | MNG_FIELD_IFIMGTYPE6,
360 0, 0xFF, 1, 1,
361 offsetof(mng_sbit, aBits[3]), MNG_NULL, MNG_NULL}
362 };
363#endif
364
365/* ************************************************************************** */
366
367#ifndef MNG_SKIPCHUNK_sPLT
368MNG_LOCAL mng_field_descriptor mng_fields_splt [] =
369 {
370 {MNG_NULL,
371 MNG_NULL,
372 0, 0, 1, 79,
373 offsetof(mng_splt, zName), MNG_NULL, offsetof(mng_splt, iNamesize)},
374 {MNG_NULL,
375 MNG_FIELD_INT,
376 8, 16, 1, 1,
377 offsetof(mng_splt, iSampledepth), MNG_NULL, MNG_NULL},
378 {mng_splt_entries,
379 MNG_NULL,
380 0, 0, 0, 0,
381 MNG_NULL, MNG_NULL, MNG_NULL}
382 };
383#endif
384
385/* ************************************************************************** */
386
387#ifndef MNG_SKIPCHUNK_hIST
388MNG_LOCAL mng_field_descriptor mng_fields_hist [] =
389 {
390 {mng_hist_entries,
391 MNG_NULL,
392 0, 0, 0, 0,
393 MNG_NULL, MNG_NULL, MNG_NULL}
394 };
395#endif
396
397/* ************************************************************************** */
398
399#ifndef MNG_SKIPCHUNK_tIME
400MNG_LOCAL mng_field_descriptor mng_fields_time [] =
401 {
402 {MNG_NULL,
403 MNG_FIELD_INT,
404 0, 0xFFFF, 2, 2,
405 offsetof(mng_time, iYear), MNG_NULL, MNG_NULL},
406 {MNG_NULL,
407 MNG_FIELD_INT,
408 1, 12, 1, 1,
409 offsetof(mng_time, iMonth), MNG_NULL, MNG_NULL},
410 {MNG_NULL,
411 MNG_FIELD_INT,
412 1, 31, 1, 1,
413 offsetof(mng_time, iDay), MNG_NULL, MNG_NULL},
414 {MNG_NULL,
415 MNG_FIELD_INT,
416 0, 24, 1, 1,
417 offsetof(mng_time, iHour), MNG_NULL, MNG_NULL},
418 {MNG_NULL,
419 MNG_FIELD_INT,
420 0, 60, 1, 1,
421 offsetof(mng_time, iMinute), MNG_NULL, MNG_NULL},
422 {MNG_NULL,
423 MNG_FIELD_INT,
424 0, 60, 1, 1,
425 offsetof(mng_time, iSecond), MNG_NULL, MNG_NULL}
426 };
427#endif
428
429/* ************************************************************************** */
430/* ************************************************************************** */
431/* JNG chunks */
432
433#ifdef MNG_INCLUDE_JNG
434MNG_LOCAL mng_field_descriptor mng_fields_jhdr [] =
435 {
436 {MNG_NULL,
437 MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT,
438 1, 0, 4, 4,
439 offsetof(mng_jhdr, iWidth), MNG_NULL, MNG_NULL},
440 {MNG_NULL,
441 MNG_FIELD_INT | MNG_FIELD_NOHIGHBIT,
442 1, 0, 4, 4,
443 offsetof(mng_jhdr, iHeight), MNG_NULL, MNG_NULL},
444 {MNG_NULL,
445 MNG_FIELD_INT,
446 8, 16, 1, 1,
447 offsetof(mng_jhdr, iColortype), MNG_NULL, MNG_NULL},
448 {MNG_NULL,
449 MNG_FIELD_INT,
450 8, 20, 1, 1,
451 offsetof(mng_jhdr, iImagesampledepth), MNG_NULL, MNG_NULL},
452 {MNG_NULL,
453 MNG_FIELD_INT,
454 8, 8, 1, 1,
455 offsetof(mng_jhdr, iImagecompression), MNG_NULL, MNG_NULL},
456 {MNG_NULL,
457 MNG_FIELD_INT,
458 0, 8, 1, 1,
459 offsetof(mng_jhdr, iImageinterlace), MNG_NULL, MNG_NULL},
460 {MNG_NULL,
461 MNG_FIELD_INT,
462 0, 16, 1, 1,
463 offsetof(mng_jhdr, iAlphasampledepth), MNG_NULL, MNG_NULL},
464 {MNG_NULL,
465 MNG_FIELD_INT,
466 0, 8, 1, 1,
467 offsetof(mng_jhdr, iAlphacompression), MNG_NULL, MNG_NULL},
468 {MNG_NULL,
469 MNG_FIELD_INT,
470 0, 0, 1, 1,
471 offsetof(mng_jhdr, iAlphafilter), MNG_NULL, MNG_NULL},
472 {MNG_NULL,
473 MNG_FIELD_INT,
474 0, 1, 1, 1,
475 offsetof(mng_jhdr, iAlphainterlace), MNG_NULL, MNG_NULL}
476 };
477#endif
478
479/* ************************************************************************** */
480
481#ifdef MNG_INCLUDE_JNG
482#define mng_fields_jdaa mng_fields_idat
483#define mng_fields_jdat mng_fields_idat
484#endif
485
486/* ************************************************************************** */
487/* ************************************************************************** */
488/* MNG chunks */
489
490MNG_LOCAL mng_field_descriptor mng_fields_mhdr [] =
491 {
492 {MNG_NULL,
493 MNG_FIELD_INT,
494 0, 0, 4, 4,
495 offsetof(mng_mhdr, iWidth), MNG_NULL, MNG_NULL},
496 {MNG_NULL,
497 MNG_FIELD_INT,
498 0, 0, 4, 4,
499 offsetof(mng_mhdr, iHeight), MNG_NULL, MNG_NULL},
500 {MNG_NULL,
501 MNG_FIELD_INT,
502 0, 0, 4, 4,
503 offsetof(mng_mhdr, iTicks), MNG_NULL, MNG_NULL},
504 {MNG_NULL,
505 MNG_FIELD_INT,
506 0, 0, 4, 4,
507 offsetof(mng_mhdr, iLayercount), MNG_NULL, MNG_NULL},
508 {MNG_NULL,
509 MNG_FIELD_INT,
510 0, 0, 4, 4,
511 offsetof(mng_mhdr, iFramecount), MNG_NULL, MNG_NULL},
512 {MNG_NULL,
513 MNG_FIELD_INT,
514 0, 0, 4, 4,
515 offsetof(mng_mhdr, iPlaytime), MNG_NULL, MNG_NULL},
516 {MNG_NULL,
517 MNG_FIELD_INT,
518 0, 0, 4, 4,
519 offsetof(mng_mhdr, iSimplicity), MNG_NULL, MNG_NULL}
520 };
521
522/* ************************************************************************** */
523
524#ifndef MNG_SKIPCHUNK_LOOP
525MNG_LOCAL mng_field_descriptor mng_fields_loop [] =
526 {
527 {mng_debunk_loop,
528 MNG_NULL,
529 0, 0, 0, 0,
530 MNG_NULL, MNG_NULL, MNG_NULL}
531 };
532#endif
533
534/* ************************************************************************** */
535
536#ifndef MNG_SKIPCHUNK_LOOP
537MNG_LOCAL mng_field_descriptor mng_fields_endl [] =
538 {
539 {MNG_NULL,
540 MNG_FIELD_INT,
541 0, 0xFF, 1, 1,
542 offsetof(mng_endl, iLevel), MNG_NULL, MNG_NULL}
543 };
544#endif
545
546/* ************************************************************************** */
547
548#ifndef MNG_SKIPCHUNK_DEFI
549MNG_LOCAL mng_field_descriptor mng_fields_defi [] =
550 {
551 {MNG_NULL,
552 MNG_FIELD_INT,
553 0, 0xFFFF, 2, 2,
554 offsetof(mng_defi, iObjectid), MNG_NULL, MNG_NULL},
555 {MNG_NULL,
556 MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
557 0, 0xFF, 1, 1,
558 offsetof(mng_defi, iDonotshow), offsetof(mng_defi, bHasdonotshow), MNG_NULL},
559 {MNG_NULL,
560 MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
561 0, 0xFF, 1, 1,
562 offsetof(mng_defi, iConcrete), offsetof(mng_defi, bHasconcrete), MNG_NULL},
563 {MNG_NULL,
564 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
565 0, 0, 4, 4,
566 offsetof(mng_defi, iXlocation), offsetof(mng_defi, bHasloca), MNG_NULL},
567 {MNG_NULL,
568 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
569 0, 0, 4, 4,
570 offsetof(mng_defi, iYlocation), MNG_NULL, MNG_NULL},
571 {MNG_NULL,
572 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2,
573 0, 0, 4, 4,
574 offsetof(mng_defi, iLeftcb), offsetof(mng_defi, bHasclip), MNG_NULL},
575 {MNG_NULL,
576 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2,
577 0, 0, 4, 4,
578 offsetof(mng_defi, iRightcb), MNG_NULL, MNG_NULL},
579 {MNG_NULL,
580 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2,
581 0, 0, 4, 4,
582 offsetof(mng_defi, iTopcb), MNG_NULL, MNG_NULL},
583 {MNG_NULL,
584 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2,
585 0, 0, 4, 4,
586 offsetof(mng_defi, iBottomcb), MNG_NULL, MNG_NULL}
587 };
588#endif
589
590/* ************************************************************************** */
591
592#ifndef MNG_SKIPCHUNK_BASI
593MNG_LOCAL mng_field_descriptor mng_fields_basi [] =
594 {
595 {MNG_NULL,
596 MNG_FIELD_INT,
597 0, 0, 4, 4,
598 offsetof(mng_basi, iWidth), MNG_NULL, MNG_NULL},
599 {MNG_NULL,
600 MNG_FIELD_INT,
601 0, 0, 4, 4,
602 offsetof(mng_basi, iHeight), MNG_NULL, MNG_NULL},
603 {MNG_NULL,
604 MNG_FIELD_INT,
605 1, 16, 1, 1,
606 offsetof(mng_basi, iBitdepth), MNG_NULL, MNG_NULL},
607 {MNG_NULL,
608 MNG_FIELD_INT,
609 0, 6, 1, 1,
610 offsetof(mng_basi, iColortype), MNG_NULL, MNG_NULL},
611 {MNG_NULL,
612 MNG_FIELD_INT,
613 0, 0, 1, 1,
614 offsetof(mng_basi, iCompression), MNG_NULL, MNG_NULL},
615 {MNG_NULL,
616 MNG_FIELD_INT,
617 0, 0, 1, 1,
618 offsetof(mng_basi, iFilter), MNG_NULL, MNG_NULL},
619 {MNG_NULL,
620 MNG_FIELD_INT,
621 0, 1, 1, 1,
622 offsetof(mng_basi, iInterlace), MNG_NULL, MNG_NULL},
623 {MNG_NULL,
624 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
625 0, 0xFFFF, 2, 2,
626 offsetof(mng_basi, iRed), MNG_NULL, MNG_NULL},
627 {MNG_NULL,
628 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
629 0, 0xFFFF, 2, 2,
630 offsetof(mng_basi, iGreen), MNG_NULL, MNG_NULL},
631 {MNG_NULL,
632 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
633 0, 0xFFFF, 2, 2,
634 offsetof(mng_basi, iBlue), MNG_NULL, MNG_NULL},
635 {MNG_NULL,
636 MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
637 0, 0xFFFF, 2, 2,
638 offsetof(mng_basi, iAlpha), offsetof(mng_basi, bHasalpha), MNG_NULL},
639 {MNG_NULL,
640 MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
641 0, 1, 1, 1,
642 offsetof(mng_basi, iViewable), MNG_NULL, MNG_NULL}
643 };
644#endif
645
646/* ************************************************************************** */
647
648#ifndef MNG_SKIPCHUNK_CLON
649MNG_LOCAL mng_field_descriptor mng_fields_clon [] =
650 {
651 {MNG_NULL,
652 MNG_FIELD_INT,
653 0, 0xFFFF, 2, 2,
654 offsetof(mng_clon, iSourceid), MNG_NULL, MNG_NULL},
655 {MNG_NULL,
656 MNG_FIELD_INT,
657 0, 0xFFFF, 2, 2,
658 offsetof(mng_clon, iCloneid), MNG_NULL, MNG_NULL},
659 {MNG_NULL,
660 MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
661 0, 2, 1, 1,
662 offsetof(mng_clon, iClonetype), MNG_NULL, MNG_NULL},
663 {MNG_NULL,
664 MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
665 0, 1, 1, 1,
666 offsetof(mng_clon, iDonotshow), offsetof(mng_clon, bHasdonotshow), MNG_NULL},
667 {MNG_NULL,
668 MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
669 0, 1, 1, 1,
670 offsetof(mng_clon, iConcrete), MNG_NULL, MNG_NULL},
671 {MNG_NULL,
672 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
673 0, 2, 1, 1,
674 offsetof(mng_clon, iLocationtype), offsetof(mng_clon, bHasloca), MNG_NULL},
675 {MNG_NULL,
676 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
677 0, 0, 4, 4,
678 offsetof(mng_clon, iLocationx), MNG_NULL, MNG_NULL},
679 {MNG_NULL,
680 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
681 0, 0, 4, 4,
682 offsetof(mng_clon, iLocationy), MNG_NULL, MNG_NULL}
683 };
684#endif
685
686/* ************************************************************************** */
687
688#ifndef MNG_SKIPCHUNK_PAST
689MNG_LOCAL mng_field_descriptor mng_fields_past [] =
690 {
691 {mng_debunk_past,
692 MNG_NULL,
693 0, 0, 0, 0,
694 MNG_NULL, MNG_NULL, MNG_NULL}
695 };
696#endif
697
698/* ************************************************************************** */
699
700#ifndef MNG_SKIPCHUNK_DISC
701MNG_LOCAL mng_field_descriptor mng_fields_disc [] =
702 {
703 {mng_disc_entries,
704 MNG_NULL,
705 0, 0, 0, 0,
706 MNG_NULL, MNG_NULL, MNG_NULL}
707 };
708#endif
709
710/* ************************************************************************** */
711
712#ifndef MNG_SKIPCHUNK_BACK
713MNG_LOCAL mng_field_descriptor mng_fields_back [] =
714 {
715 {MNG_NULL,
716 MNG_FIELD_INT,
717 0, 0xFFFF, 2, 2,
718 offsetof(mng_back, iRed), MNG_NULL, MNG_NULL},
719 {MNG_NULL,
720 MNG_FIELD_INT,
721 0, 0xFFFF, 2, 2,
722 offsetof(mng_back, iGreen), MNG_NULL, MNG_NULL},
723 {MNG_NULL,
724 MNG_FIELD_INT,
725 0, 0xFFFF, 2, 2,
726 offsetof(mng_back, iBlue), MNG_NULL, MNG_NULL},
727 {MNG_NULL,
728 MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
729 0, 3, 1, 1,
730 offsetof(mng_back, iMandatory), MNG_NULL, MNG_NULL},
731 {MNG_NULL,
732 MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
733 0, 0xFFFF, 2, 2,
734 offsetof(mng_back, iImageid), MNG_NULL, MNG_NULL},
735 {MNG_NULL,
736 MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
737 0, 1, 1, 1,
738 offsetof(mng_back, iTile), MNG_NULL, MNG_NULL}
739 };
740#endif
741
742/* ************************************************************************** */
743
744#ifndef MNG_SKIPCHUNK_FRAM
745MNG_LOCAL mng_field_descriptor mng_fields_fram [] =
746 {
747 {MNG_NULL,
748 MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
749 0, 4, 1, 1,
750 offsetof(mng_fram, iMode), MNG_NULL, MNG_NULL},
751 {MNG_NULL,
752 MNG_FIELD_TERMINATOR | MNG_FIELD_OPTIONAL,
753 0, 0, 1, 79,
754 offsetof(mng_fram, zName), MNG_NULL, offsetof(mng_fram, iNamesize)},
755 {mng_fram_remainder,
756 MNG_FIELD_OPTIONAL,
757 0, 0, 0, 0,
758 MNG_NULL, MNG_NULL, MNG_NULL}
759 };
760#endif
761
762/* ************************************************************************** */
763
764#ifndef MNG_SKIPCHUNK_MOVE
765MNG_LOCAL mng_field_descriptor mng_fields_move [] =
766 {
767 {MNG_NULL,
768 MNG_FIELD_INT,
769 0, 0xFFFF, 2, 2,
770 offsetof(mng_move, iFirstid), MNG_NULL, MNG_NULL},
771 {MNG_NULL,
772 MNG_FIELD_INT,
773 0, 0xFFFF, 2, 2,
774 offsetof(mng_move, iLastid), MNG_NULL, MNG_NULL},
775 {MNG_NULL,
776 MNG_FIELD_INT,
777 0, 1, 1, 1,
778 offsetof(mng_move, iMovetype), MNG_NULL, MNG_NULL},
779 {MNG_NULL,
780 MNG_FIELD_INT,
781 0, 0, 4, 4,
782 offsetof(mng_move, iMovex), MNG_NULL, MNG_NULL},
783 {MNG_NULL,
784 MNG_FIELD_INT,
785 0, 0, 4, 4,
786 offsetof(mng_move, iMovey), MNG_NULL, MNG_NULL}
787 };
788#endif
789
790/* ************************************************************************** */
791
792#ifndef MNG_SKIPCHUNK_CLIP
793MNG_LOCAL mng_field_descriptor mng_fields_clip [] =
794 {
795 {MNG_NULL,
796 MNG_FIELD_INT,
797 0, 0xFFFF, 2, 2,
798 offsetof(mng_clip, iFirstid), MNG_NULL, MNG_NULL},
799 {MNG_NULL,
800 MNG_FIELD_INT,
801 0, 0xFFFF, 2, 2,
802 offsetof(mng_clip, iLastid), MNG_NULL, MNG_NULL},
803 {MNG_NULL,
804 MNG_FIELD_INT,
805 0, 1, 1, 1,
806 offsetof(mng_clip, iCliptype), MNG_NULL, MNG_NULL},
807 {MNG_NULL,
808 MNG_FIELD_INT,
809 0, 0, 4, 4,
810 offsetof(mng_clip, iClipl), MNG_NULL, MNG_NULL},
811 {MNG_NULL,
812 MNG_FIELD_INT,
813 0, 0, 4, 4,
814 offsetof(mng_clip, iClipr), MNG_NULL, MNG_NULL},
815 {MNG_NULL,
816 MNG_FIELD_INT,
817 0, 0, 4, 4,
818 offsetof(mng_clip, iClipt), MNG_NULL, MNG_NULL},
819 {MNG_NULL,
820 MNG_FIELD_INT,
821 0, 0, 4, 4,
822 offsetof(mng_clip, iClipb), MNG_NULL, MNG_NULL}
823 };
824#endif
825
826/* ************************************************************************** */
827
828#ifndef MNG_SKIPCHUNK_SHOW
829MNG_LOCAL mng_field_descriptor mng_fields_show [] =
830 {
831 {MNG_NULL,
832 MNG_FIELD_INT,
833 1, 0xFFFF, 2, 2,
834 offsetof(mng_show, iFirstid), MNG_NULL, MNG_NULL},
835 {MNG_NULL,
836 MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
837 1, 0xFFFF, 2, 2,
838 offsetof(mng_show, iLastid), offsetof(mng_show, bHaslastid), MNG_NULL},
839 {MNG_NULL,
840 MNG_FIELD_INT | MNG_FIELD_OPTIONAL,
841 0, 7, 1, 1,
842 offsetof(mng_show, iMode), MNG_NULL, MNG_NULL}
843 };
844#endif
845
846/* ************************************************************************** */
847
848#ifndef MNG_SKIPCHUNK_TERM
849MNG_LOCAL mng_field_descriptor mng_fields_term [] =
850 {
851 {MNG_NULL,
852 MNG_FIELD_INT,
853 0, 3, 1, 1,
854 offsetof(mng_term, iTermaction), MNG_NULL, MNG_NULL},
855 {MNG_NULL,
856 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
857 0, 2, 1, 1,
858 offsetof(mng_term, iIteraction), MNG_NULL, MNG_NULL},
859 {MNG_NULL,
860 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
861 0, 0, 4, 4,
862 offsetof(mng_term, iDelay), MNG_NULL, MNG_NULL},
863 {MNG_NULL,
864 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
865 0, 0, 4, 4,
866 offsetof(mng_term, iItermax), MNG_NULL, MNG_NULL}
867 };
868#endif
869
870/* ************************************************************************** */
871
872#ifndef MNG_SKIPCHUNK_SAVE
873MNG_LOCAL mng_field_descriptor mng_fields_save [] =
874 {
875 {mng_save_entries,
876 MNG_NULL,
877 0, 0, 0, 0,
878 MNG_NULL, MNG_NULL, MNG_NULL}
879 };
880#endif
881
882/* ************************************************************************** */
883
884#ifndef MNG_SKIPCHUNK_SEEK
885MNG_LOCAL mng_field_descriptor mng_fields_seek [] =
886 {
887 {MNG_NULL,
888 MNG_NULL,
889 0, 0, 1, 79,
890 offsetof(mng_seek, zName), MNG_NULL, offsetof(mng_seek, iNamesize)}
891 };
892#endif
893
894/* ************************************************************************** */
895
896#ifndef MNG_SKIPCHUNK_eXPI
897MNG_LOCAL mng_field_descriptor mng_fields_expi [] =
898 {
899 {MNG_NULL,
900 MNG_FIELD_INT,
901 0, 0xFFFF, 2, 2,
902 offsetof(mng_expi, iSnapshotid), MNG_NULL, MNG_NULL},
903 {MNG_NULL,
904 MNG_NULL,
905 0, 0, 1, 79,
906 offsetof(mng_expi, zName), MNG_NULL, offsetof(mng_expi, iNamesize)}
907 };
908#endif
909
910/* ************************************************************************** */
911
912#ifndef MNG_SKIPCHUNK_fPRI
913MNG_LOCAL mng_field_descriptor mng_fields_fpri [] =
914 {
915 {MNG_NULL,
916 MNG_FIELD_INT,
917 0, 1, 1, 1,
918 offsetof(mng_fpri, iDeltatype), MNG_NULL, MNG_NULL},
919 {MNG_NULL,
920 MNG_FIELD_INT,
921 0, 0xFF, 1, 1,
922 offsetof(mng_fpri, iPriority), MNG_NULL, MNG_NULL}
923 };
924#endif
925
926/* ************************************************************************** */
927
928#ifndef MNG_SKIPCHUNK_nEED
929MNG_LOCAL mng_field_descriptor mng_fields_need [] =
930 {
931 {MNG_NULL,
932 MNG_NULL,
933 0, 0, 1, 0,
934 offsetof(mng_need, zKeywords), MNG_NULL, offsetof(mng_need, iKeywordssize)}
935 };
936#endif
937
938/* ************************************************************************** */
939
940#ifndef MNG_SKIPCHUNK_pHYg
941#define mng_fields_phyg mng_fields_phys
942#endif
943
944/* ************************************************************************** */
945
946#ifndef MNG_NO_DELTA_PNG
947MNG_LOCAL mng_field_descriptor mng_fields_dhdr [] =
948 {
949 {MNG_NULL,
950 MNG_FIELD_INT,
951 0, 0xFFFF, 2, 2,
952 offsetof(mng_dhdr, iObjectid), MNG_NULL, MNG_NULL},
953 {MNG_NULL,
954 MNG_FIELD_INT,
955 0, 2, 1, 1,
956 offsetof(mng_dhdr, iImagetype), MNG_NULL, MNG_NULL},
957 {MNG_NULL,
958 MNG_FIELD_INT,
959 0, 7, 1, 1,
960 offsetof(mng_dhdr, iDeltatype), MNG_NULL, MNG_NULL},
961 {MNG_NULL,
962 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
963 0, 0, 4, 4,
964 offsetof(mng_dhdr, iBlockwidth), offsetof(mng_dhdr, bHasblocksize), MNG_NULL},
965 {MNG_NULL,
966 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP1,
967 0, 0, 4, 4,
968 offsetof(mng_dhdr, iBlockheight), MNG_NULL, MNG_NULL},
969 {MNG_NULL,
970 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2,
971 0, 0, 4, 4,
972 offsetof(mng_dhdr, iBlockx), offsetof(mng_dhdr, bHasblockloc), MNG_NULL},
973 {MNG_NULL,
974 MNG_FIELD_INT | MNG_FIELD_OPTIONAL | MNG_FIELD_GROUP2,
975 0, 0, 4, 4,
976 offsetof(mng_dhdr, iBlocky), MNG_NULL, MNG_NULL}
977 };
978#endif
979
980/* ************************************************************************** */
981
982#ifndef MNG_NO_DELTA_PNG
983MNG_LOCAL mng_field_descriptor mng_fields_prom [] =
984 {
985 {MNG_NULL,
986 MNG_FIELD_INT,
987 0, 14, 1, 1,
988 offsetof(mng_prom, iColortype), MNG_NULL, MNG_NULL},
989 {MNG_NULL,
990 MNG_FIELD_INT,
991 0, 16, 1, 1,
992 offsetof(mng_prom, iSampledepth), MNG_NULL, MNG_NULL},
993 {MNG_NULL,
994 MNG_FIELD_INT,
995 0, 1, 1, 1,
996 offsetof(mng_prom, iFilltype), MNG_NULL, MNG_NULL}
997 };
998#endif
999
1000/* ************************************************************************** */
1001
1002#ifndef MNG_NO_DELTA_PNG
1003MNG_LOCAL mng_field_descriptor mng_fields_pplt [] =
1004 {
1005 {MNG_NULL,
1006 MNG_FIELD_INT,
1007 0, 5, 1, 1,
1008 offsetof(mng_pplt, iDeltatype), MNG_NULL, MNG_NULL},
1009 {mng_pplt_entries,
1010 MNG_NULL,
1011 0, 0, 0, 0,
1012 MNG_NULL, MNG_NULL, MNG_NULL}
1013 };
1014#endif
1015
1016/* ************************************************************************** */
1017
1018#ifndef MNG_NO_DELTA_PNG
1019MNG_LOCAL mng_field_descriptor mng_fields_drop [] =
1020 {
1021 {mng_drop_entries,
1022 MNG_NULL,
1023 0, 0, 0, 0,
1024 MNG_NULL, MNG_NULL, MNG_NULL}
1025 };
1026#endif
1027
1028/* ************************************************************************** */
1029
1030#ifndef MNG_NO_DELTA_PNG
1031#ifndef MNG_SKIPCHUNK_DBYK
1032MNG_LOCAL mng_field_descriptor mng_fields_dbyk [] =
1033 {
1034 {MNG_NULL,
1035 MNG_FIELD_INT,
1036 0, 0, 4, 4,
1037 offsetof(mng_dbyk, iChunkname), MNG_NULL, MNG_NULL},
1038 {MNG_NULL,
1039 MNG_FIELD_INT,
1040 0, 1, 1, 1,
1041 offsetof(mng_dbyk, iPolarity), MNG_NULL, MNG_NULL},
1042 {MNG_NULL,
1043 MNG_NULL,
1044 0, 0, 1, 0,
1045 offsetof(mng_dbyk, zKeywords), MNG_NULL, offsetof(mng_dbyk, iKeywordssize)}
1046 };
1047#endif
1048#endif
1049
1050/* ************************************************************************** */
1051
1052#ifndef MNG_NO_DELTA_PNG
1053#ifndef MNG_SKIPCHUNK_ORDR
1054MNG_LOCAL mng_field_descriptor mng_fields_ordr [] =
1055 {
1056 {mng_drop_entries,
1057 MNG_NULL,
1058 0, 0, 0, 0,
1059 MNG_NULL, MNG_NULL, MNG_NULL}
1060 };
1061#endif
1062#endif
1063
1064/* ************************************************************************** */
1065
1066#ifndef MNG_SKIPCHUNK_MAGN
1067MNG_LOCAL mng_field_descriptor mng_fields_magn [] =
1068 {
1069 {mng_debunk_magn,
1070 MNG_NULL,
1071 0, 0, 0, 0,
1072 MNG_NULL, MNG_NULL, MNG_NULL}
1073 };
1074#endif
1075
1076/* ************************************************************************** */
1077
1078#ifdef MNG_INCLUDE_MPNG_PROPOSAL
1079MNG_LOCAL mng_field_descriptor mng_fields_mpng [] =
1080 {
1081 {MNG_NULL,
1082 MNG_FIELD_INT,
1083 1, 0, 4, 4,
1084 offsetof(mng_mpng, iFramewidth), MNG_NULL, MNG_NULL},
1085 {MNG_NULL,
1086 MNG_FIELD_INT,
1087 1, 0, 4, 4,
1088 offsetof(mng_mpng, iFrameheight), MNG_NULL, MNG_NULL},
1089 {MNG_NULL,
1090 MNG_FIELD_INT,
1091 0, 0xFFFF, 2, 2,
1092 offsetof(mng_mpng, iNumplays), MNG_NULL, MNG_NULL},
1093 {MNG_NULL,
1094 MNG_FIELD_INT,
1095 1, 0xFFFF, 2, 2,
1096 offsetof(mng_mpng, iTickspersec), MNG_NULL, MNG_NULL},
1097 {MNG_NULL,
1098 MNG_FIELD_INT,
1099 0, 0, 1, 1,
1100 offsetof(mng_mpng, iCompressionmethod), MNG_NULL, MNG_NULL},
1101 {MNG_NULL,
1102 MNG_FIELD_DEFLATED,
1103 0, 0, 1, 0,
1104 offsetof(mng_mpng, pFrames), MNG_NULL, offsetof(mng_mpng, iFramessize)}
1105 };
1106#endif
1107
1108/* ************************************************************************** */
1109
1110#ifdef MNG_INCLUDE_ANG_PROPOSAL
1111MNG_LOCAL mng_field_descriptor mng_fields_ahdr [] =
1112 {
1113 {MNG_NULL,
1114 MNG_FIELD_INT,
1115 1, 0, 4, 4,
1116 offsetof(mng_ahdr, iNumframes), MNG_NULL, MNG_NULL},
1117 {MNG_NULL,
1118 MNG_FIELD_INT,
1119 0, 0, 4, 4,
1120 offsetof(mng_ahdr, iTickspersec), MNG_NULL, MNG_NULL},
1121 {MNG_NULL,
1122 MNG_FIELD_INT,
1123 0, 0, 4, 4,
1124 offsetof(mng_ahdr, iNumplays), MNG_NULL, MNG_NULL},
1125 {MNG_NULL,
1126 MNG_FIELD_INT,
1127 1, 0, 4, 4,
1128 offsetof(mng_ahdr, iTilewidth), MNG_NULL, MNG_NULL},
1129 {MNG_NULL,
1130 MNG_FIELD_INT,
1131 1, 0, 4, 4,
1132 offsetof(mng_ahdr, iTileheight), MNG_NULL, MNG_NULL},
1133 {MNG_NULL,
1134 MNG_FIELD_INT,
1135 0, 1, 1, 1,
1136 offsetof(mng_ahdr, iInterlace), MNG_NULL, MNG_NULL},
1137 {MNG_NULL,
1138 MNG_FIELD_INT,
1139 0, 1, 1, 1,
1140 offsetof(mng_ahdr, iStillused), MNG_NULL, MNG_NULL}
1141 };
1142
1143MNG_LOCAL mng_field_descriptor mng_fields_adat [] =
1144 {
1145 {mng_adat_tiles,
1146 MNG_NULL,
1147 0, 0, 0, 0,
1148 MNG_NULL, MNG_NULL, MNG_NULL}
1149 };
1150#endif
1151
1152/* ************************************************************************** */
1153
1154#ifndef MNG_SKIPCHUNK_evNT
1155MNG_LOCAL mng_field_descriptor mng_fields_evnt [] =
1156 {
1157 {mng_evnt_entries,
1158 MNG_NULL,
1159 0, 0, 0, 0,
1160 MNG_NULL, MNG_NULL, MNG_NULL}
1161 };
1162#endif
1163
1164/* ************************************************************************** */
1165
1166MNG_LOCAL mng_field_descriptor mng_fields_unknown [] =
1167 {
1168 {MNG_NULL,
1169 MNG_NULL,
1170 0, 0, 1, 0,
1171 offsetof(mng_unknown_chunk, pData), MNG_NULL, offsetof(mng_unknown_chunk, iDatasize)}
1172 };
1173
1174/* ************************************************************************** */
1175/* ************************************************************************** */
1176/* PNG chunks */
1177
1178MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ihdr =
1179 {mng_it_png, mng_create_none, 0, 0,
1180 MNG_NULL, MNG_NULL, mng_special_ihdr,
1181 mng_fields_ihdr, (sizeof(mng_fields_ihdr) / sizeof(mng_field_descriptor)),
1182 MNG_DESCR_GLOBAL,
1183 MNG_NULL,
1184 MNG_DESCR_NOIHDR | MNG_DESCR_NOJHDR | MNG_DESCR_NOBASI | MNG_DESCR_NOIDAT | MNG_DESCR_NOPLTE};
1185
1186MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_plte =
1187 {mng_it_png, mng_create_none, 0, offsetof(mng_plte, bEmpty),
1188 MNG_NULL, MNG_NULL, mng_special_plte,
1189 mng_fields_plte, (sizeof(mng_fields_plte) / sizeof(mng_field_descriptor)),
1190 MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED,
1191 MNG_DESCR_GenHDR,
1192 MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
1193
1194MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_idat =
1195 {mng_it_png, mng_create_none, 0, offsetof(mng_idat, bEmpty),
1196 MNG_NULL, MNG_NULL, mng_special_idat,
1197 mng_fields_idat, (sizeof(mng_fields_idat) / sizeof(mng_field_descriptor)),
1198 MNG_DESCR_EMPTYEMBED,
1199 MNG_DESCR_GenHDR,
1200 MNG_DESCR_NOJSEP};
1201
1202MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_iend =
1203 {mng_it_png, mng_create_none, 0, 0,
1204 MNG_NULL, MNG_NULL, mng_special_iend,
1205 MNG_NULL, 0,
1206 MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED,
1207 MNG_DESCR_GenHDR,
1208 MNG_NULL};
1209
1210MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_trns =
1211 {mng_it_png, mng_create_none, 0, offsetof(mng_trns, bEmpty),
1212 MNG_NULL, MNG_NULL, mng_special_trns,
1213 mng_fields_trns, (sizeof(mng_fields_trns) / sizeof(mng_field_descriptor)),
1214 MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED,
1215 MNG_DESCR_GenHDR,
1216 MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
1217
1218#ifndef MNG_SKIPCHUNK_gAMA
1219MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_gama =
1220 {mng_it_png, mng_create_none, 0, offsetof(mng_gama, bEmpty),
1221 MNG_NULL, MNG_NULL, mng_special_gama,
1222 mng_fields_gama, (sizeof(mng_fields_gama) / sizeof(mng_field_descriptor)),
1223 MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
1224 MNG_DESCR_GenHDR,
1225 MNG_DESCR_NOPLTE | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
1226#endif
1227
1228#ifndef MNG_SKIPCHUNK_cHRM
1229MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_chrm =
1230 {mng_it_png, mng_create_none, 0, offsetof(mng_chrm, bEmpty),
1231 MNG_NULL, MNG_NULL, mng_special_chrm,
1232 mng_fields_chrm, (sizeof(mng_fields_chrm) / sizeof(mng_field_descriptor)),
1233 MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
1234 MNG_DESCR_GenHDR,
1235 MNG_DESCR_NOPLTE | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
1236#endif
1237
1238#ifndef MNG_SKIPCHUNK_sRGB
1239MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_srgb =
1240 {mng_it_png, mng_create_none, 0, offsetof(mng_srgb, bEmpty),
1241 MNG_NULL, MNG_NULL, mng_special_srgb,
1242 mng_fields_srgb, (sizeof(mng_fields_srgb) / sizeof(mng_field_descriptor)),
1243 MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
1244 MNG_DESCR_GenHDR,
1245 MNG_DESCR_NOPLTE | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
1246#endif
1247
1248#ifndef MNG_SKIPCHUNK_iCCP
1249MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_iccp =
1250 {mng_it_png, mng_create_none, 0, offsetof(mng_iccp, bEmpty),
1251 MNG_NULL, MNG_NULL, mng_special_iccp,
1252 mng_fields_iccp, (sizeof(mng_fields_iccp) / sizeof(mng_field_descriptor)),
1253 MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
1254 MNG_DESCR_GenHDR,
1255 MNG_DESCR_NOPLTE | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
1256#endif
1257
1258#ifndef MNG_SKIPCHUNK_tEXt
1259MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_text =
1260 {mng_it_png, mng_create_none, 0, 0,
1261 MNG_NULL, MNG_NULL, mng_special_text,
1262 mng_fields_text, (sizeof(mng_fields_text) / sizeof(mng_field_descriptor)),
1263 MNG_DESCR_GLOBAL,
1264 MNG_DESCR_GenHDR,
1265 MNG_NULL};
1266#endif
1267
1268#ifndef MNG_SKIPCHUNK_zTXt
1269MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ztxt =
1270 {mng_it_png, mng_create_none, 0, 0,
1271 MNG_NULL, MNG_NULL, mng_special_ztxt,
1272 mng_fields_ztxt, (sizeof(mng_fields_ztxt) / sizeof(mng_field_descriptor)),
1273 MNG_DESCR_GLOBAL,
1274 MNG_DESCR_GenHDR,
1275 MNG_NULL};
1276#endif
1277
1278#ifndef MNG_SKIPCHUNK_iTXt
1279MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_itxt =
1280 {mng_it_png, mng_create_none, 0, 0,
1281 MNG_NULL, MNG_NULL, mng_special_itxt,
1282 mng_fields_itxt, (sizeof(mng_fields_itxt) / sizeof(mng_field_descriptor)),
1283 MNG_DESCR_GLOBAL,
1284 MNG_DESCR_GenHDR,
1285 MNG_NULL};
1286#endif
1287
1288#ifndef MNG_SKIPCHUNK_bKGD
1289MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_bkgd =
1290 {mng_it_png, mng_create_none, 0, offsetof(mng_bkgd, bEmpty),
1291 MNG_NULL, MNG_NULL, mng_special_bkgd,
1292 mng_fields_bkgd, (sizeof(mng_fields_bkgd) / sizeof(mng_field_descriptor)),
1293 MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
1294 MNG_DESCR_GenHDR,
1295 MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
1296#endif
1297
1298#ifndef MNG_SKIPCHUNK_pHYs
1299MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_phys =
1300 {mng_it_png, mng_create_none, 0, offsetof(mng_phys, bEmpty),
1301 MNG_NULL, MNG_NULL, mng_special_phys,
1302 mng_fields_phys, (sizeof(mng_fields_phys) / sizeof(mng_field_descriptor)),
1303 MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
1304 MNG_DESCR_GenHDR,
1305 MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
1306#endif
1307
1308#ifndef MNG_SKIPCHUNK_sBIT
1309MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_sbit =
1310 {mng_it_png, mng_create_none, 0, offsetof(mng_sbit, bEmpty),
1311 MNG_NULL, MNG_NULL, mng_special_sbit,
1312 mng_fields_sbit, (sizeof(mng_fields_sbit) / sizeof(mng_field_descriptor)),
1313 MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
1314 MNG_DESCR_GenHDR,
1315 MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
1316#endif
1317
1318#ifndef MNG_SKIPCHUNK_sPLT
1319MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_splt =
1320 {mng_it_png, mng_create_none, 0, offsetof(mng_splt, bEmpty),
1321 MNG_NULL, MNG_NULL, mng_special_splt,
1322 mng_fields_splt, (sizeof(mng_fields_splt) / sizeof(mng_field_descriptor)),
1323 MNG_DESCR_GLOBAL | MNG_DESCR_EMPTYEMBED | MNG_DESCR_EMPTYGLOBAL,
1324 MNG_DESCR_GenHDR,
1325 MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
1326#endif
1327
1328#ifndef MNG_SKIPCHUNK_hIST
1329MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_hist =
1330 {mng_it_png, mng_create_none, 0, 0,
1331 MNG_NULL, MNG_NULL, mng_special_hist,
1332 mng_fields_hist, (sizeof(mng_fields_hist) / sizeof(mng_field_descriptor)),
1333 MNG_NULL,
1334 MNG_DESCR_GenHDR | MNG_DESCR_PLTE,
1335 MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT | MNG_DESCR_NOJDAA};
1336#endif
1337
1338#ifndef MNG_SKIPCHUNK_tIME
1339MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_time =
1340 {mng_it_png, mng_create_none, 0, 0,
1341 MNG_NULL, MNG_NULL, mng_special_time,
1342 mng_fields_time, (sizeof(mng_fields_time) / sizeof(mng_field_descriptor)),
1343 MNG_DESCR_GLOBAL,
1344 MNG_DESCR_GenHDR,
1345 MNG_NULL};
1346#endif
1347
1348/* ************************************************************************** */
1349/* JNG chunks */
1350
1351#ifdef MNG_INCLUDE_JNG
1352MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_jhdr =
1353 {mng_it_jng, mng_create_none, 0, 0,
1354 MNG_NULL, MNG_NULL, mng_special_jhdr,
1355 mng_fields_jhdr, (sizeof(mng_fields_jhdr) / sizeof(mng_field_descriptor)),
1356 MNG_NULL,
1357 MNG_NULL,
1358 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1359#endif
1360
1361#ifdef MNG_INCLUDE_JNG
1362MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_jdaa =
1363 {mng_it_jng, mng_create_none, 0, 0,
1364 MNG_NULL, MNG_NULL, mng_special_jdaa,
1365 mng_fields_jdaa, (sizeof(mng_fields_jdaa) / sizeof(mng_field_descriptor)),
1366 MNG_NULL,
1367 MNG_DESCR_JngHDR,
1368 MNG_DESCR_NOJSEP};
1369#endif
1370
1371#ifdef MNG_INCLUDE_JNG
1372MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_jdat =
1373 {mng_it_jng, mng_create_none, 0, 0,
1374 MNG_NULL, MNG_NULL, mng_special_jdat,
1375 mng_fields_jdat, (sizeof(mng_fields_jdat) / sizeof(mng_field_descriptor)),
1376 MNG_DESCR_EMPTYEMBED,
1377 MNG_DESCR_JngHDR,
1378 MNG_NULL};
1379#endif
1380
1381#ifdef MNG_INCLUDE_JNG
1382MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_jsep =
1383 {mng_it_jng, mng_create_none, 0, 0,
1384 MNG_NULL, MNG_NULL, mng_special_jsep,
1385 MNG_NULL, 0,
1386 MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED,
1387 MNG_DESCR_JngHDR,
1388 MNG_DESCR_NOJSEP};
1389#endif
1390
1391/* ************************************************************************** */
1392/* MNG chunks */
1393
1394MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_mhdr =
1395 {mng_it_mng, mng_create_none, 0, 0,
1396 MNG_NULL, MNG_NULL, mng_special_mhdr,
1397 mng_fields_mhdr, (sizeof(mng_fields_mhdr) / sizeof(mng_field_descriptor)),
1398 MNG_NULL,
1399 MNG_NULL,
1400 MNG_DESCR_NOMHDR | MNG_DESCR_NOIHDR | MNG_DESCR_NOJHDR};
1401
1402MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_mend =
1403 {mng_it_mng, mng_create_none, 0, 0,
1404 MNG_NULL, MNG_NULL, mng_special_mend,
1405 MNG_NULL, 0,
1406 MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL,
1407 MNG_DESCR_MHDR,
1408 MNG_NULL};
1409
1410#ifndef MNG_SKIPCHUNK_LOOP
1411MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_loop =
1412 {mng_it_mng, mng_create_none, 0, 0,
1413 MNG_NULL, MNG_NULL, mng_special_loop,
1414 mng_fields_loop, (sizeof(mng_fields_loop) / sizeof(mng_field_descriptor)),
1415 MNG_NULL,
1416 MNG_DESCR_MHDR,
1417 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1418
1419MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_endl =
1420 {mng_it_mng, mng_create_none, 0, 0,
1421 MNG_NULL, MNG_NULL, mng_special_endl,
1422 mng_fields_endl, (sizeof(mng_fields_endl) / sizeof(mng_field_descriptor)),
1423 MNG_NULL,
1424 MNG_DESCR_MHDR,
1425 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1426#endif
1427
1428#ifndef MNG_SKIPCHUNK_DEFI
1429MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_defi =
1430 {mng_it_mng, mng_create_none, 0, 0,
1431 MNG_NULL, MNG_NULL, mng_special_defi,
1432 mng_fields_defi, (sizeof(mng_fields_defi) / sizeof(mng_field_descriptor)),
1433 MNG_NULL,
1434 MNG_DESCR_MHDR,
1435 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1436#endif
1437
1438#ifndef MNG_SKIPCHUNK_BASI
1439MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_basi =
1440 {mng_it_mng, mng_create_none, 0, 0,
1441 MNG_NULL, MNG_NULL, mng_special_basi,
1442 mng_fields_basi, (sizeof(mng_fields_basi) / sizeof(mng_field_descriptor)),
1443 MNG_NULL,
1444 MNG_DESCR_MHDR,
1445 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1446#endif
1447
1448#ifndef MNG_SKIPCHUNK_CLON
1449MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_clon =
1450 {mng_it_mng, mng_create_none, 0, 0,
1451 MNG_NULL, MNG_NULL, mng_special_clon,
1452 mng_fields_clon, (sizeof(mng_fields_clon) / sizeof(mng_field_descriptor)),
1453 MNG_NULL,
1454 MNG_DESCR_MHDR,
1455 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1456#endif
1457
1458#ifndef MNG_SKIPCHUNK_PAST
1459MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_past =
1460 {mng_it_mng, mng_create_none, 0, 0,
1461 MNG_NULL, MNG_NULL, mng_special_past,
1462 mng_fields_past, (sizeof(mng_fields_past) / sizeof(mng_field_descriptor)),
1463 MNG_NULL,
1464 MNG_DESCR_MHDR,
1465 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1466#endif
1467
1468#ifndef MNG_SKIPCHUNK_DISC
1469MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_disc =
1470 {mng_it_mng, mng_create_none, 0, 0,
1471 MNG_NULL, MNG_NULL, mng_special_disc,
1472 mng_fields_disc, (sizeof(mng_fields_disc) / sizeof(mng_field_descriptor)),
1473 MNG_NULL,
1474 MNG_DESCR_MHDR,
1475 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1476#endif
1477
1478#ifndef MNG_SKIPCHUNK_BACK
1479MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_back =
1480 {mng_it_mng, mng_create_none, 0, 0,
1481 MNG_NULL, MNG_NULL, mng_special_back,
1482 mng_fields_back, (sizeof(mng_fields_back) / sizeof(mng_field_descriptor)),
1483 MNG_NULL,
1484 MNG_DESCR_MHDR,
1485 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1486#endif
1487
1488#ifndef MNG_SKIPCHUNK_FRAM
1489MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_fram =
1490 {mng_it_mng, mng_create_none, 0, offsetof(mng_fram, bEmpty),
1491 MNG_NULL, MNG_NULL, mng_special_fram,
1492 mng_fields_fram, (sizeof(mng_fields_fram) / sizeof(mng_field_descriptor)),
1493 MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL,
1494 MNG_DESCR_MHDR,
1495 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1496#endif
1497
1498#ifndef MNG_SKIPCHUNK_MOVE
1499MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_move =
1500 {mng_it_mng, mng_create_none, 0, 0,
1501 MNG_NULL, MNG_NULL, mng_special_move,
1502 mng_fields_move, (sizeof(mng_fields_move) / sizeof(mng_field_descriptor)),
1503 MNG_NULL,
1504 MNG_DESCR_MHDR,
1505 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1506#endif
1507
1508#ifndef MNG_SKIPCHUNK_CLIP
1509MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_clip =
1510 {mng_it_mng, mng_create_none, 0, 0,
1511 MNG_NULL, MNG_NULL, mng_special_clip,
1512 mng_fields_clip, (sizeof(mng_fields_clip) / sizeof(mng_field_descriptor)),
1513 MNG_NULL,
1514 MNG_DESCR_MHDR,
1515 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1516#endif
1517
1518#ifndef MNG_SKIPCHUNK_SHOW
1519MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_show =
1520 {mng_it_mng, mng_create_none, 0, offsetof(mng_show, bEmpty),
1521 MNG_NULL, MNG_NULL, mng_special_show,
1522 mng_fields_show, (sizeof(mng_fields_show) / sizeof(mng_field_descriptor)),
1523 MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL,
1524 MNG_DESCR_MHDR,
1525 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1526#endif
1527
1528#ifndef MNG_SKIPCHUNK_TERM
1529MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_term =
1530 {mng_it_mng, mng_create_none, 0, 0,
1531 MNG_NULL, MNG_NULL, mng_special_term,
1532 mng_fields_term, (sizeof(mng_fields_term) / sizeof(mng_field_descriptor)),
1533 MNG_NULL,
1534 MNG_DESCR_MHDR,
1535 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR | MNG_DESCR_NOTERM | MNG_DESCR_NOLOOP};
1536#endif
1537
1538#ifndef MNG_SKIPCHUNK_SAVE
1539MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_save =
1540 {mng_it_mng, mng_create_none, 0, 0,
1541 MNG_NULL, MNG_NULL, mng_special_save,
1542 mng_fields_save, (sizeof(mng_fields_save) / sizeof(mng_field_descriptor)),
1543 MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL,
1544 MNG_DESCR_MHDR,
1545 MNG_DESCR_NOSAVE | MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1546#endif
1547
1548#ifndef MNG_SKIPCHUNK_SEEK
1549MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_seek =
1550 {mng_it_mng, mng_create_none, 0, 0,
1551 MNG_NULL, MNG_NULL, mng_special_seek,
1552 mng_fields_seek, (sizeof(mng_fields_seek) / sizeof(mng_field_descriptor)),
1553 MNG_DESCR_EMPTY | MNG_DESCR_EMPTYGLOBAL,
1554 MNG_DESCR_MHDR | MNG_DESCR_SAVE,
1555 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1556#endif
1557
1558#ifndef MNG_SKIPCHUNK_eXPI
1559MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_expi =
1560 {mng_it_mng, mng_create_none, 0, 0,
1561 MNG_NULL, MNG_NULL, mng_special_expi,
1562 mng_fields_expi, (sizeof(mng_fields_expi) / sizeof(mng_field_descriptor)),
1563 MNG_NULL,
1564 MNG_DESCR_MHDR,
1565 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1566#endif
1567
1568#ifndef MNG_SKIPCHUNK_fPRI
1569MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_fpri =
1570 {mng_it_mng, mng_create_none, 0, 0,
1571 MNG_NULL, MNG_NULL, mng_special_fpri,
1572 mng_fields_fpri, (sizeof(mng_fields_fpri) / sizeof(mng_field_descriptor)),
1573 MNG_NULL,
1574 MNG_DESCR_MHDR,
1575 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1576#endif
1577
1578#ifndef MNG_SKIPCHUNK_nEED
1579MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_need =
1580 {mng_it_mng, mng_create_none, 0, 0,
1581 MNG_NULL, MNG_NULL, mng_special_need,
1582 mng_fields_need, (sizeof(mng_fields_need) / sizeof(mng_field_descriptor)),
1583 MNG_NULL,
1584 MNG_DESCR_MHDR,
1585 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1586#endif
1587
1588#ifndef MNG_SKIPCHUNK_pHYg
1589MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_phyg =
1590 {mng_it_mng, mng_create_none, 0, 0,
1591 MNG_NULL, MNG_NULL, mng_special_phyg,
1592 mng_fields_phyg, (sizeof(mng_fields_phyg) / sizeof(mng_field_descriptor)),
1593 MNG_NULL,
1594 MNG_DESCR_MHDR,
1595 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1596#endif
1597
1598#ifndef MNG_NO_DELTA_PNG
1599MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_dhdr =
1600 {mng_it_mng, mng_create_none, 0, 0,
1601 MNG_NULL, MNG_NULL, mng_special_dhdr,
1602 mng_fields_dhdr, (sizeof(mng_fields_dhdr) / sizeof(mng_field_descriptor)),
1603 MNG_NULL,
1604 MNG_DESCR_MHDR,
1605 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1606#endif
1607
1608#ifndef MNG_NO_DELTA_PNG
1609MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_prom =
1610 {mng_it_mng, mng_create_none, 0, 0,
1611 MNG_NULL, MNG_NULL, mng_special_prom,
1612 mng_fields_prom, (sizeof(mng_fields_prom) / sizeof(mng_field_descriptor)),
1613 MNG_NULL,
1614 MNG_DESCR_MHDR | MNG_DESCR_DHDR,
1615 MNG_NULL};
1616#endif
1617
1618#ifndef MNG_NO_DELTA_PNG
1619MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ipng =
1620 {mng_it_mng, mng_create_none, 0, 0,
1621 MNG_NULL, MNG_NULL, mng_special_ipng,
1622 MNG_NULL, 0,
1623 MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED,
1624 MNG_DESCR_MHDR | MNG_DESCR_DHDR,
1625 MNG_NULL};
1626#endif
1627
1628#ifndef MNG_NO_DELTA_PNG
1629MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_pplt =
1630 {mng_it_mng, mng_create_none, 0, 0,
1631 MNG_NULL, MNG_NULL, mng_special_pplt,
1632 mng_fields_pplt, (sizeof(mng_fields_pplt) / sizeof(mng_field_descriptor)),
1633 MNG_NULL,
1634 MNG_DESCR_MHDR | MNG_DESCR_DHDR,
1635 MNG_NULL};
1636#endif
1637
1638#ifndef MNG_NO_DELTA_PNG
1639#ifdef MNG_INCLUDE_JNG
1640MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ijng =
1641 {mng_it_mng, mng_create_none, 0, 0,
1642 MNG_NULL, MNG_NULL, mng_special_ijng,
1643 MNG_NULL, 0,
1644 MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED,
1645 MNG_DESCR_MHDR | MNG_DESCR_DHDR,
1646 MNG_NULL};
1647#endif
1648#endif
1649
1650#ifndef MNG_NO_DELTA_PNG
1651MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_drop =
1652 {mng_it_mng, mng_create_none, 0, 0,
1653 MNG_NULL, MNG_NULL, mng_special_drop,
1654 mng_fields_drop, (sizeof(mng_fields_drop) / sizeof(mng_field_descriptor)),
1655 MNG_NULL,
1656 MNG_DESCR_MHDR | MNG_DESCR_DHDR,
1657 MNG_NULL};
1658#endif
1659
1660#ifndef MNG_NO_DELTA_PNG
1661#ifndef MNG_SKIPCHUNK_DBYK
1662MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_dbyk =
1663 {mng_it_mng, mng_create_none, 0, 0,
1664 MNG_NULL, MNG_NULL, mng_special_dbyk,
1665 mng_fields_dbyk, (sizeof(mng_fields_dbyk) / sizeof(mng_field_descriptor)),
1666 MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED,
1667 MNG_DESCR_MHDR | MNG_DESCR_DHDR,
1668 MNG_NULL};
1669#endif
1670#endif
1671
1672#ifndef MNG_NO_DELTA_PNG
1673#ifndef MNG_SKIPCHUNK_ORDR
1674MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ordr =
1675 {mng_it_mng, mng_create_none, 0, 0,
1676 MNG_NULL, MNG_NULL, mng_special_ordr,
1677 mng_fields_ordr, (sizeof(mng_fields_ordr) / sizeof(mng_field_descriptor)),
1678 MNG_NULL,
1679 MNG_DESCR_MHDR | MNG_DESCR_DHDR,
1680 MNG_NULL};
1681#endif
1682#endif
1683
1684#ifndef MNG_SKIPCHUNK_MAGN
1685MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_magn =
1686 {mng_it_mng, mng_create_none, 0, 0,
1687 MNG_NULL, MNG_NULL, mng_special_magn,
1688 mng_fields_magn, (sizeof(mng_fields_magn) / sizeof(mng_field_descriptor)),
1689 MNG_NULL,
1690 MNG_DESCR_MHDR,
1691 MNG_DESCR_NOIHDR | MNG_DESCR_NOBASI | MNG_DESCR_NODHDR | MNG_DESCR_NOJHDR};
1692#endif
1693
1694#ifndef MNG_SKIPCHUNK_evNT
1695MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_evnt =
1696 {mng_it_mng, mng_create_none, 0, 0,
1697 MNG_NULL, MNG_NULL, mng_special_evnt,
1698 mng_fields_evnt, (sizeof(mng_fields_evnt) / sizeof(mng_field_descriptor)),
1699 MNG_NULL,
1700 MNG_DESCR_MHDR,
1701 MNG_DESCR_NOSAVE};
1702#endif
1703
1704#ifdef MNG_INCLUDE_MPNG_PROPOSAL
1705MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_mpng =
1706 {mng_it_mpng, mng_create_none, 0, 0,
1707 MNG_NULL, MNG_NULL, mng_special_mpng,
1708 mng_fields_mpng, (sizeof(mng_fields_mpng) / sizeof(mng_field_descriptor)),
1709 MNG_NULL,
1710 MNG_NULL,
1711 MNG_DESCR_NOMHDR | MNG_DESCR_NOIDAT | MNG_DESCR_NOJDAT};
1712#endif
1713
1714#ifdef MNG_INCLUDE_ANG_PROPOSAL
1715MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_ahdr =
1716 {mng_it_ang, mng_create_none, 0, 0,
1717 MNG_NULL, MNG_NULL, mng_special_ahdr,
1718 mng_fields_ahdr, (sizeof(mng_fields_ahdr) / sizeof(mng_field_descriptor)),
1719 MNG_NULL,
1720 MNG_DESCR_IHDR,
1721 MNG_DESCR_NOMHDR | MNG_DESCR_NOJHDR | MNG_DESCR_NOIDAT};
1722
1723MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_adat =
1724 {mng_it_ang, mng_create_none, 0, 0,
1725 MNG_NULL, MNG_NULL, mng_special_adat,
1726 mng_fields_adat, (sizeof(mng_fields_adat) / sizeof(mng_field_descriptor)),
1727 MNG_NULL,
1728 MNG_DESCR_IHDR,
1729 MNG_DESCR_NOMHDR | MNG_DESCR_NOJHDR};
1730#endif
1731
1732/* ************************************************************************** */
1733/* ************************************************************************** */
1734/* the good ol' unknown babe */
1735
1736MNG_LOCAL mng_chunk_descriptor mng_chunk_descr_unknown =
1737 {mng_it_png, mng_create_none, 0, 0,
1738 MNG_NULL, MNG_NULL, mng_special_unknown,
1739 mng_fields_unknown, (sizeof(mng_fields_unknown) / sizeof(mng_field_descriptor)),
1740 MNG_DESCR_EMPTY | MNG_DESCR_EMPTYEMBED,
1741 MNG_NULL,
1742 MNG_NULL};
1743
1744/* ************************************************************************** */
1745/* ************************************************************************** */
1746
1747MNG_LOCAL mng_chunk_header mng_chunk_unknown =
1748 {MNG_UINT_HUH, mng_init_general, mng_free_unknown,
1749 mng_read_general, mng_write_unknown, mng_assign_unknown,
1750 0, 0, sizeof(mng_unknown_chunk), &mng_chunk_descr_unknown};
1751
1752/* ************************************************************************** */
1753
1754 /* the table-idea & binary search code was adapted from
1755 libpng 1.1.0 (pngread.c) */
1756 /* NOTE1: the table must remain sorted by chunkname, otherwise the binary
1757 search will break !!! (ps. watch upper-/lower-case chunknames !!) */
1758 /* NOTE2: the layout must remain equal to the header part of all the
1759 chunk-structures (yes, that means even the pNext and pPrev fields;
1760 it's wasting a bit of space, but hey, the code is a lot easier) */
1761
1762MNG_LOCAL mng_chunk_header mng_chunk_table [] =
1763 {
1764#ifndef MNG_SKIPCHUNK_BACK
1765 {MNG_UINT_BACK, mng_init_general, mng_free_general, mng_read_general, mng_write_back, mng_assign_general, 0, 0, sizeof(mng_back), &mng_chunk_descr_back},
1766#endif
1767#ifndef MNG_SKIPCHUNK_BASI
1768 {MNG_UINT_BASI, mng_init_general, mng_free_general, mng_read_general, mng_write_basi, mng_assign_general, 0, 0, sizeof(mng_basi), &mng_chunk_descr_basi},
1769#endif
1770#ifndef MNG_SKIPCHUNK_CLIP
1771 {MNG_UINT_CLIP, mng_init_general, mng_free_general, mng_read_general, mng_write_clip, mng_assign_general, 0, 0, sizeof(mng_clip), &mng_chunk_descr_clip},
1772#endif
1773#ifndef MNG_SKIPCHUNK_CLON
1774 {MNG_UINT_CLON, mng_init_general, mng_free_general, mng_read_general, mng_write_clon, mng_assign_general, 0, 0, sizeof(mng_clon), &mng_chunk_descr_clon},
1775#endif
1776#ifndef MNG_NO_DELTA_PNG
1777#ifndef MNG_SKIPCHUNK_DBYK
1778 {MNG_UINT_DBYK, mng_init_general, mng_free_dbyk, mng_read_general, mng_write_dbyk, mng_assign_dbyk, 0, 0, sizeof(mng_dbyk), &mng_chunk_descr_dbyk},
1779#endif
1780#endif
1781#ifndef MNG_SKIPCHUNK_DEFI
1782 {MNG_UINT_DEFI, mng_init_general, mng_free_general, mng_read_general, mng_write_defi, mng_assign_general, 0, 0, sizeof(mng_defi), &mng_chunk_descr_defi},
1783#endif
1784#ifndef MNG_NO_DELTA_PNG
1785 {MNG_UINT_DHDR, mng_init_general, mng_free_general, mng_read_general, mng_write_dhdr, mng_assign_general, 0, 0, sizeof(mng_dhdr), &mng_chunk_descr_dhdr},
1786#endif
1787#ifndef MNG_SKIPCHUNK_DISC
1788 {MNG_UINT_DISC, mng_init_general, mng_free_disc, mng_read_general, mng_write_disc, mng_assign_disc, 0, 0, sizeof(mng_disc), &mng_chunk_descr_disc},
1789#endif
1790#ifndef MNG_NO_DELTA_PNG
1791#ifndef MNG_SKIPCHUNK_DROP
1792 {MNG_UINT_DROP, mng_init_general, mng_free_drop, mng_read_general, mng_write_drop, mng_assign_drop, 0, 0, sizeof(mng_drop), &mng_chunk_descr_drop},
1793#endif
1794#endif
1795#ifndef MNG_SKIPCHUNK_LOOP
1796 {MNG_UINT_ENDL, mng_init_general, mng_free_general, mng_read_general, mng_write_endl, mng_assign_general, 0, 0, sizeof(mng_endl), &mng_chunk_descr_endl},
1797#endif
1798#ifndef MNG_SKIPCHUNK_FRAM
1799 {MNG_UINT_FRAM, mng_init_general, mng_free_fram, mng_read_general, mng_write_fram, mng_assign_fram, 0, 0, sizeof(mng_fram), &mng_chunk_descr_fram},
1800#endif
1801 {MNG_UINT_IDAT, mng_init_general, mng_free_idat, mng_read_general, mng_write_idat, mng_assign_idat, 0, 0, sizeof(mng_idat), &mng_chunk_descr_idat}, /* 12-th element! */
1802 {MNG_UINT_IEND, mng_init_general, mng_free_general, mng_read_general, mng_write_iend, mng_assign_general, 0, 0, sizeof(mng_iend), &mng_chunk_descr_iend},
1803 {MNG_UINT_IHDR, mng_init_general, mng_free_general, mng_read_general, mng_write_ihdr, mng_assign_general, 0, 0, sizeof(mng_ihdr), &mng_chunk_descr_ihdr},
1804#ifndef MNG_NO_DELTA_PNG
1805#ifdef MNG_INCLUDE_JNG
1806 {MNG_UINT_IJNG, mng_init_general, mng_free_general, mng_read_general, mng_write_ijng, mng_assign_general, 0, 0, sizeof(mng_ijng), &mng_chunk_descr_ijng},
1807#endif
1808 {MNG_UINT_IPNG, mng_init_general, mng_free_general, mng_read_general, mng_write_ipng, mng_assign_general, 0, 0, sizeof(mng_ipng), &mng_chunk_descr_ipng},
1809#endif
1810#ifdef MNG_INCLUDE_JNG
1811 {MNG_UINT_JDAA, mng_init_general, mng_free_jdaa, mng_read_general, mng_write_jdaa, mng_assign_jdaa, 0, 0, sizeof(mng_jdaa), &mng_chunk_descr_jdaa},
1812 {MNG_UINT_JDAT, mng_init_general, mng_free_jdat, mng_read_general, mng_write_jdat, mng_assign_jdat, 0, 0, sizeof(mng_jdat), &mng_chunk_descr_jdat},
1813 {MNG_UINT_JHDR, mng_init_general, mng_free_general, mng_read_general, mng_write_jhdr, mng_assign_general, 0, 0, sizeof(mng_jhdr), &mng_chunk_descr_jhdr},
1814 {MNG_UINT_JSEP, mng_init_general, mng_free_general, mng_read_general, mng_write_jsep, mng_assign_general, 0, 0, sizeof(mng_jsep), &mng_chunk_descr_jsep},
1815 {MNG_UINT_JdAA, mng_init_general, mng_free_jdaa, mng_read_general, mng_write_jdaa, mng_assign_jdaa, 0, 0, sizeof(mng_jdaa), &mng_chunk_descr_jdaa},
1816#endif
1817#ifndef MNG_SKIPCHUNK_LOOP
1818 {MNG_UINT_LOOP, mng_init_general, mng_free_loop, mng_read_general, mng_write_loop, mng_assign_loop, 0, 0, sizeof(mng_loop), &mng_chunk_descr_loop},
1819#endif
1820#ifndef MNG_SKIPCHUNK_MAGN
1821 {MNG_UINT_MAGN, mng_init_general, mng_free_general, mng_read_general, mng_write_magn, mng_assign_general, 0, 0, sizeof(mng_magn), &mng_chunk_descr_magn},
1822#endif
1823 {MNG_UINT_MEND, mng_init_general, mng_free_general, mng_read_general, mng_write_mend, mng_assign_general, 0, 0, sizeof(mng_mend), &mng_chunk_descr_mend},
1824 {MNG_UINT_MHDR, mng_init_general, mng_free_general, mng_read_general, mng_write_mhdr, mng_assign_general, 0, 0, sizeof(mng_mhdr), &mng_chunk_descr_mhdr},
1825#ifndef MNG_SKIPCHUNK_MOVE
1826 {MNG_UINT_MOVE, mng_init_general, mng_free_general, mng_read_general, mng_write_move, mng_assign_general, 0, 0, sizeof(mng_move), &mng_chunk_descr_move},
1827#endif
1828#ifndef MNG_NO_DELTA_PNG
1829#ifndef MNG_SKIPCHUNK_ORDR
1830 {MNG_UINT_ORDR, mng_init_general, mng_free_ordr, mng_read_general, mng_write_ordr, mng_assign_ordr, 0, 0, sizeof(mng_ordr), &mng_chunk_descr_ordr},
1831#endif
1832#endif
1833#ifndef MNG_SKIPCHUNK_PAST
1834 {MNG_UINT_PAST, mng_init_general, mng_free_past, mng_read_general, mng_write_past, mng_assign_past, 0, 0, sizeof(mng_past), &mng_chunk_descr_past},
1835#endif
1836 {MNG_UINT_PLTE, mng_init_general, mng_free_general, mng_read_general, mng_write_plte, mng_assign_general, 0, 0, sizeof(mng_plte), &mng_chunk_descr_plte},
1837#ifndef MNG_NO_DELTA_PNG
1838 {MNG_UINT_PPLT, mng_init_general, mng_free_general, mng_read_general, mng_write_pplt, mng_assign_general, 0, 0, sizeof(mng_pplt), &mng_chunk_descr_pplt},
1839 {MNG_UINT_PROM, mng_init_general, mng_free_general, mng_read_general, mng_write_prom, mng_assign_general, 0, 0, sizeof(mng_prom), &mng_chunk_descr_prom},
1840#endif
1841#ifndef MNG_SKIPCHUNK_SAVE
1842 {MNG_UINT_SAVE, mng_init_general, mng_free_save, mng_read_general, mng_write_save, mng_assign_save, 0, 0, sizeof(mng_save), &mng_chunk_descr_save},
1843#endif
1844#ifndef MNG_SKIPCHUNK_SEEK
1845 {MNG_UINT_SEEK, mng_init_general, mng_free_seek, mng_read_general, mng_write_seek, mng_assign_seek, 0, 0, sizeof(mng_seek), &mng_chunk_descr_seek},
1846#endif
1847#ifndef MNG_SKIPCHUNK_SHOW
1848 {MNG_UINT_SHOW, mng_init_general, mng_free_general, mng_read_general, mng_write_show, mng_assign_general, 0, 0, sizeof(mng_show), &mng_chunk_descr_show},
1849#endif
1850#ifndef MNG_SKIPCHUNK_TERM
1851 {MNG_UINT_TERM, mng_init_general, mng_free_general, mng_read_general, mng_write_term, mng_assign_general, 0, 0, sizeof(mng_term), &mng_chunk_descr_term},
1852#endif
1853#ifdef MNG_INCLUDE_ANG_PROPOSAL
1854 {MNG_UINT_adAT, mng_init_general, mng_free_adat, mng_read_general, mng_write_adat, mng_assign_adat, 0, 0, sizeof(mng_adat), &mng_chunk_descr_adat},
1855 {MNG_UINT_ahDR, mng_init_general, mng_free_general, mng_read_general, mng_write_ahdr, mng_assign_ahdr, 0, 0, sizeof(mng_ahdr), &mng_chunk_descr_ahdr},
1856#endif
1857#ifndef MNG_SKIPCHUNK_bKGD
1858 {MNG_UINT_bKGD, mng_init_general, mng_free_general, mng_read_general, mng_write_bkgd, mng_assign_general, 0, 0, sizeof(mng_bkgd), &mng_chunk_descr_bkgd},
1859#endif
1860#ifndef MNG_SKIPCHUNK_cHRM
1861 {MNG_UINT_cHRM, mng_init_general, mng_free_general, mng_read_general, mng_write_chrm, mng_assign_general, 0, 0, sizeof(mng_chrm), &mng_chunk_descr_chrm},
1862#endif
1863#ifndef MNG_SKIPCHUNK_eXPI
1864 {MNG_UINT_eXPI, mng_init_general, mng_free_expi, mng_read_general, mng_write_expi, mng_assign_expi, 0, 0, sizeof(mng_expi), &mng_chunk_descr_expi},
1865#endif
1866#ifndef MNG_SKIPCHUNK_evNT
1867 {MNG_UINT_evNT, mng_init_general, mng_free_evnt, mng_read_general, mng_write_evnt, mng_assign_evnt, 0, 0, sizeof(mng_evnt), &mng_chunk_descr_evnt},
1868#endif
1869#ifndef MNG_SKIPCHUNK_fPRI
1870 {MNG_UINT_fPRI, mng_init_general, mng_free_general, mng_read_general, mng_write_fpri, mng_assign_general, 0, 0, sizeof(mng_fpri), &mng_chunk_descr_fpri},
1871#endif
1872#ifndef MNG_SKIPCHUNK_gAMA
1873 {MNG_UINT_gAMA, mng_init_general, mng_free_general, mng_read_general, mng_write_gama, mng_assign_general, 0, 0, sizeof(mng_gama), &mng_chunk_descr_gama},
1874#endif
1875#ifndef MNG_SKIPCHUNK_hIST
1876 {MNG_UINT_hIST, mng_init_general, mng_free_general, mng_read_general, mng_write_hist, mng_assign_general, 0, 0, sizeof(mng_hist), &mng_chunk_descr_hist},
1877#endif
1878#ifndef MNG_SKIPCHUNK_iCCP
1879 {MNG_UINT_iCCP, mng_init_general, mng_free_iccp, mng_read_general, mng_write_iccp, mng_assign_iccp, 0, 0, sizeof(mng_iccp), &mng_chunk_descr_iccp},
1880#endif
1881#ifndef MNG_SKIPCHUNK_iTXt
1882 {MNG_UINT_iTXt, mng_init_general, mng_free_itxt, mng_read_general, mng_write_itxt, mng_assign_itxt, 0, 0, sizeof(mng_itxt), &mng_chunk_descr_itxt},
1883#endif
1884#ifdef MNG_INCLUDE_MPNG_PROPOSAL
1885 {MNG_UINT_mpNG, mng_init_general, mng_free_mpng, mng_read_general, mng_write_mpng, mng_assign_mpng, 0, 0, sizeof(mng_mpng), &mng_chunk_descr_mpng},
1886#endif
1887#ifndef MNG_SKIPCHUNK_nEED
1888 {MNG_UINT_nEED, mng_init_general, mng_free_need, mng_read_general, mng_write_need, mng_assign_need, 0, 0, sizeof(mng_need), &mng_chunk_descr_need},
1889#endif
1890/* TODO: {MNG_UINT_oFFs, 0, 0, 0, 0, 0, 0}, */
1891/* TODO: {MNG_UINT_pCAL, 0, 0, 0, 0, 0, 0}, */
1892#ifndef MNG_SKIPCHUNK_pHYg
1893 {MNG_UINT_pHYg, mng_init_general, mng_free_general, mng_read_general, mng_write_phyg, mng_assign_general, 0, 0, sizeof(mng_phyg), &mng_chunk_descr_phyg},
1894#endif
1895#ifndef MNG_SKIPCHUNK_pHYs
1896 {MNG_UINT_pHYs, mng_init_general, mng_free_general, mng_read_general, mng_write_phys, mng_assign_general, 0, 0, sizeof(mng_phys), &mng_chunk_descr_phys},
1897#endif
1898#ifndef MNG_SKIPCHUNK_sBIT
1899 {MNG_UINT_sBIT, mng_init_general, mng_free_general, mng_read_general, mng_write_sbit, mng_assign_general, 0, 0, sizeof(mng_sbit), &mng_chunk_descr_sbit},
1900#endif
1901/* TODO: {MNG_UINT_sCAL, 0, 0, 0, 0, 0, 0}, */
1902#ifndef MNG_SKIPCHUNK_sPLT
1903 {MNG_UINT_sPLT, mng_init_general, mng_free_splt, mng_read_general, mng_write_splt, mng_assign_splt, 0, 0, sizeof(mng_splt), &mng_chunk_descr_splt},
1904#endif
1905 {MNG_UINT_sRGB, mng_init_general, mng_free_general, mng_read_general, mng_write_srgb, mng_assign_general, 0, 0, sizeof(mng_srgb), &mng_chunk_descr_srgb},
1906#ifndef MNG_SKIPCHUNK_tEXt
1907 {MNG_UINT_tEXt, mng_init_general, mng_free_text, mng_read_general, mng_write_text, mng_assign_text, 0, 0, sizeof(mng_text), &mng_chunk_descr_text},
1908#endif
1909#ifndef MNG_SKIPCHUNK_tIME
1910 {MNG_UINT_tIME, mng_init_general, mng_free_general, mng_read_general, mng_write_time, mng_assign_general, 0, 0, sizeof(mng_time), &mng_chunk_descr_time},
1911#endif
1912 {MNG_UINT_tRNS, mng_init_general, mng_free_general, mng_read_general, mng_write_trns, mng_assign_general, 0, 0, sizeof(mng_trns), &mng_chunk_descr_trns},
1913#ifndef MNG_SKIPCHUNK_zTXt
1914 {MNG_UINT_zTXt, mng_init_general, mng_free_ztxt, mng_read_general, mng_write_ztxt, mng_assign_ztxt, 0, 0, sizeof(mng_ztxt), &mng_chunk_descr_ztxt},
1915#endif
1916 };
1917
1918/* ************************************************************************** */
1919/* ************************************************************************** */
1920
1921void mng_get_chunkheader (mng_chunkid iChunkname,
1922 mng_chunk_headerp pResult)
1923{
1924 /* binary search variables */
1925 mng_int32 iTop, iLower, iUpper, iMiddle;
1926 mng_chunk_headerp pEntry; /* pointer to found entry */
1927 /* determine max index of table */
1928 iTop = (sizeof (mng_chunk_table) / sizeof (mng_chunk_table [0])) - 1;
1929
1930 /* binary search; with 54 chunks, worst-case is 7 comparisons */
1931 iLower = 0;
1932#ifndef MNG_NO_DELTA_PNG
1933 iMiddle = 11; /* start with the IDAT entry */
1934#else
1935 iMiddle = 8;
1936#endif
1937 iUpper = iTop;
1938 pEntry = 0; /* no goods yet! */
1939
1940 do /* the binary search itself */
1941 {
1942 if (mng_chunk_table [iMiddle].iChunkname < iChunkname)
1943 iLower = iMiddle + 1;
1944 else if (mng_chunk_table [iMiddle].iChunkname > iChunkname)
1945 iUpper = iMiddle - 1;
1946 else
1947 {
1948 pEntry = &mng_chunk_table [iMiddle];
1949 break;
1950 }
1951 iMiddle = (iLower + iUpper) >> 1;
1952 }
1953 while (iLower <= iUpper);
1954
1955 if (!pEntry) /* unknown chunk ? */
1956 pEntry = &mng_chunk_unknown; /* make it so! */
1957
1958 MNG_COPY (pResult, pEntry, sizeof(mng_chunk_header));
1959
1960 return;
1961}
1962
1963/* ************************************************************************** */
1964/* ************************************************************************** */
1965/* PNG chunks */
1966
1967MNG_C_SPECIALFUNC (mng_special_ihdr)
1968{
1969 pData->bHasIHDR = MNG_TRUE; /* indicate IHDR is present */
1970 /* and store interesting fields */
1971 if ((!pData->bHasDHDR) || (pData->iDeltatype == MNG_DELTATYPE_NOCHANGE))
1972 {
1973 pData->iDatawidth = ((mng_ihdrp)pChunk)->iWidth;
1974 pData->iDataheight = ((mng_ihdrp)pChunk)->iHeight;
1975 }
1976
1977 pData->iBitdepth = ((mng_ihdrp)pChunk)->iBitdepth;
1978 pData->iColortype = ((mng_ihdrp)pChunk)->iColortype;
1979 pData->iCompression = ((mng_ihdrp)pChunk)->iCompression;
1980 pData->iFilter = ((mng_ihdrp)pChunk)->iFilter;
1981 pData->iInterlace = ((mng_ihdrp)pChunk)->iInterlace;
1982
1983#if defined(MNG_NO_1_2_4BIT_SUPPORT) || defined(MNG_NO_16BIT_SUPPORT)
1984 pData->iPNGmult = 1;
1985 pData->iPNGdepth = pData->iBitdepth;
1986#endif
1987
1988#ifdef MNG_NO_1_2_4BIT_SUPPORT
1989 if (pData->iBitdepth < 8)
1990 pData->iBitdepth = 8;
1991#endif
1992
1993#ifdef MNG_NO_16BIT_SUPPORT
1994 if (pData->iBitdepth > 8)
1995 {
1996 pData->iBitdepth = 8;
1997 pData->iPNGmult = 2;
1998 }
1999#endif
2000
2001 if ((pData->iBitdepth != 8) /* parameter validity checks */
2002#ifndef MNG_NO_1_2_4BIT_SUPPORT
2003 && (pData->iBitdepth != 1) &&
2004 (pData->iBitdepth != 2) &&
2005 (pData->iBitdepth != 4)
2006#endif
2007#ifndef MNG_NO_16BIT_SUPPORT
2008 && (pData->iBitdepth != 16)
2009#endif
2010 )
2011 MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
2012
2013 if ((pData->iColortype != MNG_COLORTYPE_GRAY ) &&
2014 (pData->iColortype != MNG_COLORTYPE_RGB ) &&
2015 (pData->iColortype != MNG_COLORTYPE_INDEXED) &&
2016 (pData->iColortype != MNG_COLORTYPE_GRAYA ) &&
2017 (pData->iColortype != MNG_COLORTYPE_RGBA ) )
2018 MNG_ERROR (pData, MNG_INVALIDCOLORTYPE);
2019
2020 if ((pData->iColortype == MNG_COLORTYPE_INDEXED) && (pData->iBitdepth > 8))
2021 MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
2022
2023 if (((pData->iColortype == MNG_COLORTYPE_RGB ) ||
2024 (pData->iColortype == MNG_COLORTYPE_GRAYA ) ||
2025 (pData->iColortype == MNG_COLORTYPE_RGBA ) ) &&
2026 (pData->iBitdepth < 8 ) )
2027 MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
2028
2029 if (pData->iCompression != MNG_COMPRESSION_DEFLATE)
2030 MNG_ERROR (pData, MNG_INVALIDCOMPRESS);
2031
2032#if defined(FILTER192) || defined(FILTER193)
2033 if ((pData->iFilter != MNG_FILTER_ADAPTIVE ) &&
2034#if defined(FILTER192) && defined(FILTER193)
2035 (pData->iFilter != MNG_FILTER_DIFFERING) &&
2036 (pData->iFilter != MNG_FILTER_NOFILTER ) )
2037#else
2038#ifdef FILTER192
2039 (pData->iFilter != MNG_FILTER_DIFFERING) )
2040#else
2041 (pData->iFilter != MNG_FILTER_NOFILTER ) )
2042#endif
2043#endif
2044 MNG_ERROR (pData, MNG_INVALIDFILTER);
2045#else
2046 if (pData->iFilter)
2047 MNG_ERROR (pData, MNG_INVALIDFILTER);
2048#endif
2049
2050 if ((pData->iInterlace != MNG_INTERLACE_NONE ) &&
2051 (pData->iInterlace != MNG_INTERLACE_ADAM7) )
2052 MNG_ERROR (pData, MNG_INVALIDINTERLACE);
2053
2054#ifdef MNG_SUPPORT_DISPLAY
2055#ifndef MNG_NO_DELTA_PNG
2056 if (pData->bHasDHDR) /* check the colortype for delta-images ! */
2057 {
2058 mng_imagedatap pBuf = ((mng_imagep)pData->pObjzero)->pImgbuf;
2059
2060 if (pData->iColortype != pBuf->iColortype)
2061 {
2062 if ( ( (pData->iColortype != MNG_COLORTYPE_INDEXED) ||
2063 (pBuf->iColortype == MNG_COLORTYPE_GRAY ) ) &&
2064 ( (pData->iColortype != MNG_COLORTYPE_GRAY ) ||
2065 (pBuf->iColortype == MNG_COLORTYPE_INDEXED) ) )
2066 MNG_ERROR (pData, MNG_INVALIDCOLORTYPE);
2067 }
2068 }
2069#endif
2070#endif
2071
2072 if (!pData->bHasheader) /* first chunk ? */
2073 {
2074 pData->bHasheader = MNG_TRUE; /* we've got a header */
2075 pData->eImagetype = mng_it_png; /* then this must be a PNG */
2076 pData->iWidth = pData->iDatawidth;
2077 pData->iHeight = pData->iDataheight;
2078 /* predict alpha-depth ! */
2079 if ((pData->iColortype == MNG_COLORTYPE_GRAYA ) ||
2080 (pData->iColortype == MNG_COLORTYPE_RGBA ) )
2081 pData->iAlphadepth = pData->iBitdepth;
2082 else
2083 if (pData->iColortype == MNG_COLORTYPE_INDEXED)
2084 pData->iAlphadepth = 8; /* worst case scenario */
2085 else
2086 pData->iAlphadepth = 1; /* Possible tRNS cheap binary transparency */
2087 /* fits on maximum canvas ? */
2088 if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight))
2089 MNG_WARNING (pData, MNG_IMAGETOOLARGE);
2090
2091#if !defined(MNG_INCLUDE_MPNG_PROPOSAL) || !defined(MNG_SUPPORT_DISPLAY)
2092 if (pData->fProcessheader) /* inform the app ? */
2093 if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight))
2094 MNG_ERROR (pData, MNG_APPMISCERROR);
2095#endif
2096 }
2097
2098 if (!pData->bHasDHDR)
2099 pData->iImagelevel++; /* one level deeper */
2100
2101#ifdef MNG_SUPPORT_DISPLAY
2102 return mng_process_display_ihdr (pData);
2103#else
2104 return MNG_NOERROR;
2105#endif /* MNG_SUPPORT_DISPLAY */
2106}
2107
2108/* ************************************************************************** */
2109
2110MNG_F_SPECIALFUNC (mng_debunk_plte)
2111{
2112 mng_pltep pPLTE = (mng_pltep)pChunk;
2113 mng_uint32 iRawlen = *piRawlen;
2114 mng_uint8p pRawdata = *ppRawdata;
2115 /* length must be multiple of 3 */
2116 if (((iRawlen % 3) != 0) || (iRawlen > 768))
2117 MNG_ERROR (pData, MNG_INVALIDLENGTH);
2118 /* this is the exact length */
2119 pPLTE->iEntrycount = iRawlen / 3;
2120
2121 MNG_COPY (pPLTE->aEntries, pRawdata, iRawlen);
2122
2123 *piRawlen = 0;
2124
2125 return MNG_NOERROR;
2126}
2127
2128/* ************************************************************************** */
2129
2130MNG_C_SPECIALFUNC (mng_special_plte)
2131{ /* multiple PLTE only inside BASI */
2132 if ((pData->bHasPLTE) && (!pData->bHasBASI))
2133 MNG_ERROR (pData, MNG_MULTIPLEERROR);
2134
2135 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2136 { /* only allowed for indexed-color or
2137 rgb(a)-color! */
2138 if ((pData->iColortype != MNG_COLORTYPE_RGB ) &&
2139 (pData->iColortype != MNG_COLORTYPE_INDEXED) &&
2140 (pData->iColortype != MNG_COLORTYPE_RGBA ) )
2141 MNG_ERROR (pData, MNG_CHUNKNOTALLOWED);
2142 /* empty only allowed if global present */
2143 if ((((mng_pltep)pChunk)->bEmpty) && (!pData->bHasglobalPLTE))
2144 MNG_ERROR (pData, MNG_CANNOTBEEMPTY);
2145 }
2146 else
2147 {
2148 if (((mng_pltep)pChunk)->bEmpty) /* cannot be empty as global! */
2149 MNG_ERROR (pData, MNG_CANNOTBEEMPTY);
2150 }
2151
2152 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2153 pData->bHasPLTE = MNG_TRUE; /* got it! */
2154 else
2155 pData->bHasglobalPLTE = MNG_TRUE;
2156
2157 pData->iPLTEcount = ((mng_pltep)pChunk)->iEntrycount;
2158
2159#ifdef MNG_SUPPORT_DISPLAY
2160 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2161 {
2162 mng_imagep pImage;
2163 mng_imagedatap pBuf;
2164
2165#ifndef MNG_NO_DELTA_PNG
2166 if (pData->bHasDHDR) /* processing delta-image ? */
2167 { /* store in object 0 !!! */
2168 pImage = (mng_imagep)pData->pObjzero;
2169 pBuf = pImage->pImgbuf;
2170 pBuf->bHasPLTE = MNG_TRUE; /* it's definitely got a PLTE now */
2171 pBuf->iPLTEcount = ((mng_pltep)pChunk)->iEntrycount;
2172 MNG_COPY (pBuf->aPLTEentries, ((mng_pltep)pChunk)->aEntries,
2173 sizeof (pBuf->aPLTEentries));
2174 }
2175 else
2176#endif
2177 { /* get the current object */
2178 pImage = (mng_imagep)pData->pCurrentobj;
2179 if (!pImage) /* no object then dump it in obj 0 */
2180 pImage = (mng_imagep)pData->pObjzero;
2181
2182 pBuf = pImage->pImgbuf; /* address the object buffer */
2183 pBuf->bHasPLTE = MNG_TRUE; /* and tell it it's got a PLTE now */
2184
2185 if (((mng_pltep)pChunk)->bEmpty) /* if empty, inherit from global */
2186 {
2187 pBuf->iPLTEcount = pData->iGlobalPLTEcount;
2188 MNG_COPY (pBuf->aPLTEentries, pData->aGlobalPLTEentries,
2189 sizeof (pBuf->aPLTEentries));
2190
2191 if (pData->bHasglobalTRNS) /* also copy global tRNS ? */
2192 {
2193 mng_uint32 iRawlen2 = pData->iGlobalTRNSrawlen;
2194 mng_uint8p pRawdata2 = (mng_uint8p)(pData->aGlobalTRNSrawdata);
2195 /* indicate tRNS available */
2196 pBuf->bHasTRNS = MNG_TRUE;
2197 /* global length oke ? */
2198 if ((iRawlen2 == 0) || (iRawlen2 > pBuf->iPLTEcount))
2199 MNG_ERROR (pData, MNG_GLOBALLENGTHERR);
2200 /* copy it */
2201 pBuf->iTRNScount = iRawlen2;
2202 MNG_COPY (pBuf->aTRNSentries, pRawdata2, iRawlen2);
2203 }
2204 }
2205 else
2206 { /* store fields for future reference */
2207 pBuf->iPLTEcount = ((mng_pltep)pChunk)->iEntrycount;
2208 MNG_COPY (pBuf->aPLTEentries, ((mng_pltep)pChunk)->aEntries,
2209 sizeof (pBuf->aPLTEentries));
2210 }
2211 }
2212 }
2213 else /* store as global */
2214 {
2215 pData->iGlobalPLTEcount = ((mng_pltep)pChunk)->iEntrycount;
2216 MNG_COPY (pData->aGlobalPLTEentries, ((mng_pltep)pChunk)->aEntries,
2217 sizeof (pData->aGlobalPLTEentries));
2218 /* create an animation object */
2219 return mng_create_ani_plte (pData);
2220 }
2221#endif /* MNG_SUPPORT_DISPLAY */
2222
2223 return MNG_NOERROR; /* done */
2224}
2225
2226/* ************************************************************************** */
2227
2228MNG_C_SPECIALFUNC (mng_special_idat)
2229{
2230#ifdef MNG_INCLUDE_JNG
2231 if ((pData->bHasJHDR) &&
2232 (pData->iJHDRalphacompression != MNG_COMPRESSION_DEFLATE))
2233 MNG_ERROR (pData, MNG_SEQUENCEERROR);
2234#endif
2235 /* not allowed for deltatype NO_CHANGE */
2236#ifndef MNG_NO_DELTA_PNG
2237 if ((pData->bHasDHDR) && ((pData->iDeltatype == MNG_DELTATYPE_NOCHANGE)))
2238 MNG_ERROR (pData, MNG_CHUNKNOTALLOWED);
2239#endif
2240 /* can only be empty in BASI-block! */
2241 if ((((mng_idatp)pChunk)->bEmpty) && (!pData->bHasBASI))
2242 MNG_ERROR (pData, MNG_INVALIDLENGTH);
2243 /* indexed-color requires PLTE */
2244 if ((pData->bHasIHDR) && (pData->iColortype == 3) && (!pData->bHasPLTE))
2245 MNG_ERROR (pData, MNG_PLTEMISSING);
2246
2247 pData->bHasIDAT = MNG_TRUE; /* got some IDAT now, don't we */
2248
2249 return MNG_NOERROR; /* done */
2250}
2251
2252/* ************************************************************************** */
2253
2254MNG_C_SPECIALFUNC (mng_special_iend)
2255{ /* IHDR-block requires IDAT */
2256 if ((pData->bHasIHDR) && (!pData->bHasIDAT))
2257 MNG_ERROR (pData, MNG_IDATMISSING);
2258
2259 pData->iImagelevel--; /* one level up */
2260
2261#ifdef MNG_SUPPORT_DISPLAY
2262 { /* create an animation object */
2263 mng_retcode iRetcode = mng_create_ani_image (pData);
2264 if (iRetcode) /* on error bail out */
2265 return iRetcode;
2266 /* display processing */
2267 iRetcode = mng_process_display_iend (pData);
2268 if (iRetcode) /* on error bail out */
2269 return iRetcode;
2270 }
2271#endif /* MNG_SUPPORT_DISPLAY */
2272
2273#ifdef MNG_SUPPORT_DISPLAY
2274 if (!pData->bTimerset) /* reset only if not broken !!! */
2275 {
2276#endif
2277 /* IEND signals the end for most ... */
2278 pData->bHasIHDR = MNG_FALSE;
2279 pData->bHasBASI = MNG_FALSE;
2280 pData->bHasDHDR = MNG_FALSE;
2281#ifdef MNG_INCLUDE_JNG
2282 pData->bHasJHDR = MNG_FALSE;
2283 pData->bHasJSEP = MNG_FALSE;
2284 pData->bHasJDAA = MNG_FALSE;
2285 pData->bHasJDAT = MNG_FALSE;
2286#endif
2287 pData->bHasPLTE = MNG_FALSE;
2288 pData->bHasTRNS = MNG_FALSE;
2289 pData->bHasGAMA = MNG_FALSE;
2290 pData->bHasCHRM = MNG_FALSE;
2291 pData->bHasSRGB = MNG_FALSE;
2292 pData->bHasICCP = MNG_FALSE;
2293 pData->bHasBKGD = MNG_FALSE;
2294 pData->bHasIDAT = MNG_FALSE;
2295#ifdef MNG_SUPPORT_DISPLAY
2296 }
2297#endif
2298
2299 return MNG_NOERROR; /* done */
2300}
2301
2302/* ************************************************************************** */
2303
2304MNG_F_SPECIALFUNC (mng_debunk_trns)
2305{
2306 mng_trnsp pTRNS = (mng_trnsp)pChunk;
2307 mng_uint32 iRawlen = *piRawlen;
2308 mng_uint8p pRawdata = *ppRawdata;
2309
2310 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2311 { /* not global! */
2312 pTRNS->bGlobal = MNG_FALSE;
2313 pTRNS->iType = pData->iColortype;
2314
2315 if (iRawlen != 0)
2316 {
2317 switch (pData->iColortype) /* store fields */
2318 {
2319 case 0: { /* gray */
2320 if (iRawlen != 2)
2321 MNG_ERROR (pData, MNG_INVALIDLENGTH);
2322 pTRNS->iGray = mng_get_uint16 (pRawdata);
2323 break;
2324 }
2325 case 2: { /* rgb */
2326 if (iRawlen != 6)
2327 MNG_ERROR (pData, MNG_INVALIDLENGTH);
2328 pTRNS->iRed = mng_get_uint16 (pRawdata);
2329 pTRNS->iGreen = mng_get_uint16 (pRawdata+2);
2330 pTRNS->iBlue = mng_get_uint16 (pRawdata+4);
2331 break;
2332 }
2333 case 3: { /* indexed */
2334 if (iRawlen > 256)
2335 MNG_ERROR (pData, MNG_INVALIDLENGTH);
2336 pTRNS->iCount = iRawlen;
2337 MNG_COPY (pTRNS->aEntries, pRawdata, iRawlen);
2338 break;
2339 }
2340 }
2341 }
2342 }
2343 else /* it's global! */
2344 {
2345 if (iRawlen == 0)
2346 MNG_ERROR (pData, MNG_INVALIDLENGTH);
2347 pTRNS->bGlobal = MNG_TRUE;
2348 pTRNS->iType = 0;
2349 pTRNS->iRawlen = iRawlen;
2350 MNG_COPY (pTRNS->aRawdata, pRawdata, iRawlen);
2351
2352 pData->iGlobalTRNSrawlen = iRawlen;
2353 MNG_COPY (pData->aGlobalTRNSrawdata, pRawdata, iRawlen);
2354 }
2355
2356 *piRawlen = 0;
2357
2358 return MNG_NOERROR;
2359}
2360
2361/* ************************************************************************** */
2362
2363MNG_C_SPECIALFUNC (mng_special_trns)
2364{ /* multiple tRNS only inside BASI */
2365 if ((pData->bHasTRNS) && (!pData->bHasBASI))
2366 MNG_ERROR (pData, MNG_MULTIPLEERROR);
2367
2368 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2369 { /* not allowed with full alpha-channel */
2370 if ((pData->iColortype == 4) || (pData->iColortype == 6))
2371 MNG_ERROR (pData, MNG_CHUNKNOTALLOWED);
2372
2373 if (!((mng_trnsp)pChunk)->bEmpty) /* filled ? */
2374 {
2375#ifdef MNG_SUPPORT_DISPLAY
2376 if (pData->iColortype == 3)
2377 {
2378 mng_imagep pImage = (mng_imagep)pData->pCurrentobj;
2379 mng_imagedatap pBuf;
2380
2381 if (!pImage) /* no object then check obj 0 */
2382 pImage = (mng_imagep)pData->pObjzero;
2383
2384 pBuf = pImage->pImgbuf; /* address object buffer */
2385
2386 if (((mng_trnsp)pChunk)->iCount > pBuf->iPLTEcount)
2387 MNG_ERROR (pData, MNG_INVALIDLENGTH);
2388 }
2389#endif
2390 }
2391 else /* if empty there must be global stuff! */
2392 {
2393 if (!pData->bHasglobalTRNS)
2394 MNG_ERROR (pData, MNG_CANNOTBEEMPTY);
2395 }
2396 }
2397
2398 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2399 pData->bHasTRNS = MNG_TRUE; /* indicate tRNS available */
2400 else
2401 pData->bHasglobalTRNS = MNG_TRUE;
2402
2403#ifdef MNG_SUPPORT_DISPLAY
2404 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2405 {
2406 mng_imagep pImage;
2407 mng_imagedatap pBuf;
2408 mng_uint8p pRawdata2;
2409 mng_uint32 iRawlen2;
2410
2411#ifndef MNG_NO_DELTA_PNG
2412 if (pData->bHasDHDR) /* processing delta-image ? */
2413 { /* store in object 0 !!! */
2414#if defined(MNG_NO_1_2_4BIT_SUPPORT)
2415 mng_uint8 multiplier[]={0,255,85,0,17,0,0,0,1,0,0,0,0,0,0,0,1};
2416#endif
2417 pImage = (mng_imagep)pData->pObjzero;
2418 pBuf = pImage->pImgbuf; /* address object buffer */
2419 pBuf->bHasTRNS = MNG_TRUE; /* tell it it's got a tRNS now */
2420 pBuf->iTRNSgray = 0;
2421 pBuf->iTRNSred = 0;
2422 pBuf->iTRNSgreen = 0;
2423 pBuf->iTRNSblue = 0;
2424 pBuf->iTRNScount = 0;
2425
2426 switch (pData->iColortype) /* store fields for future reference */
2427 {
2428 case 0: { /* gray */
2429 pBuf->iTRNSgray = ((mng_trnsp)pChunk)->iGray;
2430#if defined(MNG_NO_1_2_4BIT_SUPPORT)
2431 pBuf->iTRNSgray *= multiplier[pData->iPNGdepth];
2432#endif
2433#if defined(MNG_NO_16BIT_SUPPORT)
2434 if (pData->iPNGmult == 2)
2435 pBuf->iTRNSgray >>= 8;
2436#endif
2437 break;
2438 }
2439 case 2: { /* rgb */
2440 pBuf->iTRNSred = ((mng_trnsp)pChunk)->iRed;
2441 pBuf->iTRNSgreen = ((mng_trnsp)pChunk)->iGreen;
2442 pBuf->iTRNSblue = ((mng_trnsp)pChunk)->iBlue;
2443#if defined(MNG_NO_16BIT_SUPPORT)
2444 if (pData->iPNGmult == 2)
2445 {
2446 pBuf->iTRNSred >>= 8;
2447 pBuf->iTRNSgreen >>= 8;
2448 pBuf->iTRNSblue >>= 8;
2449 }
2450#endif
2451 break;
2452 }
2453 case 3: { /* indexed */
2454 pBuf->iTRNScount = ((mng_trnsp)pChunk)->iCount;
2455 MNG_COPY (pBuf->aTRNSentries,
2456 ((mng_trnsp)pChunk)->aEntries,
2457 ((mng_trnsp)pChunk)->iCount);
2458 break;
2459 }
2460 }
2461 }
2462 else
2463#endif
2464 { /* address current object */
2465 pImage = (mng_imagep)pData->pCurrentobj;
2466
2467 if (!pImage) /* no object then dump it in obj 0 */
2468 pImage = (mng_imagep)pData->pObjzero;
2469
2470 pBuf = pImage->pImgbuf; /* address object buffer */
2471 pBuf->bHasTRNS = MNG_TRUE; /* and tell it it's got a tRNS now */
2472 pBuf->iTRNSgray = 0;
2473 pBuf->iTRNSred = 0;
2474 pBuf->iTRNSgreen = 0;
2475 pBuf->iTRNSblue = 0;
2476 pBuf->iTRNScount = 0;
2477
2478 if (((mng_trnsp)pChunk)->bEmpty) /* if empty, inherit from global */
2479 {
2480 iRawlen2 = pData->iGlobalTRNSrawlen;
2481 pRawdata2 = (mng_ptr)(pData->aGlobalTRNSrawdata);
2482 /* global length oke ? */
2483 if ((pData->iColortype == 0) && (iRawlen2 != 2))
2484 MNG_ERROR (pData, MNG_GLOBALLENGTHERR);
2485
2486 if ((pData->iColortype == 2) && (iRawlen2 != 6))
2487 MNG_ERROR (pData, MNG_GLOBALLENGTHERR);
2488
2489 if ((pData->iColortype == 3) && ((iRawlen2 == 0) || (iRawlen2 > pBuf->iPLTEcount)))
2490 MNG_ERROR (pData, MNG_GLOBALLENGTHERR);
2491
2492 switch (pData->iColortype) /* store fields for future reference */
2493 {
2494 case 0: { /* gray */
2495 pBuf->iTRNSgray = mng_get_uint16 (pRawdata2);
2496#if defined(MNG_NO_16BIT_SUPPORT)
2497 if (pData->iPNGmult == 2)
2498 pBuf->iTRNSgray >>= 8;
2499#endif
2500 break;
2501 }
2502 case 2: { /* rgb */
2503 pBuf->iTRNSred = mng_get_uint16 (pRawdata2);
2504 pBuf->iTRNSgreen = mng_get_uint16 (pRawdata2+2);
2505 pBuf->iTRNSblue = mng_get_uint16 (pRawdata2+4);
2506#if defined(MNG_NO_16BIT_SUPPORT)
2507 if (pData->iPNGmult == 2)
2508 {
2509 pBuf->iTRNSred >>= 8;
2510 pBuf->iTRNSgreen >>= 8;
2511 pBuf->iTRNSblue >>= 8;
2512 }
2513#endif
2514 break;
2515 }
2516 case 3: { /* indexed */
2517 pBuf->iTRNScount = iRawlen2;
2518 MNG_COPY (pBuf->aTRNSentries, pRawdata2, iRawlen2);
2519 break;
2520 }
2521 }
2522 }
2523 else
2524 {
2525 switch (pData->iColortype) /* store fields for future reference */
2526 {
2527 case 0: { /* gray */
2528 pBuf->iTRNSgray = ((mng_trnsp)pChunk)->iGray;
2529#if defined(MNG_NO_16BIT_SUPPORT)
2530 if (pData->iPNGmult == 2)
2531 pBuf->iTRNSgray >>= 8;
2532#endif
2533 break;
2534 }
2535 case 2: { /* rgb */
2536 pBuf->iTRNSred = ((mng_trnsp)pChunk)->iRed;
2537 pBuf->iTRNSgreen = ((mng_trnsp)pChunk)->iGreen;
2538 pBuf->iTRNSblue = ((mng_trnsp)pChunk)->iBlue;
2539#if defined(MNG_NO_16BIT_SUPPORT)
2540 if (pData->iPNGmult == 2)
2541 {
2542 pBuf->iTRNSred >>= 8;
2543 pBuf->iTRNSgreen >>= 8;
2544 pBuf->iTRNSblue >>= 8;
2545 }
2546#endif
2547 break;
2548 }
2549 case 3: { /* indexed */
2550 pBuf->iTRNScount = ((mng_trnsp)pChunk)->iCount;
2551 MNG_COPY (pBuf->aTRNSentries,
2552 ((mng_trnsp)pChunk)->aEntries,
2553 ((mng_trnsp)pChunk)->iCount);
2554 break;
2555 }
2556 }
2557 }
2558 }
2559 }
2560 else
2561 { /* create an animation object */
2562 return mng_create_ani_trns (pData);
2563 }
2564#endif /* MNG_SUPPORT_DISPLAY */
2565
2566 return MNG_NOERROR; /* done */
2567}
2568
2569/* ************************************************************************** */
2570
2571MNG_C_SPECIALFUNC (mng_special_gama)
2572{
2573#ifdef MNG_INCLUDE_JNG
2574 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
2575#else
2576 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2577#endif
2578 pData->bHasGAMA = MNG_TRUE; /* indicate we've got it */
2579 else
2580 pData->bHasglobalGAMA = (mng_bool)!((mng_gamap)pChunk)->bEmpty;
2581
2582#ifdef MNG_SUPPORT_DISPLAY
2583#ifdef MNG_INCLUDE_JNG
2584 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
2585#else
2586 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2587#endif
2588 {
2589 mng_imagep pImage;
2590
2591#ifndef MNG_NO_DELTA_PNG
2592 if (pData->bHasDHDR) /* update delta image ? */
2593 pImage = (mng_imagep)pData->pObjzero;
2594 else
2595#endif
2596 {
2597 pImage = (mng_imagep)pData->pCurrentobj;
2598 if (!pImage) /* no object then dump it in obj 0 */
2599 pImage = (mng_imagep)pData->pObjzero;
2600 }
2601 /* store for color-processing routines */
2602 pImage->pImgbuf->iGamma = ((mng_gamap)pChunk)->iGamma;
2603 pImage->pImgbuf->bHasGAMA = MNG_TRUE;
2604 }
2605 else
2606 { /* store as global */
2607 if (!((mng_gamap)pChunk)->bEmpty)
2608 pData->iGlobalGamma = ((mng_gamap)pChunk)->iGamma;
2609 /* create an animation object */
2610 return mng_create_ani_gama (pData, pChunk);
2611 }
2612#endif /* MNG_SUPPORT_DISPLAY */
2613
2614 return MNG_NOERROR; /* done */
2615}
2616
2617/* ************************************************************************** */
2618
2619#ifndef MNG_SKIPCHUNK_cHRM
2620MNG_C_SPECIALFUNC (mng_special_chrm)
2621{
2622#ifdef MNG_INCLUDE_JNG
2623 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
2624#else
2625 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2626#endif
2627 pData->bHasCHRM = MNG_TRUE; /* indicate we've got it */
2628 else
2629 pData->bHasglobalCHRM = (mng_bool)!((mng_chrmp)pChunk)->bEmpty;
2630
2631#ifdef MNG_SUPPORT_DISPLAY
2632 {
2633#ifdef MNG_INCLUDE_JNG
2634 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
2635#else
2636 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2637#endif
2638 {
2639 mng_imagep pImage;
2640 mng_imagedatap pBuf;
2641
2642#ifndef MNG_NO_DELTA_PNG
2643 if (pData->bHasDHDR) /* update delta image ? */
2644 pImage = (mng_imagep)pData->pObjzero;
2645 else
2646#endif
2647 {
2648 pImage = (mng_imagep)pData->pCurrentobj;
2649 if (!pImage) /* no object then dump it in obj 0 */
2650 pImage = (mng_imagep)pData->pObjzero;
2651 }
2652
2653 pBuf = pImage->pImgbuf; /* address object buffer */
2654 pBuf->bHasCHRM = MNG_TRUE; /* and tell it it's got a CHRM now */
2655 /* store for color-processing routines */
2656 pBuf->iWhitepointx = ((mng_chrmp)pChunk)->iWhitepointx;
2657 pBuf->iWhitepointy = ((mng_chrmp)pChunk)->iWhitepointy;
2658 pBuf->iPrimaryredx = ((mng_chrmp)pChunk)->iRedx;
2659 pBuf->iPrimaryredy = ((mng_chrmp)pChunk)->iRedy;
2660 pBuf->iPrimarygreenx = ((mng_chrmp)pChunk)->iGreenx;
2661 pBuf->iPrimarygreeny = ((mng_chrmp)pChunk)->iGreeny;
2662 pBuf->iPrimarybluex = ((mng_chrmp)pChunk)->iBluex;
2663 pBuf->iPrimarybluey = ((mng_chrmp)pChunk)->iBluey;
2664 }
2665 else
2666 { /* store as global */
2667 if (!((mng_chrmp)pChunk)->bEmpty)
2668 {
2669 pData->iGlobalWhitepointx = ((mng_chrmp)pChunk)->iWhitepointx;
2670 pData->iGlobalWhitepointy = ((mng_chrmp)pChunk)->iWhitepointy;
2671 pData->iGlobalPrimaryredx = ((mng_chrmp)pChunk)->iRedx;
2672 pData->iGlobalPrimaryredy = ((mng_chrmp)pChunk)->iRedy;
2673 pData->iGlobalPrimarygreenx = ((mng_chrmp)pChunk)->iGreenx;
2674 pData->iGlobalPrimarygreeny = ((mng_chrmp)pChunk)->iGreeny;
2675 pData->iGlobalPrimarybluex = ((mng_chrmp)pChunk)->iBluex;
2676 pData->iGlobalPrimarybluey = ((mng_chrmp)pChunk)->iBluey;
2677 }
2678 /* create an animation object */
2679 return mng_create_ani_chrm (pData, pChunk);
2680 }
2681 }
2682#endif /* MNG_SUPPORT_DISPLAY */
2683
2684 return MNG_NOERROR; /* done */
2685}
2686#endif
2687
2688/* ************************************************************************** */
2689
2690MNG_C_SPECIALFUNC (mng_special_srgb)
2691{
2692#ifdef MNG_INCLUDE_JNG
2693 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
2694#else
2695 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2696#endif
2697 pData->bHasSRGB = MNG_TRUE; /* indicate we've got it */
2698 else
2699 pData->bHasglobalSRGB = (mng_bool)!((mng_srgbp)pChunk)->bEmpty;
2700
2701#ifdef MNG_SUPPORT_DISPLAY
2702#ifdef MNG_INCLUDE_JNG
2703 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
2704#else
2705 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2706#endif
2707 {
2708 mng_imagep pImage;
2709
2710#ifndef MNG_NO_DELTA_PNG
2711 if (pData->bHasDHDR) /* update delta image ? */
2712 pImage = (mng_imagep)pData->pObjzero;
2713 else
2714#endif
2715 {
2716 pImage = (mng_imagep)pData->pCurrentobj;
2717 if (!pImage) /* no object then dump it in obj 0 */
2718 pImage = (mng_imagep)pData->pObjzero;
2719 }
2720 /* store for color-processing routines */
2721 pImage->pImgbuf->iRenderingintent = ((mng_srgbp)pChunk)->iRenderingintent;
2722 pImage->pImgbuf->bHasSRGB = MNG_TRUE;
2723 }
2724 else
2725 { /* store as global */
2726 if (!((mng_srgbp)pChunk)->bEmpty)
2727 pData->iGlobalRendintent = ((mng_srgbp)pChunk)->iRenderingintent;
2728 /* create an animation object */
2729 return mng_create_ani_srgb (pData, pChunk);
2730 }
2731#endif /* MNG_SUPPORT_DISPLAY */
2732
2733 return MNG_NOERROR; /* done */
2734}
2735
2736/* ************************************************************************** */
2737
2738#ifndef MNG_SKIPCHUNK_iCCP
2739MNG_C_SPECIALFUNC (mng_special_iccp)
2740{
2741 mng_retcode iRetcode;
2742 mng_chunk_headerp pDummy;
2743
2744#ifdef MNG_CHECK_BAD_ICCP /* Check for bad iCCP chunk */
2745 if (!strncmp (((mng_iccpp)pChunk)->zName, "Photoshop ICC profile", 21))
2746 {
2747 if (((mng_iccpp)pChunk)->iProfilesize == 2615) /* is it the sRGB profile ? */
2748 {
2749 mng_chunk_header chunk_srgb;
2750 mng_get_chunkheader (MNG_UINT_sRGB, &chunk_srgb);
2751 /* pretend it's an sRGB chunk then ! */
2752 iRetcode = mng_read_general (pData, &chunk_srgb, 1, (mng_ptr)"0", &pDummy);
2753 if (iRetcode) /* on error bail out */
2754 return iRetcode;
2755
2756 pDummy->fCleanup (pData, pDummy);
2757 }
2758 }
2759 else
2760 {
2761#endif /* MNG_CHECK_BAD_ICCP */
2762
2763#ifdef MNG_INCLUDE_JNG
2764 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
2765#else
2766 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2767#endif
2768 pData->bHasICCP = MNG_TRUE; /* indicate we've got it */
2769 else
2770 pData->bHasglobalICCP = (mng_bool)!((mng_iccpp)pChunk)->bEmpty;
2771
2772#ifdef MNG_SUPPORT_DISPLAY
2773#ifdef MNG_INCLUDE_JNG
2774 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
2775#else
2776 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2777#endif
2778 {
2779 mng_imagep pImage;
2780
2781#ifndef MNG_NO_DELTA_PNG
2782 if (pData->bHasDHDR) /* update delta image ? */
2783 { /* store in object 0 ! */
2784 pImage = (mng_imagep)pData->pObjzero;
2785
2786 if (pImage->pImgbuf->pProfile) /* profile existed ? */
2787 MNG_FREEX (pData, pImage->pImgbuf->pProfile, pImage->pImgbuf->iProfilesize);
2788 /* allocate a buffer & copy it */
2789 MNG_ALLOC (pData, pImage->pImgbuf->pProfile, ((mng_iccpp)pChunk)->iProfilesize);
2790 MNG_COPY (pImage->pImgbuf->pProfile, ((mng_iccpp)pChunk)->pProfile, ((mng_iccpp)pChunk)->iProfilesize);
2791 /* store its length as well */
2792 pImage->pImgbuf->iProfilesize = ((mng_iccpp)pChunk)->iProfilesize;
2793 pImage->pImgbuf->bHasICCP = MNG_TRUE;
2794 }
2795 else
2796#endif
2797 {
2798 pImage = (mng_imagep)pData->pCurrentobj;
2799
2800 if (!pImage) /* no object then dump it in obj 0 */
2801 pImage = (mng_imagep)pData->pObjzero;
2802
2803 if (pImage->pImgbuf->pProfile) /* profile existed ? */
2804 MNG_FREEX (pData, pImage->pImgbuf->pProfile, pImage->pImgbuf->iProfilesize);
2805 /* allocate a buffer & copy it */
2806 MNG_ALLOC (pData, pImage->pImgbuf->pProfile, ((mng_iccpp)pChunk)->iProfilesize);
2807 MNG_COPY (pImage->pImgbuf->pProfile, ((mng_iccpp)pChunk)->pProfile, ((mng_iccpp)pChunk)->iProfilesize);
2808 /* store its length as well */
2809 pImage->pImgbuf->iProfilesize = ((mng_iccpp)pChunk)->iProfilesize;
2810 pImage->pImgbuf->bHasICCP = MNG_TRUE;
2811 }
2812 }
2813 else
2814 { /* store as global */
2815 if (pData->pGlobalProfile) /* did we have a global profile ? */
2816 MNG_FREEX (pData, pData->pGlobalProfile, pData->iGlobalProfilesize);
2817
2818 if (((mng_iccpp)pChunk)->bEmpty) /* empty chunk ? */
2819 {
2820 pData->iGlobalProfilesize = 0; /* reset to null */
2821 pData->pGlobalProfile = MNG_NULL;
2822 }
2823 else
2824 { /* allocate a global buffer & copy it */
2825 MNG_ALLOC (pData, pData->pGlobalProfile, ((mng_iccpp)pChunk)->iProfilesize);
2826 MNG_COPY (pData->pGlobalProfile, ((mng_iccpp)pChunk)->pProfile, ((mng_iccpp)pChunk)->iProfilesize);
2827 /* store its length as well */
2828 pData->iGlobalProfilesize = ((mng_iccpp)pChunk)->iProfilesize;
2829 }
2830 /* create an animation object */
2831 return mng_create_ani_iccp (pData, pChunk);
2832 }
2833#endif /* MNG_SUPPORT_DISPLAY */
2834
2835#ifdef MNG_CHECK_BAD_ICCP
2836 }
2837#endif
2838
2839 return MNG_NOERROR; /* done */
2840}
2841#endif
2842
2843/* ************************************************************************** */
2844
2845#ifndef MNG_SKIPCHUNK_tEXt
2846MNG_C_SPECIALFUNC (mng_special_text)
2847{
2848 if (pData->fProcesstext) /* inform the application ? */
2849 {
2850 mng_bool bOke = pData->fProcesstext ((mng_handle)pData, MNG_TYPE_TEXT,
2851 ((mng_textp)pChunk)->zKeyword,
2852 ((mng_textp)pChunk)->zText, 0, 0);
2853 if (!bOke)
2854 MNG_ERROR (pData, MNG_APPMISCERROR);
2855 }
2856
2857 return MNG_NOERROR; /* done */
2858}
2859#endif
2860
2861/* ************************************************************************** */
2862
2863#ifndef MNG_SKIPCHUNK_zTXt
2864MNG_C_SPECIALFUNC (mng_special_ztxt)
2865{
2866 if (pData->fProcesstext) /* inform the application ? */
2867 {
2868 mng_bool bOke = pData->fProcesstext ((mng_handle)pData, MNG_TYPE_ZTXT,
2869 ((mng_ztxtp)pChunk)->zKeyword,
2870 ((mng_ztxtp)pChunk)->zText, 0, 0);
2871 if (!bOke)
2872 MNG_ERROR (pData, MNG_APPMISCERROR);
2873 }
2874
2875 return MNG_NOERROR; /* done */
2876}
2877#endif
2878
2879/* ************************************************************************** */
2880
2881#ifndef MNG_SKIPCHUNK_iTXt
2882MNG_F_SPECIALFUNC (mng_deflate_itxt)
2883{
2884 mng_itxtp pITXT = (mng_itxtp)pChunk;
2885 mng_uint32 iBufsize = 0;
2886 mng_uint8p pBuf = 0;
2887 mng_uint32 iTextlen = 0;
2888
2889 if (pITXT->iCompressionflag) /* decompress the text ? */
2890 {
2891 mng_retcode iRetcode = mng_inflate_buffer (pData, *ppRawdata, *piRawlen,
2892 &pBuf, &iBufsize, &iTextlen);
2893
2894 if (iRetcode) /* on error bail out */
2895 { /* don't forget to drop the temp buffer */
2896 MNG_FREEX (pData, pBuf, iBufsize);
2897 return iRetcode;
2898 }
2899
2900 MNG_ALLOC (pData, pITXT->zText, iTextlen+1);
2901 MNG_COPY (pITXT->zText, pBuf, iTextlen);
2902
2903 pITXT->iTextsize = iTextlen;
2904
2905 MNG_FREEX (pData, pBuf, iBufsize);
2906
2907 } else {
2908
2909 MNG_ALLOC (pData, pITXT->zText, (*piRawlen)+1);
2910 MNG_COPY (pITXT->zText, *ppRawdata, *piRawlen);
2911
2912 pITXT->iTextsize = *piRawlen;
2913 }
2914
2915 *piRawlen = 0;
2916
2917 return MNG_NOERROR;
2918}
2919#endif
2920
2921/* ************************************************************************** */
2922
2923#ifndef MNG_SKIPCHUNK_iTXt
2924MNG_C_SPECIALFUNC (mng_special_itxt)
2925{
2926 if (pData->fProcesstext) /* inform the application ? */
2927 {
2928 mng_bool bOke = pData->fProcesstext ((mng_handle)pData, MNG_TYPE_ITXT,
2929 ((mng_itxtp)pChunk)->zKeyword,
2930 ((mng_itxtp)pChunk)->zText,
2931 ((mng_itxtp)pChunk)->zLanguage,
2932 ((mng_itxtp)pChunk)->zTranslation);
2933 if (!bOke)
2934 MNG_ERROR (pData, MNG_APPMISCERROR);
2935 }
2936
2937 return MNG_NOERROR; /* done */
2938}
2939#endif
2940
2941/* ************************************************************************** */
2942
2943#ifndef MNG_SKIPCHUNK_bKGD
2944MNG_C_SPECIALFUNC (mng_special_bkgd)
2945{
2946#ifdef MNG_SUPPORT_DISPLAY
2947 mng_imagep pImage = (mng_imagep)pData->pCurrentobj;
2948 mng_imagedatap pBuf;
2949#endif
2950
2951#ifdef MNG_INCLUDE_JNG
2952 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR) || (pData->bHasJHDR))
2953#else
2954 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2955#endif
2956 pData->bHasBKGD = MNG_TRUE; /* indicate bKGD available */
2957 else
2958 pData->bHasglobalBKGD = (mng_bool)!(((mng_bkgdp)pChunk)->bEmpty);
2959
2960#ifdef MNG_SUPPORT_DISPLAY
2961 if (!pImage) /* if no object dump it in obj 0 */
2962 pImage = (mng_imagep)pData->pObjzero;
2963 pBuf = pImage->pImgbuf; /* address object buffer */
2964
2965#ifdef MNG_INCLUDE_JNG
2966 if (pData->bHasJHDR)
2967 {
2968 pBuf->bHasBKGD = MNG_TRUE; /* tell the object it's got bKGD now */
2969
2970 switch (pData->iJHDRcolortype) /* store fields for future reference */
2971 {
2972 case 8 : ; /* gray */
2973 case 12 : { /* graya */
2974 pBuf->iBKGDgray = ((mng_bkgdp)pChunk)->iGray;
2975 break;
2976 }
2977 case 10 : ; /* rgb */
2978 case 14 : { /* rgba */
2979 pBuf->iBKGDred = ((mng_bkgdp)pChunk)->iRed;
2980 pBuf->iBKGDgreen = ((mng_bkgdp)pChunk)->iGreen;
2981 pBuf->iBKGDblue = ((mng_bkgdp)pChunk)->iBlue;
2982 break;
2983 }
2984 }
2985 }
2986 else
2987#endif /* MNG_INCLUDE_JNG */
2988 if ((pData->bHasIHDR) || (pData->bHasBASI) || (pData->bHasDHDR))
2989 {
2990 pBuf->bHasBKGD = MNG_TRUE; /* tell the object it's got bKGD now */
2991
2992 switch (pData->iColortype) /* store fields for future reference */
2993 {
2994 case 0 : ; /* gray */
2995 case 4 : { /* graya */
2996 pBuf->iBKGDgray = ((mng_bkgdp)pChunk)->iGray;
2997 break;
2998 }
2999 case 2 : ; /* rgb */
3000 case 6 : { /* rgba */
3001 pBuf->iBKGDred = ((mng_bkgdp)pChunk)->iRed;
3002 pBuf->iBKGDgreen = ((mng_bkgdp)pChunk)->iGreen;
3003 pBuf->iBKGDblue = ((mng_bkgdp)pChunk)->iBlue;
3004 break;
3005 }
3006 case 3 : { /* indexed */
3007 pBuf->iBKGDindex = ((mng_bkgdp)pChunk)->iIndex;
3008 break;
3009 }
3010 }
3011 }
3012 else /* store as global */
3013 {
3014 if (!(((mng_bkgdp)pChunk)->bEmpty))
3015 {
3016 pData->iGlobalBKGDred = ((mng_bkgdp)pChunk)->iRed;
3017 pData->iGlobalBKGDgreen = ((mng_bkgdp)pChunk)->iGreen;
3018 pData->iGlobalBKGDblue = ((mng_bkgdp)pChunk)->iBlue;
3019 }
3020 /* create an animation object */
3021 return mng_create_ani_bkgd (pData);
3022 }
3023#endif /* MNG_SUPPORT_DISPLAY */
3024
3025 return MNG_NOERROR; /* done */
3026}
3027#endif
3028
3029/* ************************************************************************** */
3030
3031#ifndef MNG_SKIPCHUNK_pHYs
3032MNG_C_SPECIALFUNC (mng_special_phys)
3033{
3034#ifdef MNG_SUPPORT_DISPLAY
3035 {
3036
3037
3038 /* TODO: something !!! */
3039
3040
3041 }
3042#endif /* MNG_SUPPORT_DISPLAY */
3043
3044 return MNG_NOERROR; /* done */
3045}
3046#endif
3047
3048/* ************************************************************************** */
3049
3050#ifndef MNG_SKIPCHUNK_sBIT
3051MNG_C_SPECIALFUNC (mng_special_sbit)
3052{
3053#ifdef MNG_SUPPORT_DISPLAY
3054 {
3055
3056
3057 /* TODO: something !!! */
3058
3059
3060 }
3061#endif /* MNG_SUPPORT_DISPLAY */
3062
3063 return MNG_NOERROR; /* done */
3064}
3065#endif
3066
3067/* ************************************************************************** */
3068
3069#ifndef MNG_SKIPCHUNK_sPLT
3070MNG_F_SPECIALFUNC (mng_splt_entries)
3071{
3072 mng_spltp pSPLT = (mng_spltp)pChunk;
3073 mng_uint32 iRawlen = *piRawlen;
3074 mng_uint8p pRawdata = *ppRawdata;
3075
3076 if ((pSPLT->iSampledepth != MNG_BITDEPTH_8 ) &&
3077 (pSPLT->iSampledepth != MNG_BITDEPTH_16) )
3078 MNG_ERROR (pData, MNG_INVSAMPLEDEPTH);
3079 /* check remaining length */
3080 if ( ((pSPLT->iSampledepth == MNG_BITDEPTH_8 ) && (iRawlen % 6 != 0)) ||
3081 ((pSPLT->iSampledepth == MNG_BITDEPTH_16) && (iRawlen % 10 != 0)) )
3082 MNG_ERROR (pData, MNG_INVALIDLENGTH);
3083
3084 if (pSPLT->iSampledepth == MNG_BITDEPTH_8)
3085 pSPLT->iEntrycount = iRawlen / 6;
3086 else
3087 pSPLT->iEntrycount = iRawlen / 10;
3088
3089 if (iRawlen)
3090 {
3091 MNG_ALLOC (pData, pSPLT->pEntries, iRawlen);
3092 MNG_COPY (pSPLT->pEntries, pRawdata, iRawlen);
3093 }
3094
3095 *piRawlen = 0;
3096
3097 return MNG_NOERROR;
3098}
3099#endif
3100
3101/* ************************************************************************** */
3102
3103#ifndef MNG_SKIPCHUNK_sPLT
3104MNG_C_SPECIALFUNC (mng_special_splt)
3105{
3106#ifdef MNG_SUPPORT_DISPLAY
3107 {
3108
3109
3110 /* TODO: something !!! */
3111
3112
3113 }
3114#endif /* MNG_SUPPORT_DISPLAY */
3115
3116 return MNG_NOERROR; /* done */
3117}
3118#endif
3119
3120/* ************************************************************************** */
3121
3122#ifndef MNG_SKIPCHUNK_hIST
3123MNG_F_SPECIALFUNC (mng_hist_entries)
3124{
3125 mng_histp pHIST = (mng_histp)pChunk;
3126 mng_uint32 iRawlen = *piRawlen;
3127 mng_uint8p pRawdata = *ppRawdata;
3128 mng_uint32 iX;
3129
3130 if ( ((iRawlen & 0x01) != 0) || ((iRawlen >> 1) != pData->iPLTEcount) )
3131 MNG_ERROR (pData, MNG_INVALIDLENGTH);
3132
3133 pHIST->iEntrycount = iRawlen >> 1;
3134
3135 for (iX = 0; iX < pHIST->iEntrycount; iX++)
3136 {
3137 pHIST->aEntries[iX] = mng_get_uint16 (pRawdata);
3138 pRawdata += 2;
3139 }
3140
3141 *piRawlen = 0;
3142
3143 return MNG_NOERROR;
3144}
3145#endif
3146
3147/* ************************************************************************** */
3148
3149#ifndef MNG_SKIPCHUNK_hIST
3150MNG_C_SPECIALFUNC (mng_special_hist)
3151{
3152#ifdef MNG_SUPPORT_DISPLAY
3153 {
3154
3155
3156 /* TODO: something !!! */
3157
3158
3159 }
3160#endif /* MNG_SUPPORT_DISPLAY */
3161
3162 return MNG_NOERROR; /* done */
3163}
3164#endif
3165
3166/* ************************************************************************** */
3167
3168#ifndef MNG_SKIPCHUNK_tIME
3169MNG_C_SPECIALFUNC (mng_special_time)
3170{
3171/* if (pData->fProcesstime) */ /* inform the application ? */
3172/* {
3173
3174 pData->fProcesstime ((mng_handle)pData, );
3175 } */
3176
3177 return MNG_NOERROR; /* done */
3178}
3179#endif
3180
3181/* ************************************************************************** */
3182/* ************************************************************************** */
3183/* JNG chunks */
3184
3185#ifdef MNG_INCLUDE_JNG
3186MNG_C_SPECIALFUNC (mng_special_jhdr)
3187{
3188 if ((pData->eSigtype == mng_it_jng) && (pData->iChunkseq > 1))
3189 MNG_ERROR (pData, MNG_SEQUENCEERROR);
3190 /* inside a JHDR-IEND block now */
3191 pData->bHasJHDR = MNG_TRUE;
3192 /* and store interesting fields */
3193 pData->iDatawidth = ((mng_jhdrp)pChunk)->iWidth;
3194 pData->iDataheight = ((mng_jhdrp)pChunk)->iHeight;
3195 pData->iJHDRcolortype = ((mng_jhdrp)pChunk)->iColortype;
3196 pData->iJHDRimgbitdepth = ((mng_jhdrp)pChunk)->iImagesampledepth;
3197 pData->iJHDRimgcompression = ((mng_jhdrp)pChunk)->iImagecompression;
3198 pData->iJHDRimginterlace = ((mng_jhdrp)pChunk)->iImageinterlace;
3199 pData->iJHDRalphabitdepth = ((mng_jhdrp)pChunk)->iAlphasampledepth;
3200 pData->iJHDRalphacompression = ((mng_jhdrp)pChunk)->iAlphacompression;
3201 pData->iJHDRalphafilter = ((mng_jhdrp)pChunk)->iAlphafilter;
3202 pData->iJHDRalphainterlace = ((mng_jhdrp)pChunk)->iAlphainterlace;
3203
3204#if defined(MNG_NO_1_2_4BIT_SUPPORT) || defined(MNG_NO_16BIT_SUPPORT)
3205 pData->iPNGmult = 1;
3206 pData->iPNGdepth = pData->iJHDRalphabitdepth;
3207#endif
3208
3209#ifdef MNG_NO_1_2_4BIT_SUPPORT
3210 if (pData->iJHDRalphabitdepth < 8)
3211 pData->iJHDRalphabitdepth = 8;
3212#endif
3213
3214#ifdef MNG_NO_16BIT_SUPPORT
3215 if (pData->iJHDRalphabitdepth > 8)
3216 {
3217 pData->iPNGmult = 2;
3218 pData->iJHDRalphabitdepth = 8;
3219 }
3220#endif
3221 /* parameter validity checks */
3222 if ((pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAY ) &&
3223 (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLOR ) &&
3224 (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGGRAYA ) &&
3225 (pData->iJHDRcolortype != MNG_COLORTYPE_JPEGCOLORA) )
3226 MNG_ERROR (pData, MNG_INVALIDCOLORTYPE);
3227
3228 if ((pData->iJHDRimgbitdepth != MNG_BITDEPTH_JPEG8 ) &&
3229 (pData->iJHDRimgbitdepth != MNG_BITDEPTH_JPEG12 ) &&
3230 (pData->iJHDRimgbitdepth != MNG_BITDEPTH_JPEG8AND12) )
3231 MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
3232
3233 if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) ||
3234 (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) )
3235 {
3236 if ((pData->iJHDRalphabitdepth != MNG_BITDEPTH_8 )
3237#ifndef MNG_NO_1_2_4BIT_SUPPORT
3238 && (pData->iJHDRalphabitdepth != MNG_BITDEPTH_1 ) &&
3239 (pData->iJHDRalphabitdepth != MNG_BITDEPTH_2 ) &&
3240 (pData->iJHDRalphabitdepth != MNG_BITDEPTH_4 )
3241#endif
3242#ifndef MNG_NO_16BIT_SUPPORT
3243 && (pData->iJHDRalphabitdepth != MNG_BITDEPTH_16)
3244#endif
3245 )
3246 MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
3247
3248 if ((pData->iJHDRalphacompression != MNG_COMPRESSION_DEFLATE ) &&
3249 (pData->iJHDRalphacompression != MNG_COMPRESSION_BASELINEJPEG) )
3250 MNG_ERROR (pData, MNG_INVALIDCOMPRESS);
3251
3252 if ((pData->iJHDRalphacompression == MNG_COMPRESSION_BASELINEJPEG) &&
3253 (pData->iJHDRalphabitdepth != MNG_BITDEPTH_8 ) )
3254 MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
3255
3256#if defined(FILTER192) || defined(FILTER193)
3257 if ((pData->iJHDRalphafilter != MNG_FILTER_ADAPTIVE ) &&
3258#if defined(FILTER192) && defined(FILTER193)
3259 (pData->iJHDRalphafilter != MNG_FILTER_DIFFERING) &&
3260 (pData->iJHDRalphafilter != MNG_FILTER_NOFILTER ) )
3261#else
3262#ifdef FILTER192
3263 (pData->iJHDRalphafilter != MNG_FILTER_DIFFERING) )
3264#else
3265 (pData->iJHDRalphafilter != MNG_FILTER_NOFILTER ) )
3266#endif
3267#endif
3268 MNG_ERROR (pData, MNG_INVALIDFILTER);
3269#else
3270 if (pData->iJHDRalphafilter)
3271 MNG_ERROR (pData, MNG_INVALIDFILTER);
3272#endif
3273
3274 }
3275 else
3276 {
3277 if (pData->iJHDRalphabitdepth)
3278 MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
3279 if (pData->iJHDRalphacompression)
3280 MNG_ERROR (pData, MNG_INVALIDCOMPRESS);
3281 if (pData->iJHDRalphafilter)
3282 MNG_ERROR (pData, MNG_INVALIDFILTER);
3283 if (pData->iJHDRalphainterlace)
3284 MNG_ERROR (pData, MNG_INVALIDINTERLACE);
3285 }
3286
3287 if (!pData->bHasheader) /* first chunk ? */
3288 {
3289 pData->bHasheader = MNG_TRUE; /* we've got a header */
3290 pData->eImagetype = mng_it_jng; /* then this must be a JNG */
3291 pData->iWidth = ((mng_jhdrp)pChunk)->iWidth;
3292 pData->iHeight = ((mng_jhdrp)pChunk)->iHeight;
3293 /* predict alpha-depth ! */
3294 if ((pData->iJHDRcolortype == MNG_COLORTYPE_JPEGGRAYA ) ||
3295 (pData->iJHDRcolortype == MNG_COLORTYPE_JPEGCOLORA) )
3296 pData->iAlphadepth = pData->iJHDRalphabitdepth;
3297 else
3298 pData->iAlphadepth = 0;
3299 /* fits on maximum canvas ? */
3300 if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight))
3301 MNG_WARNING (pData, MNG_IMAGETOOLARGE);
3302
3303 if (pData->fProcessheader) /* inform the app ? */
3304 if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight))
3305 MNG_ERROR (pData, MNG_APPMISCERROR);
3306
3307 }
3308
3309 pData->iColortype = 0; /* fake grayscale for other routines */
3310 pData->iImagelevel++; /* one level deeper */
3311
3312#ifdef MNG_SUPPORT_DISPLAY
3313 {
3314 mng_retcode iRetcode = mng_process_display_jhdr (pData);
3315 if (iRetcode) /* on error bail out */
3316 return iRetcode;
3317 }
3318#endif /* MNG_SUPPORT_DISPLAY */
3319
3320#ifdef MNG_NO_16BIT_SUPPORT
3321 if (((mng_jhdrp)pChunk)->iAlphasampledepth > 8)
3322 ((mng_jhdrp)pChunk)->iAlphasampledepth = 8;
3323#endif
3324
3325 return MNG_NOERROR; /* done */
3326}
3327#endif /* MNG_INCLUDE_JNG */
3328
3329/* ************************************************************************** */
3330
3331#ifdef MNG_INCLUDE_JNG
3332MNG_C_SPECIALFUNC (mng_special_jdaa)
3333{
3334 if (pData->iJHDRalphacompression != MNG_COMPRESSION_BASELINEJPEG)
3335 MNG_ERROR (pData, MNG_SEQUENCEERROR);
3336
3337 pData->bHasJDAA = MNG_TRUE; /* got some JDAA now, don't we */
3338 return MNG_NOERROR;
3339}
3340#endif /* MNG_INCLUDE_JNG */
3341
3342/* ************************************************************************** */
3343
3344#ifdef MNG_INCLUDE_JNG
3345MNG_C_SPECIALFUNC (mng_special_jdat)
3346{
3347 pData->bHasJDAT = MNG_TRUE; /* got some JDAT now, don't we */
3348 return MNG_NOERROR;
3349}
3350#endif /* MNG_INCLUDE_JNG */
3351
3352/* ************************************************************************** */
3353
3354#ifdef MNG_INCLUDE_JNG
3355MNG_C_SPECIALFUNC (mng_special_jsep)
3356{
3357 pData->bHasJSEP = MNG_TRUE; /* indicate we've had the 8-/12-bit separator */
3358 return MNG_NOERROR;
3359}
3360#endif /* MNG_INCLUDE_JNG */
3361
3362/* ************************************************************************** */
3363/* ************************************************************************** */
3364/* MNG chunks */
3365
3366MNG_C_SPECIALFUNC (mng_special_mhdr)
3367{
3368 if (pData->bHasheader) /* can only be the first chunk! */
3369 MNG_ERROR (pData, MNG_SEQUENCEERROR);
3370
3371 pData->bHasMHDR = MNG_TRUE; /* oh boy, a real MNG */
3372 pData->bHasheader = MNG_TRUE; /* we've got a header */
3373 pData->eImagetype = mng_it_mng; /* fill header fields */
3374 pData->iWidth = ((mng_mhdrp)pChunk)->iWidth;
3375 pData->iHeight = ((mng_mhdrp)pChunk)->iHeight;
3376 pData->iTicks = ((mng_mhdrp)pChunk)->iTicks;
3377 pData->iLayercount = ((mng_mhdrp)pChunk)->iLayercount;
3378 pData->iFramecount = ((mng_mhdrp)pChunk)->iFramecount;
3379 pData->iPlaytime = ((mng_mhdrp)pChunk)->iPlaytime;
3380 pData->iSimplicity = ((mng_mhdrp)pChunk)->iSimplicity;
3381#ifndef MNG_NO_OLD_VERSIONS
3382 pData->bPreDraft48 = MNG_FALSE;
3383#endif
3384 /* predict alpha-depth */
3385 if ((pData->iSimplicity & 0x00000001) == 0)
3386#ifndef MNG_NO_16BIT_SUPPORT
3387 pData->iAlphadepth = 16; /* no indicators = assume the worst */
3388#else
3389 pData->iAlphadepth = 8; /* anything else = assume the worst */
3390#endif
3391 else
3392 if ((pData->iSimplicity & 0x00000008) == 0)
3393 pData->iAlphadepth = 0; /* no transparency at all */
3394 else
3395 if ((pData->iSimplicity & 0x00000140) == 0x00000040)
3396 pData->iAlphadepth = 1; /* no semi-transparency guaranteed */
3397 else
3398#ifndef MNG_NO_16BIT_SUPPORT
3399 pData->iAlphadepth = 16; /* anything else = assume the worst */
3400#else
3401 pData->iAlphadepth = 8; /* anything else = assume the worst */
3402#endif
3403
3404#ifdef MNG_INCLUDE_JNG /* can we handle the complexity ? */
3405 if (pData->iSimplicity & 0x0000FC00)
3406#else
3407 if (pData->iSimplicity & 0x0000FC10)
3408#endif
3409 MNG_ERROR (pData, MNG_MNGTOOCOMPLEX);
3410 /* fits on maximum canvas ? */
3411 if ((pData->iWidth > pData->iMaxwidth) || (pData->iHeight > pData->iMaxheight))
3412 MNG_WARNING (pData, MNG_IMAGETOOLARGE);
3413
3414 if (pData->fProcessheader) /* inform the app ? */
3415 if (!pData->fProcessheader (((mng_handle)pData), pData->iWidth, pData->iHeight))
3416 MNG_ERROR (pData, MNG_APPMISCERROR);
3417
3418 pData->iImagelevel++; /* one level deeper */
3419
3420 return MNG_NOERROR; /* done */
3421}
3422
3423/* ************************************************************************** */
3424
3425MNG_C_SPECIALFUNC (mng_special_mend)
3426{
3427#ifdef MNG_SUPPORT_DISPLAY
3428 { /* do something */
3429 mng_retcode iRetcode = mng_process_display_mend (pData);
3430
3431 if (iRetcode) /* on error bail out */
3432 return iRetcode;
3433
3434 if (!pData->iTotalframes) /* save totals */
3435 pData->iTotalframes = pData->iFrameseq;
3436 if (!pData->iTotallayers)
3437 pData->iTotallayers = pData->iLayerseq;
3438 if (!pData->iTotalplaytime)
3439 pData->iTotalplaytime = pData->iFrametime;
3440 }
3441#endif /* MNG_SUPPORT_DISPLAY */
3442
3443 pData->bHasMHDR = MNG_FALSE; /* end of the line, bro! */
3444
3445 return MNG_NOERROR; /* done */
3446}
3447
3448/* ************************************************************************** */
3449
3450#ifndef MNG_SKIPCHUNK_LOOP
3451MNG_F_SPECIALFUNC (mng_debunk_loop)
3452{
3453 mng_loopp pLOOP = (mng_loopp)pChunk;
3454 mng_uint32 iRawlen = *piRawlen;
3455 mng_uint8p pRawdata = *ppRawdata;
3456
3457 if (iRawlen >= 5) /* length checks */
3458 {
3459 if (iRawlen >= 6)
3460 {
3461 if ((iRawlen - 6) % 4 != 0)
3462 MNG_ERROR (pData, MNG_INVALIDLENGTH);
3463 }
3464 }
3465 else
3466 MNG_ERROR (pData, MNG_INVALIDLENGTH);
3467
3468 if (iRawlen >= 5) /* store the fields */
3469 {
3470 pLOOP->iLevel = *pRawdata;
3471
3472#ifndef MNG_NO_OLD_VERSIONS
3473 if (pData->bPreDraft48)
3474 {
3475 pLOOP->iTermination = *(pRawdata+1);
3476 pLOOP->iRepeat = mng_get_uint32 (pRawdata+2);
3477 }
3478 else
3479#endif
3480 {
3481 pLOOP->iRepeat = mng_get_uint32 (pRawdata+1);
3482 }
3483
3484 if (iRawlen >= 6)
3485 {
3486#ifndef MNG_NO_OLD_VERSIONS
3487 if (!pData->bPreDraft48)
3488#endif
3489 pLOOP->iTermination = *(pRawdata+5);
3490
3491 if (iRawlen >= 10)
3492 {
3493 pLOOP->iItermin = mng_get_uint32 (pRawdata+6);
3494
3495#ifndef MNG_NO_LOOP_SIGNALS_SUPPORTED
3496 if (iRawlen >= 14)
3497 {
3498 pLOOP->iItermax = mng_get_uint32 (pRawdata+10);
3499 pLOOP->iCount = (iRawlen - 14) / 4;
3500
3501 if (pLOOP->iCount)
3502 {
3503 MNG_ALLOC (pData, pLOOP->pSignals, pLOOP->iCount << 2);
3504
3505#ifndef MNG_BIGENDIAN_SUPPORTED
3506 {
3507 mng_uint32 iX;
3508 mng_uint8p pIn = pRawdata + 14;
3509 mng_uint32p pOut = (mng_uint32p)pLOOP->pSignals;
3510
3511 for (iX = 0; iX < pLOOP->iCount; iX++)
3512 {
3513 *pOut++ = mng_get_uint32 (pIn);
3514 pIn += 4;
3515 }
3516 }
3517#else
3518 MNG_COPY (pLOOP->pSignals, pRawdata + 14, pLOOP->iCount << 2);
3519#endif /* !MNG_BIGENDIAN_SUPPORTED */
3520 }
3521 }
3522#endif
3523 }
3524 }
3525 }
3526
3527 *piRawlen = 0;
3528
3529 return MNG_NOERROR;
3530}
3531#endif
3532
3533/* ************************************************************************** */
3534
3535#ifndef MNG_SKIPCHUNK_LOOP
3536MNG_C_SPECIALFUNC (mng_special_loop)
3537{
3538 if (!pData->bCacheplayback) /* must store playback info to work!! */
3539 MNG_ERROR (pData, MNG_LOOPWITHCACHEOFF);
3540
3541#ifdef MNG_SUPPORT_DISPLAY
3542 {
3543 mng_retcode iRetcode;
3544
3545 pData->bHasLOOP = MNG_TRUE; /* indicate we're inside a loop */
3546 /* create the LOOP ani-object */
3547 iRetcode = mng_create_ani_loop (pData, pChunk);
3548 if (iRetcode) /* on error bail out */
3549 return iRetcode;
3550 /* skip till matching ENDL if iteration=0 */
3551 if ((!pData->bSkipping) && (((mng_loopp)pChunk)->iRepeat == 0))
3552 pData->bSkipping = MNG_TRUE;
3553 }
3554#endif /* MNG_SUPPORT_DISPLAY */
3555
3556 return MNG_NOERROR; /* done */
3557}
3558#endif
3559
3560/* ************************************************************************** */
3561
3562#ifndef MNG_SKIPCHUNK_LOOP
3563MNG_C_SPECIALFUNC (mng_special_endl)
3564{
3565#ifdef MNG_SUPPORT_DISPLAY
3566 if (pData->bHasLOOP) /* are we really processing a loop ? */
3567 {
3568 mng_uint8 iLevel = ((mng_endlp)pChunk)->iLevel;
3569 /* create an ENDL animation object */
3570 return mng_create_ani_endl (pData, iLevel);
3571 }
3572 else
3573 MNG_ERROR (pData, MNG_NOMATCHINGLOOP);
3574#endif /* MNG_SUPPORT_DISPLAY */
3575
3576 return MNG_NOERROR; /* done */
3577}
3578#endif
3579
3580/* ************************************************************************** */
3581
3582#ifndef MNG_SKIPCHUNK_DEFI
3583MNG_C_SPECIALFUNC (mng_special_defi)
3584{
3585#ifdef MNG_SUPPORT_DISPLAY
3586 mng_retcode iRetcode;
3587
3588 pData->iDEFIobjectid = ((mng_defip)pChunk)->iObjectid;
3589 pData->bDEFIhasdonotshow = ((mng_defip)pChunk)->bHasdonotshow;
3590 pData->iDEFIdonotshow = ((mng_defip)pChunk)->iDonotshow;
3591 pData->bDEFIhasconcrete = ((mng_defip)pChunk)->bHasconcrete;
3592 pData->iDEFIconcrete = ((mng_defip)pChunk)->iConcrete;
3593 pData->bDEFIhasloca = ((mng_defip)pChunk)->bHasloca;
3594 pData->iDEFIlocax = ((mng_defip)pChunk)->iXlocation;
3595 pData->iDEFIlocay = ((mng_defip)pChunk)->iYlocation;
3596 pData->bDEFIhasclip = ((mng_defip)pChunk)->bHasclip;
3597 pData->iDEFIclipl = ((mng_defip)pChunk)->iLeftcb;
3598 pData->iDEFIclipr = ((mng_defip)pChunk)->iRightcb;
3599 pData->iDEFIclipt = ((mng_defip)pChunk)->iTopcb;
3600 pData->iDEFIclipb = ((mng_defip)pChunk)->iBottomcb;
3601 /* create an animation object */
3602 iRetcode = mng_create_ani_defi (pData);
3603 if (!iRetcode) /* do display processing */
3604 iRetcode = mng_process_display_defi (pData);
3605 return iRetcode;
3606#else
3607 return MNG_NOERROR; /* done */
3608#endif /* MNG_SUPPORT_DISPLAY */
3609}
3610#endif
3611
3612/* ************************************************************************** */
3613
3614#ifndef MNG_SKIPCHUNK_BASI
3615MNG_C_SPECIALFUNC (mng_special_basi)
3616{
3617 pData->bHasBASI = MNG_TRUE; /* inside a BASI-IEND block now */
3618 /* store interesting fields */
3619 pData->iDatawidth = ((mng_basip)pChunk)->iWidth;
3620 pData->iDataheight = ((mng_basip)pChunk)->iHeight;
3621 pData->iBitdepth = ((mng_basip)pChunk)->iBitdepth;
3622 pData->iColortype = ((mng_basip)pChunk)->iColortype;
3623 pData->iCompression = ((mng_basip)pChunk)->iCompression;
3624 pData->iFilter = ((mng_basip)pChunk)->iFilter;
3625 pData->iInterlace = ((mng_basip)pChunk)->iInterlace;
3626
3627#if defined(MNG_NO_1_2_4BIT_SUPPORT) || defined(MNG_NO_16BIT_SUPPORT)
3628 pData->iPNGmult = 1;
3629 pData->iPNGdepth = pData->iBitdepth;
3630#endif
3631
3632#ifdef MNG_NO_1_2_4BIT_SUPPORT
3633 if (pData->iBitdepth < 8)
3634 pData->iBitdepth = 8;
3635#endif
3636#ifdef MNG_NO_16BIT_SUPPORT
3637 if (pData->iBitdepth > 8)
3638 {
3639 pData->iBitdepth = 8;
3640 pData->iPNGmult = 2;
3641 }
3642#endif
3643
3644 if ((pData->iBitdepth != 8) /* parameter validity checks */
3645#ifndef MNG_NO_1_2_4BIT_SUPPORT
3646 && (pData->iBitdepth != 1) &&
3647 (pData->iBitdepth != 2) &&
3648 (pData->iBitdepth != 4)
3649#endif
3650#ifndef MNG_NO_16BIT_SUPPORT
3651 && (pData->iBitdepth != 16)
3652#endif
3653 )
3654 MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
3655
3656 if ((pData->iColortype != MNG_COLORTYPE_GRAY ) &&
3657 (pData->iColortype != MNG_COLORTYPE_RGB ) &&
3658 (pData->iColortype != MNG_COLORTYPE_INDEXED) &&
3659 (pData->iColortype != MNG_COLORTYPE_GRAYA ) &&
3660 (pData->iColortype != MNG_COLORTYPE_RGBA ) )
3661 MNG_ERROR (pData, MNG_INVALIDCOLORTYPE);
3662
3663 if ((pData->iColortype == MNG_COLORTYPE_INDEXED) && (pData->iBitdepth > 8))
3664 MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
3665
3666 if (((pData->iColortype == MNG_COLORTYPE_RGB ) ||
3667 (pData->iColortype == MNG_COLORTYPE_GRAYA ) ||
3668 (pData->iColortype == MNG_COLORTYPE_RGBA ) ) &&
3669 (pData->iBitdepth < 8 ) )
3670 MNG_ERROR (pData, MNG_INVALIDBITDEPTH);
3671
3672#if defined(FILTER192) || defined(FILTER193)
3673 if ((pData->iFilter != MNG_FILTER_ADAPTIVE ) &&
3674#if defined(FILTER192) && defined(FILTER193)
3675 (pData->iFilter != MNG_FILTER_DIFFERING) &&
3676 (pData->iFilter != MNG_FILTER_NOFILTER ) )
3677#else
3678#ifdef FILTER192
3679 (pData->iFilter != MNG_FILTER_DIFFERING) )
3680#else
3681 (pData->iFilter != MNG_FILTER_NOFILTER ) )
3682#endif
3683#endif
3684 MNG_ERROR (pData, MNG_INVALIDFILTER);
3685#else
3686 if (pData->iFilter)
3687 MNG_ERROR (pData, MNG_INVALIDFILTER);
3688#endif
3689
3690 pData->iImagelevel++; /* one level deeper */
3691
3692#ifdef MNG_SUPPORT_DISPLAY
3693 { /* create an animation object */
3694 mng_retcode iRetcode = mng_create_ani_basi (pData, pChunk);
3695 if (iRetcode) /* on error bail out */
3696 return iRetcode;
3697 }
3698#endif /* MNG_SUPPORT_DISPLAY */
3699
3700#ifdef MNG_NO_16BIT_SUPPORT
3701 if (((mng_basip)pChunk)->iBitdepth > 8)
3702 ((mng_basip)pChunk)->iBitdepth = 8;
3703#endif
3704
3705 return MNG_NOERROR; /* done */
3706}
3707#endif
3708
3709/* ************************************************************************** */
3710
3711#ifndef MNG_SKIPCHUNK_CLON
3712MNG_C_SPECIALFUNC (mng_special_clon)
3713{
3714#ifdef MNG_SUPPORT_DISPLAY
3715 return mng_create_ani_clon (pData, pChunk);
3716#else
3717 return MNG_NOERROR; /* done */
3718#endif /* MNG_SUPPORT_DISPLAY */
3719}
3720#endif
3721
3722/* ************************************************************************** */
3723
3724#ifndef MNG_SKIPCHUNK_PAST
3725MNG_F_SPECIALFUNC (mng_debunk_past)
3726{
3727 mng_pastp pPAST = (mng_pastp)pChunk;
3728 mng_uint32 iRawlen = *piRawlen;
3729 mng_uint8p pRawdata = *ppRawdata;
3730 mng_uint32 iSize;
3731 mng_uint32 iX;
3732 mng_past_sourcep pSource;
3733 /* check the length */
3734 if ((iRawlen < 41) || (((iRawlen - 11) % 30) != 0))
3735 MNG_ERROR (pData, MNG_INVALIDLENGTH);
3736
3737 pPAST->iDestid = mng_get_uint16 (pRawdata);
3738 pPAST->iTargettype = *(pRawdata+2);
3739 pPAST->iTargetx = mng_get_int32 (pRawdata+3);
3740 pPAST->iTargety = mng_get_int32 (pRawdata+7);
3741 pPAST->iCount = ((iRawlen - 11) / 30); /* how many entries again? */
3742 iSize = pPAST->iCount * sizeof (mng_past_source);
3743
3744 pRawdata += 11;
3745 /* get a buffer for all the source blocks */
3746 MNG_ALLOC (pData, pPAST->pSources, iSize);
3747
3748 pSource = (mng_past_sourcep)(pPAST->pSources);
3749
3750 for (iX = pPAST->iCount; iX > 0; iX--)
3751 { /* now copy the source blocks */
3752 pSource->iSourceid = mng_get_uint16 (pRawdata);
3753 pSource->iComposition = *(pRawdata+2);
3754 pSource->iOrientation = *(pRawdata+3);
3755 pSource->iOffsettype = *(pRawdata+4);
3756 pSource->iOffsetx = mng_get_int32 (pRawdata+5);
3757 pSource->iOffsety = mng_get_int32 (pRawdata+9);
3758 pSource->iBoundarytype = *(pRawdata+13);
3759 pSource->iBoundaryl = mng_get_int32 (pRawdata+14);
3760 pSource->iBoundaryr = mng_get_int32 (pRawdata+18);
3761 pSource->iBoundaryt = mng_get_int32 (pRawdata+22);
3762 pSource->iBoundaryb = mng_get_int32 (pRawdata+26);
3763
3764 pSource++;
3765 pRawdata += 30;
3766 }
3767
3768 *piRawlen = 0;
3769
3770 return MNG_NOERROR;
3771}
3772#endif
3773
3774/* ************************************************************************** */
3775
3776#ifndef MNG_SKIPCHUNK_PAST
3777MNG_C_SPECIALFUNC (mng_special_past)
3778{
3779#ifdef MNG_SUPPORT_DISPLAY
3780 return mng_create_ani_past (pData, pChunk);
3781#else
3782 return MNG_NOERROR;
3783#endif /* MNG_SUPPORT_DISPLAY */
3784}
3785#endif
3786
3787/* ************************************************************************** */
3788
3789#ifndef MNG_SKIPCHUNK_DISC
3790MNG_F_SPECIALFUNC (mng_disc_entries)
3791{
3792 mng_discp pDISC = (mng_discp)pChunk;
3793 mng_uint32 iRawlen = *piRawlen;
3794 mng_uint8p pRawdata = *ppRawdata;
3795
3796 if ((iRawlen % 2) != 0) /* check the length */
3797 MNG_ERROR (pData, MNG_INVALIDLENGTH);
3798
3799 pDISC->iCount = (iRawlen / sizeof (mng_uint16));
3800
3801 if (pDISC->iCount)
3802 {
3803 MNG_ALLOC (pData, pDISC->pObjectids, iRawlen);
3804
3805#ifndef MNG_BIGENDIAN_SUPPORTED
3806 {
3807 mng_uint32 iX;
3808 mng_uint8p pIn = pRawdata;
3809 mng_uint16p pOut = pDISC->pObjectids;
3810
3811 for (iX = pDISC->iCount; iX > 0; iX--)
3812 {
3813 *pOut++ = mng_get_uint16 (pIn);
3814 pIn += 2;
3815 }
3816 }
3817#else
3818 MNG_COPY (pDISC->pObjectids, pRawdata, iRawlen);
3819#endif /* !MNG_BIGENDIAN_SUPPORTED */
3820 }
3821
3822 *piRawlen = 0;
3823
3824 return MNG_NOERROR;
3825}
3826#endif
3827
3828/* ************************************************************************** */
3829
3830#ifndef MNG_SKIPCHUNK_DISC
3831MNG_C_SPECIALFUNC (mng_special_disc)
3832{
3833#ifdef MNG_SUPPORT_DISPLAY
3834 return mng_create_ani_disc (pData, pChunk);
3835#else
3836 return MNG_NOERROR;
3837#endif /* MNG_SUPPORT_DISPLAY */
3838}
3839#endif
3840
3841/* ************************************************************************** */
3842
3843#ifndef MNG_SKIPCHUNK_BACK
3844MNG_C_SPECIALFUNC (mng_special_back)
3845{
3846#ifdef MNG_SUPPORT_DISPLAY
3847 /* retrieve the fields */
3848 pData->bHasBACK = MNG_TRUE;
3849 pData->iBACKred = ((mng_backp)pChunk)->iRed;
3850 pData->iBACKgreen = ((mng_backp)pChunk)->iGreen;
3851 pData->iBACKblue = ((mng_backp)pChunk)->iBlue;
3852 pData->iBACKmandatory = ((mng_backp)pChunk)->iMandatory;
3853 pData->iBACKimageid = ((mng_backp)pChunk)->iImageid;
3854 pData->iBACKtile = ((mng_backp)pChunk)->iTile;
3855
3856 return mng_create_ani_back (pData);
3857#else
3858 return MNG_NOERROR;
3859#endif /* MNG_SUPPORT_DISPLAY */
3860}
3861#endif
3862
3863/* ************************************************************************** */
3864
3865#ifndef MNG_SKIPCHUNK_FRAM
3866MNG_F_SPECIALFUNC (mng_fram_remainder)
3867{
3868 mng_framp pFRAM = (mng_framp)pChunk;
3869 mng_uint32 iRawlen = *piRawlen;
3870 mng_uint8p pRawdata = *ppRawdata;
3871 mng_uint32 iRequired = 0;
3872
3873 if (iRawlen < 4) /* must have at least 4 bytes */
3874 MNG_ERROR (pData, MNG_INVALIDLENGTH);
3875
3876 iRequired = 4; /* calculate and check required remaining length */
3877
3878 pFRAM->iChangedelay = *pRawdata;
3879 pFRAM->iChangetimeout = *(pRawdata+1);
3880 pFRAM->iChangeclipping = *(pRawdata+2);
3881 pFRAM->iChangesyncid = *(pRawdata+3);
3882
3883 if (pFRAM->iChangedelay ) { iRequired += 4; }
3884 if (pFRAM->iChangetimeout ) { iRequired += 4; }
3885 if (pFRAM->iChangeclipping) { iRequired += 17; }
3886
3887 if (pFRAM->iChangesyncid)
3888 {
3889 if ((iRawlen - iRequired) % 4 != 0)
3890 MNG_ERROR (pData, MNG_INVALIDLENGTH);
3891 }
3892 else
3893 {
3894 if (iRawlen != iRequired)
3895 MNG_ERROR (pData, MNG_INVALIDLENGTH);
3896 }
3897
3898 pRawdata += 4;
3899
3900 if (pFRAM->iChangedelay) /* delay changed ? */
3901 {
3902 pFRAM->iDelay = mng_get_uint32 (pRawdata);
3903 pRawdata += 4;
3904 }
3905
3906 if (pFRAM->iChangetimeout) /* timeout changed ? */
3907 {
3908 pFRAM->iTimeout = mng_get_uint32 (pRawdata);
3909 pRawdata += 4;
3910 }
3911
3912 if (pFRAM->iChangeclipping) /* clipping changed ? */
3913 {
3914 pFRAM->iBoundarytype = *pRawdata;
3915 pFRAM->iBoundaryl = mng_get_int32 (pRawdata+1);
3916 pFRAM->iBoundaryr = mng_get_int32 (pRawdata+5);
3917 pFRAM->iBoundaryt = mng_get_int32 (pRawdata+9);
3918 pFRAM->iBoundaryb = mng_get_int32 (pRawdata+13);
3919 pRawdata += 17;
3920 }
3921
3922 if (pFRAM->iChangesyncid)
3923 {
3924 pFRAM->iCount = (iRawlen - iRequired) / 4;
3925
3926 if (pFRAM->iCount)
3927 {
3928 MNG_ALLOC (pData, pFRAM->pSyncids, pFRAM->iCount * 4);
3929
3930#ifndef MNG_BIGENDIAN_SUPPORTED
3931 {
3932 mng_uint32 iX;
3933 mng_uint32p pOut = pFRAM->pSyncids;
3934
3935 for (iX = pFRAM->iCount; iX > 0; iX--)
3936 {
3937 *pOut++ = mng_get_uint32 (pRawdata);
3938 pRawdata += 4;
3939 }
3940 }
3941#else
3942 MNG_COPY (pFRAM->pSyncids, pRawdata, pFRAM->iCount * 4);
3943#endif /* !MNG_BIGENDIAN_SUPPORTED */
3944 }
3945 }
3946
3947#ifndef MNG_NO_OLD_VERSIONS
3948 if (pData->bPreDraft48) /* old style input-stream ? */
3949 {
3950 switch (pFRAM->iMode) /* fix the framing mode then */
3951 {
3952 case 0: { break; }
3953 case 1: { pFRAM->iMode = 3; break; }
3954 case 2: { pFRAM->iMode = 4; break; }
3955 case 3: { pFRAM->iMode = 1; break; }
3956 case 4: { pFRAM->iMode = 1; break; }
3957 case 5: { pFRAM->iMode = 2; break; }
3958 default: { pFRAM->iMode = 1; break; }
3959 }
3960 }
3961#endif
3962
3963 *piRawlen = 0;
3964
3965 return MNG_NOERROR;
3966}
3967#endif
3968
3969/* ************************************************************************** */
3970
3971#ifndef MNG_SKIPCHUNK_FRAM
3972MNG_C_SPECIALFUNC (mng_special_fram)
3973{
3974#ifdef MNG_SUPPORT_DISPLAY
3975 return mng_create_ani_fram (pData, pChunk);
3976#else
3977 return MNG_NOERROR;
3978#endif /* MNG_SUPPORT_DISPLAY */
3979}
3980#endif
3981
3982/* ************************************************************************** */
3983
3984#ifndef MNG_SKIPCHUNK_MOVE
3985MNG_C_SPECIALFUNC (mng_special_move)
3986{
3987#ifdef MNG_SUPPORT_DISPLAY
3988 return mng_create_ani_move (pData, pChunk);
3989#else
3990 return MNG_NOERROR;
3991#endif /* MNG_SUPPORT_DISPLAY */
3992}
3993#endif
3994
3995/* ************************************************************************** */
3996
3997#ifndef MNG_SKIPCHUNK_CLIP
3998MNG_C_SPECIALFUNC (mng_special_clip)
3999{
4000#ifdef MNG_SUPPORT_DISPLAY
4001 return mng_create_ani_clip (pData, pChunk);
4002#else
4003 return MNG_NOERROR;
4004#endif /* MNG_SUPPORT_DISPLAY */
4005}
4006#endif
4007
4008/* ************************************************************************** */
4009
4010#ifndef MNG_SKIPCHUNK_SHOW
4011MNG_C_SPECIALFUNC (mng_special_show)
4012{
4013#ifdef MNG_SUPPORT_DISPLAY
4014 mng_retcode iRetcode;
4015
4016 if (!((mng_showp)pChunk)->bEmpty) /* any data ? */
4017 {
4018 if (!((mng_showp)pChunk)->bHaslastid)
4019 ((mng_showp)pChunk)->iLastid = ((mng_showp)pChunk)->iFirstid;
4020
4021 pData->iSHOWfromid = ((mng_showp)pChunk)->iFirstid;
4022 pData->iSHOWtoid = ((mng_showp)pChunk)->iLastid;
4023 pData->iSHOWmode = ((mng_showp)pChunk)->iMode;
4024 }
4025 else /* use defaults then */
4026 {
4027 pData->iSHOWfromid = 1;
4028 pData->iSHOWtoid = 65535;
4029 pData->iSHOWmode = 2;
4030 }
4031 /* create a SHOW animation object */
4032 iRetcode = mng_create_ani_show (pData);
4033 if (!iRetcode) /* go and do it! */
4034 iRetcode = mng_process_display_show (pData);
4035
4036#endif /* MNG_SUPPORT_DISPLAY */
4037
4038 return iRetcode;
4039}
4040#endif
4041
4042/* ************************************************************************** */
4043
4044#ifndef MNG_SKIPCHUNK_TERM
4045MNG_C_SPECIALFUNC (mng_special_term)
4046{
4047 /* should be behind MHDR or SAVE !! */
4048 if ((!pData->bHasSAVE) && (pData->iChunkseq > 2))
4049 {
4050 pData->bMisplacedTERM = MNG_TRUE; /* indicate we found a misplaced TERM */
4051 /* and send a warning signal!!! */
4052 MNG_WARNING (pData, MNG_SEQUENCEERROR);
4053 }
4054
4055 pData->bHasTERM = MNG_TRUE;
4056
4057 if (pData->fProcessterm) /* inform the app ? */
4058 if (!pData->fProcessterm (((mng_handle)pData),
4059 ((mng_termp)pChunk)->iTermaction,
4060 ((mng_termp)pChunk)->iIteraction,
4061 ((mng_termp)pChunk)->iDelay,
4062 ((mng_termp)pChunk)->iItermax))
4063 MNG_ERROR (pData, MNG_APPMISCERROR);
4064
4065#ifdef MNG_SUPPORT_DISPLAY
4066 { /* create the TERM ani-object */
4067 mng_retcode iRetcode = mng_create_ani_term (pData, pChunk);
4068 if (iRetcode) /* on error bail out */
4069 return iRetcode;
4070 /* save for future reference */
4071 pData->pTermaniobj = pData->pLastaniobj;
4072 }
4073#endif /* MNG_SUPPORT_DISPLAY */
4074
4075 return MNG_NOERROR; /* done */
4076}
4077#endif
4078
4079/* ************************************************************************** */
4080
4081#ifndef MNG_SKIPCHUNK_SAVE
4082MNG_F_SPECIALFUNC (mng_save_entries)
4083{
4084 mng_savep pSAVE = (mng_savep)pChunk;
4085 mng_uint32 iRawlen = *piRawlen;
4086 mng_uint8p pRawdata = *ppRawdata;
4087 mng_save_entryp pEntry = MNG_NULL;
4088 mng_uint32 iCount = 0;
4089 mng_uint8 iOtype = *pRawdata;
4090 mng_uint8 iEtype;
4091 mng_uint8p pTemp;
4092 mng_uint8p pNull;
4093 mng_uint32 iLen;
4094 mng_uint32 iOffset[2];
4095 mng_uint32 iStarttime[2];
4096 mng_uint32 iFramenr;
4097 mng_uint32 iLayernr;
4098 mng_uint32 iX;
4099 mng_uint32 iNamesize;
4100
4101 if ((iOtype != 4) && (iOtype != 8))
4102 MNG_ERROR (pData, MNG_INVOFFSETSIZE);
4103
4104 pSAVE->iOffsettype = iOtype;
4105
4106 for (iX = 0; iX < 2; iX++) /* do this twice to get the count first ! */
4107 {
4108 pTemp = pRawdata + 1;
4109 iLen = iRawlen - 1;
4110
4111 if (iX) /* second run ? */
4112 {
4113 MNG_ALLOC (pData, pEntry, (iCount * sizeof (mng_save_entry)));
4114
4115 pSAVE->iCount = iCount;
4116 pSAVE->pEntries = pEntry;
4117 }
4118
4119 while (iLen) /* anything left ? */
4120 {
4121 iEtype = *pTemp; /* entrytype */
4122
4123 if ((iEtype != 0) && (iEtype != 1) && (iEtype != 2) && (iEtype != 3))
4124 MNG_ERROR (pData, MNG_INVENTRYTYPE);
4125
4126 pTemp++;
4127
4128 if (iEtype > 1)
4129 {
4130 iOffset [0] = 0;
4131 iOffset [1] = 0;
4132 iStarttime [0] = 0;
4133 iStarttime [1] = 0;
4134 iLayernr = 0;
4135 iFramenr = 0;
4136 }
4137 else
4138 {
4139 if (iOtype == 4)
4140 {
4141 iOffset [0] = 0;
4142 iOffset [1] = mng_get_uint32 (pTemp);
4143
4144 pTemp += 4;
4145 }
4146 else
4147 {
4148 iOffset [0] = mng_get_uint32 (pTemp);
4149 iOffset [1] = mng_get_uint32 (pTemp+4);
4150
4151 pTemp += 8;
4152 }
4153
4154 if (iEtype > 0)
4155 {
4156 iStarttime [0] = 0;
4157 iStarttime [1] = 0;
4158 iLayernr = 0;
4159 iFramenr = 0;
4160 }
4161 else
4162 {
4163 if (iOtype == 4)
4164 {
4165 iStarttime [0] = 0;
4166 iStarttime [1] = mng_get_uint32 (pTemp+0);
4167 iLayernr = mng_get_uint32 (pTemp+4);
4168 iFramenr = mng_get_uint32 (pTemp+8);
4169
4170 pTemp += 12;
4171 }
4172 else
4173 {
4174 iStarttime [0] = mng_get_uint32 (pTemp+0);
4175 iStarttime [1] = mng_get_uint32 (pTemp+4);
4176 iLayernr = mng_get_uint32 (pTemp+8);
4177 iFramenr = mng_get_uint32 (pTemp+12);
4178
4179 pTemp += 16;
4180 }
4181 }
4182 }
4183
4184 pNull = pTemp; /* get the name length */
4185 while (*pNull)
4186 pNull++;
4187
4188 if ((pNull - pRawdata) > (mng_int32)iRawlen)
4189 {
4190 iNamesize = iLen; /* no null found; so end of SAVE */
4191 iLen = 0;
4192 }
4193 else
4194 {
4195 iNamesize = pNull - pTemp; /* should be another entry */
4196 iLen -= iNamesize;
4197
4198 if (!iLen) /* must not end with a null ! */
4199 MNG_ERROR (pData, MNG_ENDWITHNULL);
4200 }
4201
4202 if (!pEntry)
4203 {
4204 iCount++;
4205 }
4206 else
4207 {
4208 pEntry->iEntrytype = iEtype;
4209 pEntry->iOffset [0] = iOffset [0];
4210 pEntry->iOffset [1] = iOffset [1];
4211 pEntry->iStarttime [0] = iStarttime [0];
4212 pEntry->iStarttime [1] = iStarttime [1];
4213 pEntry->iLayernr = iLayernr;
4214 pEntry->iFramenr = iFramenr;
4215 pEntry->iNamesize = iNamesize;
4216
4217 if (iNamesize)
4218 {
4219 MNG_ALLOC (pData, pEntry->zName, iNamesize+1);
4220 MNG_COPY (pEntry->zName, pTemp, iNamesize);
4221 }
4222
4223 pEntry++;
4224 }
4225
4226 pTemp += iNamesize;
4227 }
4228 }
4229
4230 *piRawlen = 0;
4231
4232 return MNG_NOERROR;
4233}
4234#endif
4235
4236/* ************************************************************************** */
4237
4238#ifndef MNG_SKIPCHUNK_SAVE
4239MNG_C_SPECIALFUNC (mng_special_save)
4240{
4241 pData->bHasSAVE = MNG_TRUE;
4242
4243 if (pData->fProcesssave) /* inform the application ? */
4244 {
4245 mng_bool bOke = pData->fProcesssave ((mng_handle)pData);
4246 if (!bOke)
4247 MNG_ERROR (pData, MNG_APPMISCERROR);
4248 }
4249
4250#ifdef MNG_SUPPORT_DISPLAY
4251 {
4252 mng_retcode iRetcode;
4253
4254 /* TODO: something with the parameters */
4255
4256 /* create a SAVE animation object */
4257 iRetcode = mng_create_ani_save (pData);
4258 if (!iRetcode) /* process it */
4259 iRetcode = mng_process_display_save (pData);
4260 if (iRetcode) /* on error bail out */
4261 return iRetcode;
4262 }
4263#endif /* MNG_SUPPORT_DISPLAY */
4264
4265 return MNG_NOERROR; /* done */
4266}
4267#endif
4268
4269/* ************************************************************************** */
4270
4271#ifndef MNG_SKIPCHUNK_SEEK
4272MNG_C_SPECIALFUNC (mng_special_seek)
4273{
4274 mng_retcode iRetcode;
4275
4276#ifdef MNG_SUPPORT_DISPLAY
4277 /* create a SEEK animation object */
4278 iRetcode = mng_create_ani_seek (pData, pChunk);
4279 if (iRetcode) /* on error bail out */
4280 return iRetcode;
4281
4282#endif /* MNG_SUPPORT_DISPLAY */
4283
4284 if (pData->fProcessseek) /* inform the app ? */
4285 if (!pData->fProcessseek ((mng_handle)pData, ((mng_seekp)pChunk)->zName))
4286 MNG_ERROR (pData, MNG_APPMISCERROR);
4287
4288#ifdef MNG_SUPPORT_DISPLAY
4289 return mng_process_display_seek (pData);
4290#else
4291 return MNG_NOERROR;
4292#endif /* MNG_SUPPORT_DISPLAY */
4293}
4294#endif
4295
4296/* ************************************************************************** */
4297
4298#ifndef MNG_SKIPCHUNK_eXPI
4299MNG_C_SPECIALFUNC (mng_special_expi)
4300{
4301#ifdef MNG_SUPPORT_DISPLAY
4302 {
4303
4304
4305 /* TODO: something !!! */
4306
4307
4308 }
4309#endif /* MNG_SUPPORT_DISPLAY */
4310
4311 return MNG_NOERROR; /* done */
4312}
4313#endif
4314
4315/* ************************************************************************** */
4316
4317#ifndef MNG_SKIPCHUNK_fPRI
4318MNG_C_SPECIALFUNC (mng_special_fpri)
4319{
4320#ifdef MNG_SUPPORT_DISPLAY
4321 {
4322
4323
4324 /* TODO: something !!! */
4325
4326
4327 }
4328#endif /* MNG_SUPPORT_DISPLAY */
4329
4330 return MNG_NOERROR; /* done */
4331}
4332#endif
4333
4334/* ************************************************************************** */
4335
4336#ifndef MNG_SKIPCHUNK_nEED
4337MNG_LOCAL mng_bool CheckKeyword (mng_datap pData,
4338 mng_uint8p pKeyword)
4339{
4340 mng_chunkid handled_chunks [] =
4341 {
4342 MNG_UINT_BACK, /* keep it sorted !!!! */
4343 MNG_UINT_BASI,
4344 MNG_UINT_CLIP,
4345 MNG_UINT_CLON,
4346#ifndef MNG_NO_DELTA_PNG
4347/* TODO: MNG_UINT_DBYK, */
4348#endif
4349 MNG_UINT_DEFI,
4350#ifndef MNG_NO_DELTA_PNG
4351 MNG_UINT_DHDR,
4352#endif
4353 MNG_UINT_DISC,
4354#ifndef MNG_NO_DELTA_PNG
4355/* TODO: MNG_UINT_DROP, */
4356#endif
4357 MNG_UINT_ENDL,
4358 MNG_UINT_FRAM,
4359 MNG_UINT_IDAT,
4360 MNG_UINT_IEND,
4361 MNG_UINT_IHDR,
4362#ifndef MNG_NO_DELTA_PNG
4363#ifdef MNG_INCLUDE_JNG
4364 MNG_UINT_IJNG,
4365#endif
4366 MNG_UINT_IPNG,
4367#endif
4368#ifdef MNG_INCLUDE_JNG
4369 MNG_UINT_JDAA,
4370 MNG_UINT_JDAT,
4371 MNG_UINT_JHDR,
4372/* TODO: MNG_UINT_JSEP, */
4373 MNG_UINT_JdAA,
4374#endif
4375 MNG_UINT_LOOP,
4376 MNG_UINT_MAGN,
4377 MNG_UINT_MEND,
4378 MNG_UINT_MHDR,
4379 MNG_UINT_MOVE,
4380/* TODO: MNG_UINT_ORDR, */
4381 MNG_UINT_PAST,
4382 MNG_UINT_PLTE,
4383#ifndef MNG_NO_DELTA_PNG
4384 MNG_UINT_PPLT,
4385 MNG_UINT_PROM,
4386#endif
4387 MNG_UINT_SAVE,
4388 MNG_UINT_SEEK,
4389 MNG_UINT_SHOW,
4390 MNG_UINT_TERM,
4391 MNG_UINT_bKGD,
4392 MNG_UINT_cHRM,
4393/* TODO: MNG_UINT_eXPI, */
4394 MNG_UINT_evNT,
4395/* TODO: MNG_UINT_fPRI, */
4396 MNG_UINT_gAMA,
4397/* TODO: MNG_UINT_hIST, */
4398 MNG_UINT_iCCP,
4399 MNG_UINT_iTXt,
4400 MNG_UINT_nEED,
4401/* TODO: MNG_UINT_oFFs, */
4402/* TODO: MNG_UINT_pCAL, */
4403/* TODO: MNG_UINT_pHYg, */
4404/* TODO: MNG_UINT_pHYs, */
4405/* TODO: MNG_UINT_sBIT, */
4406/* TODO: MNG_UINT_sCAL, */
4407/* TODO: MNG_UINT_sPLT, */
4408 MNG_UINT_sRGB,
4409 MNG_UINT_tEXt,
4410 MNG_UINT_tIME,
4411 MNG_UINT_tRNS,
4412 MNG_UINT_zTXt,
4413 };
4414
4415 mng_bool bOke = MNG_FALSE;
4416
4417 if (pData->fProcessneed) /* does the app handle it ? */
4418 bOke = pData->fProcessneed ((mng_handle)pData, (mng_pchar)pKeyword);
4419
4420 if (!bOke)
4421 { /* find the keyword length */
4422 mng_uint8p pNull = pKeyword;
4423 while (*pNull)
4424 pNull++;
4425
4426 if ((pNull - pKeyword) == 4) /* test a chunk ? */
4427 { /* get the chunk-id */
4428 mng_chunkid iChunkid = (*pKeyword << 24) + (*(pKeyword+1) << 16) +
4429 (*(pKeyword+2) << 8) + (*(pKeyword+3) );
4430 /* binary search variables */
4431 mng_int32 iTop, iLower, iUpper, iMiddle;
4432 /* determine max index of table */
4433 iTop = (sizeof (handled_chunks) / sizeof (handled_chunks [0])) - 1;
4434
4435 /* binary search; with 52 chunks, worst-case is 7 comparisons */
4436 iLower = 0;
4437 iMiddle = iTop >> 1;
4438 iUpper = iTop;
4439
4440 do /* the binary search itself */
4441 {
4442 if (handled_chunks [iMiddle] < iChunkid)
4443 iLower = iMiddle + 1;
4444 else if (handled_chunks [iMiddle] > iChunkid)
4445 iUpper = iMiddle - 1;
4446 else
4447 {
4448 bOke = MNG_TRUE;
4449 break;
4450 }
4451
4452 iMiddle = (iLower + iUpper) >> 1;
4453 }
4454 while (iLower <= iUpper);
4455 }
4456 /* test draft ? */
4457 if ((!bOke) && ((pNull - pKeyword) == 8) &&
4458 (*pKeyword == 'd') && (*(pKeyword+1) == 'r') &&
4459 (*(pKeyword+2) == 'a') && (*(pKeyword+3) == 'f') &&
4460 (*(pKeyword+4) == 't') && (*(pKeyword+5) == ' '))
4461 {
4462 mng_uint32 iDraft;
4463
4464 iDraft = (*(pKeyword+6) - '0') * 10 + (*(pKeyword+7) - '0');
4465 bOke = (mng_bool)(iDraft <= MNG_MNG_DRAFT);
4466 }
4467 /* test MNG 1.0/1.1 ? */
4468 if ((!bOke) && ((pNull - pKeyword) == 7) &&
4469 (*pKeyword == 'M') && (*(pKeyword+1) == 'N') &&
4470 (*(pKeyword+2) == 'G') && (*(pKeyword+3) == '-') &&
4471 (*(pKeyword+4) == '1') && (*(pKeyword+5) == '.') &&
4472 ((*(pKeyword+6) == '0') || (*(pKeyword+6) == '1')))
4473 bOke = MNG_TRUE;
4474 /* test CACHEOFF ? */
4475 if ((!bOke) && ((pNull - pKeyword) == 8) &&
4476 (*pKeyword == 'C') && (*(pKeyword+1) == 'A') &&
4477 (*(pKeyword+2) == 'C') && (*(pKeyword+3) == 'H') &&
4478 (*(pKeyword+4) == 'E') && (*(pKeyword+5) == 'O') &&
4479 (*(pKeyword+6) == 'F') && (*(pKeyword+7) == 'F'))
4480 {
4481 if (!pData->pFirstaniobj) /* only if caching hasn't started yet ! */
4482 {
4483 bOke = MNG_TRUE;
4484 pData->bCacheplayback = MNG_FALSE;
4485 pData->bStorechunks = MNG_FALSE;
4486 }
4487 }
4488 }
4489
4490 return bOke;
4491}
4492#endif
4493
4494/* ************************************************************************** */
4495
4496#ifndef MNG_SKIPCHUNK_nEED
4497MNG_C_SPECIALFUNC (mng_special_need)
4498{
4499 /* let's check it */
4500 mng_bool bOke = MNG_TRUE;
4501 mng_uint8p pNull, pTemp, pMax;
4502
4503 pTemp = (mng_uint8p)((mng_needp)pChunk)->zKeywords;
4504 pMax = (mng_uint8p)(pTemp + ((mng_needp)pChunk)->iKeywordssize);
4505 pNull = pTemp;
4506 while (*pNull)
4507 pNull++;
4508
4509 while ((bOke) && (pNull < pMax))
4510 {
4511 bOke = CheckKeyword (pData, pTemp);
4512 pTemp = pNull + 1;
4513 pNull = pTemp;
4514 while (*pNull)
4515 pNull++;
4516 }
4517
4518 if (bOke)
4519 bOke = CheckKeyword (pData, pTemp);
4520
4521 if (!bOke)
4522 MNG_ERROR (pData, MNG_UNSUPPORTEDNEED);
4523
4524 return MNG_NOERROR; /* done */
4525}
4526#endif
4527
4528/* ************************************************************************** */
4529
4530#ifndef MNG_SKIPCHUNK_pHYg
4531MNG_C_SPECIALFUNC (mng_special_phyg)
4532{
4533#ifdef MNG_SUPPORT_DISPLAY
4534 {
4535
4536
4537 /* TODO: something !!! */
4538
4539
4540 }
4541#endif /* MNG_SUPPORT_DISPLAY */
4542
4543 return MNG_NOERROR; /* done */
4544}
4545#endif
4546
4547/* ************************************************************************** */
4548
4549#ifndef MNG_NO_DELTA_PNG
4550MNG_C_SPECIALFUNC (mng_special_dhdr)
4551{
4552 if ((((mng_dhdrp)pChunk)->iDeltatype == MNG_DELTATYPE_REPLACE) && (((mng_dhdrp)pChunk)->bHasblockloc))
4553 MNG_ERROR (pData, MNG_INVALIDLENGTH);
4554 if ((((mng_dhdrp)pChunk)->iDeltatype == MNG_DELTATYPE_NOCHANGE) && (((mng_dhdrp)pChunk)->bHasblocksize))
4555 MNG_ERROR (pData, MNG_INVALIDLENGTH);
4556
4557 pData->bHasDHDR = MNG_TRUE; /* inside a DHDR-IEND block now */
4558 pData->iDeltatype = ((mng_dhdrp)pChunk)->iDeltatype;
4559
4560 pData->iImagelevel++; /* one level deeper */
4561
4562#ifdef MNG_SUPPORT_DISPLAY
4563 return mng_create_ani_dhdr (pData, pChunk);
4564#else
4565 return MNG_NOERROR;
4566#endif /* MNG_SUPPORT_DISPLAY */
4567}
4568#endif
4569
4570/* ************************************************************************** */
4571
4572#ifndef MNG_NO_DELTA_PNG
4573MNG_C_SPECIALFUNC (mng_special_prom)
4574{
4575 if ((((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_GRAY ) &&
4576 (((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_RGB ) &&
4577 (((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_INDEXED) &&
4578 (((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_GRAYA ) &&
4579 (((mng_promp)pChunk)->iColortype != MNG_COLORTYPE_RGBA ) )
4580 MNG_ERROR (pData, MNG_INVALIDCOLORTYPE);
4581
4582#ifdef MNG_NO_16BIT_SUPPORT
4583 if (((mng_promp)pChunk)->iSampledepth == MNG_BITDEPTH_16 )
4584 ((mng_promp)pChunk)->iSampledepth = MNG_BITDEPTH_8;
4585#endif
4586
4587 if ((((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_1 ) &&
4588 (((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_2 ) &&
4589 (((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_4 ) &&
4590 (((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_8 )
4591#ifndef MNG_NO_16BIT_SUPPORT
4592 && (((mng_promp)pChunk)->iSampledepth != MNG_BITDEPTH_16)
4593#endif
4594 )
4595 MNG_ERROR (pData, MNG_INVSAMPLEDEPTH);
4596
4597#ifdef MNG_SUPPORT_DISPLAY
4598 {
4599 mng_retcode iRetcode = mng_create_ani_prom (pData, pChunk);
4600 if (iRetcode) /* on error bail out */
4601 return iRetcode;
4602 }
4603#endif /* MNG_SUPPORT_DISPLAY */
4604
4605 return MNG_NOERROR; /* done */
4606}
4607#endif
4608
4609/* ************************************************************************** */
4610
4611#ifndef MNG_NO_DELTA_PNG
4612MNG_C_SPECIALFUNC (mng_special_ipng)
4613{
4614#ifdef MNG_SUPPORT_DISPLAY
4615 mng_retcode iRetcode = mng_create_ani_ipng (pData);
4616 if (!iRetcode) /* process it */
4617 iRetcode = mng_process_display_ipng (pData);
4618 if (iRetcode) /* on error bail out */
4619 return iRetcode;
4620#endif /* MNG_SUPPORT_DISPLAY */
4621
4622 return MNG_NOERROR; /* done */
4623}
4624#endif
4625
4626/* ************************************************************************** */
4627
4628#ifndef MNG_NO_DELTA_PNG
4629MNG_F_SPECIALFUNC (mng_pplt_entries)
4630{
4631 mng_ppltp pPPLT = (mng_ppltp)pChunk;
4632 mng_uint32 iRawlen = *piRawlen;
4633 mng_uint8p pRawdata = *ppRawdata;
4634 mng_uint8 iDeltatype = pPPLT->iDeltatype;
4635 mng_uint32 iMax = 0;
4636 mng_int32 iX, iY, iM;
4637 mng_rgbpaltab aIndexentries;
4638 mng_uint8arr aAlphaentries;
4639 mng_uint8arr aUsedentries;
4640 /* must be indexed color ! */
4641 if (pData->iColortype != MNG_COLORTYPE_INDEXED)
4642 MNG_ERROR (pData, MNG_INVALIDCOLORTYPE);
4643
4644 for (iY = 255; iY >= 0; iY--) /* reset arrays */
4645 {
4646 aIndexentries [iY].iRed = 0;
4647 aIndexentries [iY].iGreen = 0;
4648 aIndexentries [iY].iBlue = 0;
4649 aAlphaentries [iY] = 255;
4650 aUsedentries [iY] = 0;
4651 }
4652
4653 while (iRawlen) /* as long as there are entries left ... */
4654 {
4655 mng_uint32 iDiff;
4656
4657 if (iRawlen < 2)
4658 MNG_ERROR (pData, MNG_INVALIDLENGTH);
4659
4660 iX = (mng_int32)(*pRawdata); /* get start and end index */
4661 iM = (mng_int32)(*(pRawdata+1));
4662
4663 if (iM < iX)
4664 MNG_ERROR (pData, MNG_INVALIDINDEX);
4665
4666 if (iM >= (mng_int32) iMax) /* determine highest used index */
4667 iMax = iM + 1;
4668
4669 pRawdata += 2;
4670 iRawlen -= 2;
4671 iDiff = (iM - iX + 1);
4672 if ((iDeltatype == MNG_DELTATYPE_REPLACERGB ) ||
4673 (iDeltatype == MNG_DELTATYPE_DELTARGB ) )
4674 iDiff = iDiff * 3;
4675 else
4676 if ((iDeltatype == MNG_DELTATYPE_REPLACERGBA) ||
4677 (iDeltatype == MNG_DELTATYPE_DELTARGBA ) )
4678 iDiff = iDiff * 4;
4679
4680 if (iRawlen < iDiff)
4681 MNG_ERROR (pData, MNG_INVALIDLENGTH);
4682
4683 if ((iDeltatype == MNG_DELTATYPE_REPLACERGB ) ||
4684 (iDeltatype == MNG_DELTATYPE_DELTARGB ) )
4685 {
4686 for (iY = iX; iY <= iM; iY++)
4687 {
4688 aIndexentries [iY].iRed = *pRawdata;
4689 aIndexentries [iY].iGreen = *(pRawdata+1);
4690 aIndexentries [iY].iBlue = *(pRawdata+2);
4691 aUsedentries [iY] = 1;
4692
4693 pRawdata += 3;
4694 iRawlen -= 3;
4695 }
4696 }
4697 else
4698 if ((iDeltatype == MNG_DELTATYPE_REPLACEALPHA) ||
4699 (iDeltatype == MNG_DELTATYPE_DELTAALPHA ) )
4700 {
4701 for (iY = iX; iY <= iM; iY++)
4702 {
4703 aAlphaentries [iY] = *pRawdata;
4704 aUsedentries [iY] = 1;
4705
4706 pRawdata++;
4707 iRawlen--;
4708 }
4709 }
4710 else
4711 {
4712 for (iY = iX; iY <= iM; iY++)
4713 {
4714 aIndexentries [iY].iRed = *pRawdata;
4715 aIndexentries [iY].iGreen = *(pRawdata+1);
4716 aIndexentries [iY].iBlue = *(pRawdata+2);
4717 aAlphaentries [iY] = *(pRawdata+3);
4718 aUsedentries [iY] = 1;
4719
4720 pRawdata += 4;
4721 iRawlen -= 4;
4722 }
4723 }
4724 }
4725
4726 switch (pData->iBitdepth) /* check maximum allowed entries for bitdepth */
4727 {
4728 case MNG_BITDEPTH_1 : {
4729 if (iMax > 2)
4730 MNG_ERROR (pData, MNG_INVALIDINDEX);
4731 break;
4732 }
4733 case MNG_BITDEPTH_2 : {
4734 if (iMax > 4)
4735 MNG_ERROR (pData, MNG_INVALIDINDEX);
4736 break;
4737 }
4738 case MNG_BITDEPTH_4 : {
4739 if (iMax > 16)
4740 MNG_ERROR (pData, MNG_INVALIDINDEX);
4741 break;
4742 }
4743 }
4744
4745 pPPLT->iCount = iMax;
4746
4747 for (iY = 255; iY >= 0; iY--)
4748 {
4749 pPPLT->aEntries [iY].iRed = aIndexentries [iY].iRed;
4750 pPPLT->aEntries [iY].iGreen = aIndexentries [iY].iGreen;
4751 pPPLT->aEntries [iY].iBlue = aIndexentries [iY].iBlue;
4752 pPPLT->aEntries [iY].iAlpha = aAlphaentries [iY];
4753 pPPLT->aEntries [iY].bUsed = (mng_bool)(aUsedentries [iY]);
4754 }
4755
4756 { /* create animation object */
4757 mng_retcode iRetcode = mng_create_ani_pplt (pData, iDeltatype, iMax,
4758 aIndexentries, aAlphaentries,
4759 aUsedentries);
4760 if (iRetcode)
4761 return iRetcode;
4762 }
4763
4764 *piRawlen = 0;
4765
4766 return MNG_NOERROR;
4767}
4768#endif
4769
4770/* ************************************************************************** */
4771
4772#ifndef MNG_NO_DELTA_PNG
4773MNG_C_SPECIALFUNC (mng_special_pplt)
4774{
4775 return MNG_NOERROR;
4776}
4777#endif
4778
4779/* ************************************************************************** */
4780
4781#ifndef MNG_NO_DELTA_PNG
4782#ifdef MNG_INCLUDE_JNG
4783MNG_C_SPECIALFUNC (mng_special_ijng)
4784{
4785#ifdef MNG_SUPPORT_DISPLAY
4786 mng_retcode iRetcode = mng_create_ani_ijng (pData);
4787 if (!iRetcode) /* process it */
4788 iRetcode = mng_process_display_ijng (pData);
4789 return iRetcode;
4790#else
4791 return MNG_NOERROR; /* done */
4792#endif /* MNG_SUPPORT_DISPLAY */
4793}
4794#endif
4795#endif
4796
4797/* ************************************************************************** */
4798
4799#ifndef MNG_NO_DELTA_PNG
4800MNG_F_SPECIALFUNC (mng_drop_entries)
4801{
4802 mng_dropp pDROP = (mng_dropp)pChunk;
4803 mng_uint32 iRawlen = *piRawlen;
4804 mng_uint8p pRawdata = *ppRawdata;
4805 mng_uint32 iX;
4806 mng_uint32p pEntry;
4807 /* check length */
4808 if ((iRawlen < 4) || ((iRawlen % 4) != 0))
4809 MNG_ERROR (pData, MNG_INVALIDLENGTH);
4810
4811 MNG_ALLOC (pData, pEntry, iRawlen);
4812 pDROP->iCount = iRawlen / 4;
4813 pDROP->pChunknames = (mng_ptr)pEntry;
4814
4815 for (iX = pDROP->iCount; iX > 0; iX--)
4816 {
4817 *pEntry++ = mng_get_uint32 (pRawdata);
4818 pRawdata += 4;
4819 }
4820
4821 *piRawlen = 0;
4822
4823 return MNG_NOERROR;
4824}
4825#endif
4826
4827/* ************************************************************************** */
4828
4829#ifndef MNG_NO_DELTA_PNG
4830MNG_C_SPECIALFUNC (mng_special_drop)
4831{
4832#ifdef MNG_SUPPORT_DISPLAY
4833 {
4834
4835
4836 /* TODO: something !!! */
4837
4838
4839 }
4840#endif /* MNG_SUPPORT_DISPLAY */
4841
4842 return MNG_NOERROR; /* done */
4843}
4844#endif
4845
4846/* ************************************************************************** */
4847
4848#ifndef MNG_NO_DELTA_PNG
4849#ifndef MNG_SKIPCHUNK_DBYK
4850MNG_C_SPECIALFUNC (mng_special_dbyk)
4851{
4852#ifdef MNG_SUPPORT_DISPLAY
4853 {
4854
4855
4856 /* TODO: something !!! */
4857
4858
4859 }
4860#endif /* MNG_SUPPORT_DISPLAY */
4861
4862 return MNG_NOERROR; /* done */
4863}
4864#endif
4865#endif
4866
4867/* ************************************************************************** */
4868
4869#ifndef MNG_NO_DELTA_PNG
4870#ifndef MNG_SKIPCHUNK_ORDR
4871MNG_F_SPECIALFUNC (mng_ordr_entries)
4872{
4873 mng_ordrp pORDR = (mng_ordrp)pChunk;
4874 mng_uint32 iRawlen = *piRawlen;
4875 mng_uint8p pRawdata = *ppRawdata;
4876 mng_uint32 iX;
4877 mng_ordr_entryp pEntry;
4878 /* check length */
4879 if ((iRawlen < 5) || ((iRawlen % 5) != 0))
4880 MNG_ERROR (pData, MNG_INVALIDLENGTH);
4881
4882 MNG_ALLOC (pData, pEntry, iRawlen);
4883 pORDR->iCount = iRawlen / 5;
4884 pORDR->pEntries = (mng_ptr)pEntry;
4885
4886 for (iX = pORDR->iCount; iX > 0; iX--)
4887 {
4888 pEntry->iChunkname = mng_get_uint32 (pRawdata);
4889 pEntry->iOrdertype = *(pRawdata+4);
4890 pEntry++;
4891 pRawdata += 5;
4892 }
4893
4894 *piRawlen = 0;
4895
4896 return MNG_NOERROR;
4897}
4898#endif
4899#endif
4900
4901/* ************************************************************************** */
4902
4903#ifndef MNG_NO_DELTA_PNG
4904#ifndef MNG_SKIPCHUNK_ORDR
4905MNG_C_SPECIALFUNC (mng_special_ordr)
4906{
4907#ifdef MNG_SUPPORT_DISPLAY
4908 {
4909
4910
4911 /* TODO: something !!! */
4912
4913
4914 }
4915#endif /* MNG_SUPPORT_DISPLAY */
4916
4917 return MNG_NOERROR; /* done */
4918}
4919#endif
4920#endif
4921
4922/* ************************************************************************** */
4923
4924#ifndef MNG_SKIPCHUNK_MAGN
4925MNG_F_SPECIALFUNC (mng_debunk_magn)
4926{
4927 mng_magnp pMAGN = (mng_magnp)pChunk;
4928 mng_uint32 iRawlen = *piRawlen;
4929 mng_uint8p pRawdata = *ppRawdata;
4930 mng_bool bFaulty;
4931 /* check length */
4932 if (iRawlen > 20)
4933 MNG_ERROR (pData, MNG_INVALIDLENGTH);
4934
4935 /* following is an ugly hack to allow faulty layout caused by previous
4936 versions of libmng and MNGeye, which wrote MAGN with a 16-bit
4937 MethodX/MethodY (as opposed to the proper 8-bit as defined in the spec!) */
4938
4939 if ((iRawlen == 6) || (iRawlen == 8) || (iRawlen == 10) || (iRawlen == 12) ||
4940 (iRawlen == 14) || (iRawlen == 16) || (iRawlen == 20))
4941 bFaulty = MNG_TRUE; /* these lengths are all wrong */
4942 else /* length 18 can be right or wrong !!! */
4943 if ((iRawlen == 18) && (mng_get_uint16 (pRawdata+4) <= 5) &&
4944 (mng_get_uint16 (pRawdata+6) < 256) &&
4945 (mng_get_uint16 (pRawdata+8) < 256) &&
4946 (mng_get_uint16 (pRawdata+10) < 256) &&
4947 (mng_get_uint16 (pRawdata+12) < 256) &&
4948 (mng_get_uint16 (pRawdata+14) < 256) &&
4949 (mng_get_uint16 (pRawdata+16) < 256))
4950 bFaulty = MNG_TRUE; /* this is very likely the wrong layout */
4951 else
4952 bFaulty = MNG_FALSE; /* all other cases are handled as right */
4953
4954 if (bFaulty) /* wrong layout ? */
4955 {
4956 if (iRawlen > 0) /* get the fields */
4957 pMAGN->iFirstid = mng_get_uint16 (pRawdata);
4958 else
4959 pMAGN->iFirstid = 0;
4960
4961 if (iRawlen > 2)
4962 pMAGN->iLastid = mng_get_uint16 (pRawdata+2);
4963 else
4964 pMAGN->iLastid = pMAGN->iFirstid;
4965
4966 if (iRawlen > 4)
4967 pMAGN->iMethodX = (mng_uint8)(mng_get_uint16 (pRawdata+4));
4968 else
4969 pMAGN->iMethodX = 0;
4970
4971 if (iRawlen > 6)
4972 pMAGN->iMX = mng_get_uint16 (pRawdata+6);
4973 else
4974 pMAGN->iMX = 1;
4975
4976 if (iRawlen > 8)
4977 pMAGN->iMY = mng_get_uint16 (pRawdata+8);
4978 else
4979 pMAGN->iMY = pMAGN->iMX;
4980
4981 if (iRawlen > 10)
4982 pMAGN->iML = mng_get_uint16 (pRawdata+10);
4983 else
4984 pMAGN->iML = pMAGN->iMX;
4985
4986 if (iRawlen > 12)
4987 pMAGN->iMR = mng_get_uint16 (pRawdata+12);
4988 else
4989 pMAGN->iMR = pMAGN->iMX;
4990
4991 if (iRawlen > 14)
4992 pMAGN->iMT = mng_get_uint16 (pRawdata+14);
4993 else
4994 pMAGN->iMT = pMAGN->iMY;
4995
4996 if (iRawlen > 16)
4997 pMAGN->iMB = mng_get_uint16 (pRawdata+16);
4998 else
4999 pMAGN->iMB = pMAGN->iMY;
5000
5001 if (iRawlen > 18)
5002 pMAGN->iMethodY = (mng_uint8)(mng_get_uint16 (pRawdata+18));
5003 else
5004 pMAGN->iMethodY = pMAGN->iMethodX;
5005 }
5006 else /* proper layout !!!! */
5007 {
5008 if (iRawlen > 0) /* get the fields */
5009 pMAGN->iFirstid = mng_get_uint16 (pRawdata);
5010 else
5011 pMAGN->iFirstid = 0;
5012
5013 if (iRawlen > 2)
5014 pMAGN->iLastid = mng_get_uint16 (pRawdata+2);
5015 else
5016 pMAGN->iLastid = pMAGN->iFirstid;
5017
5018 if (iRawlen > 4)
5019 pMAGN->iMethodX = *(pRawdata+4);
5020 else
5021 pMAGN->iMethodX = 0;
5022
5023 if (iRawlen > 5)
5024 pMAGN->iMX = mng_get_uint16 (pRawdata+5);
5025 else
5026 pMAGN->iMX = 1;
5027
5028 if (iRawlen > 7)
5029 pMAGN->iMY = mng_get_uint16 (pRawdata+7);
5030 else
5031 pMAGN->iMY = pMAGN->iMX;
5032
5033 if (iRawlen > 9)
5034 pMAGN->iML = mng_get_uint16 (pRawdata+9);
5035 else
5036 pMAGN->iML = pMAGN->iMX;
5037
5038 if (iRawlen > 11)
5039 pMAGN->iMR = mng_get_uint16 (pRawdata+11);
5040 else
5041 pMAGN->iMR = pMAGN->iMX;
5042
5043 if (iRawlen > 13)
5044 pMAGN->iMT = mng_get_uint16 (pRawdata+13);
5045 else
5046 pMAGN->iMT = pMAGN->iMY;
5047
5048 if (iRawlen > 15)
5049 pMAGN->iMB = mng_get_uint16 (pRawdata+15);
5050 else
5051 pMAGN->iMB = pMAGN->iMY;
5052
5053 if (iRawlen > 17)
5054 pMAGN->iMethodY = *(pRawdata+17);
5055 else
5056 pMAGN->iMethodY = pMAGN->iMethodX;
5057 }
5058 /* check field validity */
5059 if ((pMAGN->iMethodX > 5) || (pMAGN->iMethodY > 5))
5060 MNG_ERROR (pData, MNG_INVALIDMETHOD);
5061
5062 *piRawlen = 0;
5063
5064 return MNG_NOERROR;
5065}
5066#endif
5067
5068/* ************************************************************************** */
5069
5070#ifndef MNG_SKIPCHUNK_MAGN
5071MNG_C_SPECIALFUNC (mng_special_magn)
5072{
5073#ifdef MNG_SUPPORT_DISPLAY
5074 return mng_create_ani_magn (pData, pChunk);
5075#else
5076 return MNG_NOERROR;
5077#endif /* MNG_SUPPORT_DISPLAY */
5078}
5079#endif
5080
5081/* ************************************************************************** */
5082
5083#ifndef MNG_SKIPCHUNK_evNT
5084MNG_F_SPECIALFUNC (mng_evnt_entries)
5085{
5086 mng_evntp pEVNT = (mng_evntp)pChunk;
5087 mng_uint32 iRawlen;
5088 mng_uint8p pRawdata;
5089#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_DYNAMICMNG)
5090 mng_retcode iRetcode;
5091#endif
5092 mng_uint8p pNull;
5093 mng_uint8 iEventtype;
5094 mng_uint8 iMasktype;
5095 mng_int32 iLeft;
5096 mng_int32 iRight;
5097 mng_int32 iTop;
5098 mng_int32 iBottom;
5099 mng_uint16 iObjectid;
5100 mng_uint8 iIndex;
5101 mng_uint32 iNamesize;
5102 mng_uint32 iCount = 0;
5103 mng_evnt_entryp pEntry = MNG_NULL;
5104 mng_uint32 iX;
5105
5106 for (iX = 0; iX < 2; iX++)
5107 {
5108 iRawlen = *piRawlen;
5109 pRawdata = *ppRawdata;
5110
5111 if (iX) /* second run ? */
5112 {
5113 MNG_ALLOC (pData, pEntry, (iCount * sizeof (mng_evnt_entry)));
5114 pEVNT->iCount = iCount;
5115 pEVNT->pEntries = pEntry;
5116 }
5117
5118 while (iRawlen) /* anything left ? */
5119 {
5120 if (iRawlen < 2) /* must have at least 2 bytes ! */
5121 MNG_ERROR (pData, MNG_INVALIDLENGTH);
5122
5123 iEventtype = *pRawdata; /* eventtype */
5124 if (iEventtype > 5)
5125 MNG_ERROR (pData, MNG_INVALIDEVENT);
5126
5127 pRawdata++;
5128
5129 iMasktype = *pRawdata; /* masktype */
5130 if (iMasktype > 5)
5131 MNG_ERROR (pData, MNG_INVALIDMASK);
5132
5133 pRawdata++;
5134 iRawlen -= 2;
5135
5136 iLeft = 0;
5137 iRight = 0;
5138 iTop = 0;
5139 iBottom = 0;
5140 iObjectid = 0;
5141 iIndex = 0;
5142
5143 switch (iMasktype)
5144 {
5145 case 1 :
5146 {
5147 if (iRawlen > 16)
5148 {
5149 iLeft = mng_get_int32 (pRawdata);
5150 iRight = mng_get_int32 (pRawdata+4);
5151 iTop = mng_get_int32 (pRawdata+8);
5152 iBottom = mng_get_int32 (pRawdata+12);
5153 pRawdata += 16;
5154 iRawlen -= 16;
5155 }
5156 else
5157 MNG_ERROR (pData, MNG_INVALIDLENGTH);
5158 break;
5159 }
5160 case 2 :
5161 {
5162 if (iRawlen > 2)
5163 {
5164 iObjectid = mng_get_uint16 (pRawdata);
5165 pRawdata += 2;
5166 iRawlen -= 2;
5167 }
5168 else
5169 MNG_ERROR (pData, MNG_INVALIDLENGTH);
5170 break;
5171 }
5172 case 3 :
5173 {
5174 if (iRawlen > 3)
5175 {
5176 iObjectid = mng_get_uint16 (pRawdata);
5177 iIndex = *(pRawdata+2);
5178 pRawdata += 3;
5179 iRawlen -= 3;
5180 }
5181 else
5182 MNG_ERROR (pData, MNG_INVALIDLENGTH);
5183 break;
5184 }
5185 case 4 :
5186 {
5187 if (iRawlen > 18)
5188 {
5189 iLeft = mng_get_int32 (pRawdata);
5190 iRight = mng_get_int32 (pRawdata+4);
5191 iTop = mng_get_int32 (pRawdata+8);
5192 iBottom = mng_get_int32 (pRawdata+12);
5193 iObjectid = mng_get_uint16 (pRawdata+16);
5194 pRawdata += 18;
5195 iRawlen -= 18;
5196 }
5197 else
5198 MNG_ERROR (pData, MNG_INVALIDLENGTH);
5199 break;
5200 }
5201 case 5 :
5202 {
5203 if (iRawlen > 19)
5204 {
5205 iLeft = mng_get_int32 (pRawdata);
5206 iRight = mng_get_int32 (pRawdata+4);
5207 iTop = mng_get_int32 (pRawdata+8);
5208 iBottom = mng_get_int32 (pRawdata+12);
5209 iObjectid = mng_get_uint16 (pRawdata+16);
5210 iIndex = *(pRawdata+18);
5211 pRawdata += 19;
5212 iRawlen -= 19;
5213 }
5214 else
5215 MNG_ERROR (pData, MNG_INVALIDLENGTH);
5216 break;
5217 }
5218 }
5219
5220 pNull = pRawdata; /* get the name length */
5221 while (*pNull)
5222 pNull++;
5223
5224 if ((pNull - pRawdata) > (mng_int32)iRawlen)
5225 {
5226 iNamesize = iRawlen; /* no null found; so end of evNT */
5227 iRawlen = 0;
5228 }
5229 else
5230 {
5231 iNamesize = pNull - pRawdata; /* should be another entry */
5232 iRawlen = iRawlen - iNamesize - 1;
5233
5234 if (!iRawlen) /* must not end with a null ! */
5235 MNG_ERROR (pData, MNG_ENDWITHNULL);
5236 }
5237
5238 if (!iX)
5239 {
5240 iCount++;
5241 }
5242 else
5243 {
5244 pEntry->iEventtype = iEventtype;
5245 pEntry->iMasktype = iMasktype;
5246 pEntry->iLeft = iLeft;
5247 pEntry->iRight = iRight;
5248 pEntry->iTop = iTop;
5249 pEntry->iBottom = iBottom;
5250 pEntry->iObjectid = iObjectid;
5251 pEntry->iIndex = iIndex;
5252 pEntry->iSegmentnamesize = iNamesize;
5253
5254 if (iNamesize)
5255 {
5256 MNG_ALLOC (pData, pEntry->zSegmentname, iNamesize+1);
5257 MNG_COPY (pEntry->zSegmentname, pRawdata, iNamesize);
5258 }
5259
5260#if defined(MNG_SUPPORT_DISPLAY) && defined(MNG_SUPPORT_DYNAMICMNG)
5261 iRetcode = mng_create_event (pData, (mng_ptr)pEntry);
5262 if (iRetcode) /* on error bail out */
5263 return iRetcode;
5264#endif
5265
5266 pEntry++;
5267 }
5268
5269 pRawdata = pRawdata + iNamesize + 1;
5270 }
5271 }
5272
5273 *piRawlen = 0;
5274
5275 return MNG_NOERROR;
5276}
5277#endif
5278
5279/* ************************************************************************** */
5280
5281#ifndef MNG_SKIPCHUNK_evNT
5282MNG_C_SPECIALFUNC (mng_special_evnt)
5283{
5284 return MNG_NOERROR;
5285}
5286#endif
5287
5288/* ************************************************************************** */
5289
5290#ifdef MNG_INCLUDE_MPNG_PROPOSAL
5291MNG_C_SPECIALFUNC (mng_special_mpng)
5292{
5293 if ((pData->eImagetype != mng_it_png) && (pData->eImagetype != mng_it_jng))
5294 MNG_ERROR (pData, MNG_CHUNKNOTALLOWED);
5295
5296#ifdef MNG_SUPPORT_DISPLAY
5297 return mng_create_mpng_obj (pData, pChunk);
5298#else
5299 return MNG_NOERROR;
5300#endif
5301}
5302#endif
5303
5304/* ************************************************************************** */
5305
5306#ifdef MNG_INCLUDE_ANG_PROPOSAL
5307MNG_C_SPECIALFUNC (mng_special_ahdr)
5308{
5309#ifdef MNG_SUPPORT_DISPLAY
5310 return mng_create_ang_obj (pData, pChunk);
5311#else
5312 return MNG_NOERROR;
5313#endif
5314}
5315#endif
5316
5317/* ************************************************************************** */
5318
5319#ifdef MNG_INCLUDE_ANG_PROPOSAL
5320MNG_F_SPECIALFUNC (mng_adat_tiles)
5321{
5322 if ((pData->eImagetype != mng_it_ang) || (!pData->pANG))
5323 MNG_ERROR (pData, MNG_CHUNKNOTALLOWED);
5324
5325 {
5326 mng_adatp pADAT = (mng_adatp)pChunk;
5327 mng_ang_objp pANG = (mng_ang_objp)pData->pANG;
5328 mng_uint32 iRawlen = *piRawlen;
5329 mng_uint8p pRawdata = *ppRawdata;
5330 mng_retcode iRetcode;
5331 mng_uint8p pBuf;
5332 mng_uint32 iBufsize;
5333 mng_uint32 iRealsize;
5334 mng_uint8p pTemp;
5335 mng_uint8p pTemp2;
5336 mng_int32 iX;
5337 mng_int32 iSize;
5338
5339#ifdef MNG_SUPPORT_DISPLAY
5340 mng_imagep pImage;
5341 mng_int32 iTemplen;
5342 mng_uint8p pSwap;
5343
5344 mng_processobject pProcess;
5345
5346 mng_uint32 iSavedatawidth;
5347 mng_uint32 iSavedataheight;
5348
5349 mng_fptr fSaveinitrowproc;
5350 mng_fptr fSavestorerow;
5351 mng_fptr fSaveprocessrow;
5352 mng_fptr fSavedifferrow;
5353 mng_imagep fSavestoreobj;
5354 mng_imagedatap fSavestorebuf;
5355
5356#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT
5357 png_imgtype eSavepngimgtype;
5358#endif
5359
5360 mng_uint8 iSaveinterlace;
5361 mng_int8 iSavepass;
5362 mng_int32 iSaverow;
5363 mng_int32 iSaverowinc;
5364 mng_int32 iSavecol;
5365 mng_int32 iSavecolinc;
5366 mng_int32 iSaverowsamples;
5367 mng_int32 iSavesamplemul;
5368 mng_int32 iSavesampleofs;
5369 mng_int32 iSavesamplediv;
5370 mng_int32 iSaverowsize;
5371 mng_int32 iSaverowmax;
5372 mng_int32 iSavefilterofs;
5373 mng_int32 iSavepixelofs;
5374 mng_uint32 iSavelevel0;
5375 mng_uint32 iSavelevel1;
5376 mng_uint32 iSavelevel2;
5377 mng_uint32 iSavelevel3;
5378 mng_uint8p pSaveworkrow;
5379 mng_uint8p pSaveprevrow;
5380 mng_uint8p pSaverGBArow;
5381 mng_bool bSaveisRGBA16;
5382 mng_bool bSaveisOpaque;
5383 mng_int32 iSavefilterbpp;
5384
5385 mng_int32 iSavedestl;
5386 mng_int32 iSavedestt;
5387 mng_int32 iSavedestr;
5388 mng_int32 iSavedestb;
5389 mng_int32 iSavesourcel;
5390 mng_int32 iSavesourcet;
5391 mng_int32 iSavesourcer;
5392 mng_int32 iSavesourceb;
5393#endif /* MNG_SUPPORT_DISPLAY */
5394
5395 iRetcode = mng_inflate_buffer (pData, pRawdata, iRawlen,
5396 &pBuf, &iBufsize, &iRealsize);
5397 if (iRetcode) /* on error bail out */
5398 { /* don't forget to drop the temp buffer */
5399 MNG_FREEX (pData, pBuf, iBufsize);
5400 return iRetcode;
5401 }
5402 /* get buffer for tile info in ADAT chunk */
5403 pADAT->iTilessize = pANG->iNumframes * sizeof(mng_adat_tile);
5404 MNG_ALLOCX (pData, pADAT->pTiles, pADAT->iTilessize);
5405 if (!pADAT->pTiles)
5406 {
5407 pADAT->iTilessize = 0;
5408 MNG_FREEX (pData, pBuf, iBufsize);
5409 MNG_ERROR (pData, MNG_OUTOFMEMORY);
5410 }
5411
5412 pTemp = pBuf;
5413 pTemp2 = (mng_uint8p)pADAT->pTiles;
5414
5415 if (!pANG->iStillused)
5416 iSize = 12;
5417 else
5418 iSize = 13;
5419
5420 for (iX = 0; iX < pANG->iNumframes; iX++)
5421 {
5422 MNG_COPY (pTemp2, pTemp, iSize);
5423 pTemp += iSize;
5424 pTemp2 += sizeof(mng_adat_tile);
5425 }
5426
5427#ifdef MNG_SUPPORT_DISPLAY
5428 /* get buffer for tile info in ANG object */
5429 pANG->iTilessize = pADAT->iTilessize;
5430 MNG_ALLOCX (pData, pANG->pTiles, pANG->iTilessize);
5431 if (!pANG->pTiles)
5432 {
5433 pANG->iTilessize = 0;
5434 MNG_FREEX (pData, pBuf, iBufsize);
5435 MNG_ERROR (pData, MNG_OUTOFMEMORY);
5436 }
5437 /* copy it from the ADAT object */
5438 MNG_COPY (pANG->pTiles, pADAT->pTiles, pANG->iTilessize);
5439
5440 /* save IDAT work-parms */
5441 fSaveinitrowproc = pData->fInitrowproc;
5442 fSavestorerow = pData->fDisplayrow;
5443 fSaveprocessrow = pData->fProcessrow;
5444 fSavedifferrow = pData->fDifferrow;
5445 fSavestoreobj = pData->pStoreobj;
5446 fSavestorebuf = pData->pStorebuf;
5447
5448#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT
5449 eSavepngimgtype = pData->ePng_imgtype;
5450#endif
5451
5452 iSavedatawidth = pData->iDatawidth;
5453 iSavedataheight = pData->iDataheight;
5454 iSaveinterlace = pData->iInterlace;
5455 iSavepass = pData->iPass;
5456 iSaverow = pData->iRow;
5457 iSaverowinc = pData->iRowinc;
5458 iSavecol = pData->iCol;
5459 iSavecolinc = pData->iColinc;
5460 iSaverowsamples = pData->iRowsamples;
5461 iSavesamplemul = pData->iSamplemul;
5462 iSavesampleofs = pData->iSampleofs;
5463 iSavesamplediv = pData->iSamplediv;
5464 iSaverowsize = pData->iRowsize;
5465 iSaverowmax = pData->iRowmax;
5466 iSavefilterofs = pData->iFilterofs;
5467 iSavepixelofs = pData->iPixelofs;
5468 iSavelevel0 = pData->iLevel0;
5469 iSavelevel1 = pData->iLevel1;
5470 iSavelevel2 = pData->iLevel2;
5471 iSavelevel3 = pData->iLevel3;
5472 pSaveworkrow = pData->pWorkrow;
5473 pSaveprevrow = pData->pPrevrow;
5474 pSaverGBArow = pData->pRGBArow;
5475 bSaveisRGBA16 = pData->bIsRGBA16;
5476 bSaveisOpaque = pData->bIsOpaque;
5477 iSavefilterbpp = pData->iFilterbpp;
5478 iSavedestl = pData->iDestl;
5479 iSavedestt = pData->iDestt;
5480 iSavedestr = pData->iDestr;
5481 iSavedestb = pData->iDestb;
5482 iSavesourcel = pData->iSourcel;
5483 iSavesourcet = pData->iSourcet;
5484 iSavesourcer = pData->iSourcer;
5485 iSavesourceb = pData->iSourceb;
5486
5487 pData->iDatawidth = pANG->iTilewidth;
5488 pData->iDataheight = pANG->iTileheight;
5489
5490 pData->iDestl = 0;
5491 pData->iDestt = 0;
5492 pData->iDestr = pANG->iTilewidth;
5493 pData->iDestb = pANG->iTileheight;
5494 pData->iSourcel = 0;
5495 pData->iSourcet = 0;
5496 pData->iSourcer = pANG->iTilewidth;
5497 pData->iSourceb = pANG->iTileheight;
5498
5499 pData->fInitrowproc = MNG_NULL;
5500 pData->fStorerow = MNG_NULL;
5501 pData->fProcessrow = MNG_NULL;
5502 pData->fDifferrow = MNG_NULL;
5503
5504 /* clone image object to store the pixel-data from object 0 */
5505 iRetcode = mng_clone_imageobject (pData, 1, MNG_FALSE, MNG_FALSE, MNG_FALSE,
5506 MNG_FALSE, 0, 0, 0, pData->pObjzero, &pImage);
5507 if (iRetcode) /* on error, drop temp buffer and bail */
5508 {
5509 MNG_FREEX (pData, pBuf, iBufsize);
5510 return iRetcode;
5511 }
5512
5513 /* make sure we got the right dimensions and interlacing */
5514 iRetcode = mng_reset_object_details (pData, pImage, pANG->iTilewidth, pANG->iTileheight,
5515 pImage->pImgbuf->iBitdepth, pImage->pImgbuf->iColortype,
5516 pImage->pImgbuf->iCompression, pImage->pImgbuf->iFilter,
5517 pANG->iInterlace, MNG_FALSE);
5518 if (iRetcode) /* on error, drop temp buffer and bail */
5519 {
5520 MNG_FREEX (pData, pBuf, iBufsize);
5521 return iRetcode;
5522 }
5523
5524 pData->pStoreobj = pImage;
5525
5526#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT
5527 pData->fInitrowproc = (mng_fptr)mng_init_rowproc;
5528 pData->ePng_imgtype = mng_png_imgtype(pData->iColortype,pData->iBitdepth);
5529#else
5530 switch (pData->iColortype) /* determine row initialization routine */
5531 {
5532 case 0 : { /* gray */
5533 switch (pData->iBitdepth)
5534 {
5535#ifndef MNG_NO_1_2_4BIT_SUPPORT
5536 case 1 : {
5537 if (!pData->iInterlace)
5538 pData->fInitrowproc = (mng_fptr)mng_init_g1_ni;
5539 else
5540 pData->fInitrowproc = (mng_fptr)mng_init_g1_i;
5541
5542 break;
5543 }
5544 case 2 : {
5545 if (!pData->iInterlace)
5546 pData->fInitrowproc = (mng_fptr)mng_init_g2_ni;
5547 else
5548 pData->fInitrowproc = (mng_fptr)mng_init_g2_i;
5549
5550 break;
5551 }
5552 case 4 : {
5553 if (!pData->iInterlace)
5554 pData->fInitrowproc = (mng_fptr)mng_init_g4_ni;
5555 else
5556 pData->fInitrowproc = (mng_fptr)mng_init_g4_i;
5557 break;
5558 }
5559#endif /* MNG_NO_1_2_4BIT_SUPPORT */
5560 case 8 : {
5561 if (!pData->iInterlace)
5562 pData->fInitrowproc = (mng_fptr)mng_init_g8_ni;
5563 else
5564 pData->fInitrowproc = (mng_fptr)mng_init_g8_i;
5565
5566 break;
5567 }
5568#ifndef MNG_NO_16BIT_SUPPORT
5569 case 16 : {
5570 if (!pData->iInterlace)
5571 pData->fInitrowproc = (mng_fptr)mng_init_g16_ni;
5572 else
5573 pData->fInitrowproc = (mng_fptr)mng_init_g16_i;
5574
5575 break;
5576 }
5577#endif
5578 }
5579
5580 break;
5581 }
5582 case 2 : { /* rgb */
5583 switch (pData->iBitdepth)
5584 {
5585 case 8 : {
5586 if (!pData->iInterlace)
5587 pData->fInitrowproc = (mng_fptr)mng_init_rgb8_ni;
5588 else
5589 pData->fInitrowproc = (mng_fptr)mng_init_rgb8_i;
5590 break;
5591 }
5592#ifndef MNG_NO_16BIT_SUPPORT
5593 case 16 : {
5594 if (!pData->iInterlace)
5595 pData->fInitrowproc = (mng_fptr)mng_init_rgb16_ni;
5596 else
5597 pData->fInitrowproc = (mng_fptr)mng_init_rgb16_i;
5598
5599 break;
5600 }
5601#endif
5602 }
5603
5604 break;
5605 }
5606 case 3 : { /* indexed */
5607 switch (pData->iBitdepth)
5608 {
5609#ifndef MNG_NO_1_2_4BIT_SUPPORT
5610 case 1 : {
5611 if (!pData->iInterlace)
5612 pData->fInitrowproc = (mng_fptr)mng_init_idx1_ni;
5613 else
5614 pData->fInitrowproc = (mng_fptr)mng_init_idx1_i;
5615
5616 break;
5617 }
5618 case 2 : {
5619 if (!pData->iInterlace)
5620 pData->fInitrowproc = (mng_fptr)mng_init_idx2_ni;
5621 else
5622 pData->fInitrowproc = (mng_fptr)mng_init_idx2_i;
5623
5624 break;
5625 }
5626 case 4 : {
5627 if (!pData->iInterlace)
5628 pData->fInitrowproc = (mng_fptr)mng_init_idx4_ni;
5629 else
5630 pData->fInitrowproc = (mng_fptr)mng_init_idx4_i;
5631
5632 break;
5633 }
5634#endif /* MNG_NO_1_2_4BIT_SUPPORT */
5635 case 8 : {
5636 if (!pData->iInterlace)
5637 pData->fInitrowproc = (mng_fptr)mng_init_idx8_ni;
5638 else
5639 pData->fInitrowproc = (mng_fptr)mng_init_idx8_i;
5640
5641 break;
5642 }
5643 }
5644
5645 break;
5646 }
5647 case 4 : { /* gray+alpha */
5648 switch (pData->iBitdepth)
5649 {
5650 case 8 : {
5651 if (!pData->iInterlace)
5652 pData->fInitrowproc = (mng_fptr)mng_init_ga8_ni;
5653 else
5654 pData->fInitrowproc = (mng_fptr)mng_init_ga8_i;
5655
5656 break;
5657 }
5658#ifndef MNG_NO_16BIT_SUPPORT
5659 case 16 : {
5660 if (!pData->iInterlace)
5661 pData->fInitrowproc = (mng_fptr)mng_init_ga16_ni;
5662 else
5663 pData->fInitrowproc = (mng_fptr)mng_init_ga16_i;
5664 break;
5665 }
5666#endif
5667 }
5668
5669 break;
5670 }
5671 case 6 : { /* rgb+alpha */
5672 switch (pData->iBitdepth)
5673 {
5674 case 8 : {
5675 if (!pData->iInterlace)
5676 pData->fInitrowproc = (mng_fptr)mng_init_rgba8_ni;
5677 else
5678 pData->fInitrowproc = (mng_fptr)mng_init_rgba8_i;
5679
5680 break;
5681 }
5682#ifndef MNG_NO_16BIT_SUPPORT
5683 case 16 : {
5684 if (!pData->iInterlace)
5685 pData->fInitrowproc = (mng_fptr)mng_init_rgba16_ni;
5686 else
5687 pData->fInitrowproc = (mng_fptr)mng_init_rgba16_i;
5688
5689 break;
5690 }
5691#endif
5692 }
5693
5694 break;
5695 }
5696 }
5697#endif /* MNG_OPTIMIZE_FOOTPRINT_INIT */
5698
5699 pData->iFilterofs = 0; /* determine filter characteristics */
5700 pData->iLevel0 = 0; /* default levels */
5701 pData->iLevel1 = 0;
5702 pData->iLevel2 = 0;
5703 pData->iLevel3 = 0;
5704
5705#ifdef FILTER192 /* leveling & differing ? */
5706 if (pData->iFilter == MNG_FILTER_DIFFERING)
5707 {
5708 switch (pData->iColortype)
5709 {
5710 case 0 : {
5711 if (pData->iBitdepth <= 8)
5712 pData->iFilterofs = 1;
5713 else
5714 pData->iFilterofs = 2;
5715
5716 break;
5717 }
5718 case 2 : {
5719 if (pData->iBitdepth <= 8)
5720 pData->iFilterofs = 3;
5721 else
5722 pData->iFilterofs = 6;
5723
5724 break;
5725 }
5726 case 3 : {
5727 pData->iFilterofs = 1;
5728 break;
5729 }
5730 case 4 : {
5731 if (pData->iBitdepth <= 8)
5732 pData->iFilterofs = 2;
5733 else
5734 pData->iFilterofs = 4;
5735
5736 break;
5737 }
5738 case 6 : {
5739 if (pData->iBitdepth <= 8)
5740 pData->iFilterofs = 4;
5741 else
5742 pData->iFilterofs = 8;
5743
5744 break;
5745 }
5746 }
5747 }
5748#endif
5749
5750#ifdef FILTER193 /* no adaptive filtering ? */
5751 if (pData->iFilter == MNG_FILTER_NOFILTER)
5752 pData->iPixelofs = pData->iFilterofs;
5753 else
5754#endif
5755 pData->iPixelofs = pData->iFilterofs + 1;
5756
5757 if (pData->fInitrowproc) /* need to initialize row processing? */
5758 {
5759 iRetcode = ((mng_initrowproc)pData->fInitrowproc) (pData);
5760 if (iRetcode)
5761 {
5762 MNG_FREEX (pData, pBuf, iBufsize);
5763 return iRetcode;
5764 }
5765 }
5766 /* calculate remainder of buffer */
5767 pTemp = pBuf + (mng_int32)(pANG->iNumframes * iSize);
5768 iTemplen = iRealsize - (mng_int32)(pANG->iNumframes * iSize);
5769
5770 do
5771 {
5772 if (iTemplen > pData->iRowmax) /* get a pixel-row from the temp buffer */
5773 {
5774 MNG_COPY (pData->pWorkrow, pTemp, pData->iRowmax);
5775 }
5776 else
5777 {
5778 MNG_COPY (pData->pWorkrow, pTemp, iTemplen);
5779 }
5780
5781 { /* image not completed yet ? */
5782 if (pData->iRow < (mng_int32)pData->iDataheight)
5783 {
5784#ifdef MNG_NO_1_2_4BIT_SUPPORT
5785 if (pData->iPNGdepth == 1)
5786 {
5787 /* Inflate Workrow to 8-bit */
5788 mng_int32 iX;
5789 mng_uint8p pSrc = pData->pWorkrow+1;
5790 mng_uint8p pDest = pSrc + pData->iRowsize - (pData->iRowsize+7)/8;
5791
5792 for (iX = ((pData->iRowsize+7)/8) ; iX > 0 ; iX--)
5793 *pDest++ = *pSrc++;
5794
5795 pDest = pData->pWorkrow+1;
5796 pSrc = pDest + pData->iRowsize - (pData->iRowsize+7)/8;
5797 for (iX = pData->iRowsize; ;)
5798 {
5799 *pDest++ = (((*pSrc)>>7)&1);
5800 if (iX-- <= 0)
5801 break;
5802 *pDest++ = (((*pSrc)>>6)&1);
5803 if (iX-- <= 0)
5804 break;
5805 *pDest++ = (((*pSrc)>>5)&1);
5806 if (iX-- <= 0)
5807 break;
5808 *pDest++ = (((*pSrc)>>4)&1);
5809 if (iX-- <= 0)
5810 break;
5811 *pDest++ = (((*pSrc)>>3)&1);
5812 if (iX-- <= 0)
5813 break;
5814 *pDest++ = (((*pSrc)>>2)&1);
5815 if (iX-- <= 0)
5816 break;
5817 *pDest++ = (((*pSrc)>>1)&1);
5818 if (iX-- <= 0)
5819 break;
5820 *pDest++ = (((*pSrc) )&1);
5821 if (iX-- <= 0)
5822 break;
5823 pSrc++;
5824 }
5825 }
5826 else if (pData->iPNGdepth == 2)
5827 {
5828 /* Inflate Workrow to 8-bit */
5829 mng_int32 iX;
5830 mng_uint8p pSrc = pData->pWorkrow+1;
5831 mng_uint8p pDest = pSrc + pData->iRowsize - (2*pData->iRowsize+7)/8;
5832
5833 for (iX = ((2*pData->iRowsize+7)/8) ; iX > 0 ; iX--)
5834 *pDest++ = *pSrc++;
5835
5836 pDest = pData->pWorkrow+1;
5837 pSrc = pDest + pData->iRowsize - (2*pData->iRowsize+7)/8;
5838 for (iX = pData->iRowsize; ;)
5839 {
5840 *pDest++ = (((*pSrc)>>6)&3);
5841 if (iX-- <= 0)
5842 break;
5843 *pDest++ = (((*pSrc)>>4)&3);
5844 if (iX-- <= 0)
5845 break;
5846 *pDest++ = (((*pSrc)>>2)&3);
5847 if (iX-- <= 0)
5848 break;
5849 *pDest++ = (((*pSrc) )&3);
5850 if (iX-- <= 0)
5851 break;
5852 pSrc++;
5853 }
5854 }
5855 else if (pData->iPNGdepth == 4)
5856 {
5857 /* Inflate Workrow to 8-bit */
5858 mng_int32 iX;
5859 mng_uint8p pSrc = pData->pWorkrow+1;
5860 mng_uint8p pDest = pSrc + pData->iRowsize - (4*pData->iRowsize+7)/8;
5861
5862 for (iX = ((4*pData->iRowsize+7)/8) ; iX > 0 ; iX--)
5863 *pDest++ = *pSrc++;
5864
5865 pDest = pData->pWorkrow+1;
5866 pSrc = pDest + pData->iRowsize - (4*pData->iRowsize+7)/8;
5867 for (iX = pData->iRowsize; ;)
5868 {
5869 *pDest++ = (((*pSrc)>>4)&0x0f);
5870 if (iX-- <= 0)
5871 break;
5872 *pDest++ = (((*pSrc) )&0x0f);
5873 if (iX-- <= 0)
5874 break;
5875 pSrc++;
5876 }
5877 }
5878 if (pData->iPNGdepth < 8 && pData->iColortype == 0)
5879 {
5880 /* Expand samples to 8-bit by LBR */
5881 mng_int32 iX;
5882 mng_uint8p pSrc = pData->pWorkrow+1;
5883 mng_uint8 multiplier[]={0,255,85,0,17,0,0,0,1};
5884
5885 for (iX = pData->iRowsize; iX > 0; iX--)
5886 *pSrc++ *= multiplier[pData->iPNGdepth];
5887 }
5888#endif
5889#ifdef MNG_NO_16BIT_SUPPORT
5890 if (pData->iPNGdepth > 8)
5891 {
5892 /* Reduce Workrow to 8-bit */
5893 mng_int32 iX;
5894 mng_uint8p pSrc = pData->pWorkrow+1;
5895 mng_uint8p pDest = pSrc;
5896
5897 for (iX = pData->iRowsize; iX > 0; iX--)
5898 {
5899 *pDest = *pSrc;
5900 pDest++;
5901 pSrc+=2;
5902 }
5903 }
5904#endif
5905
5906#ifdef FILTER192 /* has leveling info ? */
5907 if (pData->iFilterofs == MNG_FILTER_DIFFERING)
5908 iRetcode = init_rowdiffering (pData);
5909 else
5910#endif
5911 iRetcode = MNG_NOERROR;
5912 /* filter the row if necessary */
5913 if ((!iRetcode) && (pData->iFilterofs < pData->iPixelofs ) &&
5914 (*(pData->pWorkrow + pData->iFilterofs)) )
5915 iRetcode = mng_filter_a_row (pData);
5916
5917 /* additional leveling/differing ? */
5918 if ((!iRetcode) && (pData->fDifferrow))
5919 {
5920 iRetcode = ((mng_differrow)pData->fDifferrow) (pData);
5921
5922 pSwap = pData->pWorkrow;
5923 pData->pWorkrow = pData->pPrevrow;
5924 pData->pPrevrow = pSwap; /* make sure we're processing the right data */
5925 }
5926
5927 if (!iRetcode)
5928 {
5929 { /* process this row */
5930 if ((!iRetcode) && (pData->fProcessrow))
5931 iRetcode = ((mng_processrow)pData->fProcessrow) (pData);
5932 /* store in object ? */
5933 if ((!iRetcode) && (pData->fStorerow))
5934 iRetcode = ((mng_storerow)pData->fStorerow) (pData);
5935 }
5936 }
5937
5938 if (iRetcode) /* on error bail out */
5939 {
5940 MNG_FREEX (pData, pBuf, iBufsize);
5941 MNG_ERROR (pData, iRetcode);
5942 }
5943
5944 if (!pData->fDifferrow) /* swap row-pointers */
5945 {
5946 pSwap = pData->pWorkrow;
5947 pData->pWorkrow = pData->pPrevrow;
5948 pData->pPrevrow = pSwap; /* so prev points to the processed row! */
5949 }
5950 /* adjust variables for next row */
5951 iRetcode = mng_next_row (pData);
5952
5953 if (iRetcode) /* on error bail out */
5954 {
5955 MNG_FREEX (pData, pBuf, iBufsize);
5956 MNG_ERROR (pData, iRetcode);
5957 }
5958 }
5959 }
5960
5961 pTemp += pData->iRowmax;
5962 iTemplen -= pData->iRowmax;
5963 } /* until some error or EOI
5964 or all pixels received */
5965 while ( (iTemplen > 0) &&
5966 ( (pData->iRow < (mng_int32)pData->iDataheight) ||
5967 ( (pData->iPass >= 0) && (pData->iPass < 7) ) ) );
5968
5969 mng_cleanup_rowproc (pData); /* cleanup row processing buffers !! */
5970
5971 /* restore saved work-parms */
5972 pData->iDatawidth = iSavedatawidth;
5973 pData->iDataheight = iSavedataheight;
5974
5975 pData->fInitrowproc = fSaveinitrowproc;
5976 pData->fDisplayrow = fSavestorerow;
5977 pData->fProcessrow = fSaveprocessrow;
5978 pData->fDifferrow = fSavedifferrow;
5979 pData->pStoreobj = fSavestoreobj;
5980 pData->pStorebuf = fSavestorebuf;
5981
5982#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT
5983 pData->ePng_imgtype = eSavepngimgtype;
5984#endif
5985
5986 pData->iInterlace = iSaveinterlace;
5987 pData->iPass = iSavepass;
5988 pData->iRow = iSaverow;
5989 pData->iRowinc = iSaverowinc;
5990 pData->iCol = iSavecol;
5991 pData->iColinc = iSavecolinc;
5992 pData->iRowsamples = iSaverowsamples;
5993 pData->iSamplemul = iSavesamplemul;
5994 pData->iSampleofs = iSavesampleofs;
5995 pData->iSamplediv = iSavesamplediv;
5996 pData->iRowsize = iSaverowsize;
5997 pData->iRowmax = iSaverowmax;
5998 pData->iFilterofs = iSavefilterofs;
5999 pData->iPixelofs = iSavepixelofs;
6000 pData->iLevel0 = iSavelevel0;
6001 pData->iLevel1 = iSavelevel1;
6002 pData->iLevel2 = iSavelevel2;
6003 pData->iLevel3 = iSavelevel3;
6004 pData->pWorkrow = pSaveworkrow;
6005 pData->pPrevrow = pSaveprevrow;
6006 pData->pRGBArow = pSaverGBArow;
6007 pData->bIsRGBA16 = bSaveisRGBA16;
6008 pData->bIsOpaque = bSaveisOpaque;
6009 pData->iFilterbpp = iSavefilterbpp;
6010 pData->iDestl = iSavedestl;
6011 pData->iDestt = iSavedestt;
6012 pData->iDestr = iSavedestr;
6013 pData->iDestb = iSavedestb;
6014 pData->iSourcel = iSavesourcel;
6015 pData->iSourcet = iSavesourcet;
6016 pData->iSourcer = iSavesourcer;
6017 pData->iSourceb = iSavesourceb;
6018
6019 /* create the animation directives ! */
6020 pProcess = (mng_processobject)pANG->sHeader.fProcess;
6021 iRetcode = pProcess (pData, (mng_objectp)pData->pANG);
6022 if (iRetcode)
6023 return iRetcode;
6024
6025#endif /* MNG_SUPPORT_DISPLAY */
6026
6027 MNG_FREE (pData, pBuf, iBufsize); /* always free the temp buffer ! */
6028 }
6029
6030 *piRawlen = 0;
6031
6032 return MNG_NOERROR;
6033}
6034#endif
6035
6036/* ************************************************************************** */
6037
6038#ifdef MNG_INCLUDE_ANG_PROPOSAL
6039MNG_C_SPECIALFUNC (mng_special_adat)
6040{
6041 return MNG_NOERROR;
6042}
6043#endif
6044
6045/* ************************************************************************** */
6046
6047MNG_C_SPECIALFUNC (mng_special_unknown)
6048{
6049 /* critical chunk ? */
6050 if ((((mng_uint32)pData->iChunkname & 0x20000000) == 0)
6051#ifdef MNG_SKIPCHUNK_SAVE
6052 && (pData->iChunkname != MNG_UINT_SAVE)
6053#endif
6054#ifdef MNG_SKIPCHUNK_SEEK
6055 && (pData->iChunkname != MNG_UINT_SEEK)
6056#endif
6057#ifdef MNG_SKIPCHUNK_DBYK
6058 && (pData->iChunkname != MNG_UINT_DBYK)
6059#endif
6060#ifdef MNG_SKIPCHUNK_ORDR
6061 && (pData->iChunkname != MNG_UINT_ORDR)
6062#endif
6063 )
6064 MNG_ERROR (pData, MNG_UNKNOWNCRITICAL);
6065
6066 if (pData->fProcessunknown) /* let the app handle it ? */
6067 {
6068 mng_bool bOke = pData->fProcessunknown ((mng_handle)pData, pData->iChunkname,
6069 ((mng_unknown_chunkp)pChunk)->iDatasize,
6070 ((mng_unknown_chunkp)pChunk)->pData);
6071 if (!bOke)
6072 MNG_ERROR (pData, MNG_APPMISCERROR);
6073 }
6074
6075 return MNG_NOERROR; /* done */
6076}
6077
6078/* ************************************************************************** */
6079
6080#endif /* MNG_INCLUDE_READ_PROCS || MNG_INCLUDE_WRITE_PROCS */
6081#endif /* MNG_OPTIMIZE_CHUNKREADER */
6082
6083/* ************************************************************************** */
6084/* * end of file * */
6085/* ************************************************************************** */
6086
6087
6088
6089
6090
Note: See TracBrowser for help on using the repository browser.