[DVDnav-discuss] bounties for a couple items

gnosygnu gnosygnu at gmail.com
Tue Mar 25 05:14:34 CET 2014


Hi Roger.

I spent some time on (1) tonight. I've attached an untested patch that
may handle it. I would test it on my side, but I really can't think of
a simple way to do it. If I recall correctly, you have some scriptable
way to jump forward in small increments through a title.

If you can try it, I'll work with you off-list to iron out any issues.
Once you feel confident that it works, I'll commit my patch to the
repo. The patch is straightforward, fairly small, and has a good deal
of comments.

I think (2) is a different matter entirely. I've not encountered read
errors (my DVDs are burned to the hard drive), so it would be hard for
me to test. In addition, I don't know of an easy way to hook up the
jump_to_sector to the error handler. I'd imagine this would involve
significant plugging into libdvdread, which could be quite an effort.
I'd have to defer that to someone else.

Hope this helps.


On Mon, Mar 24, 2014 at 1:13 PM, Roger Pack <rogerdpack2 at gmail.com> wrote:
> Hello.
> If anybody's interested in the following tasks for a "bounty" let me know:
>
> 1) finish up the dvdnav_jump_to_sector_by_time which includes a
> parameter for whether it should "always jump forward" from a given
> time versus the default is to end up "randomly".  So implement the
> "always jump forward" part of it, currently unimplemented.
>
> 2) add some parameter/option that is like "on read error detected,
> jump forward X seconds" (possibly by leveraging the
> dvdnav_jump_to_sector_by_time  method?)
>
> Thank you.
> -roger-
> _______________________________________________
> DVDnav-discuss mailing list
> DVDnav-discuss at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/dvdnav-discuss
-------------- next part --------------
diff --git a/src/searching.c b/src/searching.c
index d0a2f80..ac2912d 100644
--- a/src/searching.c
+++ b/src/searching.c
@@ -1012,7 +1012,7 @@ static int32_t dvdnav_cell_find(dvdnav_t *this, dvd_state_t *state,
 /* Given two sectors and a fraction, calc the corresponding vobu */
 static int32_t dvdnav_admap_interpolate_vobu(dvdnav_jump_args_t *args,
             dvdnav_pos_data_t *bgn, dvdnav_pos_data_t *end, uint32_t fraction,
-            uint32_t *jump_sector) {
+            dvdnav_pos_data_t *jump) {
   int32_t result = 0;
   uint32_t vobu_len = 0;
   uint32_t vobu_adj = 0;
@@ -1044,7 +1044,8 @@ static int32_t dvdnav_admap_interpolate_vobu(dvdnav_jump_args_t *args,
     fprintf(MSG_OUT, "admap_interpolate: vobu_idx >= admap_len");
     return 0;
   }
-  *jump_sector = args->admap->vobu_start_sectors[vobu_idx];
+  jump->vobu_idx = vobu_idx;
+  jump->sector = args->admap->vobu_start_sectors[vobu_idx];
   return 1;
 }
 
@@ -1199,7 +1200,7 @@ static int32_t dvdnav_find_vobu_by_tmap(dvdnav_t *this, dvd_state_t *state,
 
   /* interpolate sector */
   result = dvdnav_admap_interpolate_vobu(args, jump_lo, jump_hi,
-      seek_pct, &jump->sector);
+      seek_pct, jump);
 
   return result;
 }
@@ -1233,7 +1234,7 @@ static int32_t dvdnav_find_vobu_by_cell_boundaries(dvdnav_t *this,
    * start of a VOBU is needed in order to index into admap */
   cell_data->end->sector += 1;
   result = dvdnav_admap_interpolate_vobu(args,
-      cell_data->bgn, cell_data->end, jump_pct, &jump->sector);
+      cell_data->bgn, cell_data->end, jump_pct, jump);
   if (!result) {
     fprintf(MSG_OUT, "find_by_admap.interpolate");
     return 0;
@@ -1287,7 +1288,32 @@ dvdnav_status_t dvdnav_jump_to_sector_by_time(dvdnav_t *this,
   }
 
   /* jump to sector */
-  sector_off = jump->sector - cell_data->bgn->sector;
+  uint32_t jump_sector = jump->sector;
+  if (mode != JUMP_MODE_TIME_DEFAULT) { /* mode specified */
+    /* get current playing sector */
+    uint32_t cur_sector = this->vobu.vobu_start + this->vobu.blockN;
+    /* get vobu_idx of jump */
+    uint32_t vobu_idx = jump->vobu_idx;
+    while (1) { /* loop */
+      int32_t vobu_adj = 0;
+      if      (   mode == JUMP_MODE_TIME_AFTER   /* mode is jump > cur       */
+               && jump_sector < cur_sector       /* however jump < cur       */
+               && vobu_idx < args->admap_len     /* and vobu is not last     */
+               ) {
+                 vobu_adj = 1;                   /* add 1 to vobu_idx        */
+      }
+      else if (  mode == JUMP_MODE_TIME_BEFORE   /* mode is jump < cur       */
+              && jump_sector > cur_sector        /* however jump > cur       */
+              && vobu_idx > 0                    /* and vobu is not first    */
+              ) {
+                 vobu_adj = -1;                  /* subtract 1 from vobu_idx */
+      }
+      if (vobu_adj == 0) break; /* no adjustment; stop; */
+      vobu_idx += vobu_adj;
+      jump_sector = args->admap->vobu_start_sectors[vobu_idx];
+    }
+  }
+  sector_off = jump_sector - cell_data->bgn->sector;
   this->cur_cell_time = 0;
   if (vm_jump_cell_block(this->vm, cell_data->idx, sector_off)) {
     pthread_mutex_lock(&this->vm_lock);
@@ -1299,4 +1325,3 @@ dvdnav_status_t dvdnav_jump_to_sector_by_time(dvdnav_t *this,
 exit:
   return result;
 }
-


More information about the DVDnav-discuss mailing list