[vlc-commits] demux: ts: typedef timestamps

Francois Cartegnie git at videolan.org
Fri May 4 19:44:59 CEST 2018


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri May  4 19:33:51 2018 +0200| [68fcf13842229e17c3db26ed62f457219484ff77] | committer: Francois Cartegnie

demux: ts: typedef timestamps

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

 modules/demux/mpeg/pes.h                |  30 ++++-----
 modules/demux/mpeg/timestamps.h         |   6 +-
 modules/demux/mpeg/ts.c                 | 108 ++++++++++++++++----------------
 modules/demux/mpeg/ts.h                 |   2 +-
 modules/demux/mpeg/ts_arib.c            |   1 +
 modules/demux/mpeg/ts_hotfixes.c        |   2 +-
 modules/demux/mpeg/ts_pid.c             |   1 +
 modules/demux/mpeg/ts_psip.c            |   1 +
 modules/demux/mpeg/ts_scte.c            |   2 +-
 modules/demux/mpeg/ts_streams.c         |   2 +-
 modules/demux/mpeg/ts_streams_private.h |  11 ++--
 11 files changed, 86 insertions(+), 80 deletions(-)

diff --git a/modules/demux/mpeg/pes.h b/modules/demux/mpeg/pes.h
index b5bc18fdd6..5511afb281 100644
--- a/modules/demux/mpeg/pes.h
+++ b/modules/demux/mpeg/pes.h
@@ -20,7 +20,7 @@
 #ifndef VLC_MPEG_PES_H
 #define VLC_MPEG_PES_H
 
-static inline bool ExtractPESTimestamp( const uint8_t *p_data, uint8_t i_flags, mtime_t *ret )
+static inline bool ExtractPESTimestamp( const uint8_t *p_data, uint8_t i_flags, int64_t *ret )
 {
     /* !warn broken muxers set incorrect flags. see #17773 and #19140 */
     /* check marker bits, and i_flags = b 0010, 0011 or 0001 */
@@ -32,29 +32,29 @@ static inline bool ExtractPESTimestamp( const uint8_t *p_data, uint8_t i_flags,
         return false;
 
 
-    *ret =  ((mtime_t)(p_data[ 0]&0x0e ) << 29)|
-             (mtime_t)(p_data[1] << 22)|
-            ((mtime_t)(p_data[2]&0xfe) << 14)|
-             (mtime_t)(p_data[3] << 7)|
-             (mtime_t)(p_data[4] >> 1);
+    *ret =  ((int64_t)(p_data[ 0]&0x0e ) << 29)|
+             (int64_t)(p_data[1] << 22)|
+            ((int64_t)(p_data[2]&0xfe) << 14)|
+             (int64_t)(p_data[3] << 7)|
+             (int64_t)(p_data[4] >> 1);
     return true;
 }
 
 /* PS SCR timestamp as defined in H222 2.5.3.2 */
-static inline mtime_t ExtractPackHeaderTimestamp( const uint8_t *p_data )
+static inline int64_t ExtractPackHeaderTimestamp( const uint8_t *p_data )
 {
-    return ((mtime_t)(p_data[ 0]&0x38 ) << 27)|
-            ((mtime_t)(p_data[0]&0x03 ) << 28)|
-             (mtime_t)(p_data[1] << 20)|
-            ((mtime_t)(p_data[2]&0xf8 ) << 12)|
-            ((mtime_t)(p_data[2]&0x03 ) << 13)|
-             (mtime_t)(p_data[3] << 5) |
-             (mtime_t)(p_data[4] >> 3);
+    return ((int64_t)(p_data[ 0]&0x38 ) << 27)|
+            ((int64_t)(p_data[0]&0x03 ) << 28)|
+             (int64_t)(p_data[1] << 20)|
+            ((int64_t)(p_data[2]&0xf8 ) << 12)|
+            ((int64_t)(p_data[2]&0x03 ) << 13)|
+             (int64_t)(p_data[3] << 5) |
+             (int64_t)(p_data[4] >> 3);
 }
 
 inline
 static int ParsePESHeader( vlc_object_t *p_object, const uint8_t *p_header, size_t i_header,
-                           unsigned *pi_skip, mtime_t *pi_dts, mtime_t *pi_pts,
+                           unsigned *pi_skip, int64_t *pi_dts, int64_t *pi_pts,
                            uint8_t *pi_stream_id, bool *pb_pes_scambling )
 {
     unsigned i_skip;
diff --git a/modules/demux/mpeg/timestamps.h b/modules/demux/mpeg/timestamps.h
index 57f4fb0802..cf805627df 100644
--- a/modules/demux/mpeg/timestamps.h
+++ b/modules/demux/mpeg/timestamps.h
@@ -25,9 +25,11 @@
 #define FROM_SCALE(x) (VLC_TS_0 + FROM_SCALE_NZ(x))
 #define TO_SCALE(x)   TO_SCALE_NZ((x) - VLC_TS_0)
 
-static inline int64_t TimeStampWrapAround( int64_t i_first_pcr, int64_t i_time )
+typedef int64_t stime_t;
+
+static inline stime_t TimeStampWrapAround( stime_t i_first_pcr, stime_t i_time )
 {
-    int64_t i_adjust = 0;
+    stime_t i_adjust = 0;
     if( i_first_pcr > 0x0FFFFFFFF && i_time < 0x0FFFFFFFF )
         i_adjust = 0x1FFFFFFFF;
 
diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index bd9505bfdf..35a21aa6a7 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -178,17 +178,17 @@ static inline int PIDGet( block_t *p )
 {
     return ( (p->p_buffer[1]&0x1f)<<8 )|p->p_buffer[2];
 }
-static mtime_t GetPCR( const block_t * );
+static stime_t GetPCR( const block_t * );
 
 static block_t * ProcessTSPacket( demux_t *p_demux, ts_pid_t *pid, block_t *p_pkt, int * );
 static bool GatherPESData( demux_t *p_demux, ts_pid_t *pid, block_t *p_bk, size_t );
 static bool GatherSectionsData( demux_t *p_demux, ts_pid_t *, block_t *, size_t );
-static void ProgramSetPCR( demux_t *p_demux, ts_pmt_t *p_prg, mtime_t i_pcr );
+static void ProgramSetPCR( demux_t *p_demux, ts_pmt_t *p_prg, stime_t i_pcr );
 
 static block_t* ReadTSPacket( demux_t *p_demux );
-static int SeekToTime( demux_t *p_demux, const ts_pmt_t *, int64_t time );
+static int SeekToTime( demux_t *p_demux, const ts_pmt_t *, stime_t time );
 static void ReadyQueuesPostSeek( demux_t *p_demux );
-static void PCRHandle( demux_t *p_demux, ts_pid_t *, mtime_t );
+static void PCRHandle( demux_t *p_demux, ts_pid_t *, stime_t );
 static void PCRFixHandle( demux_t *, ts_pmt_t *, block_t * );
 
 #define TS_PACKET_SIZE_188 188
@@ -679,8 +679,8 @@ static int Demux( demux_t *p_demux )
         }
 
         /* Adaptation field cannot be scrambled */
-        mtime_t i_pcr = GetPCR( p_pkt );
-        if( i_pcr != VLC_TS_INVALID )
+        stime_t i_pcr = GetPCR( p_pkt );
+        if( i_pcr >= 0 )
             PCRHandle( p_demux, p_pid, i_pcr );
 
         /* Probe streams to build PAT/PMT after MIN_PAT_INTERVAL in case we don't see any PAT */
@@ -975,8 +975,8 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
              p_pmt->pcr.i_first > -1 && p_pmt->i_last_dts != VLC_TS_INVALID &&
              p_pmt->pcr.i_current > -1 )
         {
-            int64_t i_length = TimeStampWrapAround( p_pmt->pcr.i_first,
-                                                   p_pmt->i_last_dts ) - p_pmt->pcr.i_first;
+            stime_t i_length = TimeStampWrapAround( p_pmt->pcr.i_first,
+                                                    p_pmt->i_last_dts ) - p_pmt->pcr.i_first;
             i64 = p_pmt->pcr.i_first + (int64_t)(i_length * f);
             if( i64 <= p_pmt->i_last_dts )
             {
@@ -1026,7 +1026,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         if( p_pmt && p_pmt->pcr.i_current > -1 && p_pmt->pcr.i_first > -1 )
         {
-            int64_t i_pcr = TimeStampWrapAround( p_pmt->pcr.i_first, p_pmt->pcr.i_current );
+            stime_t i_pcr = TimeStampWrapAround( p_pmt->pcr.i_first, p_pmt->pcr.i_current );
             *pi64 = FROM_SCALE(i_pcr - p_pmt->pcr.i_first);
             return VLC_SUCCESS;
         }
@@ -1047,12 +1047,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         if( !p_sys->b_ignore_time_for_positions &&
             p_pmt &&
-           ( p_pmt->pcr.i_first > -1 || p_pmt->pcr.i_first_dts != VLC_TS_INVALID ) &&
+           ( p_pmt->pcr.i_first > -1 || p_pmt->pcr.i_first_dts != -1 ) &&
              p_pmt->i_last_dts > 0 )
         {
-            int64_t i_start = (p_pmt->pcr.i_first > -1) ? p_pmt->pcr.i_first :
-                              TO_SCALE(p_pmt->pcr.i_first_dts);
-            int64_t i_last = TimeStampWrapAround( p_pmt->pcr.i_first, p_pmt->i_last_dts );
+            stime_t i_start = (p_pmt->pcr.i_first > -1) ? p_pmt->pcr.i_first :
+                              p_pmt->pcr.i_first_dts;
+            stime_t i_last = TimeStampWrapAround( p_pmt->pcr.i_first, p_pmt->i_last_dts );
             i_last += p_pmt->pcr.i_pcroffset;
             *pi64 = FROM_SCALE(i_last - i_start);
             return VLC_SUCCESS;
@@ -1354,7 +1354,7 @@ static block_t * ConvertPESBlock( demux_t *p_demux, ts_es_t *p_es,
         {
             /* Teletext may have missing PTS (ETSI EN 300 472 Annexe A)
              * In this case use the last PCR + 40ms */
-            mtime_t i_pcr = p_es->p_program->pcr.i_current;
+            stime_t i_pcr = p_es->p_program->pcr.i_current;
             if( i_pcr != VLC_TS_INVALID )
                 p_block->i_pts = FROM_SCALE(i_pcr) + 40000;
         }
@@ -1463,8 +1463,8 @@ static void ParsePESDataChain( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes )
     uint8_t header[34];
     unsigned i_pes_size = 0;
     unsigned i_skip = 0;
-    mtime_t i_dts = -1;
-    mtime_t i_pts = -1;
+    stime_t i_dts = -1;
+    stime_t i_pts = -1;
     mtime_t i_length = 0;
     uint8_t i_stream_id;
     bool b_pes_scrambling = false;
@@ -1621,9 +1621,9 @@ static void ParsePESDataChain( demux_t *p_demux, ts_pid_t *pid, block_t *p_pes )
                     p_pmt->pcr.i_current != VLC_TS_INVALID &&
                    (p_es->fmt.i_cat == VIDEO_ES || p_es->fmt.i_cat == AUDIO_ES) )
                 {
-                    int64_t i_dts27 = TO_SCALE(p_block->i_dts);
+                    stime_t i_dts27 = TO_SCALE(p_block->i_dts);
                     i_dts27 = TimeStampWrapAround( p_pmt->pcr.i_first, i_dts27 );
-                    int64_t i_pcr = TimeStampWrapAround( p_pmt->pcr.i_first, p_pmt->pcr.i_current );
+                    stime_t i_pcr = TimeStampWrapAround( p_pmt->pcr.i_first, p_pmt->pcr.i_current );
                     if( i_dts27 < i_pcr )
                     {
                         p_pmt->pcr.i_pcroffset = i_pcr - i_dts27 + 80000;
@@ -1798,11 +1798,11 @@ static block_t* ReadTSPacket( demux_t *p_demux )
     return p_pkt;
 }
 
-static mtime_t GetPCR( const block_t *p_pkt )
+static stime_t GetPCR( const block_t *p_pkt )
 {
     const uint8_t *p = p_pkt->p_buffer;
 
-    mtime_t i_pcr = -1;
+    stime_t i_pcr = -1;
 
     if( likely(p_pkt->i_buffer > 11) &&
         ( p[3]&0x20 ) && /* adaptation */
@@ -1810,11 +1810,11 @@ static mtime_t GetPCR( const block_t *p_pkt )
         ( p[4] >= 7 ) )
     {
         /* PCR is 33 bits */
-        i_pcr = ( (mtime_t)p[6] << 25 ) |
-                ( (mtime_t)p[7] << 17 ) |
-                ( (mtime_t)p[8] << 9 ) |
-                ( (mtime_t)p[9] << 1 ) |
-                ( (mtime_t)p[10] >> 7 );
+        i_pcr = ( (stime_t)p[6] << 25 ) |
+                ( (stime_t)p[7] << 17 ) |
+                ( (stime_t)p[8] << 9 ) |
+                ( (stime_t)p[9] << 1 ) |
+                ( (stime_t)p[10] >> 7 );
     }
     return i_pcr;
 }
@@ -1898,7 +1898,7 @@ static void ReadyQueuesPostSeek( demux_t *p_demux )
     }
 }
 
-static int SeekToTime( demux_t *p_demux, const ts_pmt_t *p_pmt, int64_t i_scaledtime )
+static int SeekToTime( demux_t *p_demux, const ts_pmt_t *p_pmt, stime_t i_scaledtime )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
 
@@ -1932,7 +1932,7 @@ static int SeekToTime( demux_t *p_demux, const ts_pmt_t *p_pmt, int64_t i_scaled
         uint64_t i_pos = i_splitpos;
         while( i_pos < i_tail_pos )
         {
-            int64_t i_pcr = -1;
+            stime_t i_pcr = -1;
             block_t *p_pkt = ReadTSPacket( p_demux );
             if( !p_pkt )
             {
@@ -1963,8 +1963,8 @@ static int SeekToTime( demux_t *p_demux, const ts_pmt_t *p_pmt, int64_t i_scaled
 
                 if( i_pcr == -1 )
                 {
-                    mtime_t i_dts = -1;
-                    mtime_t i_pts = -1;
+                    stime_t i_dts = -1;
+                    stime_t i_pts = -1;
                     uint8_t i_stream_id;
                     if ( VLC_SUCCESS == ParsePESHeader( VLC_OBJECT(p_demux), &p_pkt->p_buffer[i_skip],
                                                         p_pkt->i_buffer - i_skip, &i_skip,
@@ -1979,7 +1979,7 @@ static int SeekToTime( demux_t *p_demux, const ts_pmt_t *p_pmt, int64_t i_scaled
 
             if( i_pcr != -1 )
             {
-                int64_t i_diff = i_scaledtime - TimeStampWrapAround( p_pmt->pcr.i_first, i_pcr );
+                stime_t i_diff = i_scaledtime - TimeStampWrapAround( p_pmt->pcr.i_first, i_pcr );
                 if ( i_diff < 0 )
                     i_tail_pos = (i_splitpos >= p_sys->i_packet_size) ? i_splitpos - p_sys->i_packet_size : 0;
                 else if( i_diff < TO_SCALE(VLC_TS_0 + CLOCK_FREQ / 2) ) // 500ms
@@ -2003,7 +2003,7 @@ static int SeekToTime( demux_t *p_demux, const ts_pmt_t *p_pmt, int64_t i_scaled
     return VLC_SUCCESS;
 }
 
-static int ProbeChunk( demux_t *p_demux, int i_program, bool b_end, int64_t *pi_pcr, bool *pb_found )
+static int ProbeChunk( demux_t *p_demux, int i_program, bool b_end, stime_t *pi_pcr, bool *pb_found )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     int i_count = 0;
@@ -2046,8 +2046,8 @@ static int ProbeChunk( demux_t *p_demux, int i_program, bool b_end, int64_t *pi_
               )
             {
                 b_pcrresult = false;
-                mtime_t i_dts = -1;
-                mtime_t i_pts = -1;
+                stime_t i_dts = -1;
+                stime_t i_pts = -1;
                 uint8_t i_stream_id;
                 unsigned i_skip = 4;
                 if ( b_adaptfield ) // adaptation field
@@ -2085,9 +2085,9 @@ static int ProbeChunk( demux_t *p_demux, int i_program, bool b_end, int64_t *pi_
                         {
                             p_pmt->pcr.i_first = *pi_pcr;
                         }
-                        else if( p_pmt->pcr.i_first_dts < VLC_TS_0 )
+                        else if( p_pmt->pcr.i_first_dts == -1 )
                         {
-                            p_pmt->pcr.i_first_dts = FROM_SCALE(*pi_pcr);
+                            p_pmt->pcr.i_first_dts = *pi_pcr;
                         }
 
                         if( i_program == 0 || i_program == p_pmt->i_number )
@@ -2111,7 +2111,7 @@ int ProbeStart( demux_t *p_demux, int i_program )
 
     int i_probe_count = 0;
     int64_t i_pos;
-    mtime_t i_pcr = -1;
+    stime_t i_pcr = -1;
     bool b_found = false;
 
     do
@@ -2143,7 +2143,7 @@ int ProbeEnd( demux_t *p_demux, int i_program )
 
     int i_probe_count = PROBE_CHUNK_COUNT;
     int64_t i_pos;
-    mtime_t i_pcr = -1;
+    stime_t i_pcr = -1;
     bool b_found = false;
 
     do
@@ -2167,7 +2167,7 @@ int ProbeEnd( demux_t *p_demux, int i_program )
     return (b_found) ? VLC_SUCCESS : VLC_EGENERIC;
 }
 
-static void ProgramSetPCR( demux_t *p_demux, ts_pmt_t *p_pmt, mtime_t i_pcr )
+static void ProgramSetPCR( demux_t *p_demux, ts_pmt_t *p_pmt, stime_t i_pcr )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
 
@@ -2175,7 +2175,7 @@ static void ProgramSetPCR( demux_t *p_demux, ts_pmt_t *p_pmt, mtime_t i_pcr )
        PCR barrier, and then adapt pcr so they have valid PCR when dequeuing */
     if( p_pmt->pcr.i_current == -1 && p_pmt->pcr.b_fix_done )
     {
-        mtime_t i_mindts = -1;
+        mtime_t i_mindts = VLC_TS_INVALID;
 
         ts_pat_t *p_pat = GetPID(p_sys, 0)->u.p_pat;
         for( int i=0; i< p_pat->programs.i_size; i++ )
@@ -2188,7 +2188,7 @@ static void ProgramSetPCR( demux_t *p_demux, ts_pmt_t *p_pmt, mtime_t i_pcr )
                 while( p_block && p_block->i_dts == VLC_TS_INVALID )
                     p_block = p_block->p_next;
 
-                if( p_block && ( i_mindts == -1 || p_block->i_dts < i_mindts ) )
+                if( p_block && ( i_mindts == VLC_TS_INVALID || p_block->i_dts < i_mindts ) )
                     i_mindts = p_block->i_dts;
             }
         }
@@ -2247,7 +2247,7 @@ static int IsVideoEnd( ts_pid_t *p_pid )
              ( tail[ i_tail - 1 ] == 0xb7 ||  tail[ i_tail - 1 ] == 0x0a ) );
 }
 
-static void PCRCheckDTS( demux_t *p_demux, ts_pmt_t *p_pmt, mtime_t i_pcr)
+static void PCRCheckDTS( demux_t *p_demux, ts_pmt_t *p_pmt, stime_t i_pcr)
 {
     for( int i=0; i<p_pmt->e_streams.i_size; i++ )
     {
@@ -2277,8 +2277,8 @@ static void PCRCheckDTS( demux_t *p_demux, ts_pmt_t *p_pmt, mtime_t i_pcr)
             continue;
 
         unsigned i_skip = 0;
-        mtime_t i_dts = -1;
-        mtime_t i_pts = -1;
+        stime_t i_dts = -1;
+        stime_t i_pts = -1;
         uint8_t i_stream_id;
 
         if( ParsePESHeader( VLC_OBJECT(p_demux), (uint8_t*)&header, i_max, &i_skip,
@@ -2286,31 +2286,31 @@ static void PCRCheckDTS( demux_t *p_demux, ts_pmt_t *p_pmt, mtime_t i_pcr)
             continue;
 
         if (p_pmt->pcr.i_pcroffset > 0) {
-            if( i_dts != VLC_TS_INVALID )
+            if( i_dts != -1 )
                 i_dts += p_pmt->pcr.i_pcroffset;
-            if( i_pts != VLC_TS_INVALID )
+            if( i_pts != -1 )
                 i_pts += p_pmt->pcr.i_pcroffset;
         }
 
-        if( i_dts != VLC_TS_INVALID )
+        if( i_dts != -1 )
             i_dts = TimeStampWrapAround( i_pcr, i_dts );
-        if( i_pts != VLC_TS_INVALID )
+        if( i_pts != -1 )
             i_pts = TimeStampWrapAround( i_pcr, i_pts );
 
-        if(( i_dts != VLC_TS_INVALID && i_dts <= i_pcr ) ||
-           ( i_pts != VLC_TS_INVALID && i_pts <= i_pcr ))
+        if(( i_dts != -1 && i_dts <= i_pcr ) ||
+           ( i_pts != -1 && i_pts <= i_pcr ))
         {
             if( IsVideoEnd( p_pid ) )
             {
                 msg_Warn( p_demux, "send queued data for pid %d: TS %"PRId64" <= PCR %"PRId64"\n",
-                          p_pid->i_pid, i_dts != VLC_TS_INVALID ? i_dts : i_pts, i_pcr);
+                          p_pid->i_pid, i_dts != -1 ? i_dts : i_pts, i_pcr);
                 PushPESBlock( p_demux, p_pid, NULL, true ); /* Flush */
             }
         }
     }
 }
 
-static void PCRHandle( demux_t *p_demux, ts_pid_t *pid, mtime_t i_pcr )
+static void PCRHandle( demux_t *p_demux, ts_pid_t *pid, stime_t i_pcr )
 {
     demux_sys_t   *p_sys = p_demux->p_sys;
 
@@ -2329,7 +2329,7 @@ static void PCRHandle( demux_t *p_demux, ts_pid_t *pid, mtime_t i_pcr )
         ts_pmt_t *p_pmt = p_pat->programs.p_elems[i]->u.p_pmt;
         if( p_pmt->pcr.b_disable )
             continue;
-        mtime_t i_program_pcr = TimeStampWrapAround( p_pmt->pcr.i_first, i_pcr );
+        stime_t i_program_pcr = TimeStampWrapAround( p_pmt->pcr.i_first, i_pcr );
 
         if( p_pmt->i_pid_pcr == 0x1FFF ) /* That program has no dedicated PCR pid ISO/IEC 13818-1 2.4.4.9 */
         {
@@ -2403,9 +2403,9 @@ static void PCRFixHandle( demux_t *p_demux, ts_pmt_t *p_pmt, block_t *p_block )
     /* Record the first data packet timestamp in case there wont be any PCR */
     else if( !p_pmt->pcr.i_first_dts )
     {
-        p_pmt->pcr.i_first_dts = p_block->i_dts;
+        p_pmt->pcr.i_first_dts = TO_SCALE(p_block->i_dts);
     }
-    else if( p_block->i_dts - p_pmt->pcr.i_first_dts > CLOCK_FREQ / 2 ) /* "PCR repeat rate shall not exceed 100ms" */
+    else if( p_block->i_dts - FROM_SCALE(p_pmt->pcr.i_first_dts) > CLOCK_FREQ / 2 ) /* "PCR repeat rate shall not exceed 100ms" */
     {
         if( p_pmt->pcr.i_current < 0 &&
             GetPID( p_sys, p_pmt->i_pid_pcr )->probed.i_pcr_count == 0 )
diff --git a/modules/demux/mpeg/ts.h b/modules/demux/mpeg/ts.h
index 389bf465e3..a867db5686 100644
--- a/modules/demux/mpeg/ts.h
+++ b/modules/demux/mpeg/ts.h
@@ -122,7 +122,7 @@ struct demux_sys_t
 
     struct
     {
-        mtime_t i_first_dts;     /* first dts encountered for the stream */
+        stime_t i_first_dts;     /* first dts encountered for the stream */
         int     i_timesourcepid; /* which pid we saved the dts from */
         enum { PAT_WAITING = 0, PAT_MISSING, PAT_FIXTRIED } status; /* set if we haven't seen PAT within MIN_PAT_INTERVAL */
     } patfix;
diff --git a/modules/demux/mpeg/ts_arib.c b/modules/demux/mpeg/ts_arib.c
index 432c31a6d0..afd0798f81 100644
--- a/modules/demux/mpeg/ts_arib.c
+++ b/modules/demux/mpeg/ts_arib.c
@@ -23,6 +23,7 @@
 #include <vlc_common.h>
 #include <vlc_demux.h>
 
+#include "timestamps.h"
 #include "ts_pid.h"
 #include "ts.h"
 
diff --git a/modules/demux/mpeg/ts_hotfixes.c b/modules/demux/mpeg/ts_hotfixes.c
index 206537470f..15d7cb15d8 100644
--- a/modules/demux/mpeg/ts_hotfixes.c
+++ b/modules/demux/mpeg/ts_hotfixes.c
@@ -82,7 +82,7 @@ void ProbePES( demux_t *p_demux, ts_pid_t *pid, const uint8_t *p_pesstart, size_
         return;
 
     size_t i_pesextoffset = 8;
-    mtime_t i_dts = -1;
+    stime_t i_dts = -1;
     if( p_pes[7] & 0x80 ) // PTS
     {
         i_pesextoffset += 5;
diff --git a/modules/demux/mpeg/ts_pid.c b/modules/demux/mpeg/ts_pid.c
index df12dcae97..326a5d5790 100644
--- a/modules/demux/mpeg/ts_pid.c
+++ b/modules/demux/mpeg/ts_pid.c
@@ -25,6 +25,7 @@
 
 #include "ts_pid.h"
 #include "ts_streams.h"
+#include "timestamps.h"
 
 #include "ts.h"
 
diff --git a/modules/demux/mpeg/ts_psip.c b/modules/demux/mpeg/ts_psip.c
index 057a64eac3..a41e6bc13a 100644
--- a/modules/demux/mpeg/ts_psip.c
+++ b/modules/demux/mpeg/ts_psip.c
@@ -43,6 +43,7 @@
 #include "ts_decoders.h"
 #include "ts_psip_dvbpsi_fixes.h"
 
+#include "timestamps.h"
 #include "ts_pid.h"
 #include "ts.h"
 #include "ts_streams_private.h"
diff --git a/modules/demux/mpeg/ts_scte.c b/modules/demux/mpeg/ts_scte.c
index 1ea0b569a1..ed854bde5c 100644
--- a/modules/demux/mpeg/ts_scte.c
+++ b/modules/demux/mpeg/ts_scte.c
@@ -61,7 +61,7 @@ void SCTE18_Section_Callback( dvbpsi_t *p_handle, const dvbpsi_psi_section_t* p_
                 continue;
 
             const ts_pmt_t *p_pmt = p_es->p_program;
-            const mtime_t i_date = TimeStampWrapAround( p_pmt->pcr.i_first, p_pmt->pcr.i_current );
+            const stime_t i_date = TimeStampWrapAround( p_pmt->pcr.i_first, p_pmt->pcr.i_current );
             block_t *p_block = block_Alloc( p_section->p_payload_end - p_section->p_payload_start );
             memcpy( p_block->p_buffer, p_section->p_payload_start, i_payload );
             p_block->i_dts = p_block->i_pts = FROM_SCALE( i_date );
diff --git a/modules/demux/mpeg/ts_streams.c b/modules/demux/mpeg/ts_streams.c
index f3ff180240..755a451d4a 100644
--- a/modules/demux/mpeg/ts_streams.c
+++ b/modules/demux/mpeg/ts_streams.c
@@ -131,7 +131,7 @@ ts_pmt_t *ts_pmt_New( demux_t *p_demux )
     pmt->pcr.i_current = -1;
     pmt->pcr.i_first  = -1;
     pmt->pcr.b_disable = false;
-    pmt->pcr.i_first_dts = VLC_TS_INVALID;
+    pmt->pcr.i_first_dts = -1;
     pmt->pcr.i_pcroffset = -1;
 
     pmt->pcr.b_fix_done = false;
diff --git a/modules/demux/mpeg/ts_streams_private.h b/modules/demux/mpeg/ts_streams_private.h
index 478ffb4057..0b02911123 100644
--- a/modules/demux/mpeg/ts_streams_private.h
+++ b/modules/demux/mpeg/ts_streams_private.h
@@ -23,6 +23,7 @@ typedef struct dvbpsi_s dvbpsi_t;
 typedef struct ts_sections_processor_t ts_sections_processor_t;
 
 #include "mpeg4_iod.h"
+#include "timestamps.h"
 
 #include <vlc_common.h>
 #include <vlc_es.h>
@@ -57,11 +58,11 @@ struct ts_pmt_t
 
     struct
     {
-        mtime_t i_current;
-        mtime_t i_first; // seen <> != -1
+        stime_t i_current;
+        stime_t i_first; // seen <> != -1
         /* broken PCR handling */
-        mtime_t i_first_dts;
-        mtime_t i_pcroffset;
+        stime_t i_first_dts;
+        stime_t i_pcroffset;
         bool    b_disable; /* ignore PCR field, use dts */
         bool    b_fix_done;
     } pcr;
@@ -72,7 +73,7 @@ struct ts_pmt_t
         time_t i_event_length;
     } eit;
 
-    mtime_t i_last_dts;
+    stime_t i_last_dts;
     uint64_t i_last_dts_byte;
 
     /* ARIB specific */



More information about the vlc-commits mailing list