ifo_types.h
1 /*
2  * Copyright (C) 2000, 2001 Björn Englund <d4bjorn@dtek.chalmers.se>,
3  * Håkan Hjort <d95hjort@dtek.chalmers.se>
4  *
5  * This file is part of libdvdread.
6  *
7  * libdvdread 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
10  * (at your option) any later version.
11  *
12  * libdvdread is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with libdvdread; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #ifndef LIBDVDREAD_IFO_TYPES_H
23 #define LIBDVDREAD_IFO_TYPES_H
24 
25 #include <inttypes.h>
26 #include "dvdread/dvd_reader.h"
27 
28 
29 #undef ATTRIBUTE_PACKED
30 #undef PRAGMA_PACK_BEGIN
31 #undef PRAGMA_PACK_END
32 
33 #if defined(__GNUC__)
34 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
35 #define ATTRIBUTE_PACKED __attribute__ ((packed))
36 #define PRAGMA_PACK 0
37 #endif
38 #endif
39 
40 #if !defined(ATTRIBUTE_PACKED)
41 #define ATTRIBUTE_PACKED
42 #define PRAGMA_PACK 1
43 #endif
44 
45 #if PRAGMA_PACK
46 #pragma pack(1)
47 #endif
48 
49 
60 typedef struct {
61  uint8_t hour;
62  uint8_t minute;
63  uint8_t second;
64  uint8_t frame_u; /* The two high bits are the frame rate. */
65 } ATTRIBUTE_PACKED dvd_time_t;
66 
70 typedef struct {
71  uint8_t bytes[8];
72 } ATTRIBUTE_PACKED vm_cmd_t;
73 #define COMMAND_DATA_SIZE 8U
74 
75 
79 typedef struct {
80  unsigned char mpeg_version : 2;
81  unsigned char video_format : 2;
82  unsigned char display_aspect_ratio : 2;
83  unsigned char permitted_df : 2;
84 
85  unsigned char line21_cc_1 : 1;
86  unsigned char line21_cc_2 : 1;
87  unsigned char unknown1 : 1;
88  unsigned char bit_rate : 1;
89 
90  unsigned char picture_size : 2;
91  unsigned char letterboxed : 1;
92  unsigned char film_mode : 1;
93 } ATTRIBUTE_PACKED video_attr_t;
94 
98 typedef struct {
99  unsigned char audio_format : 3;
100  unsigned char multichannel_extension : 1;
101  unsigned char lang_type : 2;
102  unsigned char application_mode : 2;
103 
104  unsigned char quantization : 2;
105  unsigned char sample_frequency : 2;
106  unsigned char unknown1 : 1;
107  unsigned char channels : 3;
108  uint16_t lang_code;
109  uint8_t lang_extension;
110  uint8_t code_extension;
111  uint8_t unknown3;
112  union {
113  struct ATTRIBUTE_PACKED {
114  unsigned char unknown4 : 1;
115  unsigned char channel_assignment : 3;
116  unsigned char version : 2;
117  unsigned char mc_intro : 1; /* probably 0: true, 1:false */
118  unsigned char mode : 1; /* Karaoke mode 0: solo 1: duet */
119  } karaoke;
120  struct ATTRIBUTE_PACKED {
121  unsigned char unknown5 : 4;
122  unsigned char dolby_encoded : 1; /* suitable for surround decoding */
123  unsigned char unknown6 : 3;
124  } surround;
125  } ATTRIBUTE_PACKED app_info;
126 } ATTRIBUTE_PACKED audio_attr_t;
127 
128 
132 typedef struct {
133  unsigned int zero1 : 7;
134  unsigned int ach0_gme : 1;
135 
136  unsigned int zero2 : 7;
137  unsigned int ach1_gme : 1;
138 
139  unsigned int zero3 : 4;
140  unsigned int ach2_gv1e : 1;
141  unsigned int ach2_gv2e : 1;
142  unsigned int ach2_gm1e : 1;
143  unsigned int ach2_gm2e : 1;
144 
145  unsigned int zero4 : 4;
146  unsigned int ach3_gv1e : 1;
147  unsigned int ach3_gv2e : 1;
148  unsigned int ach3_gmAe : 1;
149  unsigned int ach3_se2e : 1;
150 
151  unsigned int zero5 : 4;
152  unsigned int ach4_gv1e : 1;
153  unsigned int ach4_gv2e : 1;
154  unsigned int ach4_gmBe : 1;
155  unsigned int ach4_seBe : 1;
156  uint8_t zero6[19];
157 } ATTRIBUTE_PACKED multichannel_ext_t;
158 
159 
163 typedef struct {
164  /*
165  * type: 0 not specified
166  * 1 language
167  * 2 other
168  * coding mode: 0 run length
169  * 1 extended
170  * 2 other
171  * language: indicates language if type == 1
172  * lang extension: if type == 1 contains the lang extension
173  */
174  unsigned char code_mode : 3;
175  unsigned char zero1 : 3;
176  unsigned char type : 2;
177  uint8_t zero2;
178  uint16_t lang_code;
179  uint8_t lang_extension;
180  uint8_t code_extension;
181 } ATTRIBUTE_PACKED subp_attr_t;
182 
183 
184 
188 typedef struct {
189  uint16_t nr_of_pre;
190  uint16_t nr_of_post;
191  uint16_t nr_of_cell;
192  uint16_t zero_1;
193  vm_cmd_t *pre_cmds;
194  vm_cmd_t *post_cmds;
195  vm_cmd_t *cell_cmds;
196 } ATTRIBUTE_PACKED pgc_command_tbl_t;
197 #define PGC_COMMAND_TBL_SIZE 8U
198 
202 typedef uint8_t pgc_program_map_t;
203 
207 typedef struct {
208  unsigned int block_mode : 2;
209  unsigned int block_type : 2;
210  unsigned int seamless_play : 1;
211  unsigned int interleaved : 1;
212  unsigned int stc_discontinuity: 1;
213  unsigned int seamless_angle : 1;
214 
215  unsigned int playback_mode : 1;
216  unsigned int restricted : 1;
217  unsigned int unknown2 : 6;
218  uint8_t still_time;
219  uint8_t cell_cmd_nr;
220  dvd_time_t playback_time;
221  uint32_t first_sector;
222  uint32_t first_ilvu_end_sector;
223  uint32_t last_vobu_start_sector;
224  uint32_t last_sector;
225 } ATTRIBUTE_PACKED cell_playback_t;
226 
227 #define BLOCK_TYPE_NONE 0x0
228 #define BLOCK_TYPE_ANGLE_BLOCK 0x1
229 
230 #define BLOCK_MODE_NOT_IN_BLOCK 0x0
231 #define BLOCK_MODE_FIRST_CELL 0x1
232 #define BLOCK_MODE_IN_BLOCK 0x2
233 #define BLOCK_MODE_LAST_CELL 0x3
234 
238 typedef struct {
239  uint16_t vob_id_nr;
240  uint8_t zero_1;
241  uint8_t cell_nr;
242 } ATTRIBUTE_PACKED cell_position_t;
243 
247 typedef struct {
248  unsigned int zero : 7; /* 25-31 */
249  unsigned int video_pres_mode_change : 1; /* 24 */
250 
251  unsigned int karaoke_audio_pres_mode_change : 1; /* 23 */
252  unsigned int angle_change : 1;
253  unsigned int subpic_stream_change : 1;
254  unsigned int audio_stream_change : 1;
255  unsigned int pause_on : 1;
256  unsigned int still_off : 1;
257  unsigned int button_select_or_activate : 1;
258  unsigned int resume : 1; /* 16 */
259 
260  unsigned int chapter_menu_call : 1; /* 15 */
261  unsigned int angle_menu_call : 1;
262  unsigned int audio_menu_call : 1;
263  unsigned int subpic_menu_call : 1;
264  unsigned int root_menu_call : 1;
265  unsigned int title_menu_call : 1;
266  unsigned int backward_scan : 1;
267  unsigned int forward_scan : 1; /* 8 */
268 
269  unsigned int next_pg_search : 1; /* 7 */
270  unsigned int prev_or_top_pg_search : 1;
271  unsigned int time_or_chapter_search : 1;
272  unsigned int go_up : 1;
273  unsigned int stop : 1;
274  unsigned int title_play : 1;
275  unsigned int chapter_search_or_play : 1;
276  unsigned int title_or_time_play : 1; /* 0 */
277 } ATTRIBUTE_PACKED user_ops_t;
278 
282 typedef struct {
283  uint16_t zero_1;
284  uint8_t nr_of_programs;
285  uint8_t nr_of_cells;
286  dvd_time_t playback_time;
287  user_ops_t prohibited_ops;
288  uint16_t audio_control[8]; /* New type? */
289  uint32_t subp_control[32]; /* New type? */
290  uint16_t next_pgc_nr;
291  uint16_t prev_pgc_nr;
292  uint16_t goup_pgc_nr;
293  uint8_t still_time;
294  uint8_t pg_playback_mode;
295  uint32_t palette[16]; /* New type struct {zero_1, Y, Cr, Cb} ? */
296  uint16_t command_tbl_offset;
297  uint16_t program_map_offset;
298  uint16_t cell_playback_offset;
299  uint16_t cell_position_offset;
300  pgc_command_tbl_t *command_tbl;
301  pgc_program_map_t *program_map;
302  cell_playback_t *cell_playback;
303  cell_position_t *cell_position;
304  int ref_count;
305 } ATTRIBUTE_PACKED pgc_t;
306 #define PGC_SIZE 236U
307 
311 typedef struct {
312  uint8_t entry_id;
313  unsigned int block_mode : 2;
314  unsigned int block_type : 2;
315  unsigned int unknown1 : 4;
316  uint16_t ptl_id_mask;
317  uint32_t pgc_start_byte;
318  pgc_t *pgc;
319 } ATTRIBUTE_PACKED pgci_srp_t;
320 #define PGCI_SRP_SIZE 8U
321 
325 typedef struct {
326  uint16_t nr_of_pgci_srp;
327  uint16_t zero_1;
328  uint32_t last_byte;
329  pgci_srp_t *pgci_srp;
330  int ref_count;
331 } ATTRIBUTE_PACKED pgcit_t;
332 #define PGCIT_SIZE 8U
333 
337 typedef struct {
338  uint16_t lang_code;
339  uint8_t lang_extension;
340  uint8_t exists;
341  uint32_t lang_start_byte;
342  pgcit_t *pgcit;
343 } ATTRIBUTE_PACKED pgci_lu_t;
344 #define PGCI_LU_SIZE 8U
345 
349 typedef struct {
350  uint16_t nr_of_lus;
351  uint16_t zero_1;
352  uint32_t last_byte;
353  pgci_lu_t *lu;
354 } ATTRIBUTE_PACKED pgci_ut_t;
355 #define PGCI_UT_SIZE 8U
356 
360 typedef struct {
361  uint16_t vob_id;
362  uint8_t cell_id;
363  uint8_t zero_1;
364  uint32_t start_sector;
365  uint32_t last_sector;
366 } ATTRIBUTE_PACKED cell_adr_t;
367 
371 typedef struct {
372  uint16_t nr_of_vobs; /* VOBs */
373  uint16_t zero_1;
374  uint32_t last_byte;
375  cell_adr_t *cell_adr_table; /* No explicit size given. */
376 } ATTRIBUTE_PACKED c_adt_t;
377 #define C_ADT_SIZE 8U
378 
382 typedef struct {
383  uint32_t last_byte;
384  uint32_t *vobu_start_sectors;
385 } ATTRIBUTE_PACKED vobu_admap_t;
386 #define VOBU_ADMAP_SIZE 4U
387 
388 
389 
390 
400 typedef struct {
401  char vmg_identifier[12];
402  uint32_t vmg_last_sector;
403  uint8_t zero_1[12];
404  uint32_t vmgi_last_sector;
405  uint8_t zero_2;
406  uint8_t specification_version;
407  uint32_t vmg_category;
408  uint16_t vmg_nr_of_volumes;
409  uint16_t vmg_this_volume_nr;
410  uint8_t disc_side;
411  uint8_t zero_3[19];
412  uint16_t vmg_nr_of_title_sets; /* Number of VTSs. */
413  char provider_identifier[32];
414  uint64_t vmg_pos_code;
415  uint8_t zero_4[24];
416  uint32_t vmgi_last_byte;
417  uint32_t first_play_pgc;
418  uint8_t zero_5[56];
419  uint32_t vmgm_vobs; /* sector */
420  uint32_t tt_srpt; /* sector */
421  uint32_t vmgm_pgci_ut; /* sector */
422  uint32_t ptl_mait; /* sector */
423  uint32_t vts_atrt; /* sector */
424  uint32_t txtdt_mgi; /* sector */
425  uint32_t vmgm_c_adt; /* sector */
426  uint32_t vmgm_vobu_admap; /* sector */
427  uint8_t zero_6[32];
428 
429  video_attr_t vmgm_video_attr;
430  uint8_t zero_7;
431  uint8_t nr_of_vmgm_audio_streams; /* should be 0 or 1 */
432  audio_attr_t vmgm_audio_attr;
433  audio_attr_t zero_8[7];
434  uint8_t zero_9[17];
435  uint8_t nr_of_vmgm_subp_streams; /* should be 0 or 1 */
436  subp_attr_t vmgm_subp_attr;
437  subp_attr_t zero_10[27]; /* XXX: how much 'padding' here? */
438 } ATTRIBUTE_PACKED vmgi_mat_t;
439 
440 typedef struct {
441  unsigned int zero_1 : 1;
442  unsigned int multi_or_random_pgc_title : 1; /* 0: one sequential pgc title */
443  unsigned int jlc_exists_in_cell_cmd : 1;
444  unsigned int jlc_exists_in_prepost_cmd : 1;
445  unsigned int jlc_exists_in_button_cmd : 1;
446  unsigned int jlc_exists_in_tt_dom : 1;
447  unsigned int chapter_search_or_play : 1; /* UOP 1 */
448  unsigned int title_or_time_play : 1; /* UOP 0 */
449 } ATTRIBUTE_PACKED playback_type_t;
450 
454 typedef struct {
455  playback_type_t pb_ty;
456  uint8_t nr_of_angles;
457  uint16_t nr_of_ptts;
458  uint16_t parental_id;
459  uint8_t title_set_nr;
460  uint8_t vts_ttn;
461  uint32_t title_set_sector;
462 } ATTRIBUTE_PACKED title_info_t;
463 
467 typedef struct {
468  uint16_t nr_of_srpts;
469  uint16_t zero_1;
470  uint32_t last_byte;
471  title_info_t *title;
472 } ATTRIBUTE_PACKED tt_srpt_t;
473 #define TT_SRPT_SIZE 8U
474 
475 
480 #define PTL_MAIT_NUM_LEVEL 8
481 typedef uint16_t pf_level_t[PTL_MAIT_NUM_LEVEL];
482 
486 typedef struct {
487  uint16_t country_code;
488  uint16_t zero_1;
489  uint16_t pf_ptl_mai_start_byte;
490  uint16_t zero_2;
491  pf_level_t *pf_ptl_mai; /* table of (nr_of_vtss + 1), video_ts is first */
492 } ATTRIBUTE_PACKED ptl_mait_country_t;
493 #define PTL_MAIT_COUNTRY_SIZE 8U
494 
498 typedef struct {
499  uint16_t nr_of_countries;
500  uint16_t nr_of_vtss;
501  uint32_t last_byte;
502  ptl_mait_country_t *countries;
503 } ATTRIBUTE_PACKED ptl_mait_t;
504 #define PTL_MAIT_SIZE 8U
505 
509 typedef struct {
510  uint32_t last_byte;
511  uint32_t vts_cat;
512 
513  video_attr_t vtsm_vobs_attr;
514  uint8_t zero_1;
515  uint8_t nr_of_vtsm_audio_streams; /* should be 0 or 1 */
516  audio_attr_t vtsm_audio_attr;
517  audio_attr_t zero_2[7];
518  uint8_t zero_3[16];
519  uint8_t zero_4;
520  uint8_t nr_of_vtsm_subp_streams; /* should be 0 or 1 */
521  subp_attr_t vtsm_subp_attr;
522  subp_attr_t zero_5[27];
523 
524  uint8_t zero_6[2];
525 
526  video_attr_t vtstt_vobs_video_attr;
527  uint8_t zero_7;
528  uint8_t nr_of_vtstt_audio_streams;
529  audio_attr_t vtstt_audio_attr[8];
530  uint8_t zero_8[16];
531  uint8_t zero_9;
532  uint8_t nr_of_vtstt_subp_streams;
533  subp_attr_t vtstt_subp_attr[32];
534 } ATTRIBUTE_PACKED vts_attributes_t;
535 #define VTS_ATTRIBUTES_SIZE 542U
536 #define VTS_ATTRIBUTES_MIN_SIZE 356U
537 
541 typedef struct {
542  uint16_t nr_of_vtss;
543  uint16_t zero_1;
544  uint32_t last_byte;
545  vts_attributes_t *vts;
546  uint32_t *vts_atrt_offsets; /* offsets table for each vts_attributes */
547 } ATTRIBUTE_PACKED vts_atrt_t;
548 #define VTS_ATRT_SIZE 8U
549 
553 typedef struct {
554  uint32_t last_byte; /* offsets are relative here */
555  uint16_t offsets[100]; /* == nr_of_srpts + 1 (first is disc title) */
556 #if 0
557  uint16_t unknown; /* 0x48 ?? 0x48 words (16bit) info following */
558  uint16_t zero_1;
559 
560  uint8_t type_of_info; /* ?? 01 == disc, 02 == Title, 04 == Title part */
561  uint8_t unknown1;
562  uint8_t unknown2;
563  uint8_t unknown3;
564  uint8_t unknown4; /* ?? allways 0x30 language?, text format? */
565  uint8_t unknown5;
566  uint16_t offset; /* from first */
567 
568  char text[12]; /* ended by 0x09 */
569 #endif
570 } ATTRIBUTE_PACKED txtdt_t;
571 
575 typedef struct {
576  uint16_t lang_code;
577  uint16_t unknown; /* 0x0001, title 1? disc 1? side 1? */
578  uint32_t txtdt_start_byte; /* prt, rel start of vmg_txtdt_mgi */
579  txtdt_t *txtdt;
580 } ATTRIBUTE_PACKED txtdt_lu_t;
581 #define TXTDT_LU_SIZE 8U
582 
586 typedef struct {
587  char disc_name[14]; /* how many bytes?? */
588  uint16_t nr_of_language_units; /* 32bit?? */
589  uint32_t last_byte;
590  txtdt_lu_t *lu;
591 } ATTRIBUTE_PACKED txtdt_mgi_t;
592 #define TXTDT_MGI_SIZE 20U
593 
594 
604 typedef struct {
605  char vts_identifier[12];
606  uint32_t vts_last_sector;
607  uint8_t zero_1[12];
608  uint32_t vtsi_last_sector;
609  uint8_t zero_2;
610  uint8_t specification_version;
611  uint32_t vts_category;
612  uint16_t zero_3;
613  uint16_t zero_4;
614  uint8_t zero_5;
615  uint8_t zero_6[19];
616  uint16_t zero_7;
617  uint8_t zero_8[32];
618  uint64_t zero_9;
619  uint8_t zero_10[24];
620  uint32_t vtsi_last_byte;
621  uint32_t zero_11;
622  uint8_t zero_12[56];
623  uint32_t vtsm_vobs; /* sector */
624  uint32_t vtstt_vobs; /* sector */
625  uint32_t vts_ptt_srpt; /* sector */
626  uint32_t vts_pgcit; /* sector */
627  uint32_t vtsm_pgci_ut; /* sector */
628  uint32_t vts_tmapt; /* sector */
629  uint32_t vtsm_c_adt; /* sector */
630  uint32_t vtsm_vobu_admap; /* sector */
631  uint32_t vts_c_adt; /* sector */
632  uint32_t vts_vobu_admap; /* sector */
633  uint8_t zero_13[24];
634 
635  video_attr_t vtsm_video_attr;
636  uint8_t zero_14;
637  uint8_t nr_of_vtsm_audio_streams; /* should be 0 or 1 */
638  audio_attr_t vtsm_audio_attr;
639  audio_attr_t zero_15[7];
640  uint8_t zero_16[17];
641  uint8_t nr_of_vtsm_subp_streams; /* should be 0 or 1 */
642  subp_attr_t vtsm_subp_attr;
643  subp_attr_t zero_17[27];
644  uint8_t zero_18[2];
645 
646  video_attr_t vts_video_attr;
647  uint8_t zero_19;
648  uint8_t nr_of_vts_audio_streams;
649  audio_attr_t vts_audio_attr[8];
650  uint8_t zero_20[17];
651  uint8_t nr_of_vts_subp_streams;
652  subp_attr_t vts_subp_attr[32];
653  uint16_t zero_21;
654  multichannel_ext_t vts_mu_audio_attr[8];
655  /* XXX: how much 'padding' here, if any? */
656 } ATTRIBUTE_PACKED vtsi_mat_t;
657 
661 typedef struct {
662  uint16_t pgcn;
663  uint16_t pgn;
664 } ATTRIBUTE_PACKED ptt_info_t;
665 
669 typedef struct {
670  uint16_t nr_of_ptts;
671  ptt_info_t *ptt;
672 } ATTRIBUTE_PACKED ttu_t;
673 
677 typedef struct {
678  uint16_t nr_of_srpts;
679  uint16_t zero_1;
680  uint32_t last_byte;
681  ttu_t *title;
682  uint32_t *ttu_offset; /* offset table for each ttu */
683 } ATTRIBUTE_PACKED vts_ptt_srpt_t;
684 #define VTS_PTT_SRPT_SIZE 8U
685 
686 
690 /* Should this be bit field at all or just the uint32_t? */
691 typedef uint32_t map_ent_t;
692 
696 typedef struct {
697  uint8_t tmu; /* Time unit, in seconds */
698  uint8_t zero_1;
699  uint16_t nr_of_entries;
700  map_ent_t *map_ent;
701 } ATTRIBUTE_PACKED vts_tmap_t;
702 #define VTS_TMAP_SIZE 4U
703 
707 typedef struct {
708  uint16_t nr_of_tmaps;
709  uint16_t zero_1;
710  uint32_t last_byte;
711  vts_tmap_t *tmap;
712  uint32_t *tmap_offset; /* offset table for each tmap */
713 } ATTRIBUTE_PACKED vts_tmapt_t;
714 #define VTS_TMAPT_SIZE 8U
715 
716 
717 #if PRAGMA_PACK
718 #pragma pack()
719 #endif
720 
721 
728 typedef struct {
729  dvd_file_t *file;
730 
731  /* VMGI */
732  vmgi_mat_t *vmgi_mat;
733  tt_srpt_t *tt_srpt;
734  pgc_t *first_play_pgc;
735  ptl_mait_t *ptl_mait;
736  vts_atrt_t *vts_atrt;
737  txtdt_mgi_t *txtdt_mgi;
738 
739  /* Common */
740  pgci_ut_t *pgci_ut;
741  c_adt_t *menu_c_adt;
742  vobu_admap_t *menu_vobu_admap;
743 
744  /* VTSI */
745  vtsi_mat_t *vtsi_mat;
746  vts_ptt_srpt_t *vts_ptt_srpt;
747  pgcit_t *vts_pgcit;
748  vts_tmapt_t *vts_tmapt;
749  c_adt_t *vts_c_adt;
750  vobu_admap_t *vts_vobu_admap;
751 } ifo_handle_t;
752 
753 #endif /* LIBDVDREAD_IFO_TYPES_H */
Definition: dvd_reader.c:104
Definition: ifo_types.h:728
Definition: ifo_types.h:60