changeset 21780:c9795699c414

added stream_pts to demuxer_t and demux_packet_t to hold the time value reported by the stream layer
author nicodvb
date Sun, 31 Dec 2006 11:05:26 +0000
parents 2158c95b71f6
children 36112fcf78d6
files libmpdemux/demuxer.c libmpdemux/demuxer.h
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demuxer.c	Sun Dec 31 10:54:32 2006 +0000
+++ b/libmpdemux/demuxer.c	Sun Dec 31 11:05:26 2006 +0000
@@ -184,6 +184,7 @@
   demuxer_t *d=malloc(sizeof(demuxer_t));
   memset(d,0,sizeof(demuxer_t));
   d->stream=stream;
+  d->stream_pts = MP_NOPTS_VALUE;
   d->movi_start=stream->start_pos;
   d->movi_end=stream->end_pos;
   d->seekable=1;
@@ -381,6 +382,7 @@
         ds->pts_bytes=0;
       }
       ds->pts_bytes+=p->len; // !!!
+      if(p->stream_pts != MP_NOPTS_VALUE) demux->stream_pts=p->stream_pts;
       ds->flags=p->flags;
       // unlink packet:
       ds->bytes-=p->len;
@@ -933,9 +935,9 @@
     if(flags & 1)  // absolute seek
       pts = 0.0f;
     else {
-      if(stream_control(demuxer->stream, STREAM_CTRL_GET_CURRENT_TIME, &tmp) == STREAM_UNSUPORTED)
+      if(demuxer->stream_pts == MP_NOPTS_VALUE)
         goto dmx_seek;
-      pts = tmp;
+      pts = demuxer->stream_pts;
     }
 
     if(flags & 2) {  // percent seek
--- a/libmpdemux/demuxer.h	Sun Dec 31 10:54:32 2006 +0000
+++ b/libmpdemux/demuxer.h	Sun Dec 31 11:05:26 2006 +0000
@@ -85,6 +85,7 @@
 typedef struct demux_packet_st {
   int len;
   double pts;
+  double stream_pts;
   off_t pos;  // position in index (AVI) or file (MPG)
   unsigned char* buffer;
   int flags; // keyframe, etc
@@ -176,6 +177,7 @@
   off_t movi_start;
   off_t movi_end;
   stream_t *stream;
+  double stream_pts;       // current stream pts, if applicable (e.g. dvd)
   char *filename; ///< Needed by avs_check_file
   int synced;  // stream synced (used by mpeg)
   int type;    // demuxer type: mpeg PS, mpeg ES, avi, avi-ni, avi-nini, asf
@@ -210,6 +212,7 @@
   // still using 0 by default in case there is some code that uses 0 for both
   // unknown and a valid pts value
   dp->pts=correct_pts ? MP_NOPTS_VALUE : 0;
+  dp->stream_pts = MP_NOPTS_VALUE;
   dp->pos=0;
   dp->flags=0;
   dp->refcount=1;