]> git.sesse.net Git - vlc/blob - src/input/dvd_ifo.h
cb4a8d79ac37ca2d753cd2b671dfa5ba36e4c02c
[vlc] / src / input / dvd_ifo.h
1 /*****************************************************************************
2  * dvd_ifo.h: Structures for ifo parsing
3  *****************************************************************************
4  * Copyright (C) 1999-2001 VideoLAN
5  *
6  * Author: Stéphane Borel <stef@via.ecp.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22
23 /*****************************************************************************
24  * Preamble
25  *****************************************************************************/
26 #define DVD_LB_SIZE 2048
27
28 /*****************************************************************************
29  * Common structures for Video Management and Video Title sets
30  *****************************************************************************/
31
32 /*
33  * Program Chain structures
34  */
35
36 /* Ifo vitual machine Commands */
37 typedef struct ifo_command_s
38 {
39     u8              i_type      :3;
40     u8              i_direct    :1;
41     u8              i_cmd       :4;
42     u8              i_dir_cmp   :1;
43     u8              i_cmp       :3;
44     u8              i_sub_cmd   :4;
45     u16             i_v0        :16;
46     u16             i_v2        :16;
47     u16             i_v4        :16;
48 } ifo_command_t;
49
50 /* Program Chain Command Table
51   - start at i_pgc_com_tab_sbyte */
52 typedef struct pgc_com_tab_s
53 {
54     u16             i_pre_com_nb;               // 2 bytes
55     u16             i_post_com_nb;              // 2 bytes
56     u16             i_cell_com_nb;              // 2 bytes
57 //    char[2]         ???
58     ifo_command_t*  p_pre_com;                  // i_pre_com_nb * 8 bytes
59     ifo_command_t*  p_post_com;                 // i_post_com_nb * 8 bytes
60     ifo_command_t*  p_cell_com;                 // i_cell_com_nb * 8 bytes
61 } pgc_com_tab_t;
62
63 /* Program Chain Map Table
64  * - start at "i_pgc_prg_map_sbyte" */
65 typedef struct pgc_prg_map_s
66 {
67     u8*             pi_entry_cell;              // i_prg_nb * 1 byte 
68 } pgc_prg_map_t;
69
70 /* Cell Playback Information Table
71  * we have a pointer to such a structure for each cell  
72  * - first start at "i_cell_play_inf_sbyte" */
73 typedef struct cell_play_inf_s
74 {
75     /* This information concerns the currently selected cell */
76     u16             i_cat;                      // 2 bytes
77     u8              i_still_time;               // 1 byte; in seconds; ff=inf
78     u8              i_com_nb;                   // 1 byte; 0 = no com
79     u32             i_play_time;                // 4 bytes
80     u32             i_entry_sector;             // 4 bytes
81     u32             i_first_ilvu_vobu_esector;  // 4 bytes; ???
82     u32             i_lvobu_ssector;            // 4 bytes
83     u32             i_lsector;                  // 4 bytes
84 } cell_play_inf_t;
85
86 /* Cell Position Information Table
87  * we have a pointer to such a structure for each cell 
88  * - first start at "i_cell_pos_inf_sbyte" */
89 typedef struct cell_pos_inf_s
90 {
91     /* This information concerns the currently selected cell */
92     u16             i_vob_id;                   // 2 bytes
93 //    char            ???
94     u8              i_cell_id;                  // 1 byte
95 } cell_pos_inf_t;
96
97 /* Main structure for Program Chain
98  * - start at i_fp_pgc_sbyte
99  * - or at i_vmgm_pgci_sbyte in vmgm_pgci_srp_t */
100 typedef struct pgc_s
101 {
102     /* Global features of program chain */
103 //    char[2]         ???
104     u8              i_prg_nb;                   // 1 byte
105     u8              i_cell_nb;                  // 1 byte
106     u32             i_play_time;                // 4 bytes
107     u32             i_prohibited_user_op;       // 4 bytes
108     u16             pi_audio_status[8];         // 8*2 bytes
109     u32             pi_subpic_status[32];       // 32*4 bytes
110     u16             i_next_pgc_nb;              // 2 bytes
111     u16             i_prev_pgc_nb;              // 2 bytes
112     u16             i_goup_pgc_nb;              // 2 bytes
113     u8              i_still_time;               // 1 byte ; in seconds
114     u8              i_play_mode;                // 1 byte
115     /* In video_ts.ifo, the 3 significant bytes of each color are
116      * preceded by 1 unsignificant byte */
117     u32             pi_yuv_color[16];           // 16*3 bytes
118     /* Here come the start bytes of the following structures */
119     u16             i_com_tab_sbyte;            // 2 bytes
120     u16             i_prg_map_sbyte;            // 2 bytes
121     u16             i_cell_play_inf_sbyte;      // 2 bytes
122     u16             i_cell_pos_inf_sbyte;       // 2 bytes
123     /* Predefined structures */
124     pgc_com_tab_t   com_tab;
125     pgc_prg_map_t   prg_map;
126     cell_play_inf_t* p_cell_play_inf;           // i_cell_nb * 24 bytes
127     cell_pos_inf_t* p_cell_pos_inf;             // i_cell_nb * 4 bytes
128 } pgc_t;
129
130 /*
131  * Menu PGCI Unit Table
132  */
133
134 /* Menu PGCI Language unit Descriptor */
135 typedef struct pgci_lu_s
136 {
137     char            ps_lang_code[2];            // 2 bytes (ISO-xx)
138 //    char            ???
139     u8              i_existence_mask;           // 1 byte
140     u32             i_lu_sbyte;                 // 4 bytes
141 } pgci_lu_t;
142
143 typedef struct pgci_srp_s
144 {
145     u8              i_pgc_cat_mask;             // 1 byte
146     u8              i_pgc_cat;                  // 1 byte
147     u16             i_par_mask;                 // 2 bytes
148     u32             i_pgci_sbyte;               // 4 bytes
149     pgc_t           pgc;
150 } pgci_srp_t;
151
152 /* Menu PGCI Language Unit Table 
153  * - start at i_lu_sbyte */
154 typedef struct pgci_inf_s
155 {
156     u16             i_srp_nb;                   // 2 bytes
157 //    char[2]         ???
158     u32             i_lu_ebyte;                 // 4 bytes
159     pgci_srp_t*     p_srp;                      // i_srp_nb * 8 bytes
160 } pgci_inf_t;
161
162 /* Main Struct for Menu PGCI
163  * - start at i_*_pgci_ut_ssector */
164 typedef struct pgci_ut_s
165 {
166     u16             i_lu_nb;                    // 2 bytes; ???
167 //    char[2]         ???
168     u32             i_ebyte;                    // 4 bytes
169     pgci_lu_t*      p_lu;                       // i_lu_nb * 8 bytes
170     pgci_inf_t*     p_pgci_inf;                 // i_lu_nb * 8 bytes
171 } pgci_ut_t;
172
173 /*
174  * Cell Adress Table Information
175  */
176 typedef struct cell_inf_s
177 {
178     u16             i_vob_id;                   // 2 bytes
179     u8              i_cell_id;                  // 1 byte
180 //    char            ???
181     u32             i_ssector;                  // 4 bytes
182     u32             i_esector;                  // 4 bytes
183 } cell_inf_t;
184
185 typedef struct c_adt_s
186 {
187     u16             i_vob_nb;                   // 2 bytes
188 //    char[2]         ???
189     u32             i_ebyte;                    // 4 bytes
190     cell_inf_t*     p_cell_inf;
191 } c_adt_t;
192
193
194 /*
195  * VOBU Adress Map Table
196  */
197 typedef struct vobu_admap_s
198 {
199     u32             i_ebyte;                    // 4 bytes
200     u32*            pi_vobu_ssector;            // (nb of vobu) * 4 bytes
201 } vobu_admap_t;
202
203 /*****************************************************************************
204  * Structures for Video Management (cf video_ts.ifo)
205  *****************************************************************************/
206
207 /* 
208  * Video Manager Information Management Table
209  */ 
210 typedef struct vmgi_mat_s
211 {
212     char            psz_id[13];                 // 12 bytes (DVDVIDEO-VMG)
213     u32             i_lsector;                  // 4 bytes
214 //    char[12]        ???
215     u32             i_i_lsector;                // 4 bytes
216 //    char            ???
217     u8              i_spec_ver;                 // 1 byte
218     u32             i_cat;                      // 4 bytes
219     u16             i_vol_nb;                   // 2 bytes
220     u16             i_vol;                      // 2 bytes
221     u8              i_disc_side;                // 1 bytes
222 //    char[20]        ???
223     u16             i_tts_nb;                   // 2 bytes
224     char            ps_provider_id[32];         // 32 bytes
225     u64             i_pos_code;                 // 8 bytes
226 //    char[24]        ???
227     u32             i_i_mat_ebyte;              // 4 bytes
228     u32             i_fp_pgc_sbyte;             // 4 bytes
229 //    char[56]        ???
230     u32             i_vobs_ssector;             // 4 bytes
231     u32             i_ptt_srpt_ssector;         // 4 bytes
232     u32             i_pgci_ut_ssector;          // 4 bytes
233     u32             i_ptl_mait_ssector;         // 4 bytes
234     u32             i_vts_atrt_ssector;         // 4 bytes
235     u32             i_txtdt_mg_ssector;         // 4 bytes
236     u32             i_c_adt_ssector;            // 4 bytes
237     u32             i_vobu_admap_ssector;       // 4 bytes
238 //    char[2]         ???
239     u16             i_video_atrt;               // 2 bytes
240 //    char            ???
241     u8              i_audio_nb;                 // 1 byte
242     u64             pi_audio_atrt[8];           // i_vmgm_audio_nb * 8 bytes
243 //    char[16]        ???
244     u8              i_subpic_nb;                // 1 byte
245     u64             pi_subpic_atrt[32];         // i_subpic_nb * 6 bytes
246 } vmgi_mat_t;
247
248
249 /* 
250  * Part Of Title Search Pointer Table Information
251  */
252
253 /* Title sets structure
254  * we have a pointer to this structure for each tts */
255 typedef struct tts_s
256 {
257     u8              i_play_type;                // 1 byte
258     u8              i_angle_nb;                 // 1 byte
259     u16             i_ptt_nb;                   // 2 bytes; Chapters/PGs
260     u16             i_parental_id;              // 2 bytes
261     u8              i_tts_nb;                   // 1 byte (VTS#)
262     u8              i_vts_ttn;                  // 1 byte ???
263     u32             i_ssector;                  // 4 bytes
264 } tts_t;
265
266 /* Main struct for tts
267  * - start at "i_vmg_ptt_srpt_ssector" */
268 typedef struct vmg_ptt_srpt_s
269 {
270     u16             i_ttu_nb;                   // 2 bytes
271 //    char[2]         ???
272     u32             i_ebyte;                    // 4 bytes
273     tts_t*          p_tts;                      // i_ttu_nb * 12 bytes
274 } vmg_ptt_srpt_t;
275
276 /*
277  * Parental Management Information Table
278  */
279 typedef struct vmg_ptl_mai_desc_s
280 {
281     char            ps_country_code[2];         // 2 bytes
282 //    char[2]         ???
283     u16             i_ptl_mai_sbyte;            // 2 bytes
284 //    char[2]         ???
285 } vmg_ptl_mai_desc_t;
286
287 typedef struct vmg_ptl_mask_s
288 {
289     u16*            ppi_ptl_mask[8];            // (i_vts_nb +1) * 8 * 2 bytes
290 } vmg_ptl_mask_t;
291
292 /* Main struct for parental management
293  * - start at i_vmg_ptl_mait_ssector */
294 typedef struct vmg_ptl_mait_s
295 {
296     u16             i_country_nb;               // 2 bytes
297     u16             i_vts_nb;                   // 2 bytes
298     u32             i_ebyte;                    // 4 bytes
299     vmg_ptl_mai_desc_t* p_ptl_desc;             // i_country_nb * 8 bytes
300     vmg_ptl_mask_t* p_ptl_mask;        // i_country_nb * sizeof(vmg_ptl_mask_t)
301 } vmg_ptl_mait_t;
302
303 /*
304  * Video Title Set Attribute Table
305  */
306
307 /* Attribute structure : one for each vts
308  * - start at pi_atrt_sbyte */
309 typedef struct vts_atrt_s
310 {
311     u32             i_ebyte;                    // 4 bytes
312     u32             i_cat_app_type;             // 4 bytes
313     u16             i_vtsm_video_atrt;          // 2 bytes
314 //    char            ???
315     u8              i_vtsm_audio_nb;            // 1 byte
316     u64             pi_vtsm_audio_atrt[8];      // 8 * 8 bytes
317 //    char[17]        ???
318     u8              i_vtsm_subpic_nb;           // 1 byte
319     u64             pi_vtsm_subpic_atrt[28];    // i_vtsm_subpic_nb * 6 bytes
320 //    char[2]         ???
321     u16             i_vtstt_video_atrt;         // 2 bytes
322 //    char            ???
323     u8              i_vtstt_audio_nb;           // 1 byte
324     u64             pi_vtstt_audio_atrt[8];     // 8 * 8 bytes
325 //    char[17]        ???
326     u8              i_vtstt_subpic_nb;          // 1 byte
327     u64             pi_vtstt_subpic_atrt[28];   // i_vtstt_subpic_nb * 6 bytes
328 } vts_atrt_t;
329
330 /* Main struct for vts attributes
331  * - start at i_vmg_vts_atrt_ssector */
332 typedef struct vmg_vts_atrt_s
333 {
334     u16             i_vts_nb;                   // 2 bytes
335 //    char[2]         ???
336     u32             i_ebyte;                    // 4 bytes
337     u32*            pi_vts_atrt_sbyte;          // i_vts_nb * 4 bytes
338     vts_atrt_t*     p_vts_atrt;
339 } vmg_vts_atrt_t;
340
341 /* 
342  * Global Structure for Video Manager
343  */
344 typedef struct vmg_s 
345 {
346     vmgi_mat_t      mat;
347     pgc_t           pgc;
348     vmg_ptt_srpt_t  ptt_srpt;
349     pgci_ut_t       pgci_ut;
350     vmg_ptl_mait_t  ptl_mait;
351     vmg_vts_atrt_t  vts_atrt;
352     c_adt_t         c_adt;
353     vobu_admap_t    vobu_admap;
354 } vmg_t;
355
356 /*****************************************************************************
357  * Structures for Video Title Sets (cf vts_*.ifo)
358  ****************************************************************************/
359
360 /* 
361  * Video Title Sets Information Management Table
362  */ 
363 typedef struct vtsi_mat_s
364 {
365     char            psz_id[13];                 // 12 bytes (DVDVIDEO-VTS)
366     u32             i_lsector;                  // 4 bytes
367 //    char[12]        ???
368     u32             i_i_lsector;                // 4 bytes
369 //    char            ???
370     u8              i_spec_ver;                 // 1 byte
371     u32             i_cat;                      // 4 bytes
372 //    char[90]        ???
373     u32             i_mat_ebyte;                // 4 bytes
374 //    char[60]        ???
375     u32             i_m_vobs_ssector;           // 4 bytes
376     u32             i_tt_vobs_ssector;          // 4 bytes
377     u32             i_ptt_srpt_ssector;         // 4 bytes
378     u32             i_pgcit_ssector;            // 4 bytes
379     u32             i_m_pgci_ut_ssector;        // 4 bytes
380     u32             i_tmap_ti_ssector;          // 4 bytes
381     u32             i_m_c_adt_ssector;          // 4 bytes
382     u32             i_m_vobu_admap_ssector;     // 4 bytes
383     u32             i_c_adt_ssector;            // 4 bytes
384     u32             i_vobu_admap_ssector;       // 4 bytes
385 //    char[24]        ???
386     u16             i_m_video_atrt;             // 2 bytes
387 //    char            ???
388     u8              i_m_audio_nb;               // 1 byte
389     u64             pi_m_audio_atrt[8];         // i_vmgm_audio_nb * 8 bytes
390 //    char[16]        ???
391     u8              i_m_subpic_nb;              // 1 byte
392     u64             pi_m_subpic_atrt[32];       // i_subpic_nb * 6 bytes
393                                                 // !!! only 28 subpics ???
394 //    char[2]         ???
395     u16             i_video_atrt;               // 2 bytes
396 //    char            ???
397     u8              i_audio_nb;                 // 1 byte
398     u64             pi_audio_atrt[8];           // i_vmgm_audio_nb * 8 bytes
399 //    char[16]        ???
400     u8              i_subpic_nb;                // 1 byte
401     u64             pi_subpic_atrt[32];         // i_subpic_nb * 6 bytes
402 } vtsi_mat_t;
403
404 /* 
405  * Part Of Title Search Pointer Table Information
406  */
407
408 /* Title sets structure
409  * we have a pointer to this structure for each tts */
410 typedef struct ttu_s
411 {
412     u16             i_pgc_nb;                   // 2 bytes; Chapters/PGs
413     u16             i_prg_nb;                   // 2 bytes
414 } ttu_t;
415
416 /* Main struct for tts
417  * - start at "i_vts_ptt_srpt_ssector" */
418 typedef struct vts_ptt_srpt_s
419 {
420     u16             i_ttu_nb;                   // 2 bytes
421 //    char[2]         ???
422     u32             i_ebyte;                    // 4 bytes
423     u32*            pi_ttu_sbyte;
424     ttu_t*          p_ttu;                      // i_ttu_nb * 4 bytes
425 } vts_ptt_srpt_t;
426
427 /*
428  * Time Map table information
429  */
430
431 /* Time Map structure */
432 typedef struct tmap_s
433 {
434     u8              i_time_unit;                // 1 byte
435 //    char            ???
436     u16             i_entry_nb;                 // 2 bytes
437     u32*            pi_sector;                  // i_entry_nb * 4 bytes
438 } tmap_t;
439
440 /* Main structure for tmap_ti
441  * - start at "i_tmap_ti_ssector" */
442 typedef struct vts_tmap_ti_s
443 {
444     u16             i_nb;                       // 2 bytes
445 //    char[2]         ???
446     u32             i_ebyte;                    // 4 bytes
447     u32*            pi_sbyte;                   // i_tmap_nb * 4 bytes
448     tmap_t*         p_tmap;
449 } vts_tmap_ti_t;
450
451 /*
452  * Video Title Set 
453  */
454 typedef struct vts_s
455 {
456     u32             i_pos;
457     vtsi_mat_t      mat;
458     /* Part Of Title Search Pointer Table Info */
459     vts_ptt_srpt_t  ptt_srpt;
460     /* Video Title Set Menu PGCI Unit Table */
461     pgci_ut_t       pgci_ut;
462     /* Video Title Set Program Chain Info Table */
463     pgci_inf_t      pgci_ti;
464     /* Video Title Set Time Map Table */
465     vts_tmap_ti_t   tmap_ti;
466     /* VTSM Cell Adress Table Information */
467     c_adt_t         m_c_adt;
468     /* VTSM VOBU Adress Map Table */
469     vobu_admap_t    m_vobu_admap;
470     /* VTS Cell Adress Table Information */
471     c_adt_t         c_adt;
472     /* VTS VOBU Adress Map Table */
473     vobu_admap_t    vobu_admap;
474 } vts_t;
475
476 /*
477  *  Global Ifo Structure
478  */
479 typedef struct ifo_s
480 {
481     /* File descriptor for the device */
482     int             i_fd;
483     /* Offset to video_ts.ifo on the device */
484     off64_t           i_off;
485     /* Position of stream pointer */
486     off64_t           i_pos;
487     /* Error Management */
488     boolean_t       b_error;
489     /* Structure described in video_ts */
490     vmg_t           vmg;
491     /* Table of vts ifos */
492     vts_t *         p_vts;
493 } ifo_t;
494
495 /*****************************************************************************
496  * Prototypes in dvd_ifo.c
497  *****************************************************************************/
498 ifo_t   IfoInit( int );
499 void    IfoRead( ifo_t* );