changeset 24:870a0a1eee41 src

Re-implemented seeking.
author jcdutton
date Tue, 23 Apr 2002 02:12:58 +0000
parents c2d40c38e12f
children df024077cbc1
files dvdnav.c searching.c vm.c
diffstat 3 files changed, 97 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/dvdnav.c	Tue Apr 23 00:07:16 2002 +0000
+++ b/dvdnav.c	Tue Apr 23 02:12:58 2002 +0000
@@ -752,10 +752,12 @@
   }
   /* FIXME: Don't really need "cell", we only need vobu_start */
   if( (this->position_current.cell != this->position_next.cell) ||
-      (this->position_current.vobu_start != this->position_next.vobu_start) ) {
+      (this->position_current.vobu_start != this->position_next.vobu_start) ||
+      (this->position_current.vobu_next != this->position_next.vobu_next) ) {
     this->position_current.cell = this->position_next.cell;
     /* vobu_start changes when PGC or PG changes. */
     this->position_current.vobu_start = this->position_next.vobu_start;
+    this->position_current.vobu_next = this->position_next.vobu_next;
     /* FIXME: Need to set vobu_start, vobu_next */
     this->vobu.vobu_start = this->position_next.vobu_start; 
     /* vobu_next is use for mid cell resumes */
@@ -790,6 +792,7 @@
         this->skip_still = 0;
         this->position_current.cell = this->position_next.cell;
         this->position_current.vobu_start = this->position_next.vobu_start;
+        this->position_current.vobu_next = this->position_next.vobu_next;
         this->vobu.vobu_start = this->position_next.vobu_start; 
         /* vobu_next is use for mid cell resumes */
         this->vobu.vobu_next = this->position_next.vobu_next; 
@@ -1009,6 +1012,9 @@
 
 /*
  * $Log$
+ * Revision 1.11  2002/04/23 02:12:27  jcdutton
+ * Re-implemented seeking.
+ *
  * Revision 1.10  2002/04/23 00:07:16  jcdutton
  * Name stills work better.
  *
--- a/searching.c	Tue Apr 23 00:07:16 2002 +0000
+++ b/searching.c	Tue Apr 23 02:12:58 2002 +0000
@@ -39,6 +39,67 @@
   return S_OK;
 }
 
+/* Scan the ADMAP for a particular block number. */
+/* Return placed in vobu. */
+/* Returns error status */
+
+dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, int32_t seekto_block, int32_t *vobu) {
+  /* FIXME:Need to handle seeking outside current cell. */
+  vobu_admap_t *admap = NULL;
+  *vobu = -1;
+  fprintf(stderr,"Seeking to target %u ...\n",
+              seekto_block);
+
+  /* Search through the VOBU_ADMAP for the nearest VOBU
+   * to the target block */
+  switch(domain) {
+    case FP_DOMAIN:
+    case VMGM_DOMAIN:
+      admap = this->vm->vmgi->menu_vobu_admap;
+      break;
+    case VTSM_DOMAIN:
+      admap = this->vm->vtsi->menu_vobu_admap;
+      break;
+    case VTS_DOMAIN:
+      admap = this->vm->vtsi->vts_vobu_admap;
+      break;
+    default:
+      fprintf(stderr,"Error: Unknown domain for seeking seek.\n");
+  }
+  if(admap) {
+    int32_t address = 0;
+    int32_t vobu_start, next_vobu;
+    int found = 0;
+
+    /* Search through ADMAP for best sector */
+    vobu_start = 0x3fffffff;
+    /* FIXME: Implement a faster search algorithm */
+    while((!found) && ((address<<2) < admap->last_byte)) {
+      next_vobu = admap->vobu_start_sectors[address];
+
+      /* printf("Found block %u\n", next_vobu); */
+
+      if(vobu_start <= seekto_block &&
+          next_vobu > seekto_block) {
+        found = 1;
+      } else {
+        vobu_start = next_vobu;
+      }
+
+      address ++;
+    }
+    if(found) {
+      *vobu = vobu_start;
+      return S_OK;
+    } else {
+      fprintf(stderr,"Could not locate block\n");
+      return S_ERR;
+    }
+  }
+  fprintf(stderr,"admap not located\n");
+  return S_ERR;
+}
+
 dvdnav_status_t dvdnav_sector_search(dvdnav_t *this,
 				   unsigned long int offset, int origin) {
 /* FIXME: Implement */
@@ -125,34 +186,36 @@
   }
 
   if(fnd_cell_nr <= last_cell_nr) {
+    int32_t vobu, start, blockN;
+    dvdnav_status_t status;
     fprintf(stderr,"Seeking to cell %i from choice of %i to %i\n",
 	   fnd_cell_nr, first_cell_nr, last_cell_nr);
-    this->seekto_block = target;
-    this->seeking = 1;
+    status = dvdnav_scan_admap(this, state->domain, target, &vobu);
     /* 
      * Clut does not actually change,
      * but as the decoders have been closed then opened,
      * A new clut has to be sent.
      */
-    this->spu_clut_changed = 1;
-    //ogle_do_post_jump(ogle);
-    fprintf(stderr,"FIXME: After cellN=%u blockN=%u\n" ,
+    start =(state->pgc->cell_playback[state->cellN - 1].first_sector); 
+    fprintf(stderr,"FIXME: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" ,
       state->cellN,
+      state->blockN,
+      target,
+      vobu,
+      start);
+    state->blockN = vobu - start; 
+    fprintf(stderr,"FIXME: After vobu=%x start=%x blockN=%x\n" ,
+      vobu,
+      start,
       state->blockN);
-    
     pthread_mutex_unlock(&this->vm_lock);
     return target;
   } else {
     fprintf(stderr, "Error when seeking, asked to seek outside program\n");
   }
 
-
-
   fprintf(stderr,"FIXME: Implement seeking to location %u\n", target); 
 
-//  this->seekto_block=target;
-//  this->seeking = 1;
-
   pthread_mutex_unlock(&this->vm_lock);
   return -1;
 }
--- a/vm.c	Tue Apr 23 00:07:16 2002 +0000
+++ b/vm.c	Tue Apr 23 02:12:58 2002 +0000
@@ -263,6 +263,8 @@
   link_values = process_command(vm,link_values);
   assert(link_values.command == PlayThis);
   (vm->state).blockN = link_values.data1;
+  fprintf(stderr, "vm_start: blockN set to 0x%x\n", (vm->state).blockN);
+
 
   return 0; /* ?? */
 }
@@ -279,12 +281,12 @@
   position->still = (vm->state).pgc->cell_playback[(vm->state).cellN - 1].still_time;
   position->vobu_start = (vm->state).pgc->cell_playback[(vm->state).cellN - 1].first_sector;
   position->vobu_next = (vm->state).blockN;
-  position->vobu_next = 0; /* Just for now */
+//  position->vobu_next = 0; /* Just for now */
   return 1;
 }
 
 int vm_position_print(vm_t *vm, vm_position_t *position) {
-  fprintf(stderr, "But=%x Spu=%x Aud=%x Ang=%x Hop=%x vts=%x dom=%x cell=%x still=%x start=%x next=%d\n",
+  fprintf(stderr, "But=%x Spu=%x Aud=%x Ang=%x Hop=%x vts=%x dom=%x cell=%x still=%x start=%x next=%x\n",
   position->button,
   position->spu_channel,
   position->audio_channel,
@@ -308,6 +310,7 @@
   link_values = process_command(vm, link_values);
   assert(link_values.command == PlayThis);
   (vm->state).blockN = link_values.data1;
+  fprintf(stderr, "vm_start_title: blockN set to 0x%x\n", (vm->state).blockN);
 
   return 0; /* ?? */
 }
@@ -322,6 +325,7 @@
   link_values = process_command(vm, link_values);
   assert(link_values.command == PlayThis);
   (vm->state).blockN = link_values.data1;
+  fprintf(stderr, "vm_jump_prog: blockN set to 0x%x\n", (vm->state).blockN);
   
   return 0; /* ?? */
 }
@@ -334,6 +338,7 @@
     link_values = process_command(vm, link_values);
     assert(link_values.command == PlayThis);
     (vm->state).blockN = link_values.data1;
+    fprintf(stderr, "vm_eval_cmd: blockN set to 0x%x\n", (vm->state).blockN);
     return 1; /*  Something changed, Jump */
   } else {
     return 0; /*  It updated some state thats all... */
@@ -347,6 +352,7 @@
   link_values = process_command(vm,link_values);
   assert(link_values.command == PlayThis);
   (vm->state).blockN = link_values.data1;
+  fprintf(stderr, "vm_get_next_cell: blockN set to 0x%x\n", (vm->state).blockN);
   
   return 0; /*  ?? */
 }
@@ -358,6 +364,7 @@
   link_values = process_command(vm,link_values);
   assert(link_values.command == PlayThis);
   (vm->state).blockN = link_values.data1;
+  fprintf(stderr, "vm_top_pg: blockN set to 0x%x\n", (vm->state).blockN);
   
   return 1; /*  Jump */
 }
@@ -373,6 +380,7 @@
   link_values = process_command(vm,link_values);
   assert(link_values.command == PlayThis);
   (vm->state).blockN = link_values.data1;
+  fprintf(stderr, "vm_go_up: blockN set to 0x%x\n", (vm->state).blockN);
   
   return 1; /*  Jump */
 }
@@ -442,6 +450,7 @@
       link_values = process_command(vm, link_values);
       assert(link_values.command == PlayThis);
       (vm->state).blockN = link_values.data1;
+      fprintf(stderr, "vm_menu_call: blockN set to 0x%x\n", (vm->state).blockN);
       return 1; /*  Jump */
     } else {
       (vm->state).domain = old_domain;
@@ -484,9 +493,11 @@
     link_values = process_command(vm, link_values);
     assert(link_values.command == PlayThis);
     (vm->state).blockN = link_values.data1;
+    fprintf(stderr, "vm_resume1: blockN set to 0x%x\n", (vm->state).blockN);
   } else { 
     (vm->state).cellN = (vm->state).rsm_cellN;
     (vm->state).blockN = (vm->state).rsm_blockN;
+    fprintf(stderr, "vm_resume2: blockN set to 0x%x\n", (vm->state).blockN);
     /* (vm->state).pgN = ?? does this gets the righ value in play_Cell, no! */
     if(set_PGN(vm)) {
       /* Were at or past the end of the PGC, should not happen for a RSM */
@@ -1608,6 +1619,9 @@
 
 /*
  * $Log$
+ * Revision 1.13  2002/04/23 02:12:27  jcdutton
+ * Re-implemented seeking.
+ *
  * Revision 1.12  2002/04/22 22:00:48  jcdutton
  * Start of rewrite of libdvdnav. Still need to re-implement seeking.
  *