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