[MPlayer-dev-eng] [PATCH] make ID_LENGTH float instead of int

Oded Shimon ods15 at ods15.dyndns.org
Sat Aug 27 21:08:08 CEST 2005


On Sat, Aug 27, 2005 at 10:02:50PM +0300, Oded Shimon wrote:
> This patch makes mplayer -identify show accurate ID_LENGTH in float instead 
> of int. Works for me, I only tested a few demuxers. Any objections? I'll 
> commit tommorrow.
> 
> BTW, could someone tell me why we have the slave command 'get_time_length'? 
> It's identical to -identify's ID_LENGTH, and IMO is also more appropiatte 
> there than a slave command.

sigh

I think reimar is contageous (sp?)
-------------- next part --------------
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.861
diff -u -r1.861 mplayer.c
--- mplayer.c	23 Aug 2005 07:56:29 -0000	1.861
+++ mplayer.c	27 Aug 2005 18:45:14 -0000
@@ -2025,7 +2025,7 @@
     mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_AUDIO_RATE=%d\n", sh_audio->samplerate);
     mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_AUDIO_NCH=%d\n", sh_audio->channels);
   }
-  mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_LENGTH=%ld\n", demuxer_get_time_length(demuxer));
+  mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_LENGTH=%.5lf\n", demuxer_get_time_length(demuxer));
 }
 
 if(!sh_video) goto main; // audio-only
@@ -3608,7 +3608,7 @@
 	break;
 	
     case MP_CMD_GET_TIME_LENGTH : {
-	mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_LENGTH=%ld\n", demuxer_get_time_length(demuxer));
+	mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_LENGTH=%.5lf\n", demuxer_get_time_length(demuxer));
     } break;
 
 	case MP_CMD_GET_VO_FULLSCREEN : {
@@ -4001,7 +4001,7 @@
 	}
 	if ( sh_video ) guiIntfStruct.TimeSec=sh_video->pts;
 	  else if ( sh_audio ) guiIntfStruct.TimeSec=sh_audio->delay;
-	guiIntfStruct.LengthInSec=demuxer_get_time_length(demuxer);
+	guiIntfStruct.LengthInSec=(int)demuxer_get_time_length(demuxer);
 	guiGetEvent( guiReDraw,NULL );
 	guiGetEvent( guiSetVolume,NULL );
 	if(guiIntfStruct.Playing==0) break; // STOP
Index: libmpdemux/demux_asf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_asf.c,v
retrieving revision 1.33
diff -u -r1.33 demux_asf.c
--- libmpdemux/demux_asf.c	5 Aug 2005 19:57:46 -0000	1.33
+++ libmpdemux/demux_asf.c	27 Aug 2005 18:45:15 -0000
@@ -422,7 +422,7 @@
 */
     switch(cmd) {
 	case DEMUXER_CTRL_GET_TIME_LENGTH:
-	    *((unsigned long *)arg)=(unsigned long)(asf_movielength);
+	    *((double *)arg)=(double)(asf_movielength);
 	    return DEMUXER_CTRL_OK;
 
 	case DEMUXER_CTRL_GET_PERCENT_POS:
Index: libmpdemux/demux_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_audio.c,v
retrieving revision 1.37
diff -u -r1.37 demux_audio.c
--- libmpdemux/demux_audio.c	5 Aug 2005 19:57:46 -0000	1.37
+++ libmpdemux/demux_audio.c	27 Aug 2005 18:45:15 -0000
@@ -543,7 +543,7 @@
     switch(cmd) {
 	case DEMUXER_CTRL_GET_TIME_LENGTH:
 	    if (audio_length<=0) return DEMUXER_CTRL_DONTKNOW;
-	    *((unsigned long *)arg)=(unsigned long)audio_length;
+	    *((double *)arg)=(double)audio_length;
 	    return DEMUXER_CTRL_GUESS;
 
 	case DEMUXER_CTRL_GET_PERCENT_POS:
Index: libmpdemux/demux_avi.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_avi.c,v
retrieving revision 1.65
diff -u -r1.65 demux_avi.c
--- libmpdemux/demux_avi.c	13 Aug 2005 12:20:07 -0000	1.65
+++ libmpdemux/demux_avi.c	27 Aug 2005 18:45:16 -0000
@@ -850,7 +850,7 @@
     switch(cmd) {
 	case DEMUXER_CTRL_GET_TIME_LENGTH:
     	    if (!priv->numberofframes) return DEMUXER_CTRL_DONTKNOW;
-	    *((unsigned long *)arg)=priv->numberofframes/sh_video->fps;
+	    *((double *)arg)=(double)priv->numberofframes/sh_video->fps;
 	    if (sh_video->video.dwLength<=1) return DEMUXER_CTRL_GUESS;
 	    return DEMUXER_CTRL_OK;
 
Index: libmpdemux/demux_avs.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_avs.c,v
retrieving revision 1.5
diff -u -r1.5 demux_avs.c
--- libmpdemux/demux_avs.c	5 Aug 2005 19:57:46 -0000	1.5
+++ libmpdemux/demux_avs.c	27 Aug 2005 18:45:16 -0000
@@ -343,7 +343,7 @@
         case DEMUXER_CTRL_GET_TIME_LENGTH:
         {
             if (!AVS->video_info->num_frames) return DEMUXER_CTRL_DONTKNOW;
-            *((unsigned long *)arg) = AVS->video_info->num_frames / sh_video->fps;
+            *((double *)arg) = (double)AVS->video_info->num_frames / sh_video->fps;
             return DEMUXER_CTRL_OK;
         }
         case DEMUXER_CTRL_GET_PERCENT_POS:
Index: libmpdemux/demux_lavf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_lavf.c,v
retrieving revision 1.20
diff -u -r1.20 demux_lavf.c
--- libmpdemux/demux_lavf.c	5 Aug 2005 19:57:46 -0000	1.20
+++ libmpdemux/demux_lavf.c	27 Aug 2005 18:45:17 -0000
@@ -402,7 +402,7 @@
 	    if (priv->avfc->duration == 0)
 	        return DEMUXER_CTRL_DONTKNOW;
 	    
-	    *((unsigned long *)arg) = priv->avfc->duration / AV_TIME_BASE;
+	    *((double *)arg) = (double)priv->avfc->duration / AV_TIME_BASE;
 	    return DEMUXER_CTRL_OK;
 
 	case DEMUXER_CTRL_GET_PERCENT_POS:
Index: libmpdemux/demux_mkv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mkv.c,v
retrieving revision 1.47
diff -u -r1.47 demux_mkv.c
--- libmpdemux/demux_mkv.c	24 Aug 2005 12:33:32 -0000	1.47
+++ libmpdemux/demux_mkv.c	27 Aug 2005 18:45:19 -0000
@@ -3280,7 +3280,7 @@
       if (mkv_d->duration == 0)
         return DEMUXER_CTRL_DONTKNOW;
 
-      *((unsigned long *)arg) = (unsigned long)mkv_d->duration;
+      *((double *)arg) = (double)mkv_d->duration;
       return DEMUXER_CTRL_OK;
 
     case DEMUXER_CTRL_GET_PERCENT_POS:
Index: libmpdemux/demux_mov.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mov.c,v
retrieving revision 1.126
diff -u -r1.126 demux_mov.c
--- libmpdemux/demux_mov.c	5 Aug 2005 19:57:46 -0000	1.126
+++ libmpdemux/demux_mov.c	27 Aug 2005 18:45:20 -0000
@@ -2000,7 +2000,7 @@
     case DEMUXER_CTRL_GET_TIME_LENGTH:
       if (!track->timescale)
         return DEMUXER_CTRL_DONTKNOW;
-      *((unsigned long *)arg) = track->length / track->timescale;
+      *((double *)arg) = (double)track->length / track->timescale;
       return DEMUXER_CTRL_OK;
 
     case DEMUXER_CTRL_GET_PERCENT_POS:
Index: libmpdemux/demux_mpg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mpg.c,v
retrieving revision 1.62
diff -u -r1.62 demux_mpg.c
--- libmpdemux/demux_mpg.c	26 Aug 2005 22:53:59 -0000	1.62
+++ libmpdemux/demux_mpg.c	27 Aug 2005 18:45:21 -0000
@@ -751,7 +751,7 @@
     switch(cmd) {
 	case DEMUXER_CTRL_GET_TIME_LENGTH:
             if (mpg_d && mpg_d->has_valid_timestamps) {
-              *((unsigned long *)arg)=(long)mpg_d->final_pts;
+              *((double *)arg)=(double)mpg_d->final_pts;
               return DEMUXER_CTRL_GUESS;
             }
     		return DEMUXER_CTRL_DONTKNOW;
Index: libmpdemux/demux_ogg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_ogg.c,v
retrieving revision 1.76
diff -u -r1.76 demux_ogg.c
--- libmpdemux/demux_ogg.c	5 Aug 2005 19:57:46 -0000	1.76
+++ libmpdemux/demux_ogg.c	27 Aug 2005 18:45:23 -0000
@@ -1605,7 +1605,7 @@
     switch(cmd) {
 	case DEMUXER_CTRL_GET_TIME_LENGTH:
 	    if (ogg_d->final_granulepos<=0) return DEMUXER_CTRL_DONTKNOW;
-	    *((unsigned long *)arg)=ogg_d->final_granulepos / rate;
+	    *((double *)arg)=(double)ogg_d->final_granulepos / rate;
 	    return DEMUXER_CTRL_GUESS;
 
 	case DEMUXER_CTRL_GET_PERCENT_POS:
Index: libmpdemux/demux_rawdv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_rawdv.c,v
retrieving revision 1.10
diff -u -r1.10 demux_rawdv.c
--- libmpdemux/demux_rawdv.c	5 Aug 2005 19:57:46 -0000	1.10
+++ libmpdemux/demux_rawdv.c	27 Aug 2005 18:45:24 -0000
@@ -234,7 +234,7 @@
 
     switch(cmd) {
         case DEMUXER_CTRL_GET_TIME_LENGTH:
-            *((unsigned long *)arg)=frames->frame_number / sh_video->fps;
+            *((double *)arg)=(double)frames->frame_number / sh_video->fps;
             return DEMUXER_CTRL_OK;
 
         case DEMUXER_CTRL_GET_PERCENT_POS:
Index: libmpdemux/demux_real.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_real.c,v
retrieving revision 1.72
diff -u -r1.72 demux_real.c
--- libmpdemux/demux_real.c	5 Aug 2005 19:57:46 -0000	1.72
+++ libmpdemux/demux_real.c	27 Aug 2005 18:45:25 -0000
@@ -1855,7 +1855,7 @@
 	    if (priv->duration == 0)
 	        return DEMUXER_CTRL_DONTKNOW;
 	    
-	    *((unsigned long *)arg) = priv->duration;
+	    *((double *)arg) = (double)priv->duration;
 	    return DEMUXER_CTRL_OK;
 
 	case DEMUXER_CTRL_GET_PERCENT_POS:
Index: libmpdemux/demux_ty.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_ty.c,v
retrieving revision 1.7
diff -u -r1.7 demux_ty.c
--- libmpdemux/demux_ty.c	5 Aug 2005 19:57:47 -0000	1.7
+++ libmpdemux/demux_ty.c	27 Aug 2005 18:45:26 -0000
@@ -1350,8 +1350,8 @@
 	   case DEMUXER_CTRL_GET_TIME_LENGTH:
 	      if(!sh_video->i_bps)  // unspecified or VBR 
     		   return DEMUXER_CTRL_DONTKNOW;
-	      *((unsigned long *)arg)=
-            (demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps;
+	      *((double *)arg)=
+            ((double)demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps;
 	      return DEMUXER_CTRL_GUESS;
 
 	   case DEMUXER_CTRL_GET_PERCENT_POS:
Index: libmpdemux/demux_xmms.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_xmms.c,v
retrieving revision 1.11
diff -u -r1.11 demux_xmms.c
--- libmpdemux/demux_xmms.c	5 Aug 2005 19:57:47 -0000	1.11
+++ libmpdemux/demux_xmms.c	27 Aug 2005 18:45:26 -0000
@@ -341,7 +341,7 @@
     switch(cmd) {
 	case DEMUXER_CTRL_GET_TIME_LENGTH:
 	    if (xmms_length<=0) return DEMUXER_CTRL_DONTKNOW;
-	    *((unsigned long *)arg)=(unsigned long)xmms_length/1000;
+	    *((double *)arg)=(double)xmms_length/1000;
 	    return DEMUXER_CTRL_GUESS;
 
 	case DEMUXER_CTRL_GET_PERCENT_POS:
Index: libmpdemux/demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.199
diff -u -r1.199 demuxer.c
--- libmpdemux/demuxer.c	26 Aug 2005 17:40:01 -0000	1.199
+++ libmpdemux/demuxer.c	27 Aug 2005 18:45:27 -0000
@@ -895,13 +895,13 @@
 
 
 
-unsigned long demuxer_get_time_length(demuxer_t *demuxer){     
-    unsigned long get_time_ans;     
+double demuxer_get_time_length(demuxer_t *demuxer){
+    double 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;
+        get_time_ans = (double)(demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps;
       else
         get_time_ans=0;     
     }
Index: libmpdemux/demuxer.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.h,v
retrieving revision 1.80
diff -u -r1.80 demuxer.h
--- libmpdemux/demuxer.h	26 Aug 2005 17:40:02 -0000	1.80
+++ libmpdemux/demuxer.h	27 Aug 2005 18:45:30 -0000
@@ -320,7 +320,7 @@
 
 #endif
 
-extern unsigned long demuxer_get_time_length(demuxer_t *demuxer);
+extern double demuxer_get_time_length(demuxer_t *demuxer);
 extern int demuxer_get_percent_pos(demuxer_t *demuxer);
 extern int demuxer_switch_audio(demuxer_t *demuxer, int index);
 


More information about the MPlayer-dev-eng mailing list