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