# HG changeset patch # User nicodvb # Date 1169504690 0 # Node ID 1dbe952f3b564391a90903e2985acc24f557c94b # Parent cea0eb8337582912dbb09b1ba0f34c2b0e1b144a set priv->last_pts to the pts read only if the pts was really read; patch by zaek7q gmx net (Christian Aistleitner) diff -r cea0eb833758 -r 1dbe952f3b56 libmpdemux/demux_mpg.c --- 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; }