Ticket #1045: DEEP.txt

File DEEP.txt, 7.0 KB (added by ami_stuff, 4 years ago)
Line 
1Chunky pixel image files (Used in TV Paint)
2
3IFF FORM / CHUNK DESCRIPTION
4============================
5
6Form/Chunk ID:  FORM  DEEP      (DEEP pixels)
7                Chunk DGBL      (Deep GloBaL information)
8                Chunk DPEL      (Deep Pixel ELements)
9                Chunk DLOC      (Deep display LOCation)
10                Chunk DBOD      (Deep data BODy)
11                Chunk DCHG      (Deep CHanGe buffer)
12
13Date Submitted: 10-Sep-91
14Submitted by:   Amiga Centre Scotland
15
16
17FORM
18====
19
20FORM ID:        DEEP    (DEEP pixels)
21
22FORM Purpose:
23
24To allow faster loading and saving of images when pixels are
25stored in consecutive memory locations and provide support for
26common extensions implemented on advanced graphics cards.
27
28FORM Description:
29
30This form is designed to provide support for a variety of deep
31pixels, including 24 bits images.  A deep pixel is one in which
32the pixel value is used to directly produce the output colour
33without the use of a colour look-up table and also where the
34pixel is stored in consecutive memory locations.  The format
35allows additional bits to be stored along with the colour bits
36to provide support for additional features such as masks,
37Z-buffers, linear keys, etc.
38
39The format is designed to allow different colour formats to be
40stored such as RGB, RGBA, YCM and YCMB with varying depths
41supported.  Bit ordering will be most significant bit first.
42
43
44CHUNKS
45======
46
47Chunk ID:       DGBL    (Deep GloBaL information)
48
49Chunk Purpose:
50
51Provide global information of relevance to all the data contained
52in the file.  DGBL will always be the first chunk in the file.
53
54Chunk Description:
55
56Used to provide information that is constant for all contents of
57the file.  One chunk is mandatory at the start of the file.  When
58the file is used to store a group of images it may, in
59exceptional circumstances, be necessary to add additional DGBL
60chunks.  The contents of a DGBL chunk remain valid until another
61DGBL chunk is encountered.
62
63
64Chunk ID:       DPEL    (Deep Pixel Elements)
65
66Chunk Purpose:
67
68Defines the contents of each pixel.  Enables the data content to
69be identified and handled.  Data that is unknown or not required
70can be discarded.
71
72Chunk Description:
73
74This chunk is best described by an example:
75
76        Original data = RGBA 8:8:8:4
77
78        DPEL =
79                4       (number of elements)
80                        RED     (first element)
81                        8       (bits in element)
82                        GREEN   (second element)
83                        8       (bits in second element)
84                        BLUE    (third element)
85                        8       (bits in third element)
86                        ALPHA   (fourth element)
87                        4       (bits in fourth element)
88
89        Stored data (binary) = rrrrrrrr gggggggg bbbbbbbb aaaa0000
90
91  Note:  The pixel has been padded to the next byte boundary.
92
93The elements must be defined in the order in which they are
94stored, with the most significant bit first.
95
96
97Chunk ID:       DLOC    (Deep display LOCation)
98
99Chunk Purpose:
100
101Provides information specific to the following DBOD section.
102Enables image sections to be located within the screen area
103individually & allows images with a size different to
104DisplayWidth & DisplayHeight to be stored.
105
106Chunk Description:
107
108Specifies the width, height and where to place the following Deep
109data BODy.  If no DLOC is encountered before a DBOD, the
110DisplayWidth & DisplayHeight parameters will be used as the DBOD
111image data dimensions.  The contents of a DLOC chunk remain valid
112until another DLOC chunk is encountered.
113
114
115Chunk ID:       DBOD    (Deep BODy)
116
117Chunk Purpose:
118
119Contains the image data.
120
121Chunk Description:
122
123Contains image data compressed by the method defined in DGBL.
124The image size and the location where it is to be displayed is
125provided by a DLOC chunk.  If no DLOC chunk has been read the
126data will be displayed in the upper left corner and will be
127DisplayWidth wide and DisplayHeight high.
128
129
130Chunk ID:       DCHG    (Deep CHanGe buffer)
131
132Chunk Purpose:
133
134Informs the IFF reader that a complete frame has been read.  Only
135required when multiple images are stored for cell animation.
136
137Chunk Description:
138
139When a DCHG chunk is encounter the IFF reader knows that a
140complete frame has been read.  The chunk gives the time *from the
141last frame change* before the frame should be changed again.  If
142the time has already elapsed the frame should be changed
143immediately.  A FrameRate of 0 will cause the frame changes to
144occur as fast as possible.  A FrameRate of -1 is used to indicate
145the end of the data for one frame and the start of the next in
146cases where multiple frames are stored but are not intended for
147animation.  A DCHG chunk is not required when only a single frame
148is stored.
149
150
151
152//
153//FORM DEEP
154//=========
155//
156//  Chunk DGBL
157//  ----------
158//
159    struct DGBL = {
160//
161// Size of source display
162//
163      UWORD  DisplayWidth,DisplayHeight;
164//
165// Type of compression
166//
167      UWORD  Compression;
168//
169// Pixel aspect, a ration w:h
170//
171      UBYTE  xAspect,yAspect;
172    };
173
174//
175//   Chunk DPEL
176//   ----------
177    struct DPEL = {
178//
179// Number of pixel components
180//
181    ULONG nElements;
182//
183// The TypeDepth structure is repeated nElement times to identify
184// the content of every pixel.  Pixels will always be padded to
185// byte boundaries.  The DBOD chunk will be padded to an even
186// longword boundary.
187//
188    struct TypeDepth = {
189//
190// Type of data
191//
192      UWORD cType;
193//
194// Bit depth of this type
195//
196      UWORD cBitDepth;
197      } typedepth[Nelements];
198    };
199
200//
201//  Chunk DLOC
202//  ----------
203//
204    struct DLOC = {
205//
206// Body width & height in pixels
207//
208      UWORD     w,h
209//
210// Pixel position for this image
211//
212      WORD      x,y
213    };
214
215//
216//  Chunk DBOD
217//  ----------
218//
219    pixel[0], pixel[2], pixel[3], ...., pixel[w-1]
220    pixel[((h-1)*w)], ...,pixel[h*w-1]
221
222//
223//  Chunk DCHG
224//  ----------
225//
226    struct DCHG = {
227//
228// Animation control (When multiple images are stored)
229// FrameRate - milli-seconds between frames changes
230//
231      LONG  FrameRate;
232    };
233
234Compressions currently defined:
235
236NOCOMPRESSION   =       0
237RUNLENGTH       =       1
238HUFFMAN         =       2
239DYNAMICHUFF     =       3
240JPEG            =       4
241
242Ctype currently defined:
243
244RED             =       1
245GREEN           =       2
246BLUE            =       3
247ALPHA           =       4       (no precise definition of use)
248YELLOW          =       5
249CYAN            =       6
250MAGENTA         =       7
251BLACK           =       8
252MASK            =       9
253ZBUFFER         =       10
254OPACITY         =       11
255LINEARKEY       =       12
256BINARYKEY       =       13
257
258----------------------------------------------------------------------
259
260Addendum
261========
262
263The following information is an extension to the DEEP format
264proposed by TecSoft and used in their 24 bit paint application,
265TVPaint.  The extension provides an additional compression method
266and its associated chunk.
267
268Additional compression type:
269
270TVDC            =       5
271
272Chunk ID:       TVDC    (TVPaint Deep Compression)
273
274Chunk Purpose:
275
276Provides the table of values required to enable decompression of
277the image data.
278
279Chunk Description:
280
281TVDC is a modified version of Delta compression, using a 16 word
282lookup table of delta values and also incorporates Run Length
283Limiting compression for short runs.
284
285Note that the compression is made line by line for each element
286of the chunk DPEL.  For RGBA for example we have a Red line, a
287Green line, and so on.
288
289CDepackTVDC(source,dest,table,size)
290UBYTE   *source;
291UBYTE   *dest;
292WORD    *table;
293int     size;
294{
295int     i;
296int     d;
297int     pos=0;
298UBYTE   v=0;
299
300        for(i=0;i<size;i++)
301        {
302                d=source[pos>>1];
303                if(pos++&1) d&=0xf;
304                else d>>=4;
305                v+=table[d];
306                dest[i]=v;
307                if(!table[d])
308                {
309                        d=source[pos>>1];
310                        if(pos++&1) d&=0xf;
311                        else d>>=4;
312                        while(d--) dest[++i]=v;
313                }
314        }
315        return((pos+1)/2);
316}
317