Mercurial > libdvdnav.hg
annotate vm/vm.c @ 438:04cb2d6e4f93 src tip
In vm_new_vm(), use the proper calloc() argument order
.. and don't derive 1 from the unrelated sizeof(char).
Fixes the scan-anaylzer "API violation" warning:
Result of 'calloc' is converted to a pointer of type 'vm_t', which is incompatible with sizeof operand type 'char'
Patch by Fabian Keil <fk AT fabiankeil DOT de>
| author | rathann |
|---|---|
| date | Wed, 04 Dec 2013 23:02:01 +0000 |
| parents | 29d4a43c8c86 |
| children |
| rev | line source |
|---|---|
| 225 | 1 /* |
| 390 | 2 * Copyright (C) 2000, 2001 HÃ¥kan Hjort |
| 225 | 3 * Copyright (C) 2001 Rich Wareham <richwareham@users.sourceforge.net> |
|
243
e75c52894630
* assert(0) does not always and the program (see NDEBUG)
mroi
parents:
229
diff
changeset
|
4 * 2002-2004 the dvdnav project |
| 388 | 5 * |
| 225 | 6 * This file is part of libdvdnav, a DVD navigation library. It is modified |
| 7 * from a file originally part of the Ogle DVD player. | |
| 388 | 8 * |
| 225 | 9 * libdvdnav is free software; you can redistribute it and/or modify |
| 10 * it under the terms of the GNU General Public License as published by | |
| 11 * the Free Software Foundation; either version 2 of the License, or | |
| 12 * (at your option) any later version. | |
| 388 | 13 * |
| 225 | 14 * libdvdnav is distributed in the hope that it will be useful, |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 * GNU General Public License for more details. | |
| 388 | 18 * |
|
389
d3c273ced49c
Use consistent license headers everywhere: Fix wrong FSF address.
diego
parents:
388
diff
changeset
|
19 * You should have received a copy of the GNU General Public License along |
|
d3c273ced49c
Use consistent license headers everywhere: Fix wrong FSF address.
diego
parents:
388
diff
changeset
|
20 * with libdvdnav; if not, write to the Free Software Foundation, Inc., |
|
d3c273ced49c
Use consistent license headers everywhere: Fix wrong FSF address.
diego
parents:
388
diff
changeset
|
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 225 | 22 */ |
| 23 | |
| 24 #ifdef HAVE_CONFIG_H | |
| 25 #include "config.h" | |
| 26 #endif | |
| 27 | |
| 28 #include <stdio.h> | |
| 29 #include <string.h> | |
| 30 #include <stdlib.h> | |
| 31 #include <unistd.h> | |
| 32 #include <inttypes.h> | |
|
294
2146ff691bcd
include limits.h; it was included in the previous dvdnav_internal.h and without it players segfault
nicodvb
parents:
290
diff
changeset
|
33 #include <limits.h> |
| 225 | 34 #include <assert.h> |
| 35 #include <sys/types.h> | |
| 36 #include <sys/stat.h> | |
| 290 | 37 #include <sys/time.h> |
| 225 | 38 #include <fcntl.h> |
| 39 | |
| 386 | 40 #include <dvdread/nav_types.h> |
| 41 #include <dvdread/ifo_types.h> | |
| 42 #include <dvdread/ifo_read.h> | |
|
395
9c5aef10d165
Move dvd_types.h, dvdnav_events.h and dvdnav.h into a dvdnav directory.
reimar
parents:
394
diff
changeset
|
43 #include "dvdnav/dvdnav.h" |
| 225 | 44 |
|
285
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
260
diff
changeset
|
45 #include "decoder.h" |
|
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
260
diff
changeset
|
46 #include "remap.h" |
|
52877d182e96
moved all header inclusions from .h to .c files; my word, I've never seen such a horrible entanglement as in this mess
nicodvb
parents:
260
diff
changeset
|
47 #include "vm.h" |
| 225 | 48 #include "dvdnav_internal.h" |
| 49 | |
| 50 #ifdef _MSC_VER | |
| 51 #include <io.h> /* read() */ | |
| 52 #endif /* _MSC_VER */ | |
| 53 | |
| 394 | 54 #ifdef __OS2__ |
| 55 #define INCL_DOS | |
| 56 #include <os2.h> | |
| 399 | 57 #include <io.h> /* setmode() */ |
| 58 #include <fcntl.h> /* O_BINARY */ | |
| 394 | 59 #endif |
| 60 | |
| 225 | 61 /* |
|
433
1c7c804e9c82
Prevent general CPP macro from causing strange behavior.
rathann
parents:
429
diff
changeset
|
62 #define DVDNAV_STRICT |
| 225 | 63 */ |
| 64 | |
| 65 /* Local prototypes */ | |
| 66 | |
| 67 /* get_XYZ returns a value. | |
| 68 * set_XYZ sets state using passed parameters. | |
| 69 * returns success/failure. | |
| 70 */ | |
| 71 | |
| 72 /* Play */ | |
| 73 static link_t play_PGC(vm_t *vm); | |
| 74 static link_t play_PGC_PG(vm_t *vm, int pgN); | |
| 75 static link_t play_PGC_post(vm_t *vm); | |
| 76 static link_t play_PG(vm_t *vm); | |
| 77 static link_t play_Cell(vm_t *vm); | |
| 78 static link_t play_Cell_post(vm_t *vm); | |
| 79 | |
| 80 /* Process link - returns 1 if a hop has been performed */ | |
| 81 static int process_command(vm_t *vm,link_t link_values); | |
| 82 | |
| 83 /* Set */ | |
| 84 static int set_TT(vm_t *vm, int tt); | |
| 85 static int set_PTT(vm_t *vm, int tt, int ptt); | |
| 86 static int set_VTS_TT(vm_t *vm, int vtsN, int vts_ttn); | |
| 87 static int set_VTS_PTT(vm_t *vm, int vtsN, int vts_ttn, int part); | |
|
409
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
88 static int set_PROG(vm_t *vm, int tt, int pgcn, int pgn); |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
89 static int set_VTS_PROG(vm_t *vm, int vtsN, int vts_ttn, int pgcn, int pgn); |
| 225 | 90 static int set_FP_PGC(vm_t *vm); |
| 91 static int set_MENU(vm_t *vm, int menu); | |
| 92 static int set_PGCN(vm_t *vm, int pgcN); | |
| 93 static int set_PGN(vm_t *vm); /* Set PGN based on (vm->state).CellN */ | |
| 94 static void set_RSMinfo(vm_t *vm, int cellN, int blockN); | |
| 95 | |
| 96 /* Get */ | |
| 97 static int get_TT(vm_t *vm, int vtsN, int vts_ttn); | |
| 98 static int get_ID(vm_t *vm, int id); | |
| 99 static int get_PGCN(vm_t *vm); | |
| 100 | |
| 101 static pgcit_t* get_MENU_PGCIT(vm_t *vm, ifo_handle_t *h, uint16_t lang); | |
| 102 static pgcit_t* get_PGCIT(vm_t *vm); | |
| 103 | |
| 104 | |
| 105 /* Helper functions */ | |
| 106 | |
| 107 #ifdef TRACE | |
| 108 static void vm_print_current_domain_state(vm_t *vm) { | |
| 109 switch((vm->state).domain) { | |
| 110 case VTS_DOMAIN: | |
| 111 fprintf(MSG_OUT, "libdvdnav: Video Title Domain: -\n"); | |
| 112 break; | |
| 113 | |
| 114 case VTSM_DOMAIN: | |
| 115 fprintf(MSG_OUT, "libdvdnav: Video Title Menu Domain: -\n"); | |
| 116 break; | |
| 117 | |
| 118 case VMGM_DOMAIN: | |
| 119 fprintf(MSG_OUT, "libdvdnav: Video Manager Menu Domain: -\n"); | |
| 120 break; | |
| 121 | |
| 388 | 122 case FP_DOMAIN: |
| 225 | 123 fprintf(MSG_OUT, "libdvdnav: First Play Domain: -\n"); |
| 124 break; | |
| 125 | |
| 126 default: | |
| 127 fprintf(MSG_OUT, "libdvdnav: Unknown Domain: -\n"); | |
| 128 break; | |
| 129 } | |
| 388 | 130 fprintf(MSG_OUT, "libdvdnav: VTS:%d PGC:%d PG:%u CELL:%u BLOCK:%u VTS_TTN:%u TTN:%u TT_PGCN:%u\n", |
| 225 | 131 (vm->state).vtsN, |
| 132 get_PGCN(vm), | |
| 133 (vm->state).pgN, | |
| 134 (vm->state).cellN, | |
| 135 (vm->state).blockN, | |
| 136 (vm->state).VTS_TTN_REG, | |
| 137 (vm->state).TTN_REG, | |
| 138 (vm->state).TT_PGCN_REG); | |
| 139 } | |
| 140 #endif | |
| 141 | |
| 394 | 142 #ifdef __OS2__ |
| 143 #define open os2_open | |
| 144 | |
| 145 static int os2_open(const char *name, int oflag) | |
| 146 { | |
| 400 | 147 HFILE hfile; |
| 148 ULONG ulAction; | |
| 149 ULONG rc; | |
| 394 | 150 |
| 400 | 151 rc = DosOpenL(name, &hfile, &ulAction, 0, FILE_NORMAL, |
| 152 OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW, | |
| 153 OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE | OPEN_FLAGS_DASD, | |
| 154 NULL); | |
| 394 | 155 |
| 400 | 156 if(rc) |
| 157 return -1; | |
| 394 | 158 |
| 400 | 159 setmode(hfile, O_BINARY); |
| 399 | 160 |
| 400 | 161 return (int)hfile; |
| 394 | 162 } |
| 163 #endif | |
| 164 | |
|
397
a70f79850e5f
implement and export dvdnav_get_serial_string(); patch by Matthew Wire devel - mrwire - co - uk. Fixed by Erik
nicodvb
parents:
395
diff
changeset
|
165 static void dvd_read_name(char *name, char *serial, const char *device) { |
| 229 | 166 /* Because we are compiling with _FILE_OFFSET_BITS=64 |
| 167 * all off_t are 64bit. | |
| 168 */ | |
| 169 off_t off; | |
| 225 | 170 int fd, i; |
| 171 uint8_t data[DVD_VIDEO_LB_LEN]; | |
| 172 | |
| 173 /* Read DVD name */ | |
|
244
a27c81078c3c
removing O_EXCL, since it does not work with DVD images
mroi
parents:
243
diff
changeset
|
174 fd = open(device, O_RDONLY); |
| 388 | 175 if (fd > 0) { |
| 229 | 176 off = lseek( fd, 32 * (off_t) DVD_VIDEO_LB_LEN, SEEK_SET ); |
| 177 if( off == ( 32 * (off_t) DVD_VIDEO_LB_LEN ) ) { | |
| 388 | 178 off = read( fd, data, DVD_VIDEO_LB_LEN ); |
| 229 | 179 if (off == ( (off_t) DVD_VIDEO_LB_LEN )) { |
| 225 | 180 fprintf(MSG_OUT, "libdvdnav: DVD Title: "); |
| 181 for(i=25; i < 73; i++ ) { | |
| 182 if((data[i] == 0)) break; | |
| 183 if((data[i] > 32) && (data[i] < 127)) { | |
| 184 fprintf(MSG_OUT, "%c", data[i]); | |
| 185 } else { | |
| 186 fprintf(MSG_OUT, " "); | |
| 187 } | |
| 188 } | |
|
377
9a9d15ed0599
(char*) typecase to silence gcc; patch by Erik Hovland org
nicodvb
parents:
345
diff
changeset
|
189 strncpy(name, (char*) &data[25], 48); |
| 225 | 190 name[48] = 0; |
| 191 fprintf(MSG_OUT, "\nlibdvdnav: DVD Serial Number: "); | |
| 192 for(i=73; i < 89; i++ ) { | |
| 193 if((data[i] == 0)) break; | |
| 194 if((data[i] > 32) && (data[i] < 127)) { | |
| 195 fprintf(MSG_OUT, "%c", data[i]); | |
| 196 } else { | |
| 197 fprintf(MSG_OUT, " "); | |
| 388 | 198 } |
| 225 | 199 } |
|
397
a70f79850e5f
implement and export dvdnav_get_serial_string(); patch by Matthew Wire devel - mrwire - co - uk. Fixed by Erik
nicodvb
parents:
395
diff
changeset
|
200 strncpy(serial, (char*) &data[73], (i-73)); |
|
a70f79850e5f
implement and export dvdnav_get_serial_string(); patch by Matthew Wire devel - mrwire - co - uk. Fixed by Erik
nicodvb
parents:
395
diff
changeset
|
201 serial[14] = 0; |
| 225 | 202 fprintf(MSG_OUT, "\nlibdvdnav: DVD Title (Alternative): "); |
| 203 for(i=89; i < 128; i++ ) { | |
| 204 if((data[i] == 0)) break; | |
| 205 if((data[i] > 32) && (data[i] < 127)) { | |
| 206 fprintf(MSG_OUT, "%c", data[i]); | |
| 207 } else { | |
| 208 fprintf(MSG_OUT, " "); | |
| 209 } | |
| 210 } | |
| 211 fprintf(MSG_OUT, "\n"); | |
| 212 } else { | |
| 213 fprintf(MSG_OUT, "libdvdnav: Can't read name block. Probably not a DVD-ROM device.\n"); | |
| 214 } | |
| 215 } else { | |
| 216 fprintf(MSG_OUT, "libdvdnav: Can't seek to block %u\n", 32 ); | |
| 217 } | |
| 218 close(fd); | |
| 219 } else { | |
| 220 fprintf(MSG_OUT, "NAME OPEN FAILED\n"); | |
| 221 } | |
| 222 } | |
| 223 | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
224 static int ifoOpenNewVTSI(vm_t *vm, dvd_reader_t *dvd, int vtsN) { |
| 225 | 225 if((vm->state).vtsN == vtsN) { |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
226 return 1; /* We alread have it */ |
| 225 | 227 } |
| 388 | 228 |
| 225 | 229 if(vm->vtsi != NULL) |
| 230 ifoClose(vm->vtsi); | |
| 388 | 231 |
| 225 | 232 vm->vtsi = ifoOpenVTSI(dvd, vtsN); |
| 233 if(vm->vtsi == NULL) { | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
234 fprintf(MSG_OUT, "libdvdnav: ifoOpenVTSI failed\n"); |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
235 return 0; |
| 225 | 236 } |
| 237 if(!ifoRead_VTS_PTT_SRPT(vm->vtsi)) { | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
238 fprintf(MSG_OUT, "libdvdnav: ifoRead_VTS_PTT_SRPT failed\n"); |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
239 return 0; |
| 225 | 240 } |
| 241 if(!ifoRead_PGCIT(vm->vtsi)) { | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
242 fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCIT failed\n"); |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
243 return 0; |
| 225 | 244 } |
| 245 if(!ifoRead_PGCI_UT(vm->vtsi)) { | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
246 fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCI_UT failed\n"); |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
247 return 0; |
| 225 | 248 } |
| 249 if(!ifoRead_VOBU_ADMAP(vm->vtsi)) { | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
250 fprintf(MSG_OUT, "libdvdnav: ifoRead_VOBU_ADMAP vtsi failed\n"); |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
251 return 0; |
| 225 | 252 } |
| 253 if(!ifoRead_TITLE_VOBU_ADMAP(vm->vtsi)) { | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
254 fprintf(MSG_OUT, "libdvdnav: ifoRead_TITLE_VOBU_ADMAP vtsi failed\n"); |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
255 return 0; |
| 225 | 256 } |
| 257 (vm->state).vtsN = vtsN; | |
| 388 | 258 |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
259 return 1; |
| 225 | 260 } |
| 261 | |
| 262 | |
| 263 /* Initialisation & Destruction */ | |
| 264 | |
| 265 vm_t* vm_new_vm() { | |
|
438
04cb2d6e4f93
In vm_new_vm(), use the proper calloc() argument order
rathann
parents:
435
diff
changeset
|
266 return (vm_t*)calloc(1, sizeof(vm_t)); |
| 225 | 267 } |
| 268 | |
| 269 void vm_free_vm(vm_t *vm) { | |
| 270 vm_stop(vm); | |
| 271 free(vm); | |
| 272 } | |
| 273 | |
| 274 | |
| 275 /* IFO Access */ | |
| 276 | |
| 277 ifo_handle_t *vm_get_vmgi(vm_t *vm) { | |
| 278 return vm->vmgi; | |
| 279 } | |
| 280 | |
| 281 ifo_handle_t *vm_get_vtsi(vm_t *vm) { | |
| 282 return vm->vtsi; | |
| 283 } | |
| 284 | |
| 285 | |
| 286 /* Reader Access */ | |
| 287 | |
| 288 dvd_reader_t *vm_get_dvd_reader(vm_t *vm) { | |
| 289 return vm->dvd; | |
| 290 } | |
| 291 | |
| 292 | |
| 293 /* Basic Handling */ | |
| 294 | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
295 int vm_start(vm_t *vm) { |
| 225 | 296 /* Set pgc to FP (First Play) pgc */ |
| 297 set_FP_PGC(vm); | |
| 298 process_command(vm, play_PGC(vm)); | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
299 return !vm->stopped; |
| 225 | 300 } |
| 301 | |
| 302 void vm_stop(vm_t *vm) { | |
| 303 if(vm->vmgi) { | |
| 304 ifoClose(vm->vmgi); | |
| 305 vm->vmgi=NULL; | |
| 306 } | |
| 307 if(vm->vtsi) { | |
| 308 ifoClose(vm->vtsi); | |
| 309 vm->vtsi=NULL; | |
| 310 } | |
| 311 if(vm->dvd) { | |
| 312 DVDClose(vm->dvd); | |
| 313 vm->dvd=NULL; | |
| 314 } | |
| 315 vm->stopped = 1; | |
| 316 } | |
| 388 | 317 |
| 225 | 318 int vm_reset(vm_t *vm, const char *dvdroot) { |
| 319 /* Setup State */ | |
| 320 memset((vm->state).registers.SPRM, 0, sizeof((vm->state).registers.SPRM)); | |
| 321 memset((vm->state).registers.GPRM, 0, sizeof((vm->state).registers.GPRM)); | |
| 322 memset((vm->state).registers.GPRM_mode, 0, sizeof((vm->state).registers.GPRM_mode)); | |
| 323 memset((vm->state).registers.GPRM_mode, 0, sizeof((vm->state).registers.GPRM_mode)); | |
| 324 memset((vm->state).registers.GPRM_time, 0, sizeof((vm->state).registers.GPRM_time)); | |
| 325 (vm->state).registers.SPRM[0] = ('e'<<8)|'n'; /* Player Menu Languange code */ | |
| 326 (vm->state).AST_REG = 15; /* 15 why? */ | |
| 327 (vm->state).SPST_REG = 62; /* 62 why? */ | |
| 328 (vm->state).AGL_REG = 1; | |
| 329 (vm->state).TTN_REG = 1; | |
| 330 (vm->state).VTS_TTN_REG = 1; | |
| 331 /* (vm->state).TT_PGCN_REG = 0 */ | |
| 332 (vm->state).PTTN_REG = 1; | |
| 333 (vm->state).HL_BTNN_REG = 1 << 10; | |
| 334 (vm->state).PTL_REG = 15; /* Parental Level */ | |
| 335 (vm->state).registers.SPRM[12] = ('U'<<8)|'S'; /* Parental Management Country Code */ | |
| 336 (vm->state).registers.SPRM[16] = ('e'<<8)|'n'; /* Initial Language Code for Audio */ | |
| 337 (vm->state).registers.SPRM[18] = ('e'<<8)|'n'; /* Initial Language Code for Spu */ | |
| 338 (vm->state).registers.SPRM[20] = 0x1; /* Player Regional Code Mask. Region free! */ | |
| 339 (vm->state).registers.SPRM[14] = 0x100; /* Try Pan&Scan */ | |
| 388 | 340 |
| 225 | 341 (vm->state).pgN = 0; |
| 342 (vm->state).cellN = 0; | |
| 343 (vm->state).cell_restart = 0; | |
| 344 | |
| 345 (vm->state).domain = FP_DOMAIN; | |
| 346 (vm->state).rsm_vtsN = 0; | |
| 347 (vm->state).rsm_cellN = 0; | |
| 348 (vm->state).rsm_blockN = 0; | |
| 388 | 349 |
| 225 | 350 (vm->state).vtsN = -1; |
| 388 | 351 |
|
435
29d4a43c8c86
Reset vm->hop_channel while resetting everything else in vm_reset
rathann
parents:
433
diff
changeset
|
352 vm->hop_channel = 0; |
|
29d4a43c8c86
Reset vm->hop_channel while resetting everything else in vm_reset
rathann
parents:
433
diff
changeset
|
353 |
| 225 | 354 if (vm->dvd && dvdroot) { |
| 355 /* a new dvd device has been requested */ | |
| 356 vm_stop(vm); | |
| 357 } | |
| 358 if (!vm->dvd) { | |
| 359 vm->dvd = DVDOpen(dvdroot); | |
| 360 if(!vm->dvd) { | |
| 260 | 361 fprintf(MSG_OUT, "libdvdnav: vm: failed to open/read the DVD\n"); |
| 225 | 362 return 0; |
| 363 } | |
| 364 vm->vmgi = ifoOpenVMGI(vm->dvd); | |
| 365 if(!vm->vmgi) { | |
| 260 | 366 fprintf(MSG_OUT, "libdvdnav: vm: failed to read VIDEO_TS.IFO\n"); |
| 225 | 367 return 0; |
| 368 } | |
| 369 if(!ifoRead_FP_PGC(vm->vmgi)) { | |
| 370 fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_FP_PGC failed\n"); | |
| 371 return 0; | |
| 372 } | |
| 373 if(!ifoRead_TT_SRPT(vm->vmgi)) { | |
| 374 fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_TT_SRPT failed\n"); | |
| 375 return 0; | |
| 376 } | |
| 377 if(!ifoRead_PGCI_UT(vm->vmgi)) { | |
| 378 fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_PGCI_UT failed\n"); | |
| 379 return 0; | |
| 380 } | |
| 381 if(!ifoRead_PTL_MAIT(vm->vmgi)) { | |
| 382 fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_PTL_MAIT failed\n"); | |
| 383 /* return 0; Not really used for now.. */ | |
| 384 } | |
| 385 if(!ifoRead_VTS_ATRT(vm->vmgi)) { | |
| 386 fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_VTS_ATRT failed\n"); | |
| 387 /* return 0; Not really used for now.. */ | |
| 388 } | |
| 389 if(!ifoRead_VOBU_ADMAP(vm->vmgi)) { | |
| 390 fprintf(MSG_OUT, "libdvdnav: vm: ifoRead_VOBU_ADMAP vgmi failed\n"); | |
| 391 /* return 0; Not really used for now.. */ | |
| 392 } | |
| 393 /* ifoRead_TXTDT_MGI(vmgi); Not implemented yet */ | |
|
404
d16ee5945580
Prevent display of garbage volume label when the file being scanned is
nicodvb
parents:
403
diff
changeset
|
394 dvd_read_name(vm->dvd_name, vm->dvd_serial, dvdroot); |
|
d16ee5945580
Prevent display of garbage volume label when the file being scanned is
nicodvb
parents:
403
diff
changeset
|
395 vm->map = remap_loadmap(vm->dvd_name); |
| 225 | 396 } |
| 397 if (vm->vmgi) { | |
| 398 int i, mask; | |
| 399 fprintf(MSG_OUT, "libdvdnav: DVD disk reports itself with Region mask 0x%08x. Regions:", | |
| 400 vm->vmgi->vmgi_mat->vmg_category); | |
| 401 for (i = 1, mask = 1; i <= 8; i++, mask <<= 1) | |
| 402 if (((vm->vmgi->vmgi_mat->vmg_category >> 16) & mask) == 0) | |
| 403 fprintf(MSG_OUT, " %d", i); | |
| 404 fprintf(MSG_OUT, "\n"); | |
| 405 } | |
| 406 return 1; | |
| 407 } | |
| 408 | |
| 409 | |
| 410 /* copying and merging */ | |
| 411 | |
| 412 vm_t *vm_new_copy(vm_t *source) { | |
| 413 vm_t *target = vm_new_vm(); | |
| 414 int vtsN; | |
| 415 int pgcN = get_PGCN(source); | |
| 416 int pgN = (source->state).pgN; | |
| 388 | 417 |
| 225 | 418 assert(pgcN); |
| 388 | 419 |
| 225 | 420 memcpy(target, source, sizeof(vm_t)); |
| 388 | 421 |
| 225 | 422 /* open a new vtsi handle, because the copy might switch to another VTS */ |
| 423 target->vtsi = NULL; | |
| 424 vtsN = (target->state).vtsN; | |
| 425 if (vtsN > 0) { | |
| 426 (target->state).vtsN = 0; | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
427 if (!ifoOpenNewVTSI(target, target->dvd, vtsN)) |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
428 assert(0); |
| 388 | 429 |
| 225 | 430 /* restore pgc pointer into the new vtsi */ |
| 431 if (!set_PGCN(target, pgcN)) | |
| 432 assert(0); | |
| 433 (target->state).pgN = pgN; | |
| 434 } | |
| 388 | 435 |
| 225 | 436 return target; |
| 437 } | |
| 438 | |
| 439 void vm_merge(vm_t *target, vm_t *source) { | |
| 440 if(target->vtsi) | |
| 441 ifoClose(target->vtsi); | |
| 442 memcpy(target, source, sizeof(vm_t)); | |
| 443 memset(source, 0, sizeof(vm_t)); | |
| 444 } | |
| 445 | |
| 446 void vm_free_copy(vm_t *vm) { | |
| 447 if(vm->vtsi) | |
| 448 ifoClose(vm->vtsi); | |
| 449 free(vm); | |
| 450 } | |
| 451 | |
| 452 | |
| 453 /* regular playback */ | |
| 454 | |
| 455 void vm_position_get(vm_t *vm, vm_position_t *position) { | |
| 456 position->button = (vm->state).HL_BTNN_REG >> 10; | |
| 388 | 457 position->vts = (vm->state).vtsN; |
| 458 position->domain = (vm->state).domain; | |
| 225 | 459 position->spu_channel = (vm->state).SPST_REG; |
| 460 position->audio_channel = (vm->state).AST_REG; | |
| 461 position->angle_channel = (vm->state).AGL_REG; | |
| 462 position->hop_channel = vm->hop_channel; /* Increases by one on each hop */ | |
| 463 position->cell = (vm->state).cellN; | |
| 464 position->cell_restart = (vm->state).cell_restart; | |
| 465 position->cell_start = (vm->state).pgc->cell_playback[(vm->state).cellN - 1].first_sector; | |
| 466 position->still = (vm->state).pgc->cell_playback[(vm->state).cellN - 1].still_time; | |
| 467 position->block = (vm->state).blockN; | |
| 468 | |
| 469 /* handle PGC stills at PGC end */ | |
| 470 if ((vm->state).cellN == (vm->state).pgc->nr_of_cells) | |
| 471 position->still += (vm->state).pgc->still_time; | |
| 472 /* still already determined */ | |
| 473 if (position->still) | |
| 474 return; | |
| 475 /* This is a rough fix for some strange still situations on some strange DVDs. | |
| 476 * There are discs (like the German "Back to the Future" RC2) where the only | |
| 477 * indication of a still is a cell playback time higher than the time the frames | |
| 478 * in this cell actually take to play (like 1 frame with 1 minute playback time). | |
| 479 * On the said BTTF disc, for these cells last_sector and last_vobu_start_sector | |
| 480 * are equal and the cells are very short, so we abuse these conditions to | |
| 481 * detect such discs. I consider these discs broken, so the fix is somewhat | |
| 482 * broken, too. */ | |
| 483 if (((vm->state).pgc->cell_playback[(vm->state).cellN - 1].last_sector == | |
| 484 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].last_vobu_start_sector) && | |
| 485 ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].last_sector - | |
| 486 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].first_sector < 1024)) { | |
| 487 int time; | |
| 488 int size = (vm->state).pgc->cell_playback[(vm->state).cellN - 1].last_sector - | |
| 489 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].first_sector; | |
| 490 time = ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].playback_time.hour >> 4 ) * 36000; | |
| 491 time += ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].playback_time.hour & 0x0f) * 3600; | |
| 492 time += ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].playback_time.minute >> 4 ) * 600; | |
| 493 time += ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].playback_time.minute & 0x0f) * 60; | |
| 494 time += ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].playback_time.second >> 4 ) * 10; | |
| 495 time += ((vm->state).pgc->cell_playback[(vm->state).cellN - 1].playback_time.second & 0x0f) * 1; | |
| 246 | 496 if (!time || size / time > 30) |
| 225 | 497 /* datarate is too high, it might be a very short, but regular cell */ |
| 498 return; | |
| 499 if (time > 0xff) time = 0xff; | |
| 500 position->still = time; | |
| 501 } | |
| 502 } | |
| 503 | |
| 504 void vm_get_next_cell(vm_t *vm) { | |
| 505 process_command(vm, play_Cell_post(vm)); | |
| 506 } | |
| 507 | |
| 508 | |
| 509 /* Jumping */ | |
| 510 | |
| 511 int vm_jump_pg(vm_t *vm, int pg) { | |
| 512 (vm->state).pgN = pg; | |
| 513 process_command(vm, play_PG(vm)); | |
| 514 return 1; | |
| 515 } | |
| 516 | |
| 517 int vm_jump_cell_block(vm_t *vm, int cell, int block) { | |
| 518 (vm->state).cellN = cell; | |
| 519 process_command(vm, play_Cell(vm)); | |
| 520 /* play_Cell can jump to a different cell in case of angles */ | |
| 521 if ((vm->state).cellN == cell) | |
| 522 (vm->state).blockN = block; | |
| 523 return 1; | |
| 524 } | |
| 525 | |
|
409
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
526 int vm_jump_title_program(vm_t *vm, int title, int pgcn, int pgn) { |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
527 link_t link; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
528 |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
529 if(!set_PROG(vm, title, pgcn, pgn)) |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
530 return 0; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
531 /* Some DVDs do not want us to jump directly into a title and have |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
532 * PGC pre commands taking us back to some menu. Since we do not like that, |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
533 * we do not execute PGC pre commands that would do a jump. */ |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
534 /* process_command(vm, play_PGC_PG(vm, (vm->state).pgN)); */ |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
535 link = play_PGC_PG(vm, (vm->state).pgN); |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
536 if (link.command != PlayThis) |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
537 /* jump occured -> ignore it and play the PG anyway */ |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
538 process_command(vm, play_PG(vm)); |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
539 else |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
540 process_command(vm, link); |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
541 return 1; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
542 } |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
543 |
| 225 | 544 int vm_jump_title_part(vm_t *vm, int title, int part) { |
| 545 link_t link; | |
| 388 | 546 |
| 225 | 547 if(!set_PTT(vm, title, part)) |
| 548 return 0; | |
| 549 /* Some DVDs do not want us to jump directly into a title and have | |
| 550 * PGC pre commands taking us back to some menu. Since we do not like that, | |
| 551 * we do not execute PGC pre commands that would do a jump. */ | |
| 552 /* process_command(vm, play_PGC_PG(vm, (vm->state).pgN)); */ | |
| 553 link = play_PGC_PG(vm, (vm->state).pgN); | |
| 554 if (link.command != PlayThis) | |
| 555 /* jump occured -> ignore it and play the PG anyway */ | |
| 556 process_command(vm, play_PG(vm)); | |
| 557 else | |
| 558 process_command(vm, link); | |
| 559 return 1; | |
| 560 } | |
| 561 | |
| 562 int vm_jump_top_pg(vm_t *vm) { | |
| 563 process_command(vm, play_PG(vm)); | |
| 564 return 1; | |
| 565 } | |
| 566 | |
| 567 int vm_jump_next_pg(vm_t *vm) { | |
| 568 if((vm->state).pgN >= (vm->state).pgc->nr_of_programs) { | |
| 569 /* last program -> move to TailPGC */ | |
| 570 process_command(vm, play_PGC_post(vm)); | |
| 571 return 1; | |
| 572 } else { | |
| 573 vm_jump_pg(vm, (vm->state).pgN + 1); | |
| 574 return 1; | |
| 575 } | |
| 576 } | |
| 577 | |
| 578 int vm_jump_prev_pg(vm_t *vm) { | |
| 579 if ((vm->state).pgN <= 1) { | |
| 580 /* first program -> move to last program of previous PGC */ | |
| 581 if ((vm->state).pgc->prev_pgc_nr && set_PGCN(vm, (vm->state).pgc->prev_pgc_nr)) { | |
| 582 process_command(vm, play_PGC(vm)); | |
| 583 vm_jump_pg(vm, (vm->state).pgc->nr_of_programs); | |
| 584 return 1; | |
| 585 } | |
| 586 return 0; | |
| 587 } else { | |
| 588 vm_jump_pg(vm, (vm->state).pgN - 1); | |
| 589 return 1; | |
| 590 } | |
| 591 } | |
| 592 | |
| 593 int vm_jump_up(vm_t *vm) { | |
| 594 if((vm->state).pgc->goup_pgc_nr && set_PGCN(vm, (vm->state).pgc->goup_pgc_nr)) { | |
| 595 process_command(vm, play_PGC(vm)); | |
| 596 return 1; | |
| 597 } | |
| 598 return 0; | |
| 599 } | |
| 600 | |
| 601 int vm_jump_menu(vm_t *vm, DVDMenuID_t menuid) { | |
| 602 domain_t old_domain = (vm->state).domain; | |
| 388 | 603 |
| 225 | 604 switch ((vm->state).domain) { |
| 605 case VTS_DOMAIN: | |
| 606 set_RSMinfo(vm, 0, (vm->state).blockN); | |
| 607 /* FALL THROUGH */ | |
| 608 case VTSM_DOMAIN: | |
| 609 case VMGM_DOMAIN: | |
| 610 switch(menuid) { | |
| 611 case DVD_MENU_Title: | |
| 612 case DVD_MENU_Escape: | |
| 412 | 613 if(vm->vmgi == NULL || vm->vmgi->pgci_ut == NULL) { |
| 614 return 0; | |
| 615 } | |
| 225 | 616 (vm->state).domain = VMGM_DOMAIN; |
| 617 break; | |
| 618 case DVD_MENU_Root: | |
| 619 case DVD_MENU_Subpicture: | |
| 620 case DVD_MENU_Audio: | |
| 621 case DVD_MENU_Angle: | |
| 622 case DVD_MENU_Part: | |
| 412 | 623 if(vm->vtsi == NULL || vm->vtsi->pgci_ut == NULL) { |
| 624 return 0; | |
| 625 } | |
| 225 | 626 (vm->state).domain = VTSM_DOMAIN; |
| 627 break; | |
| 628 } | |
| 412 | 629 if(get_PGCIT(vm) && set_MENU(vm, menuid)) { |
| 225 | 630 process_command(vm, play_PGC(vm)); |
| 631 return 1; /* Jump */ | |
| 632 } else { | |
| 633 (vm->state).domain = old_domain; | |
| 634 } | |
| 635 break; | |
| 636 case FP_DOMAIN: /* FIXME XXX $$$ What should we do here? */ | |
| 637 break; | |
| 638 } | |
| 388 | 639 |
| 225 | 640 return 0; |
| 641 } | |
| 642 | |
| 643 int vm_jump_resume(vm_t *vm) { | |
| 644 link_t link_values = { LinkRSM, 0, 0, 0 }; | |
| 645 | |
| 646 if (!(vm->state).rsm_vtsN) /* Do we have resume info? */ | |
| 647 return 0; | |
| 648 if (!process_command(vm, link_values)) | |
| 649 return 0; | |
| 650 return 1; | |
| 651 } | |
| 652 | |
| 653 int vm_exec_cmd(vm_t *vm, vm_cmd_t *cmd) { | |
| 654 link_t link_values; | |
| 388 | 655 |
| 225 | 656 if(vmEval_CMD(cmd, 1, &(vm->state).registers, &link_values)) |
| 657 return process_command(vm, link_values); | |
| 658 else | |
| 659 return 0; /* It updated some state thats all... */ | |
| 660 } | |
| 661 | |
| 662 | |
| 663 /* getting information */ | |
| 664 | |
| 665 int vm_get_current_menu(vm_t *vm, int *menuid) { | |
| 666 pgcit_t* pgcit; | |
| 667 int pgcn; | |
| 668 pgcn = (vm->state).pgcN; | |
| 669 pgcit = get_PGCIT(vm); | |
|
345
f051b111ef50
10l to me: in vm_get_current_menu() I forgot to attach
nicodvb
parents:
344
diff
changeset
|
670 if(pgcit==NULL) return 0; |
| 225 | 671 *menuid = pgcit->pgci_srp[pgcn - 1].entry_id & 0xf ; |
| 672 return 1; | |
| 673 } | |
| 674 | |
| 675 int vm_get_current_title_part(vm_t *vm, int *title_result, int *part_result) { | |
| 676 vts_ptt_srpt_t *vts_ptt_srpt; | |
| 677 int title, part = 0, vts_ttn; | |
| 678 int found; | |
| 679 int16_t pgcN, pgN; | |
| 680 | |
| 681 vts_ptt_srpt = vm->vtsi->vts_ptt_srpt; | |
| 682 pgcN = get_PGCN(vm); | |
| 683 pgN = vm->state.pgN; | |
| 684 | |
| 685 found = 0; | |
| 686 for (vts_ttn = 0; (vts_ttn < vts_ptt_srpt->nr_of_srpts) && !found; vts_ttn++) { | |
| 687 for (part = 0; (part < vts_ptt_srpt->title[vts_ttn].nr_of_ptts) && !found; part++) { | |
| 688 if (vts_ptt_srpt->title[vts_ttn].ptt[part].pgcn == pgcN) { | |
| 689 if (vts_ptt_srpt->title[vts_ttn].ptt[part].pgn == pgN) { | |
| 690 found = 1; | |
| 691 break; | |
| 692 } | |
| 693 if (part > 0 && vts_ptt_srpt->title[vts_ttn].ptt[part].pgn > pgN && | |
| 694 vts_ptt_srpt->title[vts_ttn].ptt[part - 1].pgn < pgN) { | |
| 695 part--; | |
| 696 found = 1; | |
| 697 break; | |
| 698 } | |
| 699 } | |
| 700 } | |
| 701 if (found) break; | |
| 702 } | |
| 703 vts_ttn++; | |
| 704 part++; | |
| 388 | 705 |
| 225 | 706 if (!found) { |
| 707 fprintf(MSG_OUT, "libdvdnav: chapter NOT FOUND!\n"); | |
| 708 return 0; | |
| 709 } | |
| 710 | |
| 711 title = get_TT(vm, vm->state.vtsN, vts_ttn); | |
| 712 | |
| 713 #ifdef TRACE | |
| 714 if (title) { | |
| 715 fprintf(MSG_OUT, "libdvdnav: ************ this chapter FOUND!\n"); | |
| 716 fprintf(MSG_OUT, "libdvdnav: VTS_PTT_SRPT - Title %3i part %3i: PGC: %3i PG: %3i\n", | |
| 717 title, part, | |
| 718 vts_ptt_srpt->title[vts_ttn-1].ptt[part-1].pgcn , | |
| 719 vts_ptt_srpt->title[vts_ttn-1].ptt[part-1].pgn ); | |
| 720 } | |
| 721 #endif | |
| 722 *title_result = title; | |
| 723 *part_result = part; | |
| 724 return 1; | |
| 725 } | |
| 726 | |
| 727 /* Return the substream id for 'logical' audio stream audioN. | |
| 728 * 0 <= audioN < 8 | |
| 729 */ | |
| 730 int vm_get_audio_stream(vm_t *vm, int audioN) { | |
| 731 int streamN = -1; | |
| 732 | |
| 733 if((vm->state).domain != VTS_DOMAIN) | |
| 734 audioN = 0; | |
| 388 | 735 |
| 225 | 736 if(audioN < 8) { |
| 388 | 737 /* Is there any control info for this logical stream */ |
| 225 | 738 if((vm->state).pgc->audio_control[audioN] & (1<<15)) { |
| 388 | 739 streamN = ((vm->state).pgc->audio_control[audioN] >> 8) & 0x07; |
| 225 | 740 } |
| 741 } | |
| 388 | 742 |
| 225 | 743 if((vm->state).domain != VTS_DOMAIN && streamN == -1) |
| 744 streamN = 0; | |
| 388 | 745 |
| 225 | 746 /* FIXME: Should also check in vtsi/vmgi status what kind of stream |
| 747 * it is (ac3/lpcm/dts/sdds...) to find the right (sub)stream id */ | |
| 748 return streamN; | |
| 749 } | |
| 750 | |
| 751 /* Return the substream id for 'logical' subpicture stream subpN and given mode. | |
| 752 * 0 <= subpN < 32 | |
| 753 * mode == 0 - widescreen | |
| 754 * mode == 1 - letterbox | |
| 755 * mode == 2 - pan&scan | |
| 756 */ | |
| 757 int vm_get_subp_stream(vm_t *vm, int subpN, int mode) { | |
| 758 int streamN = -1; | |
| 759 int source_aspect = vm_get_video_aspect(vm); | |
| 388 | 760 |
| 225 | 761 if((vm->state).domain != VTS_DOMAIN) |
| 762 subpN = 0; | |
| 388 | 763 |
| 225 | 764 if(subpN < 32) { /* a valid logical stream */ |
| 388 | 765 /* Is this logical stream present */ |
| 225 | 766 if((vm->state).pgc->subp_control[subpN] & (1<<31)) { |
| 388 | 767 if(source_aspect == 0) /* 4:3 */ |
| 768 streamN = ((vm->state).pgc->subp_control[subpN] >> 24) & 0x1f; | |
| 225 | 769 if(source_aspect == 3) /* 16:9 */ |
| 770 switch (mode) { | |
| 771 case 0: | |
| 772 streamN = ((vm->state).pgc->subp_control[subpN] >> 16) & 0x1f; | |
| 773 break; | |
| 774 case 1: | |
| 775 streamN = ((vm->state).pgc->subp_control[subpN] >> 8) & 0x1f; | |
| 776 break; | |
| 777 case 2: | |
| 778 streamN = (vm->state).pgc->subp_control[subpN] & 0x1f; | |
| 779 } | |
| 780 } | |
| 781 } | |
| 388 | 782 |
| 247 | 783 if((vm->state).domain != VTS_DOMAIN && streamN == -1) |
| 784 streamN = 0; | |
| 225 | 785 |
| 786 /* FIXME: Should also check in vtsi/vmgi status what kind of stream it is. */ | |
| 787 return streamN; | |
| 788 } | |
| 789 | |
| 790 int vm_get_audio_active_stream(vm_t *vm) { | |
| 791 int audioN; | |
| 792 int streamN; | |
| 793 audioN = (vm->state).AST_REG ; | |
| 794 streamN = vm_get_audio_stream(vm, audioN); | |
| 388 | 795 |
| 225 | 796 /* If no such stream, then select the first one that exists. */ |
| 797 if(streamN == -1) { | |
| 798 for(audioN = 0; audioN < 8; audioN++) { | |
| 799 if((vm->state).pgc->audio_control[audioN] & (1<<15)) { | |
| 800 if ((streamN = vm_get_audio_stream(vm, audioN)) >= 0) | |
| 801 break; | |
| 802 } | |
| 803 } | |
| 804 } | |
| 805 | |
| 806 return streamN; | |
| 807 } | |
| 808 | |
| 809 int vm_get_subp_active_stream(vm_t *vm, int mode) { | |
| 810 int subpN; | |
| 811 int streamN; | |
| 812 subpN = (vm->state).SPST_REG & ~0x40; | |
| 813 streamN = vm_get_subp_stream(vm, subpN, mode); | |
| 388 | 814 |
| 225 | 815 /* If no such stream, then select the first one that exists. */ |
| 816 if(streamN == -1) { | |
| 817 for(subpN = 0; subpN < 32; subpN++) { | |
| 818 if((vm->state).pgc->subp_control[subpN] & (1<<31)) { | |
| 819 if ((streamN = vm_get_subp_stream(vm, subpN, mode)) >= 0) | |
| 820 break; | |
| 821 } | |
| 822 } | |
| 823 } | |
| 824 | |
| 825 if((vm->state).domain == VTS_DOMAIN && !((vm->state).SPST_REG & 0x40)) | |
| 826 /* Bit 7 set means hide, and only let Forced display show */ | |
| 827 return (streamN | 0x80); | |
| 828 else | |
| 829 return streamN; | |
| 830 } | |
| 831 | |
| 832 void vm_get_angle_info(vm_t *vm, int *current, int *num_avail) { | |
| 833 *num_avail = 1; | |
| 834 *current = 1; | |
| 388 | 835 |
| 225 | 836 if((vm->state).domain == VTS_DOMAIN) { |
| 837 title_info_t *title; | |
| 838 /* TTN_REG does not allways point to the correct title.. */ | |
| 839 if((vm->state).TTN_REG > vm->vmgi->tt_srpt->nr_of_srpts) | |
| 840 return; | |
| 841 title = &vm->vmgi->tt_srpt->title[(vm->state).TTN_REG - 1]; | |
| 388 | 842 if(title->title_set_nr != (vm->state).vtsN || |
| 225 | 843 title->vts_ttn != (vm->state).VTS_TTN_REG) |
| 388 | 844 return; |
| 225 | 845 *num_avail = title->nr_of_angles; |
| 846 *current = (vm->state).AGL_REG; | |
| 847 } | |
| 848 } | |
| 849 | |
| 850 #if 0 | |
| 851 /* currently unused */ | |
| 852 void vm_get_audio_info(vm_t *vm, int *current, int *num_avail) { | |
| 853 switch ((vm->state).domain) { | |
| 854 case VTS_DOMAIN: | |
| 855 *num_avail = vm->vtsi->vtsi_mat->nr_of_vts_audio_streams; | |
| 856 *current = (vm->state).AST_REG; | |
| 857 break; | |
| 858 case VTSM_DOMAIN: | |
| 859 *num_avail = vm->vtsi->vtsi_mat->nr_of_vtsm_audio_streams; /* 1 */ | |
| 860 *current = 1; | |
| 861 break; | |
| 862 case VMGM_DOMAIN: | |
| 863 case FP_DOMAIN: | |
| 864 *num_avail = vm->vmgi->vmgi_mat->nr_of_vmgm_audio_streams; /* 1 */ | |
| 865 *current = 1; | |
| 866 break; | |
| 867 } | |
| 868 } | |
| 869 | |
| 870 /* currently unused */ | |
| 871 void vm_get_subp_info(vm_t *vm, int *current, int *num_avail) { | |
| 872 switch ((vm->state).domain) { | |
| 873 case VTS_DOMAIN: | |
| 874 *num_avail = vm->vtsi->vtsi_mat->nr_of_vts_subp_streams; | |
| 875 *current = (vm->state).SPST_REG; | |
| 876 break; | |
| 877 case VTSM_DOMAIN: | |
| 878 *num_avail = vm->vtsi->vtsi_mat->nr_of_vtsm_subp_streams; /* 1 */ | |
| 879 *current = 0x41; | |
| 880 break; | |
| 881 case VMGM_DOMAIN: | |
| 882 case FP_DOMAIN: | |
| 883 *num_avail = vm->vmgi->vmgi_mat->nr_of_vmgm_subp_streams; /* 1 */ | |
| 884 *current = 0x41; | |
| 885 break; | |
| 886 } | |
| 887 } | |
| 401 | 888 #endif |
| 225 | 889 |
| 890 void vm_get_video_res(vm_t *vm, int *width, int *height) { | |
| 891 video_attr_t attr = vm_get_video_attr(vm); | |
| 388 | 892 |
| 893 if(attr.video_format != 0) | |
| 225 | 894 *height = 576; |
| 895 else | |
| 896 *height = 480; | |
| 897 switch(attr.picture_size) { | |
| 898 case 0: | |
| 899 *width = 720; | |
| 900 break; | |
| 901 case 1: | |
| 902 *width = 704; | |
| 903 break; | |
| 904 case 2: | |
| 905 *width = 352; | |
| 906 break; | |
| 907 case 3: | |
| 908 *width = 352; | |
| 909 *height /= 2; | |
| 910 break; | |
| 911 } | |
| 912 } | |
| 913 | |
| 914 int vm_get_video_aspect(vm_t *vm) { | |
| 915 int aspect = vm_get_video_attr(vm).display_aspect_ratio; | |
| 388 | 916 |
| 225 | 917 assert(aspect == 0 || aspect == 3); |
| 918 (vm->state).registers.SPRM[14] &= ~(0x3 << 10); | |
| 919 (vm->state).registers.SPRM[14] |= aspect << 10; | |
| 388 | 920 |
| 225 | 921 return aspect; |
| 922 } | |
| 923 | |
| 924 int vm_get_video_scale_permission(vm_t *vm) { | |
| 925 return vm_get_video_attr(vm).permitted_df; | |
| 926 } | |
| 927 | |
| 928 video_attr_t vm_get_video_attr(vm_t *vm) { | |
| 929 switch ((vm->state).domain) { | |
| 930 case VTS_DOMAIN: | |
| 931 return vm->vtsi->vtsi_mat->vts_video_attr; | |
| 932 case VTSM_DOMAIN: | |
| 933 return vm->vtsi->vtsi_mat->vtsm_video_attr; | |
| 934 case VMGM_DOMAIN: | |
| 935 case FP_DOMAIN: | |
| 936 return vm->vmgi->vmgi_mat->vmgm_video_attr; | |
|
243
e75c52894630
* assert(0) does not always and the program (see NDEBUG)
mroi
parents:
229
diff
changeset
|
937 default: |
|
e75c52894630
* assert(0) does not always and the program (see NDEBUG)
mroi
parents:
229
diff
changeset
|
938 abort(); |
| 225 | 939 } |
| 940 } | |
| 941 | |
| 942 audio_attr_t vm_get_audio_attr(vm_t *vm, int streamN) { | |
| 943 switch ((vm->state).domain) { | |
| 944 case VTS_DOMAIN: | |
| 945 return vm->vtsi->vtsi_mat->vts_audio_attr[streamN]; | |
| 946 case VTSM_DOMAIN: | |
| 947 return vm->vtsi->vtsi_mat->vtsm_audio_attr; | |
| 948 case VMGM_DOMAIN: | |
| 949 case FP_DOMAIN: | |
| 950 return vm->vmgi->vmgi_mat->vmgm_audio_attr; | |
|
243
e75c52894630
* assert(0) does not always and the program (see NDEBUG)
mroi
parents:
229
diff
changeset
|
951 default: |
|
e75c52894630
* assert(0) does not always and the program (see NDEBUG)
mroi
parents:
229
diff
changeset
|
952 abort(); |
| 225 | 953 } |
| 954 } | |
| 955 | |
| 956 subp_attr_t vm_get_subp_attr(vm_t *vm, int streamN) { | |
| 957 switch ((vm->state).domain) { | |
| 958 case VTS_DOMAIN: | |
| 959 return vm->vtsi->vtsi_mat->vts_subp_attr[streamN]; | |
| 960 case VTSM_DOMAIN: | |
| 961 return vm->vtsi->vtsi_mat->vtsm_subp_attr; | |
| 962 case VMGM_DOMAIN: | |
| 963 case FP_DOMAIN: | |
| 964 return vm->vmgi->vmgi_mat->vmgm_subp_attr; | |
|
243
e75c52894630
* assert(0) does not always and the program (see NDEBUG)
mroi
parents:
229
diff
changeset
|
965 default: |
|
e75c52894630
* assert(0) does not always and the program (see NDEBUG)
mroi
parents:
229
diff
changeset
|
966 abort(); |
| 225 | 967 } |
| 968 } | |
| 969 | |
| 970 | |
| 971 /* Playback control */ | |
| 972 | |
| 973 static link_t play_PGC(vm_t *vm) { | |
| 974 link_t link_values; | |
| 388 | 975 |
| 225 | 976 #ifdef TRACE |
| 977 fprintf(MSG_OUT, "libdvdnav: play_PGC:"); | |
| 978 if((vm->state).domain != FP_DOMAIN) { | |
| 979 fprintf(MSG_OUT, " (vm->state).pgcN (%i)\n", get_PGCN(vm)); | |
| 980 } else { | |
| 981 fprintf(MSG_OUT, " first_play_pgc\n"); | |
| 982 } | |
| 983 #endif | |
| 984 | |
| 985 /* This must be set before the pre-commands are executed because they | |
| 986 * might contain a CallSS that will save resume state */ | |
| 987 | |
| 988 /* FIXME: This may be only a temporary fix for something... */ | |
| 989 (vm->state).pgN = 1; | |
| 990 (vm->state).cellN = 0; | |
| 991 (vm->state).blockN = 0; | |
| 992 | |
| 388 | 993 /* eval -> updates the state and returns either |
| 225 | 994 - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN) |
| 995 - just play video i.e first PG | |
| 996 (This is what happens if you fall of the end of the pre_cmds) | |
| 997 - or an error (are there more cases?) */ | |
| 998 if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_pre) { | |
| 388 | 999 if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds, |
| 1000 (vm->state).pgc->command_tbl->nr_of_pre, | |
| 225 | 1001 &(vm->state).registers, &link_values)) { |
| 1002 /* link_values contains the 'jump' return value */ | |
| 1003 return link_values; | |
| 1004 } else { | |
| 1005 #ifdef TRACE | |
| 1006 fprintf(MSG_OUT, "libdvdnav: PGC pre commands didn't do a Jump, Link or Call\n"); | |
| 1007 #endif | |
| 1008 } | |
| 1009 } | |
| 1010 return play_PG(vm); | |
| 388 | 1011 } |
| 225 | 1012 |
| 388 | 1013 static link_t play_PGC_PG(vm_t *vm, int pgN) { |
| 225 | 1014 link_t link_values; |
| 388 | 1015 |
| 225 | 1016 #ifdef TRACE |
| 1017 fprintf(MSG_OUT, "libdvdnav: play_PGC_PG:"); | |
| 1018 if((vm->state).domain != FP_DOMAIN) { | |
| 1019 fprintf(MSG_OUT, " (vm->state).pgcN (%i)\n", get_PGCN(vm)); | |
| 1020 } else { | |
| 1021 fprintf(MSG_OUT, " first_play_pgc\n"); | |
| 1022 } | |
| 1023 #endif | |
| 1024 | |
| 1025 /* This must be set before the pre-commands are executed because they | |
| 1026 * might contain a CallSS that will save resume state */ | |
| 1027 | |
| 1028 /* FIXME: This may be only a temporary fix for something... */ | |
| 1029 (vm->state).pgN = pgN; | |
| 1030 (vm->state).cellN = 0; | |
| 1031 (vm->state).blockN = 0; | |
| 1032 | |
| 388 | 1033 /* eval -> updates the state and returns either |
| 225 | 1034 - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN) |
| 1035 - just play video i.e first PG | |
| 1036 (This is what happens if you fall of the end of the pre_cmds) | |
| 1037 - or an error (are there more cases?) */ | |
| 1038 if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_pre) { | |
| 388 | 1039 if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds, |
| 1040 (vm->state).pgc->command_tbl->nr_of_pre, | |
| 225 | 1041 &(vm->state).registers, &link_values)) { |
| 1042 /* link_values contains the 'jump' return value */ | |
| 1043 return link_values; | |
| 1044 } else { | |
| 1045 #ifdef TRACE | |
| 1046 fprintf(MSG_OUT, "libdvdnav: PGC pre commands didn't do a Jump, Link or Call\n"); | |
| 1047 #endif | |
| 1048 } | |
| 1049 } | |
| 1050 return play_PG(vm); | |
| 388 | 1051 } |
| 225 | 1052 |
| 1053 static link_t play_PGC_post(vm_t *vm) { | |
| 1054 link_t link_values; | |
| 1055 | |
| 1056 #ifdef TRACE | |
| 1057 fprintf(MSG_OUT, "libdvdnav: play_PGC_post:\n"); | |
| 1058 #endif | |
| 388 | 1059 |
| 1060 /* eval -> updates the state and returns either | |
| 225 | 1061 - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN) |
| 1062 - just go to next PGC | |
| 1063 (This is what happens if you fall of the end of the post_cmds) | |
| 1064 - or an error (are there more cases?) */ | |
| 1065 if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_post && | |
| 1066 vmEval_CMD((vm->state).pgc->command_tbl->post_cmds, | |
| 388 | 1067 (vm->state).pgc->command_tbl->nr_of_post, |
| 225 | 1068 &(vm->state).registers, &link_values)) { |
| 1069 return link_values; | |
| 1070 } | |
| 388 | 1071 |
| 225 | 1072 #ifdef TRACE |
| 1073 fprintf(MSG_OUT, "libdvdnav: ** Fell of the end of the pgc, continuing in NextPGC\n"); | |
| 1074 #endif | |
| 1075 /* Should end up in the STOP_DOMAIN if next_pgc is 0. */ | |
| 1076 if(!set_PGCN(vm, (vm->state).pgc->next_pgc_nr)) { | |
| 1077 link_values.command = Exit; | |
| 1078 return link_values; | |
| 1079 } | |
| 1080 return play_PGC(vm); | |
| 1081 } | |
| 1082 | |
| 1083 static link_t play_PG(vm_t *vm) { | |
| 1084 #ifdef TRACE | |
| 1085 fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i)\n", (vm->state).pgN); | |
| 1086 #endif | |
| 388 | 1087 |
| 225 | 1088 assert((vm->state).pgN > 0); |
| 1089 if((vm->state).pgN > (vm->state).pgc->nr_of_programs) { | |
| 1090 #ifdef TRACE | |
| 388 | 1091 fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i) > pgc->nr_of_programs (%i)\n", |
| 225 | 1092 (vm->state).pgN, (vm->state).pgc->nr_of_programs ); |
| 1093 #endif | |
| 388 | 1094 assert((vm->state).pgN == (vm->state).pgc->nr_of_programs + 1); |
| 225 | 1095 return play_PGC_post(vm); |
| 1096 } | |
| 388 | 1097 |
| 225 | 1098 (vm->state).cellN = (vm->state).pgc->program_map[(vm->state).pgN - 1]; |
| 388 | 1099 |
| 225 | 1100 return play_Cell(vm); |
| 1101 } | |
| 1102 | |
| 1103 static link_t play_Cell(vm_t *vm) { | |
| 1104 static const link_t play_this = {PlayThis, /* Block in Cell */ 0, 0, 0}; | |
| 1105 | |
| 1106 #ifdef TRACE | |
| 1107 fprintf(MSG_OUT, "libdvdnav: play_Cell: (vm->state).cellN (%i)\n", (vm->state).cellN); | |
| 1108 #endif | |
| 388 | 1109 |
| 225 | 1110 assert((vm->state).cellN > 0); |
| 1111 if((vm->state).cellN > (vm->state).pgc->nr_of_cells) { | |
| 1112 #ifdef TRACE | |
| 388 | 1113 fprintf(MSG_OUT, "libdvdnav: (vm->state).cellN (%i) > pgc->nr_of_cells (%i)\n", |
| 225 | 1114 (vm->state).cellN, (vm->state).pgc->nr_of_cells ); |
| 1115 #endif | |
| 388 | 1116 assert((vm->state).cellN == (vm->state).pgc->nr_of_cells + 1); |
| 225 | 1117 return play_PGC_post(vm); |
| 1118 } | |
| 388 | 1119 |
| 225 | 1120 /* Multi angle/Interleaved */ |
| 1121 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode) { | |
| 1122 case 0: /* Normal */ | |
| 1123 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 0); | |
| 1124 break; | |
| 1125 case 1: /* The first cell in the block */ | |
| 1126 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type) { | |
| 1127 case 0: /* Not part of a block */ | |
| 1128 assert(0); | |
|
243
e75c52894630
* assert(0) does not always and the program (see NDEBUG)
mroi
parents:
229
diff
changeset
|
1129 break; |
| 225 | 1130 case 1: /* Angle block */ |
| 1131 /* Loop and check each cell instead? So we don't get outside the block? */ | |
| 1132 (vm->state).cellN += (vm->state).AGL_REG - 1; | |
|
433
1c7c804e9c82
Prevent general CPP macro from causing strange behavior.
rathann
parents:
429
diff
changeset
|
1133 #ifdef DVDNAV_STRICT |
| 225 | 1134 assert((vm->state).cellN <= (vm->state).pgc->nr_of_cells); |
| 1135 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode != 0); | |
| 1136 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 1); | |
| 1137 #else | |
| 1138 if (!((vm->state).cellN <= (vm->state).pgc->nr_of_cells) || | |
| 1139 !((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode != 0) || | |
| 1140 !((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 1)) { | |
| 1141 fprintf(MSG_OUT, "libdvdnav: Invalid angle block\n"); | |
| 1142 (vm->state).cellN -= (vm->state).AGL_REG - 1; | |
| 1143 } | |
| 1144 #endif | |
| 1145 break; | |
| 1146 case 2: /* ?? */ | |
| 1147 case 3: /* ?? */ | |
| 1148 default: | |
| 1149 fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n", | |
| 1150 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode, | |
| 1151 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type); | |
| 1152 assert(0); | |
| 1153 } | |
| 1154 break; | |
| 1155 case 2: /* Cell in the block */ | |
| 1156 case 3: /* Last cell in the block */ | |
| 1157 /* These might perhaps happen for RSM or LinkC commands? */ | |
| 1158 default: | |
| 1159 fprintf(MSG_OUT, "libdvdnav: Cell is in block but did not enter at first cell!\n"); | |
| 1160 } | |
| 388 | 1161 |
| 225 | 1162 /* Updates (vm->state).pgN and PTTN_REG */ |
| 1163 if(!set_PGN(vm)) { | |
| 1164 /* Should not happen */ | |
| 1165 assert(0); | |
| 1166 return play_PGC_post(vm); | |
| 1167 } | |
| 1168 (vm->state).cell_restart++; | |
| 1169 (vm->state).blockN = 0; | |
| 1170 #ifdef TRACE | |
| 1171 fprintf(MSG_OUT, "libdvdnav: Cell should restart here\n"); | |
| 1172 #endif | |
| 1173 return play_this; | |
| 1174 } | |
| 1175 | |
| 1176 static link_t play_Cell_post(vm_t *vm) { | |
| 1177 cell_playback_t *cell; | |
| 388 | 1178 |
| 225 | 1179 #ifdef TRACE |
| 1180 fprintf(MSG_OUT, "libdvdnav: play_Cell_post: (vm->state).cellN (%i)\n", (vm->state).cellN); | |
| 1181 #endif | |
| 388 | 1182 |
| 225 | 1183 cell = &(vm->state).pgc->cell_playback[(vm->state).cellN - 1]; |
| 388 | 1184 |
| 225 | 1185 /* Still time is already taken care of before we get called. */ |
| 388 | 1186 |
| 225 | 1187 /* Deal with a Cell command, if any */ |
| 1188 if(cell->cell_cmd_nr != 0) { | |
| 1189 link_t link_values; | |
| 388 | 1190 |
| 225 | 1191 /* These asserts are now not needed. |
| 1192 * Some DVDs have no cell commands listed in the PGC, | |
| 1193 * but the Cell itself points to a cell command that does not exist. | |
| 1194 * For this situation, just ignore the cell command and continue. | |
| 1195 * | |
| 1196 * assert((vm->state).pgc->command_tbl != NULL); | |
| 1197 * assert((vm->state).pgc->command_tbl->nr_of_cell >= cell->cell_cmd_nr); | |
| 1198 */ | |
| 1199 | |
| 1200 if ((vm->state).pgc->command_tbl != NULL && | |
| 1201 (vm->state).pgc->command_tbl->nr_of_cell >= cell->cell_cmd_nr) { | |
| 1202 #ifdef TRACE | |
| 1203 fprintf(MSG_OUT, "libdvdnav: Cell command present, executing\n"); | |
| 1204 #endif | |
| 1205 if(vmEval_CMD(&(vm->state).pgc->command_tbl->cell_cmds[cell->cell_cmd_nr - 1], 1, | |
| 1206 &(vm->state).registers, &link_values)) { | |
| 1207 return link_values; | |
| 1208 } else { | |
| 1209 #ifdef TRACE | |
| 1210 fprintf(MSG_OUT, "libdvdnav: Cell command didn't do a Jump, Link or Call\n"); | |
| 1211 #endif | |
| 1212 } | |
| 1213 } else { | |
| 1214 #ifdef TRACE | |
| 1215 fprintf(MSG_OUT, "libdvdnav: Invalid Cell command\n"); | |
| 1216 #endif | |
| 1217 } | |
| 1218 } | |
| 388 | 1219 |
| 225 | 1220 /* Where to continue after playing the cell... */ |
| 1221 /* Multi angle/Interleaved */ | |
| 1222 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode) { | |
| 1223 case 0: /* Normal */ | |
| 1224 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 0); | |
| 1225 (vm->state).cellN++; | |
| 1226 break; | |
| 1227 case 1: /* The first cell in the block */ | |
| 1228 case 2: /* A cell in the block */ | |
| 1229 case 3: /* The last cell in the block */ | |
| 1230 default: | |
| 1231 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type) { | |
| 1232 case 0: /* Not part of a block */ | |
| 1233 assert(0); | |
|
243
e75c52894630
* assert(0) does not always and the program (see NDEBUG)
mroi
parents:
229
diff
changeset
|
1234 break; |
| 225 | 1235 case 1: /* Angle block */ |
| 1236 /* Skip the 'other' angles */ | |
| 1237 (vm->state).cellN++; | |
| 1238 while((vm->state).cellN <= (vm->state).pgc->nr_of_cells && | |
| 1239 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode >= 2) { | |
| 1240 (vm->state).cellN++; | |
| 1241 } | |
| 1242 break; | |
| 1243 case 2: /* ?? */ | |
| 1244 case 3: /* ?? */ | |
| 1245 default: | |
| 1246 fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n", | |
| 1247 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode, | |
| 1248 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type); | |
| 1249 assert(0); | |
| 1250 } | |
| 1251 break; | |
| 1252 } | |
| 388 | 1253 |
| 1254 /* Figure out the correct pgN for the new cell */ | |
| 225 | 1255 if(!set_PGN(vm)) { |
| 1256 #ifdef TRACE | |
| 1257 fprintf(MSG_OUT, "libdvdnav: last cell in this PGC\n"); | |
| 1258 #endif | |
| 1259 return play_PGC_post(vm); | |
| 1260 } | |
| 1261 return play_Cell(vm); | |
| 1262 } | |
| 1263 | |
| 1264 | |
| 1265 /* link processing */ | |
| 1266 | |
| 1267 static int process_command(vm_t *vm, link_t link_values) { | |
| 388 | 1268 |
| 225 | 1269 while(link_values.command != PlayThis) { |
| 388 | 1270 |
| 225 | 1271 #ifdef TRACE |
| 1272 fprintf(MSG_OUT, "libdvdnav: Before printout starts:\n"); | |
| 1273 vm_print_link(link_values); | |
| 388 | 1274 fprintf(MSG_OUT, "libdvdnav: Link values %i %i %i %i\n", link_values.command, |
| 225 | 1275 link_values.data1, link_values.data2, link_values.data3); |
| 1276 vm_print_current_domain_state(vm); | |
| 1277 fprintf(MSG_OUT, "libdvdnav: Before printout ends.\n"); | |
| 1278 #endif | |
| 388 | 1279 |
| 225 | 1280 switch(link_values.command) { |
| 1281 case LinkNoLink: | |
| 1282 /* BUTTON number:data1 */ | |
| 1283 if(link_values.data1 != 0) | |
| 1284 (vm->state).HL_BTNN_REG = link_values.data1 << 10; | |
| 1285 return 0; /* no actual jump */ | |
| 1286 | |
| 1287 case LinkTopC: | |
| 1288 /* Restart playing from the beginning of the current Cell. */ | |
| 1289 /* BUTTON number:data1 */ | |
| 1290 if(link_values.data1 != 0) | |
| 1291 (vm->state).HL_BTNN_REG = link_values.data1 << 10; | |
| 1292 link_values = play_Cell(vm); | |
| 1293 break; | |
| 1294 case LinkNextC: | |
| 1295 /* Link to Next Cell */ | |
| 1296 /* BUTTON number:data1 */ | |
| 1297 if(link_values.data1 != 0) | |
| 1298 (vm->state).HL_BTNN_REG = link_values.data1 << 10; | |
| 1299 (vm->state).cellN += 1; | |
| 1300 link_values = play_Cell(vm); | |
| 1301 break; | |
| 1302 case LinkPrevC: | |
| 1303 /* Link to Previous Cell */ | |
| 1304 /* BUTTON number:data1 */ | |
| 1305 if(link_values.data1 != 0) | |
| 1306 (vm->state).HL_BTNN_REG = link_values.data1 << 10; | |
| 1307 assert((vm->state).cellN > 1); | |
| 1308 (vm->state).cellN -= 1; | |
| 1309 link_values = play_Cell(vm); | |
| 1310 break; | |
| 388 | 1311 |
| 225 | 1312 case LinkTopPG: |
| 1313 /* Link to Top of current Program */ | |
| 1314 /* BUTTON number:data1 */ | |
| 1315 if(link_values.data1 != 0) | |
| 1316 (vm->state).HL_BTNN_REG = link_values.data1 << 10; | |
| 1317 link_values = play_PG(vm); | |
| 1318 break; | |
| 1319 case LinkNextPG: | |
| 1320 /* Link to Next Program */ | |
| 1321 /* BUTTON number:data1 */ | |
| 1322 if(link_values.data1 != 0) | |
| 1323 (vm->state).HL_BTNN_REG = link_values.data1 << 10; | |
| 1324 (vm->state).pgN += 1; | |
| 1325 link_values = play_PG(vm); | |
| 1326 break; | |
| 1327 case LinkPrevPG: | |
| 1328 /* Link to Previous Program */ | |
| 1329 /* BUTTON number:data1 */ | |
| 1330 if(link_values.data1 != 0) | |
| 1331 (vm->state).HL_BTNN_REG = link_values.data1 << 10; | |
| 1332 assert((vm->state).pgN > 1); | |
| 1333 (vm->state).pgN -= 1; | |
| 1334 link_values = play_PG(vm); | |
| 1335 break; | |
| 1336 | |
| 1337 case LinkTopPGC: | |
| 1338 /* Restart playing from beginning of current Program Chain */ | |
| 1339 /* BUTTON number:data1 */ | |
| 1340 if(link_values.data1 != 0) | |
| 1341 (vm->state).HL_BTNN_REG = link_values.data1 << 10; | |
| 1342 link_values = play_PGC(vm); | |
| 1343 break; | |
| 1344 case LinkNextPGC: | |
| 1345 /* Link to Next Program Chain */ | |
| 1346 /* BUTTON number:data1 */ | |
| 1347 if(link_values.data1 != 0) | |
| 1348 (vm->state).HL_BTNN_REG = link_values.data1 << 10; | |
| 1349 assert((vm->state).pgc->next_pgc_nr != 0); | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1350 if(set_PGCN(vm, (vm->state).pgc->next_pgc_nr)) |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1351 link_values = play_PGC(vm); |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1352 else |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1353 link_values.command = Exit; |
| 225 | 1354 break; |
| 1355 case LinkPrevPGC: | |
| 1356 /* Link to Previous Program Chain */ | |
| 1357 /* BUTTON number:data1 */ | |
| 1358 if(link_values.data1 != 0) | |
| 1359 (vm->state).HL_BTNN_REG = link_values.data1 << 10; | |
| 1360 assert((vm->state).pgc->prev_pgc_nr != 0); | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1361 if(set_PGCN(vm, (vm->state).pgc->prev_pgc_nr)) |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1362 link_values = play_PGC(vm); |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1363 else |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1364 link_values.command = Exit; |
| 225 | 1365 break; |
| 1366 case LinkGoUpPGC: | |
| 1367 /* Link to GoUp Program Chain */ | |
| 1368 /* BUTTON number:data1 */ | |
| 1369 if(link_values.data1 != 0) | |
| 1370 (vm->state).HL_BTNN_REG = link_values.data1 << 10; | |
| 1371 assert((vm->state).pgc->goup_pgc_nr != 0); | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1372 if(set_PGCN(vm, (vm->state).pgc->goup_pgc_nr)) |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1373 link_values = play_PGC(vm); |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1374 else |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1375 link_values.command = Exit; |
| 225 | 1376 break; |
| 1377 case LinkTailPGC: | |
| 1378 /* Link to Tail of Program Chain */ | |
| 1379 /* BUTTON number:data1 */ | |
| 1380 if(link_values.data1 != 0) | |
| 1381 (vm->state).HL_BTNN_REG = link_values.data1 << 10; | |
| 1382 link_values = play_PGC_post(vm); | |
| 1383 break; | |
| 1384 | |
| 1385 case LinkRSM: | |
| 1386 { | |
| 1387 /* Link to Resume point */ | |
| 1388 int i; | |
| 388 | 1389 |
| 225 | 1390 /* Check and see if there is any rsm info!! */ |
| 1391 if (!(vm->state).rsm_vtsN) { | |
| 1392 fprintf(MSG_OUT, "libdvdnav: trying to resume without any resume info set\n"); | |
| 1393 link_values.command = Exit; | |
| 1394 break; | |
| 1395 } | |
| 388 | 1396 |
| 225 | 1397 (vm->state).domain = VTS_DOMAIN; |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1398 if (!ifoOpenNewVTSI(vm, vm->dvd, (vm->state).rsm_vtsN)) |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1399 assert(0); |
| 225 | 1400 set_PGCN(vm, (vm->state).rsm_pgcN); |
| 388 | 1401 |
| 1402 /* These should never be set in SystemSpace and/or MenuSpace */ | |
| 225 | 1403 /* (vm->state).TTN_REG = rsm_tt; ?? */ |
| 1404 /* (vm->state).TT_PGCN_REG = (vm->state).rsm_pgcN; ?? */ | |
| 1405 for(i = 0; i < 5; i++) { | |
| 1406 (vm->state).registers.SPRM[4 + i] = (vm->state).rsm_regs[i]; | |
| 1407 } | |
| 388 | 1408 |
| 225 | 1409 if(link_values.data1 != 0) |
| 1410 (vm->state).HL_BTNN_REG = link_values.data1 << 10; | |
| 388 | 1411 |
| 225 | 1412 if((vm->state).rsm_cellN == 0) { |
| 1413 assert((vm->state).cellN); /* Checking if this ever happens */ | |
| 1414 (vm->state).pgN = 1; | |
| 1415 link_values = play_PG(vm); | |
| 388 | 1416 } else { |
|
252
aee8af592d66
fix a long-standing problem: sometimes, hitting Escape in the movie and then
mroi
parents:
247
diff
changeset
|
1417 /* (vm->state).pgN = ?? this gets the right value in set_PGN() below */ |
| 225 | 1418 (vm->state).cellN = (vm->state).rsm_cellN; |
| 1419 link_values.command = PlayThis; | |
|
252
aee8af592d66
fix a long-standing problem: sometimes, hitting Escape in the movie and then
mroi
parents:
247
diff
changeset
|
1420 link_values.data1 = (vm->state).rsm_blockN & 0xffff; |
|
aee8af592d66
fix a long-standing problem: sometimes, hitting Escape in the movie and then
mroi
parents:
247
diff
changeset
|
1421 link_values.data2 = (vm->state).rsm_blockN >> 16; |
| 225 | 1422 if(!set_PGN(vm)) { |
| 1423 /* Were at the end of the PGC, should not happen for a RSM */ | |
| 1424 assert(0); | |
| 1425 link_values.command = LinkTailPGC; | |
| 1426 link_values.data1 = 0; /* No button */ | |
| 1427 } | |
| 1428 } | |
| 1429 } | |
| 1430 break; | |
| 1431 case LinkPGCN: | |
| 1432 /* Link to Program Chain Number:data1 */ | |
| 1433 if(!set_PGCN(vm, link_values.data1)) | |
| 1434 assert(0); | |
| 1435 link_values = play_PGC(vm); | |
| 1436 break; | |
| 1437 case LinkPTTN: | |
| 1438 /* Link to Part of current Title Number:data1 */ | |
| 1439 /* BUTTON number:data2 */ | |
| 1440 /* PGC Pre-Commands are not executed */ | |
| 1441 assert((vm->state).domain == VTS_DOMAIN); | |
| 1442 if(link_values.data2 != 0) | |
| 1443 (vm->state).HL_BTNN_REG = link_values.data2 << 10; | |
| 1444 if(!set_VTS_PTT(vm, (vm->state).vtsN, (vm->state).VTS_TTN_REG, link_values.data1)) | |
| 412 | 1445 link_values.command = Exit; |
| 1446 else | |
| 1447 link_values = play_PG(vm); | |
| 225 | 1448 break; |
| 1449 case LinkPGN: | |
| 1450 /* Link to Program Number:data1 */ | |
| 1451 /* BUTTON number:data2 */ | |
| 1452 if(link_values.data2 != 0) | |
| 1453 (vm->state).HL_BTNN_REG = link_values.data2 << 10; | |
| 1454 /* Update any other state, PTTN perhaps? */ | |
| 1455 (vm->state).pgN = link_values.data1; | |
| 1456 link_values = play_PG(vm); | |
| 1457 break; | |
| 1458 case LinkCN: | |
| 1459 /* Link to Cell Number:data1 */ | |
| 1460 /* BUTTON number:data2 */ | |
| 1461 if(link_values.data2 != 0) | |
| 1462 (vm->state).HL_BTNN_REG = link_values.data2 << 10; | |
| 1463 /* Update any other state, pgN, PTTN perhaps? */ | |
| 1464 (vm->state).cellN = link_values.data1; | |
| 1465 link_values = play_Cell(vm); | |
| 1466 break; | |
| 388 | 1467 |
| 225 | 1468 case Exit: |
| 1469 vm->stopped = 1; | |
| 1470 return 0; | |
| 388 | 1471 |
| 225 | 1472 case JumpTT: |
| 1473 /* Jump to VTS Title Domain */ | |
| 1474 /* Only allowed from the First Play domain(PGC) */ | |
| 1475 /* or the Video Manager domain (VMG) */ | |
| 1476 /* Stop SPRM9 Timer */ | |
| 1477 /* Set SPRM1 and SPRM2 */ | |
| 1478 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */ | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1479 if(set_TT(vm, link_values.data1)) |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1480 link_values = play_PGC(vm); |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1481 else |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1482 link_values.command = Exit; |
| 225 | 1483 break; |
| 1484 case JumpVTS_TT: | |
| 1485 /* Jump to Title:data1 in same VTS Title Domain */ | |
| 1486 /* Only allowed from the VTS Menu Domain(VTSM) */ | |
| 1487 /* or the Video Title Set Domain(VTS) */ | |
| 1488 /* Stop SPRM9 Timer */ | |
| 1489 /* Set SPRM1 and SPRM2 */ | |
| 1490 assert((vm->state).domain == VTSM_DOMAIN || (vm->state).domain == VTS_DOMAIN); /* ?? */ | |
| 1491 if(!set_VTS_TT(vm, (vm->state).vtsN, link_values.data1)) | |
| 412 | 1492 link_values.command = Exit; |
| 1493 else | |
| 1494 link_values = play_PGC(vm); | |
| 225 | 1495 break; |
| 1496 case JumpVTS_PTT: | |
| 1497 /* Jump to Part:data2 of Title:data1 in same VTS Title Domain */ | |
| 1498 /* Only allowed from the VTS Menu Domain(VTSM) */ | |
| 1499 /* or the Video Title Set Domain(VTS) */ | |
| 1500 /* Stop SPRM9 Timer */ | |
| 1501 /* Set SPRM1 and SPRM2 */ | |
| 1502 assert((vm->state).domain == VTSM_DOMAIN || (vm->state).domain == VTS_DOMAIN); /* ?? */ | |
| 1503 if(!set_VTS_PTT(vm, (vm->state).vtsN, link_values.data1, link_values.data2)) | |
| 412 | 1504 link_values.command = Exit; |
| 1505 else | |
| 1506 link_values = play_PGC_PG(vm, (vm->state).pgN); | |
| 225 | 1507 break; |
| 388 | 1508 |
| 225 | 1509 case JumpSS_FP: |
| 1510 /* Jump to First Play Domain */ | |
| 1511 /* Only allowed from the VTS Menu Domain(VTSM) */ | |
| 1512 /* or the Video Manager domain (VMG) */ | |
| 1513 /* Stop SPRM9 Timer and any GPRM counters */ | |
| 1514 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == VTSM_DOMAIN); /* ?? */ | |
| 1515 if (!set_FP_PGC(vm)) | |
| 1516 assert(0); | |
| 1517 link_values = play_PGC(vm); | |
| 1518 break; | |
| 1519 case JumpSS_VMGM_MENU: | |
| 410 | 1520 /* Jump to Video Manager domain - Title Menu:data1 or any PGC in VMG */ |
| 225 | 1521 /* Allowed from anywhere except the VTS Title domain */ |
| 1522 /* Stop SPRM9 Timer and any GPRM counters */ | |
| 1523 assert((vm->state).domain != VTS_DOMAIN); /* ?? */ | |
| 412 | 1524 if(vm->vmgi == NULL || vm->vmgi->pgci_ut == NULL) { |
| 1525 link_values.command = Exit; | |
| 1526 break; | |
| 1527 } | |
| 225 | 1528 (vm->state).domain = VMGM_DOMAIN; |
| 1529 if(!set_MENU(vm, link_values.data1)) | |
| 1530 assert(0); | |
| 1531 link_values = play_PGC(vm); | |
| 1532 break; | |
| 1533 case JumpSS_VTSM: | |
| 1534 /* Jump to a menu in Video Title domain, */ | |
| 1535 /* or to a Menu is the current VTS */ | |
| 1536 /* Stop SPRM9 Timer and any GPRM counters */ | |
| 1537 /* ifoOpenNewVTSI:data1 */ | |
| 1538 /* VTS_TTN_REG:data2 */ | |
| 388 | 1539 /* get_MENU:data3 */ |
| 225 | 1540 if(link_values.data1 != 0) { |
| 1541 if (link_values.data1 != (vm->state).vtsN) { | |
| 1542 /* the normal case */ | |
| 1543 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */ | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1544 if (!ifoOpenNewVTSI(vm, vm->dvd, link_values.data1)) /* Also sets (vm->state).vtsN */ |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1545 assert(0); |
| 412 | 1546 if(vm->vtsi == NULL || vm->vtsi->pgci_ut == NULL) { |
| 1547 link_values.command = Exit; | |
| 1548 break; | |
| 1549 } | |
| 1550 (vm->state).domain = VTSM_DOMAIN; | |
| 225 | 1551 } else { |
| 1552 /* This happens on some discs like "Captain Scarlet & the Mysterons" or | |
| 1553 * the German RC2 of "Anatomie" in VTSM. */ | |
| 1554 assert((vm->state).domain == VTSM_DOMAIN || | |
| 1555 (vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */ | |
| 412 | 1556 if(vm->vtsi == NULL || vm->vtsi->pgci_ut == NULL) { |
| 1557 link_values.command = Exit; | |
| 1558 break; | |
| 1559 } | |
| 225 | 1560 (vm->state).domain = VTSM_DOMAIN; |
| 1561 } | |
| 1562 } else { | |
| 1563 /* This happens on 'The Fifth Element' region 2. */ | |
| 1564 assert((vm->state).domain == VTSM_DOMAIN); | |
| 1565 } | |
| 1566 /* I don't know what title is supposed to be used for. */ | |
| 1567 /* Alien or Aliens has this != 1, I think. */ | |
| 1568 /* assert(link_values.data2 == 1); */ | |
| 1569 (vm->state).VTS_TTN_REG = link_values.data2; | |
| 1570 /* TTN_REG (SPRM4), VTS_TTN_REG (SPRM5), TT_PGCN_REG (SPRM6) are linked, */ | |
| 1571 /* so if one changes, the others must change to match it. */ | |
| 1572 (vm->state).TTN_REG = get_TT(vm, (vm->state).vtsN, (vm->state).VTS_TTN_REG); | |
| 1573 if(!set_MENU(vm, link_values.data3)) | |
| 1574 assert(0); | |
| 1575 link_values = play_PGC(vm); | |
| 1576 break; | |
| 1577 case JumpSS_VMGM_PGC: | |
| 1578 /* set_PGCN:data1 */ | |
| 1579 /* Stop SPRM9 Timer and any GPRM counters */ | |
| 1580 assert((vm->state).domain != VTS_DOMAIN); /* ?? */ | |
| 412 | 1581 if(vm->vmgi == NULL || vm->vmgi->pgci_ut == NULL) { |
| 1582 link_values.command = Exit; | |
| 1583 break; | |
| 1584 } | |
| 225 | 1585 (vm->state).domain = VMGM_DOMAIN; |
| 1586 if(!set_PGCN(vm, link_values.data1)) | |
| 1587 assert(0); | |
| 1588 link_values = play_PGC(vm); | |
| 1589 break; | |
| 388 | 1590 |
| 225 | 1591 case CallSS_FP: |
| 1592 /* set_RSMinfo:data1 */ | |
| 1593 assert((vm->state).domain == VTS_DOMAIN); /* ?? */ | |
| 1594 /* Must be called before domain is changed */ | |
| 1595 set_RSMinfo(vm, link_values.data1, /* We dont have block info */ 0); | |
| 1596 set_FP_PGC(vm); | |
| 1597 link_values = play_PGC(vm); | |
| 1598 break; | |
| 1599 case CallSS_VMGM_MENU: | |
| 388 | 1600 /* set_MENU:data1 */ |
| 225 | 1601 /* set_RSMinfo:data2 */ |
| 1602 assert((vm->state).domain == VTS_DOMAIN); /* ?? */ | |
| 1603 /* Must be called before domain is changed */ | |
| 412 | 1604 if(vm->vmgi == NULL || vm->vmgi->pgci_ut == NULL) { |
| 1605 link_values.command = Exit; | |
| 1606 break; | |
| 1607 } | |
| 388 | 1608 set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0); |
| 225 | 1609 (vm->state).domain = VMGM_DOMAIN; |
| 1610 if(!set_MENU(vm, link_values.data1)) | |
| 1611 assert(0); | |
| 1612 link_values = play_PGC(vm); | |
| 1613 break; | |
| 1614 case CallSS_VTSM: | |
| 388 | 1615 /* set_MENU:data1 */ |
| 225 | 1616 /* set_RSMinfo:data2 */ |
| 1617 assert((vm->state).domain == VTS_DOMAIN); /* ?? */ | |
| 1618 /* Must be called before domain is changed */ | |
| 412 | 1619 if(vm->vtsi == NULL || vm->vtsi->pgci_ut == NULL) { |
| 1620 link_values.command = Exit; | |
| 1621 break; | |
| 1622 } | |
| 225 | 1623 set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0); |
| 1624 (vm->state).domain = VTSM_DOMAIN; | |
| 1625 if(!set_MENU(vm, link_values.data1)) | |
| 1626 assert(0); | |
| 1627 link_values = play_PGC(vm); | |
| 1628 break; | |
| 1629 case CallSS_VMGM_PGC: | |
| 1630 /* set_PGC:data1 */ | |
| 1631 /* set_RSMinfo:data2 */ | |
| 1632 assert((vm->state).domain == VTS_DOMAIN); /* ?? */ | |
| 1633 /* Must be called before domain is changed */ | |
| 412 | 1634 if(vm->vmgi == NULL || vm->vmgi->pgci_ut == NULL) { |
| 1635 link_values.command = Exit; | |
| 1636 break; | |
| 1637 } | |
| 225 | 1638 set_RSMinfo(vm, link_values.data2, /* We dont have block info */ 0); |
| 1639 (vm->state).domain = VMGM_DOMAIN; | |
| 1640 if(!set_PGCN(vm, link_values.data1)) | |
| 1641 assert(0); | |
| 1642 link_values = play_PGC(vm); | |
| 1643 break; | |
| 1644 case PlayThis: | |
| 1645 /* Should never happen. */ | |
| 1646 assert(0); | |
| 1647 break; | |
| 1648 } | |
| 1649 | |
| 1650 #ifdef TRACE | |
| 1651 fprintf(MSG_OUT, "libdvdnav: After printout starts:\n"); | |
| 1652 vm_print_current_domain_state(vm); | |
| 1653 fprintf(MSG_OUT, "libdvdnav: After printout ends.\n"); | |
| 1654 #endif | |
| 388 | 1655 |
| 225 | 1656 } |
|
252
aee8af592d66
fix a long-standing problem: sometimes, hitting Escape in the movie and then
mroi
parents:
247
diff
changeset
|
1657 (vm->state).blockN = link_values.data1 | (link_values.data2 << 16); |
| 225 | 1658 return 1; |
| 1659 } | |
| 1660 | |
| 1661 | |
| 1662 /* Set functions */ | |
| 1663 | |
| 388 | 1664 static int set_TT(vm_t *vm, int tt) { |
| 225 | 1665 return set_PTT(vm, tt, 1); |
| 1666 } | |
| 1667 | |
| 1668 static int set_PTT(vm_t *vm, int tt, int ptt) { | |
| 1669 assert(tt <= vm->vmgi->tt_srpt->nr_of_srpts); | |
| 1670 return set_VTS_PTT(vm, vm->vmgi->tt_srpt->title[tt - 1].title_set_nr, | |
| 1671 vm->vmgi->tt_srpt->title[tt - 1].vts_ttn, ptt); | |
| 1672 } | |
| 1673 | |
| 1674 static int set_VTS_TT(vm_t *vm, int vtsN, int vts_ttn) { | |
| 1675 return set_VTS_PTT(vm, vtsN, vts_ttn, 1); | |
| 1676 } | |
| 1677 | |
| 1678 static int set_VTS_PTT(vm_t *vm, int vtsN, int vts_ttn, int part) { | |
| 1679 int pgcN, pgN, res; | |
| 388 | 1680 |
| 225 | 1681 (vm->state).domain = VTS_DOMAIN; |
| 1682 | |
|
256
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1683 if (vtsN != (vm->state).vtsN) |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1684 if (!ifoOpenNewVTSI(vm, vm->dvd, vtsN)) /* Also sets (vm->state).vtsN */ |
|
6299ccea8a38
killing a lot of asserts and turning them into forced executions of Exit,
mroi
parents:
254
diff
changeset
|
1685 return 0; |
| 388 | 1686 |
| 225 | 1687 if ((vts_ttn < 1) || (vts_ttn > vm->vtsi->vts_ptt_srpt->nr_of_srpts) || |
| 1688 (part < 1) || (part > vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].nr_of_ptts) ) { | |
| 1689 return 0; | |
| 1690 } | |
| 388 | 1691 |
| 225 | 1692 pgcN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgcn; |
| 1693 pgN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgn; | |
| 388 | 1694 |
| 225 | 1695 (vm->state).TT_PGCN_REG = pgcN; |
| 1696 (vm->state).PTTN_REG = part; | |
| 1697 (vm->state).TTN_REG = get_TT(vm, vtsN, vts_ttn); | |
| 412 | 1698 if( (vm->state.TTN_REG) == 0 ) |
| 1699 return 0; | |
| 1700 | |
| 225 | 1701 (vm->state).VTS_TTN_REG = vts_ttn; |
| 1702 (vm->state).vtsN = vtsN; /* Not sure about this one. We can get to it easily from TTN_REG */ | |
| 1703 /* Any other registers? */ | |
| 388 | 1704 |
| 225 | 1705 res = set_PGCN(vm, pgcN); /* This clobber's state.pgN (sets it to 1), but we don't want clobbering here. */ |
| 1706 (vm->state).pgN = pgN; | |
| 1707 return res; | |
| 1708 } | |
| 1709 | |
|
409
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1710 static int set_PROG(vm_t *vm, int tt, int pgcn, int pgn) { |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1711 assert(tt <= vm->vmgi->tt_srpt->nr_of_srpts); |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1712 return set_VTS_PROG(vm, vm->vmgi->tt_srpt->title[tt - 1].title_set_nr, |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1713 vm->vmgi->tt_srpt->title[tt - 1].vts_ttn, pgcn, pgn); |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1714 } |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1715 |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1716 static int set_VTS_PROG(vm_t *vm, int vtsN, int vts_ttn, int pgcn, int pgn) { |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1717 int pgcN, pgN, res, title, part = 0; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1718 |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1719 (vm->state).domain = VTS_DOMAIN; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1720 |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1721 if (vtsN != (vm->state).vtsN) |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1722 if (!ifoOpenNewVTSI(vm, vm->dvd, vtsN)) /* Also sets (vm->state).vtsN */ |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1723 return 0; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1724 |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1725 if ((vts_ttn < 1) || (vts_ttn > vm->vtsi->vts_ptt_srpt->nr_of_srpts)) { |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1726 return 0; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1727 } |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1728 |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1729 pgcN = pgcn; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1730 pgN = pgn; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1731 |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1732 (vm->state).TT_PGCN_REG = pgcN; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1733 (vm->state).TTN_REG = get_TT(vm, vtsN, vts_ttn); |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1734 assert( (vm->state.TTN_REG) != 0 ); |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1735 (vm->state).VTS_TTN_REG = vts_ttn; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1736 (vm->state).vtsN = vtsN; /* Not sure about this one. We can get to it easily from TTN_REG */ |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1737 /* Any other registers? */ |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1738 |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1739 res = set_PGCN(vm, pgcN); /* This clobber's state.pgN (sets it to 1), but we don't want clobbering here. */ |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1740 (vm->state).pgN = pgN; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1741 vm_get_current_title_part(vm, &title, &part); |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1742 (vm->state).PTTN_REG = part; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1743 return res; |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1744 } |
|
9b8bfc56a7fe
Add dvdnav_program_play & dvdnav_current_title_program
erik
parents:
408
diff
changeset
|
1745 |
| 388 | 1746 static int set_FP_PGC(vm_t *vm) { |
| 225 | 1747 (vm->state).domain = FP_DOMAIN; |
|
254
f78669338b49
Fix segfault if the DVD does not contain a FP_PGC.
jcdutton
parents:
252
diff
changeset
|
1748 if (!vm->vmgi->first_play_pgc) { |
|
f78669338b49
Fix segfault if the DVD does not contain a FP_PGC.
jcdutton
parents:
252
diff
changeset
|
1749 return set_PGCN(vm, 1); |
|
f78669338b49
Fix segfault if the DVD does not contain a FP_PGC.
jcdutton
parents:
252
diff
changeset
|
1750 } |
| 225 | 1751 (vm->state).pgc = vm->vmgi->first_play_pgc; |
| 1752 (vm->state).pgcN = vm->vmgi->vmgi_mat->first_play_pgc; | |
| 1753 return 1; | |
| 1754 } | |
| 1755 | |
| 1756 | |
| 1757 static int set_MENU(vm_t *vm, int menu) { | |
| 1758 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == VTSM_DOMAIN); | |
| 1759 return set_PGCN(vm, get_ID(vm, menu)); | |
| 1760 } | |
| 1761 | |
| 1762 static int set_PGCN(vm_t *vm, int pgcN) { | |
| 1763 pgcit_t *pgcit; | |
| 388 | 1764 |
| 225 | 1765 pgcit = get_PGCIT(vm); |
|
422
3d942df13d3a
Unbreak playback of DVDs with menus, broken by r1245.
rathann
parents:
418
diff
changeset
|
1766 if (pgcit == NULL) |
| 418 | 1767 return 0; |
| 225 | 1768 |
| 1769 if(pgcN < 1 || pgcN > pgcit->nr_of_pgci_srp) { | |
| 1770 #ifdef TRACE | |
| 1771 fprintf(MSG_OUT, "libdvdnav: ** No such pgcN = %d\n", pgcN); | |
| 1772 #endif | |
| 1773 return 0; | |
| 1774 } | |
| 388 | 1775 |
| 225 | 1776 (vm->state).pgc = pgcit->pgci_srp[pgcN - 1].pgc; |
| 1777 (vm->state).pgcN = pgcN; | |
| 1778 (vm->state).pgN = 1; | |
| 388 | 1779 |
| 225 | 1780 if((vm->state).domain == VTS_DOMAIN) |
| 1781 (vm->state).TT_PGCN_REG = pgcN; | |
| 1782 | |
| 1783 return 1; | |
| 1784 } | |
| 1785 | |
| 388 | 1786 /* Figure out the correct pgN from the cell and update (vm->state). */ |
| 225 | 1787 static int set_PGN(vm_t *vm) { |
| 1788 int new_pgN = 0; | |
| 408 | 1789 int dummy, part = 0; |
| 388 | 1790 |
| 1791 while(new_pgN < (vm->state).pgc->nr_of_programs | |
| 225 | 1792 && (vm->state).cellN >= (vm->state).pgc->program_map[new_pgN]) |
| 1793 new_pgN++; | |
| 388 | 1794 |
| 225 | 1795 if(new_pgN == (vm->state).pgc->nr_of_programs) /* We are at the last program */ |
| 1796 if((vm->state).cellN > (vm->state).pgc->nr_of_cells) | |
| 1797 return 0; /* We are past the last cell */ | |
| 388 | 1798 |
| 225 | 1799 (vm->state).pgN = new_pgN; |
| 388 | 1800 |
| 225 | 1801 if((vm->state).domain == VTS_DOMAIN) { |
| 1802 playback_type_t *pb_ty; | |
| 1803 if((vm->state).TTN_REG > vm->vmgi->tt_srpt->nr_of_srpts) | |
| 1804 return 0; /* ?? */ | |
| 1805 pb_ty = &vm->vmgi->tt_srpt->title[(vm->state).TTN_REG - 1].pb_ty; | |
| 1806 vm_get_current_title_part(vm, &dummy, &part); | |
| 1807 (vm->state).PTTN_REG = part; | |
| 1808 } | |
| 1809 return 1; | |
| 1810 } | |
| 1811 | |
| 1812 /* Must be called before domain is changed (set_PGCN()) */ | |
| 1813 static void set_RSMinfo(vm_t *vm, int cellN, int blockN) { | |
| 1814 int i; | |
| 388 | 1815 |
| 225 | 1816 if(cellN) { |
| 1817 (vm->state).rsm_cellN = cellN; | |
| 1818 (vm->state).rsm_blockN = blockN; | |
| 1819 } else { | |
| 1820 (vm->state).rsm_cellN = (vm->state).cellN; | |
| 1821 (vm->state).rsm_blockN = blockN; | |
| 1822 } | |
| 1823 (vm->state).rsm_vtsN = (vm->state).vtsN; | |
| 1824 (vm->state).rsm_pgcN = get_PGCN(vm); | |
| 388 | 1825 |
| 225 | 1826 /* assert((vm->state).rsm_pgcN == (vm->state).TT_PGCN_REG); for VTS_DOMAIN */ |
| 388 | 1827 |
| 225 | 1828 for(i = 0; i < 5; i++) { |
| 1829 (vm->state).rsm_regs[i] = (vm->state).registers.SPRM[4 + i]; | |
| 1830 } | |
| 1831 } | |
| 1832 | |
| 1833 | |
| 1834 /* Get functions */ | |
| 1835 | |
| 1836 /* Searches the TT tables, to find the current TT. | |
| 1837 * returns the current TT. | |
| 1838 * returns 0 if not found. | |
| 1839 */ | |
| 1840 static int get_TT(vm_t *vm, int vtsN, int vts_ttn) { | |
| 1841 int i; | |
| 1842 int tt=0; | |
| 1843 | |
| 1844 for(i = 1; i <= vm->vmgi->tt_srpt->nr_of_srpts; i++) { | |
| 388 | 1845 if( vm->vmgi->tt_srpt->title[i - 1].title_set_nr == vtsN && |
| 225 | 1846 vm->vmgi->tt_srpt->title[i - 1].vts_ttn == vts_ttn) { |
| 1847 tt=i; | |
| 1848 break; | |
| 1849 } | |
| 1850 } | |
| 1851 return tt; | |
| 1852 } | |
| 1853 | |
| 1854 /* Search for entry_id match of the PGC Category in the current VTS PGCIT table. | |
| 1855 * Return pgcN based on entry_id match. | |
| 1856 */ | |
| 1857 static int get_ID(vm_t *vm, int id) { | |
| 1858 int pgcN, i; | |
| 1859 pgcit_t *pgcit; | |
| 388 | 1860 |
| 225 | 1861 /* Relies on state to get the correct pgcit. */ |
| 1862 pgcit = get_PGCIT(vm); | |
| 1863 assert(pgcit != NULL); | |
| 1864 #ifdef TRACE | |
| 1865 fprintf(MSG_OUT, "libdvdnav: ** Searching for menu (0x%x) entry PGC\n", id); | |
| 1866 #endif | |
| 1867 | |
| 1868 /* Force high bit set. */ | |
| 1869 id |=0x80; | |
| 1870 | |
| 1871 /* Get menu/title */ | |
| 1872 for(i = 0; i < pgcit->nr_of_pgci_srp; i++) { | |
| 1873 if( (pgcit->pgci_srp[i].entry_id) == id) { | |
| 1874 pgcN = i + 1; | |
| 1875 #ifdef TRACE | |
| 1876 fprintf(MSG_OUT, "libdvdnav: Found menu.\n"); | |
| 1877 #endif | |
| 1878 return pgcN; | |
| 1879 } | |
| 1880 } | |
| 1881 #ifdef TRACE | |
| 1882 fprintf(MSG_OUT, "libdvdnav: ** No such id/menu (0x%02x) entry PGC\n", id & 0x7f); | |
| 1883 for(i = 0; i < pgcit->nr_of_pgci_srp; i++) { | |
| 1884 if ( (pgcit->pgci_srp[i].entry_id & 0x80) == 0x80) { | |
| 1885 fprintf(MSG_OUT, "libdvdnav: Available menus: 0x%x\n", | |
| 1886 pgcit->pgci_srp[i].entry_id & 0x7f); | |
| 1887 } | |
| 1888 } | |
| 1889 #endif | |
| 1890 return 0; /* error */ | |
| 1891 } | |
| 1892 | |
| 1893 /* FIXME: we have a pgcN member in the vm's state now, so this should be obsolete */ | |
| 1894 static int get_PGCN(vm_t *vm) { | |
| 1895 pgcit_t *pgcit; | |
| 1896 int pgcN = 1; | |
| 1897 | |
| 1898 pgcit = get_PGCIT(vm); | |
| 388 | 1899 |
| 225 | 1900 if (pgcit) { |
| 1901 while(pgcN <= pgcit->nr_of_pgci_srp) { | |
| 1902 if(pgcit->pgci_srp[pgcN - 1].pgc == (vm->state).pgc) { | |
| 1903 assert((vm->state).pgcN == pgcN); | |
| 1904 return pgcN; | |
| 1905 } | |
| 1906 pgcN++; | |
| 1907 } | |
| 1908 } | |
| 388 | 1909 fprintf(MSG_OUT, "libdvdnav: get_PGCN failed. Was trying to find pgcN in domain %d\n", |
| 225 | 1910 (vm->state).domain); |
| 1911 return 0; /* error */ | |
| 1912 } | |
| 1913 | |
| 1914 static pgcit_t* get_MENU_PGCIT(vm_t *vm, ifo_handle_t *h, uint16_t lang) { | |
| 1915 int i; | |
| 388 | 1916 |
| 225 | 1917 if(h == NULL || h->pgci_ut == NULL) { |
| 1918 fprintf(MSG_OUT, "libdvdnav: *** pgci_ut handle is NULL ***\n"); | |
| 1919 return NULL; /* error? */ | |
| 1920 } | |
| 388 | 1921 |
| 225 | 1922 i = 0; |
| 1923 while(i < h->pgci_ut->nr_of_lus | |
| 1924 && h->pgci_ut->lu[i].lang_code != lang) | |
| 1925 i++; | |
| 1926 if(i == h->pgci_ut->nr_of_lus) { | |
| 1927 fprintf(MSG_OUT, "libdvdnav: Language '%c%c' not found, using '%c%c' instead\n", | |
| 1928 (char)(lang >> 8), (char)(lang & 0xff), | |
| 1929 (char)(h->pgci_ut->lu[0].lang_code >> 8), | |
| 1930 (char)(h->pgci_ut->lu[0].lang_code & 0xff)); | |
| 1931 fprintf(MSG_OUT, "libdvdnav: Menu Languages available: "); | |
| 1932 for(i = 0; i < h->pgci_ut->nr_of_lus; i++) { | |
| 1933 fprintf(MSG_OUT, "%c%c ", | |
| 1934 (char)(h->pgci_ut->lu[i].lang_code >> 8), | |
| 1935 (char)(h->pgci_ut->lu[i].lang_code & 0xff)); | |
| 1936 } | |
| 1937 fprintf(MSG_OUT, "\n"); | |
| 1938 i = 0; /* error? */ | |
| 1939 } | |
| 388 | 1940 |
| 225 | 1941 return h->pgci_ut->lu[i].pgcit; |
| 1942 } | |
| 1943 | |
| 1944 /* Uses state to decide what to return */ | |
| 1945 static pgcit_t* get_PGCIT(vm_t *vm) { | |
|
344
fb2fbd4cfbf6
in get_PGCIT() check the validity of vm->vtsi before risking to dereference NULL;
nicodvb
parents:
332
diff
changeset
|
1946 pgcit_t *pgcit = NULL; |
| 388 | 1947 |
| 225 | 1948 switch ((vm->state).domain) { |
| 1949 case VTS_DOMAIN: | |
|
344
fb2fbd4cfbf6
in get_PGCIT() check the validity of vm->vtsi before risking to dereference NULL;
nicodvb
parents:
332
diff
changeset
|
1950 if(!vm->vtsi) return NULL; |
| 225 | 1951 pgcit = vm->vtsi->vts_pgcit; |
| 1952 break; | |
| 1953 case VTSM_DOMAIN: | |
|
344
fb2fbd4cfbf6
in get_PGCIT() check the validity of vm->vtsi before risking to dereference NULL;
nicodvb
parents:
332
diff
changeset
|
1954 if(!vm->vtsi) return NULL; |
| 225 | 1955 pgcit = get_MENU_PGCIT(vm, vm->vtsi, (vm->state).registers.SPRM[0]); |
| 1956 break; | |
| 1957 case VMGM_DOMAIN: | |
| 1958 case FP_DOMAIN: | |
| 1959 pgcit = get_MENU_PGCIT(vm, vm->vmgi, (vm->state).registers.SPRM[0]); | |
| 1960 break; | |
| 1961 default: | |
|
243
e75c52894630
* assert(0) does not always and the program (see NDEBUG)
mroi
parents:
229
diff
changeset
|
1962 abort(); |
| 225 | 1963 } |
| 388 | 1964 |
| 225 | 1965 return pgcit; |
| 1966 } | |
| 1967 | |
| 388 | 1968 //return the ifo_handle_t describing required title, used to |
|
312
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1969 //identify chapters |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1970 ifo_handle_t *vm_get_title_ifo(vm_t *vm, uint32_t title) |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1971 { |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1972 ifo_handle_t *ifo = NULL; |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1973 uint8_t titleset_nr; |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1974 if((title < 1) || (title > vm->vmgi->tt_srpt->nr_of_srpts)) |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1975 return NULL; |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1976 titleset_nr = vm->vmgi->tt_srpt->title[title-1].title_set_nr; |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1977 ifo = ifoOpen(vm->dvd, titleset_nr); |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1978 return ifo; |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1979 } |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1980 |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1981 void vm_ifo_close(ifo_handle_t *ifo) |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1982 { |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1983 ifoClose(ifo); |
|
fdbfb58d2735
added utility functions vm_get_title_ifo() and vm_ifo_close()
nicodvb
parents:
294
diff
changeset
|
1984 } |
| 225 | 1985 |
| 1986 /* Debug functions */ | |
| 1987 | |
| 1988 #ifdef TRACE | |
| 1989 void vm_position_print(vm_t *vm, vm_position_t *position) { | |
| 1990 fprintf(MSG_OUT, "libdvdnav: But=%x Spu=%x Aud=%x Ang=%x Hop=%x vts=%x dom=%x cell=%x cell_restart=%x cell_start=%x still=%x block=%x\n", | |
| 1991 position->button, | |
| 1992 position->spu_channel, | |
| 1993 position->audio_channel, | |
| 1994 position->angle_channel, | |
| 1995 position->hop_channel, | |
| 1996 position->vts, | |
| 1997 position->domain, | |
| 1998 position->cell, | |
| 1999 position->cell_restart, | |
| 2000 position->cell_start, | |
| 2001 position->still, | |
| 2002 position->block); | |
| 2003 } | |
| 2004 #endif | |
| 2005 |
