]> granicus.if.org Git - handbrake/commitdiff
libhb: fix calculation of chapter durations in dvdread and dvdnav.
authorRodeo <tdskywalker@gmail.com>
Sun, 16 Jun 2013 01:56:22 +0000 (01:56 +0000)
committerRodeo <tdskywalker@gmail.com>
Sun, 16 Jun 2013 01:56:22 +0000 (01:56 +0000)
The values printed to the scan log were incorrect.

Patch by Stuart Webster. Thanks!

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5588 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/dvd.c
libhb/dvdnav.c

index 56c1ba571cb9b544de2bdcb2423f9afe253bff05..240582a52fdc1c182ce6287961facf41ed5f0112 100644 (file)
@@ -173,8 +173,6 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur
     ifo_handle_t * vts = NULL;
     int            pgc_id, pgn, i;
     hb_chapter_t * chapter;
-    uint64_t       duration;
-    float          duration_correction;
     unsigned char  unused[1024];
     const char   * codec_name;
 
@@ -609,19 +607,9 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t, uint64_t min_dur
         hb_list_add( title->list_chapter, chapter );
     }
 
-    /* The durations we get for chapters aren't precise. Scale them so
-       the total matches the title duration */
-    duration = 0;
-    for( i = 0; i < hb_list_count( title->list_chapter ); i++ )
-    {
-        chapter = hb_list_item( title->list_chapter, i );
-        duration += chapter->duration;
-    }
-    duration_correction = (float) title->duration / (float) duration;
     for( i = 0; i < hb_list_count( title->list_chapter ); i++ )
     {
         chapter           = hb_list_item( title->list_chapter, i );
-        chapter->duration = duration_correction * chapter->duration;
 
         int seconds       = ( chapter->duration + 45000 ) / 90000;
         chapter->hours    = ( seconds / 3600 );
@@ -1270,8 +1258,8 @@ static int dvdtime2msec(dvd_time_t * dt)
 
     if( fps > 0 )
     {
-        ms += ((dt->frame_u & 0x30) >> 3) * 5 +
-              (dt->frame_u & 0x0f) * 1000.0 / fps;
+        ms += (((dt->frame_u & 0x30) >> 3) * 5 +
+                (dt->frame_u & 0x0f)) * 1000.0 / fps;
     }
 
     return ms;
index 0d741b05e678723c91c5e991753838a309e72deb..ef80bf54124382ada209aed5082ea70e90192ac3 100644 (file)
@@ -318,7 +318,6 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura
     int            count;
     uint64_t       duration, longest;
     int            longest_pgcn, longest_pgn, longest_pgcn_end;
-    float          duration_correction;
     const char   * name;
     const char   * codec_name;
 
@@ -758,7 +757,6 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura
 
     hb_log( "scan: title %d has %d chapters", t, c );
 
-    duration = 0;
     count = hb_list_count( title->list_chapter );
     for (i = 0; i < count; i++)
     {
@@ -797,16 +795,11 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t, uint64_t min_dura
 #undef cp
             cell_cur = FindNextCell( pgc, cell_cur );
         }
-        duration += chapter->duration;
     }
 
-    /* The durations we get for chapters aren't precise. Scale them so
-       the total matches the title duration */
-    duration_correction = (float) title->duration / (float) duration;
     for( i = 0; i < hb_list_count( title->list_chapter ); i++ )
     {
         chapter           = hb_list_item( title->list_chapter, i );
-        chapter->duration = duration_correction * chapter->duration;
 
         int seconds       = ( chapter->duration + 45000 ) / 90000;
         chapter->hours    = ( seconds / 3600 );
@@ -1998,8 +1991,8 @@ static int dvdtime2msec(dvd_time_t * dt)
 
     if( fps > 0 )
     {
-        ms += ((dt->frame_u & 0x30) >> 3) * 5 +
-              (dt->frame_u & 0x0f) * 1000.0 / fps;
+        ms += (((dt->frame_u & 0x30) >> 3) * 5 +
+                (dt->frame_u & 0x0f)) * 1000.0 / fps;
     }
 
     return ms;