]> git.sesse.net Git - vlc/blob - doc/subtitles/cvd-subtitles.txt
Add OGT and CVD subtitle demuxers.
[vlc] / doc / subtitles / cvd-subtitles.txt
1 $Id: cvd-subtitles.txt,v 1.2 2004/01/04 16:51:59 rocky Exp $
2 The following information is culled from information from 
3 Julio Sanchez Fernandez (http://subhandler.sourceforge.net)
4 by Rocky Bernstein. 
5
6 We do not have information on the subtitle format used on CVD's except
7 the submux sample code and a couple of samples of dubious
8 origin. Thus, the information below is result of reading some code
9 whose correctness is not known and some experimentation.
10
11 CVD subtitles are different in several ways from SVCD OGT subtitles
12 (see see corresponding info on that.)
13
14 Image comes first and meta data is at the end.  So that the metadata
15 can be found easily, the subtitle packet starts with two bytes
16 (everything is big-endian again) that gives the total size of the
17 subtitle data and the offset to the metadata - i.e. size of the image
18 data plus the four bytes at the beginning.
19
20 Data for single screen subtitle may come in several non-contiguous
21 packets of a stream. From the scant data on the format, the only way
22 known to detect the first packet in a subtitle.  The first packet
23 seems to have a valid PTS while later packets for the same image
24 don't.
25
26 Image data comes interlaced and is run-length encoded (RLE). Each
27 field is a four-bit nibbles that is further subdivided in a two-bit
28 repeat count and a two-bit color number - up to three pixels can be
29 described in four bits.  What a 0 repeat count means is unknown.  It
30 might be used for RLE extension.  There is a special case of a 0
31 repeat count though.  When the full nibble is zero, the rest of the
32 line is filled with the color value in the next nibble.  It is unknown
33 what happens if the color value is greater than three.  The rest seems
34 to use a 4-entries palette.  It is not impossible that the fill-line
35 complete case above is not as described and the zero repeat count
36 means fill line.  The sample code never produces this, so it may be
37 untested.
38
39 Here is information given at the start of a subtitle:
40
41 SPU size        2 bytes
42 metadata offset 2 bytes
43
44 Although metadata information does not have to come in a fixed field
45 order, every metadata field consists of a tag byte followed by
46 parameters. In all cases known, the size including the tag byte is
47 exactly four bytes.
48
49 code    Meaning 
50 ----    -------
51 0x0c    Unknown
52
53 0x04    24-bit subtitle duration in 1/90000ths of a second
54
55 0x17    upper left x, y position, each a 10-bit value, encoded:
56            x = ((p[1]&0x0f)<<6) + (p[2]>>2)
57            y = ((p[2]&0x03)<<8) + p[3];
58
59 0x1f    lower right x, y position, each a 10-bit (0-1023) value,
60         encoded as above 
61
62 0x24    3 bytes primary palette 0 - 1 byte for each of y, u, and v 
63 0x25    3 bytes primary palette 1 - 1 byte for each of y, u, and v
64 0x26    3 bytes primary palette 2 - 1 byte for each of y, u, and v
65 0x27    3 bytes primary palette 3 - 1 byte for each of y, u, and v
66
67 0x2c    3 bytes highlight palette 0 - 1 byte for each of y, u, and v 
68 0x2d    3 bytes highlight palette 1 - 1 byte for each of y, u, and v
69 0x2e    3 bytes highlight palette 2 - 1 byte for each of y, u, and v
70 0x2f    3 bytes highlight palette 3 - 1 byte for each of y, u, and v
71
72 0x37    3 bytes transparency for primary palette - 1 byte for each 
73         of y, u  and v
74
75 0x3f    3 bytes transparency for highlight palette - 1 byte for each 
76         of y, u  and v
77
78 0x47    Offset to start of even rows of interlaced image.
79 0x4f    Offset to start of odd rows of interlaced image.
80
81
82
83
84
85
86
87
88