| 1 | /* |
| 2 | * Copyright (C) 2000, 2001, 2002 Håkan Hjort <[email protected]> |
| 3 | * |
| 4 | * The data structures in this file should represent the layout of the |
| 5 | * pci and dsi packets as they are stored in the stream. Information |
| 6 | * found by reading the source to VOBDUMP is the base for the structure |
| 7 | * and names of these data types. |
| 8 | * |
| 9 | * VOBDUMP: a program for examining DVD .VOB files. |
| 10 | * Copyright 1998, 1999 Eric Smith <[email protected]> |
| 11 | * |
| 12 | * VOBDUMP is free software; you can redistribute it and/or modify it |
| 13 | * under the terms of the GNU General Public License version 2 or version 3 as |
| 14 | * published by the Free Software Foundation. Note that I am not |
| 15 | * granting permission to redistribute or modify VOBDUMP under the terms |
| 16 | * of any later version of the General Public License. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful (or at |
| 19 | * least amusing), but WITHOUT ANY WARRANTY; without even the implied |
| 20 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 21 | * the GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with this program; if not, write to the Free Software Foundation, |
| 25 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 26 | */ |
| 27 | |
| 28 | #ifndef LIBDVDREAD_NAV_TYPES_H |
| 29 | #define LIBDVDREAD_NAV_TYPES_H |
| 30 | |
| 31 | #include <inttypes.h> |
| 32 | |
| 33 | #include <dvdread/attributes.h> |
| 34 | #include <dvdread/ifo_types.h> /* only dvd_time_t, vm_cmd_t and user_ops_t */ |
| 35 | |
| 36 | /* The length including the substream id byte. */ |
| 37 | #define PCI_BYTES 0x3d4 |
| 38 | #define DSI_BYTES 0x3fa |
| 39 | |
| 40 | #define PS2_PCI_SUBSTREAM_ID 0x00 |
| 41 | #define PS2_DSI_SUBSTREAM_ID 0x01 |
| 42 | |
| 43 | /* Remove this */ |
| 44 | #define DSI_START_BYTE 1031 |
| 45 | |
| 46 | /** |
| 47 | * PCI General Information |
| 48 | */ |
| 49 | typedef struct { |
| 50 | uint32_t nv_pck_lbn; /**< sector address of this nav pack */ |
| 51 | uint16_t vobu_cat; /**< 'category' of vobu */ |
| 52 | uint16_t zero1; /**< reserved */ |
| 53 | user_ops_t vobu_uop_ctl; /**< UOP of vobu */ |
| 54 | uint32_t vobu_s_ptm; /**< start presentation time of vobu */ |
| 55 | uint32_t vobu_e_ptm; /**< end presentation time of vobu */ |
| 56 | uint32_t vobu_se_e_ptm; /**< end ptm of sequence end in vobu */ |
| 57 | dvd_time_t e_eltm; /**< Cell elapsed time */ |
| 58 | char vobu_isrc[32]; |
| 59 | } ATTRIBUTE_PACKED pci_gi_t; |
| 60 | |
| 61 | /** |
| 62 | * Non Seamless Angle Information |
| 63 | */ |
| 64 | typedef struct { |
| 65 | uint32_t nsml_agl_dsta[9]; /**< address of destination vobu in AGL_C#n */ |
| 66 | } ATTRIBUTE_PACKED nsml_agli_t; |
| 67 | |
| 68 | /** |
| 69 | * Highlight General Information |
| 70 | * |
| 71 | * For btngrX_dsp_ty the bits have the following meaning: |
| 72 | * 000b: normal 4/3 only buttons |
| 73 | * XX1b: wide (16/9) buttons |
| 74 | * X1Xb: letterbox buttons |
| 75 | * 1XXb: pan&scan buttons |
| 76 | */ |
| 77 | typedef struct { |
| 78 | uint16_t hli_ss; /**< status, only low 2 bits 0: no buttons, 1: different 2: equal 3: eual except for button cmds */ |
| 79 | uint32_t hli_s_ptm; /**< start ptm of hli */ |
| 80 | uint32_t hli_e_ptm; /**< end ptm of hli */ |
| 81 | uint32_t btn_se_e_ptm; /**< end ptm of button select */ |
| 82 | unsigned char zero1 : 2; /**< reserved */ |
| 83 | unsigned char btngr_ns : 2; /**< number of button groups 1, 2 or 3 with 36/18/12 buttons */ |
| 84 | unsigned char zero2 : 1; /**< reserved */ |
| 85 | unsigned char btngr1_dsp_ty : 3; /**< display type of subpic stream for button group 1 */ |
| 86 | unsigned char zero3 : 1; /**< reserved */ |
| 87 | unsigned char btngr2_dsp_ty : 3; /**< display type of subpic stream for button group 2 */ |
| 88 | unsigned char zero4 : 1; /**< reserved */ |
| 89 | unsigned char btngr3_dsp_ty : 3; /**< display type of subpic stream for button group 3 */ |
| 90 | uint8_t btn_ofn; /**< button offset number range 0-255 */ |
| 91 | uint8_t btn_ns; /**< number of valid buttons <= 36/18/12 (low 6 bits) */ |
| 92 | uint8_t nsl_btn_ns; /**< number of buttons selectable by U_BTNNi (low 6 bits) nsl_btn_ns <= btn_ns */ |
| 93 | uint8_t zero5; /**< reserved */ |
| 94 | uint8_t fosl_btnn; /**< forcedly selected button (low 6 bits) */ |
| 95 | uint8_t foac_btnn; /**< forcedly activated button (low 6 bits) */ |
| 96 | } ATTRIBUTE_PACKED hl_gi_t; |
| 97 | |
| 98 | |
| 99 | /** |
| 100 | * Button Color Information Table |
| 101 | * Each entry is a 32bit word that contains the color indices and alpha |
| 102 | * values to use. They are all represented by 4 bit number and stored |
| 103 | * like this [Ci3, Ci2, Ci1, Ci0, A3, A2, A1, A0]. The actual palette |
| 104 | * that the indexes reference is in the PGC. |
| 105 | * @TODO split the uint32_t into a struct |
| 106 | */ |
| 107 | typedef struct { |
| 108 | uint32_t btn_coli[3][2]; /**< [button color number-1][select:0/action:1] */ |
| 109 | } ATTRIBUTE_PACKED btn_colit_t; |
| 110 | |
| 111 | /** |
| 112 | * Button Information |
| 113 | * |
| 114 | * NOTE: I've had to change the structure from the disk layout to get |
| 115 | * the packing to work with Sun's Forte C compiler. |
| 116 | * The 4 and 7 bytes are 'rotated' was: ABC DEF GHIJ is: ABCG DEFH IJ |
| 117 | */ |
| 118 | typedef struct { |
| 119 | unsigned int btn_coln : 2; /**< button color number */ |
| 120 | unsigned int x_start : 10; /**< x start offset within the overlay */ |
| 121 | unsigned int zero1 : 2; /**< reserved */ |
| 122 | unsigned int x_end : 10; /**< x end offset within the overlay */ |
| 123 | |
| 124 | unsigned int auto_action_mode : 2; /**< 0: no, 1: activated if selected */ |
| 125 | unsigned int y_start : 10; /**< y start offset within the overlay */ |
| 126 | unsigned int zero2 : 2; /**< reserved */ |
| 127 | unsigned int y_end : 10; /**< y end offset within the overlay */ |
| 128 | |
| 129 | unsigned int zero3 : 2; /**< reserved */ |
| 130 | unsigned int up : 6; /**< button index when pressing up */ |
| 131 | unsigned int zero4 : 2; /**< reserved */ |
| 132 | unsigned int down : 6; /**< button index when pressing down */ |
| 133 | unsigned int zero5 : 2; /**< reserved */ |
| 134 | unsigned int left : 6; /**< button index when pressing left */ |
| 135 | unsigned int zero6 : 2; /**< reserved */ |
| 136 | unsigned int right : 6; /**< button index when pressing right */ |
| 137 | vm_cmd_t cmd; |
| 138 | } ATTRIBUTE_PACKED btni_t; |
| 139 | |
| 140 | /** |
| 141 | * Highlight Information |
| 142 | */ |
| 143 | typedef struct { |
| 144 | hl_gi_t hl_gi; |
| 145 | btn_colit_t btn_colit; |
| 146 | btni_t btnit[36]; |
| 147 | } ATTRIBUTE_PACKED hli_t; |
| 148 | |
| 149 | /** |
| 150 | * PCI packet |
| 151 | */ |
| 152 | typedef struct { |
| 153 | pci_gi_t pci_gi; |
| 154 | nsml_agli_t nsml_agli; |
| 155 | hli_t hli; |
| 156 | uint8_t zero1[189]; |
| 157 | } ATTRIBUTE_PACKED pci_t; |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | /** |
| 163 | * DSI General Information |
| 164 | */ |
| 165 | typedef struct { |
| 166 | uint32_t nv_pck_scr; |
| 167 | uint32_t nv_pck_lbn; /**< sector address of this nav pack */ |
| 168 | uint32_t vobu_ea; /**< end address of this VOBU */ |
| 169 | uint32_t vobu_1stref_ea; /**< end address of the 1st reference image */ |
| 170 | uint32_t vobu_2ndref_ea; /**< end address of the 2nd reference image */ |
| 171 | uint32_t vobu_3rdref_ea; /**< end address of the 3rd reference image */ |
| 172 | uint16_t vobu_vob_idn; /**< VOB Id number that this VOBU is part of */ |
| 173 | uint8_t zero1; /**< reserved */ |
| 174 | uint8_t vobu_c_idn; /**< Cell Id number that this VOBU is part of */ |
| 175 | dvd_time_t c_eltm; /**< Cell elapsed time */ |
| 176 | } ATTRIBUTE_PACKED dsi_gi_t; |
| 177 | |
| 178 | /** |
| 179 | * Seamless Playback Information |
| 180 | */ |
| 181 | typedef struct { |
| 182 | uint16_t category; /**< 'category' of seamless VOBU */ |
| 183 | uint32_t ilvu_ea; /**< end address of interleaved Unit */ |
| 184 | uint32_t ilvu_sa; /**< start address of next interleaved unit */ |
| 185 | uint16_t size; /**< size of next interleaved unit */ |
| 186 | uint32_t vob_v_s_s_ptm; /**< video start ptm in vob */ |
| 187 | uint32_t vob_v_e_e_ptm; /**< video end ptm in vob */ |
| 188 | struct { |
| 189 | uint32_t stp_ptm1; |
| 190 | uint32_t stp_ptm2; |
| 191 | uint32_t gap_len1; |
| 192 | uint32_t gap_len2; |
| 193 | } vob_a[8]; |
| 194 | } ATTRIBUTE_PACKED sml_pbi_t; |
| 195 | |
| 196 | /** |
| 197 | * Seamless Angle Information for one angle |
| 198 | */ |
| 199 | typedef struct { |
| 200 | uint32_t address; /**< offset to next ILVU, high bit is before/after */ |
| 201 | uint16_t size; /**< byte size of the ILVU pointed to by address */ |
| 202 | } ATTRIBUTE_PACKED sml_agl_data_t; |
| 203 | |
| 204 | /** |
| 205 | * Seamless Angle Information |
| 206 | */ |
| 207 | typedef struct { |
| 208 | sml_agl_data_t data[9]; |
| 209 | } ATTRIBUTE_PACKED sml_agli_t; |
| 210 | |
| 211 | /** |
| 212 | * VOBU Search Information |
| 213 | */ |
| 214 | typedef struct { |
| 215 | uint32_t next_video; /**< Next vobu that contains video */ |
| 216 | uint32_t fwda[19]; /**< Forwards, time */ |
| 217 | uint32_t next_vobu; |
| 218 | uint32_t prev_vobu; |
| 219 | uint32_t bwda[19]; /**< Backwards, time */ |
| 220 | uint32_t prev_video; |
| 221 | } ATTRIBUTE_PACKED vobu_sri_t; |
| 222 | |
| 223 | #define SRI_END_OF_CELL 0x3fffffff |
| 224 | |
| 225 | /** |
| 226 | * Synchronous Information |
| 227 | */ |
| 228 | typedef struct { |
| 229 | uint16_t a_synca[8]; /**< offset to first audio packet for this VOBU */ |
| 230 | uint32_t sp_synca[32]; /**< offset to first subpicture packet */ |
| 231 | } ATTRIBUTE_PACKED synci_t; |
| 232 | |
| 233 | /** |
| 234 | * DSI packet |
| 235 | */ |
| 236 | typedef struct { |
| 237 | dsi_gi_t dsi_gi; |
| 238 | sml_pbi_t sml_pbi; |
| 239 | sml_agli_t sml_agli; |
| 240 | vobu_sri_t vobu_sri; |
| 241 | synci_t synci; |
| 242 | uint8_t zero1[471]; |
| 243 | } ATTRIBUTE_PACKED dsi_t; |
| 244 | |
| 245 | |
| 246 | #if PRAGMA_PACK |
| 247 | #pragma pack() |
| 248 | #endif |
| 249 | |
| 250 | #endif /* LIBDVDREAD_NAV_TYPES_H */ |