📄 mplayer_novideo_0.00.c
字号:
dir = DVB_CHANNEL_LOWER; if(dvb_step_channel(priv, dir)) { uninit_player(INITED_ALL-(INITED_STREAM|INITED_INPUT)); cache_uninit(stream); goto goto_enable_cache; } } }#endif goto goto_next_file; // exit_player(MSGTR_Exit_error);}/* display clip info */demux_info_print(demuxer);//================== Read SUBTITLES (DVD & TEXT) ==========================if(vo_spudec==NULL && sh_video && (stream->type==STREAMTYPE_DVD || demuxer->type==DEMUXER_TYPE_MATROSKA || d_dvdsub->id >= 0)){if (spudec_ifo) { unsigned int palette[16], width, height; current_module="spudec_init_vobsub"; if (vobsub_parse_ifo(NULL,spudec_ifo, palette, &width, &height, 1, -1, NULL) >= 0) vo_spudec=spudec_new_scaled(palette, width, height);}#ifdef USE_DVDNAVif (vo_spudec==NULL && stream->type==STREAMTYPE_DVDNAV) { current_module="spudec_init_dvdnav"; vo_spudec=spudec_new_scaled(dvdnav_stream_get_palette((dvdnav_priv_t*)(stream->priv)), sh_video->disp_w, sh_video->disp_h);}#endif#ifdef USE_DVDREADif (vo_spudec==NULL && stream->type==STREAMTYPE_DVD) { current_module="spudec_init_dvdread"; vo_spudec=spudec_new_scaled(((dvd_priv_t *)(stream->priv))->cur_pgc->palette, sh_video->disp_w, sh_video->disp_h);}#endif#ifdef HAVE_MATROSKAif ((vo_spudec == NULL) && (demuxer->type == DEMUXER_TYPE_MATROSKA) && (d_dvdsub->sh != NULL) && (((mkv_sh_sub_t *)d_dvdsub->sh)->type == 'v')) { mkv_sh_sub_t *mkv_sh_sub = (mkv_sh_sub_t *)d_dvdsub->sh; current_module = "spudec_init_matroska"; vo_spudec = spudec_new_scaled_vobsub(mkv_sh_sub->palette, mkv_sh_sub->colors, mkv_sh_sub->custom_colors, mkv_sh_sub->width, mkv_sh_sub->height); forced_subs_only = mkv_sh_sub->forced_subs_only;}#endifif (vo_spudec==NULL) { current_module="spudec_init_normal"; vo_spudec=spudec_new_scaled(NULL, sh_video->disp_w, sh_video->disp_h); spudec_set_font_factor(vo_spudec,font_factor);}if (vo_spudec!=NULL) inited_flags|=INITED_SPUDEC;}// Apply current settings for forced subsif (vo_spudec!=NULL) spudec_set_forced_subs_only(vo_spudec,forced_subs_only);#ifdef USE_SUBif(sh_video) {// after reading video params we should load subtitles because// we know fps so now we can adjust subtitles time to ~6 seconds AST// check .sub current_module="read_subtitles_file"; if(sub_name){ for (i = 0; sub_name[i] != NULL; ++i) add_subtitles (sub_name[i], sh_video->fps, 0); } if(sub_auto) { // auto load sub file ... char *psub = get_path( "sub/" ); char **tmp = sub_filenames((psub ? psub : ""), filename); char **tmp2 = tmp; free(psub); // release the buffer created by get_path() above while (*tmp2) add_subtitles (*tmp2++, sh_video->fps, 0); free(tmp); if (set_of_sub_size == 0) { add_subtitles (mem_ptr=get_path("default.sub"), sh_video->fps, 1); free(mem_ptr); // release the buffer created by get_path() } if (set_of_sub_size > 0) add_subtitles (NULL, sh_video->fps, 1); } if (set_of_sub_size > 0) { // setup global sub numbering global_sub_indices[SUB_SOURCE_SUBS] = global_sub_size; // the global # of the first sub. global_sub_size += set_of_sub_size; }}#endifif (global_sub_size) { // find the best sub to use if (vobsub_id >= 0) { // if user asks for a vobsub id, use that first. global_sub_pos = global_sub_indices[SUB_SOURCE_VOBSUB] + vobsub_id; } else if (dvdsub_id >= 0 && global_sub_indices[SUB_SOURCE_DEMUX] >= 0) { // if user asks for a dvd sub id, use that next. global_sub_pos = global_sub_indices[SUB_SOURCE_DEMUX] + dvdsub_id; } else if (global_sub_indices[SUB_SOURCE_SUBS] >= 0) { // if there are text subs to use, use those. (autosubs come last here) global_sub_pos = global_sub_indices[SUB_SOURCE_SUBS];/* } else if (global_sub_indices[SUB_SOURCE_DEMUX] >= 0) { // if nothing else works, get subs from the demuxer. global_sub_pos = global_sub_indices[SUB_SOURCE_DEMUX];*/ } else { // nothing worth doing automatically. global_sub_pos = -1; } // rather than duplicate code, use the SUB_SELECT handler to init the right one. global_sub_pos--; mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));}//================== Init AUDIO (codec) ==========================if(sh_audio){ // Go through the codec.conf and find the best codec... current_module="init_audio_codec"; mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n"); if(!init_best_audio_codec(sh_audio,audio_codec_list,audio_fm_list)){ sh_audio=d_audio->sh=NULL; // failed to init :( } else inited_flags|=INITED_ACODEC; mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");}if(identify) { mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_FILENAME=%s\n", filename); if (sh_video) { /* Assume FOURCC if all bytes >= 0x20 (' ') */ if (sh_video->format >= 0x20202020) mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_VIDEO_FORMAT=%.4s\n", &sh_video->format); else mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_VIDEO_FORMAT=0x%08X\n", sh_video->format); mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_VIDEO_BITRATE=%d\n", sh_video->i_bps*8); mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_VIDEO_WIDTH=%d\n", sh_video->disp_w); mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_VIDEO_HEIGHT=%d\n", sh_video->disp_h); mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_VIDEO_FPS=%5.3f\n", sh_video->fps); mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_VIDEO_ASPECT=%1.4f\n", sh_video->aspect); } if (sh_audio) { if (sh_audio->codec) mp_msg(MSGT_GLOBAL,MSGL_INFO, "ID_AUDIO_CODEC=%s\n", sh_audio->codec->name); /* Assume FOURCC if all bytes >= 0x20 (' ') */ if (sh_audio->format >= 0x20202020) mp_msg(MSGT_GLOBAL,MSGL_INFO, "ID_AUDIO_FORMAT=%.4s\n", &sh_audio->format); else mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_AUDIO_FORMAT=%d\n", sh_audio->format); mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_AUDIO_BITRATE=%d\n", sh_audio->i_bps*8); mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_AUDIO_RATE=%d\n", sh_audio->samplerate); mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_AUDIO_NCH=%d\n", sh_audio->channels); } mp_msg(MSGT_GLOBAL,MSGL_INFO,"ID_LENGTH=%ld\n", demuxer_get_time_length(demuxer));}if(!sh_video) goto main; // audio-only//================== Init VIDEO (codec & libvo) ==========================if(!fixed_vo || !(inited_flags&INITED_VO)){current_module="preinit_libvo";vo_config_count=0;//if((video_out->preinit(vo_subdevice))!=0){if(!(video_out=init_best_video_out(video_driver_list))){ mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_ErrorInitializingVODevice); goto goto_next_file; // exit_player(MSGTR_Exit_error);}sh_video->video_out=video_out;inited_flags|=INITED_VO;}current_module="init_video_filters";{ char* vf_arg[] = { "_oldargs_", (char*)video_out , NULL }; sh_video->vfilter=(void*)vf_open_filter(NULL,"vo",vf_arg);}#ifdef HAVE_MENUif(use_menu) { char* vf_arg[] = { "_oldargs_", menu_root, NULL }; vf_menu = vf_open_plugin(libmenu_vfs,sh_video->vfilter,"menu",vf_arg); if(!vf_menu) { mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantOpenLibmenuFilterWithThisRootMenu,menu_root); use_menu = 0; }}if(vf_menu) sh_video->vfilter=(void*)append_filters(vf_menu);else#endifsh_video->vfilter=(void*)append_filters(sh_video->vfilter);current_module="init_video_codec";mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");init_best_video_codec(sh_video,video_codec_list,video_fm_list);mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");if(!sh_video->inited){ if(!fixed_vo) uninit_player(INITED_VO); if(!sh_audio) goto goto_next_file; sh_video = d_video->sh = NULL; goto main; // exit_player(MSGTR_Exit_error);}inited_flags|=INITED_VCODEC;if(auto_quality>0){ // Auto quality option enabled output_quality=get_video_quality_max(sh_video); if(auto_quality>output_quality) auto_quality=output_quality; else output_quality=auto_quality; mp_msg(MSGT_CPLAYER,MSGL_V,"AutoQ: setting quality to %d.\n",output_quality); set_video_quality(sh_video,output_quality);}// ========== Init display (sh_video->disp_w*sh_video->disp_h/out_fmt) ============current_module="init_vo"; if(vo_flags & 0x08 && vo_spudec) spudec_set_hw_spu(vo_spudec,video_out);#ifdef HAVE_FREETYPE force_load_font = 1;#endif//================== MAIN: ==========================main:current_module="main";// If there is no video OSD has to be disabled.// In case of playing a playtree we have to restore the// old OSD level after playing one or more audio-only files.if(!sh_video && osd_level >= 0) { // save OSD level only once osd_level_saved = osd_level; osd_level = 0;} else if (osd_level_saved > -1) { // if there is a saved OSD level, restore it osd_level = osd_level_saved; osd_level_saved = -1;}fflush(stdout);#ifdef HAVE_NEW_GUI if ( use_gui ) { if ( sh_audio ) guiIntfStruct.AudioType=sh_audio->channels; else guiIntfStruct.AudioType=0; if ( !sh_video && sh_audio ) guiGetEvent( guiSetAudioOnly,(char *)1 ); else guiGetEvent( guiSetAudioOnly,(char *)0 ); guiGetEvent( guiSetFileFormat,(char *)demuxer->file_format ); if ( guiGetEvent( guiSetValues,(char *)sh_video ) ) goto goto_next_file; guiGetEvent( guiSetDemuxer,(char *)demuxer ); }#endif{//int frame_corr_num=0; ////float v_frame=0; // Videofloat time_frame=0; // Timer//float num_frames=0; // number of frames playedint grab_frames=0;char osd_text_buffer[64];char osd_show_text_buffer[64];int drop_frame=0; // current dropping statusint dropped_frames=0; // how many frames dropped since last non-dropped frameint too_slow_frame_cnt=0;int too_fast_frame_cnt=0;// for auto-quality:float AV_delay=0; // average of A-V timestamp differencesdouble vdecode_time;unsigned int lastframeout_ts=0;/*float time_frame_corr_avg=0;*/ /* unused */float next_frame_time=0;int frame_time_remaining=0; // flagint blit_frame=0;osd_text_buffer[0]=0;//================ SETUP AUDIO ==========================if(sh_audio){ //const ao_info_t *info=audio_out->info; current_module="af_preinit"; ao_data.samplerate=force_srate?force_srate:sh_audio->samplerate*playback_speed; ao_data.channels=audio_output_channels?audio_output_channels:sh_audio->channels; ao_data.format=audio_output_format?audio_output_format:sh_audio->sample_format;#if 1 if(!preinit_audio_filters(sh_audio, // input: (int)(sh_audio->samplerate*playback_speed), sh_audio->channels, sh_audio->sample_format, // output: &ao_data.samplerate, &ao_data.channels, &ao_data.format)){ mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_AudioFilterChainPreinitError); }#endif current_module="ao2_init"; if(!(audio_out=init_best_audio_out(audio_driver_list, 0, // plugin flag force_srate?force_srate:ao_data.samplerate, audio_output_channels?audio_output_channels:ao_data.channels, audio_output_format?audio_output_format:ao_data.format,0))){ // FAILED: mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotInitAO); uninit_player(INITED_ACODEC); // close codec sh_audio=d_audio->sh=NULL; // -> nosound } else { // SUCCESS: inited_flags|=INITED_AO; mp_msg(MSGT_CPLAYER,MSGL_INFO,"AO: [%s] %dHz %dch %s (%d bps)\n", audio_out->info->short_name, ao_data.samplerate, ao_data.channels, af_fmt2str_short(ao_data.format), af_fmt2bits(ao_data.format)/8 ); mp_msg(MSGT_CPLAYER,MSGL_V,"AO: Description: %s\nAO: Author: %s\n", audio_out->info->name, audio_out->info->author); if(strlen(audio_out->info->comment) > 0) mp_msg(MSGT_CPLAYER,MSGL_V,"AO: Comment: %s\n", audio_out->info->comment); // init audio filters:#if 1 current_module="af_init"; if(!build_afilter_chain(sh_audio, &ao_data)) { mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_NoMatchingFilter);// mp_msg(MSGT_CPLAYER,MSGL_ERR,"Couldn't find matching filter / ao format! -> NOSOUND\n");// uninit_player(INITED_ACODEC|INITED_AO); // close codec & ao// sh_audio=d_audio->sh=NULL; // -> nosound }#endif } mixer.audio_out = audio_out; mixer.volstep = volstep;}current_module="av_init";if(sh_video) sh_video->timer=0;if(sh_audio) sh_audio->delay=-audio_delay;if(!sh_audio){ mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_NoSound); mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused audio chunks.\n",d_audio->packs); ds_free_packs(d_audio); // free buffered chunks d_audio->id=-2; // do not read audio chunks //uninit_player(INITED_AO); // close device}if(!sh_video){ mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Video_NoVideo); mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused video chunks.\n",d_video->packs); ds_free_packs(d_video); d_video->id=-2; //if(!fixed_vo) uninit_player(INITED_VO);}if (!sh_video && !sh_audio) goto goto_next_file;//if(demuxer->file_format!=DEMUXER_TYPE_AVI) pts_from_bps=0; // it must be 0 for mpeg/asf!if(force_fps && sh_video){ vo_fps = sh_video->fps=force_fps; sh_video->frametime=1.0f/sh_video->fps; mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_FPSforced,sh_video->fps,sh_video->frametime);}//==================== START PLAYING =======================if(loop_times>1) loop_times--; elseif(loop_times==1) loop_times = -1;mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_StartPlaying);fflush(stdout);InitTimer();#ifdef USE_DVDNAVif (stream->type==STREAMTYPE_DVDNAV) { dvdnav_stream_fullstart((dvdnav_priv_t *)stream->priv);}#endiftotal_time_usage_start=GetTimer();audio_time_usage=0; video_time_usage=0; vout_time_usage=0;total_frame_cnt=0; drop_frame_cnt=0; // fix for multifile fps benchmarkplay_n_frames=play_n_frames_mf;if(play_n_frames==0){ eof=PT_NEXT_ENTRY; goto goto_next_file;}while(!eof){ float aq_sleep_time=0; if(play_n_frames>=0){ --play_n_frames; if(play_n_frames<0) eof = PT_NEXT_ENTRY; }/*========================== PLAY AUDIO ============================*/while(sh_audio){ unsigned int t; double tt; int playsize; current_module="play_audio"; ao_data.pts=((sh_video?sh_video->timer:0)+sh_audio->delay)*90000.0; playsize=audio_out->get_space(); // handle audio-only case: if(playsize < ao_data.outburst && !sh_video) { // buffer is full, do not block here!!! usec_sleep(10000); // Wait a tick before retry continue; } if(playsize>MAX_OUTBURST) playsize=MAX_OUTBURST; // we shouldn't exceed it! // Fill buffer if needed: current_module="decode_audio"; // Enter AUDIO decoder module t=GetTimer(); while(sh_audio->a_out_buffer_len<playsize && !d_audio->eof){ int ret=decode_audio(sh_audio,&sh_audio->a_out_buffer[sh_audio->a_out_buffer_len], playsize-sh_audio->a_out_buffer_len,sh_audio->a_out_buffer_size-sh_audio->a_out_buffer_len); if(ret<=0) break; // EOF? sh_audio->a_out_buffer_len+=ret; } t=GetTimer()-t; tt = t*0.000001f; audio_time_usage+=tt; if(playsize>sh_audio->a_out_buffer_len) playsize=sh_audio->a_out_buffer_len; // play audio: current_module="play_audio"; playsize=audio_out->play(sh_audio->a_out_buffer,playsize,0); if(playsize>0){ sh_audio->a_out_buffer_len-=playsize; memmove(sh_audio->a_out_buffer,&sh_audio->a_out_buffer[playsize],sh_audio->a_out_buffer_len); sh_audio->delay+=playback_speed*playsize/((float)((a
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -