]> git.sesse.net Git - vlc/blob - doc/subtitles/svcd-ogt-subtitles.txt
Merge branch 'master' into lpcm_encoder
[vlc] / doc / subtitles / svcd-ogt-subtitles.txt
1 $Id$
2
3 The following information is culled from information from Julio
4 Sanchez Fernandez [1] by Rocky Bernstein.
5
6 SVCD subtitles (Philips Overlay Graphics Text or OGT) are transported
7 in an MPEG private stream with stream id 0x70. AC3 subtitle stream
8 numbers start at 0,x80 and go to 0,x87. (CVD subtitle stream numbers
9 start at stream ID 0 and go to 3.)
10
11 All numbers are in big-endian and the image is interlaced with a
12 resolution of 720x480 for NTSC streams or 720x576 for PAL streams.
13
14 Data packets start with a 4-byte header:
15
16     * Stream number (1 byte). Only bits 0-3 are used as there can only
17       be up to 8 subtitles.
18
19     * Packet number(1 byte). The first packet starts at 0; the last
20       packet of a subtitle has the 7th bit set. A subtitle can be
21       broken up into several packets when it is multiplexed into the
22       MPEG stream.
23
24     * Subtitle image number (2 bytes).
25
26     * Length of the rest of the packet (described in the next section). 
27
28 ================
29 SUBTITLE PACKETS
30 ================
31
32 The information below comes immediately after the packet header in the
33 same packet.
34
35 * Packet length (2 bytes) 
36
37 The assembled subtitle, with stripped sequence numbers
38
39 * Option byte (1 byte) 
40
41 This is normally set to 0x2e; bit 3 indicates that a field with the
42 display-time of the subtitle is present. What the other bits do is not
43 known.
44
45 * Time to display the subtitle (4 bytes) 
46
47 This in 1/90000'th of a second. This is only present if bit 3 above is
48 set. This value specifies how long the subtitle will be shown, not
49 when. When the subtitle is to be shown is specified in the PTS in the
50 PES header.
51
52 * X position (2 bytes) 
53
54 * Y position (2 bytes) 
55
56 * Width (2 bytes)
57
58 This value must be even.
59
60 * Height (2 bytes)
61
62 This value must be even.
63
64 * Unknown (1 byte) 
65
66 * 4 Color Palette Entries (16 bytes)
67
68 * A pallette entry has the following format:
69
70     * Y (1 byte)
71     * U (1 byte)
72     * V (1 byte)
73     * Transparency (1 byte). A 0 value means totally transparent and
74       255 totally opaque.
75
76 * Command (1 byte) 
77
78 if cmd>>6 == 1 then a shift command and (cmd>>4)&3 is the
79 direction. 0=top, 1=left, 2 = right, 3 = bottom
80
81 * Odd-field data offset (2 bytes) 
82
83 Image data is stored interlaced with the even lines first. This offset
84 specifies where the first odd-line image data starts.
85
86 IMAGE DATA
87
88 Then subtitle image data follows the above control information. Image
89 lines are interlaced. That is line 0 is comes first, then line 2, then
90 line 4. After all of the even lines, comes line 1, then line 3,
91 etc.. The subtitle aspect ratio is not to be scaled. It is independent
92 of the aspect ratio of the underlying image which it is to be
93 overlayed on top of.
94
95 The image is encoded using two bits per pixel that select a palette
96 entry except that value 0 starts a limited run-length encoding for
97 color 0. When 0 is seen, the next two bits encode one less than
98 the number of pixels, so we can encode run lengths from 1 to 4. These
99 get filled with the color in palette entry 0.
100
101 The encoding of each line is padded to a whole number of bytes. The
102 first field is padded to an even byte length and the complete subtitle
103 is padded to a 4-byte multiple that always include one zero byte at
104 the end.
105
106 ================
107 SUBTITLING TOOLS
108 ================
109
110 Philips SVCD tools can create SVCD subtitles, but it only works under
111 NT4. It is not that easy to find anymore. (dvd.da.ru, doom9.net or
112 similar perhaps?). It can create good subtitled SVCDs. Subtitles are
113 created in a text editor. Another tool is called submux. Last version
114 I tried doesn't do renumber presentation time stamps properly, but
115 many media players (now) can tolerate this.
116
117 The subtitles you get from tools like "I-author" are not SVCD
118 subtitles, they are CVD subtitles. They look similar to DVD subtitles,
119 but the run-length encoding (RLE) and command format are different.