changeset 16346:6ff303d2876b

Make -identify's 'ID_LENGTH=' print a float and not an integer.. The accuracey may be totally fake for some demuxers (mpg), but accurate for others.. (avi)
author ods15
date Fri, 02 Sep 2005 08:32:32 +0000
parents feb16d0117c8
children da2926d990ce
files libmpdemux/demux_asf.c libmpdemux/demux_audio.c libmpdemux/demux_avi.c libmpdemux/demux_avs.c libmpdemux/demux_lavf.c libmpdemux/demux_mkv.c libmpdemux/demux_mov.c libmpdemux/demux_mpg.c libmpdemux/demux_ogg.c libmpdemux/demux_rawdv.c libmpdemux/demux_real.c libmpdemux/demux_ty.c libmpdemux/demux_xmms.c libmpdemux/demuxer.c libmpdemux/demuxer.h mplayer.c
diffstat 16 files changed, 20 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_asf.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demux_asf.c	Fri Sep 02 08:32:32 2005 +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:
--- a/libmpdemux/demux_audio.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demux_audio.c	Fri Sep 02 08:32:32 2005 +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:
--- a/libmpdemux/demux_avi.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demux_avi.c	Fri Sep 02 08:32:32 2005 +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;
 
--- a/libmpdemux/demux_avs.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demux_avs.c	Fri Sep 02 08:32:32 2005 +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:
--- a/libmpdemux/demux_lavf.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demux_lavf.c	Fri Sep 02 08:32:32 2005 +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:
--- a/libmpdemux/demux_mkv.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demux_mkv.c	Fri Sep 02 08:32:32 2005 +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:
--- a/libmpdemux/demux_mov.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demux_mov.c	Fri Sep 02 08:32:32 2005 +0000
@@ -2016,7 +2016,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:
--- a/libmpdemux/demux_mpg.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demux_mpg.c	Fri Sep 02 08:32:32 2005 +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;
--- a/libmpdemux/demux_ogg.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demux_ogg.c	Fri Sep 02 08:32:32 2005 +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:
--- a/libmpdemux/demux_rawdv.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demux_rawdv.c	Fri Sep 02 08:32:32 2005 +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:
--- a/libmpdemux/demux_real.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demux_real.c	Fri Sep 02 08:32:32 2005 +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:
--- a/libmpdemux/demux_ty.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demux_ty.c	Fri Sep 02 08:32:32 2005 +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:
--- a/libmpdemux/demux_xmms.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demux_xmms.c	Fri Sep 02 08:32:32 2005 +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:
--- a/libmpdemux/demuxer.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demuxer.c	Fri Sep 02 08:32:32 2005 +0000
@@ -918,13 +918,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;     
     }
--- a/libmpdemux/demuxer.h	Fri Sep 02 08:29:30 2005 +0000
+++ b/libmpdemux/demuxer.h	Fri Sep 02 08:32:32 2005 +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);
 
--- a/mplayer.c	Fri Sep 02 08:29:30 2005 +0000
+++ b/mplayer.c	Fri Sep 02 08:32:32 2005 +0000
@@ -2032,7 +2032,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=%.2lf\n", demuxer_get_time_length(demuxer));
 }
 
 if(!sh_video) goto main; // audio-only
@@ -3615,7 +3615,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=%.2lf\n", demuxer_get_time_length(demuxer));
     } break;
 
 	case MP_CMD_GET_VO_FULLSCREEN : {