changeset 29486:a373af1e3b24

Handle demuxers that never set filepos by using stream_tell.
author reimar
date Mon, 17 Aug 2009 05:55:40 +0000
parents d252912eaf5b
children 53ff77686a5c
files libmpdemux/demuxer.c mencoder.c
diffstat 2 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demuxer.c	Mon Aug 17 02:06:00 2009 +0000
+++ b/libmpdemux/demuxer.c	Mon Aug 17 05:55:40 2009 +0000
@@ -242,7 +242,7 @@
     d->movi_end = stream->end_pos;
     d->seekable = 1;
     d->synced = 0;
-    d->filepos = 0;
+    d->filepos = -1;
     d->audio = new_demuxer_stream(d, a_id);
     d->video = new_demuxer_stream(d, v_id);
     d->sub = new_demuxer_stream(d, s_id);
@@ -1262,8 +1262,9 @@
     int res = demux_control(demuxer, DEMUXER_CTRL_GET_PERCENT_POS, &ans);
     int len = (demuxer->movi_end - demuxer->movi_start) / 100;
     if (res <= 0) {
+        off_t pos = demuxer->filepos > 0 ? demuxer->filepos : stream_tell(demuxer->stream);
         if (len > 0)
-            ans = (demuxer->filepos - demuxer->movi_start) / len;
+            ans = (pos - demuxer->movi_start) / len;
         else
             ans = 0;
     }
--- a/mencoder.c	Mon Aug 17 02:06:00 2009 +0000
+++ b/mencoder.c	Mon Aug 17 05:55:40 2009 +0000
@@ -1399,7 +1399,8 @@
 
     {	float t=(GetTimerMS()-timer_start)*0.001f;
 	float len=(demuxer->movi_end-demuxer->movi_start);
-	float p=len>1000 ? (float)(demuxer->filepos-demuxer->movi_start) / len :
+	off_t pos = demuxer->filepos >= 0 ? demuxer->filepos : stream_tell(demuxer->stream);
+	float p=len>1000 ? (float)(pos-demuxer->movi_start) / len :
                 (demuxer_get_percent_pos(demuxer) / 100.0);
 #if 0
 	if(!len && sh_audio && sh_audio->audio.dwLength>100){