File: mng-play-reco-proposal-20070907 It is proposed to register playlist and record MNG chunks: PLAY and ReC0. In this proposal, the new chunk names are shown in private form (second letter lowercase, PlAY). Until the proposal is approved, the private form must be used in any test implementations. It is proposed to document the PLAY and ReCO chunks in the MNG 1.0 Specification, Version 1.0.1, as follows: A. Change document version to 1.0.1. B. Add glossary entry, simplicity bit, and paragraphs 4.3.6, 4.3.7, and 10.8 Glossary: A "tile" is a pixel array copied from an object and used to construct a layer. Simplicity profile in MHDR chunk: Add bit 10: 0: PLAY and RECO chunks are not present. 1: PLAY or RECO chunks may be present. 4.3.6 PLAY Playlist The PLAY chunk contains a compressed "play list" that provides instructions to the decoder for constructing animation layers from pieces of previously defined objects. The PLAY chunk contains a 1-byte header followed by one or more 32-byte layer structures. The header gives the compression method: byte 0 compression_method (byte) 0: deflate 1 layer_structure_array[n] (n > 0; n * 32 bytes): layer (compressed) structures Each layer is a tile combined with a transparent background to form a layer of size (frame_width, frame_height), from the MHDR chunk. Each layer is initialized to a transparent (RGBA(0,0,0,0)) rectangle, regardless of the contents of the BACK chunk. The layer structure array is always compressed according to the specified compression method. A layer is described by a structure of 32 bytes: byte 0 object (unsigned int) Object ID of source image 2 delta mode (unsigned byte) 0: dimensions and offsets are absolute 1: dimensions and offsets are deltas from the stored values from the same or a preceding PLAY chunk 3 update mode (unsigned byte) 0: Do not update stored values of dimensions and offsets 1: Update stored values 4 x (unsigned int) Left of tile pixels 8 y (unsigned int) Top of tile pixels 12 width (unsigned int) Width of tile pixels 16 height (unsigned int) Height of tile pixels 20 x_offset (signed int) X offset of tile destination 24 y_offset (signed int) Y offset of tile destination 28 delay (unsigned int) interframe delay The layer data identifies a rectangle (x,y,width,height) in the object containing pixels of a tile. X and y are measured from the upper left corner of the object from which the tile is extracted. The location and clipping boundaries from the DEFI chunk for the object are ignored. This tile is composited on the layer with its upper left corner at position (x_offset, y_offset), measured from the upper left corner of the layer. Any part of the tile outside the object must be treated as transparent. Any part of the tile which extends outside the layer must be ignored. The tile width or height may be zero, in which case the layer contains all transparent pixels. The stored values of x, y, x_offset, and y_offset are intialized to zero, the width to frame_width, and the height to frame_height from the MHDR chunk. These are used as the basis for computing current values to be used when delta_mode is 1, and the results, whether from a delta calculation or from supplied absolute values, are used to update the stored values when update_mode is 1. The delay is measured in ticks_per_second from the MHDR chunk, and it overrides but does not replace the value from the FRAM chunk. Even if a layer's tile is entirely outside the layer, the delay for the resulting empty layer must be handled in the same way as if it were inside the frame. The decoder must handle the layers as specified in the FRAM chunk. This might or might not involve inserting background layers between them or coalescing zero-delay layers together into one frame, and the usual clipping to layer and frame boundaries must be done. 4.3.7 ReCO Record current frame The ReCO chunk is useful for accomplishing the equivalent of the GIF "restore-to-previous" disposal method. It has two fields: object_id (16-bit unsigned int): existing object to be used for storing image of frame mode (byte) 0: initialize object to transparent and start recording offscreen copy of current frame (including any background layers). 1: stop recording. 2: restart recording with existing contents. The object_id must already have been the subject of a DEFI chunk and must still exist. The dimensions and location of the area to be recorded are specified in the DEFI chunk. Each layer that is defined while the ReCO chunk is in recording mode is composited over (or replacing, depending on the framing_mode) whatever is in the object. 10.8 PlAY recommendations for encoders Tall vs wide layouts Typically the best compression is obtained when a PNG image is very wide and not very tall, with similar tiles adjacent. C. Add to the Appendix: Revision History * 30 Sept 2007 (version 1.0.1): * Added the PlAY and ReCO animation chunks.