=head1 SVCD Subtitle Information - Philips Overlay Graphics Text (OGT)

The following information is culled from information from Julio
Sánchez Fernández (L<http://subhandler.sourceforge.net>) by Rocky
Bernstein.

If you have any corrections or additions to make, please send them
to rocky@panix.com.

SVCD subtitles (Philips Overlay Graphics Text or OGT) are transported
nin an MPEG private stream with stream id 0x70. AC3 subtitle stream
numbers start at 0,x80 and go to 0,x87.

All numbers are in big-endian and the image is interlaced with a
resolution of 720x480 for NTSC streams or 720x576 for PAL streams.

Data packets start with a 4-byte header:

=over 4

=item * Stream number (1 byte). 

Only bits 0-3 are used as there can only be up to 8 subtitles.

=item * Packet number (1 byte). 

The first packet starts at 0; the last packet of a subtitle has the
7th bit set. A subtitle can be broken up into several packets when it
is multiplexed into the MPEG stream.

=item * Subtitle image number (2 bytes).

=item * Length 

Length of the rest of the packet (described in the next section).

=back

=head2 Format of a Subtitle Header

The information below comes immediately after the packet header in the
same packet.

=over 

=item Packet length (2 bytes) 

The assembled subtitle, with stripped sequence numbers.

=item Option (1 byte) 

normally set to 0x2e, bit 3 indicates that a field with the
display-time of the subtitle is present.  What the other bits means is
not known.

=item Duration of subtitle display (4 bytes) 

Units are in 1/90000'ths of a second.  This is only present if bit 3
above is set. This only implies i<how long> the subtitle will be
shown, not when. That is given by the PTS in the PES header.

=item X position (2 bytes)

=item Y position (2 bytes)

=item Width (2 bytes)

This should should be an even number.

=item Height (2 bytes)

This should should be an even number.  

=item Unknown (1 byte) 

=item 4 Palette Entries (4 x 4 = 16 bytes)

These are formated as Y, U, V, and T (transparancy) each a single
byte. T=0 is fully transparent, and 255 is fully opaque.

=item Command (1 byte) 

if cmd>>6 == 1 then we have a shift command and (cmd>>4)&3 is the
direction: 0=top, 1=left, 2 = right, 3 = bottom.

=item Odd-field data offset (2 bytes)

Image data is stored interlaced with the even lines first. This offset
specifies where the first odd-line image data starts. 

=item image data 

Subtitle image data follows the above control information. Image lines
are interlaced. That is line 0 is comes first, then line 2, then line
4. After all of the even lines, comes line 1, then line 3, etc.. I<The
subtitle aspect ratio is not to be scaled. It is independent of the
aspect ratio of the underlying image which it is to be overlayed on
top of.>

The image is encoded using two bits per pixel that select a palette
entry except that value 0 starts a limited run-length encoding for
color 0. When 0 is seen, the next two bits encode one less than the
number of pixels, so we can encode run lengths from 1 to 4. These get
filled with the color in palette entry 0.

The encoding of each line is padded to a whole number of bytes. The
first field is padded to an even byte length and the complete subtitle
is padded to a 4-byte multiple that always include one zero byte at
the end.  Image data is formatted like this: 2 bit codes are used so
01 means 1 pixel of color 1, 10 means color 2 etc.

=back

=head2 Format of a Subtitle Header

Philips SVCD tools can create SVCD subtitles, but it only works under
NT4. It is not that easy to find anymore. (dvd.da.ru, doom9.net or
similar perhaps?). It can create good subtitled SVCDs. Subtitles are
created in a text editor. Another tool is called submux. Last version
I tried doesn't do renumber presentation time stamps properly, but
many media players (now) can tolerate this.

The subtitles you get from tools like "I-author" are not SVCD
subtitles, they are CVD
subtitles. L<http://www.vcdimager.org/pub/vcdimager/manuals/0.7/cvd-subtitles.html>
for information on CVD subtitles.  They look similar to DVD subtitles,
but the run-length encoding (RLE) and command format are different.

I<$Id: svcd-ogt-subtitles.pod,v 1.4 2006/02/07 02:57:35 rocky Exp $>

