comparison mplayer.c @ 1124:0e95f30ffd4c

-frames and -benchmark options to make chl & gabucino happy
author arpi_esp
date Wed, 13 Jun 2001 21:55:24 +0000
parents ebb2605b9c60
children 3ec8f4779e81
comparison
equal deleted inserted replaced
1123:5b69dabe5823 1124:0e95f30ffd4c
279 //**************************************************************************// 279 //**************************************************************************//
280 280
281 static vo_functions_t *video_out=NULL; 281 static vo_functions_t *video_out=NULL;
282 static ao_functions_t *audio_out=NULL; 282 static ao_functions_t *audio_out=NULL;
283 283
284 double video_time_usage=0;
285 double vout_time_usage=0;
286 double audio_time_usage=0;
287 int total_time_usage_start=0;
288 int benchmark=0;
289
284 static int play_in_bg=0; 290 static int play_in_bg=0;
285 291
286 extern void avi_fixate(); 292 extern void avi_fixate();
287 293
288 #ifdef HAVE_GUI 294 #ifdef HAVE_GUI
291 #else 297 #else
292 #define GUI_MSG(x) 298 #define GUI_MSG(x)
293 #endif 299 #endif
294 300
295 void exit_player(char* how){ 301 void exit_player(char* how){
302
303 total_time_usage_start=GetTimer()-total_time_usage_start;
296 304
297 #ifdef HAVE_GUI 305 #ifdef HAVE_GUI
298 if ( !nogui ) 306 if ( !nogui )
299 { 307 {
300 if ( how != NULL ) 308 if ( how != NULL )
307 } 315 }
308 #endif 316 #endif
309 317
310 if(how) printf("\nExiting... (%s)\n",how); 318 if(how) printf("\nExiting... (%s)\n",how);
311 if(verbose) printf("max framesize was %d bytes\n",max_framesize); 319 if(verbose) printf("max framesize was %d bytes\n",max_framesize);
320 if(benchmark){
321 double tot=video_time_usage+vout_time_usage+audio_time_usage;
322 double total_time_usage=(float)total_time_usage_start*0.000001;
323 printf("BENCHMARKs: V:%8.3fs VO:%8.3fs A:%8.3fs Sys:%8.3fs = %8.3fs\n",
324 video_time_usage,vout_time_usage,audio_time_usage,
325 total_time_usage-tot,total_time_usage);
326 if(total_time_usage>0.0)
327 printf("BENCHMARK%%: V:%8.4f%% VO:%8.4f%% A:%8.4f%% Sys:%8.4f%% = %8.4f%%\n",
328 100.0*video_time_usage/total_time_usage,
329 100.0*vout_time_usage/total_time_usage,
330 100.0*audio_time_usage/total_time_usage,
331 100.0*(total_time_usage-tot)/total_time_usage,
332 100.0);
333 }
312 // restore terminal: 334 // restore terminal:
313 #ifdef HAVE_GUI 335 #ifdef HAVE_GUI
314 if ( nogui ) 336 if ( nogui )
315 #endif 337 #endif
316 getch2_disable(); 338 getch2_disable();
399 421
400 float force_fps=0; 422 float force_fps=0;
401 int force_srate=0; 423 int force_srate=0;
402 float audio_delay=0; 424 float audio_delay=0;
403 int frame_dropping=0; // option 0=no drop 1= drop vo 2= drop decode 425 int frame_dropping=0; // option 0=no drop 1= drop vo 2= drop decode
426 int play_n_frames=-1;
404 427
405 // screen info: 428 // screen info:
406 char* video_driver=NULL; //"mga"; // default 429 char* video_driver=NULL; //"mga"; // default
407 char* audio_driver=NULL; 430 char* audio_driver=NULL;
408 int fullscreen=0; 431 int fullscreen=0;
1353 float c_total=0; 1376 float c_total=0;
1354 float max_pts_correction=0;//default_max_pts_correction; 1377 float max_pts_correction=0;//default_max_pts_correction;
1355 int eof=0; 1378 int eof=0;
1356 int force_redraw=0; 1379 int force_redraw=0;
1357 float num_frames=0; // number of frames played 1380 float num_frames=0; // number of frames played
1358 double video_time_usage=0;
1359 double vout_time_usage=0;
1360 double audio_time_usage=0;
1361 int grab_frames=0; 1381 int grab_frames=0;
1362 char osd_text_buffer[64]; 1382 char osd_text_buffer[64];
1363 int drop_frame=0; 1383 int drop_frame=0;
1364 int drop_frame_cnt=0; 1384 int drop_frame_cnt=0;
1365 1385
1471 } 1491 }
1472 1492
1473 printf("Start playing...\n");fflush(stdout); 1493 printf("Start playing...\n");fflush(stdout);
1474 1494
1475 InitTimer(); 1495 InitTimer();
1496
1497 total_time_usage_start=GetTimer();
1476 1498
1477 while(!eof){ 1499 while(!eof){
1478 1500
1479 /*========================== PLAY AUDIO ============================*/ 1501 /*========================== PLAY AUDIO ============================*/
1480 //if(!has_audio){ 1502 //if(!has_audio){
1789 drop_frame=frame_dropping; // tricky! 1811 drop_frame=frame_dropping; // tricky!
1790 ++drop_frame_cnt; 1812 ++drop_frame_cnt;
1791 if (verbose>0) printf("\nframe drop %d, %.2f\n", drop_frame, time_frame); 1813 if (verbose>0) printf("\nframe drop %d, %.2f\n", drop_frame, time_frame);
1792 } 1814 }
1793 } else { 1815 } else {
1794 if(time_frame<-3*frame_time || time_frame>3*frame_time) time_frame=0; 1816 if( (time_frame<-3*frame_time || time_frame>3*frame_time) || benchmark)
1817 time_frame=0;
1818
1795 } 1819 }
1796 1820
1797 if(verbose>1)printf("sleep: %5.3f a:%6.3f v:%6.3f \n",time_frame,a_frame,v_frame); 1821 if(verbose>1)printf("sleep: %5.3f a:%6.3f v:%6.3f \n",time_frame,a_frame,v_frame);
1798 1822
1799 while(time_frame>0.005){ 1823 while(time_frame>0.005){
1809 // usec_sleep(50000); // test only! 1833 // usec_sleep(50000); // test only!
1810 1834
1811 } 1835 }
1812 1836
1813 current_module=NULL; 1837 current_module=NULL;
1838
1839 if(play_n_frames>=0){
1840 --play_n_frames;
1841 if(play_n_frames<0) exit_player("Requested number of frames played");
1842 }
1814 1843
1815 if(eof) break; 1844 if(eof) break;
1816 if(force_redraw){ 1845 if(force_redraw){
1817 --force_redraw; 1846 --force_redraw;
1818 if(!force_redraw) osd_function=OSD_PLAY; 1847 if(!force_redraw) osd_function=OSD_PLAY;