comparison searching.c @ 24:870a0a1eee41 src

Re-implemented seeking.
author jcdutton
date Tue, 23 Apr 2002 02:12:58 +0000
parents 3c1df0cb3aee
children df024077cbc1
comparison
equal deleted inserted replaced
23:c2d40c38e12f 24:870a0a1eee41
37 unsigned long int time) { 37 unsigned long int time) {
38 /* Time search the current PGC based on the xxx table */ 38 /* Time search the current PGC based on the xxx table */
39 return S_OK; 39 return S_OK;
40 } 40 }
41 41
42 /* Scan the ADMAP for a particular block number. */
43 /* Return placed in vobu. */
44 /* Returns error status */
45
46 dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, int32_t seekto_block, int32_t *vobu) {
47 /* FIXME:Need to handle seeking outside current cell. */
48 vobu_admap_t *admap = NULL;
49 *vobu = -1;
50 fprintf(stderr,"Seeking to target %u ...\n",
51 seekto_block);
52
53 /* Search through the VOBU_ADMAP for the nearest VOBU
54 * to the target block */
55 switch(domain) {
56 case FP_DOMAIN:
57 case VMGM_DOMAIN:
58 admap = this->vm->vmgi->menu_vobu_admap;
59 break;
60 case VTSM_DOMAIN:
61 admap = this->vm->vtsi->menu_vobu_admap;
62 break;
63 case VTS_DOMAIN:
64 admap = this->vm->vtsi->vts_vobu_admap;
65 break;
66 default:
67 fprintf(stderr,"Error: Unknown domain for seeking seek.\n");
68 }
69 if(admap) {
70 int32_t address = 0;
71 int32_t vobu_start, next_vobu;
72 int found = 0;
73
74 /* Search through ADMAP for best sector */
75 vobu_start = 0x3fffffff;
76 /* FIXME: Implement a faster search algorithm */
77 while((!found) && ((address<<2) < admap->last_byte)) {
78 next_vobu = admap->vobu_start_sectors[address];
79
80 /* printf("Found block %u\n", next_vobu); */
81
82 if(vobu_start <= seekto_block &&
83 next_vobu > seekto_block) {
84 found = 1;
85 } else {
86 vobu_start = next_vobu;
87 }
88
89 address ++;
90 }
91 if(found) {
92 *vobu = vobu_start;
93 return S_OK;
94 } else {
95 fprintf(stderr,"Could not locate block\n");
96 return S_ERR;
97 }
98 }
99 fprintf(stderr,"admap not located\n");
100 return S_ERR;
101 }
102
42 dvdnav_status_t dvdnav_sector_search(dvdnav_t *this, 103 dvdnav_status_t dvdnav_sector_search(dvdnav_t *this,
43 unsigned long int offset, int origin) { 104 unsigned long int offset, int origin) {
44 /* FIXME: Implement */ 105 /* FIXME: Implement */
45 106
46 uint32_t target = 0; 107 uint32_t target = 0;
123 fnd_cell = cell; 184 fnd_cell = cell;
124 } 185 }
125 } 186 }
126 187
127 if(fnd_cell_nr <= last_cell_nr) { 188 if(fnd_cell_nr <= last_cell_nr) {
189 int32_t vobu, start, blockN;
190 dvdnav_status_t status;
128 fprintf(stderr,"Seeking to cell %i from choice of %i to %i\n", 191 fprintf(stderr,"Seeking to cell %i from choice of %i to %i\n",
129 fnd_cell_nr, first_cell_nr, last_cell_nr); 192 fnd_cell_nr, first_cell_nr, last_cell_nr);
130 this->seekto_block = target; 193 status = dvdnav_scan_admap(this, state->domain, target, &vobu);
131 this->seeking = 1;
132 /* 194 /*
133 * Clut does not actually change, 195 * Clut does not actually change,
134 * but as the decoders have been closed then opened, 196 * but as the decoders have been closed then opened,
135 * A new clut has to be sent. 197 * A new clut has to be sent.
136 */ 198 */
137 this->spu_clut_changed = 1; 199 start =(state->pgc->cell_playback[state->cellN - 1].first_sector);
138 //ogle_do_post_jump(ogle); 200 fprintf(stderr,"FIXME: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" ,
139 fprintf(stderr,"FIXME: After cellN=%u blockN=%u\n" ,
140 state->cellN, 201 state->cellN,
202 state->blockN,
203 target,
204 vobu,
205 start);
206 state->blockN = vobu - start;
207 fprintf(stderr,"FIXME: After vobu=%x start=%x blockN=%x\n" ,
208 vobu,
209 start,
141 state->blockN); 210 state->blockN);
142
143 pthread_mutex_unlock(&this->vm_lock); 211 pthread_mutex_unlock(&this->vm_lock);
144 return target; 212 return target;
145 } else { 213 } else {
146 fprintf(stderr, "Error when seeking, asked to seek outside program\n"); 214 fprintf(stderr, "Error when seeking, asked to seek outside program\n");
147 } 215 }
148 216
149
150
151 fprintf(stderr,"FIXME: Implement seeking to location %u\n", target); 217 fprintf(stderr,"FIXME: Implement seeking to location %u\n", target);
152
153 // this->seekto_block=target;
154 // this->seeking = 1;
155 218
156 pthread_mutex_unlock(&this->vm_lock); 219 pthread_mutex_unlock(&this->vm_lock);
157 return -1; 220 return -1;
158 } 221 }
159 222