[vlc-commits] dvdread: simplify dvdtime_to_time() with a parameter that's always 0

Steve Lhomme git at videolan.org
Tue Sep 18 16:53:24 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon May  7 13:31:41 2018 +0200| [07f10602132611f188b7a24ce3b4a18566779a54] | committer: Steve Lhomme

dvdread: simplify dvdtime_to_time() with a parameter that's always 0

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=07f10602132611f188b7a24ce3b4a18566779a54
---

 modules/access/dvdread.c | 54 ++++++++++++++++++++----------------------------
 1 file changed, 22 insertions(+), 32 deletions(-)

diff --git a/modules/access/dvdread.c b/modules/access/dvdread.c
index e19afbcf87..6ab1c7a5ed 100644
--- a/modules/access/dvdread.c
+++ b/modules/access/dvdread.c
@@ -290,41 +290,31 @@ static void Close( vlc_object_t *p_this )
     free( p_sys );
 }
 
-static vlc_tick_t dvdtime_to_time( dvd_time_t *dtime, uint8_t still_time )
+static vlc_tick_t dvdtime_to_time( dvd_time_t *dtime )
 {
 /* Macro to convert Binary Coded Decimal to Decimal */
 #define BCD2D(__x__) (((__x__ & 0xf0) >> 4) * 10 + (__x__ & 0x0f))
 
     double f_fps, f_ms;
-    vlc_tick_t i_micro_second;
 
-    if (still_time == 0 || still_time == 0xFF)
-    {
-        int64_t sec = (int64_t)(BCD2D(dtime->hour)) * 60 * 60;
-        sec += (int64_t)(BCD2D(dtime->minute)) * 60;
-        sec += (int64_t)(BCD2D(dtime->second));
+    int64_t sec = (int64_t)(BCD2D(dtime->hour)) * 60 * 60;
+    sec += (int64_t)(BCD2D(dtime->minute)) * 60;
+    sec += (int64_t)(BCD2D(dtime->second));
 
-        switch((dtime->frame_u & 0xc0) >> 6)
-        {
-        case 1:
-            f_fps = 25.0;
-            break;
-        case 3:
-            f_fps = 29.97;
-            break;
-        default:
-            f_fps = 2500.0;
-            break;
-        }
-        f_ms = BCD2D(dtime->frame_u&0x3f) * 1000.0 / f_fps;
-        i_micro_second = vlc_tick_from_sec(sec) + VLC_TICK_FROM_MS(f_ms);
-    }
-    else
+    switch((dtime->frame_u & 0xc0) >> 6)
     {
-        i_micro_second = vlc_tick_from_sec(still_time);
+    case 1:
+        f_fps = 25.0;
+        break;
+    case 3:
+        f_fps = 29.97;
+        break;
+    default:
+        f_fps = 2500.0;
+        break;
     }
-
-    return i_micro_second;
+    f_ms = BCD2D(dtime->frame_u&0x3f) * 1000.0 / f_fps;
+    return vlc_tick_from_sec(sec) + VLC_TICK_FROM_MS(f_ms);
 }
 
 /*****************************************************************************
@@ -365,7 +355,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             pi64 = va_arg( args, int64_t * );
             if( p_sys->cur_title >= 0 && p_sys->cur_title < p_sys->i_titles )
             {
-                *pi64 = (int64_t) dvdtime_to_time( &p_sys->p_cur_pgc->playback_time, 0 ) /
+                *pi64 = (int64_t) dvdtime_to_time( &p_sys->p_cur_pgc->playback_time ) /
                         p_sys->i_title_blocks * p_sys->i_title_offset;
                 return VLC_SUCCESS;
             }
@@ -376,7 +366,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             pi64 = va_arg( args, int64_t * );
             if( p_sys->cur_title >= 0 && p_sys->cur_title < p_sys->i_titles )
             {
-                *pi64 = (int64_t)dvdtime_to_time( &p_sys->p_cur_pgc->playback_time, 0 );
+                *pi64 = (int64_t)dvdtime_to_time( &p_sys->p_cur_pgc->playback_time );
                 return VLC_SUCCESS;
             }
             *pi64 = 0;
@@ -1185,7 +1175,7 @@ static void DvdReadHandleDSI( demux_t *p_demux, uint8_t *p_data )
      * Store the timecodes so we can get the current time
      */
     p_sys->i_title_cur_time = (vlc_tick_t) p_sys->dsi_pack.dsi_gi.nv_pck_scr / 90 * 1000;
-    p_sys->i_cell_cur_time = dvdtime_to_time( &p_sys->dsi_pack.dsi_gi.c_eltm, 0 );
+    p_sys->i_cell_cur_time = dvdtime_to_time( &p_sys->dsi_pack.dsi_gi.c_eltm );
 
     /*
      * If we're not at the end of this cell, we can determine the next
@@ -1254,7 +1244,7 @@ static void DvdReadHandleDSI( demux_t *p_demux, uint8_t *p_data )
         p_sys->i_next_vobu =
             p_sys->p_cur_pgc->cell_playback[p_sys->i_cur_cell].first_sector;
 
-        p_sys->i_cell_duration = dvdtime_to_time( &p_sys->p_cur_pgc->cell_playback[p_sys->i_cur_cell].playback_time, 0 );
+        p_sys->i_cell_duration = dvdtime_to_time( &p_sys->p_cur_pgc->cell_playback[p_sys->i_cur_cell].playback_time );
     }
 
 
@@ -1265,10 +1255,10 @@ static void DvdReadHandleDSI( demux_t *p_demux, uint8_t *p_data )
              p_sys->dsi_pack.dsi_gi.vobu_ea,
              p_sys->dsi_pack.dsi_gi.vobu_vob_idn,
              p_sys->dsi_pack.dsi_gi.vobu_c_idn,
-             dvdtime_to_time( &p_sys->dsi_pack.dsi_gi.c_eltm, 0 ) );
+             dvdtime_to_time( &p_sys->dsi_pack.dsi_gi.c_eltm ) );
 
     msg_Dbg( p_demux, "cell duration: %lld",
-             dvdtime_to_time( &p_sys->p_cur_pgc->cell_playback[p_sys->i_cur_cell].playback_time, 0 ) );
+             dvdtime_to_time( &p_sys->p_cur_pgc->cell_playback[p_sys->i_cur_cell].playback_time ) );
 
     msg_Dbg( p_demux, "cat 0x%02x ilvu_ea %d ilvu_sa %d size %d",
              p_sys->dsi_pack.sml_pbi.category,



More information about the vlc-commits mailing list