Pack Types 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, and 0x8e (Performers, Songwriters, Composers,
Arrangers, and Message Area respectively) have to be attributed to
each track if they are present for the whole disc.

Pack Type 0x8f (Block Size Information) describes the overall content of a block and in part of all other blocks.

The total size of a block’s attribute set is restricted by the fact
that it has to be stored in at most 253 records with 12 bytes of
payload. These records are called Text Packs described in the
next section. Since information such as the Disc and Genre
Identification is often the same across mutiple tracks, a compact way
to repeat identical information is provided.

1.2 Pack Contents

Packs are stored in CD in the sub-channel of the Lead-in of the
disc. The file ‘doc/cookbook.txt’ of the
libburnia distribution describes
how to write the CD Text pack array to CD, and how to read CD Text
packs from CD. If you are just interested in a more high-level access
CD Text information without having to understand the internal
structure, you can use libcdio’s CD Text API for getting and setting
fields.

The format is explained in part in Annex J of (MMC-3), and in part by Sony’s documentation
cdtext.zip.

Each pack consists of a 4-byte header, 12 bytes of payload, and 2 bytes
of CRC.

The first byte of each pack contains the pack type. See
table:categories for a list of pack types.

The second byte often gives the track number of the pack. However, a
zero track value indicates that the information pertains to the whole
album. Higher numbers are valid for track-oriented packs (types
0x80 to 0x85, and 0x8e). In these pack types, there
should be one text pack for the disc and one for each track. With TOC
packs (types 0x88 and 0x89), the second byte is a track
number too. With type 0x8f, the second byte counts the record
parts from 0 to 2.

The third byte is a sequential counter.

The fourth byte is the Block Number and Character Position Indicator.
It consists of three bit fields:

bits 0-3

Character position. Either the number of characters which the current
text inherited from the previous pack, or 15 if the current
text started before the previous pack.

bits 4-6

Block Number (groups text packs in language blocks)

bit 7

Is 0 if single byte characters, 1 if double-byte characters.

The 12 payload bytes contain pieces of zero terminated data. When
double-byte text is used the zero is a double byte, otherwise it is a
single ASCII NUL.

A text may span over several packs. Unused characters in
a pack are used for the next text of the same pack type. If no text of
the same type follows, then the remaining text bytes are set to 0.

The CRC algorithm uses divisor 0x11021. The resulting 16-bit
residue of the polynomial division is inverted (xor-ed with
0xffff) and written as Big-endian number in bytes 16 and 17 of
the pack.

The text packs are grouped in up to 8 blocks of at most 256 packs. Each
block pertains to one language. Sequence numbers of each block are
counted separately. All packs of block 0 come before the packs of block
1.

The limitation of block number and sequence numbers imply that there are
at most 2048 text packs possible.

If a text of a track (pack types 0x80 to 0x85 and
0x8e) repeats identically for the next track, then it may be
represented by a TAB character (ASCII 9) for single byte texts, and
two TAB characters for double byte texts. This is desirable because
there is a somewhat limited amount of space for CD Text — 256 * 12
bytes which may have to accomodate up to 99 tracks.

The two binary bytes of pack type 0x87 are written to the first
0x87 pack of a block. They may or may not be repeated at the start
of the follow-up packs of type 0x87.

1.3 Text Packs (0x80–0x85, 0x8e)

Pack types 0x80 to 0x85 and 0x8e (Title, Performers,
Songwriters, Arrangers, Message Area and UPC/EAN code respectively)
contain a NUL-termintated string. If double-byte characters are used,
then two zero bytes terminate the text. Of these, all except the last,
0x8e or UPC/EAN code, are encoded according to their block’s
Character Code. This could be either as ISO-8859-1 single byte
characters, as 7-bit ASCII single byte characters, or as MS-JIS double
byte characters.

Pack type 0x8e is documented by Sony as:

UPC/EAN Code (POS Code) of the
album. This field typically consists of 13 characters.

1.5 TOC Pack Types (0x88, 0x89)

This information duplicates information stored elsewhere and that can
be obtained by an MMC READ TOC/PMA/ATP command.

The first pack of type 0x88 (Table of Contents) records in its
payload bytes as follows:

0 : PMIN of POINT A1 = First Track Number
1 : PMIN of POINT A2 = Last Track Number
2 : unknown, 0 in Sony example
3 : PMIN of POINT A2 = Start position of Lead-Out
4 : PSEC of POINT A2 = Start position of Lead-Out
5 : PFRAME of POINT A2 = Start position of Lead-Out
6 to 11 : unknown, 0 in Sony example

The following packs record PMIN, PSEC, PFRAME of the
POINTs between the lowest track number (1 or 01h) and the highest
track number (99 or 63h). The payload of the last pack is padded
by zeros.

The track numbers are stored in the track number byte of the packs. The
two time points are stored in byte 6 to 11 of the payload. Byte 0 of the
payload seems to be a sequential counter. Byte 1 always 4? Byte 2 to 5
always 0?

1.6 Block Size Information Type (0x8f)

Pack type 0x8f summarizes the whole list of text packs of a
block. So there is one group of three 0x8f packs per block.
Nevertheless each 0x8f group indicates the highest sequence
number and the language code of all blocks.

The payload bytes of three 0x8f packs form a 36-byte record.
The track number bytes of the three packs have the values 0, 1, 2.

2.1 Sony Text File Format (Input Sheet Version 0.7T)

This text file format provides comprehensive means to define the text
attributes of session and tracks for a single block. More than one
such file has to be read to form an attribute set with multiple blocks.

The information is given by text lines of the following form:
purpose specifier [whitespace] = [whitespace] content text
[whitespace] is zero or more ASCII 32 (space) or ASCII 9 (tab) characters.
The purpose specifier tells the meaning of the content text.
Empty content text does not cause a CD Text attribute to be attached.