Changes

Jump to: navigation, search

APNG Specification

334 bytes removed, 19:04, 21 March 2007
APNG 0.9
APNG 0.8 9 <i>[DRAFT]</i>
Authors:
We are currently waiting on the PNG group to approve our use of our chunks as public chunks (i.e. 2nd letter is capitalized.) Once they have approved the chunk names only the public chunk names will be valid and APNGs created before that point will become invalid.
acTl acTL -> aCTlaCTL, fcTl fcTL -> fCTlfCTL, fdAt fdAT -> fDAtfDAT
= Overview =
The size of the first frame defines the boundaries of the entire animation; hence, if extra space will be needed for later frames that is unused in the first frame, the first frame should be appropriately padded with fully transparent regions.
To be recognized as an APNG, an `acTlacTL` chunk must appear in the stream before any `IDAT` chunks. The `acTlacTL` structure is described in the next section.
An `fcTlfcTL` chunk must also appear before `IDAT`, providing frame information for the first frame encoded in the PNG stream's `IDAT` chunks, known as frame 0. If there is no fCTl chunk before IDAT, then frame 0 is intialized to RGBA(0,0,0,0) and the IDAT chunks are not used.
Subsequent frames are encoded in `fdAtfdAT` chunks containing almost the same structure of content as IDAT chunks. Information for each frame about placement and rendering is stored in `fcTlfcTL` chunks. The full layout of `fdAtfdAT` and `fcTlfcTL` chunks is described below.
Note: For purposes of chunk descriptions, an "unsigned int" shall be a 32-bit unsigned integer in network byte order limited to the range 0 to (2^31)-1; an "unsigned short" shall be a 16-bit unsigned integer in network byte order; a "byte" shall be an 8-bit unsigned integer.
== Chunk Sequence Numbers ==
The `fcTlfcTL` and `fdAtfdAT` chunks have a 4 byte sequence number. Both chunk types share the sequence. The purpose of this number is to detect (and optionally correct) sequence errors in an Animated PNG, since the PNG specification does not impose orderng restrictions on ancillary chunks.
The first fCTl chunk must contain sequence number 0, and the sequence numbers in the remaining fCTl and fDAt chunks must be in order, with no gaps or duplicates.
The table below illustrates the use of sequence numbers for images with more than one frame and more than one `fdAtfdAT` chunk:
Sequence number Chunk
0 `fcTlfcTL` describing frame 0 1 `fcTlfcTL` describing frame 1 2 first `fdAtfdAT` for frame 1 3 second `fdAtfdAT` for frame 1
....
APNG viewers must abandon the APNG chunks in a datastream with out-of-order APNG chunks and display frame 0 instead. APNG-aware PNG editors should restore them to correct order using the sequence numbers.
== `acTlacTL`: The Animation Control Chunk ==
The `acTlacTL` chunk is an ancillary chunk as defined in the PNG Specification. It must appear before the first `IDAT` chunk within a valid PNG stream.
The `acTlacTL` chunk contains:
byte
0 num_frames (unsigned int) Number of frames
4 num_iterations (unsigned int) Number of times to loop this APNG. 0 indicates infinite looping.
8 IHDR_crc (unsigned int) CRC of the IHDR chunk.
12 PLTE_crc (unsigned int) CRC of the PLTE chunk or 0.
`num_frames` indicates the total number of frames in the animation. 0 is not a valid value. 1 is a valid value for a single-frame APNG. In case this number does not match the actual number of frames, behaviour of the implementation is not specified.
`num_iterations` indicates the number of iterations that this animation should play; if it is 0, the animation should play indefinitely. If nonzero, the animation should come to rest on the final non-skipped frame at the end of the last iteration.
== `IHDR_crcfcTL` must contain a copy of the CRC from the IHDR chunk. If the two checksums do not match, any further frames must be discarded.: The Frame Control Chunk ==
The `PLTE_crcfcTL` must contain a copy of the CRC from the PLTE chunk if the color type for is an ancillary chunk as defined in the PNG is 3 (indexed-color), and 0 otherwiseSpecification. If It must appear before the two checksums do not match`IDAT` or `fdAT` chunks of the frame to which it applies, any further frames must be discarded.specifically:
== `fcTl`: The Frame Control Chunk == The `fcTl` chunk is an ancillary chunk as defined in the PNG Specification. It must appear before the `IDAT` or `fdAt` chunks of the frame to which it applies, specifically: * For the first frame, the `fcTlfcTL` chunk must appear before the first `IDAT` chunk. Position relative to the `acTlacTL` chunk is not specified.* For the second frame, the `fcTlfcTL` chunk must appear after the `IDAT` chunks from the first frame and before the fdAt fdAT chunks for the second frame.* For any subsequent frames, the `fcTlfcTL` chunk for the frame N must appear after the `fdAtfdAT` chunks from the frame N-1 and before the fdAt fdAT chunks for the frame N.
* Other ancillary chunks are allowed to appear among the APNG chunks, including between fDAt chunks. Decoders must ignore such chunks.
24 render_op (byte) Type of output buffer area disposal to be done after rendering this frame
The frame must be rendered within the region defined by the `width`, `height`, `x_offset` and `y_offset` from the `fcTlfcTL`, and the width and height from the `IHDR` chunk.
The width and height must be greater than zero and must not be bigger than (respectively) the width and height specified in the IHDR chunk.
APNG_RENDER_OP_BLEND_FLAG must be 0 for frame 0.
== `fdAtfdAT`: The Frame Data Chunk ==
The `fdAtfdAT` chunk has the same purpose as an `IDAT` chunk. It has the same data structure as an `IDAT` chunk, except a sequence number is appended in the beginning.
Each frame must contain at least one fDAt chunk. The compressed datastream is then the concatenation of the contents of the data fields of all the fDAt chunks within a frame. When decompressed, the datastream is a complete PNG image, including the filter byte at the beginning of each scanline. It utilizes the same bit depth, color type, compression method, filter method, interlace method, and palette (if any) as the main image.
* IDAT, fcTl and fdAt are no longer required to have no other chunks in between them
 
== From 0.8 ==
 
* Removed CRCs for IHDR and PLTE from acTl
 
* The acTL fcTL and adAT are now not copy safe, renamed them to acTL, fcTL and adAT
= Test Encoder and Sample Images =
569
edits

Navigation menu