Mercurial > libdvdnav.hg
annotate vm.c @ 109:f41eae322bd1 src
warning: ugly fix ahead! (see comment in the code for details)
But I hate it when DVDs do not work with libdvdnav and after checking a bunch of
other DVDs it seems that this fix is unlikely to break anything else, so I
decided to commit it. "Back to the Future" menus are working fine now.
| author | mroi |
|---|---|
| date | Fri, 22 Nov 2002 17:14:26 +0000 |
| parents | e984044bbe7b |
| children | ac50954e1345 |
| 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 - |
|
f41eae322bd1
warning: ugly fix ahead! (see comment in the code for details)
mroi
parents:
106
diff
changeset
|
381 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].first_sector < 200)) { |
|
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; | |
| 90 | 540 int title=0, part=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); | |
| 90 | 561 for(title=0;( (title < vts_ptt_srpt->nr_of_srpts) && (found == 0) );title++) { |
| 88 | 562 for(part=0;((part < vts_ptt_srpt->title[title].nr_of_ptts) && (found == 0));part++) { |
| 563 if ( (vts_ptt_srpt->title[title].ptt[part].pgcn == pgcN) && | |
| 564 (vts_ptt_srpt->title[title].ptt[part].pgn == pgN ) ) { | |
| 565 found = 1; | |
| 566 break; | |
| 567 } | |
| 568 } | |
| 569 if (found != 0) break; | |
| 570 } | |
| 571 title++; | |
| 572 part++; | |
| 573 if (found == 1) { | |
| 574 fprintf(MSG_OUT, "libdvdnav: ************ this chapter FOUND!\n"); | |
| 101 | 575 fprintf(MSG_OUT, "libdvdnav: VTS_PTT_SRPT - Title %3i part %3i: PGC: %3i PG: %3i\n", |
| 88 | 576 title, part, |
| 577 vts_ptt_srpt->title[title-1].ptt[part-1].pgcn , | |
| 578 vts_ptt_srpt->title[title-1].ptt[part-1].pgn ); | |
| 579 } else { | |
| 580 fprintf(MSG_OUT, "libdvdnav: ************ this chapter NOT FOUND!\n"); | |
| 581 return S_ERR; | |
| 582 } | |
| 90 | 583 *title_result = title; |
| 584 *part_result = part; | |
| 585 return 1; | |
| 586 } | |
| 587 | |
| 588 /* Jump to a particlar part of a particlar title on this vts */ | |
| 589 /* returns S_ERR if not in the VTS_DOMAIN */ | |
| 590 /* FIXME: Should we do some locking here ? */ | |
| 591 int vm_jump_title_part(vm_t *vm, int title, int part) { | |
| 592 link_t link_values; | |
| 593 int vtsN; | |
| 594 | |
| 595 if((!vm) || (!vm->vtsi) || (!vm->vmgi) ) | |
| 596 return S_ERR; | |
| 597 | |
| 598 if(!(vm->state.pgc) ) | |
| 599 return S_ERR; | |
| 600 /* if ( (title < 1) || (title > vm->vtsi->vts_ptt_srpt->nr_of_srpts) || | |
| 601 (part < 1) || (part > vm->vtsi->vts_ptt_srpt->title[title].nr_of_ptts) ) { | |
| 88 | 602 return S_ERR; |
| 603 } | |
| 90 | 604 */ |
| 605 if( (title < 1) || (title > vm->vmgi->tt_srpt->nr_of_srpts) ) { | |
| 606 return S_ERR; | |
| 607 } | |
| 608 vtsN = vm->vmgi->tt_srpt->title[title - 1].title_set_nr; | |
| 609 | |
| 610 if(set_VTS_PTT(vm, vtsN, title, part) == -1) { | |
| 611 return S_ERR; | |
| 612 } | |
| 88 | 613 link_values = play_PGC_PG( vm, (vm->state).pgN ); |
| 614 link_values = process_command(vm,link_values); | |
| 615 assert(link_values.command == PlayThis); | |
| 616 (vm->state).blockN = link_values.data1; | |
| 617 assert( (vm->state).blockN == 0 ); | |
| 618 vm->hop_channel++; | |
| 619 | |
| 620 fprintf(MSG_OUT, "libdvdnav: previous chapter done\n"); | |
| 621 | |
| 622 return 1; | |
| 623 } | |
| 624 | |
| 0 | 625 static domain_t menuid2domain(DVDMenuID_t menuid) |
| 626 { | |
| 627 domain_t result = VTSM_DOMAIN; /* Really shouldn't have to.. */ | |
| 628 | |
| 629 switch(menuid) { | |
| 630 case DVD_MENU_Title: | |
| 631 result = VMGM_DOMAIN; | |
| 632 break; | |
| 633 case DVD_MENU_Root: | |
| 634 case DVD_MENU_Subpicture: | |
| 635 case DVD_MENU_Audio: | |
| 636 case DVD_MENU_Angle: | |
| 637 case DVD_MENU_Part: | |
| 638 result = VTSM_DOMAIN; | |
| 639 break; | |
| 640 } | |
| 641 | |
| 642 return result; | |
| 643 } | |
| 644 | |
| 6 | 645 int vm_menu_call(vm_t *vm, DVDMenuID_t menuid, int block) |
| 0 | 646 { |
| 647 domain_t old_domain; | |
| 648 link_t link_values; | |
| 649 | |
| 650 /* Should check if we are allowed/can acces this menu */ | |
| 651 | |
| 652 | |
| 653 /* FIXME XXX $$$ How much state needs to be restored | |
| 654 * when we fail to find a menu? */ | |
| 655 | |
| 6 | 656 old_domain = (vm->state).domain; |
| 0 | 657 |
| 6 | 658 switch((vm->state).domain) { |
| 0 | 659 case VTS_DOMAIN: |
| 6 | 660 saveRSMinfo(vm, 0, block); |
| 0 | 661 /* FALL THROUGH */ |
| 662 case VTSM_DOMAIN: | |
| 663 case VMGM_DOMAIN: | |
| 6 | 664 (vm->state).domain = menuid2domain(menuid); |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
665 if(get_PGCIT(vm) != NULL && set_MENU(vm, menuid) != -1) { |
| 6 | 666 link_values = play_PGC(vm); |
| 667 link_values = process_command(vm, link_values); | |
| 0 | 668 assert(link_values.command == PlayThis); |
| 6 | 669 (vm->state).blockN = link_values.data1; |
| 31 | 670 #ifdef TRACE |
| 76 | 671 fprintf(MSG_OUT, "libdvdnav: vm_menu_call: blockN set to 0x%x\n", (vm->state).blockN); |
| 31 | 672 #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
|
673 assert( (vm->state).blockN == 0 ); |
| 0 | 674 return 1; /* Jump */ |
| 675 } else { | |
| 6 | 676 (vm->state).domain = old_domain; |
| 0 | 677 } |
| 678 break; | |
| 679 case FP_DOMAIN: /* FIXME XXX $$$ What should we do here? */ | |
| 680 break; | |
| 681 } | |
| 682 | |
| 683 return 0; | |
| 684 } | |
| 685 | |
| 686 | |
| 6 | 687 int vm_resume(vm_t *vm) |
| 0 | 688 { |
| 689 int i; | |
| 690 link_t link_values; | |
| 691 | |
| 692 /* Check and see if there is any rsm info!! */ | |
| 6 | 693 if((vm->state).rsm_vtsN == 0) { |
| 0 | 694 return 0; |
| 695 } | |
| 696 | |
| 6 | 697 (vm->state).domain = VTS_DOMAIN; |
| 698 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
|
699 set_PGC(vm, (vm->state).rsm_pgcN); |
| 0 | 700 |
| 701 /* These should never be set in SystemSpace and/or MenuSpace */ | |
| 6 | 702 /* (vm->state).TTN_REG = (vm->state).rsm_tt; */ |
| 703 /* (vm->state).TT_PGCN_REG = (vm->state).rsm_pgcN; */ | |
| 704 /* (vm->state).HL_BTNN_REG = (vm->state).rsm_btnn; */ | |
| 0 | 705 for(i = 0; i < 5; i++) { |
| 6 | 706 (vm->state).registers.SPRM[4 + i] = (vm->state).rsm_regs[i]; |
| 0 | 707 } |
| 708 | |
| 6 | 709 if((vm->state).rsm_cellN == 0) { |
| 710 assert((vm->state).cellN); /* Checking if this ever happens */ | |
| 711 (vm->state).pgN = 1; | |
| 712 link_values = play_PG(vm); | |
| 713 link_values = process_command(vm, link_values); | |
| 0 | 714 assert(link_values.command == PlayThis); |
| 6 | 715 (vm->state).blockN = link_values.data1; |
| 31 | 716 #ifdef TRACE |
| 76 | 717 fprintf(MSG_OUT, "libdvdnav: vm_resume1: blockN set to 0x%x\n", (vm->state).blockN); |
| 31 | 718 #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
|
719 assert( (vm->state).blockN == 0 ); |
| 0 | 720 } else { |
| 6 | 721 (vm->state).cellN = (vm->state).rsm_cellN; |
| 722 (vm->state).blockN = (vm->state).rsm_blockN; | |
| 31 | 723 #ifdef TRACE |
| 76 | 724 fprintf(MSG_OUT, "libdvdnav: vm_resume2: blockN set to 0x%x\n", (vm->state).blockN); |
| 31 | 725 #endif |
| 6 | 726 /* (vm->state).pgN = ?? does this gets the righ value in play_Cell, no! */ |
| 727 if(set_PGN(vm)) { | |
| 0 | 728 /* Were at or past the end of the PGC, should not happen for a RSM */ |
| 729 assert(0); | |
| 6 | 730 play_PGC_post(vm); |
| 0 | 731 } |
| 732 } | |
| 733 | |
| 734 return 1; /* Jump */ | |
| 735 } | |
| 736 | |
| 737 /** | |
| 738 * Return the substream id for 'logical' audio stream audioN. | |
| 739 * 0 <= audioN < 8 | |
| 740 */ | |
| 6 | 741 int vm_get_audio_stream(vm_t *vm, int audioN) |
| 0 | 742 { |
| 743 int streamN = -1; | |
| 31 | 744 #ifdef TRACE |
| 76 | 745 fprintf(MSG_OUT, "libdvdnav: vm.c:get_audio_stream audioN=%d\n",audioN); |
| 31 | 746 #endif |
| 6 | 747 if((vm->state).domain == VTSM_DOMAIN |
| 748 || (vm->state).domain == VMGM_DOMAIN | |
| 749 || (vm->state).domain == FP_DOMAIN) { | |
| 0 | 750 audioN = 0; |
| 751 } | |
| 752 | |
| 753 if(audioN < 8) { | |
| 754 /* Is there any contol info for this logical stream */ | |
| 6 | 755 if((vm->state).pgc->audio_control[audioN] & (1<<15)) { |
| 756 streamN = ((vm->state).pgc->audio_control[audioN] >> 8) & 0x07; | |
| 0 | 757 } |
| 758 } | |
| 759 | |
| 6 | 760 if((vm->state).domain == VTSM_DOMAIN |
| 761 || (vm->state).domain == VMGM_DOMAIN | |
| 762 || (vm->state).domain == FP_DOMAIN) { | |
| 0 | 763 if(streamN == -1) |
| 764 streamN = 0; | |
| 765 } | |
| 766 | |
| 767 /* Should also check in vtsi/vmgi status that what kind of stream | |
| 768 * it is (ac3/lpcm/dts/sdds...) to find the right (sub)stream id */ | |
| 769 return streamN; | |
| 770 } | |
| 771 | |
| 772 /** | |
|
55
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
773 * Return the substream id for 'logical' subpicture stream subpN and given mode. |
| 0 | 774 * 0 <= subpN < 32 |
|
55
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
775 * mode == 0 - widescreen |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
776 * mode == 1 - letterbox |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
777 * mode == 2 - pan&scan |
| 0 | 778 */ |
|
55
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
779 int vm_get_subp_stream(vm_t *vm, int subpN, int mode) |
| 0 | 780 { |
| 781 int streamN = -1; | |
|
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
782 int source_aspect = vm_get_video_aspect(vm); |
| 0 | 783 |
| 6 | 784 if((vm->state).domain == VTSM_DOMAIN |
| 785 || (vm->state).domain == VMGM_DOMAIN | |
| 786 || (vm->state).domain == FP_DOMAIN) { | |
| 0 | 787 subpN = 0; |
| 788 } | |
| 789 | |
| 790 if(subpN < 32) { /* a valid logical stream */ | |
| 791 /* Is this logical stream present */ | |
| 6 | 792 if((vm->state).pgc->subp_control[subpN] & (1<<31)) { |
| 0 | 793 if(source_aspect == 0) /* 4:3 */ |
| 6 | 794 streamN = ((vm->state).pgc->subp_control[subpN] >> 24) & 0x1f; |
| 0 | 795 if(source_aspect == 3) /* 16:9 */ |
|
55
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
796 switch (mode) { |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
797 case 0: |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
798 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
|
799 break; |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
800 case 1: |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
801 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
|
802 break; |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
803 case 2: |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
804 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
|
805 } |
| 0 | 806 } |
| 807 } | |
| 808 | |
| 809 /* Paranoia.. if no stream select 0 anyway */ | |
| 810 /* I am not paranoid */ | |
| 6 | 811 /* if((vm->state).domain == VTSM_DOMAIN |
| 812 || (vm->state).domain == VMGM_DOMAIN | |
| 813 || (vm->state).domain == FP_DOMAIN) { | |
| 0 | 814 if(streamN == -1) |
| 815 streamN = 0; | |
| 816 } | |
| 817 */ | |
| 818 /* Should also check in vtsi/vmgi status that what kind of stream it is. */ | |
| 819 return streamN; | |
| 820 } | |
| 821 | |
|
55
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
822 int vm_get_subp_active_stream(vm_t *vm, int mode) |
| 0 | 823 { |
| 824 int subpN; | |
| 825 int streamN; | |
| 6 | 826 subpN = (vm->state).SPST_REG & ~0x40; |
|
55
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
827 streamN = vm_get_subp_stream(vm, subpN, mode); |
| 0 | 828 |
| 829 /* If no such stream, then select the first one that exists. */ | |
| 830 if(streamN == -1) { | |
| 831 for(subpN = 0; subpN < 32; subpN++) { | |
| 6 | 832 if((vm->state).pgc->subp_control[subpN] & (1<<31)) { |
| 0 | 833 |
|
55
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
834 streamN = vm_get_subp_stream(vm, subpN, mode); |
| 0 | 835 break; |
| 836 } | |
| 837 } | |
| 838 } | |
| 839 | |
| 840 /* We should instead send the on/off status to the spudecoder / mixer */ | |
| 841 /* If we are in the title domain see if the spu mixing is on */ | |
| 6 | 842 if((vm->state).domain == VTS_DOMAIN && !((vm->state).SPST_REG & 0x40)) { |
| 0 | 843 /* Bit 7 set means hide, and only let Forced display show */ |
| 844 return (streamN | 0x80); | |
| 845 } else { | |
| 846 return streamN; | |
| 847 } | |
| 848 } | |
| 849 | |
| 6 | 850 int vm_get_audio_active_stream(vm_t *vm) |
| 0 | 851 { |
| 852 int audioN; | |
| 853 int streamN; | |
| 6 | 854 audioN = (vm->state).AST_REG ; |
| 855 streamN = vm_get_audio_stream(vm, audioN); | |
| 0 | 856 |
| 857 /* If no such stream, then select the first one that exists. */ | |
| 858 if(streamN == -1) { | |
| 859 for(audioN = 0; audioN < 8; audioN++) { | |
| 6 | 860 if((vm->state).pgc->audio_control[audioN] & (1<<15)) { |
| 861 streamN = vm_get_audio_stream(vm, audioN); | |
| 0 | 862 break; |
| 863 } | |
| 864 } | |
| 865 } | |
| 866 | |
| 867 return streamN; | |
| 868 } | |
| 869 | |
| 870 | |
| 6 | 871 void vm_get_angle_info(vm_t *vm, int *num_avail, int *current) |
| 0 | 872 { |
| 873 *num_avail = 1; | |
| 874 *current = 1; | |
| 875 | |
| 6 | 876 if((vm->state).domain == VTS_DOMAIN) { |
| 0 | 877 /* TTN_REG does not allways point to the correct title.. */ |
| 878 title_info_t *title; | |
| 6 | 879 if((vm->state).TTN_REG > vm->vmgi->tt_srpt->nr_of_srpts) |
| 0 | 880 return; |
| 6 | 881 title = &vm->vmgi->tt_srpt->title[(vm->state).TTN_REG - 1]; |
| 882 if(title->title_set_nr != (vm->state).vtsN || | |
| 883 title->vts_ttn != (vm->state).VTS_TTN_REG) | |
| 0 | 884 return; |
| 885 *num_avail = title->nr_of_angles; | |
| 6 | 886 *current = (vm->state).AGL_REG; |
| 0 | 887 if(*current > *num_avail) /* Is this really a good idea? */ |
| 888 *current = *num_avail; | |
| 889 } | |
| 890 } | |
| 891 | |
| 892 | |
| 6 | 893 void vm_get_audio_info(vm_t *vm, int *num_avail, int *current) |
| 0 | 894 { |
| 6 | 895 if((vm->state).domain == VTS_DOMAIN) { |
| 896 *num_avail = vm->vtsi->vtsi_mat->nr_of_vts_audio_streams; | |
| 897 *current = (vm->state).AST_REG; | |
| 898 } else if((vm->state).domain == VTSM_DOMAIN) { | |
| 899 *num_avail = vm->vtsi->vtsi_mat->nr_of_vtsm_audio_streams; /* 1 */ | |
| 0 | 900 *current = 1; |
| 6 | 901 } else if((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN) { |
| 902 *num_avail = vm->vmgi->vmgi_mat->nr_of_vmgm_audio_streams; /* 1 */ | |
| 0 | 903 *current = 1; |
| 904 } | |
| 905 } | |
| 906 | |
| 6 | 907 void vm_get_subp_info(vm_t *vm, int *num_avail, int *current) |
| 0 | 908 { |
| 6 | 909 if((vm->state).domain == VTS_DOMAIN) { |
| 910 *num_avail = vm->vtsi->vtsi_mat->nr_of_vts_subp_streams; | |
| 911 *current = (vm->state).SPST_REG; | |
| 912 } else if((vm->state).domain == VTSM_DOMAIN) { | |
| 913 *num_avail = vm->vtsi->vtsi_mat->nr_of_vtsm_subp_streams; /* 1 */ | |
| 0 | 914 *current = 0x41; |
| 6 | 915 } else if((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN) { |
| 916 *num_avail = vm->vmgi->vmgi_mat->nr_of_vmgm_subp_streams; /* 1 */ | |
| 0 | 917 *current = 0x41; |
| 918 } | |
| 919 } | |
| 920 | |
| 6 | 921 subp_attr_t vm_get_subp_attr(vm_t *vm, int streamN) |
| 0 | 922 { |
| 923 subp_attr_t attr; | |
| 924 | |
| 6 | 925 if((vm->state).domain == VTS_DOMAIN) { |
| 926 attr = vm->vtsi->vtsi_mat->vts_subp_attr[streamN]; | |
| 927 } else if((vm->state).domain == VTSM_DOMAIN) { | |
| 928 attr = vm->vtsi->vtsi_mat->vtsm_subp_attr; | |
| 929 } else if((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN) { | |
| 930 attr = vm->vmgi->vmgi_mat->vmgm_subp_attr; | |
| 0 | 931 } |
| 932 return attr; | |
| 933 } | |
| 934 | |
| 6 | 935 audio_attr_t vm_get_audio_attr(vm_t *vm, int streamN) |
| 0 | 936 { |
| 937 audio_attr_t attr; | |
| 938 | |
| 6 | 939 if((vm->state).domain == VTS_DOMAIN) { |
| 940 attr = vm->vtsi->vtsi_mat->vts_audio_attr[streamN]; | |
| 941 } else if((vm->state).domain == VTSM_DOMAIN) { | |
| 942 attr = vm->vtsi->vtsi_mat->vtsm_audio_attr; | |
| 943 } else if((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN) { | |
| 944 attr = vm->vmgi->vmgi_mat->vmgm_audio_attr; | |
| 0 | 945 } |
| 946 return attr; | |
| 947 } | |
| 948 | |
| 6 | 949 video_attr_t vm_get_video_attr(vm_t *vm) |
| 0 | 950 { |
| 951 video_attr_t attr; | |
| 952 | |
| 6 | 953 if((vm->state).domain == VTS_DOMAIN) { |
| 954 attr = vm->vtsi->vtsi_mat->vts_video_attr; | |
| 955 } else if((vm->state).domain == VTSM_DOMAIN) { | |
| 956 attr = vm->vtsi->vtsi_mat->vtsm_video_attr; | |
| 957 } else if((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN) { | |
| 958 attr = vm->vmgi->vmgi_mat->vmgm_video_attr; | |
| 0 | 959 } |
| 960 return attr; | |
| 961 } | |
| 962 | |
| 6 | 963 void vm_get_video_res(vm_t *vm, int *width, int *height) |
| 0 | 964 { |
| 965 video_attr_t attr; | |
| 966 | |
| 6 | 967 attr = vm_get_video_attr(vm); |
| 0 | 968 |
| 969 if(attr.video_format != 0) | |
| 970 *height = 576; | |
| 971 else | |
| 972 *height = 480; | |
| 973 switch(attr.picture_size) { | |
| 974 case 0: | |
| 975 *width = 720; | |
| 976 break; | |
| 977 case 1: | |
| 978 *width = 704; | |
| 979 break; | |
| 980 case 2: | |
| 981 *width = 352; | |
| 982 break; | |
| 983 case 3: | |
| 984 *width = 352; | |
| 985 *height /= 2; | |
| 986 break; | |
| 987 } | |
| 988 } | |
| 989 | |
| 990 /* Must be called before domain is changed (get_PGCN()) */ | |
| 6 | 991 static void saveRSMinfo(vm_t *vm, int cellN, int blockN) |
| 0 | 992 { |
| 993 int i; | |
| 994 | |
| 995 if(cellN != 0) { | |
| 6 | 996 (vm->state).rsm_cellN = cellN; |
| 997 (vm->state).rsm_blockN = 0; | |
| 0 | 998 } else { |
| 6 | 999 (vm->state).rsm_cellN = (vm->state).cellN; |
| 1000 (vm->state).rsm_blockN = blockN; | |
| 0 | 1001 } |
| 6 | 1002 (vm->state).rsm_vtsN = (vm->state).vtsN; |
| 1003 (vm->state).rsm_pgcN = get_PGCN(vm); | |
| 0 | 1004 |
| 42 | 1005 /* assert((vm->state).rsm_pgcN == (vm->state).TT_PGCN_REG); for VTS_DOMAIN */ |
| 0 | 1006 |
| 1007 for(i = 0; i < 5; i++) { | |
| 6 | 1008 (vm->state).rsm_regs[i] = (vm->state).registers.SPRM[4 + i]; |
| 0 | 1009 } |
| 1010 } | |
| 1011 | |
| 1012 | |
| 1013 | |
| 6 | 1014 /* Figure out the correct pgN from the cell and update (vm->state). */ |
| 1015 static int set_PGN(vm_t *vm) { | |
| 0 | 1016 int new_pgN = 0; |
| 1017 | |
| 6 | 1018 while(new_pgN < (vm->state).pgc->nr_of_programs |
| 1019 && (vm->state).cellN >= (vm->state).pgc->program_map[new_pgN]) | |
| 0 | 1020 new_pgN++; |
| 1021 | |
| 6 | 1022 if(new_pgN == (vm->state).pgc->nr_of_programs) /* We are at the last program */ |
| 1023 if((vm->state).cellN > (vm->state).pgc->nr_of_cells) | |
| 0 | 1024 return 1; /* We are past the last cell */ |
| 1025 | |
| 6 | 1026 (vm->state).pgN = new_pgN; |
| 0 | 1027 |
| 6 | 1028 if((vm->state).domain == VTS_DOMAIN) { |
| 0 | 1029 playback_type_t *pb_ty; |
| 6 | 1030 if((vm->state).TTN_REG > vm->vmgi->tt_srpt->nr_of_srpts) |
| 0 | 1031 return 0; /* ?? */ |
| 6 | 1032 pb_ty = &vm->vmgi->tt_srpt->title[(vm->state).TTN_REG - 1].pb_ty; |
| 0 | 1033 if(pb_ty->multi_or_random_pgc_title == /* One_Sequential_PGC_Title */ 0) { |
| 1034 #if 0 /* TTN_REG can't be trusted to have a correct value here... */ | |
| 1035 vts_ptt_srpt_t *ptt_srpt = vtsi->vts_ptt_srpt; | |
| 6 | 1036 assert((vm->state).VTS_TTN_REG <= ptt_srpt->nr_of_srpts); |
| 1037 assert(get_PGCN() == ptt_srpt->title[(vm->state).VTS_TTN_REG - 1].ptt[0].pgcn); | |
| 1038 assert(1 == ptt_srpt->title[(vm->state).VTS_TTN_REG - 1].ptt[0].pgn); | |
| 0 | 1039 #endif |
| 6 | 1040 (vm->state).PTTN_REG = (vm->state).pgN; |
| 80 | 1041 } else { |
| 1042 /* FIXME: Handle RANDOM or SHUFFLE titles. */ | |
| 1043 fprintf(MSG_OUT, "libdvdnav: RANDOM or SHUFFLE titles are NOT handled yet.\n"); | |
| 0 | 1044 } |
| 80 | 1045 |
| 0 | 1046 } |
| 1047 | |
| 1048 return 0; | |
| 1049 } | |
| 1050 | |
| 6 | 1051 static link_t play_PGC(vm_t *vm) |
| 0 | 1052 { |
| 1053 link_t link_values; | |
| 1054 | |
| 31 | 1055 #ifdef TRACE |
| 76 | 1056 fprintf(MSG_OUT, "libdvdnav: vm: play_PGC:"); |
| 31 | 1057 if((vm->state).domain != FP_DOMAIN) { |
| 76 | 1058 fprintf(MSG_OUT, " (vm->state).pgcN (%i)\n", get_PGCN(vm)); |
| 31 | 1059 } else { |
| 76 | 1060 fprintf(MSG_OUT, " first_play_pgc\n"); |
| 31 | 1061 } |
| 1062 #endif | |
| 0 | 1063 |
| 1064 /* This must be set before the pre-commands are executed because they */ | |
| 1065 /* might contain a CallSS that will save resume state */ | |
| 38 | 1066 |
| 1067 /* FIXME: This may be only a temporary fix for something... */ | |
| 6 | 1068 (vm->state).pgN = 1; |
| 1069 (vm->state).cellN = 0; | |
| 0 | 1070 |
| 1071 /* eval -> updates the state and returns either | |
| 1072 - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN) | |
| 1073 - just play video i.e first PG | |
| 1074 (This is what happens if you fall of the end of the pre_cmds) | |
| 1075 - or a error (are there more cases?) */ | |
| 6 | 1076 if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_pre) { |
| 1077 if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds, | |
| 1078 (vm->state).pgc->command_tbl->nr_of_pre, | |
| 1079 &(vm->state).registers, &link_values)) { | |
| 0 | 1080 /* link_values contains the 'jump' return value */ |
| 1081 return link_values; | |
| 1082 } else { | |
| 31 | 1083 #ifdef TRACE |
| 76 | 1084 fprintf(MSG_OUT, "libdvdnav: PGC pre commands didn't do a Jump, Link or Call\n"); |
| 31 | 1085 #endif |
| 0 | 1086 } |
| 1087 } | |
| 6 | 1088 return play_PG(vm); |
| 0 | 1089 } |
| 1090 | |
| 38 | 1091 static link_t play_PGC_PG(vm_t *vm, int pgN) |
| 1092 { | |
| 1093 link_t link_values; | |
| 1094 | |
| 1095 #ifdef TRACE | |
| 76 | 1096 fprintf(MSG_OUT, "libdvdnav: vm: play_PGC:"); |
| 38 | 1097 if((vm->state).domain != FP_DOMAIN) { |
| 76 | 1098 fprintf(MSG_OUT, " (vm->state).pgcN (%i)\n", get_PGCN(vm)); |
| 38 | 1099 } else { |
| 76 | 1100 fprintf(MSG_OUT, " first_play_pgc\n"); |
| 38 | 1101 } |
| 1102 #endif | |
| 1103 | |
| 1104 /* This must be set before the pre-commands are executed because they */ | |
| 1105 /* might contain a CallSS that will save resume state */ | |
| 1106 | |
| 1107 /* FIXME: This may be only a temporary fix for something... */ | |
| 1108 (vm->state).pgN = pgN; | |
| 1109 (vm->state).cellN = 0; | |
| 1110 | |
| 1111 /* eval -> updates the state and returns either | |
| 1112 - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN) | |
| 1113 - just play video i.e first PG | |
| 1114 (This is what happens if you fall of the end of the pre_cmds) | |
| 1115 - or a error (are there more cases?) */ | |
| 1116 if((vm->state).pgc->command_tbl && (vm->state).pgc->command_tbl->nr_of_pre) { | |
| 1117 if(vmEval_CMD((vm->state).pgc->command_tbl->pre_cmds, | |
| 1118 (vm->state).pgc->command_tbl->nr_of_pre, | |
| 1119 &(vm->state).registers, &link_values)) { | |
| 1120 /* link_values contains the 'jump' return value */ | |
| 1121 return link_values; | |
| 1122 } else { | |
| 1123 #ifdef TRACE | |
| 76 | 1124 fprintf(MSG_OUT, "libdvdnav: PGC pre commands didn't do a Jump, Link or Call\n"); |
| 38 | 1125 #endif |
| 1126 } | |
| 1127 } | |
| 1128 return play_PG(vm); | |
| 1129 } | |
| 0 | 1130 |
| 6 | 1131 static link_t play_PG(vm_t *vm) |
| 0 | 1132 { |
| 31 | 1133 #ifdef TRACE |
| 76 | 1134 fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i)\n", (vm->state).pgN); |
| 31 | 1135 #endif |
| 0 | 1136 |
| 6 | 1137 assert((vm->state).pgN > 0); |
| 1138 if((vm->state).pgN > (vm->state).pgc->nr_of_programs) { | |
| 31 | 1139 #ifdef TRACE |
| 80 | 1140 fprintf(MSG_OUT, "libdvdnav: play_PG: (vm->state).pgN (%i) > pgc->nr_of_programs (%i)\n", |
| 1141 (vm->state).pgN, (vm->state).pgc->nr_of_programs ); | |
| 31 | 1142 #endif |
| 80 | 1143 assert((vm->state).pgN == (vm->state).pgc->nr_of_programs + 1); |
| 6 | 1144 return play_PGC_post(vm); |
| 0 | 1145 } |
| 1146 | |
| 6 | 1147 (vm->state).cellN = (vm->state).pgc->program_map[(vm->state).pgN - 1]; |
| 0 | 1148 |
| 6 | 1149 return play_Cell(vm); |
| 0 | 1150 } |
| 1151 | |
| 1152 | |
| 6 | 1153 static link_t play_Cell(vm_t *vm) |
| 0 | 1154 { |
| 31 | 1155 #ifdef TRACE |
| 76 | 1156 fprintf(MSG_OUT, "libdvdnav: play_Cell: (vm->state).cellN (%i)\n", (vm->state).cellN); |
| 31 | 1157 #endif |
| 0 | 1158 |
| 6 | 1159 assert((vm->state).cellN > 0); |
| 1160 if((vm->state).cellN > (vm->state).pgc->nr_of_cells) { | |
| 31 | 1161 #ifdef TRACE |
| 80 | 1162 fprintf(MSG_OUT, "libdvdnav: (vm->state).cellN (%i) > pgc->nr_of_cells (%i)\n", |
| 1163 (vm->state).cellN, (vm->state).pgc->nr_of_cells ); | |
| 31 | 1164 #endif |
| 6 | 1165 assert((vm->state).cellN == (vm->state).pgc->nr_of_cells + 1); |
| 1166 return play_PGC_post(vm); | |
| 0 | 1167 } |
| 1168 | |
| 1169 | |
| 1170 /* Multi angle/Interleaved */ | |
| 6 | 1171 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode) { |
| 0 | 1172 case 0: /* Normal */ |
| 6 | 1173 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 0); |
| 0 | 1174 break; |
| 1175 case 1: /* The first cell in the block */ | |
| 6 | 1176 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type) { |
| 0 | 1177 case 0: /* Not part of a block */ |
| 1178 assert(0); | |
| 1179 case 1: /* Angle block */ | |
| 1180 /* Loop and check each cell instead? So we don't get outsid the block. */ | |
| 6 | 1181 (vm->state).cellN += (vm->state).AGL_REG - 1; |
| 75 | 1182 #ifdef STRICT |
| 6 | 1183 assert((vm->state).cellN <= (vm->state).pgc->nr_of_cells); |
| 1184 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode != 0); | |
| 1185 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 1); | |
| 75 | 1186 #endif |
| 1187 if (!((vm->state).cellN <= (vm->state).pgc->nr_of_cells) || | |
| 1188 !((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode != 0) || | |
| 1189 !((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 1)) { | |
| 76 | 1190 fprintf(MSG_OUT, "libdvdnav: Invalid angle block\n"); |
| 75 | 1191 (vm->state).cellN -= (vm->state).AGL_REG - 1; |
| 1192 } | |
| 0 | 1193 break; |
| 1194 case 2: /* ?? */ | |
| 1195 case 3: /* ?? */ | |
| 1196 default: | |
| 76 | 1197 fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n", |
| 6 | 1198 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode, |
| 1199 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type); | |
| 0 | 1200 } |
| 1201 break; | |
| 1202 case 2: /* Cell in the block */ | |
| 1203 case 3: /* Last cell in the block */ | |
| 1204 /* These might perhaps happen for RSM or LinkC commands? */ | |
| 1205 default: | |
| 76 | 1206 fprintf(MSG_OUT, "libdvdnav: Cell is in block but did not enter at first cell!\n"); |
| 0 | 1207 } |
| 1208 | |
| 6 | 1209 /* Updates (vm->state).pgN and PTTN_REG */ |
| 1210 if(set_PGN(vm)) { | |
| 0 | 1211 /* Should not happen */ |
| 1212 link_t tmp = {LinkTailPGC, /* No Button */ 0, 0, 0}; | |
| 1213 assert(0); | |
| 1214 return tmp; | |
| 1215 } | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1216 (vm->state).cell_restart++; |
| 76 | 1217 fprintf(MSG_OUT, "libdvdnav: Cell should restart here\n"); |
| 0 | 1218 { |
| 1219 link_t tmp = {PlayThis, /* Block in Cell */ 0, 0, 0}; | |
| 1220 return tmp; | |
| 1221 } | |
| 1222 | |
| 1223 } | |
| 1224 | |
| 6 | 1225 static link_t play_Cell_post(vm_t *vm) |
| 0 | 1226 { |
| 1227 cell_playback_t *cell; | |
| 1228 | |
| 31 | 1229 #ifdef TRACE |
| 76 | 1230 fprintf(MSG_OUT, "libdvdnav: play_Cell_post: (vm->state).cellN (%i)\n", (vm->state).cellN); |
| 31 | 1231 #endif |
| 0 | 1232 |
| 6 | 1233 cell = &(vm->state).pgc->cell_playback[(vm->state).cellN - 1]; |
| 0 | 1234 |
| 1235 /* Still time is already taken care of before we get called. */ | |
| 1236 | |
| 1237 /* Deal with a Cell command, if any */ | |
| 1238 if(cell->cell_cmd_nr != 0) { | |
| 1239 link_t link_values; | |
| 1240 | |
| 83 | 1241 /* These asserts are now not needed. |
| 1242 * Some DVDs have no cell commands listed in the PGC, | |
| 1243 * but the Cell itself points to a cell command that does not exist. | |
| 1244 * For this situation, just ignore the cell command and continue. | |
| 1245 * | |
| 1246 * assert((vm->state).pgc->command_tbl != NULL); | |
| 1247 * assert((vm->state).pgc->command_tbl->nr_of_cell >= cell->cell_cmd_nr); | |
| 1248 */ | |
| 1249 | |
| 75 | 1250 if ((vm->state).pgc->command_tbl != NULL && |
| 1251 (vm->state).pgc->command_tbl->nr_of_cell >= cell->cell_cmd_nr) { | |
| 31 | 1252 #ifdef TRACE |
| 76 | 1253 fprintf(MSG_OUT, "libdvdnav: Cell command present, executing\n"); |
| 31 | 1254 #endif |
| 75 | 1255 if(vmEval_CMD(&(vm->state).pgc->command_tbl->cell_cmds[cell->cell_cmd_nr - 1], 1, |
| 1256 &(vm->state).registers, &link_values)) { | |
| 1257 return link_values; | |
| 1258 } else { | |
| 76 | 1259 fprintf(MSG_OUT, "libdvdnav: Cell command didn't do a Jump, Link or Call\n"); |
| 75 | 1260 /* Error ?? goto tail? goto next PG? or what? just continue? */ |
| 1261 } | |
| 0 | 1262 } else { |
| 76 | 1263 fprintf(MSG_OUT, "libdvdnav: Invalid Cell command\n"); |
| 83 | 1264 |
| 0 | 1265 } |
| 1266 } | |
| 1267 | |
| 1268 | |
| 1269 /* Where to continue after playing the cell... */ | |
| 1270 /* Multi angle/Interleaved */ | |
| 6 | 1271 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode) { |
| 0 | 1272 case 0: /* Normal */ |
| 6 | 1273 assert((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type == 0); |
| 1274 (vm->state).cellN++; | |
| 0 | 1275 break; |
| 1276 case 1: /* The first cell in the block */ | |
| 1277 case 2: /* A cell in the block */ | |
| 1278 case 3: /* The last cell in the block */ | |
| 1279 default: | |
| 6 | 1280 switch((vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type) { |
| 0 | 1281 case 0: /* Not part of a block */ |
| 1282 assert(0); | |
| 1283 case 1: /* Angle block */ | |
| 1284 /* Skip the 'other' angles */ | |
| 6 | 1285 (vm->state).cellN++; |
| 1286 while((vm->state).cellN <= (vm->state).pgc->nr_of_cells | |
| 1287 && (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode >= 2) { | |
| 1288 (vm->state).cellN++; | |
| 0 | 1289 } |
| 1290 break; | |
| 1291 case 2: /* ?? */ | |
| 1292 case 3: /* ?? */ | |
| 1293 default: | |
| 76 | 1294 fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n", |
| 6 | 1295 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode, |
| 1296 (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_type); | |
| 0 | 1297 } |
| 1298 break; | |
| 1299 } | |
| 1300 | |
| 1301 | |
| 1302 /* Figure out the correct pgN for the new cell */ | |
| 6 | 1303 if(set_PGN(vm)) { |
| 31 | 1304 #ifdef TRACE |
| 76 | 1305 fprintf(MSG_OUT, "libdvdnav: last cell in this PGC\n"); |
| 31 | 1306 #endif |
| 6 | 1307 return play_PGC_post(vm); |
| 0 | 1308 } |
| 1309 | |
| 6 | 1310 return play_Cell(vm); |
| 0 | 1311 } |
| 1312 | |
| 1313 | |
| 6 | 1314 static link_t play_PGC_post(vm_t *vm) |
| 0 | 1315 { |
| 1316 link_t link_values; | |
| 1317 | |
| 31 | 1318 #ifdef TRACE |
| 76 | 1319 fprintf(MSG_OUT, "libdvdnav: play_PGC_post:\n"); |
| 31 | 1320 #endif |
| 0 | 1321 |
| 80 | 1322 /* FIXME Implement PGC Stills. Currently only Cell stills work */ |
| 1323 assert((vm->state).pgc->still_time == 0); | |
| 0 | 1324 |
| 1325 /* eval -> updates the state and returns either | |
| 1326 - some kind of jump (Jump(TT/SS/VTS_TTN/CallSS/link C/PG/PGC/PTTN) | |
| 1327 - or a error (are there more cases?) | |
| 1328 - if you got to the end of the post_cmds, then what ?? */ | |
| 6 | 1329 if((vm->state).pgc->command_tbl && |
| 1330 vmEval_CMD((vm->state).pgc->command_tbl->post_cmds, | |
| 1331 (vm->state).pgc->command_tbl->nr_of_post, | |
| 1332 &(vm->state).registers, &link_values)) { | |
| 0 | 1333 return link_values; |
| 1334 } | |
| 1335 | |
| 1336 /* Or perhaps handle it here? */ | |
| 1337 { | |
| 1338 link_t link_next_pgc = {LinkNextPGC, 0, 0, 0}; | |
| 76 | 1339 fprintf(MSG_OUT, "libdvdnav: ** Fell of the end of the pgc, continuing in NextPGC\n"); |
| 6 | 1340 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
|
1341 /* Should end up in the STOP_DOMAIN if next_pgc is 0. */ |
| 0 | 1342 return link_next_pgc; |
| 1343 } | |
| 1344 } | |
| 1345 | |
| 1346 | |
| 6 | 1347 static link_t process_command(vm_t *vm, link_t link_values) |
| 0 | 1348 { |
| 1349 /* FIXME $$$ Move this to a separate function? */ | |
| 6 | 1350 vm->badness_counter++; |
| 82 | 1351 if (vm->badness_counter > 1) fprintf(MSG_OUT, "libdvdnav: **** WARNING: process_command re-entered %d*****\n",vm->badness_counter); |
| 0 | 1352 while(link_values.command != PlayThis) { |
| 1353 | |
| 31 | 1354 #ifdef TRACE |
| 82 | 1355 fprintf(MSG_OUT, "libdvdnav: Before printout starts:\n"); |
| 0 | 1356 vmPrint_LINK(link_values); |
| 1357 | |
| 76 | 1358 fprintf(MSG_OUT, "libdvdnav: Link values %i %i %i %i\n", link_values.command, |
| 0 | 1359 link_values.data1, link_values.data2, link_values.data3); |
| 1360 | |
| 6 | 1361 vm_print_current_domain_state(vm); |
| 82 | 1362 fprintf(MSG_OUT, "libdvdnav: Before printout ends.\n"); |
| 31 | 1363 #endif |
| 0 | 1364 |
| 1365 switch(link_values.command) { | |
| 1366 case LinkNoLink: | |
| 1367 /* No Link */ | |
| 9 | 1368 /* BUTTON number:data1 */ |
| 0 | 1369 if(link_values.data1 != 0) |
| 6 | 1370 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
| 76 | 1371 fprintf(MSG_OUT, "libdvdnav: FIXME: in trouble...LinkNoLink - CRASHING!!!\n"); |
| 6 | 1372 assert(0); |
| 0 | 1373 |
| 1374 case LinkTopC: | |
| 52 | 1375 /* Restart playing from the beginning of the current Cell. */ |
| 9 | 1376 /* BUTTON number:data1 */ |
| 76 | 1377 fprintf(MSG_OUT, "libdvdnav: FIXME: LinkTopC. Replay current Cell\n"); |
| 0 | 1378 if(link_values.data1 != 0) |
| 6 | 1379 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
| 1380 link_values = play_Cell(vm); | |
| 0 | 1381 break; |
| 1382 case LinkNextC: | |
| 1383 /* Link to Next Cell */ | |
| 9 | 1384 /* BUTTON number:data1 */ |
| 0 | 1385 if(link_values.data1 != 0) |
| 6 | 1386 (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
|
1387 (vm->state).cellN += 1; /* if cellN becomes > nr_of_cells? it is handled in play_Cell() */ |
| 6 | 1388 link_values = play_Cell(vm); |
| 0 | 1389 break; |
| 1390 case LinkPrevC: | |
| 1391 /* Link to Previous Cell */ | |
| 9 | 1392 /* BUTTON number:data1 */ |
| 0 | 1393 if(link_values.data1 != 0) |
| 6 | 1394 (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
|
1395 (vm->state).cellN -= 1; /* If cellN becomes < 1? it is handled in play_Cell() */ |
| 6 | 1396 link_values = play_Cell(vm); |
| 0 | 1397 break; |
| 1398 | |
| 1399 case LinkTopPG: | |
| 1400 /* Link to Top Program */ | |
| 9 | 1401 /* BUTTON number:data1 */ |
| 76 | 1402 fprintf(MSG_OUT, "libdvdnav: FIXME: LinkTopPG. This should start the current PG again.\n"); |
| 0 | 1403 if(link_values.data1 != 0) |
| 6 | 1404 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
| 0 | 1405 /* Does pgN always contain the current value? */ |
| 6 | 1406 link_values = play_PG(vm); |
| 0 | 1407 break; |
| 1408 case LinkNextPG: | |
| 1409 /* Link to Next Program */ | |
| 9 | 1410 /* BUTTON number:data1 */ |
| 0 | 1411 if(link_values.data1 != 0) |
| 6 | 1412 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
| 0 | 1413 /* Does pgN always contain the current value? */ |
| 6 | 1414 (vm->state).pgN += 1; /* FIXME: What if pgN becomes > pgc.nr_of_programs? */ |
| 1415 link_values = play_PG(vm); | |
| 0 | 1416 break; |
| 1417 case LinkPrevPG: | |
| 1418 /* Link to Previous Program */ | |
| 9 | 1419 /* BUTTON number:data1 */ |
| 0 | 1420 if(link_values.data1 != 0) |
| 6 | 1421 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
| 0 | 1422 /* Does pgN always contain the current value? */ |
| 9 | 1423 assert((vm->state).pgN > 1); |
| 6 | 1424 (vm->state).pgN -= 1; /* FIXME: What if pgN becomes < 1? */ |
| 1425 link_values = play_PG(vm); | |
| 0 | 1426 break; |
| 1427 | |
| 1428 case LinkTopPGC: | |
| 52 | 1429 /* Restart playing from beginning of current Program Chain */ |
| 9 | 1430 /* BUTTON number:data1 */ |
| 76 | 1431 fprintf(MSG_OUT, "libdvdnav: FIXME: LinkTopPGC. Restart from beginning of current Program Chain\n"); |
| 0 | 1432 if(link_values.data1 != 0) |
| 6 | 1433 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
| 1434 link_values = play_PGC(vm); | |
| 0 | 1435 break; |
| 1436 case LinkNextPGC: | |
| 1437 /* Link to Next Program Chain */ | |
| 9 | 1438 /* BUTTON number:data1 */ |
| 0 | 1439 if(link_values.data1 != 0) |
| 6 | 1440 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
| 1441 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
|
1442 if(set_PGC(vm, (vm->state).pgc->next_pgc_nr)) |
| 0 | 1443 assert(0); |
| 6 | 1444 link_values = play_PGC(vm); |
| 0 | 1445 break; |
| 1446 case LinkPrevPGC: | |
| 1447 /* Link to Previous 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->prev_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->prev_pgc_nr)) |
| 0 | 1453 assert(0); |
| 6 | 1454 link_values = play_PGC(vm); |
| 0 | 1455 break; |
| 1456 case LinkGoUpPGC: | |
| 1457 /* Link to GoUp??? 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->goup_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->goup_pgc_nr)) |
| 0 | 1463 assert(0); |
| 6 | 1464 link_values = play_PGC(vm); |
| 0 | 1465 break; |
| 1466 case LinkTailPGC: | |
| 1467 /* Link to Tail??? Program Chain */ | |
| 9 | 1468 /* BUTTON number:data1 */ |
| 76 | 1469 /* fprintf(MSG_OUT, "libdvdnav: FIXME: LinkTailPGC. What is LinkTailPGC?\n"); */ |
| 0 | 1470 if(link_values.data1 != 0) |
| 6 | 1471 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
| 1472 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
|
1473 break; |
| 0 | 1474 |
| 1475 case LinkRSM: | |
| 1476 { | |
| 1477 /* Link to Resume */ | |
| 1478 int i; | |
| 1479 /* Check and see if there is any rsm info!! */ | |
| 6 | 1480 (vm->state).domain = VTS_DOMAIN; |
| 1481 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
|
1482 set_PGC(vm, (vm->state).rsm_pgcN); |
| 0 | 1483 |
| 1484 /* These should never be set in SystemSpace and/or MenuSpace */ | |
| 6 | 1485 /* (vm->state).TTN_REG = rsm_tt; ?? */ |
| 1486 /* (vm->state).TT_PGCN_REG = (vm->state).rsm_pgcN; ?? */ | |
| 0 | 1487 for(i = 0; i < 5; i++) { |
| 6 | 1488 (vm->state).registers.SPRM[4 + i] = (vm->state).rsm_regs[i]; |
| 0 | 1489 } |
| 1490 | |
| 1491 if(link_values.data1 != 0) | |
| 6 | 1492 (vm->state).HL_BTNN_REG = link_values.data1 << 10; |
| 0 | 1493 |
| 6 | 1494 if((vm->state).rsm_cellN == 0) { |
| 1495 assert((vm->state).cellN); /* Checking if this ever happens */ | |
| 0 | 1496 /* assert( time/block/vobu is 0 ); */ |
| 6 | 1497 (vm->state).pgN = 1; |
| 1498 link_values = play_PG(vm); | |
| 0 | 1499 } else { |
| 1500 /* assert( time/block/vobu is _not_ 0 ); */ | |
| 1501 /* play_Cell_at_time */ | |
| 6 | 1502 /* (vm->state).pgN = ?? this gets the righ value in play_Cell */ |
| 1503 (vm->state).cellN = (vm->state).rsm_cellN; | |
| 0 | 1504 link_values.command = PlayThis; |
| 6 | 1505 link_values.data1 = (vm->state).rsm_blockN; |
| 1506 if(set_PGN(vm)) { | |
| 0 | 1507 /* Were at the end of the PGC, should not happen for a RSM */ |
| 1508 assert(0); | |
| 1509 link_values.command = LinkTailPGC; | |
| 1510 link_values.data1 = 0; /* No button */ | |
| 1511 } | |
| 1512 } | |
| 1513 } | |
| 1514 break; | |
| 1515 case LinkPGCN: | |
| 1516 /* Link to Program Chain Number:data1 */ | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1517 if(set_PGC(vm, link_values.data1)) |
| 0 | 1518 assert(0); |
| 6 | 1519 link_values = play_PGC(vm); |
| 0 | 1520 break; |
| 1521 case LinkPTTN: | |
| 1522 /* Link to Part of this Title Number:data1 */ | |
| 9 | 1523 /* BUTTON number:data2 */ |
| 6 | 1524 assert((vm->state).domain == VTS_DOMAIN); |
| 0 | 1525 if(link_values.data2 != 0) |
| 6 | 1526 (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
|
1527 if(set_VTS_PTT(vm, (vm->state).vtsN, (vm->state).VTS_TTN_REG, link_values.data1) == -1) |
| 0 | 1528 assert(0); |
| 6 | 1529 link_values = play_PG(vm); |
| 0 | 1530 break; |
| 1531 case LinkPGN: | |
| 1532 /* Link to Program Number:data1 */ | |
| 9 | 1533 /* BUTTON number:data2 */ |
| 0 | 1534 if(link_values.data2 != 0) |
| 6 | 1535 (vm->state).HL_BTNN_REG = link_values.data2 << 10; |
| 0 | 1536 /* Update any other state, PTTN perhaps? */ |
| 6 | 1537 (vm->state).pgN = link_values.data1; |
| 1538 link_values = play_PG(vm); | |
| 0 | 1539 break; |
| 1540 case LinkCN: | |
| 1541 /* Link to Cell Number:data1 */ | |
| 9 | 1542 /* BUTTON number:data2 */ |
| 0 | 1543 if(link_values.data2 != 0) |
| 6 | 1544 (vm->state).HL_BTNN_REG = link_values.data2 << 10; |
| 0 | 1545 /* Update any other state, pgN, PTTN perhaps? */ |
| 6 | 1546 (vm->state).cellN = link_values.data1; |
| 1547 link_values = play_Cell(vm); | |
| 0 | 1548 break; |
| 1549 | |
| 1550 case Exit: | |
| 76 | 1551 fprintf(MSG_OUT, "libdvdnav: FIXME:in trouble...Link Exit - CRASHING!!!\n"); |
| 6 | 1552 assert(0); /* What should we do here?? */ |
| 0 | 1553 |
| 1554 case JumpTT: | |
| 1555 /* Jump to VTS Title Domain */ | |
| 1556 /* Only allowed from the First Play domain(PGC) */ | |
| 1557 /* or the Video Manager domain (VMG) */ | |
| 6 | 1558 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
|
1559 if(set_TT(vm,link_values.data1) == -1) |
| 0 | 1560 assert(0); |
| 6 | 1561 link_values = play_PGC(vm); |
| 0 | 1562 break; |
| 1563 case JumpVTS_TT: | |
| 1564 /* Jump to Title:data1 in same VTS Title Domain */ | |
| 1565 /* Only allowed from the VTS Menu Domain(VTSM) */ | |
| 1566 /* or the Video Title Set Domain(VTS) */ | |
| 6 | 1567 assert((vm->state).domain == VTSM_DOMAIN || (vm->state).domain == VTS_DOMAIN); /* ?? */ |
| 76 | 1568 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
|
1569 if(set_VTS_TT(vm,(vm->state).vtsN, link_values.data1) == -1) |
| 0 | 1570 assert(0); |
| 6 | 1571 link_values = play_PGC(vm); |
| 0 | 1572 break; |
| 1573 case JumpVTS_PTT: | |
| 1574 /* Jump to Part:data2 of 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); /* ?? */ |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1578 if(set_VTS_PTT(vm,(vm->state).vtsN, link_values.data1, link_values.data2) == -1) |
| 0 | 1579 assert(0); |
| 87 | 1580 link_values = play_PGC_PG( vm, (vm->state).pgN ); |
| 0 | 1581 break; |
| 1582 | |
| 1583 case JumpSS_FP: | |
| 1584 /* Jump to First Play Domain */ | |
| 1585 /* Only allowed from the VTS Menu Domain(VTSM) */ | |
| 1586 /* or the Video Manager domain (VMG) */ | |
| 6 | 1587 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
|
1588 set_FP_PGC(vm); |
| 6 | 1589 link_values = play_PGC(vm); |
| 0 | 1590 break; |
| 1591 case JumpSS_VMGM_MENU: | |
| 1592 /* Jump to Video Manger domain - Title Menu:data1 or any PGC in VMG */ | |
| 1593 /* Allowed from anywhere except the VTS Title domain */ | |
| 6 | 1594 assert((vm->state).domain == VMGM_DOMAIN || |
| 1595 (vm->state).domain == VTSM_DOMAIN || | |
| 1596 (vm->state).domain == FP_DOMAIN); /* ?? */ | |
| 1597 (vm->state).domain = VMGM_DOMAIN; | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1598 if(set_MENU(vm,link_values.data1) == -1) |
| 0 | 1599 assert(0); |
| 6 | 1600 link_values = play_PGC(vm); |
| 0 | 1601 break; |
| 1602 case JumpSS_VTSM: | |
| 1603 /* Jump to a menu in Video Title domain, */ | |
| 1604 /* or to a Menu is the current VTS */ | |
| 1605 /* FIXME: This goes badly wrong for some DVDs. */ | |
| 1606 /* FIXME: Keep in touch with ogle people regarding what to do here */ | |
| 9 | 1607 /* ifoOpenNewVTSI:data1 */ |
| 1608 /* VTS_TTN_REG:data2 */ | |
| 1609 /* get_MENU:data3 */ | |
| 31 | 1610 #ifdef TRACE |
| 76 | 1611 fprintf(MSG_OUT, "libdvdnav: BUG TRACKING *******************************************************************\n"); |
| 1612 fprintf(MSG_OUT, "libdvdnav: data1=%u data2=%u data3=%u\n", | |
| 0 | 1613 link_values.data1, |
| 1614 link_values.data2, | |
| 1615 link_values.data3); | |
| 76 | 1616 fprintf(MSG_OUT, "libdvdnav: *******************************************************************\n"); |
| 31 | 1617 #endif |
| 0 | 1618 |
| 1619 if(link_values.data1 !=0) { | |
| 6 | 1620 assert((vm->state).domain == VMGM_DOMAIN || (vm->state).domain == FP_DOMAIN); /* ?? */ |
| 1621 (vm->state).domain = VTSM_DOMAIN; | |
| 1622 ifoOpenNewVTSI(vm, vm->dvd, link_values.data1); /* Also sets (vm->state).vtsN */ | |
| 0 | 1623 } else { |
| 1624 /* This happens on 'The Fifth Element' region 2. */ | |
| 6 | 1625 assert((vm->state).domain == VTSM_DOMAIN); |
| 0 | 1626 } |
| 1627 /* I don't know what title is supposed to be used for. */ | |
| 1628 /* Alien or Aliens has this != 1, I think. */ | |
| 1629 /* assert(link_values.data2 == 1); */ | |
| 6 | 1630 (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
|
1631 if(set_MENU(vm, link_values.data3) == -1) |
| 0 | 1632 assert(0); |
| 6 | 1633 link_values = play_PGC(vm); |
| 0 | 1634 break; |
| 1635 case JumpSS_VMGM_PGC: | |
| 9 | 1636 /* get_PGC:data1 */ |
| 6 | 1637 assert((vm->state).domain == VMGM_DOMAIN || |
| 1638 (vm->state).domain == VTSM_DOMAIN || | |
| 1639 (vm->state).domain == FP_DOMAIN); /* ?? */ | |
| 1640 (vm->state).domain = VMGM_DOMAIN; | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1641 if(set_PGC(vm,link_values.data1) == -1) |
| 0 | 1642 assert(0); |
| 6 | 1643 link_values = play_PGC(vm); |
| 0 | 1644 break; |
| 1645 | |
| 1646 case CallSS_FP: | |
| 9 | 1647 /* saveRSMinfo:data1 */ |
| 6 | 1648 assert((vm->state).domain == VTS_DOMAIN); /* ?? */ |
| 0 | 1649 /* Must be called before domain is changed */ |
| 6 | 1650 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
|
1651 set_FP_PGC(vm); |
| 6 | 1652 link_values = play_PGC(vm); |
| 0 | 1653 break; |
| 1654 case CallSS_VMGM_MENU: | |
| 9 | 1655 /* get_MENU:data1 */ |
| 1656 /* saveRSMinfo:data2 */ | |
| 6 | 1657 assert((vm->state).domain == VTS_DOMAIN); /* ?? */ |
| 0 | 1658 /* Must be called before domain is changed */ |
| 6 | 1659 saveRSMinfo(vm,link_values.data2, /* We dont have block info */ 0); |
| 1660 (vm->state).domain = VMGM_DOMAIN; | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1661 if(set_MENU(vm,link_values.data1) == -1) |
| 0 | 1662 assert(0); |
| 6 | 1663 link_values = play_PGC(vm); |
| 0 | 1664 break; |
| 1665 case CallSS_VTSM: | |
| 9 | 1666 /* get_MENU:data1 */ |
| 1667 /* saveRSMinfo:data2 */ | |
| 6 | 1668 assert((vm->state).domain == VTS_DOMAIN); /* ?? */ |
| 0 | 1669 /* Must be called before domain is changed */ |
| 6 | 1670 saveRSMinfo(vm,link_values.data2, /* We dont have block info */ 0); |
| 1671 (vm->state).domain = VTSM_DOMAIN; | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1672 if(set_MENU(vm,link_values.data1) == -1) |
| 0 | 1673 assert(0); |
| 6 | 1674 link_values = play_PGC(vm); |
| 0 | 1675 break; |
| 1676 case CallSS_VMGM_PGC: | |
| 9 | 1677 /* get_PGC:data1 */ |
| 1678 /* saveRSMinfo:data2 */ | |
| 6 | 1679 assert((vm->state).domain == VTS_DOMAIN); /* ?? */ |
| 0 | 1680 /* Must be called before domain is changed */ |
| 6 | 1681 saveRSMinfo(vm,link_values.data2, /* We dont have block info */ 0); |
| 1682 (vm->state).domain = VMGM_DOMAIN; | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1683 if(set_PGC(vm,link_values.data1) == -1) |
| 0 | 1684 assert(0); |
| 6 | 1685 link_values = play_PGC(vm); |
| 0 | 1686 break; |
| 1687 case PlayThis: | |
| 1688 /* Should never happen. */ | |
| 9 | 1689 assert(0); |
| 0 | 1690 break; |
| 1691 } | |
| 31 | 1692 |
| 1693 #ifdef TRACE | |
| 82 | 1694 fprintf(MSG_OUT, "libdvdnav: After printout starts:\n"); |
| 6 | 1695 vm_print_current_domain_state(vm); |
| 82 | 1696 fprintf(MSG_OUT, "libdvdnav: After printout ends.\n"); |
| 31 | 1697 #endif |
| 0 | 1698 |
| 1699 } | |
| 6 | 1700 vm->badness_counter--; |
| 0 | 1701 return link_values; |
| 1702 } | |
| 1703 | |
| 14 | 1704 /* Searches the TT tables, to find the current TT. |
| 1705 * returns the current TT. | |
| 1706 * returns 0 if not found. | |
| 1707 */ | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1708 static int get_TT(vm_t *vm, int vtsN, int vts_ttn) { |
| 14 | 1709 int i; |
| 1710 int tt=0; | |
| 1711 for(i = 1; i <= vm->vmgi->tt_srpt->nr_of_srpts; i++) { | |
| 1712 if( vm->vmgi->tt_srpt->title[i - 1].title_set_nr == vtsN && | |
| 1713 vm->vmgi->tt_srpt->title[i - 1].vts_ttn == vts_ttn) { | |
| 1714 tt=i; | |
| 1715 break; | |
| 1716 } | |
| 1717 } | |
| 1718 return tt; | |
| 1719 } | |
| 1720 | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1721 static int set_TT(vm_t *vm, int tt) |
| 0 | 1722 { |
| 6 | 1723 assert(tt <= vm->vmgi->tt_srpt->nr_of_srpts); |
| 0 | 1724 |
| 6 | 1725 (vm->state).TTN_REG = tt; |
| 0 | 1726 |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1727 return set_VTS_TT(vm, vm->vmgi->tt_srpt->title[tt - 1].title_set_nr, |
| 6 | 1728 vm->vmgi->tt_srpt->title[tt - 1].vts_ttn); |
| 0 | 1729 } |
| 1730 | |
| 1731 | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1732 static int set_VTS_TT(vm_t *vm, int vtsN, int vts_ttn) |
| 0 | 1733 { |
| 76 | 1734 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
|
1735 return set_VTS_PTT(vm, vtsN, vts_ttn, 1); |
| 42 | 1736 /* pgcN = get_ID(vm, vts_ttn); This might return -1 */ |
| 1737 /* | |
| 1738 assert(pgcN != -1); | |
| 0 | 1739 |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1740 (vm->state).TTN_REG = get_TT(*vm, vtsN, vts_ttn); |
| 42 | 1741 (vm->state).VTS_TTN_REG = vts_ttn; |
| 1742 (vm->state).vtsN = | |
| 1743 */ | |
| 0 | 1744 /* Any other registers? */ |
| 1745 | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1746 /* return set_PGC(vm, pgcN); */ |
| 0 | 1747 } |
| 1748 | |
| 1749 | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1750 static int set_VTS_PTT(vm_t *vm, int vtsN, int /* is this really */ vts_ttn, int part) |
| 0 | 1751 { |
| 52 | 1752 int pgcN, pgN, res; |
| 0 | 1753 |
| 6 | 1754 (vm->state).domain = VTS_DOMAIN; |
| 1755 if(vtsN != (vm->state).vtsN) | |
| 1756 ifoOpenNewVTSI(vm, vm->dvd, vtsN); /* Also sets (vm->state).vtsN */ | |
| 0 | 1757 |
| 90 | 1758 if ((vts_ttn < 1) || (vts_ttn > vm->vtsi->vts_ptt_srpt->nr_of_srpts) || |
| 1759 (part < 1) || (part > vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].nr_of_ptts) ) { | |
| 1760 return S_ERR; | |
| 1761 } | |
| 0 | 1762 |
| 6 | 1763 pgcN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgcn; |
| 1764 pgN = vm->vtsi->vts_ptt_srpt->title[vts_ttn - 1].ptt[part - 1].pgn; | |
| 14 | 1765 |
| 1766 (vm->state).TT_PGCN_REG = pgcN; | |
| 1767 (vm->state).PTTN_REG = pgN; | |
| 1768 | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1769 (vm->state).TTN_REG = get_TT(vm, vtsN, vts_ttn); |
| 14 | 1770 assert( (vm->state.TTN_REG) != 0 ); |
| 6 | 1771 (vm->state).VTS_TTN_REG = vts_ttn; |
| 14 | 1772 (vm->state).vtsN = vtsN; /* Not sure about this one. We can get to it easily from TTN_REG */ |
| 0 | 1773 /* Any other registers? */ |
| 1774 | |
|
106
e984044bbe7b
port Stephen's comment fixing to avoid problems when syncing xine-lib's copy of
mroi
parents:
101
diff
changeset
|
1775 res = set_PGC(vm, pgcN); /* This clobber's state.pgN (sets it to 1), but we don't want clobbering here. */ |
| 52 | 1776 (vm->state).pgN = pgN; /* Part?? */ |
| 1777 return res; | |
| 0 | 1778 } |
| 1779 | |
| 1780 | |
| 1781 | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1782 static int set_FP_PGC(vm_t *vm) |
| 0 | 1783 { |
| 6 | 1784 (vm->state).domain = FP_DOMAIN; |
| 0 | 1785 |
| 6 | 1786 (vm->state).pgc = vm->vmgi->first_play_pgc; |
| 0 | 1787 |
| 1788 return 0; | |
| 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_MENU(vm_t *vm, int menu) |
| 0 | 1793 { |
| 6 | 1794 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
|
1795 return set_PGC(vm, get_ID(vm, menu)); |
| 0 | 1796 } |
| 1797 | |
| 52 | 1798 /* Search for entry_id match of the PGC Category in the current VTS PGCIT table. |
| 1799 * Return pgcN based on entry_id match. | |
| 1800 */ | |
| 6 | 1801 static int get_ID(vm_t *vm, int id) |
| 0 | 1802 { |
| 1803 int pgcN, i; | |
| 1804 pgcit_t *pgcit; | |
| 1805 | |
| 1806 /* Relies on state to get the correct pgcit. */ | |
| 6 | 1807 pgcit = get_PGCIT(vm); |
| 0 | 1808 assert(pgcit != NULL); |
| 76 | 1809 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
|
1810 |
|
731834155645
Remove an assert() so that user initiated jumps to particlar menus does not seg fault if
jcdutton
parents:
76
diff
changeset
|
1811 /* 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
|
1812 id |=0x80; |
| 0 | 1813 /* Get menu/title */ |
| 1814 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
|
1815 if( (pgcit->pgci_srp[i].entry_id) == id) { |
| 0 | 1816 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
|
1817 fprintf(MSG_OUT, "libdvdnav: Found menu.\n"); |
| 0 | 1818 return pgcN; |
| 1819 } | |
| 1820 } | |
|
77
731834155645
Remove an assert() so that user initiated jumps to particlar menus does not seg fault if
jcdutton
parents:
76
diff
changeset
|
1821 fprintf(MSG_OUT, "libdvdnav: ** No such id/menu (0x%02x) entry PGC\n", id & 0x7f); |
| 54 | 1822 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
|
1823 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
|
1824 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
|
1825 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
|
1826 } |
| 54 | 1827 } |
| 0 | 1828 return -1; /* error */ |
| 1829 } | |
| 1830 | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1831 /* Set the vm->state to pgcN. |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1832 * Returns success/failure. |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1833 */ |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1834 static int set_PGC(vm_t *vm, int pgcN) |
| 0 | 1835 { |
| 1836 /* FIXME: Keep this up to date with the ogle people */ | |
| 1837 pgcit_t *pgcit; | |
| 1838 | |
| 6 | 1839 pgcit = get_PGCIT(vm); |
| 0 | 1840 |
| 1841 assert(pgcit != NULL); /* ?? Make this return -1 instead */ | |
| 1842 if(pgcN < 1 || pgcN > pgcit->nr_of_pgci_srp) { | |
| 76 | 1843 fprintf(MSG_OUT, "libdvdnav: ** No such pgcN = %d\n", pgcN); |
| 52 | 1844 return -1; /* error */ |
| 0 | 1845 } |
| 1846 | |
| 6 | 1847 /* (vm->state).pgcN = pgcN; */ |
| 1848 (vm->state).pgc = pgcit->pgci_srp[pgcN - 1].pgc; | |
| 52 | 1849 (vm->state).pgN = 1; |
| 1850 | |
| 6 | 1851 if((vm->state).domain == VTS_DOMAIN) |
| 1852 (vm->state).TT_PGCN_REG = pgcN; | |
| 0 | 1853 |
| 1854 return 0; | |
| 1855 } | |
| 1856 | |
| 6 | 1857 static int get_PGCN(vm_t *vm) |
| 0 | 1858 { |
| 1859 pgcit_t *pgcit; | |
| 1860 int pgcN = 1; | |
| 1861 | |
| 6 | 1862 pgcit = get_PGCIT(vm); |
| 0 | 1863 |
| 1864 assert(pgcit != NULL); | |
| 1865 | |
| 1866 while(pgcN <= pgcit->nr_of_pgci_srp) { | |
| 6 | 1867 if(pgcit->pgci_srp[pgcN - 1].pgc == (vm->state).pgc) |
| 0 | 1868 return pgcN; |
| 1869 pgcN++; | |
| 1870 } | |
| 76 | 1871 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
|
1872 (vm->state).domain); |
|
85
aa14e5673881
Add a bit more debug info. Now print PGCN in debug.
jcdutton
parents:
83
diff
changeset
|
1873 /* assert(0);*/ |
| 0 | 1874 return -1; /* error */ |
| 1875 } | |
| 1876 | |
|
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
1877 int vm_get_video_aspect(vm_t *vm) |
| 0 | 1878 { |
| 1879 int aspect = 0; | |
| 1880 | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1881 switch ((vm->state).domain) { |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1882 case VTS_DOMAIN: |
| 6 | 1883 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
|
1884 break; |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1885 case VTSM_DOMAIN: |
| 6 | 1886 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
|
1887 break; |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1888 case VMGM_DOMAIN: |
| 6 | 1889 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
|
1890 break; |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1891 default: |
| 76 | 1892 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
|
1893 (vm->state).domain); |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1894 assert(0); |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1895 break; |
| 0 | 1896 } |
| 31 | 1897 #ifdef TRACE |
| 76 | 1898 fprintf(MSG_OUT, "libdvdnav: get_video_aspect:aspect=%d\n",aspect); |
| 31 | 1899 #endif |
| 0 | 1900 assert(aspect == 0 || aspect == 3); |
| 6 | 1901 (vm->state).registers.SPRM[14] &= ~(0x3 << 10); |
| 1902 (vm->state).registers.SPRM[14] |= aspect << 10; | |
| 0 | 1903 |
| 1904 return aspect; | |
| 1905 } | |
| 1906 | |
|
55
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1907 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
|
1908 { |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1909 int permission = 0; |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1910 |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1911 if((vm->state).domain == VTS_DOMAIN) { |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1912 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
|
1913 } else if((vm->state).domain == VTSM_DOMAIN) { |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1914 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
|
1915 } else if((vm->state).domain == VMGM_DOMAIN) { |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1916 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
|
1917 } |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1918 #ifdef TRACE |
| 76 | 1919 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
|
1920 #endif |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1921 |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1922 return permission; |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1923 } |
|
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
1924 |
| 6 | 1925 static void ifoOpenNewVTSI(vm_t *vm, dvd_reader_t *dvd, int vtsN) |
| 0 | 1926 { |
| 6 | 1927 if((vm->state).vtsN == vtsN) { |
| 0 | 1928 return; /* We alread have it */ |
| 1929 } | |
| 1930 | |
| 6 | 1931 if(vm->vtsi != NULL) |
| 1932 ifoClose(vm->vtsi); | |
| 0 | 1933 |
| 6 | 1934 vm->vtsi = ifoOpenVTSI(dvd, vtsN); |
| 1935 if(vm->vtsi == NULL) { | |
| 76 | 1936 fprintf(MSG_OUT, "libdvdnav: ifoOpenVTSI failed - CRASHING!!!\n"); |
| 6 | 1937 assert(0); |
| 0 | 1938 } |
| 6 | 1939 if(!ifoRead_VTS_PTT_SRPT(vm->vtsi)) { |
| 76 | 1940 fprintf(MSG_OUT, "libdvdnav: ifoRead_VTS_PTT_SRPT failed - CRASHING!!!\n"); |
| 6 | 1941 assert(0); |
| 0 | 1942 } |
| 6 | 1943 if(!ifoRead_PGCIT(vm->vtsi)) { |
| 76 | 1944 fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCIT failed - CRASHING!!!\n"); |
| 6 | 1945 assert(0); |
| 0 | 1946 } |
| 6 | 1947 if(!ifoRead_PGCI_UT(vm->vtsi)) { |
| 76 | 1948 fprintf(MSG_OUT, "libdvdnav: ifoRead_PGCI_UT failed - CRASHING!!!\n"); |
| 6 | 1949 assert(0); |
| 0 | 1950 } |
| 6 | 1951 if(!ifoRead_VOBU_ADMAP(vm->vtsi)) { |
| 76 | 1952 fprintf(MSG_OUT, "libdvdnav: ifoRead_VOBU_ADMAP vtsi failed - CRASHING\n"); |
| 6 | 1953 assert(0); |
| 0 | 1954 } |
| 6 | 1955 if(!ifoRead_TITLE_VOBU_ADMAP(vm->vtsi)) { |
| 76 | 1956 fprintf(MSG_OUT, "libdvdnav: ifoRead_TITLE_VOBU_ADMAP vtsi failed - CRASHING\n"); |
| 6 | 1957 assert(0); |
| 0 | 1958 } |
| 6 | 1959 (vm->state).vtsN = vtsN; |
| 0 | 1960 } |
| 1961 | |
| 6 | 1962 static pgcit_t* get_MENU_PGCIT(vm_t *vm, ifo_handle_t *h, uint16_t lang) |
| 0 | 1963 { |
| 1964 int i; | |
| 1965 | |
| 1966 if(h == NULL || h->pgci_ut == NULL) { | |
| 76 | 1967 fprintf(MSG_OUT, "libdvdnav: *** pgci_ut handle is NULL ***\n"); |
| 0 | 1968 return NULL; /* error? */ |
| 1969 } | |
| 1970 | |
| 1971 i = 0; | |
| 1972 while(i < h->pgci_ut->nr_of_lus | |
| 1973 && h->pgci_ut->lu[i].lang_code != lang) | |
| 1974 i++; | |
| 1975 if(i == h->pgci_ut->nr_of_lus) { | |
| 76 | 1976 fprintf(MSG_OUT, "libdvdnav: Language '%c%c' not found, using '%c%c' instead\n", |
| 0 | 1977 (char)(lang >> 8), (char)(lang & 0xff), |
| 1978 (char)(h->pgci_ut->lu[0].lang_code >> 8), | |
| 1979 (char)(h->pgci_ut->lu[0].lang_code & 0xff)); | |
| 76 | 1980 fprintf(MSG_OUT, "libdvdnav: Menu Languages available: "); |
| 53 | 1981 for(i=0;i< h->pgci_ut->nr_of_lus;i++) { |
| 76 | 1982 fprintf(MSG_OUT, "%c%c ", |
| 53 | 1983 (char)(h->pgci_ut->lu[0].lang_code >> 8), |
| 1984 (char)(h->pgci_ut->lu[0].lang_code & 0xff)); | |
| 1985 } | |
| 76 | 1986 fprintf(MSG_OUT, "\n"); |
| 53 | 1987 |
| 0 | 1988 i = 0; /* error? */ |
| 1989 } | |
| 1990 | |
| 1991 return h->pgci_ut->lu[i].pgcit; | |
| 1992 } | |
| 1993 | |
| 1994 /* Uses state to decide what to return */ | |
| 6 | 1995 static pgcit_t* get_PGCIT(vm_t *vm) { |
| 0 | 1996 pgcit_t *pgcit; |
| 1997 | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1998 switch ((vm->state).domain) { |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
1999 case VTS_DOMAIN: |
| 6 | 2000 pgcit = vm->vtsi->vts_pgcit; |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
2001 break; |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
2002 case VTSM_DOMAIN: |
| 6 | 2003 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
|
2004 break; |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
2005 case VMGM_DOMAIN: |
|
85
aa14e5673881
Add a bit more debug info. Now print PGCN in debug.
jcdutton
parents:
83
diff
changeset
|
2006 case FP_DOMAIN: |
| 6 | 2007 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
|
2008 break; |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
2009 default: |
| 0 | 2010 pgcit = NULL; /* Should never hapen */ |
| 76 | 2011 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
|
2012 (vm->state).domain); |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
2013 assert(0); |
|
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
2014 break; |
| 0 | 2015 } |
| 2016 | |
| 2017 return pgcit; | |
| 2018 } | |
| 2019 | |
| 2020 /* | |
| 2021 * $Log$ | |
|
109
f41eae322bd1
warning: ugly fix ahead! (see comment in the code for details)
mroi
parents:
106
diff
changeset
|
2022 * 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
|
2023 * 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
|
2024 * 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
|
2025 * 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
|
2026 * 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
|
2027 * |
|
106
e984044bbe7b
port Stephen's comment fixing to avoid problems when syncing xine-lib's copy of
mroi
parents:
101
diff
changeset
|
2028 * 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
|
2029 * 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
|
2030 * libdvdnav |
|
e984044bbe7b
port Stephen's comment fixing to avoid problems when syncing xine-lib's copy of
mroi
parents:
101
diff
changeset
|
2031 * |
| 101 | 2032 * Revision 1.36 2002/09/22 11:53:32 mroi |
| 2033 * small output beautification | |
| 2034 * | |
|
97
c1dff1899bda
First patch for personalized dvd viewing. I have not tested it yet.
jcdutton
parents:
90
diff
changeset
|
2035 * 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
|
2036 * 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
|
2037 * |
| 90 | 2038 * Revision 1.34 2002/09/03 07:50:45 jcdutton |
| 2039 * Improve chapter selection functions. | |
| 2040 * | |
| 88 | 2041 * Revision 1.33 2002/09/02 03:20:01 jcdutton |
| 2042 * Implement proper prev/next chapter/part. | |
| 2043 * I don't know why someone has not noticed the problem until now. | |
| 2044 * | |
| 87 | 2045 * Revision 1.32 2002/09/02 00:27:14 jcdutton |
| 2046 * Fix bug in JumpVTS_PTT command. | |
| 2047 * | |
|
85
aa14e5673881
Add a bit more debug info. Now print PGCN in debug.
jcdutton
parents:
83
diff
changeset
|
2048 * 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
|
2049 * 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
|
2050 * |
| 83 | 2051 * Revision 1.30 2002/08/31 10:51:01 jcdutton |
| 2052 * Handle badly written DVDs better. | |
| 2053 * If a Cell has a Cell command pointer, but the PGC Cell command list does not have an | |
| 2054 * entry for it, assume that the cell has no cell commands and continue instead of | |
| 2055 * assert(). | |
| 2056 * | |
| 82 | 2057 * Revision 1.29 2002/08/31 02:50:27 jcdutton |
| 2058 * Improve some debug messages. | |
| 2059 * Add some comments about dvdnav_open memory leaks. | |
| 2060 * | |
| 80 | 2061 * Revision 1.28 2002/08/29 05:33:54 jcdutton |
| 2062 * Slight changes to help debugging. | |
| 2063 * | |
|
77
731834155645
Remove an assert() so that user initiated jumps to particlar menus does not seg fault if
jcdutton
parents:
76
diff
changeset
|
2064 * 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
|
2065 * 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
|
2066 * 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
|
2067 * |
| 76 | 2068 * Revision 1.26 2002/08/27 19:15:08 mroi |
| 2069 * more consistent console output | |
| 2070 * | |
| 75 | 2071 * Revision 1.25 2002/08/21 15:25:50 mroi |
| 2072 * fix playback of the following dvds | |
| 2073 * - Bram Stoker's Dracula RC2 | |
| 2074 * - The Cell RC2, German FSK16 | |
| 2075 * | |
|
55
5674fbd44f26
report all spu types (widescreen, letterbox and pan&scan), not widescreen
mroi
parents:
54
diff
changeset
|
2076 * 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
|
2077 * 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
|
2078 * 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
|
2079 * |
| 54 | 2080 * Revision 1.23 2002/07/05 01:42:30 jcdutton |
| 2081 * Add more debug info for Menu language selection. | |
| 2082 * Only do vm_start when we have to. | |
| 2083 * | |
| 53 | 2084 * Revision 1.22 2002/07/04 00:38:51 jcdutton |
| 2085 * Add some menu language printf's. | |
| 2086 * | |
| 52 | 2087 * Revision 1.21 2002/07/03 02:41:31 jcdutton |
| 2088 * Fix another long standing bug. | |
| 2089 * Now changing PGC will force a start at the first PG of the PGC. | |
| 2090 * | |
|
50
578ce1d41479
Rename some of the functions in vm.c to help readability.
jcdutton
parents:
42
diff
changeset
|
2091 * 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
|
2092 * 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
|
2093 * 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
|
2094 * 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
|
2095 * |
| 42 | 2096 * Revision 1.19 2002/06/04 13:35:16 richwareham |
| 2097 * Removed more C++ style comments | |
| 2098 * | |
| 38 | 2099 * Revision 1.18 2002/05/30 19:25:08 richwareham |
| 2100 * Another small fix | |
| 2101 * | |
|
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
|
2102 * 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
|
2103 * 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
|
2104 * |
| 31 | 2105 * Revision 1.16 2002/04/24 21:15:25 jcdutton |
| 2106 * Quiet please!!! | |
| 2107 * | |
|
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
|
2108 * 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
|
2109 * 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
|
2110 * |
|
25
df024077cbc1
Why rewrite vm function, use it instead (this remark is for me, of course ;-) ).
f1rmb
parents:
24
diff
changeset
|
2111 * 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
|
2112 * 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
|
2113 * 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
|
2114 * |
| 24 | 2115 * Revision 1.13 2002/04/23 02:12:27 jcdutton |
| 2116 * Re-implemented seeking. | |
| 2117 * | |
|
22
3c1df0cb3aee
Start of rewrite of libdvdnav. Still need to re-implement seeking.
jcdutton
parents:
19
diff
changeset
|
2118 * 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
|
2119 * 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
|
2120 * |
|
19
7e8628911b4f
Implement General Register Counters or GPRM counters.
jcdutton
parents:
18
diff
changeset
|
2121 * Revision 1.11 2002/04/12 20:06:41 jcdutton |
|
7e8628911b4f
Implement General Register Counters or GPRM counters.
jcdutton
parents:
18
diff
changeset
|
2122 * Implement General Register Counters or GPRM counters. |
|
7e8628911b4f
Implement General Register Counters or GPRM counters.
jcdutton
parents:
18
diff
changeset
|
2123 * Navigation timers are not supported yet. SPRM[9] and SPRM[10]. |
|
7e8628911b4f
Implement General Register Counters or GPRM counters.
jcdutton
parents:
18
diff
changeset
|
2124 * |
| 18 | 2125 * Revision 1.10 2002/04/12 12:43:36 jcdutton |
| 2126 * Display DVD disk region setting. | |
| 2127 * Display possible RCE region protection message. | |
| 2128 * | |
| 17 | 2129 * Revision 1.9 2002/04/10 16:45:57 jcdutton |
| 2130 * Actually fix the const this time! | |
| 2131 * | |
| 16 | 2132 * Revision 1.8 2002/04/10 16:40:52 jcdutton |
| 2133 * Fix a const problem. | |
| 2134 * | |
| 14 | 2135 * Revision 1.7 2002/04/10 13:09:40 jcdutton |
| 2136 * Some improvements to decoder.c | |
| 2137 * Registers should be updated correctly now, but still needs checking. | |
| 2138 * | |
|
10
6f0fb88d1463
Added some debug info, to hopefully help in tracking bugs in libdvdnav.
jcdutton
parents:
9
diff
changeset
|
2139 * 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
|
2140 * 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
|
2141 * |
| 9 | 2142 * Revision 1.5 2002/04/07 19:35:54 jcdutton |
| 2143 * Added some comments into the code. | |
| 2144 * | |
| 6 | 2145 * Revision 1.4 2002/04/06 18:31:50 jcdutton |
| 2146 * Some cleaning up. | |
| 2147 * changed exit(1) to assert(0) so they actually get seen by the user so that it helps developers more. | |
| 2148 * | |
|
4
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
2149 * 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
|
2150 * Added reset patch from Kees Cook <kees@outflux.net> |
|
99bed5d6db2f
Added reset patch from Kees Cook <kees@outflux.net>
richwareham
parents:
3
diff
changeset
|
2151 * |
|
3
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
2152 * 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
|
2153 * 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
|
2154 * |
|
328eadb3f37e
Added initial example programs directory and make sure all debug/error output goes to stderr.
richwareham
parents:
0
diff
changeset
|
2155 * 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
|
2156 * Initial import |
| 0 | 2157 * |
| 2158 * Revision 1.18 2002/01/22 16:56:49 jcdutton | |
| 2159 * Fix clut after seeking. | |
| 6 | 2160 * 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 | 2161 * Fix a few debug messages, so they do not say FIXME. |
| 2162 * Move the FIXME debug messages to comments in the code. | |
| 2163 * | |
| 2164 * Revision 1.17 2002/01/21 01:16:30 jcdutton | |
| 2165 * Added some debug messages, to hopefully get info from users. | |
| 2166 * | |
| 2167 * Revision 1.16 2002/01/20 21:40:46 jcdutton | |
| 2168 * Start to fix some assert failures. | |
| 2169 * | |
| 2170 * Revision 1.15 2002/01/19 20:24:38 jcdutton | |
| 2171 * Just some FIXME notes added. | |
| 2172 * | |
| 2173 * Revision 1.14 2002/01/13 22:17:57 jcdutton | |
| 2174 * Change logging. | |
| 2175 * | |
| 2176 * | |
| 2177 */ |
