OSDN Git Service

aa4d37654297142ad76f14de44e898bb754d6a8c
[handbrake-jp/handbrake-jp-git.git] / contrib / libdvdnav / A05-forward-seek.patch
1 diff -Naur libdvdnav.orig/src/searching.c libdvdnav/src/searching.c
2 --- libdvdnav.orig/src/searching.c      2009-01-08 14:57:11.000000000 -0800
3 +++ libdvdnav/src/searching.c   2009-09-12 12:35:12.483551884 -0700
4 @@ -47,7 +47,7 @@
5  /* Return placed in vobu. */
6  /* Returns error status */
7  /* FIXME: Maybe need to handle seeking outside current cell. */
8 -static dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, uint32_t seekto_block, uint32_t *vobu) {
9 +static dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, uint32_t seekto_block, uint8_t next, uint32_t *vobu) {
10    vobu_admap_t *admap = NULL;
11  
12  #ifdef LOG_DEBUG
13 @@ -89,7 +89,10 @@
14        vobu_start = next_vobu;
15        address++;
16      }
17 -    *vobu = vobu_start;
18 +    if(next)
19 +      *vobu = next_vobu;
20 +    else
21 +      *vobu = vobu_start;
22      return DVDNAV_STATUS_OK;
23    }
24    fprintf(MSG_OUT, "libdvdnav: admap not located\n");
25 @@ -160,7 +163,7 @@
26      fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n",
27             cell_nr, first_cell_nr, last_cell_nr);
28  #endif
29 -    if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) {
30 +    if (dvdnav_scan_admap(this, state->domain, target, 0, &vobu) == DVDNAV_STATUS_OK) {
31        uint32_t start = state->pgc->cell_playback[cell_nr-1].first_sector;
32  
33        if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) {
34 @@ -270,6 +273,27 @@
35      } else {
36        /* convert the target sector from Cell-relative to absolute physical sector */
37        target += cell->first_sector;
38 +      if (origin == SEEK_CUR && offset > 0) {
39 +        uint32_t vobu;
40 +        /* if we are seeking forward from the current position, make sure
41 +         * we move to a new position that is after our current position.
42 +         * simply truncating to the vobu will go backwards */
43 +        if (dvdnav_scan_admap(this, state->domain, target, 1, &vobu) == DVDNAV_STATUS_OK) {
44 +          if (vobu > cell->last_sector) {
45 +            if (cell_nr == last_cell_nr) {
46 +              break;
47 +            } else {
48 +                cell_nr++;
49 +                cell =  &(state->pgc->cell_playback[cell_nr-1]);
50 +                target = cell->first_sector;
51 +            }
52 +          } else {
53 +            target = vobu;
54 +          }
55 +        } else {
56 +          break;
57 +        }
58 +      }
59        found = 1;
60        break;
61      }
62 @@ -281,7 +305,7 @@
63      fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n",
64             cell_nr, first_cell_nr, last_cell_nr);
65  #endif
66 -    if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) {
67 +    if (dvdnav_scan_admap(this, state->domain, target, 0, &vobu) == DVDNAV_STATUS_OK) {
68        int32_t start = state->pgc->cell_playback[cell_nr-1].first_sector;
69  
70        if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) {