~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to libdvdnav/searching.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-01-12 22:23:28 UTC
  • mfrom: (0.4.7 sid)
  • mto: This revision was merged to the branch mainline in revision 76.
  • Revision ID: package-import@ubuntu.com-20120112222328-8jqdyodym3p84ygu
Tags: 2:1.0~rc4.dfsg1+svn34540-1
* New upstream snapshot
* upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
/* Return placed in vobu. */
48
48
/* Returns error status */
49
49
/* FIXME: Maybe need to handle seeking outside current cell. */
50
 
static dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, uint32_t seekto_block, uint32_t *vobu) {
 
50
static dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, uint32_t seekto_block, int next, uint32_t *vobu) {
51
51
  vobu_admap_t *admap = NULL;
52
52
 
53
53
#ifdef LOG_DEBUG
89
89
      vobu_start = next_vobu;
90
90
      address++;
91
91
    }
92
 
    *vobu = vobu_start;
 
92
    *vobu = next ? next_vobu : vobu_start;
93
93
    return DVDNAV_STATUS_OK;
94
94
  }
95
95
  fprintf(MSG_OUT, "libdvdnav: admap not located\n");
160
160
    fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n",
161
161
            cell_nr, first_cell_nr, last_cell_nr);
162
162
#endif
163
 
    if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) {
 
163
    if (dvdnav_scan_admap(this, state->domain, target, 0, &vobu) == DVDNAV_STATUS_OK) {
164
164
      uint32_t start = state->pgc->cell_playback[cell_nr-1].first_sector;
165
165
 
166
166
      if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) {
184
184
dvdnav_status_t dvdnav_sector_search(dvdnav_t *this,
185
185
                                     uint64_t offset, int32_t origin) {
186
186
  uint32_t target = 0;
 
187
  uint32_t current_pos;
 
188
  uint32_t cur_sector;
 
189
  uint32_t cur_cell_nr;
187
190
  uint32_t length = 0;
188
191
  uint32_t first_cell_nr, last_cell_nr, cell_nr;
189
192
  int32_t found;
 
193
  int forward = 0;
190
194
  cell_playback_t *cell;
191
195
  dvd_state_t *state;
192
196
  dvdnav_status_t result;
213
217
  fprintf(MSG_OUT, "libdvdnav: Before cellN=%u blockN=%u\n", state->cellN, state->blockN);
214
218
#endif
215
219
 
 
220
  current_pos = target;
 
221
  cur_sector = this->vobu.vobu_start + this->vobu.blockN;
 
222
  cur_cell_nr = state->cellN;
 
223
 
216
224
  switch(origin) {
217
225
   case SEEK_SET:
218
226
    if(offset >= length) {
244
252
    pthread_mutex_unlock(&this->vm_lock);
245
253
    return DVDNAV_STATUS_ERR;
246
254
  }
 
255
  forward = target > current_pos;
247
256
 
248
257
  this->cur_cell_time = 0;
249
258
  if (this->pgc_based) {
270
279
    } else {
271
280
      /* convert the target sector from Cell-relative to absolute physical sector */
272
281
      target += cell->first_sector;
 
282
      if (forward && (cell_nr == cur_cell_nr)) {
 
283
        uint32_t vobu;
 
284
        /* if we are seeking forward from the current position, make sure
 
285
         * we move to a new position that is after our current position.
 
286
         * simply truncating to the vobu will go backwards */
 
287
        if (dvdnav_scan_admap(this, state->domain, target, 0, &vobu) != DVDNAV_STATUS_OK)
 
288
          break;
 
289
        if (vobu <= cur_sector) {
 
290
          if (dvdnav_scan_admap(this, state->domain, target, 1, &vobu) != DVDNAV_STATUS_OK)
 
291
            break;
 
292
          if (vobu > cell->last_sector) {
 
293
            if (cell_nr == last_cell_nr)
 
294
              break;
 
295
            cell_nr++;
 
296
            cell =  &(state->pgc->cell_playback[cell_nr-1]);
 
297
            target = cell->first_sector;
 
298
          } else {
 
299
            target = vobu;
 
300
          }
 
301
        }
 
302
      }
273
303
      found = 1;
274
304
      break;
275
305
    }
281
311
    fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n",
282
312
            cell_nr, first_cell_nr, last_cell_nr);
283
313
#endif
284
 
    if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) {
 
314
    if (dvdnav_scan_admap(this, state->domain, target, 0, &vobu) == DVDNAV_STATUS_OK) {
285
315
      int32_t start = state->pgc->cell_playback[cell_nr-1].first_sector;
286
316
 
287
317
      if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) {