1 /*
2     Common definitions needed across both authoring and unauthoring tools.
3 */
4 /*
5    Copyright (C) 2010 Lawrence D'Oliveiro <ldo@geek-central.gen.nz>.
6 
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or (at
10    your option) any later version.
11 
12    This program is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20    MA 02110-1301 USA.
21  */
22 
23 #ifndef __DVDAUTHOR_COMMON_H_
24 #define __DVDAUTHOR_COMMON_H_
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 enum
31   {
32   /* MPEG header ID codes relevant to DVD-Video. Each packet begins with
33     a 4-byte code 00 00 01 nn where nn is one of the following */
34 
35   /* start codes */
36     MPID_PICTURE = 0x00, /* picture header */
37     MPID_SEQUENCE = 0xb3, /* sequence header */
38     MPID_EXTENSION = 0xb5, /* extension header */
39     MPID_SEQUENCE_END = 0xb7, /* sequence end */
40     MPID_GOP = 0xb8, /* Group Of Pictures */
41     MPID_PROGRAM_END = 0xb9, /* program end (terminates a program stream) */
42 
43   /* special headers */
44     MPID_PACK = 0xba,
45       /* PACK header, contains a more precise clock reference, and indication of overall
46         bandwidth requirements. DVD-Video requires each PACK to be 2048 bytes in size. */
47     MPID_SYSTEM = 0xbb,
48       /* system header, specifies how many audio and video streams there are, the
49         bandwidth they need, and whether they are synchronized to the system clock. */
50 
51   /* stream ID codes: the two bytes after the first four are the length of the remaining data */
52     MPID_PRIVATE1 = 0xbd,
53       /* private stream 1, used in DVD-Video for subpictures and additional non-MPEG audio
54         formats. The first byte after the packet header+extensions is the substream ID,
55         the bits of which are divided up as follows: fffssnnn, where fff is 001 for
56         a subpicture stream (with ssnnn giving the stream number, allowing up to 32 subpicture
57         streams), or 100 for an audio stream, in which case ss specifies the audio format:
58         00 => AC3, 01 => DTS, 10 => PCM, and nnn is the stream number, allowing up to 8
59         audio streams. */
60     MPID_PAD = 0xbe, /* padding stream */
61     MPID_PRIVATE2 = 0xbf,
62       /* private stream 2, used in DVD-Video for PCI and DSI packets; the byte after the
63         length is 0 for a PCI packet, 1 for a DSI packet. */
64     MPID_AUDIO_FIRST = 0xc0,
65       /* MPEG audio streams have IDs in range [MPID_AUDIO_FIRST .. MPID_AUDIO_LAST], but note
66         DVD-Video only allows 8 audio streams. */
67     MPID_AUDIO_LAST = 0xdf,
68     MPID_VIDEO_FIRST = 0xe0,
69       /* video streams have IDs in range [MPID_VIDEO_FIRST .. MPID_VIDEO_LAST], but note
70         DVD-Video only allows one video stream. dvdauthor assumes its ID will be
71         MPID_VIDEO_FIRST. */
72     MPID_VIDEO_LAST = 0xef,
73   };
74 
75 enum
76   { /* subpicture operation codes */
77     SPU_FSTA_DSP = 0, /* forced start display, no arguments */
78     SPU_STA_DSP = 1, /* start display, no arguments */
79     SPU_STP_DSP = 2, /* stop display, no arguments */
80     SPU_SET_COLOR = 3, /* four nibble indexes into CLUT for current PGC = 2 bytes of args */
81     SPU_SET_CONTR = 4, /* four nibble contrast/alpha values = 2 bytes of args */
82     SPU_SET_DAREA = 5, /* set display area, start X/Y, end X/Y = 6 bytes of args */
83     SPU_SET_DSPXA = 6,
84       /* define pixel data addresses, 2-byte offset to top field data, 2-byte offset to
85         bottom field data = 4 bytes of args */
86     SPU_CHG_COLCON = 7,
87       /* change colour/contrast, 2 bytes param area size (incl itself) + variable nr
88         bytes params: one or more LN_CTLI, each immediately followed by 1 to 8 PX_CTLI.
89         Each LN_CTLI is 4 bytes, consisting of 4 bits of zero, 12 bits of starting line
90         number (must be greater than ending line of previous LN_CTLI, if any), 4 bits
91         of number of following PX_CTLI (must be in [1 .. 8]), and 12 bits of ending line
92         number (must not be less than starting line number).
93         Each PX_CTLI is 6 bytes, consisting of 2 bytes starting col number (must be
94         at least 8 greater than previous PX_CTLI, if any), 2 bytes of colour values
95         as per SET_COLOR, and 2 bytes of new contrast values as per SET_CONTR. */
96     SPU_CMD_END = 255 /* ends one SP_DCSQ */
97   };
98 
99 typedef enum /* attributes of cell */
100 /* A "cell" is a  grouping of one or more VOBUs, which might have a single VM command attached.
101     A "program" is a grouping of one or more cells; the significance is that skipping using
102     the next/prev buttons on the DVD player remote is done in units of programs. Also with
103     multiple interleaved angles, each angle goes in its own cell(s), but they must be within
104     the same program.
105     A program can also be marked as a "chapter" (aka "Part Of Title", "PTT"), which means it
106     can be directly referenced via an entry in the VTS_PTT_SRPT table, which allows it
107     to be linked from outside the current PGC.
108     And finally, one or more programs are grouped into a "program chain" (PGC). This can
109     have a VM command sequence to be executed at the start of the PGC, and another sequence
110     to be executed at the end. It also specifies the actual audio and subpicture stream IDs
111     corresponding to the stream attributes described in the IFO header for this menu/title.
112     Each menu or title may consist of a single PGC, or a sequence of multiple PGCs.
113     There is also a special "first play" PGC (FPC), which if present is automatically entered
114     when the disc is inserted into the player. */
115   {
116     CELL_NEITHER = 0, /* neither of following specified */
117     CELL_CHAPTER_PROGRAM = 1, /* cell has chapter attribute (implies program attribute) */
118     CELL_PROGRAM = 2, /* cell has program attribute only */
119   } cell_chapter_types;
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 enum
126   {
127     PROVIDER_SIZE = 32, /* length of provider string field in VMG IFO */
128   };
129 
130 #endif
131