Mercurial > mplayer.hg
comparison mplayer.c @ 1334:061cabfbc07b
some more cleanup
author | arpi |
---|---|
date | Mon, 16 Jul 2001 17:07:13 +0000 |
parents | b4457de47804 |
children | 345585097137 |
comparison
equal
deleted
inserted
replaced
1333:8dbc156c9467 | 1334:061cabfbc07b |
---|---|
230 int osd_level=2; | 230 int osd_level=2; |
231 int divx_quality=0; | 231 int divx_quality=0; |
232 char *seek_to_sec=NULL; | 232 char *seek_to_sec=NULL; |
233 int seek_to_byte=0; | 233 int seek_to_byte=0; |
234 int has_audio=1; | 234 int has_audio=1; |
235 //int has_video=1; | |
236 char *audio_codec=NULL; // override audio codec | 235 char *audio_codec=NULL; // override audio codec |
237 char *video_codec=NULL; // override video codec | 236 char *video_codec=NULL; // override video codec |
238 int audio_family=-1; // override audio codec family | 237 int audio_family=-1; // override audio codec family |
239 int video_family=-1; // override video codec family | 238 int video_family=-1; // override video codec family |
240 | 239 |
345 #ifdef HAVE_GUI | 344 #ifdef HAVE_GUI |
346 if ( nogui ) | 345 if ( nogui ) |
347 #endif | 346 #endif |
348 lirc_mp_cleanup(); | 347 lirc_mp_cleanup(); |
349 #endif | 348 #endif |
350 //if(play_in_bg) system("xsetroot -solid \\#000000"); | |
351 exit(1); | 349 exit(1); |
352 } | 350 } |
353 | 351 |
354 static char* current_module=NULL; // for debugging | 352 static char* current_module=NULL; // for debugging |
355 | 353 |
373 #endif | 371 #endif |
374 exit_player(NULL); | 372 exit_player(NULL); |
375 } | 373 } |
376 | 374 |
377 extern int vcd_get_track_end(int fd,int track); | 375 extern int vcd_get_track_end(int fd,int track); |
378 extern int init_video_codec(sh_video_t *sh_video); | |
379 //extern void mpeg2_allocate_image_buffers(picture_t * picture); | |
380 extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height); | 376 extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height); |
381 | 377 |
382 // dec_audio.c: | 378 // dec_audio.c: |
383 extern int init_audio(sh_audio_t *sh_audio); | 379 extern int init_audio(sh_audio_t *sh_audio); |
384 extern int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen); | 380 extern int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen); |
1130 if(!allow_dshow && sh_video->codec->driver==4) continue; // skip DShow | 1126 if(!allow_dshow && sh_video->codec->driver==4) continue; // skip DShow |
1131 else if(video_codec && strcmp(sh_video->codec->name,video_codec)) continue; | 1127 else if(video_codec && strcmp(sh_video->codec->name,video_codec)) continue; |
1132 else if(video_family!=-1 && sh_video->codec->driver!=video_family) continue; | 1128 else if(video_family!=-1 && sh_video->codec->driver!=video_family) continue; |
1133 break; | 1129 break; |
1134 } | 1130 } |
1135 //has_video=sh_video->codec->driver; | |
1136 | 1131 |
1137 printf("%s video codec: [%s] drv:%d (%s)\n",video_codec?"Forcing":"Detected",sh_video->codec->name,sh_video->codec->driver,sh_video->codec->info); | 1132 printf("%s video codec: [%s] drv:%d (%s)\n",video_codec?"Forcing":"Detected",sh_video->codec->name,sh_video->codec->driver,sh_video->codec->info); |
1138 | 1133 |
1139 for(i=0;i<CODECS_MAX_OUTFMT;i++){ | 1134 for(i=0;i<CODECS_MAX_OUTFMT;i++){ |
1140 int ret; | 1135 int ret; |
1164 if(!init_video(sh_video)){ | 1159 if(!init_video(sh_video)){ |
1165 fprintf(stderr,"FATAL: Couldn't initialize video codec :(\n"); | 1160 fprintf(stderr,"FATAL: Couldn't initialize video codec :(\n"); |
1166 GUI_MSG( mplUnknowError ) | 1161 GUI_MSG( mplUnknowError ) |
1167 exit(1); | 1162 exit(1); |
1168 } | 1163 } |
1169 | |
1170 if(verbose) printf("vo_debug2: out_fmt=%s\n",vo_format_name(out_fmt)); | |
1171 | 1164 |
1172 // ================== Init output files for encoding =============== | 1165 // ================== Init output files for encoding =============== |
1173 if(encode_name){ | 1166 if(encode_name){ |
1174 // encode file!!! | 1167 // encode file!!! |
1175 FILE *encode_file=fopen(encode_name,"rb"); | 1168 FILE *encode_file=fopen(encode_name,"rb"); |
1248 sh_video->disp_w,sh_video->disp_h, | 1241 sh_video->disp_w,sh_video->disp_h, |
1249 screen_size_x,screen_size_y, | 1242 screen_size_x,screen_size_y, |
1250 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3), | 1243 fullscreen|(vidmode<<1)|(softzoom<<2)|(flip<<3), |
1251 title,out_fmt); | 1244 title,out_fmt); |
1252 | 1245 |
1253 if(verbose) printf("vo_debug3: out_fmt=%s\n",vo_format_name(out_fmt)); | |
1254 | |
1255 #ifdef HAVE_GUI | 1246 #ifdef HAVE_GUI |
1256 if ( !nogui ) | 1247 if ( !nogui ) |
1257 { | 1248 { |
1258 mplShMem->items.videodata.width=sh_video->disp_w; | 1249 mplShMem->items.videodata.width=sh_video->disp_w; |
1259 mplShMem->items.videodata.height=sh_video->disp_h; | 1250 mplShMem->items.videodata.height=sh_video->disp_h; |
1274 fflush(stdout); | 1265 fflush(stdout); |
1275 | 1266 |
1276 //================== MAIN: ========================== | 1267 //================== MAIN: ========================== |
1277 { | 1268 { |
1278 | 1269 |
1279 float frame_correction=0; // A-V timestamp kulonbseg atlagolas | 1270 float frame_correction=0; // average of A-V timestamp differences |
1280 int frame_corr_num=0; // | 1271 int frame_corr_num=0; // |
1281 float v_frame=0; // Video | 1272 float v_frame=0; // Video |
1282 float time_frame=0; // Timer | 1273 float time_frame=0; // Timer |
1283 float c_total=0; | 1274 float c_total=0; |
1284 float max_pts_correction=0;//default_max_pts_correction; | 1275 float max_pts_correction=0;//default_max_pts_correction; |
1369 printf("Audio: no sound\n"); | 1360 printf("Audio: no sound\n"); |
1370 if(verbose) printf("Freeing %d unused audio chunks\n",d_audio->packs); | 1361 if(verbose) printf("Freeing %d unused audio chunks\n",d_audio->packs); |
1371 ds_free_packs(d_audio); // free buffered chunks | 1362 ds_free_packs(d_audio); // free buffered chunks |
1372 d_audio->id=-2; // do not read audio chunks | 1363 d_audio->id=-2; // do not read audio chunks |
1373 if(sh_audio) if(sh_audio->a_buffer) free(sh_audio->a_buffer); | 1364 if(sh_audio) if(sh_audio->a_buffer) free(sh_audio->a_buffer); |
1374 //alsa=1; | |
1375 // fake, required for timer: | |
1376 #if 1 | |
1377 sh_audio=NULL; | 1365 sh_audio=NULL; |
1378 #else | |
1379 sh_audio=new_sh_audio(255); // FIXME!!!!!!!!!! | |
1380 sh_audio->samplerate=76800; | |
1381 sh_audio->samplesize=sh_audio->channels=2; | |
1382 sh_audio->o_bps=sh_audio->channels*sh_audio->samplerate*sh_audio->samplesize; | |
1383 #endif | |
1384 } | 1366 } |
1385 | 1367 |
1386 current_module=NULL; | 1368 current_module=NULL; |
1387 | 1369 |
1388 //==================== START PLAYING ======================= | 1370 //==================== START PLAYING ======================= |
1389 | 1371 |
1390 if(file_format==DEMUXER_TYPE_AVI && has_audio){ | 1372 if(file_format==DEMUXER_TYPE_AVI && has_audio){ |
1391 //a_pts=d_audio->pts; | 1373 //a_pts=d_audio->pts; |
1392 printf("Initial frame delay A: %d V: %d\n",(int)sh_audio->audio.dwInitialFrames,(int)sh_video->video.dwInitialFrames); | 1374 if(verbose) printf("Initial frame delay A: %d V: %d\n",(int)sh_audio->audio.dwInitialFrames,(int)sh_video->video.dwInitialFrames); |
1393 if(!pts_from_bps){ | 1375 if(!pts_from_bps){ |
1394 float x=(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)*sh_video->frametime; | 1376 float x=(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)*sh_video->frametime; |
1395 audio_delay-=x; | 1377 audio_delay-=x; |
1396 printf("AVI Initial frame delay: %5.3f\n",x); | 1378 if(verbose) printf("AVI Initial frame delay: %5.3f\n",x); |
1397 } | 1379 } |
1398 if(verbose){ | 1380 if(verbose){ |
1399 // printf("v: audio_delay=%5.3f buffer_delay=%5.3f a_pts=%5.3f a_frame=%5.3f\n", | 1381 // printf("v: audio_delay=%5.3f buffer_delay=%5.3f a_pts=%5.3f a_frame=%5.3f\n", |
1400 // audio_delay,audio_buffer_delay,a_pts,a_frame); | 1382 // audio_delay,audio_buffer_delay,a_pts,a_frame); |
1401 printf("START: a_pts=%5.3f v_pts=%5.3f \n",d_audio->pts,d_video->pts); | 1383 printf("START: a_pts=%5.3f v_pts=%5.3f \n",d_audio->pts,d_video->pts); |
1451 | 1433 |
1452 if(playsize>0){ | 1434 if(playsize>0){ |
1453 sh_audio->a_buffer_len-=playsize; | 1435 sh_audio->a_buffer_len-=playsize; |
1454 memcpy(sh_audio->a_buffer,&sh_audio->a_buffer[playsize],sh_audio->a_buffer_len); | 1436 memcpy(sh_audio->a_buffer,&sh_audio->a_buffer[playsize],sh_audio->a_buffer_len); |
1455 a_frame+=playsize/(float)(sh_audio->o_bps); | 1437 a_frame+=playsize/(float)(sh_audio->o_bps); |
1456 //a_pts+=playsize/(float)(sh_audio->o_bps); | |
1457 // time_frame+=playsize/(float)(sh_audio->o_bps); | |
1458 } | 1438 } |
1459 | 1439 |
1460 break; | 1440 break; |
1461 } // if(has_audio) | 1441 } // if(has_audio) |
1462 | 1442 |
1489 float pts1=d_video->pts; | 1469 float pts1=d_video->pts; |
1490 int blit_frame=0; | 1470 int blit_frame=0; |
1491 | 1471 |
1492 current_module="decode_video"; | 1472 current_module="decode_video"; |
1493 | 1473 |
1494 // if(!force_redraw && v_frame+0.1<a_frame) drop_frame=1; else drop_frame=0; | |
1495 // if(drop_frame) ++drop_frame_cnt; | |
1496 | |
1497 //-------------------- Decode a frame: ----------------------- | 1474 //-------------------- Decode a frame: ----------------------- |
1498 | 1475 |
1499 if(file_format==DEMUXER_TYPE_MPEG_ES || file_format==DEMUXER_TYPE_MPEG_PS){ | 1476 if(file_format==DEMUXER_TYPE_MPEG_ES || file_format==DEMUXER_TYPE_MPEG_PS){ |
1500 int in_frame=0; | 1477 int in_frame=0; |
1501 float newfps; | 1478 float newfps; |
1580 sh_video->frametime=d; // 1ms | 1557 sh_video->frametime=d; // 1ms |
1581 sh_video->fps=1.0f/d; | 1558 sh_video->fps=1.0f/d; |
1582 } | 1559 } |
1583 } | 1560 } |
1584 v_frame+=frame_time; | 1561 v_frame+=frame_time; |
1585 //v_pts+=frame_time; | |
1586 time_frame+=frame_time; // for nosound | 1562 time_frame+=frame_time; // for nosound |
1587 | 1563 |
1588 if(file_format==DEMUXER_TYPE_MPEG_PS) d_video->pts+=frame_time; | 1564 if(file_format==DEMUXER_TYPE_MPEG_PS) d_video->pts+=frame_time; |
1589 | 1565 |
1590 if(verbose>1) printf("*** ftime=%5.3f ***\n",frame_time); | 1566 if(verbose>1) printf("*** ftime=%5.3f ***\n",frame_time); |
2064 } | 2040 } |
2065 break; | 2041 break; |
2066 | 2042 |
2067 } // switch(file_format) | 2043 } // switch(file_format) |
2068 | 2044 |
2069 // Set OSD: | |
2070 if(osd_level){ | |
2071 int len=((demuxer->movi_end-demuxer->movi_start)>>8); | |
2072 if(len>0){ | |
2073 osd_visible=sh_video->fps; // 1 sec | |
2074 vo_osd_progbar_type=0; | |
2075 vo_osd_progbar_value=(demuxer->filepos-demuxer->movi_start)/len; | |
2076 } | |
2077 //printf("avi filepos = %d (len=%d)\n",vo_osd_progbar_value,len); | |
2078 } | |
2079 | |
2080 //====================== re-sync audio: ===================== | 2045 //====================== re-sync audio: ===================== |
2081 if(has_audio){ | 2046 if(has_audio){ |
2082 | 2047 |
2083 if(skip_audio_bytes){ | 2048 if(skip_audio_bytes){ |
2084 demux_read_data(d_audio,NULL,skip_audio_bytes); | 2049 demux_read_data(d_audio,NULL,skip_audio_bytes); |
2098 skip_audio_frame(sh_audio); | 2063 skip_audio_frame(sh_audio); |
2099 } | 2064 } |
2100 } | 2065 } |
2101 } | 2066 } |
2102 | 2067 |
2068 current_module="audio_reset"; | |
2069 audio_out->reset(); // stop audio, throwing away buffered data | |
2103 current_module=NULL; | 2070 current_module=NULL; |
2104 | |
2105 audio_out->reset(); // stop audio, throwing away buffered data | |
2106 | 2071 |
2107 c_total=0; // kell ez? | 2072 c_total=0; // kell ez? |
2108 printf("A:%6.1f V:%6.1f A-V:%7.3f",d_audio->pts,d_video->pts,0.0f); | 2073 printf("A:%6.1f V:%6.1f A-V:%7.3f",d_audio->pts,d_video->pts,0.0f); |
2109 printf(" ct:%7.3f \r",c_total);fflush(stdout); | 2074 printf(" ct:%7.3f \r",c_total);fflush(stdout); |
2110 } else { | 2075 } else { |
2111 printf("A: --- V:%6.1f \r",d_video->pts);fflush(stdout); | 2076 printf("A: --- V:%6.1f \r",d_video->pts);fflush(stdout); |
2077 } | |
2078 | |
2079 // Set OSD: | |
2080 if(osd_level){ | |
2081 int len=((demuxer->movi_end-demuxer->movi_start)>>8); | |
2082 if(len>0){ | |
2083 osd_visible=sh_video->fps; // 1 sec | |
2084 vo_osd_progbar_type=0; | |
2085 vo_osd_progbar_value=(demuxer->filepos-demuxer->movi_start)/len; | |
2086 } | |
2112 } | 2087 } |
2113 | 2088 |
2114 max_pts_correction=0.1; | 2089 max_pts_correction=0.1; |
2115 frame_corr_num=0; // -5 | 2090 frame_corr_num=0; // -5 |
2116 frame_correction=0; | 2091 frame_correction=0; |
2117 force_redraw=5; | 2092 force_redraw=5; |
2118 a_frame=-skip_audio_secs; | 2093 a_frame=-skip_audio_secs; |
2119 v_frame=0; // !!!!!! | 2094 v_frame=0; // !!!!!! |
2120 audio_time_usage=0; video_time_usage=0; vout_time_usage=0; | 2095 audio_time_usage=0; video_time_usage=0; vout_time_usage=0; |
2121 // num_frames=real_num_frames=0; | |
2122 | 2096 |
2123 } | 2097 } |
2124 rel_seek_secs=0; | 2098 rel_seek_secs=0; |
2125 } // keyboard event handler | 2099 } // keyboard event handler |
2126 | 2100 |