1 /*****************************************************************************
2 * dvd_ifo.h: Structures for ifo parsing
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VideoLAN
6 * Author: Stéphane Borel <stef@via.ecp.fr>
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.
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.
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 *****************************************************************************/
23 /*****************************************************************************
25 *****************************************************************************/
26 #define DVD_LB_SIZE 2048
28 /*****************************************************************************
29 * Common structures for Video Management and Video Title sets
30 *****************************************************************************/
33 * Program Chain structures
36 /* Ifo vitual machine Commands */
37 typedef struct ifo_command_s
50 /* Program Chain Command Table
51 - start at i_pgc_com_tab_sbyte */
52 typedef struct pgc_com_tab_s
54 u16 i_pre_com_nb; // 2 bytes
55 u16 i_post_com_nb; // 2 bytes
56 u16 i_cell_com_nb; // 2 bytes
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
63 /* Program Chain Map Table
64 * - start at "i_pgc_prg_map_sbyte" */
65 typedef struct pgc_prg_map_s
67 u8* pi_entry_cell; // i_prg_nb * 1 byte
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
75 /* This information concerns the currently selected cell */
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
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
91 /* This information concerns the currently selected cell */
92 u16 i_vob_id; // 2 bytes
94 u8 i_cell_id; // 1 byte
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 */
102 /* Global features of program chain */
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
131 * Menu PGCI Unit Table
134 /* Menu PGCI Language unit Descriptor */
135 typedef struct pgci_lu_s
137 char ps_lang_code[2]; // 2 bytes (ISO-xx)
139 u8 i_existence_mask; // 1 byte
140 u32 i_lu_sbyte; // 4 bytes
143 typedef struct pgci_srp_s
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
152 /* Menu PGCI Language Unit Table
153 * - start at i_lu_sbyte */
154 typedef struct pgci_inf_s
156 u16 i_srp_nb; // 2 bytes
158 u32 i_lu_ebyte; // 4 bytes
159 pgci_srp_t* p_srp; // i_srp_nb * 8 bytes
162 /* Main Struct for Menu PGCI
163 * - start at i_*_pgci_ut_ssector */
164 typedef struct pgci_ut_s
166 u16 i_lu_nb; // 2 bytes; ???
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
174 * Cell Adress Table Information
176 typedef struct cell_inf_s
178 u16 i_vob_id; // 2 bytes
179 u8 i_cell_id; // 1 byte
181 u32 i_ssector; // 4 bytes
182 u32 i_esector; // 4 bytes
185 typedef struct c_adt_s
187 u16 i_vob_nb; // 2 bytes
189 u32 i_ebyte; // 4 bytes
190 cell_inf_t* p_cell_inf;
195 * VOBU Adress Map Table
197 typedef struct vobu_admap_s
199 u32 i_ebyte; // 4 bytes
200 u32* pi_vobu_ssector; // (nb of vobu) * 4 bytes
203 /*****************************************************************************
204 * Structures for Video Management (cf video_ts.ifo)
205 *****************************************************************************/
208 * Video Manager Information Management Table
210 typedef struct vmgi_mat_s
212 char psz_id[13]; // 12 bytes (DVDVIDEO-VMG)
213 u32 i_lsector; // 4 bytes
215 u32 i_i_lsector; // 4 bytes
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
223 u16 i_tts_nb; // 2 bytes
224 char ps_provider_id[32]; // 32 bytes
225 u64 i_pos_code; // 8 bytes
227 u32 i_i_mat_ebyte; // 4 bytes
228 u32 i_fp_pgc_sbyte; // 4 bytes
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
239 u16 i_video_atrt; // 2 bytes
241 u8 i_audio_nb; // 1 byte
242 u64 pi_audio_atrt[8]; // i_vmgm_audio_nb * 8 bytes
244 u8 i_subpic_nb; // 1 byte
245 u64 pi_subpic_atrt[32]; // i_subpic_nb * 6 bytes
250 * Part Of Title Search Pointer Table Information
253 /* Title sets structure
254 * we have a pointer to this structure for each tts */
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
266 /* Main struct for tts
267 * - start at "i_vmg_ptt_srpt_ssector" */
268 typedef struct vmg_ptt_srpt_s
270 u16 i_ttu_nb; // 2 bytes
272 u32 i_ebyte; // 4 bytes
273 tts_t* p_tts; // i_ttu_nb * 12 bytes
277 * Parental Management Information Table
279 typedef struct vmg_ptl_mai_desc_s
281 char ps_country_code[2]; // 2 bytes
283 u16 i_ptl_mai_sbyte; // 2 bytes
285 } vmg_ptl_mai_desc_t;
287 typedef struct vmg_ptl_mask_s
289 u16* ppi_ptl_mask[8]; // (i_vts_nb +1) * 8 * 2 bytes
292 /* Main struct for parental management
293 * - start at i_vmg_ptl_mait_ssector */
294 typedef struct vmg_ptl_mait_s
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)
304 * Video Title Set Attribute Table
307 /* Attribute structure : one for each vts
308 * - start at pi_atrt_sbyte */
309 typedef struct vts_atrt_s
311 u32 i_ebyte; // 4 bytes
312 u32 i_cat_app_type; // 4 bytes
313 u16 i_vtsm_video_atrt; // 2 bytes
315 u8 i_vtsm_audio_nb; // 1 byte
316 u64 pi_vtsm_audio_atrt[8]; // 8 * 8 bytes
318 u8 i_vtsm_subpic_nb; // 1 byte
319 u64 pi_vtsm_subpic_atrt[28]; // i_vtsm_subpic_nb * 6 bytes
321 u16 i_vtstt_video_atrt; // 2 bytes
323 u8 i_vtstt_audio_nb; // 1 byte
324 u64 pi_vtstt_audio_atrt[8]; // 8 * 8 bytes
326 u8 i_vtstt_subpic_nb; // 1 byte
327 u64 pi_vtstt_subpic_atrt[28]; // i_vtstt_subpic_nb * 6 bytes
330 /* Main struct for vts attributes
331 * - start at i_vmg_vts_atrt_ssector */
332 typedef struct vmg_vts_atrt_s
334 u16 i_vts_nb; // 2 bytes
336 u32 i_ebyte; // 4 bytes
337 u32* pi_vts_atrt_sbyte; // i_vts_nb * 4 bytes
338 vts_atrt_t* p_vts_atrt;
342 * Global Structure for Video Manager
348 vmg_ptt_srpt_t ptt_srpt;
350 vmg_ptl_mait_t ptl_mait;
351 vmg_vts_atrt_t vts_atrt;
353 vobu_admap_t vobu_admap;
356 /*****************************************************************************
357 * Structures for Video Title Sets (cf vts_*.ifo)
358 ****************************************************************************/
361 * Video Title Sets Information Management Table
363 typedef struct vtsi_mat_s
365 char psz_id[13]; // 12 bytes (DVDVIDEO-VTS)
366 u32 i_lsector; // 4 bytes
368 u32 i_i_lsector; // 4 bytes
370 u8 i_spec_ver; // 1 byte
371 u32 i_cat; // 4 bytes
373 u32 i_mat_ebyte; // 4 bytes
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
386 u16 i_m_video_atrt; // 2 bytes
388 u8 i_m_audio_nb; // 1 byte
389 u64 pi_m_audio_atrt[8]; // i_vmgm_audio_nb * 8 bytes
391 u8 i_m_subpic_nb; // 1 byte
392 u64 pi_m_subpic_atrt[32]; // i_subpic_nb * 6 bytes
393 // !!! only 28 subpics ???
395 u16 i_video_atrt; // 2 bytes
397 u8 i_audio_nb; // 1 byte
398 u64 pi_audio_atrt[8]; // i_vmgm_audio_nb * 8 bytes
400 u8 i_subpic_nb; // 1 byte
401 u64 pi_subpic_atrt[32]; // i_subpic_nb * 6 bytes
405 * Part Of Title Search Pointer Table Information
408 /* Title sets structure
409 * we have a pointer to this structure for each tts */
412 u16 i_pgc_nb; // 2 bytes; Chapters/PGs
413 u16 i_prg_nb; // 2 bytes
416 /* Main struct for tts
417 * - start at "i_vts_ptt_srpt_ssector" */
418 typedef struct vts_ptt_srpt_s
420 u16 i_ttu_nb; // 2 bytes
422 u32 i_ebyte; // 4 bytes
424 ttu_t* p_ttu; // i_ttu_nb * 4 bytes
428 * Time Map table information
431 /* Time Map structure */
432 typedef struct tmap_s
434 u8 i_time_unit; // 1 byte
436 u16 i_entry_nb; // 2 bytes
437 u32* pi_sector; // i_entry_nb * 4 bytes
440 /* Main structure for tmap_ti
441 * - start at "i_tmap_ti_ssector" */
442 typedef struct vts_tmap_ti_s
446 u32 i_ebyte; // 4 bytes
447 u32* pi_sbyte; // i_tmap_nb * 4 bytes
458 /* Part Of Title Search Pointer Table Info */
459 vts_ptt_srpt_t ptt_srpt;
460 /* Video Title Set Menu PGCI Unit Table */
462 /* Video Title Set Program Chain Info Table */
464 /* Video Title Set Time Map Table */
465 vts_tmap_ti_t tmap_ti;
466 /* VTSM Cell Adress Table Information */
468 /* VTSM VOBU Adress Map Table */
469 vobu_admap_t m_vobu_admap;
470 /* VTS Cell Adress Table Information */
472 /* VTS VOBU Adress Map Table */
473 vobu_admap_t vobu_admap;
477 * Global Ifo Structure
481 /* File descriptor for the device */
483 /* Offset to video_ts.ifo on the device */
485 /* Position of stream pointer */
487 /* Error Management */
489 /* Structure described in video_ts */
491 /* Table of vts ifos */
495 /*****************************************************************************
496 * Prototypes in dvd_ifo.c
497 *****************************************************************************/
498 ifo_t IfoInit( int );
499 void IfoRead( ifo_t* );