Changes

Jump to: navigation, search

APNG Specification

728 bytes added, 09:54, 6 March 2007
no edit summary
APNG 0.6 7 <i>[DRAFT]</i>
Authors:
* Stuart Parmenter <pavlov@pavlov.net>
* Vladimir Vukicevic <vladimir@pobox.com>
* Andrew Smith <asmith15@learn.senecac.on.ca>
= Overview =
= Structure =
An APNG stream is a normal PNG stream as defined in the [PNG Specification][pngspec], with four three additional chunks chunk types describing the animation and providing additional frame data. The first frame of an animation, frame 0, is encoded as a normal PNG. This frame is what decoders that do not understand the APNG chunks will display.
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.
An `fcTl` 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.
Subsequent frames are encoded in `fdAt` chunks, containing information almost the same structure of content as IDAT chunks. Information for each frame about placement and rendering of a frame is stored in `fcTl` chunks, as well as frame data encoded as normal PNG streams. The full layout of the `fdAt` chunk and `fcTl` chunks is described in section 2.3below.
Note: For purposes of chunk descriptions, an "unsigned int" shall be a 32-bit unsigned integer in network byte order; a "signed int" shall be a 32-bit signed integer in network byte order; an "unsigned short" shall be a 16-bit unsigned integer in network byte order; a "byte" shall be a 8-bit unsigned integer.
 
== Chuck Sequence Numbers ==
 
The `fcTl` and `fdAt` 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 table below illustrates the use of sequence numbers for images with more than one frame and more than one `fdAt` chunk:
 
Sequence number Chunk
0 `fcTl` describing frame 0
1 `fcTl` describing frame 1
2 first `fdAt` for frame 1
3 second `fdAt` for frame 1
....
== `acTl`: The Animation Control Chunk ==
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, that is the first frame plus the number of fdAt chunks. 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.
== `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 `fcTl` chunk must appear before the first `IDAT` chunk. Position relative to the `acTl` chunk is not specified.
* For the second frame, the `fcTl` chunk must appear immediately after the `IDAT` chunks from the first frame and immediately before the fdAt chunks for the second frame.* For any subsequent frames, the `fcTl` chunk for the frame N must be first in the data part of appear immediately after the `fdAt` chunkchunks from the frame N-1 and immediately before the fdAt chunks for the frame N.
The `fcTl` chunk is mandatory for every frame. More than one `fcTl` chunk per frame is not allowed.
byte
0 sequence_number (unsigned int) Sequence number of the frameanimation chunk, starting from 0 4 width (unsigned int) Width of the following frame 8 height (unsigned int) Height of the following frame 12 x_offset (unsigned int) X position at which to render this the following frame 8 16 y_offset (unsigned int) Y position at which to render this the following frame 12 20 delay_num (unsigned short) Frame delay fraction numerator 14 22 delay_den (unsigned short) Frame delay fraction denominator 16 24 render_op (byte) Type of canvas area disposal to be done after rendering this frame
The frame must be rendered within the region defined by the `sequence_numberwidth` shall begin with 0 for , `height`, `x_offset` and `y_offset` from the first `fdAtfcTl` in , and the PNG stream, width and increase by one with each subsequent frameheight from the `IHDR`.
The frame must width and height cannot be rendered within bigger than (respectively) the region defined by width and height specified in the `x_offsetIHDR` and `y_offset` from chunk. For frame 0 the `fcTl`, width and height fields must equal the width and height from this frame's the `IHDR`chunk. For Also for frame 0, the `x_offset` and `y_offset` fields must be 0. Should partsof the region fall outside the canvas defined by frame 0, rendering is to may be clipped to that canvasor the condition may be treated as an error.
The `delay_num` and `delay_den` parameters together specify a fraction indicating the delay after the current frame, in seconds. If the denominator is 0, it is to be treated as if it were 100 (that is, delay_num then specifies 1/100ths of a second). If the the value of the numerator is 0 the decoder should render the next frame as quickly as possible, though viewers may impose a reasonable lower bound on the delay.
== `fdAt`: The Frame Data Chunk ==
The `fdAt` chunk contains one frame for has the animation. Any `fdAt` chunks must follow any same purpose as an `IDAT` chunkschunk. All It has the same data structure as an `fdAtIDAT` chunks must be adjacent chunk, except a sequence number is appended in the PNG streambeginning. Should a decoder receive an APNG stream with missing or out of order  There may be multiple `fdAt` chunksfor any one frame; if so, it they shall appear consecutively with no other intervening chunks. The compressed datastream is under no obligation to attempt to reorder then the concatenation of the contents of the data fields of all the `fdAt` chunks and may treat that case as an error condition.
Format:
byte
0 `fcTl` chunk 29 bytes `fcTl` sequence_number (unsigned int) Sequence number of the animation chunk for this frame, starting from 0 29 `IDAT` chunks 4 frame_data X bytes Frame data for this frame 29+X `feND` chunk 12 bytes `feND` chunk to mark the end of the frame data Each of the chunks contained in the data section of the `fdAt` must follow all the rules in section 5 of the PNG specification, except 5.6 Chunk Ordering. The order of chunks within the `fdAt` is fixed. The frame data within the `fdAt` consists of a series of `IDAT` chunks, following the rules from section 11.2.4 of the PNG Specification. The `feND` is an ancillary, zero-length data field chunk, used to mark the end of the frame data. The `feND` chunk is a mandatory last chunk in the data part of the `fdAt` chunk. Only one `feND` per `fdAt` is allowed. Each frame inherits every property specified by any critical or ancillary chunks before the first IDAT in the file.
Note: both the container chunk (`fdAt`) and Each frame inherits every chunk within (`fcTl`, `IDAT`s, `feND`) must specify property except the length of its own data field width and the CRC over its own chunk name + chunk data as required height specified by section 5.3 of any critical or ancillary chunks before the first IDAT in the PNG Specificationfile.
= Revisions to this Specification ==
== From 0.1 ==
* The acTL fcTL and adAT are now copy safe, renamed them to acTl, fcTl and adAt
 
== From .6 ==
 
* The fdAt chunk is no longer a container for other chunks, but rather a replacement for an IDAT chunk
 
* Added a sequence number field to fdAt
 
* Reintroduced the width and height fields in fcTl
= Test Encoder and Sample Images =
48
edits

Navigation menu