1 /* ************************************************************************** */
2 /* *             For conditions of distribution and use,                    * */
3 /* *                see copyright notice in libmng.h                        * */
4 /* ************************************************************************** */
5 /* *                                                                        * */
6 /* * project   : libmng                                                     * */
7 /* * file      : libmng_data.h             copyright (c) 2000 G.Juyn        * */
8 /* * version   : 1.0.2                                                      * */
9 /* *                                                                        * */
10 /* * purpose   : main data structure definition                             * */
11 /* *                                                                        * */
12 /* * author    : G.Juyn                                                     * */
13 /* * web       : http://www.3-t.com                                         * */
14 /* * email     : mailto:info@3-t.com                                        * */
15 /* *                                                                        * */
16 /* * comment   : Definition of the library main data structure              * */
17 /* *                                                                        * */
18 /* * changes   : 0.5.1 - 05/04/2000 - G.Juyn                                * */
19 /* *             - added CRC table to main structure (for thread-safety)    * */
20 /* *             0.5.1 - 05/06/2000 - G.Juyn                                * */
21 /* *             - added iPLTEentries for checking hIST-length              * */
22 /* *             0.5.1 - 05/08/2000 - G.Juyn                                * */
23 /* *             - changed palette definition to exported palette-type      * */
24 /* *             - removed frozen indicator                                 * */
25 /* *             - added create/write indicators                            * */
26 /* *             - changed strict-ANSI stuff                                * */
27 /* *             0.5.1 - 05/13/2000 - G.Juyn                                * */
28 /* *             - added eMNGma hack (will be removed in 1.0.0 !!!)         * */
29 /* *             - added TERM animation object pointer (easier reference)   * */
30 /* *             - added saved-data structure for SAVE/SEEK processing      * */
31 /* *                                                                        * */
32 /* *             0.5.2 - 05/18/2000 - G.Juyn                                * */
33 /* *             - added fields for JNG support (IJG-based)                 * */
34 /* *             0.5.2 - 05/24/2000 - G.Juyn                                * */
35 /* *             - changed global tRNS definition                           * */
36 /* *             0.5.2 - 05/30/2000 - G.Juyn                                * */
37 /* *             - added delta-image fields                                 * */
38 /* *             0.5.2 - 06/01/2000 - G.Juyn                                * */
39 /* *             - added internal delta-image processing callbacks          * */
40 /* *             0.5.2 - 06/02/2000 - G.Juyn                                * */
41 /* *             - changed SWAP_ENDIAN to BIGENDIAN_SUPPORTED               * */
42 /* *               (contributed by Tim Rowley)                              * */
43 /* *             - added getalphaline callback for RGB8_A8 canvasstyle      * */
44 /* *             0.5.2 - 06/06/2000 - G.Juyn                                * */
45 /* *             - added parameter for delayed buffer-processing            * */
46 /* *                                                                        * */
47 /* *             0.5.3 - 06/16/2000 - G.Juyn                                * */
48 /* *             - added update-region parms for refresh calback            * */
49 /* *             - added Needrefresh parameter                              * */
50 /* *             0.5.3 - 06/17/2000 - G.Juyn                                * */
51 /* *             - added Deltaimmediate parm for faster delta-processing    * */
52 /* *             0.5.3 - 06/21/2000 - G.Juyn                                * */
53 /* *             - added Speed parameter to facilitate testing              * */
54 /* *             - added Imagelevel parameter for processtext callback      * */
55 /* *             0.5.3 - 06/26/2000 - G.Juyn                                * */
56 /* *             - changed userdata variable to mng_ptr                     * */
57 /* *                                                                        * */
58 /* *             0.9.1 - 07/07/2000 - G.Juyn                                * */
59 /* *             - added variables for go_xxxx processing                   * */
60 /* *             0.9.1 - 07/08/2000 - G.Juyn                                * */
61 /* *             - added variables for improved timing support              * */
62 /* *             0.9.1 - 07/15/2000 - G.Juyn                                * */
63 /* *             - added callbacks for SAVE/SEEK processing                 * */
64 /* *             - added variable for NEEDSECTIONWAIT breaks                * */
65 /* *             - added variable for freeze & reset processing             * */
66 /* *             0.9.1 - 07/17/2000 - G.Juyn                                * */
67 /* *             - fixed suspension-buffering for 32K+ chunks               * */
68 /* *                                                                        * */
69 /* *             0.9.2 - 07/29/2000 - G.Juyn                                * */
70 /* *             - removed Nextbackxxx fields (no longer used)              * */
71 /* *             0.9.2 - 07/31/2000 - G.Juyn                                * */
72 /* *             - fixed wrapping of suspension parameters                  * */
73 /* *             0.9.2 - 08/04/2000 - G.Juyn                                * */
74 /* *             - B111096 - fixed large-buffer read-suspension             * */
75 /* *             0.9.2 - 08/05/2000 - G.Juyn                                * */
76 /* *             - changed file-prefixes                                    * */
77 /* *                                                                        * */
78 /* *             0.9.3 - 08/26/2000 - G.Juyn                                * */
79 /* *             - added MAGN chunk                                         * */
80 /* *             0.9.3 - 09/07/2000 - G.Juyn                                * */
81 /* *             - added support for new filter_types                       * */
82 /* *             0.9.3 - 09/10/2000 - G.Juyn                                * */
83 /* *             - fixed DEFI behavior                                      * */
84 /* *             0.9.3 - 10/10/2000 - G.Juyn                                * */
85 /* *             - added support for alpha-depth prediction                 * */
86 /* *             0.9.3 - 10/11/2000 - G.Juyn                                * */
87 /* *             - added support for nEED                                   * */
88 /* *             0.9.3 - 10/16/2000 - G.Juyn                                * */
89 /* *             - added optional support for bKGD for PNG images           * */
90 /* *             - added support for JDAA                                   * */
91 /* *             0.9.3 - 10/17/2000 - G.Juyn                                * */
92 /* *             - added callback to process non-critical unknown chunks    * */
93 /* *             - fixed support for bKGD                                   * */
94 /* *             0.9.3 - 10/19/2000 - G.Juyn                                * */
95 /* *             - implemented delayed delta-processing                     * */
96 /* *             0.9.4 - 12/16/2000 - G.Juyn                                * */
97 /* *             - fixed mixup of data- & function-pointers (thanks Dimitri)* */
98 /* *                                                                        * */
99 /* *             1.0.1 - 02/08/2001 - G.Juyn                                * */
100 /* *             - added MEND processing callback                           * */
101 /* *             1.0.1 - 02/13/2001 - G.Juyn                                * */
102 /* *             - fixed first FRAM_MODE=4 timing problem                   * */
103 /* *                                                                        * */
104 /* *             1.0.2 - 06/23/2001 - G.Juyn                                * */
105 /* *             - added optimization option for MNG-video playback         * */
106 /* *             - added processterm callback                               * */
107 /* *             1.0.2 - 06/25/2001 - G.Juyn                                * */
108 /* *             - added option to turn off progressive refresh             * */
109 /* *                                                                        * */
110 /* ************************************************************************** */
111 
112 #if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
113 #pragma option -A                      /* force ANSI-C */
114 #endif
115 
116 #ifndef _libmng_data_h_
117 #define _libmng_data_h_
118 
119 /* ************************************************************************** */
120 
121 #define MNG_MAGIC 0x52530a0aL
122 
123 /* ************************************************************************** */
124 /* *                                                                        * */
125 /* * Internal structures                                                    * */
126 /* *                                                                        * */
127 /* ************************************************************************** */
128 
129 typedef mng_palette8 mng_rgbpaltab;
130 
131 /* ************************************************************************** */
132 /* *                                                                        * */
133 /* * The saved_data structure                                               * */
134 /* *                                                                        * */
135 /* * This contains the saved data after a SAVE chunk has been processed.    * */
136 /* * The data is saved from the main data structure during SAVE processing, * */
137 /* * and restored to the main data structure during SEEK processing.        * */
138 /* *                                                                        * */
139 /* ************************************************************************** */
140 
141 typedef struct mng_savedata_struct {
142 
143 #if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
144            mng_bool          bHasglobalPLTE;     /* global PLTE chunk processed */
145            mng_bool          bHasglobalTRNS;     /* global tRNS chunk processed */
146            mng_bool          bHasglobalGAMA;     /* global gAMA chunk processed */
147            mng_bool          bHasglobalCHRM;     /* global cHRM chunk processed */
148            mng_bool          bHasglobalSRGB;     /* global sRGB chunk processed */
149            mng_bool          bHasglobalICCP;     /* global iCCP chunk processed */
150            mng_bool          bHasglobalBKGD;     /* global bKGD chunk processed */
151 #endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */
152 
153 #ifdef MNG_SUPPORT_DISPLAY
154            mng_uint16        iBACKred;           /* BACK fields */
155            mng_uint16        iBACKgreen;
156            mng_uint16        iBACKblue;
157            mng_uint8         iBACKmandatory;
158            mng_uint16        iBACKimageid;
159            mng_uint8         iBACKtile;
160 
161            mng_uint8         iFRAMmode;          /* FRAM fields (global) */
162            mng_uint32        iFRAMdelay;
163            mng_uint32        iFRAMtimeout;
164            mng_bool          bFRAMclipping;
165            mng_int32         iFRAMclipl;
166            mng_int32         iFRAMclipr;
167            mng_int32         iFRAMclipt;
168            mng_int32         iFRAMclipb;
169 
170            mng_uint32        iGlobalPLTEcount;   /* global PLTE fields */
171            mng_rgbpaltab     aGlobalPLTEentries;
172 
173            mng_uint32        iGlobalTRNSrawlen;  /* global tRNS fields */
174            mng_uint8arr      aGlobalTRNSrawdata;
175 
176            mng_uint32        iGlobalGamma;       /* global gAMA fields */
177 
178            mng_uint32        iGlobalWhitepointx; /* global cHRM fields */
179            mng_uint32        iGlobalWhitepointy;
180            mng_uint32        iGlobalPrimaryredx;
181            mng_uint32        iGlobalPrimaryredy;
182            mng_uint32        iGlobalPrimarygreenx;
183            mng_uint32        iGlobalPrimarygreeny;
184            mng_uint32        iGlobalPrimarybluex;
185            mng_uint32        iGlobalPrimarybluey;
186 
187            mng_uint8         iGlobalRendintent;  /* global sRGB fields */
188 
189            mng_uint32        iGlobalProfilesize; /* global iCCP fields */
190            mng_ptr           pGlobalProfile;
191 
192            mng_uint16        iGlobalBKGDred;     /* global bKGD fields */
193            mng_uint16        iGlobalBKGDgreen;
194            mng_uint16        iGlobalBKGDblue;
195 #endif /* MNG_SUPPORT_DISPLAY */
196 
197         } mng_savedata;
198 
199 typedef mng_savedata * mng_savedatap;
200 
201 /* ************************************************************************** */
202 /* *                                                                        * */
203 /* * The main libmng data structure                                         * */
204 /* *                                                                        * */
205 /* * The handle used in all functions points to this structure which        * */
206 /* * contains all volatile data necessary to process the network graphic.   * */
207 /* *                                                                        * */
208 /* ************************************************************************** */
209 
210 typedef struct mng_data_struct {
211 
212            mng_uint32        iMagic;             /* magic number to validate
213                                                     a given handle */
214            mng_ptr           pUserdata;          /* application workdata */
215 
216            mng_imgtype       eSigtype;           /* image information */
217            mng_imgtype       eImagetype;         /* initially zeroed */
218            mng_uint32        iWidth;             /* filled after header is processed */
219            mng_uint32        iHeight;
220            mng_uint32        iTicks;             /* these only after MHDR */
221            mng_uint32        iLayercount;
222            mng_uint32        iFramecount;
223            mng_uint32        iPlaytime;
224            mng_uint32        iSimplicity;
225            mng_uint8         iAlphadepth;        /* indicates expected alpha-depth */
226 
227            mng_uint32        iImagelevel;        /* level an image inside a stream */
228 
229            mng_uint32        iCanvasstyle;       /* layout of the drawing-canvas */
230            mng_uint32        iBkgdstyle;         /* layout of the background-canvas */
231 
232            mng_int8          iMagnify;           /* magnification factor (not used yet) */
233            mng_uint32        iOffsetx;           /* x-offset for extremely large image */
234            mng_uint32        iOffsety;           /* y-offset for extremely large image */
235            mng_uint32        iCanvaswidth;       /* real canvas size */
236            mng_uint32        iCanvasheight;      /* must be set by processheader callback */
237 
238            mng_uint16        iBGred;             /* default background color */
239            mng_uint16        iBGgreen;           /* initially "black" */
240            mng_uint16        iBGblue;
241            mng_bool          bUseBKGD;           /* preferred use of bKGD for PNG */
242 
243            mng_bool          bIssRGB;            /* indicates sRGB system */
244 
245 #ifdef MNG_FULL_CMS                              /* little CMS variables */
246            mng_cmsprof       hProf1;             /* image input profile */
247            mng_cmsprof       hProf2;             /* default output profile */
248            mng_cmsprof       hProf3;             /* default sRGB profile */
249            mng_cmstrans      hTrans;             /* current transformation handle */
250 #endif
251 
252            mng_float         dViewgamma;         /* gamma calculation variables */
253            mng_float         dDisplaygamma;      /* initially set for sRGB conditions */
254            mng_float         dDfltimggamma;
255 
256            mng_bool          bStorechunks;       /* switch for storing chunkdata */
257            mng_bool          bSectionbreaks;     /* indicate NEEDSECTIONWAIT breaks */
258            mng_bool          bCacheplayback;     /* switch to cache playback info */
259            mng_bool          bDoProgressive;     /* progressive refresh for large images */
260 
261            mng_speedtype     iSpeed;             /* speed-modifier for animations */
262 
263            mng_uint32        iMaxwidth;          /* maximum canvas size */
264            mng_uint32        iMaxheight;         /* initially set to 1024 x 1024 */
265 
266            mng_int32         iErrorcode;         /* error reporting fields */
267            mng_int8          iSeverity;
268            mng_int32         iErrorx1;
269            mng_int32         iErrorx2;
270            mng_pchar         zErrortext;
271 
272            mng_memalloc      fMemalloc;          /* callback pointers */
273            mng_memfree       fMemfree;           /* initially nulled */
274            mng_openstream    fOpenstream;
275            mng_closestream   fClosestream;
276            mng_readdata      fReaddata;
277            mng_writedata     fWritedata;
278            mng_errorproc     fErrorproc;
279            mng_traceproc     fTraceproc;
280            mng_processheader fProcessheader;
281            mng_processtext   fProcesstext;
282            mng_processsave   fProcesssave;
283            mng_processseek   fProcessseek;
284            mng_processneed   fProcessneed;
285            mng_processmend   fProcessmend;
286            mng_processunknown fProcessunknown;
287            mng_processterm   fProcessterm;
288            mng_getcanvasline fGetcanvasline;
289            mng_getbkgdline   fGetbkgdline;
290            mng_getalphaline  fGetalphaline;
291            mng_refresh       fRefresh;
292            mng_gettickcount  fGettickcount;
293            mng_settimer      fSettimer;
294            mng_processgamma  fProcessgamma;
295            mng_processchroma fProcesschroma;
296            mng_processsrgb   fProcesssrgb;
297            mng_processiccp   fProcessiccp;
298            mng_processarow   fProcessarow;
299 
300 #if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
301            mng_bool          bPreDraft48;        /* flags ancient style draft */
302 
303            mng_chunkid       iChunkname;         /* read/write-state variables */
304            mng_uint32        iChunkseq;
305            mng_chunkp        pFirstchunk;        /* double-linked list of */
306            mng_chunkp        pLastchunk;         /* stored chunk-structures */
307 
308            mng_bool          bHasheader;         /* first header chunk processed */
309            mng_bool          bHasMHDR;           /* inside a MHDR-MEND sequence */
310            mng_bool          bHasIHDR;           /* inside a IHDR-IEND sequence */
311            mng_bool          bHasBASI;           /* inside a BASI-IEND sequence */
312            mng_bool          bHasDHDR;           /* inside a DHDR-IEND sequence */
313 #ifdef MNG_INCLUDE_JNG
314            mng_bool          bHasJHDR;           /* inside a JHDR-IEND sequence */
315            mng_bool          bHasJSEP;           /* passed the JSEP separator */
316            mng_bool          bHasJDAA;           /* at least 1 JDAA processed */
317            mng_bool          bHasJDAT;           /* at least 1 JDAT processed */
318 #endif
319            mng_bool          bHasPLTE;           /* PLTE chunk processed */
320            mng_bool          bHasTRNS;           /* tRNS chunk processed */
321            mng_bool          bHasGAMA;           /* gAMA chunk processed */
322            mng_bool          bHasCHRM;           /* cHRM chunk processed */
323            mng_bool          bHasSRGB;           /* sRGB chunk processed */
324            mng_bool          bHasICCP;           /* iCCP chunk processed */
325            mng_bool          bHasBKGD;           /* bKGD chunk processed */
326            mng_bool          bHasIDAT;           /* at least 1 IDAT processed */
327 
328            mng_bool          bHasSAVE;           /* SAVE chunk processed */
329            mng_bool          bHasBACK;           /* BACK chunk processed */
330            mng_bool          bHasFRAM;           /* FRAM chunk processed */
331            mng_bool          bHasTERM;           /* TERM chunk processed */
332            mng_bool          bHasLOOP;           /* at least 1 LOOP open */
333 
334            mng_bool          bHasglobalPLTE;     /* global PLTE chunk processed */
335            mng_bool          bHasglobalTRNS;     /* global tRNS chunk processed */
336            mng_bool          bHasglobalGAMA;     /* global gAMA chunk processed */
337            mng_bool          bHasglobalCHRM;     /* global cHRM chunk processed */
338            mng_bool          bHasglobalSRGB;     /* global sRGB chunk processed */
339            mng_bool          bHasglobalICCP;     /* global iCCP chunk processed */
340            mng_bool          bHasglobalBKGD;     /* global bKGD chunk processed */
341 
342            mng_uint32        iDatawidth;         /* IHDR/BASI/DHDR fields */
343            mng_uint32        iDataheight;        /* valid if inside IHDR-IEND, */
344            mng_uint8         iBitdepth;          /* BASI-IEND or DHDR-IEND */
345            mng_uint8         iColortype;
346            mng_uint8         iCompression;
347            mng_uint8         iFilter;
348            mng_uint8         iInterlace;
349 
350            mng_uint32        iPLTEcount;         /* PLTE fields */
351 
352            mng_bool          bEMNGMAhack;        /* TODO: to be removed in 1.0.0 !!! */
353 
354 #ifdef MNG_INCLUDE_JNG
355            mng_uint8         iJHDRcolortype;     /* JHDR fields */
356            mng_uint8         iJHDRimgbitdepth;   /* valid if inside JHDR-IEND */
357            mng_uint8         iJHDRimgcompression;
358            mng_uint8         iJHDRimginterlace;
359            mng_uint8         iJHDRalphabitdepth;
360            mng_uint8         iJHDRalphacompression;
361            mng_uint8         iJHDRalphafilter;
362            mng_uint8         iJHDRalphainterlace;
363 #endif
364 
365 #endif /* MNG_SUPPORT_READ || MNG_SUPPORT_WRITE */
366 
367 #ifdef MNG_SUPPORT_READ
368            mng_bool          bReading;           /* read processing variables */
369            mng_bool          bHavesig;
370            mng_bool          bEOF;
371            mng_uint32        iReadbufsize;
372            mng_uint8p        pReadbuf;
373 
374            mng_uint32        iLargebufsize;      /* temp for very large chunks */
375            mng_uint8p        pLargebuf;
376 
377            mng_uint32        iSuspendtime;       /* tickcount at last suspension */
378            mng_bool          bSuspended;         /* input-reading has been suspended;
379                                                     we're expecting a call to
380                                                     mng_read_resume! */
381            mng_uint8         iSuspendpoint;      /* indicates at which point the flow
382                                                     was broken to suspend input-reading */
383 
384            mng_bool          bSuspensionmode;    /* I/O-suspension variables */
385            mng_uint32        iSuspendbufsize;
386            mng_uint8p        pSuspendbuf;
387            mng_uint8p        pSuspendbufnext;
388            mng_uint32        iSuspendbufleft;
389            mng_uint32        iChunklen;          /* chunk length */
390            mng_uint8p        pReadbufnext;       /* 32K+ suspension-processing */
391 #endif /* MNG_SUPPORT_READ */
392 
393 #ifdef MNG_SUPPORT_WRITE
394            mng_bool          bCreating;          /* create/write processing variables */
395            mng_bool          bWriting;
396            mng_chunkid       iFirstchunkadded;
397            mng_uint32        iWritebufsize;
398            mng_uint8p        pWritebuf;
399 #endif
400 
401 #ifdef MNG_SUPPORT_DISPLAY
402            mng_bool          bDisplaying;        /* display-state variables */
403            mng_bool          bFramedone;
404            mng_uint32        iFrameseq;
405            mng_uint32        iLayerseq;
406            mng_uint32        iFrametime;         /* millisecs */
407 
408            mng_uint32        iRequestframe;      /* go_xxxx variables */
409            mng_uint32        iRequestlayer;
410            mng_uint32        iRequesttime;
411            mng_bool          bSearching;
412 
413            mng_bool          bRestorebkgd;       /* flags restore required before IDAT/JDAT */
414 
415            mng_uint32        iRuntime;           /* millisecs since start */
416            mng_uint32        iSynctime;          /* tickcount at last framesync */
417            mng_uint32        iStarttime;         /* tickcount at start */
418            mng_uint32        iEndtime;           /* tickcount at end */
419            mng_bool          bRunning;           /* animation is active */
420            mng_bool          bTimerset;          /* the timer has been set;
421                                                     we're expecting a call to
422                                                     mng_display_resume! */
423            mng_uint8         iBreakpoint;        /* indicates at which point the
424                                                     flow was broken to run the timer */
425            mng_bool          bSectionwait;       /* indicates a section break */
426            mng_bool          bFreezing;          /* indicates app requested a freeze */
427            mng_bool          bResetting;         /* indicates app requested a reset */
428            mng_bool          bNeedrefresh;       /* indicates screen-refresh is needed */
429            mng_objectp       pCurrentobj;        /* current "object" */
430            mng_objectp       pCurraniobj;        /* current animation object
431                                                     "to be"/"being" processed */
432            mng_objectp       pTermaniobj;        /* TERM animation object */
433            mng_uint32        iIterations;        /* TERM/MEND iteration count */
434            mng_objectp       pObjzero;           /* "on-the-fly" image (object = 0) */
435            mng_objectp       pLastclone;         /* last clone */
436            mng_objectp       pStoreobj;          /* current store object for row routines */
437            mng_objectp       pStorebuf;          /* current store object-buffer for row routines */
438            mng_objectp       pRetrieveobj;       /* current retrieve object for row routines */
439            mng_savedatap     pSavedata;          /* pointer to saved data (after SAVE) */
440 
441            mng_uint32        iUpdateleft;        /* update region for refresh */
442            mng_uint32        iUpdateright;
443            mng_uint32        iUpdatetop;
444            mng_uint32        iUpdatebottom;
445 
446            mng_int8          iPass;              /* current interlacing pass;
447                                                     negative value means no interlace */
448            mng_int32         iRow;               /* current row counter */
449            mng_int32         iRowinc;            /* row increment for this pass */
450            mng_int32         iCol;               /* current starting column */
451            mng_int32         iColinc;            /* column increment for this pass */
452            mng_int32         iRowsamples;        /* nr. of samples in current workrow */
453            mng_int32         iSamplemul;         /* needed to calculate rowsize */
454            mng_int32         iSampleofs;            /* from rowsamples */
455            mng_int32         iSamplediv;
456            mng_int32         iRowsize;           /* size of actual data in work row */
457            mng_int32         iRowmax;            /* maximum size of data in work row */
458            mng_int32         iFilterofs;         /* offset to filter-byte in work row */
459            mng_int32         iPixelofs;          /* offset to pixel-bytes in work row */
460            mng_uint32        iLevel0;            /* leveling variables */
461            mng_uint32        iLevel1;
462            mng_uint32        iLevel2;
463            mng_uint32        iLevel3;
464            mng_uint8p        pWorkrow;           /* working row of pixel-data */
465            mng_uint8p        pPrevrow;           /* previous row of pixel-data */
466            mng_uint8p        pRGBArow;           /* intermediate row of RGBA8 or RGBA16 data */
467            mng_bool          bIsRGBA16;          /* indicates intermediate row is RGBA16 */
468            mng_bool          bIsOpaque;          /* indicates intermediate row is fully opaque */
469            mng_int32         iFilterbpp;         /* bpp index for filtering routines */
470 
471            mng_int32         iSourcel;           /* variables for showing objects */
472            mng_int32         iSourcer;
473            mng_int32         iSourcet;
474            mng_int32         iSourceb;
475            mng_int32         iDestl;
476            mng_int32         iDestr;
477            mng_int32         iDestt;
478            mng_int32         iDestb;
479 
480            mng_objectp       pFirstimgobj;       /* double-linked list of */
481            mng_objectp       pLastimgobj;        /* image-object structures */
482            mng_objectp       pFirstaniobj;       /* double-linked list of */
483            mng_objectp       pLastaniobj;        /* animation-object structures */
484 
485 #if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS)
486            mng_uint8         aGammatab[256];     /* precomputed gamma lookup table */
487            mng_float         dLastgamma;         /* last gamma used to compute table */
488 #endif
489 
490            mng_fptr          fDisplayrow;        /* internal callback to display an
491                                                     uncompressed/unfiltered/
492                                                     color-corrected row */
493            mng_fptr          fRestbkgdrow;       /* internal callback for restore-
494                                                     background processing of a row */
495            mng_fptr          fCorrectrow;        /* internal callback to color-correct an
496                                                     uncompressed/unfiltered row */
497            mng_fptr          fRetrieverow;       /* internal callback to retrieve an
498                                                     uncompressed/unfiltered row of data */
499            mng_fptr          fStorerow;          /* internal callback to store an
500                                                     uncompressed/unfiltered row of data */
501            mng_fptr          fProcessrow;        /* internal callback to process an
502                                                     uncompressed row of data */
503            mng_fptr          fDifferrow;         /* internal callback to perform
504                                                     added filter leveling and
505                                                     differing on an unfiltered row */
506            mng_fptr          fScalerow;          /* internal callback to scale a
507                                                     delta-row to the bitdepth of its target */
508            mng_fptr          fDeltarow;          /* internal callback to execute a
509                                                     delta-row onto a target */
510            mng_fptr          fInitrowproc;       /* internal callback to initialize
511                                                     the row processing */
512 
513            mng_uint16        iDEFIobjectid;      /* DEFI fields */
514            mng_bool          bDEFIhasdonotshow;
515            mng_uint8         iDEFIdonotshow;
516            mng_bool          bDEFIhasconcrete;
517            mng_uint8         iDEFIconcrete;
518            mng_bool          bDEFIhasloca;
519            mng_int32         iDEFIlocax;
520            mng_int32         iDEFIlocay;
521            mng_bool          bDEFIhasclip;
522            mng_int32         iDEFIclipl;
523            mng_int32         iDEFIclipr;
524            mng_int32         iDEFIclipt;
525            mng_int32         iDEFIclipb;
526 
527            mng_uint16        iBACKred;           /* BACK fields */
528            mng_uint16        iBACKgreen;
529            mng_uint16        iBACKblue;
530            mng_uint8         iBACKmandatory;
531            mng_uint16        iBACKimageid;
532            mng_uint8         iBACKtile;
533 
534            mng_uint8         iFRAMmode;          /* FRAM fields (global) */
535            mng_uint32        iFRAMdelay;
536            mng_uint32        iFRAMtimeout;
537            mng_bool          bFRAMclipping;
538            mng_int32         iFRAMclipl;
539            mng_int32         iFRAMclipr;
540            mng_int32         iFRAMclipt;
541            mng_int32         iFRAMclipb;
542 
543            mng_uint8         iFramemode;         /* current subframe variables */
544            mng_uint32        iFramedelay;
545            mng_uint32        iFrametimeout;
546            mng_bool          bFrameclipping;
547            mng_int32         iFrameclipl;
548            mng_int32         iFrameclipr;
549            mng_int32         iFrameclipt;
550            mng_int32         iFrameclipb;
551 
552            mng_uint32        iNextdelay;         /* delay for *after* next image */
553 
554            mng_uint8         iSHOWmode;          /* SAVE fields */
555            mng_uint16        iSHOWfromid;
556            mng_uint16        iSHOWtoid;
557            mng_uint16        iSHOWnextid;
558            mng_int16         iSHOWskip;
559 
560            mng_uint32        iGlobalPLTEcount;   /* global PLTE fields */
561            mng_rgbpaltab     aGlobalPLTEentries;
562 
563            mng_uint32        iGlobalTRNSrawlen;  /* global tRNS fields */
564            mng_uint8arr      aGlobalTRNSrawdata;
565 
566            mng_uint32        iGlobalGamma;       /* global gAMA fields */
567 
568            mng_uint32        iGlobalWhitepointx; /* global cHRM fields */
569            mng_uint32        iGlobalWhitepointy;
570            mng_uint32        iGlobalPrimaryredx;
571            mng_uint32        iGlobalPrimaryredy;
572            mng_uint32        iGlobalPrimarygreenx;
573            mng_uint32        iGlobalPrimarygreeny;
574            mng_uint32        iGlobalPrimarybluex;
575            mng_uint32        iGlobalPrimarybluey;
576 
577            mng_uint8         iGlobalRendintent;  /* global sRGB fields */
578 
579            mng_uint32        iGlobalProfilesize; /* global iCCP fields */
580            mng_ptr           pGlobalProfile;
581 
582            mng_uint16        iGlobalBKGDred;     /* global bKGD fields */
583            mng_uint16        iGlobalBKGDgreen;
584            mng_uint16        iGlobalBKGDblue;
585 
586            mng_ptr           pDeltaImage;        /* delta-image fields */
587            mng_uint8         iDeltaImagetype;
588            mng_uint8         iDeltatype;
589            mng_uint32        iDeltaBlockwidth;
590            mng_uint32        iDeltaBlockheight;
591            mng_uint32        iDeltaBlockx;
592            mng_uint32        iDeltaBlocky;
593            mng_bool          bDeltaimmediate;
594 
595            mng_fptr          fDeltagetrow;       /* internal delta-proc callbacks */
596            mng_fptr          fDeltaaddrow;
597            mng_fptr          fDeltareplacerow;
598            mng_fptr          fDeltaputrow;
599 
600            mng_uint16        iMAGNfromid;
601            mng_uint16        iMAGNtoid;
602 #endif /* MNG_SUPPORT_DISPLAY */
603 
604 #ifdef MNG_INCLUDE_ZLIB
605            z_stream          sZlib;              /* zlib (de)compression variables */
606 
607            mng_int32         iZlevel;            /* zlib compression parameters */
608            mng_int32         iZmethod;
609            mng_int32         iZwindowbits;
610            mng_int32         iZmemlevel;
611            mng_int32         iZstrategy;
612 
613            mng_uint32        iMaxIDAT;           /* maximum size of IDAT data */
614 
615            mng_bool          bInflating;         /* indicates "inflate" in progress */
616            mng_bool          bDeflating;         /* indicates "deflate" in progress */
617 #endif /* MNG_INCLUDE_ZLIB */
618 
619 #ifdef MNG_INCLUDE_JNG
620            mngjpeg_dctmethod eJPEGdctmethod;     /* IJG compression variables */
621            mng_int32         iJPEGquality;
622            mng_int32         iJPEGsmoothing;
623            mng_bool          bJPEGcompressprogr;
624            mng_bool          bJPEGcompressopt;
625 
626            mng_uint32        iMaxJDAT;           /* maximum size of JDAT/JDAA data */
627 
628            mngjpeg_compp     pJPEGcinfo;         /* compression structure */
629            mngjpeg_errorp    pJPEGcerr;          /* error-manager compress */
630 
631            mngjpeg_decompp   pJPEGdinfo;         /* decompression structure (JDAT) */
632            mngjpeg_errorp    pJPEGderr;          /* error-manager decompress (JDAT) */
633            mngjpeg_sourcep   pJPEGdsrc;          /* source-manager decompress (JDAT) */
634 
635            mngjpeg_decompp   pJPEGdinfo2;        /* decompression structure (JDAA) */
636            mngjpeg_errorp    pJPEGderr2;         /* error-manager decompress (JDAA) */
637            mngjpeg_sourcep   pJPEGdsrc2;         /* source-manager decompress (JDAA) */
638 
639            mng_uint8p        pJPEGbuf;           /* buffer for JPEG (de)compression (JDAT) */
640            mng_uint32        iJPEGbufmax;        /* allocated space for buffer (JDAT) */
641            mng_uint8p        pJPEGcurrent;       /* current pointer into buffer (JDAT) */
642            mng_uint32        iJPEGbufremain;     /* remaining bytes in buffer (JDAT) */
643            mng_uint32        iJPEGtoskip;        /* bytes to skip on next input-block (JDAT) */
644 
645            mng_uint8p        pJPEGbuf2;          /* buffer for JPEG (de)compression (JDAA) */
646            mng_uint32        iJPEGbufmax2;       /* allocated space for buffer (JDAA) */
647            mng_uint8p        pJPEGcurrent2;      /* current pointer into buffer (JDAA) */
648            mng_uint32        iJPEGbufremain2;    /* remaining bytes in buffer (JDAA) */
649            mng_uint32        iJPEGtoskip2;       /* bytes to skip on next input-block (JDAA) */
650 
651            mng_uint8p        pJPEGrow;           /* buffer for a JPEG row of samples (JDAT) */
652            mng_uint32        iJPEGrowlen;
653 
654            mng_uint8p        pJPEGrow2;          /* buffer for a JPEG row of samples (JDAA) */
655            mng_uint32        iJPEGrowlen2;
656 
657            mng_bool          bJPEGcompress;      /* indicates "compress" initialized */
658 
659            mng_bool          bJPEGdecompress;    /* indicates "decompress" initialized (JDAT) */
660            mng_bool          bJPEGhasheader;     /* indicates "readheader" succeeded (JDAT) */
661            mng_bool          bJPEGdecostarted;   /* indicates "decompress" started (JDAT) */
662            mng_bool          bJPEGscanstarted;   /* indicates "first scan" started (JDAT) */
663            mng_bool          bJPEGprogressive;   /* indicates a progressive image (JDAT) */
664 
665            mng_bool          bJPEGdecompress2;   /* indicates "decompress" initialized (JDAA) */
666            mng_bool          bJPEGhasheader2;    /* indicates "readheader" succeeded (JDAA) */
667            mng_bool          bJPEGdecostarted2;  /* indicates "decompress" started (JDAA) */
668            mng_bool          bJPEGscanstarted2;  /* indicates "first scan" started (JDAA) */
669            mng_bool          bJPEGprogressive2;  /* indicates a progressive image (JDAA) */
670 
671            mng_fptr          fStorerow2;         /* internal callback to store an
672                                                     uncompressed/unfiltered row of JPEG-data (JDAT) */
673 
674            mng_fptr          fStorerow3;         /* internal callback to store an
675                                                     uncompressed/unfiltered row of JPEG-data (JDAA) */
676 
677            mng_uint32        iJPEGrow;           /* row-number for current JPEG row */
678            mng_uint32        iJPEGalpharow;      /* nr. of rows filled with alpha */
679            mng_uint32        iJPEGrgbrow;        /* nr. of rows filled with 'color'-info */
680            mng_uint32        iJPEGdisprow;       /* nr. of rows already displayed "on-the-fly" */
681 
682 #if defined(MNG_USE_SETJMP) && defined (MNG_INCLUDE_IJG6B)
683            jmp_buf           sErrorbuf;          /* setjmp/longjmp buffer (error-recovery) */
684 #endif
685 
686 #endif /* MNG_INCLUDE_JNG */
687 
688            mng_uint32        aCRCtable [256];    /* CRC prefab table */
689            mng_bool          bCRCcomputed;       /* "has been build" indicator */
690 
691         } mng_data;
692 
693 typedef mng_data * mng_datap;
694 
695 /* ************************************************************************** */
696 /* *                                                                        * */
697 /* * Internal Callback-Function prototypes                                  * */
698 /* *                                                                        * */
699 /* ************************************************************************** */
700 
701 typedef mng_retcode(*mng_displayrow)  (mng_datap  pData);
702 typedef mng_retcode(*mng_restbkgdrow) (mng_datap  pData);
703 typedef mng_retcode(*mng_correctrow)  (mng_datap  pData);
704 typedef mng_retcode(*mng_retrieverow) (mng_datap  pData);
705 typedef mng_retcode(*mng_storerow)    (mng_datap  pData);
706 typedef mng_retcode(*mng_processrow)  (mng_datap  pData);
707 typedef mng_retcode(*mng_initrowproc) (mng_datap  pData);
708 typedef mng_retcode(*mng_differrow)   (mng_datap  pData);
709 typedef mng_retcode(*mng_scalerow)    (mng_datap  pData);
710 typedef mng_retcode(*mng_deltarow)    (mng_datap  pData);
711 
712 typedef mng_retcode(*mng_magnify_x)   (mng_datap  pData,
713                                        mng_uint16 iMX,
714                                        mng_uint16 iML,
715                                        mng_uint16 iMR,
716                                        mng_uint32 iWidth,
717                                        mng_uint8p iSrcline,
718                                        mng_uint8p iDstline);
719 typedef mng_retcode(*mng_magnify_y)   (mng_datap  pData,
720                                        mng_int32  iM,
721                                        mng_int32  iS,
722                                        mng_uint32 iWidth,
723                                        mng_uint8p iSrcline1,
724                                        mng_uint8p iSrcline2,
725                                        mng_uint8p iDstline);
726 
727 /* ************************************************************************** */
728 /* *                                                                        * */
729 /* * Routines for swapping byte-order from and to graphic files             * */
730 /* * (This code is adapted from the libpng package)                         * */
731 /* *                                                                        * */
732 /* ************************************************************************** */
733 
734 #ifndef MNG_BIGENDIAN_SUPPORTED
735 mng_uint32 mng_get_uint32 (mng_uint8p pBuf);
736 mng_int32  mng_get_int32  (mng_uint8p pBuf);
737 mng_uint16 mng_get_uint16 (mng_uint8p pBuf);
738 void       mng_put_uint32 (mng_uint8p pBuf,
739                            mng_uint32 i);
740 void       mng_put_int32  (mng_uint8p pBuf,
741                            mng_int32  i);
742 void       mng_put_uint16 (mng_uint8p pBuf,
743                            mng_uint16 i);
744 #else /* MNG_BIGENDIAN_SUPPORTED */
745 #define mng_get_uint32(P)   *(mng_uint32p)(P)
746 #define mng_get_int32(P)    *(mng_int32p)(P)
747 #define mng_get_uint16(P)   *(mng_uint16p)(P)
748 #define mng_put_uint32(P,I) *(mng_uint32p)(P) = (I)
749 #define mng_put_int32(P,I)  *(mng_int32p)(P) = (I)
750 #define mng_put_uint16(P,I) *(mng_uint16p)(P) = (I)
751 #endif /* MNG_BIGENDIAN_SUPPORTED */
752 
753 /* ************************************************************************** */
754 /* *                                                                        * */
755 /* * Some handy(?) macro definitions                                        * */
756 /* *                                                                        * */
757 /* ************************************************************************** */
758 
759 #define MAX_COORD(a, b)  (((a) > (b)) ? (a) : (b))
760 #define MIN_COORD(a, b)  (((a) < (b)) ? (a) : (b))
761 
762 /* ************************************************************************** */
763 
764 #endif /* _libmng_data_h_ */
765 
766 /* ************************************************************************** */
767 /* * end of file                                                            * */
768 /* ************************************************************************** */
769