[MPlayer-cvslog] CVS: main/libmpdemux demux_asf.c, 1.30, 1.31 demux_avi.c, 1.61, 1.62 demux_mkv.c, 1.33, 1.34 demux_mpg.c, 1.53, 1.54 demux_ty.c, 1.3, 1.4 demuxer.c, 1.180, 1.181

Reimar Döffinger CVS syncmail at mplayerhq.hu
Sat Jan 15 17:11:47 CET 2005


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv21291/libmpdemux

Modified Files:
	demux_asf.c demux_avi.c demux_mkv.c demux_mpg.c demux_ty.c 
	demuxer.c 
Log Message:
Move generic length and percent pos calculation to demuxer.c


Index: demux_asf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_asf.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- demux_asf.c	11 Sep 2004 09:40:34 -0000	1.30
+++ demux_asf.c	15 Jan 2005 16:11:44 -0000	1.31
@@ -423,11 +423,7 @@
 	    return DEMUXER_CTRL_OK;
 
 	case DEMUXER_CTRL_GET_PERCENT_POS:
-	    if (demuxer->movi_end==demuxer->movi_start) {
 		return DEMUXER_CTRL_DONTKNOW;
-	    }
-    	    *((int *)arg)=(int)((demuxer->filepos-demuxer->movi_start)/((demuxer->movi_end-demuxer->movi_start)/100));
-	    return DEMUXER_CTRL_OK;
 
 	default:
 	    return DEMUXER_CTRL_NOTIMPL;

Index: demux_avi.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_avi.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- demux_avi.c	17 Mar 2004 14:50:36 -0000	1.61
+++ demux_avi.c	15 Jan 2005 16:11:44 -0000	1.62
@@ -846,9 +846,7 @@
 
 	case DEMUXER_CTRL_GET_PERCENT_POS:
     	    if (!priv->numberofframes) {
-		if (demuxer->movi_end==demuxer->movi_start) return DEMUXER_CTRL_DONTKNOW;
-		*((int *)arg)=(int)((demuxer->filepos-demuxer->movi_start)/((demuxer->movi_end-demuxer->movi_start)/100));
-		return DEMUXER_CTRL_OK; 
+              return DEMUXER_CTRL_DONTKNOW;
 	    }
 	    *((int *)arg)=(int)(priv->video_pack_no*100/priv->numberofframes);
 	    if (sh_video->video.dwLength<=1) return DEMUXER_CTRL_GUESS;

Index: demux_mkv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mkv.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- demux_mkv.c	13 Jan 2005 21:04:34 -0000	1.33
+++ demux_mkv.c	15 Jan 2005 16:11:44 -0000	1.34
@@ -3328,12 +3328,7 @@
     case DEMUXER_CTRL_GET_PERCENT_POS:
       if (mkv_d->duration == 0)
         {
-          if (demuxer->movi_start == demuxer->movi_end)
             return DEMUXER_CTRL_DONTKNOW;
-
-          *((int *)arg) = (int)((demuxer->filepos - demuxer->movi_start) /
-                                ((demuxer->movi_end-demuxer->movi_start)/100));
-          return DEMUXER_CTRL_OK;
         }
 
       *((int *) arg) = (int) (100 * mkv_d->last_pts / mkv_d->duration);

Index: demux_mpg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mpg.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- demux_mpg.c	8 Jan 2005 10:05:44 -0000	1.53
+++ demux_mpg.c	15 Jan 2005 16:11:44 -0000	1.54
@@ -520,20 +520,14 @@
               *((unsigned long *)arg)=(long)mpg_d->final_pts;
               return DEMUXER_CTRL_GUESS;
             }
-	    if(!sh_video || !sh_video->i_bps)  // unspecified or VBR 
     		return DEMUXER_CTRL_DONTKNOW;
-	    *((unsigned long *)arg)=(demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps;
-	    return DEMUXER_CTRL_GUESS;
 
 	case DEMUXER_CTRL_GET_PERCENT_POS:
-	    if (demuxer->movi_end==demuxer->movi_start) 
-    		return DEMUXER_CTRL_DONTKNOW;
             if (mpg_d && mpg_d->has_valid_timestamps && mpg_d->final_pts > 0.0) {
               *((int *)arg)=(int)(100 * mpg_d->last_pts / mpg_d->final_pts);
               return DEMUXER_CTRL_OK;
             }
-    	    *((int *)arg)=(int)((demuxer->filepos-demuxer->movi_start)/((demuxer->movi_end-demuxer->movi_start)/100));
-	    return DEMUXER_CTRL_OK;
+	    return DEMUXER_CTRL_DONTKNOW;
 
 	default:
 	    return DEMUXER_CTRL_NOTIMPL;

Index: demux_ty.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_ty.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- demux_ty.c	19 Jul 2004 23:17:37 -0000	1.3
+++ demux_ty.c	15 Jan 2005 16:11:44 -0000	1.4
@@ -1027,12 +1027,7 @@
 	      return DEMUXER_CTRL_GUESS;
 
 	   case DEMUXER_CTRL_GET_PERCENT_POS:
-	      if (demuxer->movi_end==demuxer->movi_start) 
     		   return DEMUXER_CTRL_DONTKNOW;
-    	    *((int *)arg)=
-             (int)((demuxer->filepos-demuxer->movi_start)/
-             ((demuxer->movi_end-demuxer->movi_start)/100));
-	       return DEMUXER_CTRL_OK;
 	    default:
 	       return DEMUXER_CTRL_NOTIMPL;
     }

Index: demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -r1.180 -r1.181
--- demuxer.c	29 Dec 2004 19:51:56 -0000	1.180
+++ demuxer.c	15 Jan 2005 16:11:45 -0000	1.181
@@ -1717,7 +1717,12 @@
 
 unsigned long demuxer_get_time_length(demuxer_t *demuxer){     
     unsigned long get_time_ans;     
+    sh_video_t *sh_video = demuxer->video->sh;
+    // <= 0 means DEMUXER_CTRL_NOTIMPL or DEMUXER_CTRL_DONTKNOW
     if (demux_control(demuxer, DEMUXER_CTRL_GET_TIME_LENGTH,(void *)&get_time_ans)<=0)  {
+      if (sh_video && sh_video->i_bps)
+        get_time_ans = (demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps;
+      else
         get_time_ans=0;     
     }
     return get_time_ans;
@@ -1727,9 +1732,14 @@
     int ans = 0;
     int res = demux_control(demuxer, DEMUXER_CTRL_GET_PERCENT_POS, &ans);
     int len = (demuxer->movi_end - demuxer->movi_start) / 100;
-    if (res == DEMUXER_CTRL_NOTIMPL && len > 0)
+    if (res <= 0) {
+      if (len > 0)
       ans = (demuxer->filepos - demuxer->movi_start) / len;
-    if (ans>100 || ans<0) ans=0;
+      else
+       ans = 0;
+    }
+    if (ans < 0) ans = 0;
+    if (ans > 100) ans = 100;
     return ans;
 }
 




More information about the MPlayer-cvslog mailing list