| 1 |
|
| 2 |
> |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 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 "dvdread/nav_types.h" |
| 30 |
#include "dvdread/nav_read.h" |
| 31 |
#include "dvdread_internal.h" |
| 32 |
#include "dvdread/bitreader.h" |
| 33 |
|
| 34 |
#define getbits_init dvdread_getbits_init |
| 35 |
#define getbits dvdread_getbits |
| 36 |
|
| 37 |
#define CHECK_VALUE(arg)\ |
| 38 |
if(!(arg)) {\ |
| 39 |
DVDReadLog(NULL, NULL, DVD_LOGGER_LEVEL_WARN,\ |
| 40 |
"CHECK_VALUE failed in %s:%i for %s",\ |
| 41 |
__FILE__, __LINE__, # arg );\ |
| 42 |
} |
| 43 |
|
| 44 |
void navRead_PCI(pci_t *pci, unsigned char *buffer) { |
| 45 |
int32_t i, j; |
| 46 |
getbits_state_t state; |
| 47 |
if (!getbits_init(&state, buffer)) abort(); |
| 48 |
|
| 49 |
|
| 50 |
pci->pci_gi.nv_pck_lbn = getbits(&state, 32 ); |
| 51 |
pci->pci_gi.vobu_cat = getbits(&state, 16 ); |
| 52 |
pci->pci_gi.zero1 = getbits(&state, 16 ); |
| 53 |
pci->pci_gi.vobu_uop_ctl.zero = getbits(&state, 7 ); |
| 54 |
pci->pci_gi.vobu_uop_ctl.video_pres_mode_change = getbits(&state, 1 ); |
| 55 |
|
| 56 |
pci->pci_gi.vobu_uop_ctl.karaoke_audio_pres_mode_change = getbits(&state, 1 ); |
| 57 |
pci->pci_gi.vobu_uop_ctl.angle_change = getbits(&state, 1 ); |
| 58 |
pci->pci_gi.vobu_uop_ctl.subpic_stream_change = getbits(&state, 1 ); |
| 59 |
pci->pci_gi.vobu_uop_ctl.audio_stream_change = getbits(&state, 1 ); |
| 60 |
pci->pci_gi.vobu_uop_ctl.pause_on = getbits(&state, 1 ); |
| 61 |
pci->pci_gi.vobu_uop_ctl.still_off = getbits(&state, 1 ); |
| 62 |
pci->pci_gi.vobu_uop_ctl.button_select_or_activate = getbits(&state, 1 ); |
| 63 |
pci->pci_gi.vobu_uop_ctl.resume = getbits(&state, 1 ); |
| 64 |
|
| 65 |
pci->pci_gi.vobu_uop_ctl.chapter_menu_call = getbits(&state, 1 ); |
| 66 |
pci->pci_gi.vobu_uop_ctl.angle_menu_call = getbits(&state, 1 ); |
| 67 |
pci->pci_gi.vobu_uop_ctl.audio_menu_call = getbits(&state, 1 ); |
| 68 |
pci->pci_gi.vobu_uop_ctl.subpic_menu_call = getbits(&state, 1 ); |
| 69 |
pci->pci_gi.vobu_uop_ctl.root_menu_call = getbits(&state, 1 ); |
| 70 |
pci->pci_gi.vobu_uop_ctl.title_menu_call = getbits(&state, 1 ); |
| 71 |
pci->pci_gi.vobu_uop_ctl.backward_scan = getbits(&state, 1 ); |
| 72 |
pci->pci_gi.vobu_uop_ctl.forward_scan = getbits(&state, 1 ); |
| 73 |
|
| 74 |
pci->pci_gi.vobu_uop_ctl.next_pg_search = getbits(&state, 1 ); |
| 75 |
pci->pci_gi.vobu_uop_ctl.prev_or_top_pg_search = getbits(&state, 1 ); |
| 76 |
pci->pci_gi.vobu_uop_ctl.time_or_chapter_search = getbits(&state, 1 ); |
| 77 |
pci->pci_gi.vobu_uop_ctl.go_up = getbits(&state, 1 ); |
| 78 |
pci->pci_gi.vobu_uop_ctl.stop = getbits(&state, 1 ); |
| 79 |
pci->pci_gi.vobu_uop_ctl.title_play = getbits(&state, 1 ); |
| 80 |
pci->pci_gi.vobu_uop_ctl.chapter_search_or_play = getbits(&state, 1 ); |
| 81 |
pci->pci_gi.vobu_uop_ctl.title_or_time_play = getbits(&state, 1 ); |
| 82 |
pci->pci_gi.vobu_s_ptm = getbits(&state, 32 ); |
| 83 |
pci->pci_gi.vobu_e_ptm = getbits(&state, 32 ); |
| 84 |
pci->pci_gi.vobu_se_e_ptm = getbits(&state, 32 ); |
| 85 |
pci->pci_gi.e_eltm.hour = getbits(&state, 8 ); |
| 86 |
pci->pci_gi.e_eltm.minute = getbits(&state, 8 ); |
| 87 |
pci->pci_gi.e_eltm.second = getbits(&state, 8 ); |
| 88 |
pci->pci_gi.e_eltm.frame_u = getbits(&state, 8 ); |
| 89 |
for(i = 0; i < 32; i++) |
| 90 |
pci->pci_gi.vobu_isrc[i] = getbits(&state, 8 ); |
| 91 |
|
| 92 |
|
| 93 |
for(i = 0; i < 9; i++) |
| 94 |
pci->nsml_agli.nsml_agl_dsta[i] = getbits(&state, 32 ); |
| 95 |
|
| 96 |
|
| 97 |
pci->hli.hl_gi.hli_ss = getbits(&state, 16 ); |
| 98 |
pci->hli.hl_gi.hli_s_ptm = getbits(&state, 32 ); |
| 99 |
pci->hli.hl_gi.hli_e_ptm = getbits(&state, 32 ); |
| 100 |
pci->hli.hl_gi.btn_se_e_ptm = getbits(&state, 32 ); |
| 101 |
pci->hli.hl_gi.zero1 = getbits(&state, 2 ); |
| 102 |
pci->hli.hl_gi.btngr_ns = getbits(&state, 2 ); |
| 103 |
pci->hli.hl_gi.zero2 = getbits(&state, 1 ); |
| 104 |
pci->hli.hl_gi.btngr1_dsp_ty = getbits(&state, 3 ); |
| 105 |
pci->hli.hl_gi.zero3 = getbits(&state, 1 ); |
| 106 |
pci->hli.hl_gi.btngr2_dsp_ty = getbits(&state, 3 ); |
| 107 |
pci->hli.hl_gi.zero4 = getbits(&state, 1 ); |
| 108 |
pci->hli.hl_gi.btngr3_dsp_ty = getbits(&state, 3 ); |
| 109 |
pci->hli.hl_gi.btn_ofn = getbits(&state, 8 ); |
| 110 |
pci->hli.hl_gi.btn_ns = getbits(&state, 8 ); |
| 111 |
pci->hli.hl_gi.nsl_btn_ns = getbits(&state, 8 ); |
| 112 |
pci->hli.hl_gi.zero5 = getbits(&state, 8 ); |
| 113 |
pci->hli.hl_gi.fosl_btnn = getbits(&state, 8 ); |
| 114 |
pci->hli.hl_gi.foac_btnn = getbits(&state, 8 ); |
| 115 |
|
| 116 |
|
| 117 |
for(i = 0; i < 3; i++) |
| 118 |
for(j = 0; j < 2; j++) |
| 119 |
pci->hli.btn_colit.btn_coli[i][j] = getbits(&state, 32 ); |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
for(i = 0; i < 36; i++) { |
| 126 |
pci->hli.btnit[i].btn_coln = getbits(&state, 2 ); |
| 127 |
pci->hli.btnit[i].x_start = getbits(&state, 10 ); |
| 128 |
pci->hli.btnit[i].zero1 = getbits(&state, 2 ); |
| 129 |
pci->hli.btnit[i].x_end = getbits(&state, 10 ); |
| 130 |
|
| 131 |
pci->hli.btnit[i].auto_action_mode = getbits(&state, 2 ); |
| 132 |
pci->hli.btnit[i].y_start = getbits(&state, 10 ); |
| 133 |
pci->hli.btnit[i].zero2 = getbits(&state, 2 ); |
| 134 |
pci->hli.btnit[i].y_end = getbits(&state, 10 ); |
| 135 |
|
| 136 |
pci->hli.btnit[i].zero3 = getbits(&state, 2 ); |
| 137 |
pci->hli.btnit[i].up = getbits(&state, 6 ); |
| 138 |
pci->hli.btnit[i].zero4 = getbits(&state, 2 ); |
| 139 |
pci->hli.btnit[i].down = getbits(&state, 6 ); |
| 140 |
pci->hli.btnit[i].zero5 = getbits(&state, 2 ); |
| 141 |
pci->hli.btnit[i].left = getbits(&state, 6 ); |
| 142 |
pci->hli.btnit[i].zero6 = getbits(&state, 2 ); |
| 143 |
pci->hli.btnit[i].right = getbits(&state, 6 ); |
| 144 |
|
| 145 |
for(j = 0; j < 8; j++) |
| 146 |
pci->hli.btnit[i].cmd.bytes[j] = getbits(&state, 8 ); |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
#ifndef NDEBUG |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
CHECK_VALUE(pci->pci_gi.zero1 == 0); |
| 155 |
|
| 156 |
|
| 157 |
CHECK_VALUE(pci->hli.hl_gi.zero1 == 0); |
| 158 |
CHECK_VALUE(pci->hli.hl_gi.zero2 == 0); |
| 159 |
CHECK_VALUE(pci->hli.hl_gi.zero3 == 0); |
| 160 |
CHECK_VALUE(pci->hli.hl_gi.zero4 == 0); |
| 161 |
CHECK_VALUE(pci->hli.hl_gi.zero5 == 0); |
| 162 |
|
| 163 |
|
| 164 |
if((pci->hli.hl_gi.hli_ss & 0x03) != 0) { |
| 165 |
CHECK_VALUE(pci->hli.hl_gi.btn_ns != 0); |
| 166 |
CHECK_VALUE(pci->hli.hl_gi.btngr_ns != 0); |
| 167 |
} else { |
| 168 |
CHECK_VALUE((pci->hli.hl_gi.btn_ns != 0 && pci->hli.hl_gi.btngr_ns != 0) |
| 169 |
|| (pci->hli.hl_gi.btn_ns == 0 && pci->hli.hl_gi.btngr_ns == 0)); |
| 170 |
} |
| 171 |
|
| 172 |
|
| 173 |
for(i = 0; i < pci->hli.hl_gi.btngr_ns; i++) { |
| 174 |
for(j = 0; j < (36 / pci->hli.hl_gi.btngr_ns); j++) { |
| 175 |
int n = (36 / pci->hli.hl_gi.btngr_ns) * i + j; |
| 176 |
CHECK_VALUE(pci->hli.btnit[n].zero1 == 0); |
| 177 |
CHECK_VALUE(pci->hli.btnit[n].zero2 == 0); |
| 178 |
CHECK_VALUE(pci->hli.btnit[n].zero3 == 0); |
| 179 |
CHECK_VALUE(pci->hli.btnit[n].zero4 == 0); |
| 180 |
CHECK_VALUE(pci->hli.btnit[n].zero5 == 0); |
| 181 |
CHECK_VALUE(pci->hli.btnit[n].zero6 == 0); |
| 182 |
|
| 183 |
if (j < pci->hli.hl_gi.btn_ns) { |
| 184 |
CHECK_VALUE(pci->hli.btnit[n].x_start <= pci->hli.btnit[n].x_end); |
| 185 |
CHECK_VALUE(pci->hli.btnit[n].y_start <= pci->hli.btnit[n].y_end); |
| 186 |
CHECK_VALUE(pci->hli.btnit[n].up <= pci->hli.hl_gi.btn_ns); |
| 187 |
CHECK_VALUE(pci->hli.btnit[n].down <= pci->hli.hl_gi.btn_ns); |
| 188 |
CHECK_VALUE(pci->hli.btnit[n].left <= pci->hli.hl_gi.btn_ns); |
| 189 |
CHECK_VALUE(pci->hli.btnit[n].right <= pci->hli.hl_gi.btn_ns); |
| 190 |
|
| 191 |
} else { |
| 192 |
int k; |
| 193 |
CHECK_VALUE(pci->hli.btnit[n].btn_coln == 0); |
| 194 |
CHECK_VALUE(pci->hli.btnit[n].auto_action_mode == 0); |
| 195 |
CHECK_VALUE(pci->hli.btnit[n].x_start == 0); |
| 196 |
CHECK_VALUE(pci->hli.btnit[n].y_start == 0); |
| 197 |
CHECK_VALUE(pci->hli.btnit[n].x_end == 0); |
| 198 |
CHECK_VALUE(pci->hli.btnit[n].y_end == 0); |
| 199 |
CHECK_VALUE(pci->hli.btnit[n].up == 0); |
| 200 |
CHECK_VALUE(pci->hli.btnit[n].down == 0); |
| 201 |
CHECK_VALUE(pci->hli.btnit[n].left == 0); |
| 202 |
CHECK_VALUE(pci->hli.btnit[n].right == 0); |
| 203 |
for (k = 0; k < 8; k++) |
| 204 |
CHECK_VALUE(pci->hli.btnit[n].cmd.bytes[k] == 0); |
| 205 |
} |
| 206 |
} |
| 207 |
} |
| 208 |
#endif |
| 209 |
} |
| 210 |
|
| 211 |
void navRead_DSI(dsi_t *dsi, unsigned char *buffer) { |
| 212 |
int i; |
| 213 |
getbits_state_t state; |
| 214 |
if (!getbits_init(&state, buffer)) abort(); |
| 215 |
|
| 216 |
|
| 217 |
dsi->dsi_gi.nv_pck_scr = getbits(&state, 32 ); |
| 218 |
dsi->dsi_gi.nv_pck_lbn = getbits(&state, 32 ); |
| 219 |
dsi->dsi_gi.vobu_ea = getbits(&state, 32 ); |
| 220 |
dsi->dsi_gi.vobu_1stref_ea = getbits(&state, 32 ); |
| 221 |
dsi->dsi_gi.vobu_2ndref_ea = getbits(&state, 32 ); |
| 222 |
dsi->dsi_gi.vobu_3rdref_ea = getbits(&state, 32 ); |
| 223 |
dsi->dsi_gi.vobu_vob_idn = getbits(&state, 16 ); |
| 224 |
dsi->dsi_gi.zero1 = getbits(&state, 8 ); |
| 225 |
dsi->dsi_gi.vobu_c_idn = getbits(&state, 8 ); |
| 226 |
dsi->dsi_gi.c_eltm.hour = getbits(&state, 8 ); |
| 227 |
dsi->dsi_gi.c_eltm.minute = getbits(&state, 8 ); |
| 228 |
dsi->dsi_gi.c_eltm.second = getbits(&state, 8 ); |
| 229 |
dsi->dsi_gi.c_eltm.frame_u = getbits(&state, 8 ); |
| 230 |
|
| 231 |
|
| 232 |
dsi->sml_pbi.category = getbits(&state, 16 ); |
| 233 |
dsi->sml_pbi.ilvu_ea = getbits(&state, 32 ); |
| 234 |
dsi->sml_pbi.ilvu_sa = getbits(&state, 32 ); |
| 235 |
dsi->sml_pbi.size = getbits(&state, 16 ); |
| 236 |
dsi->sml_pbi.vob_v_s_s_ptm = getbits(&state, 32 ); |
| 237 |
dsi->sml_pbi.vob_v_e_e_ptm = getbits(&state, 32 ); |
| 238 |
for(i = 0; i < 8; i++) { |
| 239 |
dsi->sml_pbi.vob_a[i].stp_ptm1 = getbits(&state, 32 ); |
| 240 |
dsi->sml_pbi.vob_a[i].stp_ptm2 = getbits(&state, 32 ); |
| 241 |
dsi->sml_pbi.vob_a[i].gap_len1 = getbits(&state, 32 ); |
| 242 |
dsi->sml_pbi.vob_a[i].gap_len2 = getbits(&state, 32 ); |
| 243 |
} |
| 244 |
|
| 245 |
|
| 246 |
for(i = 0; i < 9; i++) { |
| 247 |
dsi->sml_agli.data[ i ].address = getbits(&state, 32 ); |
| 248 |
dsi->sml_agli.data[ i ].size = getbits(&state, 16 ); |
| 249 |
} |
| 250 |
|
| 251 |
|
| 252 |
dsi->vobu_sri.next_video = getbits(&state, 32 ); |
| 253 |
for(i = 0; i < 19; i++) |
| 254 |
dsi->vobu_sri.fwda[i] = getbits(&state, 32 ); |
| 255 |
dsi->vobu_sri.next_vobu = getbits(&state, 32 ); |
| 256 |
dsi->vobu_sri.prev_vobu = getbits(&state, 32 ); |
| 257 |
for(i = 0; i < 19; i++) |
| 258 |
dsi->vobu_sri.bwda[i] = getbits(&state, 32 ); |
| 259 |
dsi->vobu_sri.prev_video = getbits(&state, 32 ); |
| 260 |
|
| 261 |
|
| 262 |
for(i = 0; i < 8; i++) |
| 263 |
dsi->synci.a_synca[i] = getbits(&state, 16 ); |
| 264 |
for(i = 0; i < 32; i++) |
| 265 |
dsi->synci.sp_synca[i] = getbits(&state, 32 ); |
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
CHECK_VALUE(dsi->dsi_gi.zero1 == 0); |
| 272 |
} |