]> git.sesse.net Git - vlc/blob - plugins/dvd/dvd_ifo.h
-better handling of angles: you should be able to change on the fly now
[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.14 2001/04/22 00:08:25 stef Exp $
6  *
7  * Author: Stéphane Borel <stef@via.ecp.fr>
8  *
9  * based on:
10  *  - libifo by Thomas Mirlacher <dent@cosy.sbg.ac.at>
11  *  - IFO structure documentation by Thomas Mirlacher, Björn Englund,
12  *  Håkan Hjort
13  * 
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
27  *****************************************************************************/
28
29 /*****************************************************************************
30  * Common structures for Video Management and Video Title sets
31  *****************************************************************************/
32
33 /*
34  * Program Chain structures
35  */
36 typedef struct ifo_video_s
37 {
38     u8      i_compression         ;// 2;
39     u8      i_system              ;// 2;
40     u8      i_ratio               ;// 2;
41     u8      i_perm_displ          ;// 2;
42
43     u8      i_line21_1            ;// 1;
44     u8      i_line21_2            ;// 1;
45     u8      i_source_res          ;// 2;
46     u8      i_letterboxed         ;// 1;
47     u8      i_mode                ;// 1;
48 } ifo_video_t;
49
50 /* Audio type information */
51 typedef struct ifo_audio_s
52 {
53     u8      i_coding_mode         ;// 3;
54     u8      i_multichannel_extension  ;// 1;
55     u8      i_type                ;// 2;
56     u8      i_appl_mode           ;// 2;
57
58     u8      i_quantization        ;// 2;
59     u8      i_sample_freq         ;// 2;
60     u8      i_test                ;// 1;
61     u8      i_num_channels        ;// 3;
62     u16     i_lang_code           ;// 16;   // <char> description
63     u8      i_foo                 ;// 8;    // 0x00000000 ?
64     u8      i_caption             ;// 8;
65     u8      i_bar                 ;// 8;    // 0x00000000 ?
66 } ifo_audio_t;
67
68 typedef struct ifo_spu_t
69 {
70     u16     i_prefix              ;// 16;   // 0x0100 ?
71     u16     i_lang_code           ;// 16;   // <char> description
72     u8      i_foo                 ;// 8;    // dont know
73     u8      i_caption             ;// 8;    // 0x00 ?
74 } ifo_spu_t;
75
76
77
78 /* Ifo vitual machine Commands */
79 typedef struct command_desc_s
80 {
81     u8              i_type      :3;
82     u8              i_direct    :1;
83     u8              i_cmd       :4;
84     u8              i_dir_cmp   :1;
85     u8              i_cmp       :3;
86     u8              i_sub_cmd   :4;
87     union
88     {
89         u8          pi_8[6];
90         u16         pi_16[3];
91     } data;
92 } command_desc_t;
93
94 /* Program Chain Command Table
95   - start at i_pgc_com_tab_sbyte */
96 typedef struct command_s
97 {
98     u16             i_pre_command_nb;               // 2 bytes
99     u16             i_post_command_nb;              // 2 bytes
100     u16             i_cell_command_nb;              // 2 bytes
101 //    char[2]         ???
102     u64* p_pre_command;                  // i_pre_com_nb * 8 bytes
103     u64* p_post_command;                 // i_post_com_nb * 8 bytes
104     u64* p_cell_command;                  // i_pre_com_nb * 8 bytes
105
106 //    command_desc_t* p_cell_command;                 // i_cell_com_nb * 8 bytes
107 //    command_desc_t* p_post_command;                 // i_post_com_nb * 8 bytes
108 //    command_desc_t* p_cell_command;                 // i_cell_com_nb * 8 bytes
109 } command_t;
110
111 /* Program Chain Map Table
112  * - start at "i_pgc_prg_map_sbyte" */
113 typedef struct chapter_map_s
114 {
115     u8*             pi_start_cell;              // i_prg_nb * 1 byte 
116 } chapter_map_t;
117
118 /* Cell Playback Information Table
119  * we have a pointer to such a structure for each cell  
120  * - first start at "i_cell_play_inf_sbyte" */
121 typedef struct cell_play_s
122 {
123     /* This information concerns the currently selected cell */
124     u16             i_category;                      // 2 bytes
125     u8              i_still_time;               // 1 byte; in seconds; ff=inf
126     u8              i_command_nb;                   // 1 byte; 0 = no com
127     u32             i_play_time;                // 4 bytes
128     u32             i_start_sector;             // 4 bytes
129     u32             i_first_ilvu_vobu_esector;  // 4 bytes; ???
130     u32             i_last_vobu_start_sector;            // 4 bytes
131     u32             i_end_sector;                  // 4 bytes
132 } cell_play_t;
133
134 /* Cell Position Information Table
135  * we have a pointer to such a structure for each cell 
136  * - first start at "i_cell_pos_inf_sbyte" */
137 typedef struct cell_pos_s
138 {
139     /* This information concerns the currently selected cell */
140     u16             i_vob_id;                   // 2 bytes
141 //    char            ???
142     u8              i_cell_id;                  // 1 byte
143 } cell_pos_t;
144
145 /* Main structure for Program Chain
146  * - start at i_fp_pgc_sbyte
147  * - or at i_vmgm_pgci_sbyte in vmgm_pgci_srp_t */
148 typedef struct title_s
149 {
150     /* Global features of program chain */
151 //    char[2]         ???
152     u8              i_chapter_nb;                   // 1 byte
153     u8              i_cell_nb;                  // 1 byte
154     u32             i_play_time;                // 4 bytes
155     u32             i_prohibited_user_op;       // 4 bytes
156     u16             pi_audio_status[8];         // 8*2 bytes
157     u32             pi_subpic_status[32];       // 32*4 bytes
158     u16             i_next_title_num;              // 2 bytes
159     u16             i_prev_title_num;              // 2 bytes
160     u16             i_go_up_title_num;              // 2 bytes
161     u8              i_still_time;               // 1 byte ; in seconds
162     u8              i_play_mode;                // 1 byte
163     /* In video_ts.ifo, the 3 significant bytes of each color are
164      * preceded by 1 unsignificant byte */
165     u32             pi_yuv_color[16];           // 16*3 bytes
166     /* Here come the start bytes of the following structures */
167     u16             i_command_start_byte;            // 2 bytes
168     u16             i_chapter_map_start_byte;            // 2 bytes
169     u16             i_cell_play_start_byte;      // 2 bytes
170     u16             i_cell_pos_start_byte;       // 2 bytes
171     /* Predefined structures */
172     command_t       command;
173     chapter_map_t   chapter_map;
174     cell_play_t*    p_cell_play;           // i_cell_nb * 24 bytes
175     cell_pos_t*     p_cell_pos;             // i_cell_nb * 4 bytes
176 } title_t;
177
178 /*
179  * Menu PGCI Unit Table
180  */
181
182 /* Menu PGCI Language unit Descriptor */
183 typedef struct unit_s
184 {
185     u16             i_lang_code;            // 2 bytes (ISO-xx)
186 //    char            ???
187     u8              i_existence_mask;           // 1 byte
188     u32             i_unit_inf_start_byte;                 // 4 bytes
189 } unit_t;
190
191 typedef struct unit_title_s
192 {
193     u8              i_category_mask;             // 1 byte
194     u8              i_category;                  // 1 byte
195     u16             i_parental_mask;                 // 2 bytes
196     u32             i_title_start_byte;               // 4 bytes
197     title_t         title;
198 } unit_title_t;
199
200 /* Menu PGCI Language Unit Table 
201  * - start at i_lu_sbyte */
202 typedef struct unit_inf_s
203 {
204     u16             i_title_nb;                   // 2 bytes
205 //    char[2]         ???
206     u32             i_end_byte;                 // 4 bytes
207     unit_title_t *  p_title;                      // i_srp_nb * 8 bytes
208 } unit_inf_t;
209
210 /* Main Struct for Menu PGCI
211  * - start at i_*_pgci_ut_ssector */
212 typedef struct title_unit_s
213 {
214     u16             i_unit_nb;                    // 2 bytes; ???
215 //    char[2]         ???
216     u32             i_end_byte;                    // 4 bytes
217     unit_t*         p_unit;                       // i_lu_nb * 8 bytes
218     unit_inf_t*     p_unit_inf;                 // i_lu_nb * 8 bytes
219 } title_unit_t;
220
221 /*
222  * Cell Adress Table Information
223  */
224 typedef struct cell_map_s
225 {
226     u16             i_vob_id;                   // 2 bytes
227     u8              i_cell_id;                  // 1 byte
228 //    char            ???
229     u32             i_start_sector;                  // 4 bytes
230     u32             i_end_sector;                  // 4 bytes
231 } cell_map_t;
232
233 typedef struct cell_inf_s
234 {
235     u16             i_vob_nb;                   // 2 bytes
236 //    char[2]         ???
237     u32             i_end_byte;                    // 4 bytes
238     u16             i_cell_nb;                  // not in ifo; computed
239                                                 // with e_byte
240     cell_map_t*     p_cell_map;
241 } cell_inf_t;
242
243
244 /*
245  * VOBU Adress Map Table
246  */
247 typedef struct vobu_map_s
248 {
249     u32             i_end_byte;                    // 4 bytes
250     u32*            pi_vobu_start_sector;            // (nb of vobu) * 4 bytes
251 } vobu_map_t;
252
253 /*****************************************************************************
254  * Structures for Video Management (cf video_ts.ifo)
255  *****************************************************************************/
256
257 /* 
258  * Video Manager Information Management Table
259  */ 
260 typedef struct manager_inf_s
261 {
262     char            psz_id[13];                 // 12 bytes (DVDVIDEO-VMG)
263     u32             i_vmg_end_sector;                  // 4 bytes
264 //    char[12]        ???
265     u32             i_vmg_inf_end_sector;                // 4 bytes
266 //    char            ???
267     u8              i_spec_ver;                 // 1 byte
268     u32             i_cat;                      // 4 bytes
269     u16             i_volume_nb;                   // 2 bytes
270     u16             i_volume;                      // 2 bytes
271     u8              i_disc_side;                // 1 bytes
272 //    char[20]        ???
273     u16             i_title_set_nb;                   // 2 bytes
274     char            ps_provider_id[32];         // 32 bytes
275     u64             i_pos_code;                 // 8 bytes
276 //    char[24]        ???
277     u32             i_vmg_inf_end_byte;              // 4 bytes
278     u32             i_first_play_title_start_byte;             // 4 bytes
279 //    char[56]        ???
280     u32             i_vob_start_sector;             // 4 bytes
281     u32             i_title_inf_start_sector;         // 4 bytes
282     u32             i_title_unit_start_sector;          // 4 bytes
283     u32             i_parental_inf_start_sector;         // 4 bytes
284     u32             i_vts_inf_start_sector;         // 4 bytes
285     u32             i_text_data_start_sector;         // 4 bytes
286     u32             i_cell_inf_start_sector;            // 4 bytes
287     u32             i_vobu_map_start_sector;       // 4 bytes
288 //    char[2]         ???
289     ifo_video_t     video_attr;                 // 2 bytes
290 //    char            ???
291     u8              i_audio_nb;                 // 1 byte
292     ifo_audio_t     p_audio_attr[8];            // i_vmgm_audio_nb * 8 bytes
293 //    char[16]        ???
294     u8              i_spu_nb;                // 1 byte
295     ifo_spu_t       p_spu_attr[32];          // i_subpic_nb * 6 bytes
296 } manager_inf_t;
297
298
299 /* 
300  * Part Of Title Search Pointer Table Information
301  */
302
303 /* Title sets structure
304  * we have a pointer to this structure for each tts */
305 typedef struct title_attr_s
306 {
307     u8              i_play_type;                // 1 byte
308     u8              i_angle_nb;                 // 1 byte
309     u16             i_chapter_nb;                  // 2 bytes; Chapters/PGs
310     u16             i_parental_id;              // 2 bytes
311     u8              i_title_set_num;            // 1 byte (VTS#)
312     u8              i_title_num;                 // 1 byte ???
313     u32             i_start_sector;              // 4 bytes
314 } title_attr_t;
315
316 /* Main struct for tts
317  * - start at "i_vmg_ptt_srpt_ssector" */
318 typedef struct title_inf_s
319 {
320     u16             i_title_nb;                   // 2 bytes
321 //    char[2]         ???
322     u32             i_end_byte;                    // 4 bytes
323     title_attr_t *  p_attr;                     // i_ttu_nb * 12 bytes
324 } title_inf_t;
325
326 /*
327  * Parental Management Information Table
328  */
329 typedef struct parental_desc_s
330 {
331     char            ps_country_code[2];         // 2 bytes
332 //    char[2]         ???
333     u16             i_parental_mask_start_byte;            // 2 bytes
334 //    char[2]         ???
335 } parental_desc_t;
336
337 typedef struct parental_mask_s
338 {
339     u16*            ppi_mask[8];            // (i_vts_nb +1) * 8 * 2 bytes
340 } parental_mask_t;
341
342 /* Main struct for parental management
343  * - start at i_vmg_ptl_mait_ssector */
344 typedef struct parental_inf_s
345 {
346     u16             i_country_nb;               // 2 bytes
347     u16             i_vts_nb;                   // 2 bytes
348     u32             i_end_byte;                    // 4 bytes
349     parental_desc_t* p_parental_desc;             // i_country_nb * 8 bytes
350     parental_mask_t* p_parental_mask;        // i_country_nb * sizeof(vmg_ptl_mask_t)
351 } parental_inf_t;
352
353 /*
354  * Video Title Set Attribute Table
355  */
356
357 /* Attribute structure : one for each vts
358  * - start at pi_atrt_sbyte */
359 typedef struct vts_attr_s
360 {
361     u32             i_end_byte;                    // 4 bytes
362     u32             i_cat_app_type;             // 4 bytes
363     ifo_video_t     vts_menu_video_attr;          // 2 bytes
364 //    char            ???
365     u8              i_vts_menu_audio_nb;            // 1 byte
366     ifo_audio_t     p_vts_menu_audio_attr[8];       // 8 * 8 bytes
367 //    char[17]        ???
368     u8              i_vts_menu_spu_nb;           // 1 byte
369     ifo_spu_t       p_vts_menu_spu_attr[28];     // i_vtsm_subpic_nb * 6 bytes
370 //    char[2]         ???
371     ifo_video_t     vts_title_video_attr;         // 2 bytes
372 //    char            ???
373     u8              i_vts_title_audio_nb;           // 1 byte
374     ifo_audio_t     p_vts_title_audio_attr[8];      // 8 * 8 bytes
375 //    char[17]        ???
376     u8              i_vts_title_spu_nb;          // 1 byte
377     ifo_spu_t       p_vts_title_spu_attr[28];    // i_vtstt_subpic_nb * 6 bytes
378 } vts_attr_t;
379
380 /* Main struct for vts attributes
381  * - start at i_vmg_vts_atrt_ssector */
382 typedef struct vts_inf_s
383 {
384     u16             i_vts_nb;                   // 2 bytes
385 //    char[2]         ???
386     u32             i_end_byte;                    // 4 bytes
387     u32*            pi_vts_attr_start_byte;          // i_vts_nb * 4 bytes
388     vts_attr_t*     p_vts_attr;
389 } vts_inf_t;
390
391 /* 
392  * Global Structure for Video Manager
393  */
394 typedef struct vmg_s 
395 {
396     manager_inf_t       manager_inf;
397     title_t             title;
398     title_inf_t         title_inf;
399     title_unit_t        title_unit;
400     parental_inf_t      parental_inf;
401     vts_inf_t           vts_inf;
402     cell_inf_t          cell_inf;
403     vobu_map_t          vobu_map;
404 } vmg_t;
405
406 /*****************************************************************************
407  * Structures for Video Title Sets (cf vts_*.ifo)
408  ****************************************************************************/
409
410 /* 
411  * Video Title Sets Information Management Table
412  */ 
413 typedef struct vts_manager_s
414 {
415     char            psz_id[13];                 // 12 bytes (DVDVIDEO-VTS)
416     u32             i_end_sector;                  // 4 bytes
417 //    char[12]        ???
418     u32             i_inf_end_sector;                // 4 bytes
419 //    char            ???
420     u8              i_spec_ver;                 // 1 byte
421     u32             i_cat;                      // 4 bytes
422 //    char[90]        ???
423     u32             i_inf_end_byte;                // 4 bytes
424 //    char[60]        ???
425     u32             i_menu_vob_start_sector;           // 4 bytes
426     u32             i_title_vob_start_sector;          // 4 bytes
427     u32             i_title_inf_start_sector;         // 4 bytes
428     u32             i_title_unit_start_sector;            // 4 bytes
429     u32             i_menu_unit_start_sector;        // 4 bytes
430     u32             i_time_inf_start_sector;          // 4 bytes
431     u32             i_menu_cell_inf_start_sector;          // 4 bytes
432     u32             i_menu_vobu_map_start_sector;     // 4 bytes
433     u32             i_cell_inf_start_sector;            // 4 bytes
434     u32             i_vobu_map_start_sector;       // 4 bytes
435 //    char[24]        ???
436     ifo_video_t     menu_video_attr;               // 2 bytes
437 //    char            ???
438     u8              i_menu_audio_nb;               // 1 byte
439     ifo_audio_t     p_menu_audio_attr[8];          // i_vmgm_audio_nb * 8 bytes
440 //    char[16]        ???
441     u8              i_menu_spu_nb;              // 1 byte
442     ifo_spu_t       p_menu_spu_attr[32];        // i_subpic_nb * 6 bytes
443                                                 // !!! only 28 subpics ???
444 //    char[2]         ???
445     ifo_video_t     video_attr;                 // 2 bytes
446 //    char            ???
447     u8              i_audio_nb;                 // 1 byte
448     ifo_audio_t     p_audio_attr[8];            // i_vmgm_audio_nb * 8 bytes
449 //    char[16]        ???
450     u8              i_spu_nb;                // 1 byte
451     ifo_spu_t       p_spu_attr[32];          // i_subpic_nb * 6 bytes
452 } vts_manager_t;
453
454 /* 
455  * Part Of Title Search Pointer Table Information
456  */
457
458 /* Title sets structure
459  * we have a pointer to this structure for each tts */
460 typedef struct title_start_s
461 {
462     u16             i_title_id;         // 2 bytes; Chapters/PGs
463     u16             i_chapter;                   // 2 bytes
464 } title_start_t;
465
466 /* Main struct for tts
467  * - start at "i_vts_ptt_srpt_ssector" */
468 typedef struct vts_title_s
469 {
470     u16             i_title_nb;                   // 2 bytes
471 //    char[2]         ???
472     u32             i_end_byte;                    // 4 bytes
473     u32*            pi_start_byte;
474     title_start_t * p_title_start;                      // i_ttu_nb * 4 bytes
475 } vts_title_t;
476
477 /*
478  * Time Map table information
479  */
480
481 /* Time Map structure */
482 typedef struct time_map_s
483 {
484     u8              i_time_unit;                // 1 byte
485 //    char            ???
486     u16             i_entry_nb;                 // 2 bytes
487     u32*            pi_sector;                  // i_entry_nb * 4 bytes
488 } time_map_t;
489
490 /* Main structure for tmap_ti
491  * - start at "i_tmap_ti_ssector" */
492 typedef struct time_inf_s
493 {
494     u16             i_nb;                       // 2 bytes
495 //    char[2]         ???
496     u32             i_end_byte;                    // 4 bytes
497     u32*            pi_start_byte;                   // i_tmap_nb * 4 bytes
498     time_map_t*     p_time_map;
499 } time_inf_t;
500
501 /*
502  * Video Title Set 
503  */
504 typedef struct vts_s
505 {
506     boolean_t       b_initialized;
507     off_t           i_pos;
508     vts_manager_t   manager_inf;
509     vts_title_t     title_inf;
510     title_unit_t    menu_unit;
511     unit_inf_t      title_unit;
512     time_inf_t      time_inf;
513     cell_inf_t      menu_cell_inf;
514     vobu_map_t      menu_vobu_map;
515     cell_inf_t      cell_inf;
516     vobu_map_t      vobu_map;
517 } vts_t;
518
519 /*
520  *  Global Ifo Structure
521  */
522 typedef struct ifo_s
523 {
524     int             i_fd;           /* File descriptor for the device */
525     off_t           i_off;          /* Offset to video_ts.ifo on the device */
526     off_t           i_pos;          /* Position of stream pointer */
527     boolean_t       b_error;        /* Error Management */
528     vmg_t           vmg;            /* Structure described in video_ts */
529     int             i_title;        /* Current title number */
530     vts_t           vts;            /* Vts ifo for current title set */
531 } ifo_t;
532