Header packets must appear in order. Decoding of a data packet is not possible until all header packets have been decoded.
Each Kate packet starts with a one byte type. A type with the MSB set (eg, between 0x80 and 0xff) indicates a header packet, while a type with the MSB cleared (eg, between 0x00 and 0x7f) indicates a data packet. All header packets then have the Kate magic, from byte offset 1 to byte offset 7 ("kate\0\0\0").
Since the ID header must appear first, a Kate stream can be recognized by comparing the first eight bytes of the first packet with the signature string "\200kate\0\0\0".
All subsequent header packets must be on one or more pages. Each data packet must be on a separate page.
The last data packet must be the end of stream packet (packet type 0x7f). The corresponding Ogg packet must be marked as end of stream (EOS). There can be only one end of stream packet in a Kate stream. No other packet may be marked as EOS.
As per the Ogg specification, granule positions must be non decreasing within the stream. Header packets have granule position 0.
Header packets:
Data packets:
The remainder of the format will be documented later.