Mercurial > mplayer.hg
comparison mplayer.c @ 5151:610d399f50c3
- cleanup pass 1. more to come soon...
- fixed order of libcss and dumpstream stuff
- fixed some comments, added more to get source easier searchable
- removed some nonsense goto, use if() instead
- removed some obsoleted, #if 0'd code
- rewritten text subtitle init calls
- removed useless 'max benchmark' code (it shows 480% cpu when playing vcd on p4...)
TODO: fix order or ao/vo init, and migrate video codec selection to libmpcodecs
author | arpi |
---|---|
date | Sun, 17 Mar 2002 00:47:15 +0000 |
parents | fce3b54250b1 |
children | f67115a72b7c |
comparison
equal
deleted
inserted
replaced
5150:23879c23ec67 | 5151:610d399f50c3 |
---|---|
138 #include "parse_es.h" | 138 #include "parse_es.h" |
139 | 139 |
140 #include "dec_audio.h" | 140 #include "dec_audio.h" |
141 #include "dec_video.h" | 141 #include "dec_video.h" |
142 | 142 |
143 #if 0 | |
144 extern picture_t *picture; // exported from libmpeg2/decode.c | |
145 | |
146 int frameratecode2framerate[16] = { | |
147 0, | |
148 // Official mpeg1/2 framerates: | |
149 24000*10000/1001, 24*10000,25*10000, 30000*10000/1001, 30*10000,50*10000,60000*10000/1001, 60*10000, | |
150 // libmpeg3's "Unofficial economy rates": | |
151 1*10000,5*10000,10*10000,12*10000,15*10000,0,0 | |
152 }; | |
153 #endif | |
154 | |
155 //**************************************************************************// | 143 //**************************************************************************// |
156 //**************************************************************************// | 144 //**************************************************************************// |
157 | 145 |
158 // Common FIFO functions, and keyboard/event FIFO code | 146 // Common FIFO functions, and keyboard/event FIFO code |
159 #include "fifo.c" | 147 #include "fifo.c" |
164 ao_functions_t *audio_out=NULL; | 152 ao_functions_t *audio_out=NULL; |
165 | 153 |
166 // benchmark: | 154 // benchmark: |
167 double video_time_usage=0; | 155 double video_time_usage=0; |
168 double vout_time_usage=0; | 156 double vout_time_usage=0; |
169 double max_video_time_usage=0; | |
170 double max_vout_time_usage=0; | |
171 double cur_video_time_usage=0; | |
172 double cur_vout_time_usage=0; | |
173 static double audio_time_usage=0; | 157 static double audio_time_usage=0; |
174 static double max_audio_time_usage=0; | |
175 static double cur_audio_time_usage=0; | |
176 static int total_time_usage_start=0; | 158 static int total_time_usage_start=0; |
177 int benchmark=0; | 159 int benchmark=0; |
178 static unsigned bench_dropped_frames=0; | 160 static unsigned bench_dropped_frames=0; |
179 | 161 |
180 // static int play_in_bg=0; | 162 // static int play_in_bg=0; |
244 | 226 |
245 static float force_fps=0; | 227 static float force_fps=0; |
246 static int force_srate=0; | 228 static int force_srate=0; |
247 static int frame_dropping=0; // option 0=no drop 1= drop vo 2= drop decode | 229 static int frame_dropping=0; // option 0=no drop 1= drop vo 2= drop decode |
248 static int play_n_frames=-1; | 230 static int play_n_frames=-1; |
249 static uint32_t our_n_frames=0; | |
250 | 231 |
251 // screen info: | 232 // screen info: |
252 char* video_driver=NULL; //"mga"; // default | 233 char* video_driver=NULL; //"mga"; // default |
253 char* audio_driver=NULL; | 234 char* audio_driver=NULL; |
254 | 235 |
844 free(buf); | 825 free(buf); |
845 } | 826 } |
846 if(vo_vobsub) | 827 if(vo_vobsub) |
847 sub_auto=0; // don't do autosub for textsubs if vobsub found | 828 sub_auto=0; // don't do autosub for textsubs if vobsub found |
848 | 829 |
849 #ifdef USE_SUB_OLD | |
850 // check .sub | |
851 if(sub_name){ | |
852 #if 0 | |
853 int l=strlen(sub_name); | |
854 if ((l>4) && ((0==strcmp(&sub_name[l-4],".utf")) | |
855 ||(0==strcmp(&sub_name[l-4],".UTF")))) | |
856 sub_utf8=1; | |
857 #endif | |
858 subtitles=sub_read_file(sub_name); | |
859 if(!subtitles || sub_num == 0) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,sub_name); | |
860 } | |
861 if(!sub_name){ | |
862 if(sub_auto && filename) { // auto load sub file ... | |
863 subtitles=sub_read_file( sub_filename( get_path("sub/"), filename ) ); | |
864 } | |
865 #if 0 | |
866 if(!subtitles) subtitles=sub_read_file(get_path("default.sub")); // try default | |
867 #endif | |
868 } | |
869 | |
870 if(subtitles && stream_dump_type==3) list_sub_file(subtitles); | |
871 if(subtitles && stream_dump_type==4) dump_mpsub(subtitles, fps); | |
872 #endif | |
873 | |
874 stream=NULL; | 830 stream=NULL; |
875 demuxer=NULL; | 831 demuxer=NULL; |
876 d_audio=NULL; | 832 d_audio=NULL; |
877 d_video=NULL; | 833 d_video=NULL; |
878 sh_audio=NULL; | 834 sh_audio=NULL; |
950 break; | 906 break; |
951 } | 907 } |
952 } | 908 } |
953 } | 909 } |
954 | 910 |
911 //============ Open & Sync STREAM --- fork cache2 ==================== | |
912 | |
955 current_module="open_stream"; | 913 current_module="open_stream"; |
956 stream=open_stream(filename,vcd_track,&file_format); | 914 stream=open_stream(filename,vcd_track,&file_format); |
957 if(!stream) { // error... | 915 if(!stream) { // error... |
958 eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY); | 916 eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY); |
959 goto goto_next_file; | 917 goto goto_next_file; |
960 } | 918 } |
961 inited_flags|=INITED_STREAM; | 919 inited_flags|=INITED_STREAM; |
920 | |
962 if(stream->type == STREAMTYPE_PLAYLIST) { | 921 if(stream->type == STREAMTYPE_PLAYLIST) { |
963 play_tree_t* entry; | 922 play_tree_t* entry; |
964 // Handle playlist | 923 // Handle playlist |
924 current_module="handle_playlist"; | |
965 mp_msg(MSGT_CPLAYER,MSGL_V,"Parsing playlist %s...\n",filename); | 925 mp_msg(MSGT_CPLAYER,MSGL_V,"Parsing playlist %s...\n",filename); |
966 entry = parse_playtree(stream); | 926 entry = parse_playtree(stream); |
967 if(!entry) { | 927 if(!entry) { |
968 entry = playtree_iter->tree; | 928 entry = playtree_iter->tree; |
969 if(play_tree_iter_step(playtree_iter,1,0) != PLAY_TREE_ITER_ENTRY) { | 929 if(play_tree_iter_step(playtree_iter,1,0) != PLAY_TREE_ITER_ENTRY) { |
990 eof = PT_NEXT_SRC; | 950 eof = PT_NEXT_SRC; |
991 goto goto_next_file; | 951 goto goto_next_file; |
992 } | 952 } |
993 stream->start_pos+=seek_to_byte; | 953 stream->start_pos+=seek_to_byte; |
994 | 954 |
955 #ifdef HAVE_LIBCSS | |
956 current_module="libcss"; | |
957 if (dvdimportkey) { | |
958 if (dvd_import_key(dvdimportkey)) { | |
959 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_ErrorDVDkey); | |
960 exit_player(MSGTR_Exit_error); | |
961 } | |
962 mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_CmdlineDVDkey); | |
963 } | |
964 if (dvd_auth_device) { | |
965 if (dvd_auth(dvd_auth_device,filename)) { | |
966 mp_msg(MSGT_CPLAYER,MSGL_FATAL,"Error in DVD auth...\n"); | |
967 exit_player(MSGTR_Exit_error); | |
968 } | |
969 mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_DVDauthOk); | |
970 } | |
971 #endif | |
972 | |
995 if(stream_dump_type==5){ | 973 if(stream_dump_type==5){ |
996 unsigned char buf[4096]; | 974 unsigned char buf[4096]; |
997 int len; | 975 int len; |
998 FILE *f; | 976 FILE *f; |
999 current_module="dump"; | 977 current_module="dumpstream"; |
1000 stream_reset(stream); | 978 stream_reset(stream); |
1001 stream_seek(stream,stream->start_pos); | 979 stream_seek(stream,stream->start_pos); |
1002 f=fopen(stream_dump_name,"wb"); | 980 f=fopen(stream_dump_name,"wb"); |
1003 if(!f){ | 981 if(!f){ |
1004 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_CantOpenDumpfile); | 982 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_CantOpenDumpfile); |
1018 if(audio_lang && audio_id==-1) audio_id=dvd_aid_from_lang(stream,audio_lang); | 996 if(audio_lang && audio_id==-1) audio_id=dvd_aid_from_lang(stream,audio_lang); |
1019 if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=dvd_sid_from_lang(stream,dvdsub_lang); | 997 if(dvdsub_lang && dvdsub_id==-1) dvdsub_id=dvd_sid_from_lang(stream,dvdsub_lang); |
1020 current_module=NULL; | 998 current_module=NULL; |
1021 #endif | 999 #endif |
1022 | 1000 |
1023 // initial prefill: 20% later: 5% (should be set by -cacheopts) | 1001 // CACHE2: initial prefill: 20% later: 5% (should be set by -cacheopts) |
1024 if(stream_cache_size && ! stream_enable_cache(stream,stream_cache_size*1024,stream_cache_size*1024/5,stream_cache_size*1024/20)) { | 1002 if(stream_cache_size){ |
1025 eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY); | 1003 current_module="enable_cache"; |
1026 if(eof) | 1004 if(!stream_enable_cache(stream,stream_cache_size*1024,stream_cache_size*1024/5,stream_cache_size*1024/20)) |
1027 goto goto_next_file; | 1005 if((eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY))) goto goto_next_file; |
1028 } | 1006 } |
1029 | 1007 |
1030 #ifdef HAVE_LIBCSS | 1008 //============ Open DEMUXERS --- DETECT file type ======================= |
1031 current_module="libcss"; | |
1032 if (dvdimportkey) { | |
1033 if (dvd_import_key(dvdimportkey)) { | |
1034 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_ErrorDVDkey); | |
1035 exit_player(MSGTR_Exit_error); | |
1036 } | |
1037 mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_CmdlineDVDkey); | |
1038 } | |
1039 if (dvd_auth_device) { | |
1040 // if (dvd_auth(dvd_auth_device,f)) { | |
1041 if (dvd_auth(dvd_auth_device,filename)) { | |
1042 mp_msg(MSGT_CPLAYER,MSGL_FATAL,"Error in DVD auth...\n"); | |
1043 exit_player(MSGTR_Exit_error); | |
1044 } | |
1045 mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_DVDauthOk); | |
1046 } | |
1047 #endif | |
1048 | |
1049 //============ Open & Sync stream and detect file format =============== | |
1050 | |
1051 | 1009 |
1052 if(!has_audio) audio_id=-2; // do NOT read audio packets... | 1010 if(!has_audio) audio_id=-2; // do NOT read audio packets... |
1053 | 1011 |
1054 current_module="demux_open"; | 1012 current_module="demux_open"; |
1055 | 1013 |
1100 } | 1058 } |
1101 | 1059 |
1102 sh_audio=d_audio->sh; | 1060 sh_audio=d_audio->sh; |
1103 sh_video=d_video->sh; | 1061 sh_video=d_video->sh; |
1104 | 1062 |
1105 current_module="video_read_properties"; | |
1106 | |
1107 if(sh_video){ | 1063 if(sh_video){ |
1108 | 1064 |
1065 current_module="video_read_properties"; | |
1109 if(!video_read_properties(sh_video)) { | 1066 if(!video_read_properties(sh_video)) { |
1110 mp_msg(MSGT_CPLAYER,MSGL_ERR,"Video: can't read properties\n"); | 1067 mp_msg(MSGT_CPLAYER,MSGL_ERR,"Video: can't read properties\n"); |
1111 sh_video=d_video->sh=NULL; | 1068 sh_video=d_video->sh=NULL; |
1112 } else { | 1069 } else { |
1113 mp_msg(MSGT_CPLAYER,MSGL_INFO,"[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.2f ftime:=%6.4f\n", | 1070 mp_msg(MSGT_CPLAYER,MSGL_INFO,"[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.2f ftime:=%6.4f\n", |
1136 if(!sh_video && !sh_audio){ | 1093 if(!sh_video && !sh_audio){ |
1137 mp_msg(MSGT_CPLAYER,MSGL_FATAL,"No stream found\n"); | 1094 mp_msg(MSGT_CPLAYER,MSGL_FATAL,"No stream found\n"); |
1138 goto goto_next_file; // exit_player(MSGTR_Exit_error); | 1095 goto goto_next_file; // exit_player(MSGTR_Exit_error); |
1139 } | 1096 } |
1140 | 1097 |
1141 if(!sh_video) goto init_audio; | 1098 /* display clip info */ |
1099 demux_info_print(demuxer); | |
1100 | |
1101 //================== Read SUBTITLES (DVD & TEXT) ========================== | |
1102 if(sh_video){ | |
1142 | 1103 |
1143 #ifdef USE_DVDREAD | 1104 #ifdef USE_DVDREAD |
1144 current_module="spudec"; | 1105 current_module="spudec_init"; |
1145 vo_spudec=spudec_new_scaled(stream->type==STREAMTYPE_DVD?((dvd_priv_t *)(stream->priv))->cur_pgc->palette:NULL, | 1106 vo_spudec=spudec_new_scaled(stream->type==STREAMTYPE_DVD?((dvd_priv_t *)(stream->priv))->cur_pgc->palette:NULL, |
1146 sh_video->disp_w, sh_video->disp_h); | 1107 sh_video->disp_w, sh_video->disp_h); |
1147 if (vo_spudec!=NULL) | 1108 if (vo_spudec!=NULL) |
1148 inited_flags|=INITED_SPUDEC; | 1109 inited_flags|=INITED_SPUDEC; |
1149 current_module=NULL; | |
1150 #endif | 1110 #endif |
1151 | 1111 |
1152 #ifdef USE_SUB | 1112 #ifdef USE_SUB |
1153 // after reading video params we should load subtitles because | 1113 // after reading video params we should load subtitles because |
1154 // we know fps so now we can adjust subtitles time to ~6 seconds AST | 1114 // we know fps so now we can adjust subtitles time to ~6 seconds AST |
1155 // check .sub | 1115 // check .sub |
1156 current_module="read_subtitles_file"; | 1116 current_module="read_subtitles_file"; |
1157 if(sub_name){ | 1117 if(sub_name){ |
1158 #if 0 | 1118 subtitles=sub_read_file(sub_name, sh_video->fps); |
1159 int l=strlen(sub_name); | 1119 if(!subtitles) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,sub_name); |
1160 if ((l>4) && ((0==strcmp(&sub_name[l-4],".utf")) | 1120 } else |
1161 ||(0==strcmp(&sub_name[l-4],".UTF")))) | 1121 if(sub_auto) { // auto load sub file ... |
1162 sub_utf8=1; | 1122 subtitles=sub_read_file( filename ? sub_filename( get_path("sub/"), filename ) |
1163 #endif | 1123 : "default.sub", sh_video->fps ); |
1164 subtitles=sub_read_file(sub_name, sh_video->fps); | 1124 } |
1165 if(!subtitles || sub_num == 0) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,sub_name); | |
1166 } | |
1167 if(!sub_name){ | |
1168 if(sub_auto && filename) { // auto load sub file ... | |
1169 subtitles=sub_read_file( sub_filename( get_path("sub/"), filename ), | |
1170 sh_video->fps ); | |
1171 } | |
1172 #if 0 | |
1173 if(!subtitles) subtitles=sub_read_file(get_path("default.sub"), | |
1174 sh_video->fps); // try default | |
1175 #endif | |
1176 } | |
1177 | |
1178 if(subtitles && stream_dump_type==3) list_sub_file(subtitles); | 1125 if(subtitles && stream_dump_type==3) list_sub_file(subtitles); |
1179 if(subtitles && stream_dump_type==4) dump_mpsub(subtitles, sh_video->fps); | 1126 if(subtitles && stream_dump_type==4) dump_mpsub(subtitles, sh_video->fps); |
1180 #endif | 1127 #endif |
1181 | 1128 |
1129 } | |
1182 //================== Init AUDIO (codec) ========================== | 1130 //================== Init AUDIO (codec) ========================== |
1183 init_audio: | |
1184 current_module="init_audio_codec"; | 1131 current_module="init_audio_codec"; |
1185 | |
1186 /* display clip info */ | |
1187 demux_info_print(demuxer); | |
1188 | 1132 |
1189 if(sh_audio){ | 1133 if(sh_audio){ |
1190 // Go through the codec.conf and find the best codec... | 1134 // Go through the codec.conf and find the best codec... |
1191 sh_audio->codec=NULL; | 1135 sh_audio->codec=NULL; |
1192 if(audio_family!=-1) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_TryForceAudioFmt,audio_family); | 1136 if(audio_family!=-1) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_TryForceAudioFmt,audio_family); |
1378 fflush(stdout); | 1322 fflush(stdout); |
1379 | 1323 |
1380 //================== MAIN: ========================== | 1324 //================== MAIN: ========================== |
1381 main: | 1325 main: |
1382 if(!sh_video) osd_level = 0; | 1326 if(!sh_video) osd_level = 0; |
1327 | |
1328 | |
1383 { | 1329 { |
1384 | |
1385 //int frame_corr_num=0; // | 1330 //int frame_corr_num=0; // |
1386 //float v_frame=0; // Video | 1331 //float v_frame=0; // Video |
1387 float time_frame=0; // Timer | 1332 float time_frame=0; // Timer |
1388 int force_redraw=0; | 1333 int force_redraw=0; |
1389 //float num_frames=0; // number of frames played | 1334 //float num_frames=0; // number of frames played |
1400 double vdecode_time; | 1345 double vdecode_time; |
1401 unsigned int lastframeout_ts; | 1346 unsigned int lastframeout_ts; |
1402 float time_frame_corr_avg=0; | 1347 float time_frame_corr_avg=0; |
1403 | 1348 |
1404 //================ SETUP AUDIO ========================== | 1349 //================ SETUP AUDIO ========================== |
1350 | |
1351 if(sh_audio){ | |
1352 const ao_info_t *info=audio_out->info; | |
1405 current_module="setup_audio"; | 1353 current_module="setup_audio"; |
1406 | |
1407 if(sh_audio){ | |
1408 | |
1409 const ao_info_t *info=audio_out->info; | |
1410 mp_msg(MSGT_CPLAYER,MSGL_INFO,"AO: [%s] %iHz %s %s\n", | 1354 mp_msg(MSGT_CPLAYER,MSGL_INFO,"AO: [%s] %iHz %s %s\n", |
1411 info->short_name, | 1355 info->short_name, |
1412 force_srate?force_srate:sh_audio->samplerate, | 1356 force_srate?force_srate:sh_audio->samplerate, |
1413 sh_audio->channels>1?"Stereo":"Mono", | 1357 sh_audio->channels>1?"Stereo":"Mono", |
1414 audio_out_format_name(sh_audio->sample_format) | 1358 audio_out_format_name(sh_audio->sample_format) |
1415 ); | 1359 ); |
1416 mp_msg(MSGT_CPLAYER,MSGL_V,"AO: Description: %s\nAO: Author: %s\n", | 1360 mp_msg(MSGT_CPLAYER,MSGL_V,"AO: Description: %s\nAO: Author: %s\n", |
1417 info->name, | 1361 info->name, info->author); |
1418 info->author | 1362 if(strlen(info->comment) > 0) |
1419 ); | |
1420 if(strlen(info->comment) > 0) | |
1421 mp_msg(MSGT_CPLAYER,MSGL_V,"AO: Comment: %s\n", info->comment); | 1363 mp_msg(MSGT_CPLAYER,MSGL_V,"AO: Comment: %s\n", info->comment); |
1364 | |
1422 if(!audio_out->init(force_srate?force_srate:sh_audio->samplerate, | 1365 if(!audio_out->init(force_srate?force_srate:sh_audio->samplerate, |
1423 sh_audio->channels,sh_audio->sample_format,0)){ | 1366 sh_audio->channels,sh_audio->sample_format,0)){ |
1424 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotInitAO); | 1367 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotInitAO); |
1425 sh_audio=d_audio->sh=NULL; | 1368 sh_audio=d_audio->sh=NULL; |
1426 if(sh_video == NULL) | 1369 if(sh_video == NULL) |
1427 goto goto_next_file; | 1370 goto goto_next_file; |
1428 } else { | 1371 } else { |
1429 inited_flags|=INITED_AO; | 1372 inited_flags|=INITED_AO; |
1430 } | 1373 } |
1431 | 1374 } |
1432 // printf("Audio buffer size: %d bytes, delay: %5.3fs\n",audio_buffer_size,audio_buffer_delay); | 1375 |
1433 | 1376 current_module="av_init"; |
1434 // fixup audio buffer size: | 1377 |
1435 // if(outburst<MAX_OUTBURST){ | 1378 if(sh_video) sh_video->timer=0; |
1436 // sh_audio->a_buffer_size=sh_audio->audio_out_minsize+outburst; | 1379 if(sh_audio) sh_audio->timer=-audio_delay; |
1437 // printf("Audio out buffer size reduced to %d bytes\n",sh_audio->a_buffer_size); | |
1438 // } | |
1439 | |
1440 // sh_audio->timer=-(audio_buffer_delay); | |
1441 } | |
1442 | |
1443 if(sh_video) sh_video->timer=0; | |
1444 if(sh_audio) sh_audio->timer=-audio_delay; | |
1445 | 1380 |
1446 if(!sh_audio){ | 1381 if(!sh_audio){ |
1447 mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_NoSound); | 1382 mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_NoSound); |
1448 if(verbose) mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused audio chunks\n",d_audio->packs); | 1383 if(verbose) mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused audio chunks\n",d_audio->packs); |
1449 ds_free_packs(d_audio); // free buffered chunks | 1384 ds_free_packs(d_audio); // free buffered chunks |
1450 d_audio->id=-2; // do not read audio chunks | 1385 d_audio->id=-2; // do not read audio chunks |
1451 if(audio_out) uninit_player(INITED_AO); // close device | 1386 if(audio_out) uninit_player(INITED_AO); // close device |
1452 } | 1387 } |
1453 if(!sh_video){ | 1388 if(!sh_video){ |
1454 mp_msg(MSGT_CPLAYER,MSGL_INFO,"Video: no video!!!\n"); | 1389 mp_msg(MSGT_CPLAYER,MSGL_INFO,"Video: no video!!!\n"); |
1455 if(verbose) mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused video chunks\n",d_video->packs); | 1390 if(verbose) mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused video chunks\n",d_video->packs); |
1456 ds_free_packs(d_video); | 1391 ds_free_packs(d_video); |
1457 d_video->id=-2; | 1392 d_video->id=-2; |
1458 if(video_out) uninit_player(INITED_VO); | 1393 if(video_out) uninit_player(INITED_VO); |
1459 } | 1394 } |
1460 current_module=NULL; | |
1461 | 1395 |
1462 if(demuxer->file_format!=DEMUXER_TYPE_AVI) pts_from_bps=0; // it must be 0 for mpeg/asf! | 1396 if(demuxer->file_format!=DEMUXER_TYPE_AVI) pts_from_bps=0; // it must be 0 for mpeg/asf! |
1463 if(force_fps){ | 1397 if(force_fps){ |
1464 vo_fps = sh_video->fps=force_fps; | 1398 vo_fps = sh_video->fps=force_fps; |
1465 sh_video->frametime=1.0f/sh_video->fps; | 1399 sh_video->frametime=1.0f/sh_video->fps; |
1472 | 1406 |
1473 InitTimer(); | 1407 InitTimer(); |
1474 | 1408 |
1475 total_time_usage_start=GetTimer(); | 1409 total_time_usage_start=GetTimer(); |
1476 audio_time_usage=0; video_time_usage=0; vout_time_usage=0; | 1410 audio_time_usage=0; video_time_usage=0; vout_time_usage=0; |
1477 if(benchmark) | |
1478 { | |
1479 max_audio_time_usage=0; max_video_time_usage=0; max_vout_time_usage=0; | |
1480 } | |
1481 while(!eof){ | 1411 while(!eof){ |
1482 // unsigned int aq_total_time=GetTimer(); | 1412 // unsigned int aq_total_time=GetTimer(); |
1483 float aq_sleep_time=0; | 1413 float aq_sleep_time=0; |
1484 | 1414 |
1485 if(play_n_frames>=0){ | 1415 if(play_n_frames>=0){ |
1521 } | 1451 } |
1522 current_module=NULL; // Leave AUDIO decoder module | 1452 current_module=NULL; // Leave AUDIO decoder module |
1523 t=GetTimer()-t; | 1453 t=GetTimer()-t; |
1524 tt = t*0.000001f; | 1454 tt = t*0.000001f; |
1525 audio_time_usage+=tt; | 1455 audio_time_usage+=tt; |
1526 if(benchmark) | |
1527 { | |
1528 if(tt > max_audio_time_usage) max_audio_time_usage = tt; | |
1529 cur_audio_time_usage=tt; | |
1530 } | |
1531 if(playsize>sh_audio->a_buffer_len) playsize=sh_audio->a_buffer_len; | 1456 if(playsize>sh_audio->a_buffer_len) playsize=sh_audio->a_buffer_len; |
1532 | 1457 |
1533 playsize=audio_out->play(sh_audio->a_buffer,playsize,0); | 1458 playsize=audio_out->play(sh_audio->a_buffer,playsize,0); |
1534 | 1459 |
1535 if(playsize>0){ | 1460 if(playsize>0){ |
1770 | 1695 |
1771 video_out->flip_page(); | 1696 video_out->flip_page(); |
1772 t2=GetTimer()-t2; | 1697 t2=GetTimer()-t2; |
1773 tt = t2*0.000001f; | 1698 tt = t2*0.000001f; |
1774 vout_time_usage+=tt; | 1699 vout_time_usage+=tt; |
1775 if(benchmark) | |
1776 { | |
1777 if(cur_vout_time_usage + tt > max_vout_time_usage) | |
1778 max_vout_time_usage = cur_vout_time_usage + tt; | |
1779 our_n_frames++; | |
1780 } | |
1781 } | 1700 } |
1782 // usec_sleep(50000); // test only! | 1701 // usec_sleep(50000); // test only! |
1783 | 1702 |
1784 } | |
1785 /* Compute total frame dropping here */ | |
1786 if(benchmark) | |
1787 { | |
1788 if((cur_video_time_usage + cur_vout_time_usage + cur_audio_time_usage)*vo_fps > 1) | |
1789 bench_dropped_frames ++; | |
1790 } | 1703 } |
1791 current_module=NULL; | 1704 current_module=NULL; |
1792 | 1705 |
1793 if(eof) break; | 1706 if(eof) break; |
1794 if(force_redraw){ | 1707 if(force_redraw){ |
2788 goto_next_file: // don't jump here after ao/vo/getch initialization! | 2701 goto_next_file: // don't jump here after ao/vo/getch initialization! |
2789 | 2702 |
2790 if(benchmark){ | 2703 if(benchmark){ |
2791 double tot=video_time_usage+vout_time_usage+audio_time_usage; | 2704 double tot=video_time_usage+vout_time_usage+audio_time_usage; |
2792 double total_time_usage; | 2705 double total_time_usage; |
2793 max_video_time_usage *= our_n_frames; | |
2794 max_vout_time_usage *= our_n_frames; | |
2795 max_audio_time_usage *= our_n_frames; | |
2796 total_time_usage_start=GetTimer()-total_time_usage_start; | 2706 total_time_usage_start=GetTimer()-total_time_usage_start; |
2797 total_time_usage = (float)total_time_usage_start*0.000001; | 2707 total_time_usage = (float)total_time_usage_start*0.000001; |
2798 mp_msg(MSGT_CPLAYER,MSGL_INFO,"\nAVE BENCHMARKs: VC:%8.3fs VO:%8.3fs A:%8.3fs Sys:%8.3fs = %8.3fs\n", | 2708 mp_msg(MSGT_CPLAYER,MSGL_INFO,"\nBENCHMARKs: VC:%8.3fs VO:%8.3fs A:%8.3fs Sys:%8.3fs = %8.3fs\n", |
2799 video_time_usage,vout_time_usage,audio_time_usage, | 2709 video_time_usage,vout_time_usage,audio_time_usage, |
2800 total_time_usage-tot,total_time_usage); | 2710 total_time_usage-tot,total_time_usage); |
2801 if(total_time_usage>0.0) | 2711 if(total_time_usage>0.0) |
2802 mp_msg(MSGT_CPLAYER,MSGL_INFO,"AVE BENCHMARK%%: VC:%8.4f%% VO:%8.4f%% A:%8.4f%% Sys:%8.4f%% = %8.4f%%\n", | 2712 mp_msg(MSGT_CPLAYER,MSGL_INFO,"BENCHMARK%%: VC:%8.4f%% VO:%8.4f%% A:%8.4f%% Sys:%8.4f%% = %8.4f%%\n", |
2803 100.0*video_time_usage/total_time_usage, | 2713 100.0*video_time_usage/total_time_usage, |
2804 100.0*vout_time_usage/total_time_usage, | 2714 100.0*vout_time_usage/total_time_usage, |
2805 100.0*audio_time_usage/total_time_usage, | 2715 100.0*audio_time_usage/total_time_usage, |
2806 100.0*(total_time_usage-tot)/total_time_usage, | 2716 100.0*(total_time_usage-tot)/total_time_usage, |
2807 100.0); | 2717 100.0); |
2808 mp_msg(MSGT_CPLAYER,MSGL_INFO,"\nMAX BENCHMARKs: VC:%8.3fs VO:%8.3fs A:%8.3fs\n", | |
2809 max_video_time_usage,max_vout_time_usage, | |
2810 max_audio_time_usage); | |
2811 if(total_time_usage>0.0) | |
2812 mp_msg(MSGT_CPLAYER,MSGL_INFO,"MAX BENCHMARK%%: VC:%8.4f%% VO:%8.4f%% A:%8.4f%% = %8.4f%%\n", | |
2813 100.0*max_video_time_usage/total_time_usage, | |
2814 100.0*max_vout_time_usage/total_time_usage, | |
2815 100.0*max_audio_time_usage/total_time_usage, | |
2816 100.0*max_video_time_usage/total_time_usage+ | |
2817 100.0*max_vout_time_usage/total_time_usage+ | |
2818 100.0*max_audio_time_usage/total_time_usage | |
2819 ); | |
2820 /* This code computes number of frame which should be dropped | |
2821 in ideal case (without SYSTIME); i.e. when file is located | |
2822 in RAM and kernel+other_tasks eat 0% of CPU. */ | |
2823 mp_msg(MSGT_CPLAYER,MSGL_INFO,"TOTAL BENCHMARK: from %u frames should be dropped: %u at least\n" | |
2824 ,our_n_frames,bench_dropped_frames); | |
2825 } | 2718 } |
2826 | 2719 |
2827 #ifdef HAVE_NEW_GUI | 2720 #ifdef HAVE_NEW_GUI |
2828 if( use_gui ) | 2721 if( use_gui ) |
2829 { | 2722 { |