comparison mplayer.c @ 1478:6f9167f0fcca

'too slow' message is fixed - better detection now based on both drop_cnt and A-V sync
author arpi
date Fri, 10 Aug 2001 01:27:02 +0000
parents f352e1e951ba
children db2a6ae7e296
comparison
equal deleted inserted replaced
1477:8b7ede5849f4 1478:6f9167f0fcca
18 18
19 #include <fcntl.h> 19 #include <fcntl.h>
20 20
21 #include "version.h" 21 #include "version.h"
22 #include "config.h" 22 #include "config.h"
23
24 #ifdef __FreeBSD__
25 #include <sys/cdrio.h>
26 #endif
27 23
28 #ifdef sun 24 #ifdef sun
29 #define DEFAULT_CDROM_DEVICE "/vol/dev/aliases/cdrom0" 25 #define DEFAULT_CDROM_DEVICE "/vol/dev/aliases/cdrom0"
30 #else 26 #else
31 #define DEFAULT_CDROM_DEVICE "/dev/cdrom" 27 #define DEFAULT_CDROM_DEVICE "/dev/cdrom"
962 int grab_frames=0; 958 int grab_frames=0;
963 char osd_text_buffer[64]; 959 char osd_text_buffer[64];
964 int drop_frame=0; 960 int drop_frame=0;
965 int drop_frame_cnt=0; 961 int drop_frame_cnt=0;
966 // for auto-quality: 962 // for auto-quality:
967 float frame_correction=0; // average of A-V timestamp differences 963 float AV_delay=0; // average of A-V timestamp differences
968 double cvideo_base_vtime; 964 double cvideo_base_vtime;
969 double cvideo_base_vframe; 965 double cvideo_base_vframe;
970 double vdecode_time; 966 double vdecode_time;
971 967
972 #ifdef HAVE_LIRC 968 #ifdef HAVE_LIRC
1293 if(verbose>1)printf("delay=%d\n",delay); 1289 if(verbose>1)printf("delay=%d\n",delay);
1294 time_frame=sh_video->timer; 1290 time_frame=sh_video->timer;
1295 time_frame-=sh_audio->timer-(float)delay/(float)sh_audio->o_bps; 1291 time_frame-=sh_audio->timer-(float)delay/(float)sh_audio->o_bps;
1296 // we are out of time... drop next frame! 1292 // we are out of time... drop next frame!
1297 if(time_frame<-2*frame_time){ 1293 if(time_frame<-2*frame_time){
1294 static int drop_message=0;
1298 drop_frame=frame_dropping; // tricky! 1295 drop_frame=frame_dropping; // tricky!
1299 ++drop_frame_cnt; 1296 ++drop_frame_cnt;
1300 if(drop_frame_cnt==50 && frame_dropping<1) 1297 if(drop_frame_cnt>50 && AV_delay>0.5 && !drop_message){
1298 drop_message=1;
1301 printf("\n************************************************************************" 1299 printf("\n************************************************************************"
1302 "\n** Your system is too SLOW to play this! try with -framedrop or RTFM! **" 1300 "\n** Your system is too SLOW to play this! try with -framedrop or RTFM! **"
1303 "\n************************************************************************" 1301 "\n************************************************************************"
1304 "\n"); 1302 "\n");
1303 }
1305 if (verbose>0) printf("\nframe drop %d, %.2f\n", drop_frame, time_frame); 1304 if (verbose>0) printf("\nframe drop %d, %.2f\n", drop_frame, time_frame);
1306 } 1305 }
1307 } else { 1306 } else {
1308 if( (time_frame<-3*frame_time || time_frame>3*frame_time) || benchmark) 1307 if( (time_frame<-3*frame_time || time_frame>3*frame_time) || benchmark)
1309 time_frame=0; 1308 time_frame=0;
1345 // printf("A:%6.1f V:%6.1f A-V:%7.3f frame=%5.2f \r",d_audio->pts,d_video->pts,d_audio->pts-d_video->pts,sh_audio->timer); 1344 // printf("A:%6.1f V:%6.1f A-V:%7.3f frame=%5.2f \r",d_audio->pts,d_video->pts,d_audio->pts-d_video->pts,sh_audio->timer);
1346 // fflush(stdout); 1345 // fflush(stdout);
1347 1346
1348 #if 1 1347 #if 1
1349 /*================ A-V TIMESTAMP CORRECTION: =========================*/ 1348 /*================ A-V TIMESTAMP CORRECTION: =========================*/
1350 frame_correction=0;
1351 if(sh_audio){ 1349 if(sh_audio){
1352 float a_pts=0; 1350 float a_pts=0;
1353 float v_pts=0; 1351 float v_pts=0;
1354 1352
1355 // unplayed bytes in our and soundcard/dma buffer: 1353 // unplayed bytes in our and soundcard/dma buffer:
1369 float x=d_audio->pts-d_video->pts-(delay+audio_delay); 1367 float x=d_audio->pts-d_video->pts-(delay+audio_delay);
1370 float y=-(delay+audio_delay); 1368 float y=-(delay+audio_delay);
1371 float bps_a_pts=(ds_tell(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->wf->nAvgBytesPerSec; 1369 float bps_a_pts=(ds_tell(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->wf->nAvgBytesPerSec;
1372 float bps_v_pts=d_video->pack_no*(float)sh_video->video.dwScale/(float)sh_video->video.dwRate; 1370 float bps_v_pts=d_video->pack_no*(float)sh_video->video.dwScale/(float)sh_video->video.dwRate;
1373 printf("Initial PTS delay: %5.3f sec ->%5.3f (bps: %5.3f) audio_delay=%5.3f\n",x,2*sh_video->frametime,bps_a_pts-bps_v_pts-(delay+audio_delay),audio_delay); 1371 printf("Initial PTS delay: %5.3f sec ->%5.3f (bps: %5.3f) audio_delay=%5.3f\n",x,2*sh_video->frametime,bps_a_pts-bps_v_pts-(delay+audio_delay),audio_delay);
1374 x=2*sh_video->frametime; 1372 x=0; //2*sh_video->frametime;
1375 // initial_pts_delay+=x; audio_delay+=x; 1373 // initial_pts_delay+=x; audio_delay+=x;
1376 delay_corrected=1; 1374 delay_corrected=1;
1377 if(verbose) 1375 if(verbose)
1378 printf("v: audio_delay=%5.3f buffer_delay=%5.3f a.pts=%5.3f v.pts=%5.3f\n", 1376 printf("v: audio_delay=%5.3f buffer_delay=%5.3f a.pts=%5.3f v.pts=%5.3f\n",
1379 audio_delay,delay,d_audio->pts,d_video->pts); 1377 audio_delay,delay,d_audio->pts,d_video->pts);
1380 } 1378 }
1381 // PTS = (last timestamp) + (bytes after last timestamp)/(bytes per sec) 1379 // PTS = (last timestamp) + (bytes after last timestamp)/(bytes per sec)
1382 a_pts=d_audio->pts; 1380 a_pts=d_audio->pts;
1381 //printf("*** %5.3f ***\n",a_pts);
1383 a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; 1382 a_pts+=(ds_tell_pts(d_audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
1384 // v_pts=d_video->pts-frame_time; 1383 // v_pts=d_video->pts-frame_time;
1385 v_pts=d_video->pts; 1384 v_pts=d_video->pts;
1386 } 1385 }
1387 1386
1388 if(verbose>1)printf("### A:%8.3f (%8.3f) V:%8.3f A-V:%7.4f \n",a_pts,a_pts-audio_delay-delay,v_pts,(a_pts-delay-audio_delay)-v_pts); 1387 if(verbose>1)printf("### A:%8.3f (%8.3f) V:%8.3f A-V:%7.4f \n",a_pts,a_pts-audio_delay-delay,v_pts,(a_pts-delay-audio_delay)-v_pts);
1389 1388
1390 if(delay_corrected){ 1389 if(delay_corrected){
1391 float x=frame_correction=(a_pts-delay-audio_delay)-v_pts; 1390 float x;
1391 AV_delay=(a_pts-delay-audio_delay)-v_pts;
1392 // printf("A:%6.1f V:%6.1f A-V:%7.3f",a_pts-audio_delay-delay,v_pts,x); 1392 // printf("A:%6.1f V:%6.1f A-V:%7.3f",a_pts-audio_delay-delay,v_pts,x);
1393 if(!quiet) 1393 if(!quiet)
1394 printf("A:%6.1f (%6.1f) V:%6.1f A-V:%7.3f",a_pts,a_pts-audio_delay-delay,v_pts,x); 1394 printf("A:%6.1f (%6.1f) V:%6.1f A-V:%7.3f",a_pts,a_pts-audio_delay-delay,v_pts,AV_delay);
1395 x*=0.1f; 1395 x=AV_delay*0.1f;
1396 if(x<-max_pts_correction) x=-max_pts_correction; else 1396 if(x<-max_pts_correction) x=-max_pts_correction; else
1397 if(x> max_pts_correction) x= max_pts_correction; 1397 if(x> max_pts_correction) x= max_pts_correction;
1398 if(default_max_pts_correction>=0) 1398 if(default_max_pts_correction>=0)
1399 max_pts_correction=default_max_pts_correction; 1399 max_pts_correction=default_max_pts_correction;
1400 else 1400 else