4
4
/* ************************************************************************** */
6
6
/* * project : libmng * */
7
/* * file : libmng_data.h copyright (c) 2000 G.Juyn * */
8
/* * version : 1.0.2 * */
7
/* * file : libmng_data.h copyright (c) 2000-2004 G.Juyn * */
8
/* * version : 1.0.8 * */
10
10
/* * purpose : main data structure definition * */
12
12
/* * author : G.Juyn * */
13
/* * web : http://www.3-t.com * */
14
/* * email : mailto:info@3-t.com * */
16
14
/* * comment : Definition of the library main data structure * */
107
105
/* * 1.0.2 - 06/25/2001 - G.Juyn * */
108
106
/* * - added option to turn off progressive refresh * */
108
/* * 1.0.5 - 07/08/2002 - G.Juyn * */
109
/* * - B578572 - removed eMNGma hack (thanks Dimitri!) * */
110
/* * 1.0.5 - 07/16/2002 - G.Juyn * */
111
/* * - B581625 - large chunks fail with suspension reads * */
112
/* * 1.0.5 - 08/15/2002 - G.Juyn * */
113
/* * - completed PROM support * */
114
/* * 1.0.5 - 09/15/2002 - G.Juyn * */
115
/* * - fixed LOOP iteration=0 special case * */
116
/* * 1.0.5 - 09/20/2002 - G.Juyn * */
117
/* * - finished support for BACK image & tiling * */
118
/* * 1.0.5 - 10/07/2002 - G.Juyn * */
119
/* * - added another fix for misplaced TERM chunk * */
120
/* * - completed support for condition=2 in TERM chunk * */
121
/* * 1.0.5 - 10/20/2002 - G.Juyn * */
122
/* * - fixed processing for multiple objects in MAGN * */
123
/* * - fixed display of visible target of PAST operation * */
124
/* * 1.0.5 - 11/07/2002 - G.Juyn * */
125
/* * - added support to get totals after mng_read() * */
126
/* * 1.0.5 - 24/02/2003 - G.Juyn * */
127
/* * - B683152 - libjpeg suspension not always honored correctly* */
129
/* * 1.0.6 - 04/11/2003 - G.Juyn * */
130
/* * - B719420 - fixed several MNG_APP_CMS problems * */
131
/* * 1.0.6 - 07/05/2003 - G. R-P * */
132
/* * - optionally use zlib's crc32() function * */
133
/* * 1.0.6 - 07/29/2003 - G.R-P * */
134
/* * - added SKIPCHUNK conditionals around PAST chunk support * */
135
/* * 1.0.6 - 08/17/2003 - G.R-P * */
136
/* * - added iPNGdepth member to pData structure * */
138
/* * 1.0.7 - 03/10/2004 - G.R-P * */
139
/* * - added conditionals around openstream/closestream * */
140
/* * 1.0.7 - 03/24/2004 - G.R-P * */
141
/* * - added more SKIPCHUNK conditionals * */
143
/* * 1.0.8 - 04/02/2004 - G.Juyn * */
144
/* * - added CRC existence & checking flags * */
145
/* * 1.0.8 - 04/10/2004 - G.Juyn * */
146
/* * - added data-push mechanisms for specialized decoders * */
110
148
/* ************************************************************************** */
112
150
#if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
176
214
mng_uint32 iGlobalGamma; /* global gAMA fields */
216
#ifndef MNG_SKIPCHUNK_cHRM
178
217
mng_uint32 iGlobalWhitepointx; /* global cHRM fields */
179
218
mng_uint32 iGlobalWhitepointy;
180
219
mng_uint32 iGlobalPrimaryredx;
201
241
/* ************************************************************************** */
243
/* * Internal buffer structure for data push mechanisms * */
245
/* ************************************************************************** */
248
mng_ptr pNext; /* for linked list */
249
mng_ptr pData; /* used for chunks & data */
252
mng_uint8p pDatanext; /* only used for data */
253
mng_uint32 iRemaining;
255
typedef mng_pushdata * mng_pushdatap;
257
/* ************************************************************************** */
203
259
/* * The main libmng data structure * */
205
261
/* * The handle used in all functions points to this structure which * */
224
280
mng_uint32 iSimplicity;
225
281
mng_uint8 iAlphadepth; /* indicates expected alpha-depth */
227
mng_uint32 iImagelevel; /* level an image inside a stream */
283
mng_uint32 iImagelevel; /* level of image inside a stream */
229
285
mng_uint32 iCanvasstyle; /* layout of the drawing-canvas */
230
286
mng_uint32 iBkgdstyle; /* layout of the background-canvas */
256
312
mng_bool bStorechunks; /* switch for storing chunkdata */
257
313
mng_bool bSectionbreaks; /* indicate NEEDSECTIONWAIT breaks */
258
314
mng_bool bCacheplayback; /* switch to cache playback info */
259
mng_bool bDoProgressive; /* progressive refresh for large images */
315
mng_bool bDoProgressive; /* progressive refresh for large images */
316
mng_uint32 iCrcmode; /* CRC existence & checking flags */
261
318
mng_speedtype iSpeed; /* speed-modifier for animations */
272
329
mng_memalloc fMemalloc; /* callback pointers */
273
330
mng_memfree fMemfree; /* initially nulled */
331
mng_releasedata fReleasedata;
332
#ifndef MNG_NO_OPEN_CLOSE_STREAM
274
333
mng_openstream fOpenstream;
275
334
mng_closestream fClosestream;
276
336
mng_readdata fReaddata;
277
337
mng_writedata fWritedata;
278
338
mng_errorproc fErrorproc;
298
358
mng_processarow fProcessarow;
300
360
#if defined(MNG_SUPPORT_READ) || defined(MNG_SUPPORT_WRITE)
361
#ifndef MNG_NO_OLD_VERSIONS
301
362
mng_bool bPreDraft48; /* flags ancient style draft */
303
365
mng_chunkid iChunkname; /* read/write-state variables */
304
366
mng_uint32 iChunkseq;
388
448
mng_uint32 iSuspendbufleft;
389
449
mng_uint32 iChunklen; /* chunk length */
390
450
mng_uint8p pReadbufnext; /* 32K+ suspension-processing */
451
mng_uint8p pLargebufnext;
453
mng_pushdatap pFirstpushchunk; /* variables for push mechanisms */
454
mng_pushdatap pLastpushchunk;
455
mng_pushdatap pFirstpushdata;
456
mng_pushdatap pLastpushdata;
391
457
#endif /* MNG_SUPPORT_READ */
393
459
#ifdef MNG_SUPPORT_WRITE
394
460
mng_bool bCreating; /* create/write processing variables */
395
461
mng_bool bWriting;
396
mng_chunkid iFirstchunkadded;
462
mng_chunkid iFirstchunkadded;
397
463
mng_uint32 iWritebufsize;
398
464
mng_uint8p pWritebuf;
405
471
mng_uint32 iLayerseq;
406
472
mng_uint32 iFrametime; /* millisecs */
474
mng_uint32 iTotalframes; /* end-totals after mng_read() */
475
mng_uint32 iTotallayers;
476
mng_uint32 iTotalplaytime; /* millisecs */
478
mng_bool bSkipping; /* LOOP iteration=0 */
480
#ifdef MNG_SUPPORT_DYNAMICMNG
481
mng_bool bDynamic; /* MNG is dynamic (eg. has events) */
482
mng_bool bRunningevent; /* currently processing an event */
483
mng_bool bStopafterseek; /* stop after next SEEK */
484
mng_int32 iEventx; /* X/Y of current event */
486
mng_objectp pLastmousemove; /* last event triggered */
408
489
mng_uint32 iRequestframe; /* go_xxxx variables */
409
490
mng_uint32 iRequestlayer;
410
491
mng_uint32 iRequesttime;
426
507
mng_bool bFreezing; /* indicates app requested a freeze */
427
508
mng_bool bResetting; /* indicates app requested a reset */
428
509
mng_bool bNeedrefresh; /* indicates screen-refresh is needed */
510
mng_bool bMisplacedTERM; /* indicates TERM is out of place */
511
mng_bool bOnlyfirstframe; /* show first frame after TERM and stop */
512
mng_uint32 iFramesafterTERM; /* determines frame-count after TERM */
429
513
mng_objectp pCurrentobj; /* current "object" */
430
514
mng_objectp pCurraniobj; /* current animation object
431
515
"to be"/"being" processed */
481
565
mng_objectp pLastimgobj; /* image-object structures */
482
566
mng_objectp pFirstaniobj; /* double-linked list of */
483
567
mng_objectp pLastaniobj; /* animation-object structures */
568
#ifdef MNG_SUPPORT_DYNAMICMNG
569
mng_objectp pFirstevent; /* double-linked list of */
570
mng_objectp pLastevent; /* event-object structures */
485
#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS)
573
#if defined(MNG_GAMMA_ONLY) || defined(MNG_FULL_CMS) || defined(MNG_APP_CMS)
486
574
mng_uint8 aGammatab[256]; /* precomputed gamma lookup table */
487
575
mng_float dLastgamma; /* last gamma used to compute table */
507
595
delta-row to the bitdepth of its target */
508
596
mng_fptr fDeltarow; /* internal callback to execute a
509
597
delta-row onto a target */
598
#ifndef MNG_SKIPCHUNK_PAST
599
mng_fptr fFliprow; /* internal callback to flip a row of pixels
600
left<->right for a PAST operation */
601
mng_fptr fTilerow; /* internal callback to tile a row of pixels
602
during a PAST operation */
510
604
mng_fptr fInitrowproc; /* internal callback to initialize
511
605
the row processing */
531
625
mng_uint16 iBACKimageid;
532
626
mng_uint8 iBACKtile;
628
mng_int32 iBackimgoffsx; /* temp variables for restore_bkgd */
629
mng_int32 iBackimgoffsy;
630
mng_uint32 iBackimgwidth;
631
mng_uint32 iBackimgheight;
633
#ifndef MNG_SKIPCHUNK_FRAM
534
634
mng_uint8 iFRAMmode; /* FRAM fields (global) */
535
635
mng_uint32 iFRAMdelay;
536
636
mng_uint32 iFRAMtimeout;
549
649
mng_int32 iFrameclipt;
550
650
mng_int32 iFrameclipb;
552
mng_uint32 iNextdelay; /* delay for *after* next image */
652
mng_uint32 iNextdelay; /* delay *after* next image */
554
mng_uint8 iSHOWmode; /* SAVE fields */
655
#ifndef MNG_SKIPCHUNK_SHOW
656
mng_uint8 iSHOWmode; /* SHOW fields */
555
657
mng_uint16 iSHOWfromid;
556
658
mng_uint16 iSHOWtoid;
557
659
mng_uint16 iSHOWnextid;
558
660
mng_int16 iSHOWskip;
560
663
mng_uint32 iGlobalPLTEcount; /* global PLTE fields */
561
664
mng_rgbpaltab aGlobalPLTEentries;
566
669
mng_uint32 iGlobalGamma; /* global gAMA fields */
671
#ifndef MNG_SKIPCHUNK_cHRM
568
672
mng_uint32 iGlobalWhitepointx; /* global cHRM fields */
569
673
mng_uint32 iGlobalWhitepointy;
570
674
mng_uint32 iGlobalPrimaryredx;
573
677
mng_uint32 iGlobalPrimarygreeny;
574
678
mng_uint32 iGlobalPrimarybluex;
575
679
mng_uint32 iGlobalPrimarybluey;
577
682
mng_uint8 iGlobalRendintent; /* global sRGB fields */
684
#ifndef MNG_SKIPCHUNK_iCCP
579
685
mng_uint32 iGlobalProfilesize; /* global iCCP fields */
580
686
mng_ptr pGlobalProfile;
582
689
mng_uint16 iGlobalBKGDred; /* global bKGD fields */
583
690
mng_uint16 iGlobalBKGDgreen;
586
693
mng_ptr pDeltaImage; /* delta-image fields */
587
694
mng_uint8 iDeltaImagetype;
588
mng_uint8 iDeltatype;
695
#endif /* MNG_SUPPORT_DISPLAY */
696
mng_uint8 iDeltatype; /* need this one in read processing !! */
697
#ifdef MNG_SUPPORT_DISPLAY
589
698
mng_uint32 iDeltaBlockwidth;
590
699
mng_uint32 iDeltaBlockheight;
591
700
mng_uint32 iDeltaBlockx;
597
706
mng_fptr fDeltareplacerow;
598
707
mng_fptr fDeltaputrow;
709
#ifndef MNG_SKIPCHUNK_PROM
710
mng_fptr fPromoterow; /* internal PROM fields */
711
mng_fptr fPromBitdepth;
713
mng_uint8 iPromColortype;
714
mng_uint8 iPromBitdepth;
715
mng_uint8 iPromFilltype;
716
mng_uint32 iPromWidth;
721
#ifndef MNG_SKIPCHUNK_MAGN
600
722
mng_uint16 iMAGNfromid;
723
mng_uint16 iMAGNcurrentid;
601
724
mng_uint16 iMAGNtoid;
727
#ifndef MNG_SKIPCHUNK_PAST
729
mng_int32 iPastx; /* target x/y of last PAST */
733
mng_objectp pLastseek; /* last processed ani_seek object */
602
734
#endif /* MNG_SUPPORT_DISPLAY */
604
736
#ifdef MNG_INCLUDE_ZLIB
660
792
mng_bool bJPEGhasheader; /* indicates "readheader" succeeded (JDAT) */
661
793
mng_bool bJPEGdecostarted; /* indicates "decompress" started (JDAT) */
662
794
mng_bool bJPEGscanstarted; /* indicates "first scan" started (JDAT) */
795
mng_bool bJPEGscanending; /* indicates "finish_output" suspended (JDAT) */
663
796
mng_bool bJPEGprogressive; /* indicates a progressive image (JDAT) */
665
798
mng_bool bJPEGdecompress2; /* indicates "decompress" initialized (JDAA) */
686
819
#endif /* MNG_INCLUDE_JNG */
688
mng_uint32 aCRCtable [256]; /* CRC prefab table */
689
mng_bool bCRCcomputed; /* "has been build" indicator */
821
#ifndef MNG_USE_ZLIB_CRC
822
mng_uint32 aCRCtable [256]; /* CRC prefab table */
823
mng_bool bCRCcomputed; /* "has been built" indicator */
826
#ifdef MNG_OPTIMIZE_FOOTPRINT_INIT
827
png_imgtype ePng_imgtype;
830
#if defined(MNG_NO_16BIT_SUPPORT)
831
mng_uint8 iPNGdepth; /* Real input depth */
708
852
typedef mng_retcode(*mng_differrow) (mng_datap pData);
709
853
typedef mng_retcode(*mng_scalerow) (mng_datap pData);
710
854
typedef mng_retcode(*mng_deltarow) (mng_datap pData);
855
typedef mng_retcode(*mng_promoterow) (mng_datap pData);
856
typedef mng_retcode(*mng_fliprow) (mng_datap pData);
857
typedef mng_retcode(*mng_tilerow) (mng_datap pData);
859
typedef mng_uint8 (*mng_bitdepth_8) (mng_uint8 iB);
860
typedef mng_uint16 (*mng_bitdepth_16) (mng_uint8 iB);
712
862
typedef mng_retcode(*mng_magnify_x) (mng_datap pData,