home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-387-Vol-3of3.iso
/
c
/
cinemker.zip
/
SNIPSPEC.DOC
< prev
Wrap
Text File
|
1991-08-21
|
6KB
|
130 lines
ComputerEyes "Snip" File Format
===============================
This document describes the format of the data contained in a
ComputerEyes "Snip" (.SNP) file. A Snip file contains a
moving image, or snip.
The bytes in the file that make up word and longword values
are all stored in low-to-high sequential order.
Unlike other moving image file formats, the Snip format is
optimized for performance, with a slight sacrifice in
flexibility. This allows moving images to be played with good
performance on most computers with VGA graphics capability, not
just high-powered, expensive computers.
All Byte Offsets are relative to the beginning of the file.
There is one 16-byte File Header at the beginning of the file:
Byte Number
Offset of Bytes Name Description
-------------------------------------------------------------
0 2 VER Software Version Number
2 2 NFRM Number of frames in Snip
4 2 HRES Horizontal Resolution
6 2 VRES Vertical Resolution
8 2 Reserved
10 2 DELAY Delay Time between frames
12 2 Reserved
14 2 Reserved
DELAY is a value that represents the approximate time between
frames, expressed in 1/18-second ticks. For example, if DELAY =
9, there is 9/18 or one-half second between frames.
The File Header is followed by the color palette table. The
color palette is organized as 256 3-byte triplets: red, then
green, then blue. The RGB values range from 0 to 63. This
palette contains all 256 colors, although the frame data consists
of palette pointers whose values range only from 64 to 255.
Byte Number
Offset of Bytes Name Description
-------------------------------------------------------------
16 768 PAL Color palette
Following the palette is a table of (NFRM+1) longword offsets to
the beginning of each frame's data. There is one extra offset to
allow Snip file readers to calculate the size of the last frame.
That is, Size(N) = FROFF(N+1) - FROFF(N).
Byte Number
Offset of Bytes Name Description
-------------------------------------------------------------
784 4*(NFRM+1) FROFF Table of longword offsets to the
start of each frame
Finally comes NFRM frames of image data, as described below:
The IMAGE data is encoded in a simple yet effective manner to
achieve reasonably high image compression, while allowing moving
images to be played back without a lot of software overhead
(which would affect performance) or image compression hardware
(which would affect one's budget). The compression scheme is as
follows:
Images are stored starting in the upper left corner, proceeding
left to right for HRES pixels, then top to bottom for VRES lines.
The Snip file reader must maintain a counter that corresponds to
the current pixel location (we'll call it COUNT). If an image
data value is 64 or greater, it is interpreted simply as a
palette pointer and written to the screen at the current pixel
location (COUNT), which is incremented. If an image data value
is less than 64 (but greater than 0), it is interpreted instead
as the number of pixels to skip; specifically, the image data
value is added to COUNT. An image data value of 0 is interpreted
as an end-of-frame flag.
COUNT should be set to 0 at the beginning of a frame. It is
allowed to wrap around at the end of lines, so that COUNT would
proceed from 0 to HRES*VRES as the frame is read. It is up to
the Snip file reader to map COUNT to the physical display address
as the frame is read.
Typically, in a Snip, the first frame is considered all new so
that there would be exactly HRES*VRES bytes in the first frame,
whose values all range from 64 to 255. Then, in subsequent
frames, relatively few pixels require changing from one frame to
the next, requiring perhaps a few hundred bytes per frame.
The following is an example of the data in a typical frame:
Hex Dec Interpretation
--- --- ---------------------------------------
9C 156 Upper left pixel = 156
C2 194 Next pixel to right = 194
04 4 Make no change to next 4 pixels
83 131 Seventh pixel from top left = 131
3F 63 Skip next 63 pixels
3F 63 And another 63 pixels
21 33 And another 33 pixels
F1 241 Next pixel = 241
|
|
|
00 0 Frame done
Note that this compression is NOT done on a line-by-line basis.
Thus, if you were working on the first line with an HRES of 128
pixels, COUNT were 120, and you encountered the following
sequence:
Hex Dec Interpretation
--- --- ---------------------------------------
|
14 20 Skip 20 pixels
A3 163 Next pixel = 163
|
the 163 would be displayed in the 12th pixel from the left on the
second line.
Within a Snip, the frame offset table FROFF can safely be ignored
if the Snip file reader is simply reading frames sequentially and
displaying them. FROFF can be useful for applications that, for
example, play Snips backwards or edit Snips.