[vlc-commits] demux: ts: remove useless mtime->time conversions

Francois Cartegnie git at videolan.org
Sat Feb 27 13:46:49 CET 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Feb 27 11:43:25 2016 +0100| [dd98ce6700bd01853034286faa8dd54fb0d196c5] | committer: Francois Cartegnie

demux: ts: remove useless mtime->time conversions

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

 modules/demux/mpeg/ts.c         |   24 ++++++++++++++++--------
 modules/demux/mpeg/ts.h         |    2 +-
 modules/demux/mpeg/ts_psi_eit.c |   11 ++++++-----
 3 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index 58d6373..6f9d73b 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -744,7 +744,7 @@ static int Demux( demux_t *p_demux )
 /*****************************************************************************
  * Control:
  *****************************************************************************/
-static int EITCurrentEventTime( const ts_pmt_t *p_pmt, mtime_t i_tdt_offset,
+static int EITCurrentEventTime( const ts_pmt_t *p_pmt, time_t i_tdt_offset,
                                 time_t *pi_time, time_t *pi_length )
 {
     if( pi_length )
@@ -754,7 +754,7 @@ static int EITCurrentEventTime( const ts_pmt_t *p_pmt, mtime_t i_tdt_offset,
 
     if( p_pmt && p_pmt->eit.i_event_length > 0 )
     {
-        const time_t t = time(NULL) + i_tdt_offset / CLOCK_FREQ;
+        const time_t t = time(NULL) + i_tdt_offset;
         if( p_pmt->eit.i_event_start <= t && t < p_pmt->eit.i_event_start + p_pmt->eit.i_event_length )
         {
             if( pi_length )
@@ -889,7 +889,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         /* Access control test is because EPG for recordings is not relevant */
         if( p_sys->b_dvb_meta && p_sys->b_access_control )
         {
-            int64_t i_time, i_length;
+            time_t i_time, i_length;
             if( !EITCurrentEventTime( p_pmt, p_sys->i_tdt_delta, &i_time, &i_length ) && i_length > 0 )
             {
                 *pf = (double)i_time/(double)i_length;
@@ -930,13 +930,13 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
         if( p_sys->b_dvb_meta && p_sys->b_access_control &&
            !p_sys->b_force_seek_per_percent && p_pmt )
         {
-            int64_t i_time, i_length;
+            time_t i_time, i_length;
             if( !EITCurrentEventTime( p_pmt, p_sys->i_tdt_delta, &i_time, &i_length ) &&
-                 i_length > 0 && !SeekToTime( p_demux, p_pmt, (int64_t)(TO_SCALE(i_length) * f) ) )
+                 i_length > 0 && !SeekToTime( p_demux, p_pmt, (int64_t)(TO_SCALE(i_length * CLOCK_FREQ) * f) ) )
             {
                 ReadyQueuesPostSeek( p_demux );
                 es_out_Control( p_demux->out, ES_OUT_SET_NEXT_DISPLAY_TIME,
-                                (int64_t)(TO_SCALE(i_length) * f) );
+                                (int64_t)(TO_SCALE(i_length * CLOCK_FREQ) * f) );
                 return VLC_SUCCESS;
             }
         }
@@ -986,8 +986,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         if( p_sys->b_dvb_meta && p_sys->b_access_control )
         {
-            if( !EITCurrentEventTime( p_pmt, p_sys->i_tdt_delta, pi64, NULL ) )
+            time_t i_event_start;
+            if( !EITCurrentEventTime( p_pmt, p_sys->i_tdt_delta, &i_event_start, NULL ) )
+            {
+                *pi64 = i_event_start * CLOCK_FREQ;
                 return VLC_SUCCESS;
+            }
         }
 
         if( p_pmt && p_pmt->pcr.i_current > -1 && p_pmt->pcr.i_first > -1 )
@@ -1003,8 +1007,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         if( p_sys->b_dvb_meta && p_sys->b_access_control )
         {
-            if( !EITCurrentEventTime( p_pmt, p_sys->i_tdt_delta, NULL, pi64 ) )
+            time_t i_event_duration;
+            if( !EITCurrentEventTime( p_pmt, p_sys->i_tdt_delta, NULL, &i_event_duration ) )
+            {
+                *pi64 = i_event_duration * CLOCK_FREQ;
                 return VLC_SUCCESS;
+            }
         }
 
         if( p_pmt &&
diff --git a/modules/demux/mpeg/ts.h b/modules/demux/mpeg/ts.h
index 87e5db6..1360a06 100644
--- a/modules/demux/mpeg/ts.h
+++ b/modules/demux/mpeg/ts.h
@@ -98,7 +98,7 @@ struct demux_sys_t
 
     /* */
     bool        b_dvb_meta;
-    int64_t     i_tdt_delta;
+    time_t      i_tdt_delta;
     bool        b_broken_charset; /* True if broken encoding is used in EPG/SDT */
 
     /* Selected programs */
diff --git a/modules/demux/mpeg/ts_psi_eit.c b/modules/demux/mpeg/ts_psi_eit.c
index 4d49c51..a611bb9 100644
--- a/modules/demux/mpeg/ts_psi_eit.c
+++ b/modules/demux/mpeg/ts_psi_eit.c
@@ -283,8 +283,7 @@ static void TDTCallBack( demux_t *p_demux, dvbpsi_tot_t *p_tdt )
 {
     demux_sys_t        *p_sys = p_demux->p_sys;
 
-    p_sys->i_tdt_delta = CLOCK_FREQ * EITConvertStartTime( p_tdt->i_utc_time )
-                         - mdate();
+    p_sys->i_tdt_delta = EITConvertStartTime( p_tdt->i_utc_time ) - time(NULL);
     dvbpsi_tot_delete(p_tdt);
 }
 
@@ -321,17 +320,19 @@ static void EITCallBack( demux_t *p_demux,
         int64_t i_start;
         int i_duration;
         int i_min_age = 0;
-        int64_t i_tot_time = 0;
 
         i_start = EITConvertStartTime( p_evt->i_start_time );
         i_duration = EITConvertDuration( p_evt->i_duration );
 
         if( p_sys->arib.e_mode == ARIBMODE_ENABLED )
         {
+            time_t i_now = time(NULL);
+            time_t i_tot_time = 0;
+
             if( p_sys->i_tdt_delta == 0 )
-                p_sys->i_tdt_delta = CLOCK_FREQ * (i_start + i_duration - 5) - mdate();
+                p_sys->i_tdt_delta = (i_start + i_duration - 5) - i_now;
 
-            i_tot_time = (mdate() + p_sys->i_tdt_delta) / CLOCK_FREQ;
+            i_tot_time = i_now + p_sys->i_tdt_delta;
 
             tzset(); // JST -> UTC
             i_start += timezone; // FIXME: what about DST?



More information about the vlc-commits mailing list