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