changeset 21978:1dbe952f3b56

set priv->last_pts to the pts read only if the pts was really read; patch by zaek7q gmx net (Christian Aistleitner)
author nicodvb
date Mon, 22 Jan 2007 22:24:50 +0000
parents cea0eb833758
children 20a9ec250b4f
files libmpdemux/demux_mpg.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mpg.c	Mon Jan 22 08:02:06 2007 +0000
+++ b/libmpdemux/demux_mpg.c	Mon Jan 22 22:24:50 2007 +0000
@@ -190,6 +190,7 @@
 static int demux_mpg_read_packet(demuxer_t *demux,int id){
   int d;
   int len;
+  int set_pts=0; // !=0 iff pts has been set to a proper value
   unsigned char c=0;
   unsigned long long pts=0;
   unsigned long long dts=0;
@@ -241,12 +242,14 @@
   // Read System-1 stream timestamps:
   if((c>>4)==2){
     pts=read_mpeg_timestamp(demux->stream,c);
+    set_pts=1;
     len-=4;
   } else
   if((c>>4)==3){
     pts=read_mpeg_timestamp(demux->stream,c);
     c=stream_read_char(demux->stream);
     if((c>>4)!=1) pts=0; //printf("{ERROR4}");
+    else set_pts = 1;
     dts=read_mpeg_timestamp(demux->stream,c);
     len-=4+1+4;
   } else
@@ -264,11 +267,13 @@
     if(pts_flags==2 && hdrlen>=5){
       c=stream_read_char(demux->stream);
       pts=read_mpeg_timestamp(demux->stream,c);
+      set_pts=1;
       len-=5;hdrlen-=5;
     } else
     if(pts_flags==3 && hdrlen>=10){
       c=stream_read_char(demux->stream);
       pts=read_mpeg_timestamp(demux->stream,c);
+      set_pts=1;
       c=stream_read_char(demux->stream);
       dts=read_mpeg_timestamp(demux->stream,c);
       len-=10;hdrlen-=10;
@@ -467,7 +472,7 @@
     if(ds == demux->video && stream_control(demux->stream, STREAM_CTRL_GET_CURRENT_TIME,(void *)&stream_pts)!=STREAM_UNSUPORTED)
       dp->stream_pts = stream_pts;
     ds_add_packet(ds,dp);
-    if (demux->priv) ((mpg_demuxer_t*)demux->priv)->last_pts = pts/90000.0f;
+    if (demux->priv && set_pts) ((mpg_demuxer_t*)demux->priv)->last_pts = pts/90000.0f;
 //    if(ds==demux->sub) parse_dvdsub(ds->last->buffer,ds->last->len);
     return 1;
   }