Mercurial > libdvdread4.hg
annotate nav_read.c @ 26:0d82d0f30c98 src
cosmetics: Convert all tabs to spaces.
| author | diego |
|---|---|
| date | Tue, 23 Sep 2008 09:14:45 +0000 |
| parents | 447c5319a522 |
| children | 98951f8ec89c |
| rev | line source |
|---|---|
| 3 | 1 /* |
| 22 | 2 * Copyright (C) 2000, 2001, 2002, 2003 HÃ¥kan Hjort <d95hjort@dtek.chalmers.se> |
| 3 | 3 * |
|
21
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
4 * This file is part of libdvdread. |
|
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
5 * |
|
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
6 * libdvdread is free software; you can redistribute it and/or modify |
| 3 | 7 * it under the terms of the GNU General Public License as published by |
| 8 * the Free Software Foundation; either version 2 of the License, or | |
| 9 * (at your option) any later version. | |
| 10 * | |
|
21
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
11 * libdvdread is distributed in the hope that it will be useful, |
| 3 | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 * GNU General Public License for more details. | |
| 15 * | |
|
21
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
16 * You should have received a copy of the GNU General Public License along |
|
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
17 * with libdvdread; if not, write to the Free Software Foundation, Inc., |
|
4aa618ae094f
Use consistent license headers everywhere: Fix FSF address and boilerplate.
diego
parents:
20
diff
changeset
|
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 3 | 19 */ |
| 20 | |
| 21 #include "config.h" | |
| 22 | |
| 23 #include <stdio.h> | |
| 24 #include <stdlib.h> | |
| 25 #include <string.h> | |
| 26 #include <inttypes.h> | |
| 27 | |
| 28 #include "bswap.h" | |
| 29 #include "nav_types.h" | |
| 30 #include "nav_read.h" | |
| 31 #include "dvdread_internal.h" | |
| 32 #include "bitreader.h" | |
| 33 | |
| 34 #define getbits_init dvdread_getbits_init | |
| 35 #define getbits dvdread_getbits | |
| 36 | |
| 37 void navRead_PCI(pci_t *pci, unsigned char *buffer) { | |
| 38 int32_t i, j; | |
| 39 getbits_state_t state; | |
| 40 if (!getbits_init(&state, buffer)) abort(); /* Passed NULL pointers */ | |
| 41 | |
| 42 /* pci pci_gi */ | |
| 43 pci->pci_gi.nv_pck_lbn = getbits(&state, 32 ); | |
| 44 pci->pci_gi.vobu_cat = getbits(&state, 16 ); | |
| 45 pci->pci_gi.zero1 = getbits(&state, 16 ); | |
| 46 pci->pci_gi.vobu_uop_ctl.zero = getbits(&state, 7 ); | |
| 47 pci->pci_gi.vobu_uop_ctl.video_pres_mode_change = getbits(&state, 1 ); | |
| 48 | |
| 20 | 49 pci->pci_gi.vobu_uop_ctl.karaoke_audio_pres_mode_change = getbits(&state, 1 ); |
| 3 | 50 pci->pci_gi.vobu_uop_ctl.angle_change = getbits(&state, 1 ); |
| 51 pci->pci_gi.vobu_uop_ctl.subpic_stream_change = getbits(&state, 1 ); | |
| 52 pci->pci_gi.vobu_uop_ctl.audio_stream_change = getbits(&state, 1 ); | |
| 53 pci->pci_gi.vobu_uop_ctl.pause_on = getbits(&state, 1 ); | |
| 54 pci->pci_gi.vobu_uop_ctl.still_off = getbits(&state, 1 ); | |
| 55 pci->pci_gi.vobu_uop_ctl.button_select_or_activate = getbits(&state, 1 ); | |
| 56 pci->pci_gi.vobu_uop_ctl.resume = getbits(&state, 1 ); | |
| 57 | |
| 20 | 58 pci->pci_gi.vobu_uop_ctl.chapter_menu_call = getbits(&state, 1 ); |
| 3 | 59 pci->pci_gi.vobu_uop_ctl.angle_menu_call = getbits(&state, 1 ); |
| 60 pci->pci_gi.vobu_uop_ctl.audio_menu_call = getbits(&state, 1 ); | |
| 61 pci->pci_gi.vobu_uop_ctl.subpic_menu_call = getbits(&state, 1 ); | |
| 62 pci->pci_gi.vobu_uop_ctl.root_menu_call = getbits(&state, 1 ); | |
| 63 pci->pci_gi.vobu_uop_ctl.title_menu_call = getbits(&state, 1 ); | |
| 64 pci->pci_gi.vobu_uop_ctl.backward_scan = getbits(&state, 1 ); | |
| 65 pci->pci_gi.vobu_uop_ctl.forward_scan = getbits(&state, 1 ); | |
| 66 | |
| 20 | 67 pci->pci_gi.vobu_uop_ctl.next_pg_search = getbits(&state, 1 ); |
| 3 | 68 pci->pci_gi.vobu_uop_ctl.prev_or_top_pg_search = getbits(&state, 1 ); |
| 69 pci->pci_gi.vobu_uop_ctl.time_or_chapter_search = getbits(&state, 1 ); | |
| 70 pci->pci_gi.vobu_uop_ctl.go_up = getbits(&state, 1 ); | |
| 71 pci->pci_gi.vobu_uop_ctl.stop = getbits(&state, 1 ); | |
| 72 pci->pci_gi.vobu_uop_ctl.title_play = getbits(&state, 1 ); | |
| 73 pci->pci_gi.vobu_uop_ctl.chapter_search_or_play = getbits(&state, 1 ); | |
| 74 pci->pci_gi.vobu_uop_ctl.title_or_time_play = getbits(&state, 1 ); | |
| 20 | 75 pci->pci_gi.vobu_s_ptm = getbits(&state, 32 ); |
| 76 pci->pci_gi.vobu_e_ptm = getbits(&state, 32 ); | |
| 77 pci->pci_gi.vobu_se_e_ptm = getbits(&state, 32 ); | |
| 3 | 78 pci->pci_gi.e_eltm.hour = getbits(&state, 8 ); |
| 79 pci->pci_gi.e_eltm.minute = getbits(&state, 8 ); | |
| 80 pci->pci_gi.e_eltm.second = getbits(&state, 8 ); | |
| 81 pci->pci_gi.e_eltm.frame_u = getbits(&state, 8 ); | |
| 82 for(i = 0; i < 32; i++) | |
| 83 pci->pci_gi.vobu_isrc[i] = getbits(&state, 8 ); | |
| 84 | |
| 85 /* pci nsml_agli */ | |
| 86 for(i = 0; i < 9; i++) | |
| 87 pci->nsml_agli.nsml_agl_dsta[i] = getbits(&state, 32 ); | |
| 88 | |
| 89 /* pci hli hli_gi */ | |
| 90 pci->hli.hl_gi.hli_ss = getbits(&state, 16 ); | |
| 20 | 91 pci->hli.hl_gi.hli_s_ptm = getbits(&state, 32 ); |
| 3 | 92 pci->hli.hl_gi.hli_e_ptm = getbits(&state, 32 ); |
| 93 pci->hli.hl_gi.btn_se_e_ptm = getbits(&state, 32 ); | |
| 94 pci->hli.hl_gi.zero1 = getbits(&state, 2 ); | |
| 95 pci->hli.hl_gi.btngr_ns = getbits(&state, 2 ); | |
| 96 pci->hli.hl_gi.zero2 = getbits(&state, 1 ); | |
| 97 pci->hli.hl_gi.btngr1_dsp_ty = getbits(&state, 3 ); | |
| 98 pci->hli.hl_gi.zero3 = getbits(&state, 1 ); | |
| 99 pci->hli.hl_gi.btngr2_dsp_ty = getbits(&state, 3 ); | |
| 100 pci->hli.hl_gi.zero4 = getbits(&state, 1 ); | |
| 101 pci->hli.hl_gi.btngr3_dsp_ty = getbits(&state, 3 ); | |
| 102 pci->hli.hl_gi.btn_ofn = getbits(&state, 8 ); | |
| 103 pci->hli.hl_gi.btn_ns = getbits(&state, 8 ); | |
| 20 | 104 pci->hli.hl_gi.nsl_btn_ns = getbits(&state, 8 ); |
| 3 | 105 pci->hli.hl_gi.zero5 = getbits(&state, 8 ); |
| 106 pci->hli.hl_gi.fosl_btnn = getbits(&state, 8 ); | |
| 107 pci->hli.hl_gi.foac_btnn = getbits(&state, 8 ); | |
| 108 | |
| 109 /* pci hli btn_colit */ | |
| 110 for(i = 0; i < 3; i++) | |
| 111 for(j = 0; j < 2; j++) | |
| 20 | 112 pci->hli.btn_colit.btn_coli[i][j] = getbits(&state, 32 ); |
| 3 | 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. */ | |
| 20 | 116 |
| 3 | 117 /* pci hli btni */ |
| 118 for(i = 0; i < 36; i++) { | |
| 119 pci->hli.btnit[i].btn_coln = getbits(&state, 2 ); | |
| 120 pci->hli.btnit[i].x_start = getbits(&state, 10 ); | |
| 121 pci->hli.btnit[i].zero1 = getbits(&state, 2 ); | |
| 122 pci->hli.btnit[i].x_end = getbits(&state, 10 ); | |
| 123 | |
| 124 pci->hli.btnit[i].auto_action_mode = getbits(&state, 2 ); | |
| 125 pci->hli.btnit[i].y_start = getbits(&state, 10 ); | |
| 126 pci->hli.btnit[i].zero2 = getbits(&state, 2 ); | |
| 127 pci->hli.btnit[i].y_end = getbits(&state, 10 ); | |
| 128 | |
| 129 pci->hli.btnit[i].zero3 = getbits(&state, 2 ); | |
| 130 pci->hli.btnit[i].up = getbits(&state, 6 ); | |
| 131 pci->hli.btnit[i].zero4 = getbits(&state, 2 ); | |
| 132 pci->hli.btnit[i].down = getbits(&state, 6 ); | |
| 133 pci->hli.btnit[i].zero5 = getbits(&state, 2 ); | |
| 134 pci->hli.btnit[i].left = getbits(&state, 6 ); | |
| 135 pci->hli.btnit[i].zero6 = getbits(&state, 2 ); | |
| 136 pci->hli.btnit[i].right = getbits(&state, 6 ); | |
| 137 /* pci vm_cmd */ | |
| 138 for(j = 0; j < 8; j++) | |
| 139 pci->hli.btnit[i].cmd.bytes[j] = getbits(&state, 8 ); | |
| 140 } | |
| 141 | |
| 142 | |
| 143 | |
| 144 #ifndef NDEBUG | |
| 145 /* Asserts */ | |
| 146 | |
| 20 | 147 /* pci pci gi */ |
| 3 | 148 CHECK_VALUE(pci->pci_gi.zero1 == 0); |
| 149 | |
| 150 /* pci hli hli_gi */ | |
| 151 CHECK_VALUE(pci->hli.hl_gi.zero1 == 0); | |
| 152 CHECK_VALUE(pci->hli.hl_gi.zero2 == 0); | |
| 153 CHECK_VALUE(pci->hli.hl_gi.zero3 == 0); | |
| 154 CHECK_VALUE(pci->hli.hl_gi.zero4 == 0); | |
| 155 CHECK_VALUE(pci->hli.hl_gi.zero5 == 0); | |
| 156 | |
| 157 /* Are there buttons defined here? */ | |
| 158 if((pci->hli.hl_gi.hli_ss & 0x03) != 0) { | |
| 20 | 159 CHECK_VALUE(pci->hli.hl_gi.btn_ns != 0); |
| 160 CHECK_VALUE(pci->hli.hl_gi.btngr_ns != 0); | |
| 3 | 161 } else { |
| 20 | 162 CHECK_VALUE((pci->hli.hl_gi.btn_ns != 0 && pci->hli.hl_gi.btngr_ns != 0) |
| 26 | 163 || (pci->hli.hl_gi.btn_ns == 0 && pci->hli.hl_gi.btngr_ns == 0)); |
| 3 | 164 } |
| 165 | |
| 166 /* pci hli btnit */ | |
| 167 for(i = 0; i < pci->hli.hl_gi.btngr_ns; i++) { | |
| 168 for(j = 0; j < (36 / pci->hli.hl_gi.btngr_ns); j++) { | |
| 169 int n = (36 / pci->hli.hl_gi.btngr_ns) * i + j; | |
| 170 CHECK_VALUE(pci->hli.btnit[n].zero1 == 0); | |
| 171 CHECK_VALUE(pci->hli.btnit[n].zero2 == 0); | |
| 172 CHECK_VALUE(pci->hli.btnit[n].zero3 == 0); | |
| 173 CHECK_VALUE(pci->hli.btnit[n].zero4 == 0); | |
| 174 CHECK_VALUE(pci->hli.btnit[n].zero5 == 0); | |
| 175 CHECK_VALUE(pci->hli.btnit[n].zero6 == 0); | |
| 20 | 176 |
| 177 if (j < pci->hli.hl_gi.btn_ns) { | |
| 26 | 178 CHECK_VALUE(pci->hli.btnit[n].x_start <= pci->hli.btnit[n].x_end); |
| 179 CHECK_VALUE(pci->hli.btnit[n].y_start <= pci->hli.btnit[n].y_end); | |
| 180 CHECK_VALUE(pci->hli.btnit[n].up <= pci->hli.hl_gi.btn_ns); | |
| 181 CHECK_VALUE(pci->hli.btnit[n].down <= pci->hli.hl_gi.btn_ns); | |
| 182 CHECK_VALUE(pci->hli.btnit[n].left <= pci->hli.hl_gi.btn_ns); | |
| 183 CHECK_VALUE(pci->hli.btnit[n].right <= pci->hli.hl_gi.btn_ns); | |
| 184 /* vmcmd_verify(pci->hli.btnit[n].cmd); */ | |
| 3 | 185 } else { |
| 26 | 186 int k; |
| 187 CHECK_VALUE(pci->hli.btnit[n].btn_coln == 0); | |
| 188 CHECK_VALUE(pci->hli.btnit[n].auto_action_mode == 0); | |
| 189 CHECK_VALUE(pci->hli.btnit[n].x_start == 0); | |
| 190 CHECK_VALUE(pci->hli.btnit[n].y_start == 0); | |
| 191 CHECK_VALUE(pci->hli.btnit[n].x_end == 0); | |
| 192 CHECK_VALUE(pci->hli.btnit[n].y_end == 0); | |
| 193 CHECK_VALUE(pci->hli.btnit[n].up == 0); | |
| 194 CHECK_VALUE(pci->hli.btnit[n].down == 0); | |
| 195 CHECK_VALUE(pci->hli.btnit[n].left == 0); | |
| 196 CHECK_VALUE(pci->hli.btnit[n].right == 0); | |
| 197 for (k = 0; k < 8; k++) | |
| 198 CHECK_VALUE(pci->hli.btnit[n].cmd.bytes[k] == 0); /* CHECK_ZERO? */ | |
| 3 | 199 } |
| 200 } | |
| 201 } | |
| 202 #endif /* !NDEBUG */ | |
| 203 } | |
| 204 | |
| 205 void navRead_DSI(dsi_t *dsi, unsigned char *buffer) { | |
| 206 int i; | |
| 207 getbits_state_t state; | |
| 208 if (!getbits_init(&state, buffer)) abort(); /* Passed NULL pointers */ | |
| 209 | |
| 210 /* dsi dsi gi */ | |
| 211 dsi->dsi_gi.nv_pck_scr = getbits(&state, 32 ); | |
| 212 dsi->dsi_gi.nv_pck_lbn = getbits(&state, 32 ); | |
| 213 dsi->dsi_gi.vobu_ea = getbits(&state, 32 ); | |
| 214 dsi->dsi_gi.vobu_1stref_ea = getbits(&state, 32 ); | |
| 215 dsi->dsi_gi.vobu_2ndref_ea = getbits(&state, 32 ); | |
| 216 dsi->dsi_gi.vobu_3rdref_ea = getbits(&state, 32 ); | |
| 217 dsi->dsi_gi.vobu_vob_idn = getbits(&state, 16 ); | |
| 218 dsi->dsi_gi.zero1 = getbits(&state, 8 ); | |
| 219 dsi->dsi_gi.vobu_c_idn = getbits(&state, 8 ); | |
| 220 dsi->dsi_gi.c_eltm.hour = getbits(&state, 8 ); | |
| 221 dsi->dsi_gi.c_eltm.minute = getbits(&state, 8 ); | |
| 222 dsi->dsi_gi.c_eltm.second = getbits(&state, 8 ); | |
| 223 dsi->dsi_gi.c_eltm.frame_u = getbits(&state, 8 ); | |
| 224 | |
| 225 /* dsi sml pbi */ | |
| 226 dsi->sml_pbi.category = getbits(&state, 16 ); | |
| 227 dsi->sml_pbi.ilvu_ea = getbits(&state, 32 ); | |
| 228 dsi->sml_pbi.ilvu_sa = getbits(&state, 32 ); | |
| 229 dsi->sml_pbi.size = getbits(&state, 16 ); | |
| 230 dsi->sml_pbi.vob_v_s_s_ptm = getbits(&state, 32 ); | |
| 231 dsi->sml_pbi.vob_v_e_e_ptm = getbits(&state, 32 ); | |
| 232 for(i = 0; i < 8; i++) { | |
| 233 dsi->sml_pbi.vob_a[i].stp_ptm1 = getbits(&state, 32 ); | |
| 234 dsi->sml_pbi.vob_a[i].stp_ptm2 = getbits(&state, 32 ); | |
| 235 dsi->sml_pbi.vob_a[i].gap_len1 = getbits(&state, 32 ); | |
| 236 dsi->sml_pbi.vob_a[i].gap_len2 = getbits(&state, 32 ); | |
| 237 } | |
| 238 | |
| 239 /* dsi sml agli */ | |
| 240 for(i = 0; i < 9; i++) { | |
| 241 dsi->sml_agli.data[ i ].address = getbits(&state, 32 ); | |
| 242 dsi->sml_agli.data[ i ].size = getbits(&state, 16 ); | |
| 243 } | |
| 244 | |
| 245 /* dsi vobu sri */ | |
| 246 dsi->vobu_sri.next_video = getbits(&state, 32 ); | |
| 247 for(i = 0; i < 19; i++) | |
| 248 dsi->vobu_sri.fwda[i] = getbits(&state, 32 ); | |
| 249 dsi->vobu_sri.next_vobu = getbits(&state, 32 ); | |
| 250 dsi->vobu_sri.prev_vobu = getbits(&state, 32 ); | |
| 251 for(i = 0; i < 19; i++) | |
| 252 dsi->vobu_sri.bwda[i] = getbits(&state, 32 ); | |
| 253 dsi->vobu_sri.prev_video = getbits(&state, 32 ); | |
| 254 | |
| 255 /* dsi synci */ | |
| 256 for(i = 0; i < 8; i++) | |
| 257 dsi->synci.a_synca[i] = getbits(&state, 16 ); | |
| 258 for(i = 0; i < 32; i++) | |
| 259 dsi->synci.sp_synca[i] = getbits(&state, 32 ); | |
| 260 | |
| 20 | 261 |
| 3 | 262 /* Asserts */ |
| 263 | |
| 264 /* dsi dsi gi */ | |
| 265 CHECK_VALUE(dsi->dsi_gi.zero1 == 0); | |
| 266 } | |
| 267 |
