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