OSDN Git Service

Fixed dvd_seek for titles which are not linear
authortiter <titer@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 15 Jan 2006 13:51:39 +0000 (13:51 +0000)
committertiter <titer@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 15 Jan 2006 13:51:39 +0000 (13:51 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@20 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/dvd.c
libhb/scan.c

index 3888f41..54b5e5e 100644 (file)
@@ -536,26 +536,34 @@ void hb_dvd_stop( hb_dvd_t * d )
  **********************************************************************/
 int hb_dvd_seek( hb_dvd_t * d, float f )
 {
-    int target;
+    int count, sizeCell;
+    int i;
 
-    target = d->title_start + (int) ( f * d->title_block_count );
+    count = f * d->title_block_count;
 
-    /* Find the cell we shall start in */
-    d->cell_cur = d->cell_start;
-    FindNextCell( d );
-    for( ;; )
+    for( i = d->cell_start; i <= d->cell_end; i++ )
     {
-        if( target < d->pgc->cell_playback[d->cell_cur].last_sector )
+        sizeCell = d->pgc->cell_playback[i].last_sector + 1 -
+            d->pgc->cell_playback[i].first_sector;
+
+        if( count < sizeCell )
         {
+            d->cell_cur = i;
+            FindNextCell( d );
+
+            /* Now let hb_dvd_read find the next VOBU */
+            d->next_vobu = d->pgc->cell_playback[i].first_sector + count;
+            d->pack_len  = 0;
             break;
         }
-        d->cell_cur = d->cell_next;
-        FindNextCell( d );
+
+        count -= sizeCell;
     }
 
-    /* Now let hb_dvd_read find the next VOBU */
-    d->next_vobu = target;
-    d->pack_len  = 0;
+    if( i > d->cell_end )
+    {
+        return 0;
+    }
 
     return 1;
 }
index f60392c..c2814f3 100644 (file)
@@ -239,7 +239,10 @@ static int DecodePreviews( hb_scan_t * data, hb_title_t * title )
         FILE * file_preview;
         char   filename[1024];
 
-        hb_dvd_seek( data->dvd, (float) ( i + 1 ) / 11.0 );
+        if( !hb_dvd_seek( data->dvd, (float) ( i + 1 ) / 11.0 ) )
+        {
+            goto error;
+        }
 
         hb_log( "scan: preview %d", i + 1 );