2 * Copyright (C) 2000 Björn Englund <d4bjorn@dtek.chalmers.se>,
3 * Håkan Hjort <d95hjort@dtek.chalmers.se>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef IFO_TYPES_H_INCLUDED
21 #define IFO_TYPES_H_INCLUDED
24 #include "dvd_reader.h"
27 #undef ATTRIBUTE_PACKED
28 #undef PRAGMA_PACK_BEGIN
29 #undef PRAGMA_PACK_END
32 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
33 #define ATTRIBUTE_PACKED __attribute__ ((packed))
38 #if !defined(ATTRIBUTE_PACKED)
39 #define ATTRIBUTE_PACKED
51 * The following structures are used in both the VMGI and VTSI.
56 * DVD Time Information.
62 uint8_t frame_u; // The two high bits are the frame rate.
63 } ATTRIBUTE_PACKED dvd_time_t;
66 * Type to store per-command data.
70 } ATTRIBUTE_PACKED vm_cmd_t;
71 #define COMMAND_DATA_SIZE 8
78 #ifdef WORDS_BIGENDIAN
79 unsigned int mpeg_version : 2;
80 unsigned int video_format : 2;
81 unsigned int display_aspect_ratio : 2;
82 unsigned int permitted_df : 2;
84 unsigned int line21_cc_1 : 1;
85 unsigned int line21_cc_2 : 1;
86 unsigned int unknown1 : 2;
88 unsigned int picture_size : 2;
89 unsigned int letterboxed : 1;
90 unsigned int film_mode : 1;
92 unsigned int permitted_df : 2;
93 unsigned int display_aspect_ratio : 2;
94 unsigned int video_format : 2;
95 unsigned int mpeg_version : 2;
97 unsigned int film_mode : 1;
98 unsigned int letterboxed : 1;
99 unsigned int picture_size : 2;
101 unsigned int unknown1 : 2;
102 unsigned int line21_cc_2 : 1;
103 unsigned int line21_cc_1 : 1;
105 } ATTRIBUTE_PACKED video_attr_t;
108 * Audio Attributes. (Incomplete/Wrong?)
111 #ifdef WORDS_BIGENDIAN
112 unsigned int audio_format : 3;
113 unsigned int multichannel_extension : 1;
114 unsigned int lang_type : 2;
115 unsigned int application_mode : 2;
117 unsigned int quantization : 2;
118 unsigned int sample_frequency : 2;
119 unsigned int unknown1 : 1;
120 unsigned int channels : 3;
122 unsigned int application_mode : 2;
123 unsigned int lang_type : 2;
124 unsigned int multichannel_extension : 1;
125 unsigned int audio_format : 3;
127 unsigned int channels : 3;
128 unsigned int unknown1 : 1;
129 unsigned int sample_frequency : 2;
130 unsigned int quantization : 2;
133 uint8_t lang_code2; // ??
134 uint8_t lang_extension;
136 } ATTRIBUTE_PACKED audio_attr_t;
139 * Subpicture Attributes.(Incomplete/Wrong)
143 * type: 0 not specified
146 * coding mode: 0 run length
149 * language: indicates language if type == 1
150 * lang extension: if type == 1 contains the lang extension
155 uint8_t lang_extension;
157 } ATTRIBUTE_PACKED subp_attr_t;
172 } ATTRIBUTE_PACKED pgc_command_tbl_t;
173 #define PGC_COMMAND_TBL_SIZE 8
178 typedef uint8_t pgc_program_map_t;
181 * Cell Playback Information.
184 #ifdef WORDS_BIGENDIAN
185 unsigned int block_mode : 2;
186 unsigned int block_type : 2;
187 unsigned int seamless_play : 1;
188 unsigned int interleaved : 1;
189 unsigned int stc_discontinuity: 1;
190 unsigned int seamless_angle : 1;
192 unsigned int unknown1 : 1;
193 unsigned int restricted : 1;
194 unsigned int unknown2 : 6;
196 unsigned int seamless_angle : 1;
197 unsigned int stc_discontinuity: 1;
198 unsigned int interleaved : 1;
199 unsigned int seamless_play : 1;
200 unsigned int block_type : 2;
201 unsigned int block_mode : 2;
203 unsigned int unknown2 : 6;
204 unsigned int restricted : 1;
205 unsigned int unknown1 : 1;
209 dvd_time_t playback_time;
210 uint32_t first_sector;
211 uint32_t first_ilvu_end_sector;
212 uint32_t last_vobu_start_sector;
213 uint32_t last_sector;
214 } ATTRIBUTE_PACKED cell_playback_t;
216 #define BLOCK_TYPE_NONE 0x0
217 #define BLOCK_TYPE_ANGLE_BLOCK 0x1
219 #define BLOCK_MODE_NOT_IN_BLOCK 0x0
220 #define BLOCK_MODE_FIRST_CELL 0x1
221 #define BLOCK_MODE_IN_BLOCK 0x2
222 #define BLOCK_MODE_LAST_CELL 0x3
225 * Cell Position Information.
231 } ATTRIBUTE_PACKED cell_position_t;
237 #ifdef WORDS_BIGENDIAN
238 unsigned int zero : 7; // 25-31
239 unsigned int video_pres_mode_change : 1; // 24
241 unsigned int karaoke_audio_pres_mode_change : 1; // 23
242 unsigned int angle_change : 1; // 22
243 unsigned int subpic_stream_change : 1; // 21
244 unsigned int audio_stream_change : 1; // 20
245 unsigned int pause_on : 1; // 19
246 unsigned int still_off : 1; // 18
247 unsigned int button_select_or_activate : 1; // 17
248 unsigned int resume : 1; // 16
250 unsigned int chapter_menu_call : 1; // 15
251 unsigned int angle_menu_call : 1; // 14
252 unsigned int audio_menu_call : 1; // 13
253 unsigned int subpic_menu_call : 1; // 12
254 unsigned int root_menu_call : 1; // 11
255 unsigned int title_menu_call : 1; // 10
256 unsigned int backward_scan : 1; // 9
257 unsigned int forward_scan : 1; // 8
259 unsigned int next_pg_search : 1; // 7
260 unsigned int prev_or_top_pg_search : 1; // 6
261 unsigned int time_or_chapter_search : 1; // 5
262 unsigned int go_up : 1; // 4
263 unsigned int stop : 1; // 3
264 unsigned int title_play : 1; // 2
265 unsigned int chapter_search_or_play : 1; // 1
266 unsigned int title_or_time_play : 1; // 0
268 unsigned int video_pres_mode_change : 1; // 24
269 unsigned int zero : 7; // 25-31
271 unsigned int resume : 1; // 16
272 unsigned int button_select_or_activate : 1; // 17
273 unsigned int still_off : 1; // 18
274 unsigned int pause_on : 1; // 19
275 unsigned int audio_stream_change : 1; // 20
276 unsigned int subpic_stream_change : 1; // 21
277 unsigned int angle_change : 1; // 22
278 unsigned int karaoke_audio_pres_mode_change : 1; // 23
280 unsigned int forward_scan : 1; // 8
281 unsigned int backward_scan : 1; // 9
282 unsigned int title_menu_call : 1; // 10
283 unsigned int root_menu_call : 1; // 11
284 unsigned int subpic_menu_call : 1; // 12
285 unsigned int audio_menu_call : 1; // 13
286 unsigned int angle_menu_call : 1; // 14
287 unsigned int chapter_menu_call : 1; // 15
289 unsigned int title_or_time_play : 1; // 0
290 unsigned int chapter_search_or_play : 1; // 1
291 unsigned int title_play : 1; // 2
292 unsigned int stop : 1; // 3
293 unsigned int go_up : 1; // 4
294 unsigned int time_or_chapter_search : 1; // 5
295 unsigned int prev_or_top_pg_search : 1; // 6
296 unsigned int next_pg_search : 1; // 7
298 } ATTRIBUTE_PACKED user_ops_t;
301 * Program Chain Information.
305 uint8_t nr_of_programs;
307 dvd_time_t playback_time;
308 user_ops_t prohibited_ops;
309 uint16_t audio_control[8]; /* New type? */
310 uint32_t subp_control[32]; /* New type? */
311 uint16_t next_pgc_nr;
312 uint16_t prev_pgc_nr;
313 uint16_t goup_pgc_nr;
315 uint8_t pg_playback_mode;
316 uint32_t palette[16]; /* New type struct {zero_1, Y, Cr, Cb} ? */
317 uint16_t command_tbl_offset;
318 uint16_t program_map_offset;
319 uint16_t cell_playback_offset;
320 uint16_t cell_position_offset;
321 pgc_command_tbl_t *command_tbl;
322 pgc_program_map_t *program_map;
323 cell_playback_t *cell_playback;
324 cell_position_t *cell_position;
325 } ATTRIBUTE_PACKED pgc_t;
329 * Program Chain Information Search Pointer.
333 #ifdef WORDS_BIGENDIAN
334 unsigned int block_mode : 2;
335 unsigned int block_type : 2;
336 unsigned int unknown1 : 4;
338 unsigned int unknown1 : 4;
339 unsigned int block_type : 2;
340 unsigned int block_mode : 2;
342 uint16_t ptl_id_mask;
343 uint32_t pgc_start_byte;
345 } ATTRIBUTE_PACKED pgci_srp_t;
346 #define PGCI_SRP_SIZE 8
349 * Program Chain Information Table.
352 uint16_t nr_of_pgci_srp;
355 pgci_srp_t *pgci_srp;
356 } ATTRIBUTE_PACKED pgcit_t;
360 * Menu PGCI Language Unit.
366 uint32_t lang_start_byte;
368 } ATTRIBUTE_PACKED pgci_lu_t;
369 #define PGCI_LU_SIZE 8
372 * Menu PGCI Unit Table.
379 } ATTRIBUTE_PACKED pgci_ut_t;
380 #define PGCI_UT_SIZE 8
383 * Cell Address Information.
389 uint32_t start_sector;
390 uint32_t last_sector;
391 } ATTRIBUTE_PACKED cell_adr_t;
394 * Cell Address Table.
397 uint16_t nr_of_vobs; /* VOBs */
400 cell_adr_t *cell_adr_table;
401 } ATTRIBUTE_PACKED c_adt_t;
409 uint32_t *vobu_start_sectors;
410 } ATTRIBUTE_PACKED vobu_admap_t;
411 #define VOBU_ADMAP_SIZE 4
419 * The following structures relate to the Video Manager.
423 * Video Manager Information Management Table.
426 char vmg_identifier[12];
427 uint32_t vmg_last_sector;
429 uint32_t vmgi_last_sector;
431 uint8_t specification_version;
432 uint32_t vmg_category;
433 uint16_t vmg_nr_of_volumes;
434 uint16_t vmg_this_volume_nr;
437 uint16_t vmg_nr_of_title_sets; /* Number of VTSs. */
438 char provider_identifier[32];
439 uint64_t vmg_pos_code;
441 uint32_t vmgi_last_byte;
442 uint32_t first_play_pgc;
444 uint32_t vmgm_vobs; /* sector */
445 uint32_t tt_srpt; /* sector */
446 uint32_t vmgm_pgci_ut; /* sector */
447 uint32_t ptl_mait; /* sector */
448 uint32_t vts_atrt; /* sector */
449 uint32_t txtdt_mgi; /* sector */
450 uint32_t vmgm_c_adt; /* sector */
451 uint32_t vmgm_vobu_admap; /* sector */
454 video_attr_t vmgm_video_attr;
456 uint8_t nr_of_vmgm_audio_streams; // should be 0 or 1
457 audio_attr_t vmgm_audio_attr;
458 audio_attr_t zero_8[7];
460 uint8_t nr_of_vmgm_subp_streams; // should be 0 or 1
461 subp_attr_t vmgm_subp_attr;
462 subp_attr_t zero_10[27]; /* XXX: how much 'padding' here? */
463 } ATTRIBUTE_PACKED vmgi_mat_t;
466 #ifdef WORDS_BIGENDIAN
467 unsigned int zero_1 : 1;
468 unsigned int multi_or_random_pgc_title : 1; // 0 == one sequential pgc title
469 unsigned int jlc_exists_in_cell_cmd : 1;
470 unsigned int jlc_exists_in_prepost_cmd : 1;
471 unsigned int jlc_exists_in_button_cmd : 1;
472 unsigned int jlc_exists_in_tt_dom : 1;
473 unsigned int chapter_search_or_play : 1; // UOP 1
474 unsigned int title_or_time_play : 1; // UOP 0
476 unsigned int title_or_time_play : 1; // UOP 0
477 unsigned int chapter_search_or_play : 1; // UOP 1
478 unsigned int jlc_exists_in_tt_dom : 1;
479 unsigned int jlc_exists_in_button_cmd : 1;
480 unsigned int jlc_exists_in_prepost_cmd : 1;
481 unsigned int jlc_exists_in_cell_cmd : 1;
482 unsigned int multi_or_random_pgc_title : 1; // 0 == one sequential pgc title
483 unsigned int zero_1 : 1;
485 } ATTRIBUTE_PACKED playback_type_t;
491 playback_type_t pb_ty;
492 uint8_t nr_of_angles;
494 uint16_t parental_id;
495 uint8_t title_set_nr;
497 uint32_t title_set_sector;
498 } ATTRIBUTE_PACKED title_info_t;
501 * PartOfTitle Search Pointer Table.
504 uint16_t nr_of_srpts;
508 } ATTRIBUTE_PACKED tt_srpt_t;
509 #define TT_SRPT_SIZE 8
512 * Parental Management Information Unit Table.
515 uint16_t country_code;
517 uint16_t pf_ptl_mai_start_byte;
519 /* uint16_t *pf_ptl_mai // table of nr_of_vtss+1 x 8 */
520 } ATTRIBUTE_PACKED ptl_mait_country_t;
521 #define PTL_MAIT_COUNTRY_SIZE 8
524 * Parental Management Information Table.
527 uint16_t nr_of_countries;
530 ptl_mait_country_t *countries;
531 } ATTRIBUTE_PACKED ptl_mait_t;
532 #define PTL_MAIT_SIZE 8
535 * Video Title Set Attributes.
541 video_attr_t vtsm_vobs_attr;
543 uint8_t nr_of_vtsm_audio_streams; // should be 0 or 1
544 audio_attr_t vtsm_audio_attr;
545 audio_attr_t zero_2[7];
548 uint8_t nr_of_vtsm_subp_streams; // should be 0 or 1
549 subp_attr_t vtsm_subp_attr;
550 subp_attr_t zero_5[27];
554 video_attr_t vtstt_vobs_video_attr;
556 uint8_t nr_of_vtstt_audio_streams;
557 audio_attr_t vtstt_audio_attr[8];
560 uint8_t nr_of_vtstt_subp_streams;
561 subp_attr_t vtstt_subp_attr[32];
562 } ATTRIBUTE_PACKED vts_attributes_t;
563 #define VTS_ATTRIBUTES_SIZE 542
564 #define VTS_ATTRIBUTES_MIN_SIZE 356
567 * Video Title Set Attribute Table.
573 vts_attributes_t *vts;
574 } ATTRIBUTE_PACKED vts_atrt_t;
575 #define VTS_ATRT_SIZE 8
578 * Text Data. (Incomplete)
581 uint32_t last_byte; /* offsets are relative here */
582 uint16_t offsets[100]; /* == nr_of_srpts + 1 (first is disc title) */
584 uint16_t unknown; // 0x48 ?? 0x48 words (16bit) info following
587 uint8_t type_of_info;//?? 01 == disc, 02 == Title, 04 == Title part
591 uint8_t unknown4;//?? allways 0x30 language?, text format?
593 uint16_t offset; // from first
595 char text[12]; // ended by 0x09
597 } ATTRIBUTE_PACKED txtdt_t;
600 * Text Data Language Unit. (Incomplete)
604 uint16_t unknown; /* 0x0001, title 1? disc 1? side 1? */
605 uint32_t txtdt_start_byte; /* prt, rel start of vmg_txtdt_mgi */
607 } ATTRIBUTE_PACKED txtdt_lu_t;
608 #define TXTDT_LU_SIZE 8
611 * Text Data Manager Information. (Incomplete)
614 char disc_name[14]; /* how many bytes?? */
615 uint16_t nr_of_language_units; /* 32bit?? */
618 } ATTRIBUTE_PACKED txtdt_mgi_t;
619 #define TXTDT_MGI_SIZE 20
625 * Structures relating to the Video Title Set (VTS).
629 * Video Title Set Information Management Table.
632 char vts_identifier[12];
633 uint32_t vts_last_sector;
635 uint32_t vtsi_last_sector;
637 uint8_t specification_version;
638 uint32_t vts_category;
647 uint32_t vtsi_last_byte;
650 uint32_t vtsm_vobs; /* sector */
651 uint32_t vtstt_vobs; /* sector */
652 uint32_t vts_ptt_srpt; /* sector */
653 uint32_t vts_pgcit; /* sector */
654 uint32_t vtsm_pgci_ut; /* sector */
655 uint32_t vts_tmapt; /* sector */ // XXX: FIXME TODO Implement
656 uint32_t vtsm_c_adt; /* sector */
657 uint32_t vtsm_vobu_admap; /* sector */
658 uint32_t vts_c_adt; /* sector */
659 uint32_t vts_vobu_admap; /* sector */
662 video_attr_t vtsm_video_attr;
664 uint8_t nr_of_vtsm_audio_streams; // should be 0 or 1
665 audio_attr_t vtsm_audio_attr;
666 audio_attr_t zero_15[7];
668 uint8_t nr_of_vtsm_subp_streams; // should be 0 or 1
669 subp_attr_t vtsm_subp_attr;
670 subp_attr_t zero_17[27];
673 video_attr_t vts_video_attr;
675 uint8_t nr_of_vts_audio_streams;
676 audio_attr_t vts_audio_attr[8];
678 uint8_t nr_of_vts_subp_streams;
679 subp_attr_t vts_subp_attr[32];
680 /* XXX: how much 'padding' here, if any? */
681 } ATTRIBUTE_PACKED vtsi_mat_t;
684 * PartOfTitle Unit Information.
689 } ATTRIBUTE_PACKED ptt_info_t;
692 * PartOfTitle Information.
697 } ATTRIBUTE_PACKED ttu_t;
700 * PartOfTitle Search Pointer Table.
703 uint16_t nr_of_srpts;
707 } ATTRIBUTE_PACKED vts_ptt_srpt_t;
708 #define VTS_PTT_SRPT_SIZE 8
717 * The following structure defines an IFO file. The structure is divided into
718 * two parts, the VMGI, or Video Manager Information, which is read from the
719 * VIDEO_TS.[IFO,BUP] file, and the VTSI, or Video Title Set Information, which
720 * is read in from the VTS_XX_0.[IFO,BUP] files.
726 vmgi_mat_t *vmgi_mat;
728 pgc_t *first_play_pgc;
729 ptl_mait_t *ptl_mait;
730 vts_atrt_t *vts_atrt;
731 txtdt_mgi_t *txtdt_mgi;
736 vobu_admap_t *menu_vobu_admap;
739 vtsi_mat_t *vtsi_mat;
740 vts_ptt_srpt_t *vts_ptt_srpt;
742 int *vts_tmapt; // FIXME add/correct the type
744 vobu_admap_t *vts_vobu_admap;
747 #endif /* IFO_TYPES_H_INCLUDED */