Index: gstmpegdemux.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mpegdemux/gstmpegdemux.c,v
retrieving revision 1.7
diff -u -r1.7 gstmpegdemux.c
--- gstmpegdemux.c	20 Oct 2008 14:19:17 -0000	1.7
+++ gstmpegdemux.c	20 Oct 2008 22:26:16 -0000
@@ -55,7 +55,7 @@
 
 /* We clamp scr delta with 0 so negative bytes won't be possible */
 #define GSTTIME_TO_BYTES(time) \
-  ((time != -1) ? gst_util_uint64_scale (MAX(0,(gint64) (GSTTIME_TO_MPEGTIME(time) - demux->first_scr)), demux->scr_rate_n, demux->scr_rate_d) : -1)
+  ((time != -1) ? gst_util_uint64_scale (MAX(0,(gint64) GSTTIME_TO_MPEGTIME(time)), demux->scr_rate_n, demux->scr_rate_d) : -1)
 #define BYTES_TO_GSTTIME(bytes) ((bytes != -1) ? MPEGTIME_TO_GSTTIME(gst_util_uint64_scale (bytes, demux->scr_rate_d, demux->scr_rate_n)) : -1)
 
 #define ADAPTER_OFFSET_FLUSH(_bytes_) demux->adapter_offset += (_bytes_)
@@ -444,7 +444,7 @@
 
   /* timestamps */
   if (demux->next_pts != G_MAXUINT64)
-    timestamp = MPEGTIME_TO_GSTTIME (demux->next_pts);
+    timestamp = MPEGTIME_TO_GSTTIME (demux->next_pts - demux->first_scr);
   else
     timestamp = GST_CLOCK_TIME_NONE;
 
@@ -453,21 +453,19 @@
     gint64 time, start, stop;
     GstEvent *newsegment;
 
-    GST_DEBUG ("timestamp:%" GST_TIME_FORMAT " base_time %" GST_TIME_FORMAT
+    GST_DEBUG ("timestamp:%" GST_TIME_FORMAT
         " src_segment.start:%" GST_TIME_FORMAT " .stop:%" GST_TIME_FORMAT,
-        GST_TIME_ARGS (timestamp), GST_TIME_ARGS (demux->base_time),
+        GST_TIME_ARGS (timestamp),
         GST_TIME_ARGS (demux->src_segment.start),
         GST_TIME_ARGS (demux->src_segment.stop));
 
-    if (GST_CLOCK_TIME_IS_VALID (demux->base_time) &&
-        GST_CLOCK_TIME_IS_VALID (demux->src_segment.start))
-      start = demux->base_time + demux->src_segment.start;
+    if (GST_CLOCK_TIME_IS_VALID (demux->src_segment.start))
+      start = demux->src_segment.start;
     else
       start = 0;
 
-    if (GST_CLOCK_TIME_IS_VALID (demux->src_segment.stop) &&
-        GST_CLOCK_TIME_IS_VALID (demux->base_time))
-      stop = demux->base_time + demux->src_segment.stop;
+    if (GST_CLOCK_TIME_IS_VALID (demux->src_segment.stop))
+      stop = demux->src_segment.stop;
     else
       stop = -1;
 
@@ -895,8 +893,7 @@
         goto not_supported;
       }
 
-      position = demux->base_time +
-          MPEGTIME_TO_GSTTIME (demux->current_scr - demux->first_scr);
+      position = MPEGTIME_TO_GSTTIME (demux->current_scr - demux->first_scr);
 
       GST_LOG_OBJECT (demux, "Position at GStreamer Time:%" GST_TIME_FORMAT,
           GST_TIME_ARGS (position));
@@ -1122,7 +1119,6 @@
   if (demux->first_scr == G_MAXUINT64) {
     demux->first_scr = scr;
     demux->first_scr_offset = demux->last_scr_offset;
-    demux->base_time = MPEGTIME_TO_GSTTIME (demux->first_scr);
     /* at begin consider the new_rate as the scr rate, bytes/clock ticks */
     demux->scr_rate_n = new_rate;
     demux->scr_rate_d = CLOCK_FREQ;
@@ -1839,7 +1835,6 @@
       demux->filter.gather_pes = TRUE;
       demux->first_scr = G_MAXUINT64;
       demux->current_scr = G_MAXUINT64;
-      demux->base_time = G_MAXUINT64;
       demux->scr_rate_n = G_MAXUINT64;
       demux->scr_rate_d = G_MAXUINT64;
       break;
@@ -1849,7 +1844,6 @@
       demux->next_pts = G_MAXUINT64;
       demux->next_dts = G_MAXUINT64;
       demux->first_scr = G_MAXUINT64;
-      demux->base_time = G_MAXUINT64;
       demux->scr_rate_n = G_MAXUINT64;
       demux->scr_rate_d = G_MAXUINT64;
       demux->need_no_more_pads = TRUE;
Index: gstmpegdemux.h
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mpegdemux/gstmpegdemux.h,v
retrieving revision 1.1
diff -u -r1.1 gstmpegdemux.h
--- gstmpegdemux.h	2 Sep 2008 12:04:31 -0000	1.1
+++ gstmpegdemux.h	20 Oct 2008 22:26:16 -0000
@@ -104,7 +104,6 @@
   gint64         mux_rate;
   guint64	     first_scr;
   guint64	     first_dts;
-  guint64	     base_time;
   guint64        current_scr;
   guint64        next_scr;
   guint64        bytes_since_scr;
