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