changeset 1124:0e95f30ffd4c

-frames and -benchmark options to make chl & gabucino happy
author arpi_esp
date Wed, 13 Jun 2001 21:55:24 +0000
parents 5b69dabe5823
children 3ec8f4779e81
files cfg-mplayer.h mplayer.c
diffstat 2 files changed, 36 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-mplayer.h	Wed Jun 13 16:12:14 2001 +0000
+++ b/cfg-mplayer.h	Wed Jun 13 21:55:24 2001 +0000
@@ -96,6 +96,9 @@
 	{"framedrop", &frame_dropping, CONF_TYPE_FLAG, 0, 0, 1},
 	{"hardframedrop", &frame_dropping, CONF_TYPE_FLAG, 0, 0, 2},
 	{"noframedrop", &frame_dropping, CONF_TYPE_FLAG, 0, 1, 0},
+
+	{"frames", &play_n_frames, CONF_TYPE_INT, CONF_MIN, 0, 0},
+	{"benchmark", &benchmark, CONF_TYPE_FLAG, 0, 0, 1},
 	
 	{"aid", &audio_id, CONF_TYPE_INT, CONF_RANGE, 0, 256},
 	{"vid", &video_id, CONF_TYPE_INT, CONF_RANGE, 0, 256},
--- a/mplayer.c	Wed Jun 13 16:12:14 2001 +0000
+++ b/mplayer.c	Wed Jun 13 21:55:24 2001 +0000
@@ -281,6 +281,12 @@
 static vo_functions_t *video_out=NULL;
 static ao_functions_t *audio_out=NULL;
 
+double video_time_usage=0;
+double vout_time_usage=0;
+double audio_time_usage=0;
+int total_time_usage_start=0;
+int benchmark=0;
+
 static int play_in_bg=0;
 
 extern void avi_fixate();
@@ -294,6 +300,8 @@
 
 void exit_player(char* how){
 
+ total_time_usage_start=GetTimer()-total_time_usage_start;
+
 #ifdef HAVE_GUI
  if ( !nogui )
   {
@@ -309,6 +317,20 @@
 
   if(how) printf("\nExiting... (%s)\n",how);
   if(verbose) printf("max framesize was %d bytes\n",max_framesize);
+  if(benchmark){
+      double tot=video_time_usage+vout_time_usage+audio_time_usage;
+      double total_time_usage=(float)total_time_usage_start*0.000001;
+      printf("BENCHMARKs: V:%8.3fs VO:%8.3fs A:%8.3fs Sys:%8.3fs = %8.3fs\n",
+          video_time_usage,vout_time_usage,audio_time_usage,
+	  total_time_usage-tot,total_time_usage);
+      if(total_time_usage>0.0)
+      printf("BENCHMARK%%: V:%8.4f%% VO:%8.4f%% A:%8.4f%% Sys:%8.4f%% = %8.4f%%\n",
+          100.0*video_time_usage/total_time_usage,
+	  100.0*vout_time_usage/total_time_usage,
+	  100.0*audio_time_usage/total_time_usage,
+	  100.0*(total_time_usage-tot)/total_time_usage,
+	  100.0);
+  }
   // restore terminal:
   #ifdef HAVE_GUI
    if ( nogui )
@@ -401,6 +423,7 @@
 int force_srate=0;
 float audio_delay=0;
 int frame_dropping=0; // option  0=no drop  1= drop vo  2= drop decode
+int play_n_frames=-1;
 
 // screen info:
 char* video_driver=NULL; //"mga"; // default
@@ -1355,9 +1378,6 @@
 int eof=0;
 int force_redraw=0;
 float num_frames=0;      // number of frames played
-double video_time_usage=0;
-double vout_time_usage=0;
-double audio_time_usage=0;
 int grab_frames=0;
 char osd_text_buffer[64];
 int drop_frame=0;
@@ -1474,6 +1494,8 @@
 
 InitTimer();
 
+total_time_usage_start=GetTimer();
+
 while(!eof){
 
 /*========================== PLAY AUDIO ============================*/
@@ -1791,7 +1813,9 @@
 	      if (verbose>0) printf("\nframe drop %d, %.2f\n", drop_frame, time_frame);
 	  }
       } else {
-          if(time_frame<-3*frame_time || time_frame>3*frame_time) time_frame=0;
+          if( (time_frame<-3*frame_time || time_frame>3*frame_time) || benchmark)
+	      time_frame=0;
+	  
       }
 
       if(verbose>1)printf("sleep: %5.3f  a:%6.3f  v:%6.3f  \n",time_frame,a_frame,v_frame);
@@ -1812,6 +1836,11 @@
 
     current_module=NULL;
     
+    if(play_n_frames>=0){
+      --play_n_frames;
+      if(play_n_frames<0) exit_player("Requested number of frames played");
+    }
+    
     if(eof) break;
     if(force_redraw){
       --force_redraw;