1
#ifndef IFO_TYPES_H_INCLUDED
2
#define IFO_TYPES_H_INCLUDED
5
* Copyright (C) 2000, 2001 Bj�rn Englund <d4bjorn@dtek.chalmers.se>,
6
* H�kan Hjort <d95hjort@dtek.chalmers.se>
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-1307 USA
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 8U
78
unsigned char mpeg_version : 2;
79
unsigned char video_format : 2;
80
unsigned char display_aspect_ratio : 2;
81
unsigned char permitted_df : 2;
83
unsigned char line21_cc_1 : 1;
84
unsigned char line21_cc_2 : 1;
85
unsigned char unknown1 : 1;
86
unsigned char bit_rate : 1;
88
unsigned char picture_size : 2;
89
unsigned char letterboxed : 1;
90
unsigned char film_mode : 1;
91
} ATTRIBUTE_PACKED video_attr_t;
97
unsigned char audio_format : 3;
98
unsigned char multichannel_extension : 1;
99
unsigned char lang_type : 2;
100
unsigned char application_mode : 2;
102
unsigned char quantization : 2;
103
unsigned char sample_frequency : 2;
104
unsigned char unknown1 : 1;
105
unsigned char channels : 3;
107
uint8_t lang_extension;
108
uint8_t code_extension;
111
struct ATTRIBUTE_PACKED {
112
unsigned char unknown4 : 1;
113
unsigned char channel_assignment : 3;
114
unsigned char version : 2;
115
unsigned char mc_intro : 1; /* probably 0: true, 1:false */
116
unsigned char mode : 1; /* Karaoke mode 0: solo 1: duet */
118
struct ATTRIBUTE_PACKED {
119
unsigned char unknown5 : 4;
120
unsigned char dolby_encoded : 1; /* suitable for surround decoding */
121
unsigned char unknown6 : 3;
124
} ATTRIBUTE_PACKED audio_attr_t;
128
* MultiChannel Extension
131
unsigned int zero1 : 7;
132
unsigned int ach0_gme : 1;
134
unsigned int zero2 : 7;
135
unsigned int ach1_gme : 1;
137
unsigned int zero3 : 4;
138
unsigned int ach2_gv1e : 1;
139
unsigned int ach2_gv2e : 1;
140
unsigned int ach2_gm1e : 1;
141
unsigned int ach2_gm2e : 1;
143
unsigned int zero4 : 4;
144
unsigned int ach3_gv1e : 1;
145
unsigned int ach3_gv2e : 1;
146
unsigned int ach3_gmAe : 1;
147
unsigned int ach3_se2e : 1;
149
unsigned int zero5 : 4;
150
unsigned int ach4_gv1e : 1;
151
unsigned int ach4_gv2e : 1;
152
unsigned int ach4_gmBe : 1;
153
unsigned int ach4_seBe : 1;
155
} ATTRIBUTE_PACKED multichannel_ext_t;
159
* Subpicture Attributes.
163
* type: 0 not specified
166
* coding mode: 0 run length
169
* language: indicates language if type == 1
170
* lang extension: if type == 1 contains the lang extension
172
unsigned char code_mode : 3;
173
unsigned char zero1 : 3;
174
unsigned char type : 2;
177
uint8_t lang_extension;
178
uint8_t code_extension;
179
} ATTRIBUTE_PACKED subp_attr_t;
194
} ATTRIBUTE_PACKED pgc_command_tbl_t;
195
#define PGC_COMMAND_TBL_SIZE 8U
200
typedef uint8_t pgc_program_map_t;
203
* Cell Playback Information.
206
unsigned int block_mode : 2;
207
unsigned int block_type : 2;
208
unsigned int seamless_play : 1;
209
unsigned int interleaved : 1;
210
unsigned int stc_discontinuity: 1;
211
unsigned int seamless_angle : 1;
212
unsigned int playback_mode : 1; /**< When set, enter StillMode after each VOBU */
213
unsigned int restricted : 1; /**< ?? drop out of fastforward? */
214
unsigned int unknown2 : 6;
217
dvd_time_t playback_time;
218
uint32_t first_sector;
219
uint32_t first_ilvu_end_sector;
220
uint32_t last_vobu_start_sector;
221
uint32_t last_sector;
222
} ATTRIBUTE_PACKED cell_playback_t;
224
#define BLOCK_TYPE_NONE 0x0
225
#define BLOCK_TYPE_ANGLE_BLOCK 0x1
227
#define BLOCK_MODE_NOT_IN_BLOCK 0x0
228
#define BLOCK_MODE_FIRST_CELL 0x1
229
#define BLOCK_MODE_IN_BLOCK 0x2
230
#define BLOCK_MODE_LAST_CELL 0x3
233
* Cell Position Information.
239
} ATTRIBUTE_PACKED cell_position_t;
245
unsigned int zero : 7; /* 25-31 */
246
unsigned int video_pres_mode_change : 1; /* 24 */
248
unsigned int karaoke_audio_pres_mode_change : 1; /* 23 */
249
unsigned int angle_change : 1;
250
unsigned int subpic_stream_change : 1;
251
unsigned int audio_stream_change : 1;
252
unsigned int pause_on : 1;
253
unsigned int still_off : 1;
254
unsigned int button_select_or_activate : 1;
255
unsigned int resume : 1; /* 16 */
257
unsigned int chapter_menu_call : 1; /* 15 */
258
unsigned int angle_menu_call : 1;
259
unsigned int audio_menu_call : 1;
260
unsigned int subpic_menu_call : 1;
261
unsigned int root_menu_call : 1;
262
unsigned int title_menu_call : 1;
263
unsigned int backward_scan : 1;
264
unsigned int forward_scan : 1; /* 8 */
266
unsigned int next_pg_search : 1; /* 7 */
267
unsigned int prev_or_top_pg_search : 1;
268
unsigned int time_or_chapter_search : 1;
269
unsigned int go_up : 1;
270
unsigned int stop : 1;
271
unsigned int title_play : 1;
272
unsigned int chapter_search_or_play : 1;
273
unsigned int title_or_time_play : 1; /* 0 */
274
} ATTRIBUTE_PACKED user_ops_t;
277
* Program Chain Information.
281
uint8_t nr_of_programs;
283
dvd_time_t playback_time;
284
user_ops_t prohibited_ops;
285
uint16_t audio_control[8]; /* New type? */
286
uint32_t subp_control[32]; /* New type? */
287
uint16_t next_pgc_nr;
288
uint16_t prev_pgc_nr;
289
uint16_t goup_pgc_nr;
291
uint8_t pg_playback_mode;
292
uint32_t palette[16]; /* New type struct {zero_1, Y, Cr, Cb} ? */
293
uint16_t command_tbl_offset;
294
uint16_t program_map_offset;
295
uint16_t cell_playback_offset;
296
uint16_t cell_position_offset;
297
pgc_command_tbl_t *command_tbl;
298
pgc_program_map_t *program_map;
299
cell_playback_t *cell_playback;
300
cell_position_t *cell_position;
301
} ATTRIBUTE_PACKED pgc_t;
302
#define PGC_SIZE 236U
305
* Program Chain Information Search Pointer.
309
unsigned int block_mode : 2;
310
unsigned int block_type : 2;
311
unsigned int unknown1 : 4;
312
uint16_t ptl_id_mask;
313
uint32_t pgc_start_byte;
315
} ATTRIBUTE_PACKED pgci_srp_t;
316
#define PGCI_SRP_SIZE 8U
319
* Program Chain Information Table.
322
uint16_t nr_of_pgci_srp;
325
pgci_srp_t *pgci_srp;
326
} ATTRIBUTE_PACKED pgcit_t;
327
#define PGCIT_SIZE 8U
330
* Menu PGCI Language Unit.
334
uint8_t lang_extension;
336
uint32_t lang_start_byte;
338
} ATTRIBUTE_PACKED pgci_lu_t;
339
#define PGCI_LU_SIZE 8U
342
* Menu PGCI Unit Table.
349
} ATTRIBUTE_PACKED pgci_ut_t;
350
#define PGCI_UT_SIZE 8U
353
* Cell Address Information.
359
uint32_t start_sector;
360
uint32_t last_sector;
361
} ATTRIBUTE_PACKED cell_adr_t;
364
* Cell Address Table.
367
uint16_t nr_of_vobs; /* VOBs */
370
cell_adr_t *cell_adr_table; /* No explicit size given. */
371
} ATTRIBUTE_PACKED c_adt_t;
372
#define C_ADT_SIZE 8U
379
uint32_t *vobu_start_sectors;
380
} ATTRIBUTE_PACKED vobu_admap_t;
381
#define VOBU_ADMAP_SIZE 4U
389
* The following structures relate to the Video Manager.
393
* Video Manager Information Management Table.
396
char vmg_identifier[12];
397
uint32_t vmg_last_sector;
399
uint32_t vmgi_last_sector;
401
uint8_t specification_version;
402
uint32_t vmg_category;
403
uint16_t vmg_nr_of_volumes;
404
uint16_t vmg_this_volume_nr;
407
uint16_t vmg_nr_of_title_sets; /* Number of VTSs. */
408
char provider_identifier[32];
409
uint64_t vmg_pos_code;
411
uint32_t vmgi_last_byte;
412
uint32_t first_play_pgc;
414
uint32_t vmgm_vobs; /* sector */
415
uint32_t tt_srpt; /* sector */
416
uint32_t vmgm_pgci_ut; /* sector */
417
uint32_t ptl_mait; /* sector */
418
uint32_t vts_atrt; /* sector */
419
uint32_t txtdt_mgi; /* sector */
420
uint32_t vmgm_c_adt; /* sector */
421
uint32_t vmgm_vobu_admap; /* sector */
424
video_attr_t vmgm_video_attr;
426
uint8_t nr_of_vmgm_audio_streams; /* should be 0 or 1 */
427
audio_attr_t vmgm_audio_attr;
428
audio_attr_t zero_8[7];
430
uint8_t nr_of_vmgm_subp_streams; /* should be 0 or 1 */
431
subp_attr_t vmgm_subp_attr;
432
subp_attr_t zero_10[27]; /* XXX: how much 'padding' here? */
433
} ATTRIBUTE_PACKED vmgi_mat_t;
436
unsigned int zero_1 : 1;
437
unsigned int multi_or_random_pgc_title : 1; /* 0: one sequential pgc title */
438
unsigned int jlc_exists_in_cell_cmd : 1;
439
unsigned int jlc_exists_in_prepost_cmd : 1;
440
unsigned int jlc_exists_in_button_cmd : 1;
441
unsigned int jlc_exists_in_tt_dom : 1;
442
unsigned int chapter_search_or_play : 1; /* UOP 1 */
443
unsigned int title_or_time_play : 1; /* UOP 0 */
444
} ATTRIBUTE_PACKED playback_type_t;
450
playback_type_t pb_ty;
451
uint8_t nr_of_angles;
453
uint16_t parental_id;
454
uint8_t title_set_nr;
456
uint32_t title_set_sector;
457
} ATTRIBUTE_PACKED title_info_t;
460
* PartOfTitle Search Pointer Table.
463
uint16_t nr_of_srpts;
467
} ATTRIBUTE_PACKED tt_srpt_t;
468
#define TT_SRPT_SIZE 8U
472
* Parental Management Information Unit Table.
473
* Level 1 (US: G), ..., 7 (US: NC-17), 8
475
typedef uint16_t pf_level_t[8];
478
* Parental Management Information Unit Table.
481
uint16_t country_code;
483
uint16_t pf_ptl_mai_start_byte;
485
pf_level_t *pf_ptl_mai; /* table of (nr_of_vtss + 1), video_ts is first */
486
} ATTRIBUTE_PACKED ptl_mait_country_t;
487
#define PTL_MAIT_COUNTRY_SIZE 8U
490
* Parental Management Information Table.
493
uint16_t nr_of_countries;
496
ptl_mait_country_t *countries;
497
} ATTRIBUTE_PACKED ptl_mait_t;
498
#define PTL_MAIT_SIZE 8U
501
* Video Title Set Attributes.
507
video_attr_t vtsm_vobs_attr;
509
uint8_t nr_of_vtsm_audio_streams; /* should be 0 or 1 */
510
audio_attr_t vtsm_audio_attr;
511
audio_attr_t zero_2[7];
514
uint8_t nr_of_vtsm_subp_streams; /* should be 0 or 1 */
515
subp_attr_t vtsm_subp_attr;
516
subp_attr_t zero_5[27];
520
video_attr_t vtstt_vobs_video_attr;
522
uint8_t nr_of_vtstt_audio_streams;
523
audio_attr_t vtstt_audio_attr[8];
526
uint8_t nr_of_vtstt_subp_streams;
527
subp_attr_t vtstt_subp_attr[32];
528
} ATTRIBUTE_PACKED vts_attributes_t;
529
#define VTS_ATTRIBUTES_SIZE 542U
530
#define VTS_ATTRIBUTES_MIN_SIZE 356U
533
* Video Title Set Attribute Table.
539
vts_attributes_t *vts;
540
uint32_t *vts_atrt_offsets; /* offsets table for each vts_attributes */
541
} ATTRIBUTE_PACKED vts_atrt_t;
542
#define VTS_ATRT_SIZE 8U
545
* Text Data. (Incomplete)
548
uint32_t last_byte; /* offsets are relative here */
549
uint16_t offsets[100]; /* == nr_of_srpts + 1 (first is disc title) */
551
uint16_t unknown; /* 0x48 ?? 0x48 words (16bit) info following */
554
uint8_t type_of_info; /* ?? 01 == disc, 02 == Title, 04 == Title part */
558
uint8_t unknown4; /* ?? allways 0x30 language?, text format? */
560
uint16_t offset; /* from first */
562
char text[12]; /* ended by 0x09 */
564
} ATTRIBUTE_PACKED txtdt_t;
567
* Text Data Language Unit. (Incomplete)
571
uint16_t unknown; /* 0x0001, title 1? disc 1? side 1? */
572
uint32_t txtdt_start_byte; /* prt, rel start of vmg_txtdt_mgi */
574
} ATTRIBUTE_PACKED txtdt_lu_t;
575
#define TXTDT_LU_SIZE 8U
578
* Text Data Manager Information. (Incomplete)
581
char disc_name[14]; /* how many bytes?? */
582
uint16_t nr_of_language_units; /* 32bit?? */
585
} ATTRIBUTE_PACKED txtdt_mgi_t;
586
#define TXTDT_MGI_SIZE 20U
592
* Structures relating to the Video Title Set (VTS).
596
* Video Title Set Information Management Table.
599
char vts_identifier[12];
600
uint32_t vts_last_sector;
602
uint32_t vtsi_last_sector;
604
uint8_t specification_version;
605
uint32_t vts_category;
614
uint32_t vtsi_last_byte;
617
uint32_t vtsm_vobs; /* sector */
618
uint32_t vtstt_vobs; /* sector */
619
uint32_t vts_ptt_srpt; /* sector */
620
uint32_t vts_pgcit; /* sector */
621
uint32_t vtsm_pgci_ut; /* sector */
622
uint32_t vts_tmapt; /* sector */
623
uint32_t vtsm_c_adt; /* sector */
624
uint32_t vtsm_vobu_admap; /* sector */
625
uint32_t vts_c_adt; /* sector */
626
uint32_t vts_vobu_admap; /* sector */
629
video_attr_t vtsm_video_attr;
631
uint8_t nr_of_vtsm_audio_streams; /* should be 0 or 1 */
632
audio_attr_t vtsm_audio_attr;
633
audio_attr_t zero_15[7];
635
uint8_t nr_of_vtsm_subp_streams; /* should be 0 or 1 */
636
subp_attr_t vtsm_subp_attr;
637
subp_attr_t zero_17[27];
640
video_attr_t vts_video_attr;
642
uint8_t nr_of_vts_audio_streams;
643
audio_attr_t vts_audio_attr[8];
645
uint8_t nr_of_vts_subp_streams;
646
subp_attr_t vts_subp_attr[32];
648
multichannel_ext_t vts_mu_audio_attr[8];
649
/* XXX: how much 'padding' here, if any? */
650
} ATTRIBUTE_PACKED vtsi_mat_t;
653
* PartOfTitle Unit Information.
658
} ATTRIBUTE_PACKED ptt_info_t;
661
* PartOfTitle Information.
666
} ATTRIBUTE_PACKED ttu_t;
669
* PartOfTitle Search Pointer Table.
672
uint16_t nr_of_srpts;
676
uint32_t *ttu_offset; /* offset table for each ttu */
677
} ATTRIBUTE_PACKED vts_ptt_srpt_t;
678
#define VTS_PTT_SRPT_SIZE 8U
684
/* Should this be bit field at all or just the uint32_t? */
685
typedef uint32_t map_ent_t;
691
uint8_t tmu; /* Time unit, in seconds */
693
uint16_t nr_of_entries;
695
} ATTRIBUTE_PACKED vts_tmap_t;
696
#define VTS_TMAP_SIZE 4U
702
uint16_t nr_of_tmaps;
706
uint32_t *tmap_offset; /* offset table for each tmap */
707
} ATTRIBUTE_PACKED vts_tmapt_t;
708
#define VTS_TMAPT_SIZE 8U
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
vts_tmapt_t *vts_tmapt;
744
vobu_admap_t *vts_vobu_admap;
747
#endif /* IFO_TYPES_H_INCLUDED */