[vlc-devel] commit: Used VLC_TS_INVALID/0 in PS demuxer. (Laurent Aimar )

git version control git at videolan.org
Mon Dec 21 00:02:34 CET 2009


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Dec 20 21:19:11 2009 +0100| [b4493aebb15e58455854481836c5c145a5c92b4a] | committer: Laurent Aimar 

Used VLC_TS_INVALID/0 in PS demuxer.

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

 modules/demux/ps.c |    6 +++---
 modules/demux/ps.h |   28 ++++++++++++++++------------
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/modules/demux/ps.c b/modules/demux/ps.c
index 610d424..761e99f 100644
--- a/modules/demux/ps.c
+++ b/modules/demux/ps.c
@@ -397,8 +397,8 @@ static int Demux( demux_t *p_demux )
                 p_sys->i_scr = -1;
             }
 
-            if( p_sys->i_scr > 0 )
-                es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_scr );
+            if( p_sys->i_scr >= 0 )
+                es_out_Control( p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + p_sys->i_scr );
 
             p_sys->i_scr = -1;
 
@@ -411,7 +411,7 @@ static int Demux( demux_t *p_demux )
             {
                 if( !b_new && !p_sys->b_have_pack &&
                     (tk->fmt.i_cat == AUDIO_ES) &&
-                    (p_pkt->i_pts > 0) )
+                    (p_pkt->i_pts > VLC_TS_INVALID) )
                 {
                     /* A hack to sync the A/V on PES files. */
                     msg_Dbg( p_demux, "force SCR: %"PRId64, p_pkt->i_pts );
diff --git a/modules/demux/ps.h b/modules/demux/ps.h
index a4e1760..3edca03 100644
--- a/modules/demux/ps.h
+++ b/modules/demux/ps.h
@@ -399,6 +399,8 @@ static inline int ps_pkt_parse_pes( block_t *p_pes, int i_skip_extra )
 {
     uint8_t header[34];
     unsigned int i_skip  = 0;
+    int64_t i_pts = -1;
+    int64_t i_dts = -1;
 
     memcpy( header, p_pes->p_buffer, __MIN( p_pes->i_buffer, 34 ) );
 
@@ -423,19 +425,19 @@ static inline int ps_pkt_parse_pes( block_t *p_pes, int i_skip_extra )
 
                 if( header[7]&0x80 )    /* has pts */
                 {
-                    p_pes->i_pts = ((mtime_t)(header[ 9]&0x0e ) << 29)|
-                                    (mtime_t)(header[10] << 22)|
-                                   ((mtime_t)(header[11]&0xfe) << 14)|
-                                    (mtime_t)(header[12] << 7)|
-                                    (mtime_t)(header[13] >> 1);
+                    i_pts = ((mtime_t)(header[ 9]&0x0e ) << 29)|
+                             (mtime_t)(header[10] << 22)|
+                            ((mtime_t)(header[11]&0xfe) << 14)|
+                             (mtime_t)(header[12] << 7)|
+                             (mtime_t)(header[13] >> 1);
 
                     if( header[7]&0x40 )    /* has dts */
                     {
-                         p_pes->i_dts = ((mtime_t)(header[14]&0x0e ) << 29)|
-                                         (mtime_t)(header[15] << 22)|
-                                        ((mtime_t)(header[16]&0xfe) << 14)|
-                                         (mtime_t)(header[17] << 7)|
-                                         (mtime_t)(header[18] >> 1);
+                         i_dts = ((mtime_t)(header[14]&0x0e ) << 29)|
+                                  (mtime_t)(header[15] << 22)|
+                                 ((mtime_t)(header[16]&0xfe) << 14)|
+                                  (mtime_t)(header[17] << 7)|
+                                  (mtime_t)(header[18] >> 1);
                     }
                 }
             }
@@ -499,8 +501,10 @@ static inline int ps_pkt_parse_pes( block_t *p_pes, int i_skip_extra )
     p_pes->p_buffer += i_skip;
     p_pes->i_buffer -= i_skip;
 
-    p_pes->i_dts = 100 * p_pes->i_dts / 9;
-    p_pes->i_pts = 100 * p_pes->i_pts / 9;
+    if( i_dts >= 0 )
+        p_pes->i_dts = VLC_TS_0 + 100 * i_dts / 9;
+    if( i_pts >= 0 )
+        p_pes->i_pts = VLC_TS_0 + 100 * i_pts / 9;
 
     return VLC_SUCCESS;
 }




More information about the vlc-devel mailing list