libkate: Format - data packet type 0x00 - text

# Format - data packet type 0x00 - text

Text packets are the main payload packet.

- a 64 bit value representing the start of the event, at the granule rate.
- a 64 bit value representing the duration of the event, at the granule rate.
- a 64 bit value representing the start of the earliest event still active when this event starts, at the granule rate.
- a 32 bit value representing the number of bytes in the text to follow.
- that same number of bytes representing the text.
- 1 bit being 1 if the event is assigned an ID, 0 if not.
- if the event is assigned an ID, a variable length integer representing the ID assigned to this event.
- 1 bit being 1 if there are motions attached to this event.

Next, if there are motions attached to this event:

- a variable length integer representing the number of motions attached to this event.

For each motion:

- a bit being 1 if the next motion is predefined, 0 if not
- if the next motion is predefined, a variable length integer representing the index of this motion in the list of predefined motions
- if the next motion is not predefined, a motion definition.

Next, a bit being 1 if there are overrides for this event. If there are:

- if the next bit is set, 8 bits for the text encoding used by the text in this packet.
- if the next bit is set, 8 bits for the text directionality used by the text in this packet.
- if the next bit is set, a ref format_32v "variable length integer" representing the number of characters in the following language string, followed by this number of bytes for a (non NUL terminated) string representing the language used by the text in this event.
- if the next bit is set, a variable length integer representing the index of a predefined region to use for this event.
- if the next bit is set, a region definition to use for this event.
- if the next bit is set, a variable length integer representing the index of a predefined style to use for this event.
- if the next bit is set, a style definition to use for this event.
- if the next bit is set, a variable length integer representing the index of a predefined style to use as secondary style for this event.
- if the next bit is set, a style definition to use as secondary style for this event.
- if the next bit is set, a variable length integer representing the index of the font mapping to use for the text in this event.

Next, there is a warp.

Bitstream version 0.2 starts making use of this warp:

- if the next bit is set, a variable length integer representing the index of the palette to use for the bitmap in this event.
- if the next bit is set, a palette definition to use for the bitmap in this event.
- if the next bit is set, a variable length integer representing the index of the bitmap to use for this event.
- if the next bit is set, a bitmap definition to use for this event.
- if the next bit is set, 8 bits representing the type of markup to use to interpret the text in this event.

Bitstream version 0.4 makes further use of this warp:

- a variable length integer representing the number of bitmaps associated with this event. For this many bitmaps:
- a bit being 1 is the bitmap is a reference to one already present in the stream headers
- if the bitmap is already present in the stream headers, a variable length integer representing its index in the stream headers.
- if the bitmap is not already present in the stream headers, a bitmap definition.

Bitstream 0.6 makes further use of this warp to add:

- a metadata set.

Note:
  Since a warp may contain any number of chained warps, it is important to note that the bistream will contain another warp after any non empty warps. This means that a warp is a chain of single warps, where the last warp (and only the last one) is empty.

Next, the data ends.