Ea Iff 85

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

"EA IFF 85" Standard for Interchange Format Files Document Date: From: Status of Standard: 1$ Introduction Standards

are %ood for Soft&are De'elo(ers As home com(uter hard&are e'ol'es to )etter and )etter media machines the demand increases for higher *uality more detailed data$ Data de'elo(ment gets more e+(ensi'e re*uires more e+(ertise and )etter tools and has to )e shared across (ro,ects$ -hin. a)out se'eral (orts of a (roduct on one /D0#1" &ith 522" 3ytes of common data4 De'elo(ment tools need standard interchange file formats$ Imagine scanning in images of "(layer" sha(es mo'ing them to a (aint (rogram for editing then incor(orating them into a game$ 1r &riting a theme song &ith a "acintosh score editor and incor(orating it into an Amiga game$ -he data must at times )e transformed cli((ed filled out and mo'ed across machine .inds$ "edia (ro,ects &ill de(end on data transfer from gra(hic music sound effect animation and scri(t tools$ Standards are %ood for Soft&are 5sers /ustomers should )e a)le to mo'e their o&n data )et&een inde(endently de'elo(ed soft&are (roducts$ And they should )e a)le to )uy data li)raries usa)le across many such (roducts$ -he ty(es of data o),ects to e+change are o(en0ended and include (lain and formatted te+t raster and structured gra(hics fonts music sound effects musical instrument descri(tions and animation$ -he (ro)lem &ith e+(edient file formats ty(ically memory dum(s is that they6re too (ro'incial$ 3y designing data for one (articular use 7e$g$ a screen sna(shot8 they (reclude future e+(ansion 7&ould you li.e a full (age (icture9 a multi0(age document98$ In neglecting the (ossi)ility that other (rograms might read their data they fail to sa'e conte+tual information 7ho& many )it (lanes9 &hat resolution98$ Ignoring that other (rograms might create such files they6re intolerant of e+tra data 7te+ture (alette for a (icture editor8 missing data 7no color ma(8 or minor 'ariations 7smaller image8$ In (ractice a filed re(resentation should rarely mirror an in0memory re(resentation$ -he former should )e designed for longe'ity: the latter to o(timi;e the mani(ulations of a (articular (rogram$ -he same filed data &ill )e read into different memory formats )y different (rograms$ -he IFF (hiloso(hy: "A little )ehind0the0scenes con'ersion &hen (rograms read and &rite files is far )etter than <+" e+(licit con'ersion utilities for highly s(eciali;ed formats$" So &e need some standardi;ation for data interchange among de'elo(ment tools and (roducts$ -he more de'elo(ers that ado(t a standard the )etter for all of us and our customers$ =ere is "EA IFF 1!85" =ere is our offering: Electronic Arts6 IFF standard for Interchange File Format$ -he full name is "EA IFF 1!85"$ Alternati'es and ,ustifications are included for certain choices$ >u)lic domain su)routine (ac.ages January 14 1!85 Jerry "orrison Electronic Arts #eleased and in use

and utility (rograms are a'aila)le to ma.e it easy to &rite and use IFF0com(ati)le (rograms$ >art 1 introduces the standard$ >art ? (resents its re*uirements and )ac.ground$ >arts @ 4 and 5 define the (rimiti'e data ty(es F1#"s and AIS-s res(ecti'ely and ho& to define ne& high le'el ty(es$ >art B s(ecifies the to( le'el file structure$ A((endi+ A is included for *uic. reference and A((endi+ 3 names the committee res(onsi)le for this standard$ #eferences American <ational Standard Additional /ontrol /odes for 5se &ith AS/II A<SI standard @$B401!C! for an 80)it character set$ See also IS1 standard ?2?? and IS1DDIS standard B4?!$?$ AmigaEtmF is a trademar. of /ommodore0Amiga Inc$ -artan

/ A #eference "anual Samuel >$ =ar)ison and %uy A$ Steele Jr$ Aa)oratories$ >rentice0=all Engle&ood /liffs <J 1!84$

/om(iler /onstruction An Ad'anced /ourse edited )y F$ A$ 3auer and J$ Eic.el 7S(ringer0Gerlag 1!CB8$ -his )oo. is one of many sources for information on recursi'e descent (arsing$ DIF -echnical S(ecification 7c81!81 )y Soft&are Arts Inc$ DIFEtmF is the format for s(readsheet data interchange de'elo(ed )y Soft&are Arts Inc$ DIFEtmF is a trademar. of Soft&are Arts Inc$ Electronic ArtsEtmF is a trademar. of Electronic Arts$ "F-H-" IFF Formatted -e+t for a te+t format$ from Electronic Arts$ IFF su((lement document a

Inside "acintosh 7c8 1!8? 1!8@ 1!84 1!85 A((le /om(uter Inc$ (rogrammer6s reference manual$ A((le7#8 is a trademar. of A((le /om(uter Inc$ "acintoshEtmF is a trademar. licensed to A((le /om(uter Inc$

"IA3"" IFF Interlea'ed 3itma( from Electronic Arts$ IFF su((lement document for a raster image format$ "B8222 1BD@?03it "icro(rocessor >rogrammer6s #eference "anual7c8 1!84 1!8? 1!82 1!C! )y "otorola Inc$ >ostScri(t Aanguage "anual 7c8 1!84 Ado)e Systems Incor(orated$ >ostScri(tEtmF is a trademar. of Ado)e Systems Inc$ -imes and =el'etica7#8 are trademar.s of Allied /or(oration$ InterScri(t: A >ro(osal for a Standard for the Interchange of Edita)le Documents 7c81!84 Hero+ /or(oration$ Introduction to InterScri(t 7c8 1!85 Hero+ /or(oration$

?$ 3ac.ground for Designers >art ? is a)out the )ac.ground re*uirements and goals for the standard$ It6s geared for (eo(le &ho &ant to design ne& ty(es of IFF o),ects$ >eo(le ,ust interested in using the standard may &ish to s.i( this (art$ Ihat Do Ie <eed9 A standard should )e long on (rescri(tion and short on o'erhead$ It should gi'e lots of rules for designing (rograms and data files for synergy$ 3ut neither the (rograms nor the files should cost too much more than the e+(edient 'ariety$ Ihile &e6re loo.ing to a future &ith /D0#1"s and (er(endicular recording the standard must &or. &ell on flo((y dis.s$ For (rogram (orta)ility sim(licity and efficiency formats should )e designed &ith more than one im(lementation style in mind$ 7In (ractice (ure stream ID1 is ade*uate although random access ma.es it easier to &rite files$8 It ought to )e (ossi)le to read one of many o),ects in a file &ithout scanning all the (receding data$ Some (rograms need to read and (lay out their data in real time so &e need good com(romises )et&een generality and efficiency$ As much as &e need standards they can6t hold u( (roduct schedules$ So &e also need a .ind of decentrali;ed e+tensi)ility &here any soft&are de'elo(er can define and refine ne& o),ect ty(es &ithout some "standards authority" in the loo($ De'elo(ers must )e a)le to e+tend e+isting formats in a for&ard0 and )ac.&ard0com(ati)le &ay$ A central re(ository for design information and e+am(le (rograms can hel( us ta.e full ad'antage of the standard$ For con'enience data formats should heed the restrictions of 'arious (rocessors and en'ironments$ E$g$ &ord0alignment greatly hel(s B8222 access at insignificant cost to 8288 (rograms$ 1ther goals include the a)ility to share common elements o'er a list of o),ects and the a)ility to construct com(osite o),ects containing other data o),ects &ith structural information li.e directories$ And finally "Sim(le things should )e sim(le and com(le+ things should )e (ossi)le$" Alan Jay$ -hin. Ahead Aet6s thin. ahead and )uild (rograms that read and &rite files for each other and for (rograms yet to )e designed$ 3uild data formats to last for future com(uters so long as the o'erhead is acce(ta)le$ -his e+tends the usefulness and life of today6s (rograms and data$ -o ma+imi;e interconnecti'ity the standard file structure and the s(ecific o),ect formats must all )e general and e+tensi)le$ -hin. ahead &hen designing an o),ect$ It should ser'e many (ur(oses and allo& many (rograms to store and read )ac. all the information they need: e'en s*uee;e in custom data$ -hen a (rogrammer can store the a'aila)le data and is encouraged to include fi+ed conte+tual details$ #eci(ient (rograms can read the needed (arts s.i( unrecogni;ed stuff default missing data and use the stored conte+t to hel( transform the data as needed$ Sco(e

IFF addresses these needs )y defining a standard file structure some initial data o),ect ty(es &ays to define ne& ty(es and rules for accessing these files$ Ie can accom(lish a great deal )y &riting (rograms according to this standard )ut don6t e+(ect direct com(ati)ility &ith e+isting soft&are$ Ie6ll need con'ersion (rograms to )ridge the ga( from the old &orld$ IFF is geared for com(uters that readily (rocess information in 80)it )ytes$ It assumes a "(hysical layer" of data storage and transmission that relia)ly maintains "files" as strings of 80)it )ytes$ -he standard treats a "file" as a container of data )ytes and is inde(endent of ho& to find a file and &hether it has a )yte count$ -his standard does not )y itself im(lement a cli()oard for cutting and (asting data )et&een (rograms$ A cli()oard needs soft&are to mediate access to maintain a "contents 'ersion num)er" so (rograms can detect u(dates and to manage the data in "'irtual memory"$ Data A)straction -he )asic (ro)lem is ho& to re(resent information in a &ay that6s (rogram0inde(endent com(iler0 inde(endent machine0inde(endent and de'ice0inde(endent$ -he com(uter science a((roach is "data a)straction" also .no&n as "o),ects" "actors" and "a)stract data ty(es"$ A data a)straction has a "concrete re(resentation" 7its storage format8 an "a)stract re(resentation" 7its ca(a)ilities and uses8 and access (rocedures that isolate all the calling soft&are from the concrete re(resentation$ 1nly the access (rocedures touch the data storage$ =iding muta)le details )ehind an interface is called "information hiding"$ Ihat data a)straction does is a)stract from details of im(lementing the o),ect namely the selected storage re(resentation and algorithms for mani(ulating it$ -he (o&er of this a((roach is modularity$ 3y ad,usting the access (rocedures &e can e+tend and restructure the data &ithout im(acting the interface or its callers$ /on'ersely &e can e+tend and restructure the interface and callers &ithout ma.ing e+isting data o)solete$ It6s great for interchange4 3ut &e seem to need the o((osite: fi+ed file formats for all (rograms to access$ Actually &e could file data a)stractions 7"filed o),ects"8 )y storing the data and access (rocedures together$ Ie6d ha'e to encode the access (rocedures in a standard machine0inde(endent (rogramming language la >ostScri(t$ E'en still the interface can6t e'ol'e freely since &e can6t u(date all co(ies of the access (rocedures$ So &e6ll ha'e to design our a)stract re(resentations for limited e'olution and occasional re'olution 7con'ersion8$ In any case today6s microcom(uters can6t (ractically store data a)stractions$ -hey can do the ne+t )est thing: store ar)itrary ty(es of data in "data chun.s" each &ith a ty(e identifier and a length count$ -he ty(e identifier is a reference )y name to the access (rocedures 7any local im(lementation8$ -he length count ena)les storage0le'el o),ect o(erations li.e "co(y" and "s.i( to ne+t" inde(endent of o),ect ty(e$ /hun. &riting is straightfor&ard$ /hun. reading re*uires a tri'ial (arser to scan each chun. and dis(atch to the (ro(er accessDcon'ersion (rocedure$ #eading chun.s nested inside other chun.s re*uires recursion )ut no loo.ahead or )ac.u($ -hat6s the main idea of IFF$ -here are of course a fe& other detailsI

>re'ious Ior. Ihere our needs are similar &e )orro& from e+isting standards$

1ur )asic need to mo'e data )et&een inde(endently de'elo(ed (rograms is similar to that addressed )y the A((le "acintosh des. scra( or "cli()oard" EInside "acintosh cha(ter "Scra( "anager"F$ -he Scra( "anager &or.s closely &ith the #esource "anager a handy filer and s&a((er for data o),ects 7te+t strings dialog &indo& tem(lates (ictures fontsI8 including ty(es yet to )e designed EInside "acintosh cha(ter "#esource "anager"F$ -he #esource "anager is a .in to Smalltal.6s o),ect s&a((er$ Ie &ill (ro)a)ly &rite a "acintosh des. accessory that con'erts IFF files to and from the "acintosh cli()oard for *uic. and easy interchange &ith (rograms li.e "ac>aint and #esource "o'er$ "acintosh uses a sim(le and elegant scheme of 40character "identifiers" to identify resource ty(es cli()oard format ty(es file ty(es and file creator (rograms$ Alternati'es are uni*ue ID num)ers assigned )y a central authority or )y hierarchical authorities uni*ue ID num)ers generated )y algorithm other fi+ed length character strings and 'aria)le length strings$ /haracter string identifiers dou)le as reada)le sign(osts in data files and (rograms$ -he choice of 4 characters is a good tradeoff )et&een storage s(ace fetchDcom(areDstore time and name s(ace si;e$ Ie6ll honor A((le6s designers )y ado(ting this scheme$ ">I/-" is a good e+am(le of a standard structured gra(hics format 7including raster images8 and its many uses EInside "acintosh cha(ter "Kuic.Dra&"F$ "acintosh (ro'ides Kuic.Dra& routines in #1" to create mani(ulate and dis(lay >I/-s$ Any a((lication can create a >I/- )y sim(ly as.ing Kuic.Dra& to record a se*uence of dra&ing commands$ Since it6s ,ust as easy to as. Kuic.Dra& to render a >I/- to a screen or a (rinter it6s 'ery effecti'e to (ass them )et&een (rograms say from an illustrator to a &ord (rocessor$ An im(ortant feature is the a)ility to store "comments" in a >I/- &hich Kuic.Dra& &ill ignore$ Actually it (asses them to your o(tional custom "comment handler"$ >ostScri(t Ado)e6s (rint file standard is a more general &ay to re(resent any (rint image 7&hich is a s(ecification for (utting mar.s on (a(er8 E>ostScri(t Aanguage "anualF$ In fact >ostScri(t is a full0fledged (rogramming language$ -o inter(ret a >ostScri(t (rogram is to render a document on a raster out(ut de'ice$ -he language is defined in layers: a le+ical layer of identifiers constants and o(erators: a layer of re'erse (olish semantics including sco(e rules and a &ay to define ne& su)routines: and a (rinting0s(ecific layer of )uilt0in identifiers and o(erators for rendering gra(hic images$ It is clearly a (o&erful 7-uring e*ui'alent8 image definition language$ >I/- and a su)set of >ostScri(t are candidates for structured gra(hics standards$ A >ostScri(t document can )e (rinted on any raster out(ut de'ice 7including a dis(lay8 )ut cannot generally )e edited$ -hat6s )ecause the original fle+i)ility and constraints ha'e )een discarded$ 3esides a >ostScri(t (rogram may use ar)itrary com(utation to su((ly (arameters li.e (lacement and si;e to each o(erator$ A Kuic.Dra& >I/- in com(arison is a more restricted format of gra(hic (rimiti'es (arameteri;ed )y constants$ So a >I/- can )e edited at the le'el of the (rimiti'es e$g$ mo'e or thic.en a line$ It cannot )e edited at the higher le'el of say the )ar chart data &hich generated the (icture$ >ostScri(t has another limitation: <ot all .inds of data amount to mar.s on (a(er$ A musical instrument descri(tion is one e+am(le$ >ostScri(t

is ,ust not geared for such uses$ "DIF" is another e+am(le of data )eing stored in a general format usa)le )y future (rograms EDIF -echnical S(ecificationF$ DIF is a format for s(readsheet data interchange$ DIF and >ostScri(t are )oth e+(ressed in (lain AS/II te+t files$ -his is 'ery handy for (rinting de)ugging e+(erimenting and transmitting across modems$ It can ha'e su)stantial cost in com(action and readD&rite &or. de(ending on use$ Ie &on6t store IFF files this &ay )ut &e could define an AS/II alternate re(resentation &ith a con'erter (rogram$ InterScri(t is Hero+6 standard for interchange of edita)le documents EIntroduction to InterScri(tF$ It a((roaches a harder (ro)lem: =o& to re(resent edita)le &ord (rocessor documents that may contain formatted te+t (ictures cross0references li.e figure num)ers and e'en highly s(eciali;ed o),ects li.e mathematical e*uations9 InterScri(t aims to define one standard re(resentation for each .ind of information$ Each InterScri(t0com(ati)le editor is su((osed to (reser'e the o),ects it doesn6t understand and e'en maintain nested cross0references$ So a sim(le &ord (rocessor &ould let you edit the te+t of a fancy document &ithout discarding the e*uations or disru(ting the e*uation num)ers$ 1ur tas. is similarly to store high le'el information and (reser'e as much content as (ractical &hile mo'ing it )et&een (rograms$ 3ut &e need to s(an a larger uni'erse of data ty(es and cannot e+(ect to centrally define them all$ Fortunately &e don6t need to ma.e (rograms (reser'e information that they don6t understand$ And for )etter or &orse &e don6t ha'e to tac.le general0(ur(ose cross0references yet$

@$ >rimiti'e Data -y(es Atomic com(onents such as integers and characters that are inter(reta)le directly )y the />5 are s(ecified in one format for all (rocessors$ Ie chose a format that6s most con'enient for the "otorola "/B8222 (rocessor E"B8222 1BD@?03it "icro(rocessor >rogrammer6s #eference "anualF$ <$3$: >art @ dictates the format for "(rimiti'e" data ty(es &here and only &here used in the o'erall file structure and standard .inds of chun.s 7/f$ /hun.s8$ -he num)er of such occurrences &ill )e small enough that the costs of con'ersion storage and management of (rocessor0 s(ecific files &ould far e+ceed the costs of con'ersion during ID1 )y "foreign" (rograms$ A (articular data chun. may )e s(ecified &ith a different format for its internal (rimiti'e ty(es or &ith (rocessor0 or en'ironment0 s(eci fic 'ariants if necessary to o(timi;e local usage$ Since that hurts data interchange it6s not recommended$ 7/f$ Designing <e& Data Sections in >art 4$8 Alignment All data o),ects larger than a )yte are aligned on e'en )yte addresses relati'e to the start of the file$ -his may re*uire (adding$ >ad )ytes are to )e &ritten as ;eros )ut don6t count on that &hen reading$ -his means that e'ery odd0length "chun." 7see )elo&8 must )e (added so that the ne+t one &ill fall on an e'en )oundary$ Also designers of structures to )e stored in chun.s should include (ad fields &here needed to align e'ery field larger than a )yte$ Leros should )e stored in all the (ad )ytes$ Justification: E'en0alignment causes a little e+tra &or. for files that are used only on certain (rocessors )ut allo&s B8222 (rograms to construct and scan the data in memory and do )loc. ID1$ Mou ,ust add an occasional (ad field to data structures that you6re going to )loc. readD&rite or else stream readD&rite an e+tra )yte$ And the same source code &or.s on all (rocessors$ 5ns(ecified alignment on the other hand &ould force B8222 (rograms to 7dis8assem)le &ord and long0&ord data one )yte at a time$ >retty cum)ersome in a high le'el language$ And if you don6t conditionally com(ile that out for other (rocessors you &on6t gain anything$ <um)ers <umeric ty(es su((orted are t&o6s com(lement )inary integers in the format used )y the "/B8222 (rocessor high )yte first high &ord first the re'erse of 8288 and B52? format$ -hey could (otentially include signed and unsigned 8 1B and @? )it integers )ut the standard only uses the follo&ing: 53M-E I1#D 5I1#D A1<% 8 1B 1B @? )its )its )its )its unsigned signed unsigned signed

-he actual ty(e definitions de(end on the />5 and the com(iler$ In this document &e6ll e+(ress data ty(e definitions in the / (rogramming language$ ESee / A #eference "anual$F In B8222 Aattice /: ty(edef unsigned char ty(edef short I1#D: ty(edef unsigned short 53M-E: DN 8 )its unsigned DN 1B )its signed ND 5I1#D: DN 1B )its unsigned ND ND

ty(edef long /haracters

A1<%:

DN @? )its signed

ND

-he follo&ing character set is assumed &here'er characters are used e$g$ in te+t strings IDs and -EH- chun.s 7see )elo&8$ /haracters are encoded in 80)it AS/II$ /haracters in the range <5A 7he+ 28 through DEA 7he+ CF8 are &ell defined )y the C0)it AS/II standard$ IFF uses the gra(hic grou( #JS 7S> he+ ?28 through #OS 7he+ CE8$ "ost of the control character grou( he+ 21 through he+ 1F ha'e no standard meaning in IFF$ -he control character AF 7he+ 2A8 is defined as a "ne&line" character$ It denotes an intentional line )rea. that is a (aragra(h or line terminator$ 7-here is no &ay to store an automatic line )rea.$ -hat is strictly a function of the margins in the en'ironment the te+t is (laced$8 -he control character ES/ 7he+ 138 is a reser'ed esca(e character under the rules of A<SI standard @$B401!C! American <ational Standard Additional /ontrol /odes for 5se &ith AS/II IS1 standard ?2?? and IS1DDIS standard B4?!$?$ /haracters in the range he+ CF through he+ FF are not glo)ally defined in IFF$ -hey are )est left reser'ed for future standardi;ation$ 3ut note that the F1#" ty(e F-H- 7formatted te+t8 defines the meaning of these characters &ithin F-H- forms$ In (articular character 'alues he+ CF through he+ !F are control codes &hile characters he+ A2 through he+ FF are e+tended gra(hic characters li.e as (er the IS1 and A<SI standards cited a)o'e$ ESee the su((lementary document "F-H-" IFF Formatted -e+t$F Dates A "creation date" is defined as the date and time a stream of data )ytes &as created$ 7Some systems call this a "last modified date"$8 Editing some data changes its creation date$ "o'ing the data )et&een 'olumes or machines does not$ -he IFF standard date format &ill )e one of those used in "S0D1S "acintosh or Amiga D1S 7(ro)a)ly a @?0)it unsigned num)er of seconds since a reference (oint8$ Issue: In'estigate these three$ -y(e IDs A "ty(e ID" "(ro(erty name" "F1#" ty(e" or any other IFF identifier is a @?0)it 'alue: the concatenation of four AS/II characters in the range # S 7S> he+ ?28 through #OS 7he+ CE8$ S(aces 7he+ ?28 should not (recede (rinting characters: trailing s(aces are o.$ /ontrol characters are for)idden$ ty(edef /=A# IDE4F: IDs are com(ared using a sim(le @?0)it case0de(endent e*uality test$ Data section ty(e IDs 7a.a F1#" ty(es8 are restriced IDs$ 7/f$ Data Sections$8 Since they may )e stored in filename e+tensions 7/f$ Single >ur(ose Files8 lo&er case letters and (unctuation mar.s are for)idden$ -railing s(aces are o.$ /arefully choose those four characters &hen you (ic. a ne& ID$ "a.e them mnemonic so (rogrammers can loo. at an interchange format file and figure out &hat .ind of data it contains$ -he name s(ace ma.es it (ossi)le for de'elo(ers scattered around the glo)e to generate ID 'alues &ith minimal collisions so long as they choose s(ecific

names li.e ""5S4" instead of general ones li.e "-M>E" and "FIAE"$ EA &ill "register" ne& F1#" ty(e IDs and format descri(tions as they6re de'ised )ut collisions &ill )e im(ro)a)le so there &ill )e no (ressure on this "clearinghouse" (rocess$ A((endi+ A has a list of currently defined IDs$ Sometimes it6s necessary to ma.e data format changes that aren6t )ac.&ard com(ati)le$ Since IDs are used to denote data formats in IFF ne& IDs are chosen to denote re'ised formats$ Since (rograms &on6t read chun.s &hose IDs they don6t recogni;e 7see /hun.s )elo&8 the ne& IDs .ee( old (rograms from stum)ling o'er ne& data$ -he con'entional &ay to chose a "re'ision" ID is to increment the last character if it6s a digit or else change the last character to a digit$ E$g$ first and second re'isions of the ID "HM" &ould )e "HM1" and "HM?"$ #e'isions of "/"A>" &ould )e "/"A1" and "/"A?"$ /hun.s /hun.s are the )uilding )loc.s in the IFF structure$ -he form e+(ressed as a / ty(edef is: ty(edef struct P ID c.ID: A1<% c.Si;e: DN si;eof7c.Data8 ND 53M-E c.DataEDN c.Si;e NDF: Q /hun.: Ie can diagram an e+am(le chun. a "/"A>" chun. containing 1? data )ytes li.e this: 0000000000000000 c.ID: R 6/"A>6 R c.Si;e: R 1? R c.Data: R 2 2 2 @? R 00000000 R 2 2 B4 2 R 1? )ytes R 2 2 B4 2 R 000000000 0000000000000000 -he fi+ed header (art means "=ere6s a ty(e c.ID chun. &ith c.Si;e )ytes of data$" -he c.ID identifies the format and (ur(ose of the chun.$ As a rule a (rogram must recogni;e c.ID to inter(ret c.Data$ It should s.i( o'er all unrecogni;ed chun.s$ -he c.ID also ser'es as a format 'ersion num)er as long as &e (ic. ne& IDs to identify ne& formats of c.Data 7see a)o'e8$ -he follo&ing c.IDs are uni'ersally reser'ed to identify chun.s &ith (articular IFF meanings: "AIS-" "F1#"" ">#1>" "/A- " and " "$ -he s(ecial ID " " 74 s(aces8 is a c.ID for "filler" chun.s that is chun.s that fill s(ace )ut ha'e no meaningful contents$ -he IDs "AIS1" through "AIS!" "F1#1" through "F1#!" and "/A-1" through "/A-!" are reser'ed for future "'ersion num)er" 'ariations$ All IFF0com(ati)le soft&are must account for these ?@ chun. IDs$ A((endi+ A has a list of (redefined IDs$ -he c.Si;e is a logical )loc. si;e ho& many data )ytes are in c.Data$ If c.Data is an odd num)er of )ytes long a 2 (ad )yte follo&s &hich is not included in c.Si;e$ 7/f$ Alignment$8 A chun.6s total (hysical si;e is c.Si;e rounded u( to an e'en num)er (lus the si;e of the header$ So the smallest chun. is 8 )ytes long &ith c.Si;e S 2$ For the sa.e of follo&ing chun.s (rograms must res(ect e'ery chun.6s c.Si;e as a 'irtual end0of0file for reading its c.Data e'en if that data is malformed e$g$ if nested contents are truncated$

Ie can descri)e the synta+ of a chun. as a regular e+(ression &ith "T" re(resenting the c.Si;e i$e$ the length of the follo&ing P)racedQ )ytes$ -he "E2F" re(resents a sometimes needed (ad )yte$ 7-he regular e+(ressions in this document are collected in A((endi+ A along &ith an e+(lanation of notation$8 /hun. ::S ID TP 53M-EN Q E2F

1ne chun. out(ut techni*ue is to stream &rite a chun. header stream &rite the chun. contents then random access )ac. to the header to fill in the si;e$ Another techni*ue is to ma.e a (reliminary (ass o'er the data to com(ute the si;e then &rite it out all at once$ Strings String /hun.s and String >ro(erties

In a string of AS/II te+t AF denotes a forced line )rea. 7(aragra(h or line terminator8$ 1ther control characters are not used$ 7/f$ /haracters$8 -he c.ID for a chun. that contains a string of (lain unformatted te+t is "-EH-"$ As a (ractical matter a te+t string should (ro)a)ly not )e longer than @?CBC )ytes$ -he standard allo&s u( to ?@1 0 1 )ytes$ Ihen used as a data (ro(erty 7see )elo&8 a te+t string chun. may )e 2 to ?55 characters long$ Such a string is readily con'erted to a / string or a >ascal S-#I<%E?55F$ -he c.ID of a (ro(erty must )e the (ro(erty name not "-EH-"$ Ihen used as a (art of a chun. or data (ro(erty restricted / string format is normally used$ -hat means 2 to ?55 characters follo&ed )y a <5A )yte 7AS/II 'alue 28$ Data >ro(erties Data (ro(erties s(ecify attri)utes for follo&ing 7non0(ro(erty8 chun.s$ A data (ro(erty essentially says "identifier S 'alue" for e+am(le "HM S 712 ?228" telling something a)out follo&ing chun.s$ >ro(erties may only a((ear inside data sections 7"F1#"" chun.s cf$ Data Sections8 and (ro(erty sections 7">#1>" chun.s cf$ %rou( >#1>8$ -he form of a data (ro(erty is a s(ecial case of /hun.$ -he c.ID is a (ro(erty name as &ell as a (ro(erty ty(e$ -he c.Si;e should )e small since data (ro(erties are intended to )e accumulated in #A" &hen reading a file$ 7?5B )ytes is a reasona)le u((er )ound$8 Syntactically: >ro(erty::S /hun. Ihen designing a data o),ect use (ro(erties to descri)e conte+t information li.e the si;e of an image e'en if they don6t 'ary in your (rogram$ 1ther (rograms &ill need this information$ -hin. of (ro(erty settings as assignments to 'aria)les in a (rogramming language$ "ulti(le assignments are redundant and local assignments tem(orarily o'erride glo)al assignments$ -he order of assignments doesn6t matter as long as they (recede the affected chun.s$ 7/f$ AIS-s /A-s and Shared >ro(erties$8 Each o),ect ty(e 7F1#" ty(e8 is a local name s(ace for (ro(erty IDs$ -hin. of a "/"A>" (ro(erty in a "F1#" IA3"" as the *ualified ID "IA3"$/"A>"$ >ro(erty IDs s(ecified &hen an o),ect ty(e is designed 7and therefore .no&n to all clients8 are called "standard" &hile s(eciali;ed ones added later are "nonstandard"$

Ain.s Issue: A standard mechanism for "lin.s" or "cross references" is 'ery desira)le for things li.e com)ining images and sounds into animations$ >erha(s &e6ll define "lin." chun.s &ithin F1#"s that refer to other F1#"s or to s(ecific chun.s &ithin the same and other F1#"s$ -his needs further &or.$ EA IFF 1!85 has no standard lin. mechanism$ For no& it may suffice to read a list of say musical instruments and then ,ust refer to them &ithin a musical score )y inde+ num)er$ File #eferences Issue: Ie may need a standard form for references to other files$ A "file ref" could name a directory and a file in the same ty(e of o(erating system as the ref6s originator$ Follo&ing the reference &ould e+(ect the file to )e on some mounted 'olume$ In a net&or. en'ironment a file ref could name a ser'er too$ Issue: =o& can &e e+(ress o(erating0system inde(endent file refs9 Issue: Ihat a)out a means to reference a (ortion of another file9 Iould this )e a "file ref" (lus a reference to a "lin." &ithin the target file9

4$ Data Sections -he first thing &e need of a file is to chec.: Does it contain IFF data and if so does it contain the .ind of data &e6re loo.ing for9 So &e come to the notion of a "data section"$ A "data section" or IFF "F1#"" is one self0contained "data o),ect" that might )e stored in a file )y itself$ It is one high le'el data o),ect such as a (icture or a sound effect$ -he IFF structure "F1#"" ma.es it self0 identifying$ It could )e a com(osite o),ect li.e a musical score &ith nested musical instrument descri(tions$ %rou( F1#" A data section is a chun. &ith c.ID "F1#"" and this arrangement: F1#" ::S "F1#"" TP Form-y(e 7Aocal/hun. R F1#" R AIS- R /A-8N Q Form-y(e::S ID Aocal/hun. ::S >ro(erty R /hun. -he ID "F1#"" is a syntactic .ey&ord li.e "struct" in /$ -hin. of a "struct IA3"" containing a field "/"A>"$ If you see "F1#"" you6ll .no& to e+(ect a F1#" ty(e ID 7the structure name "IA3"" in this e+am(le8 and a (articular contents arrangement or "synta+" 7local chun.s F1#"s AIS-s and /A-s8$ 7AIS-s and /A-s are discussed in (art 5 )elo&$8 A "F1#" IA3"" in (articular might contain a local chun. "/"A>" an "IA3"$/"A>" 7to use a *ualified name8$ So the chun. ID "F1#"" indicates a data section$ It im(lies that the chun. contains an ID and some num)er of nested chun.s$ In reading a F1#" li.e any other chun. (rograms must res(ect its c.Si;e as a 'irtual end0of0file for reading its contents e'en if they6re truncated$ -he Form-y(e 7or F1#" ty(e8 is a restricted ID that may not contain lo&er case letters or (unctuation characters$ 7/f$ -y(e IDs$ /f$ Single >ur(ose Files$8 -he ty(e0s(ecific information in a F1#" is com(osed of its "local chun.s": data (ro(erties and other chun.s$ Each F1#" ty(e is a local name s(ace for local chun. IDs$ So "/"A>" local chun.s in other F1#" ty(es may )e unrelated to "IA3"$/"A>"$ "ore than that each F1#" ty(e defines semantic sco(e$ If you .no& &hat a F1#" IA3" is you6ll .no& &hat an IA3"$/"A> is$ Aocal chun.s defined &hen the F1#" ty(e is designed 7and therefore .no&n to all clients of this ty(e8 are called "standard" &hile s(eciali;ed ones added later are "nonstandard"$ Among the local chun.s (ro(erty chun.s gi'e settings for 'arious details li.e te+t font &hile the other chun.s su((ly the essential information$ -his distinction is not clear cut$ A (ro(erty setting cancelled )y a later setting of the same (ro(erty has effect only on data chun.s in )et&een$ E$g$ in the se*uence: (ro(1 S + 7(ro(< S 'alue8N (ro(1 S y the setting (ro(1 S + has no effect$

&here the (ro(<s are not (ro(1

-he follo&ing uni'ersal chun. IDs are reser'ed inside any F1#": "AIS-" "F1#"" ">#1>" "/A- " "JJJJ" "AIS1" through "AIS!" "F1#1" through "F1#!" and "/A-1" through "/A-!"$ 7/f$ /hun.s$ /f$ %rou( AIS-$ /f$

%rou( >#1>$8 For clarity ty(e IDs either$

these uni'ersal chun. names may not )e F1#"

>art 5 )elo& tal.s a)out grou(ing F1#"s into AIS-s and /A-s$ -hey let you grou( a )unch of F1#"s )ut don6t im(ose any (articular meaning or constraints on the grou(ing$ #ead on$ /om(osite F1#"s A F1#" chun. inside a F1#" is a full0fledged data section$ -his means you can )uild a com(osite o),ect li.e a multi0frame animation se*uence from a'aila)le (icture F1#"s and sound effect F1#"s$ Mou can insert additional chun.s &ith information li.e frame rate and frame count$ 5sing com(osite F1#"s you le'erage on e+isting (rograms that create and edit the com(onent F1#"s$ -hose editors may e'en loo. into your com(osite o),ect to co(y out its ty(e of com(onent although it6ll )e the rare (rogram that6s fancy enough to do that$ Such editors are not allo&ed to re(lace their com(onent o),ects &ithin your com(osite o),ect$ -hat6s )ecause the IFF standard lets you s(ecify consistency re*uirements for the com(osite F1#" such as maintaining a count or a directory of the com(onents$ 1nly (rograms that are &ritten to u(hold the rules of your F1#" ty(e should create or modify such F1#"s$ -herefore in designing a (rogram that creates com(osite o),ects you are strongly re*uested to (ro'ide a facility for your users to im(ort and e+(ort the nested F1#"s$ Im(ort and e+(ort could mo'e the data through a cli()oard or a file$ =ere are se'eral e+isting F1#" ty(es and rules for defining ne& ones$ F-HAn F-H- data section contains te+t &ith character formatting information li.e fonts and faces$ It has no (aragra(h or document formatting information li.e margins and (age headers$ F1#" F-H- is &ell matched to the te+t re(resentation in Amiga6s Intuition en'ironment$ See the su((lemental document "F-H-" IFF Formatted -e+t$ IA3" "IA3"" is an InterAea'ed 3it"a( image &ith color ma(: a machine0inde(endent format for raster images$ F1#" IA3" is the standard image file format for the /ommodore0Amiga com(uter and is useful in other en'ironments too$ See the su((lemental document "IA3"" IFF Interlea'ed 3itma($ >I/S -he data chun. inside a ">I/S" data section has ID ">I/-" and holds a Kuic.Dra& (icture$ Issue: Allo& more than one >I/- in a >I/S9 See Inside "acintosh cha(ter "Kuic.Dra&" for details on >I/-s and ho& to create and dis(lay them on the "acintosh com(uter$ -he only standard (ro(erty for >I/S is "HM" an o(tional (ro(erty that indicates the (osition of the >I/- relati'e to "the )ig (icture"$ -he contents of an HM is a Kuic.Dra& >oint$ <ote: >I/- may )e limited to "acintosh use in &hich case there6ll )e another format for structured gra(hics in other en'ironments$ 1ther "acintosh #esource -y(es Some other "acintosh resource ty(es could )e ado(ted for use &ithin

IFF files: (erha(s "I#-

I/<

I/<T

and S-#T$

Issue: /onsider the candidates and reser'e some more IDs$ Designing <e& Data Sections Su((lemental documents &ill define additional o),ect ty(es$ A su((lement needs to s(ecify the o),ect6s (ur(ose its F1#" ty(e ID the IDs and formats of standard local chun.s and rules for generating and inter(reting the data$ It6s a good idea to su((ly ty(edefs and an e+am(le source (rogram that accesses the ne& o),ect$ See "IA3"" IFF Interlea'ed 3itma( for a good e+am(le$ Anyone can (ic. a ne& F1#" ty(e ID )ut should reser'e it &ith Electronic Arts at their earliest con'enience$ EIssue: EA contact (erson9 =and this off to another organi;ation9F Ihile decentrali;ed format definitions and e+tensions are (ossi)le in IFF our (reference is to get design consensus )y committee im(lement a (rogram to read and &rite it (erha(s tune the format and then (u)lish the format &ith e+am(le code$ Some organi;ation should remain in charge of ans&ering *uestions and coordinating e+tensions to the format$ If it )ecomes necessary to re'ise the design of some data section its F1#" ty(e ID &ill ser'e as a 'ersion num)er 7/f$ -y(e IDs8$ E$g$ a re'ised "GDE1" data section could )e called "GDE1"$ 3ut try to get )y &ith com(ati)le re'isions &ithin the e+isting F1#" ty(e$ In a ne& F1#" ty(e the rules for (rimiti'e data ty(es and &ord0alignment 7/f$ >rimiti'e Data -y(es8 may )e o'erriden for the contents of its local chun.s )ut not for the chun. structure itself if your documentation s(ells out the de'iations$ If machine0s(ecific ty(e 'ariants are needed e$g$ to store 'ast num)ers of integers in re'erse )it order then outline the con'ersion algorithm and indicate the 'ariant inside each file (erha(s 'ia different F1#" ty(es$ <eedless to say 'ariations should )e minimi;ed$ In designing a F1#" ty(e enca(sulate all the data that other (rograms &ill need to inter(ret your files$ E$g$ a raster gra(hics image should s(ecify the image si;e e'en if your (rogram al&ays uses @?2 + ?22 (i+els + @ )it(lanes$ #ecei'ing (rograms are then em(o&ered to a((end or cli( the image rectangle to add or dro( )it(lanes etc$ -his ena)les a lot more com(ati)ility$ Se(arate the central data 7li.e musical notes8 from more s(eciali;ed information 7li.e note )eams8 so sim(ler (rograms can e+tract the central (arts during read0in$ Aea'e room for e+(ansion so other (rograms can s*uee;e in ne& .inds of information 7li.e lyrics8$ And remem)er to .ee( the (ro(erty chun.s managea)ly short let6s say ? ?5B )ytes$ Ihen designing a data o),ect try to stri.e a good tradeoff )et&een a su(er0general format and a highly0s(eciali;ed one$ Fit the details to at least one (articular need for e+am(le a raster image might as &ell store (i+els in the current machine6s scan order$ 3ut add the .ind of generality that ma.es it usa)le &ith foreseea)le hard&are and soft&are$ E$g$ use a &hole )yte for each red green and )lue color 'alue e'en if this year6s com(uter has only 40)it 'ideo DA/s$ -hin. ahead and hel( other (rograms so long as the o'erhead is acce(ta)le$ E$g$ run com(ress a raster )y scan line rather than as a unit so future (rograms can s&a( images )y scan line to and from secondary storage$ -ry to design a general (ur(ose "least common multi(le" format that encom(asses the needs of many (rograms &ithout getting too com(licated$ Aet6s coalesce our uses around a fe& such formats &idely se(arated

in the 'ast design s(ace$ -&o factors ma.e this fle+i)ility and sim(licity (ractical$ First file storage s(ace is getting 'ery (lentiful so com(action is not a (riority$ Second nearly any locally0(erformed data con'ersion &or. during file reading and &riting &ill )e chea( com(ared to the ID1 time$ It must )e o. to co(y a AIS- or F1#" or /A- intact e$g$ to incor(orate it into a com(osite F1#"$ So any .ind of internal references &ithin a F1#" must )e relati'e references$ -hey could )e relati'e to the start of the containing F1#" relati'e from the referencing chun. or a se*uence num)er into a collection$ Iith com(osite F1#"s you le'erage on e+isting (rograms that create and edit the com(onents$ If you &rite a (rogram that creates com(osite o),ects (lease (ro'ide a facility for your users to im(ort and e+(ort the nested F1#"s$ -he im(ort and e+(ort functions may mo'e data through a se(arate file or a cli()oard$ Finally don6t forget to s(ecify all im(lied rules in detail$

5$ AIS-s

/A-s

and Shared >ro(erties

Data often needs to )e grou(ed together li.e a list of icons$ Sometimes a tric. li.e arranging little images into a )ig raster &or.s )ut generally they6ll need to )e structured as a first class grou($ -he o),ects "AIS-" and "/A-" are IFF0uni'ersal mechanisms for this (ur(ose$ >ro(erty settings sometimes need to )e shared o'er a list of similar o),ects$ E$g$ a list of icons may share one color ma($ AIS- (ro'ides a means called ">#1>" to do this$ 1ne (ur(ose of a AIS- is to define the sco(e of a >#1>$ A "/A-" on the other hand is sim(ly a concatenation of o),ects$ Sim(ler (rograms may s.i( AIS-s and >#1>s altogether and ,ust handle F1#"s and /A-s$ All "fully0conforming" IFF (rograms also .no& a)out "/A- " "AIS-" and ">#1>"$ Any (rogram that reads a F1#" inside a AIS- must (rocess shared >#1>s to correctly inter(ret that F1#"$ %rou( /AA /A- is ,ust an unty(ed grou( of data o),ects$ Structurally a /A- is a chun. &ith chun. ID "/A- " containing a "contents ty(e" ID follo&ed )y the nested o),ects$ -he c.Si;e of each contained chun. is essentially a relati'e (ointer to the ne+t one$ /A::S "/A- " TP /ontents-y(e 7F1#" R AIS- R /A-8N Q /ontents-y(e ::S ID 00 a hint or an "a)stract data ty(e" ID In reading a /A- li.e any other chun. (rograms must res(ect it6s c.Si;e as a 'irtual end0of0file for reading the nested o),ects e'en if they6re malformed or truncated$ -he "contents ty(e" follo&ing the /A-6s c.Si;e indicates &hat .ind of F1#"s are inside$ So a /A- of IA3"s &ould store "IA3"" there$ It6s ,ust a hint$ It may )e used to store an "a)stract data ty(e"$ A /Acould ,ust ha'e )lan. contents ID 7"JJJJ"8 if it contains more than one .ind of F1#"$ /A- defines only the format of the grou($ -he grou(6s meaning is o(en to inter(retation$ -his is li.e a list in AIS>: the structure of cells is (redefined )ut the meaning of the contents as say an association list de(ends on use$ If you need a grou( &ith an enforced meaning 7an "a)stract data ty(e" or Smalltal. "su)class"8 some consistency constraints or additional data chun.s use a com(osite F1#" instead 7/f$ /om(osite F1#"s8$ Since a /A- ,ust means a concatenation of o),ects /A-s are rarely nested$ >rograms should really merge /A-s rather than nest them$ %rou( AISA AIS- defines a grou( 'ery much li.e /A- )ut it also gi'es a sco(e for >#1>s 7see )elo&8$ And unli.e /A-s AIS-s should not )e merged &ithout understanding their contents$ Structurally a AIS- is a chun. &ith c.ID "AIS-" containing a "contents ty(e" ID o(tional shared (ro(erties and the nested contents 7F1#"s AIS-s and /A-s8 in that order$ -he c.Si;e of each contained chun. is a relati'e (ointer to the ne+t one$ A AIS- is not an ar)itrary lin.ed list the cells are sim(ly concatenated$

AIS::S "AIS-" TP /ontents-y(e >#1>N 7F1#" R AIS- R /A-8N Q /ontents-y(e ::S ID %rou( >#1> >#1> chun.s may a((ear in AIS-s 7not in F1#"s or /A-s8$ -hey su((ly shared (ro(erties for the F1#"s in that AIS-$ -his a)ility to ele'ate some (ro(erty settings to shared status for a list of forms is useful for )oth indirection and com(action$ E$g$ a list of images &ith the same si;e and colors can share one "si;e" (ro(erty and one "color ma(" (ro(erty$ Indi'idual F1#"s can o'erride the shared settings$ -he contents of a >#1> is li.e a F1#" &ith no data chun.s: >#1> It means ::S ">#1>" TP Form-y(e >ro(ertyN Q "=ere are the shared (ro(erties for F1#" ty(e UUForm-y(eV$"

A AIS- may ha'e at most one >#1> of a F1#" ty(e and all the >#1>s must a((ear )efore any of the F1#"s or nested AIS-s and /A-s$ Mou can ha'e su)se*uences of F1#"s sharing (ro(erties )y ma.ing each su)se*uence a AIS-$ Sco(ing: -hin. of (ro(erty settings as 'aria)le )indings in nested )loc.s of a (rogramming language$ Ihere in / you could &rite: -EH-WF1<- te+tWfont S /ourier: DN (rogram6s glo)al default ND ND ND

File78: P -EH-WF1<- te+tWfont S -imes#oman:

DN shared setting

P -EH-WF1<- te+tWfont S =el'etica: DN local setting >rint7"=ello "8:DN uses font =el'etica ND Q P >rint7"there$"8:DN uses font -imes#oman ND Q Q An IFF file could contain: AIS- P >#1> -EH- P F1<- P-imes#omanQ Q DN shared setting ND

F1#" -EH- P F1<- P=el'eticaQDN local settingND /=#S P=ello Q DN uses font =el'etica Q F1#" -EH- P /=#S Pthere$Q Q Q DN uses font -imes#oman ND

ND

-he shared (ro(erty assignments selecti'ely o'erride the reader6s glo)al defaults )ut only for F1#"s &ithin the grou($ A F1#"6s o&n (ro(erty assignments selecti'ely o'erride the glo)al and grou(0su((lied 'alues$ So &hen reading an IFF file .ee( (ro(erty settings on a stac.$ -hey6re designed to )e small enough to hold in main memory$

Shared (ro(erties are semantically e*ui'alent to co(ying those (ro(erties into each of the nested F1#"s right after their F1#" ty(e IDs$ >ro(erties for AIS1(tional "(ro(erties for AIS-" store the origin of the list6s contents in a >#1> chun. for the fa.e F1#" ty(e "AIS-"$ -hey are the (ro(erties originating (rogram "1>%"" (rocessor family "1/>5" com(uter ty(e "1/">" com(uter serial num)er or net&or. address "1S< " and user name "5<A""$ In our im(erfect &orld these could )e called u(on to distinguish )et&een unintended 'ariations of a data format or to &or. around )ugs in (articular originatingDrecei'ing (rogram (airs$ Issue: S(ecify the format of these (ro(erties$ A creation date could also )e stored in a (ro(erty )ut let6s as. that file creating editing and trans(orting (rograms maintain the correct date in the local file system$ >rograms that mo'e files )et&een machine ty(es are e+(ected to co(y across the creation dates$

B$ Standard File Structure File Structure 1'er'ie& An IFF file is ,ust a single chun. of ty(e F1#" AIS- or /A-$ -herefore an IFF file can )e recogni;ed )y its first 4 )ytes: "F1#"" "AIS-" or "/A- "$ Any file contents after the chun.6s end are to )e ignored$ Since an IFF file can )e a grou( of o),ects (rograms that readD&rite single o),ects can communicate to an e+tent &ith (rograms that readD&rite grou(s$ Mou6re encouraged to &rite (rograms that handle all the o),ects in a AIS- or /A-$ A gra(hics editor for e+am(le could (rocess a list of (ictures as a multi(le (age document one (age at a time$ >rograms should enforce IFF6s syntactic rules &hen reading and &riting files$ -his ensures ro)ust data transfer$ -he (u)lic domain IFF readerD&riter su)routine (ac.age does this for you$ A utility (rogram "IFF/hec." is a'aila)le that scans an IFF file and chec.s it for conformance to IFF6s syntactic rules$ IFF/hec. also (rints an outline of the chun.s in the file sho&ing the c.ID and c.Si;e of each$ -his is *uite handy &hen )uilding IFF (rograms$ E+am(le (rograms are also a'aila)le to sho& details of reading and &riting IFF files$ A merge (rogram "IFFJoin" &ill )e a'aila)le that logically a((ends IFF files into a single /A- grou($ It "un&ra(s" each in(ut file that is a /A- so that the com)ined file isn6t nested /A-s$ If &e need to re'ise the IFF standard the three anchoring IDs &ill )e used as "'ersion num)ers"$ -hat6s &hy IDs "F1#1" through "F1#!" "AIS1" through "AIS!" and "/A-1" through "/A-!" are reser'ed$ IFF formats are designed for reasona)le (erformance &ith flo((y dis.s$ Ie achie'e considera)le sim(licity in the formats and (rograms )y relying on the host file system rather than defining uni'ersal grou(ing structures li.e directories for AIS- contents$ 1n huge storage systems IFF files could )e leaf nodes in a file structure li.e a 30tree$ Aet6s ho(e the host file system im(lements that for us4 -hre are t&o .inds of IFF files: single (ur(ose files and scra( files$ -hey differ in the inter(retation of multi(le data o),ects and in the file6s e+ternal ty(e$ Single >ur(ose Files A single (ur(ose IFF file is for normal "document" and "archi'e" storage$ -his is in contrast &ith "scra( files" 7see )elo&8 and tem(orary )ac.ing storage 7non0interchange files8$ -he e+ternal file ty(e 7or filename e+tension de(ending on the host file system8 indicates the file6s contents$ It6s generally the F1#" ty(e of the data contained hence the restrictions on F1#" ty(e IDs$ >rogrammers and users may (ic. an "intended use" ty(e as the filename e+tension to ma.e it easy to filter for the rele'ant files in a filename re*uestor$ -his is actually a "su)class" or "su)ty(e" that con'eniently se(arates files of the same F1#" ty(e that ha'e different uses$ >rograms cannot demand conformity to its e+(ected su)ty(es &ithout o'erly restricting data interchange since they cannot .no& a)out the su)ty(es to )e used )y future (rograms that users &ill &ant to e+change data &ith$ Issue: =o& to generate @0letter "S0D1S e+tensions from 40letter F1#" ty(e IDs9

"ost single (ur(ose files &ill )e a single F1#" 7(erha(s a com(osite F1#" li.e a musical score containing nested F1#"s li.e musical instrument descri(tions8$ If it6s a AIS- or a /A- (rograms should s.i( o'er unrecogni;ed o),ects to read the recogni;ed ones or the first recogni;ed one$ -hen a (rogram that can read a single (ur(ose file can read something out of a "scra( file" too$ Scra( Files A "scra( file" is for ma+imum interconnecti'ity in getting data )et&een (rograms: the core of a cli()oard function$ Scra( files may ha'e ty(e "IFF " or filename e+tension "$IFF"$ A scra( file is ty(ically a /A- containing alternate re(resentations of the same )asic information$ Include as many alternati'es as you can readily generate$ -his redundancy im(ro'es interconnecti'ity in situations &here &e can6t ma.e all (rograms read and &rite su(er0general formats$ EInside "acintosh cha(ter "Scra( "anager"$F E$g$ a gra(hically0 annotated musical score might )e su((lemented )y a stri((ed do&n 40'oice melody and )y a te+t 7the lyrics8$ -he originating (rogram should &rite the alternate re(resentations in order of "(reference": most (referred 7most com(rehensi'e8 ty(e to least (referred 7least com(rehensi'e8 ty(e$ A recei'ing (rogram should either use the first a((earing ty(e that it understands or search for its o&n "(referred" ty(e$ A scra( file should ha'e at most one alternati'e of any ty(e$ 7A AISof same ty(e o),ects is o. as one of the alternati'es$8 3ut don6t count on this &hen reading: ignore e+tra sections of a ty(e$ -hen a (rogram that reads scra( files can read something out of single (ur(ose files$ #ules for #eader >rograms =ere are some notes on )uilding (rograms that read IFF files$ If you use the standard IFF reader module "IFF#$/" many of these rules and details &ill )e automatically handled$ 7See "Su((ort Soft&are" in A((endi+ A$8 Ie recommend that you start from the e+am(le (rogram "Sho&IA3"$/"$ Mou should also read u( on recursi'e descent (arsers$ ESee for e+am(le /om(iler /onstruction An Ad'anced /ourse$F X -he standard is 'ery fle+i)le so many (rograms can e+change data$ -his im(lies a (rogram has to scan the file and react to &hat6s actually there in &hate'er order it a((ears$ An IFF reader (rogram is a (arser$ X For interchange to really &or. (rograms must )e &illing to do some con'ersion during read0in$ If the data isn6t e+actly &hat you e+(ect say the raster is smaller than those created )y your (rogram then ad,ust it$ Similarly your (rogram could cro( a large (icture add or dro( )it(lanes and createDdiscard a mas. (lane$ -he (rogram should gi'e u( gracefully on data that it can6t con'ert$ X If it doesn6t start &ith "F1#"" an IFF085 file$ X For any chun. you encounter to understand its contents$ "AIS-" or "/A- " it6s not

you must recogni;e its ty(e ID

X For any F1#" chun. you encounter you must recogni;e its F1#" ty(e ID to understand the contained "local chun.s"$ E'en if you don6t

recogni;e the F1#" ty(e and /A-s of interest$ X

you can still scan it for nested F1#"s

AIS-s

Don6t forget to s.i( the (ad )yte after e'ery odd0length chun.$

X /hun. ty(es AIS- F1#" >#1> and /A- are generic grou(s$ -hey al&ays contain a su)ty(e ID follo&ed )y chun.s$ X #eaders ought to handle a /A- of F1#"s in a file$ Mou may treat the F1#"s li.e document (ages to se*uence through or ,ust use the first F1#"$ X Sim(ler IFF readers com(letely s.i( AIS-s$ "Fully IFF0conforming" readers are those that handle AIS-s e'en if ,ust to read the first F1#" from a file$ If you do loo. into a AIS- you must (rocess shared (ro(erties 7in >#1> chun.s8 (ro(erly$ -he idea is to get the correct data or none at all$ X -he nicest readers are &illing to loo. into unrecogni;ed F1#"s for nested F1#" ty(es that they do recogni;e$ For e+am(le a musical score may contain nested instrument descri(tions and an animation file may contain still (ictures$ <ote to (rogrammers: >rocessing >#1> chun.s is not sim(le4 Mou6ll need some )ac.ground in inter(reters &ith stac. frames$ If this is foreign to you )uild (rograms that readD&rite only one F1#" (er file$ For the more intre(id (rogrammers the ne+t (aragra(h summari;es ho& to (rocess AIS-s and >#1>s$ See the general IFF reader module "IFF#$/" and the e+am(le (rogram "Sho&IA3"$/" for details$ Allocate a stac. frame for e'ery AIS- and F1#" you encounter and initiali;e it )y co(ying the stac. frame of the (arent AIS- or F1#"$ At the to( le'el you6ll need a stac. frame initiali;ed to your (rogram6s glo)al defaults$ Ihile reading each AIS- or F1#" store all encountered (ro(erties into the current stac. frame$ In the e+am(le Sho&IA3" each stac. frame has a (lace for a )itma( header (ro(erty IA3"$3"=D and a color ma( (ro(erty IA3"$/"A>$ Ihen you finally get to the IA3"6s 31DM chun. use the (ro(erty settings accumulated in the current stac. frame$ An alternate im(lementation &ould ,ust remem)er >#1>s encountered forgetting each on reaching the end of its sco(e 7the end of the containing AIS-8$ Ihen a F1#" HHHH is encountered scan the chun.s in all remem)ered >#1>s HHHH in order as if they a((eared )efore the chun.s actually in the F1#" HHHH$ -his gets tric.ier if you read F1#"s inside of F1#"s$ #ules for Iriter >rograms =ere are some notes on )uilding (rograms that &rite IFF files &hich is much easier than reading them$ If you use the standard IFF &riter module "IFFI$/" 7see "Su((ort Soft&are" in A((endi+ A8 many of these rules and details &ill automatically )e enforced$ See the e+am(le (rogram "#a&?IA3"$/"$ X An IFF file is a single F1#" AISor /A- chun.$

X Any IFF085 file must start &ith the 4 characters "F1#"" "AIS-" or "/A- " follo&ed )y a A1<% c.Si;e$ -here should )e no data after the chun. end$ X /hun. ty(es AIS- F1#" >#1> and /A- are generic$ -hey al&ays contain a su)ty(e ID follo&ed )y chun.s$ -hese three IDs are uni'ersally reser'ed as are "AIS1" through "AIS!" "F1#1" through "F1#!" "/A-1" through "/A-!" and " "$

Don6t forget to &rite a 2 (ad )yte after each odd0length chun.$

X Four techni*ues for &riting an IFF grou(: 718 )uild the data in a file ma((ed into 'irtual memory 7?8 )uild the data in memory )loc.s and use )loc. ID1 7@8 stream &rite the data (iecemeal and 7don6t forget48 random access )ac. to set the grou( length count and 748 ma.e a (reliminary (ass to com(ute the length count then stream &rite the data$ X Do not try to edit a file that you don6t .no& ho& to create$ >rograms may loo. into a file and co(y out nested F1#"s of ty(es that they recogni;e )ut don6t edit and re(lace the nested F1#"s and don6t add or remo'e them$ -hat could ma.e the containing structure inconsistent$ Mou may &rite a ne& file containing items you co(ied 7or co(ied and modified8 from another IFF file )ut don6t co(y structural (arts you don6t understand$ X Mou must adhere to the synta+ descri(tions in A((ende+ A$ E$g$ >#1>s may only a((ear inside AIS-s$

A((endi+ A$ #eference -y(e Definitions -he follo&ing / ty(edefs descri)e standard IFF structures$ Declarations to use in (ractice &ill 'ary &ith the />5 and com(iler$ For e+am(le B8222 Aattice / (roduces efficient com(arison code if &e define ID as a "A1<%"$ A macro ""a.eID" )uilds these IDs at com(ile time$ DN Standard IFF ty(es ty(edef ty(edef ty(edef ty(edef e+(ressed in B8222 Aattice /$ ND ND ND ND

unsigned char 53M-E: DN 8 )its unsigned short I1#D: DN 1B )its signed ND unsigned short 5I1#D: DN 1B )its unsigned long A1<%: DN @? )its signed ND DN 4 chars in 6 6 through 6O6

ty(edef char IDE4F:

ty(edef struct P ID c.ID: A1<% c.Si;e: DN si;eof7c.Data8 53M-E c.DataEDN c.Si;e NDF: Q /hun.:

ND

DN ID ty(edef and )uilder for B8222 Aattice /$ ND ty(edef A1<% ID: DN 4 chars in 6 6 through 6O6 ND Tdefine "a.eID7a ) c d8 7 7a8UUUU?4 R 7)8UUUU1B R 7c8UUUU8 R 7d8 8 DN %lo)ally reser'ed IDs$ ND Tdefine IDWF1#" "a.eID76F6 Tdefine IDWAIS"a.eID76A6 Tdefine IDW>#1> "a.eID76>6 Tdefine IDW/A"a.eID76/6 Tdefine IDWFIAAE# "a.eID76 6 Synta+ Definitions =ere6s a collection of the synta+ definitions in this document$ /hun. ::S ID TP 53M-EN Q E2F 616 6I6 6#6 6A6 6 6 6#6 6S6 616 6-6 6 6 6"68 6-68 6>68 6 68 6 68

>ro(erty::S /hun. F1#" ::S "F1#"" TP Form-y(e 7Aocal/hun. R F1#" R AIS- R /A-8N Q Form-y(e::S ID Aocal/hun. ::S >ro(erty R /hun. /A::S "/A- " TP /ontents-y(e 7F1#" R AIS- R /A-8N Q /ontents-y(e ::S ID 00 a hint or an "a)stract data ty(e" ID AIS>#1> ::S "AIS-" TP /ontents-y(e >#1>N 7F1#" R AIS- R /A-8N Q ::S ">#1>" TP Form-y(e >ro(ertyN Q

In this e+tended regular e+(ression notation the to.en "T" re(resents a c.Si;e A1<% count of the follo&ing P)racedQ data )ytes$ Aiteral items are sho&n in "*uotes" Es*uare )rac.eted itemsF are o(tional and "N" means 2 or more instances$ A sometimes0needed (ad )yte is sho&n as "E2F"$ Defined /hun. IDs

-his is a ta)le of currently defined chun. IDs$ Ie may also )orro& some "acintosh IDs and data formats$ %rou( chun. IDs F1#" AIS- >#1> /A-$ Future re'ision grou( chun. IDs F1#1 I F1#! AIS1 I AIS! /A-1 I /A-!$ F1#" ty(e IDs 7-he a)o'e grou( chun. IDs may not )e used for F1#" ty(e IDs$8 7Ao&er case letters and (unctuation mar.s are for)idden in F1#" ty(e IDs$8 8SGH 80)it sam(led sound 'oice A<3" animated )itma( F<-# raster font F<-G 'ector font F-H- formatted te+t %S/# general0use musical score IA3" interlea'ed raster )itma( image >DEF Delu+e >rint (age definition >I/S "acintosh (icture >A3" 7o)solete8 5S/# 5huru Sound Soft&are musical score 5G1H 5huru Sound Soft&are "acintosh 'oice S"5S sim(le musical score GDE1 Delu+e Gideo /onstruction Set 'ideo$ Data chun. IDs "JJJJ" -EH- >I/-$ >#1> AIS- (ro(erty IDs 1>%" 1/>5 1/"> 1S< 5<A"$

Su((ort Soft&are -hese (u)lic domain / source (rograms are a'aila)le for use in )uilding IFF0com(ati)le (rograms: IFF$= IFF#$/ IFFI$/ IFF reader and &riter (ac.age$ -hese modules handle many of the details of relia)ly reading and &riting IFF files$ IFF/hec.$/ -his handy utility (rogram scans an IFF file chec.s that the contents are &ell formed and (rints an outline of the chun.s$ >ac.er$/ 5n>ac.er$/

>A/JE#$=

#un encoder and decoder used for IA3" files$ IA3"$= IA3"#$/ IA3"I$/ #eader and &riter su((ort routines for raster image F1#" IA3"$ IA3"# calls IFF# and 5n>ac.er$ IA3"I calls IFFI and >ac.er$ Sho&IA3"$/ E+am(le caller of IFF# and IA3"# modules$ -his /ommodore0Amiga (rogram reads and dis(lays a F1#" IA3"$ #a&?IA3"$/ E+am(le IA3" &riter (rogram$ As a demonstration it reads a ra& raster image file and &rites the image as a F1#" IA3" file$ IA3"?#a&$/ E+am(le IA3" reader (rogram$ #eads a F1#" IA3" file and &rites it into a ra& raster image$ #E"AAA1/$= #emalloc$c "emory allocation routines used in these e+am(les$ I<-5AAA$= #EAD>I/-$= generic "include almost e'erything" include0file &ith the se*uence of includes correctly s(ecified$ #ead>ict$c gi'en an IA3" file a color ma( >5->I/-$= >ut>ict$c gi'en a )itma( and a color ma( an IA3" file$ %I1$= %io$c sa'e it as read it into a )itma( and

generic ID1 s(eedu( (ac.age$ Attem(ts to s(eed dis. ID1 )y )uffering &rites and reads$ sam(le call to gio$ reads in IA3" file (rints out ascii re(resentation for including in / files$ (rints out a /0language re(resentation of data for

giocall$c il)mdum($c )m(rintc$c

a )itma($

E+am(le Diagrams =ere6s a )o+ diagram for an e+am(le IFF file a raster image F1#" IA3"$ -his F1#" contains a )itma( header (ro(erty chun. 3"=D a color ma( (ro(erty chun. /"A> and a raster data chun. 31DM$ -his (articular raster is @?2 + ?22 (i+els + @ )it (lanes uncom(ressed$ -he "2" after the /"A> chun. re(resents a ;ero (ad )yte: included since the /"A> chun. has an odd length$ -he te+t to the right of the diagram sho&s the outline that &ould )e (rinted )y the IFF/hec. utility (rogram for this (articular file$ Y00000000000000000000000000000000000Y R6F1#"6 ?42C2 R Y00000000000000000000000000000000000Y R6IA3"6 R Y00000000000000000000000000000000000Y R Y0000000000000000000000000000000Y R R R 63"=D6 ?2 R R R R @?2 ?22 2 2 @ 2 2 $$$ R R R Y 000000000000000000000000000000Y R R R 6/"A>6 ?1 R R R R 2 2 2: @? 2 2: B4 2 2: $$ R R R Y0000000000000000000000000000000Y R R 2 R Y00000000000000000000000000000000000Y R631DM6 ?4222 R R2 2 2 $$$ R Y00000000000000000000000000000000000Y F1#" ?42C2 I3A"

$3"=D $/"A>

?2 ?1

$31DM ?4222

-his second diagram sho&s a AIS- of t&o F1#"s IA3" sharing a common 3"=D (ro(erty and a common /"A> (ro(erty$ Again the te+t on the right is an outline a la IFF/hec.$ Y00000000000000000000000000000000000000000Y R6AIS-6 48114 R Y00000000000000000000000000000000000000000Y R6AAAA6 R R Y00000000000000000000000000000000000Y R R R6>#1>6 B? R R R Y00000000000000000000000000000000000Y R R R6IA3"6 R R R Y00000000000000000000000000000000000Y R R R Y0000000000000000000000000000000Y R R R R R 63"=D6 ?2 R R R R R R @?2 ?22 2 2 @ 2 2 $$$ R R R R R R 000000000000000000000000000000Y R R R R R 6/"A>6 ?1 R R R R R R 2 2 2: @? 2 2: B4 2 2: $$ R R R R R Y0000000000000000000000000000000Y R R R R 2 R R R Y00000000000000000000000000000000000Y R R Y00000000000000000000000000000000000Y R R R6F1#"6 ?421? R R R Y00000000000000000000000000000000000Y R R R6IA3"6 R R R Y00000000000000000000000000000000000Y R R R Y00000000000000000000000000000Y R R R R R631DM6 ?4222 R R R R R R2 2 2 $$$ R R R R R Y00000000000000000000000000000Y R R R Y00000000000000000000000000000000000Y R

AIS$>#1>

48114 B?

AAAA IA3"

$$3"=D $$/"A>

?2 ?1

$F1#"

?421?

IA3"

$$31DM

?4222

R Y00000000000000000000000000000000000Y R R R6F1#"6 ?421? R R R Y00000000000000000000000000000000000Y R R R6IA3"6 R R R Y00000000000000000000000000000000000Y R R R Y00000000000000000000000000000Y R R R R R631DM6 ?4222 R R R R R R2 2 2 $$$ R R R R R Y00000000000000000000000000000Y R R R Y00000000000000000000000000000000000Y R Y00000000000000000000000000000000000000000Y

$F1#"

?421?

IA3"

$$31DM

?4222

A((endi+ 3$ Standards /ommittee -he follo&ing (eo(le contri)uted to the design of this IFF standard: 3o) "Jodia." 3urns /ommodore0Amiga #$ J$ "ical /ommodore0Amiga Jerry "orrison Electronic Arts %reg #i.er Electronic Arts Ste'e Sha& Electronic Arts 3arry Ialsh /ommodore0Amiga

You might also like