libmng_chunk_descr.c 193 KB

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