📄 mplayer_novideo_0.00.c
字号:
saddf(line, &pos, width, "%d%% ", cache_fill_status);#endif // other if (playback_speed != 1) saddf(line, &pos, width, "%4.2fx ", playback_speed); // end memset(&line[pos], ' ', width - pos); line[width] = 0; mp_msg(MSGT_AVSYNC, MSGL_STATUS, "%s\r", line); free(line);}/** * \brief build a chain of audio filters that converts the input format * to the ao's format, taking into account the current playback_speed. * \param sh_audio describes the requested input format of the chain. * \param ao_data describes the requested output format of the chain. */static int build_afilter_chain(sh_audio_t *sh_audio, ao_data_t *ao_data){ int new_srate; int result; if (!sh_audio) {#ifdef HAVE_NEW_GUI guiGetEvent(guiSetAfilter, (char *)NULL);#endif mixer.afilter = NULL; return 0; } new_srate = sh_audio->samplerate * playback_speed; if (new_srate != ao_data->samplerate) { // limits are taken from libaf/af_resample.c if (new_srate < 8000) new_srate = 8000; if (new_srate > 192000) new_srate = 192000; playback_speed = (float)new_srate / (float)sh_audio->samplerate; } result = init_audio_filters(sh_audio, new_srate, sh_audio->channels, sh_audio->sample_format, ao_data->samplerate, ao_data->channels, ao_data->format, ao_data->outburst * 4, ao_data->buffersize); mixer.afilter = sh_audio->afilter;#ifdef HAVE_NEW_GUI guiGetEvent(guiSetAfilter, (char *)sh_audio->afilter);#endif return result;}#ifdef USE_SUB/** * \brief Log the currently displayed subtitle to a file * * Logs the current or last displayed subtitle together with filename * and time information to ~/.mplayer/subtitle_log * * Intended purpose is to allow convenient marking of bogus subtitles * which need to be fixed while watching the movie. */static void log_sub(){ char *fname; FILE *f; int i; if (subdata == NULL || vo_sub_last == NULL) return; fname = get_path("subtitle_log"); f = fopen(fname, "a"); if (!f) return; fprintf(f, "----------------------------------------------------------\n"); if (subdata->sub_uses_time) { fprintf(f, "N: %s S: %02d:%02d:%02d.%02d E: %02d:%02d:%02d.%02d\n", filename, vo_sub_last->start/360000, (vo_sub_last->start/6000)%60, (vo_sub_last->start/100)%60, vo_sub_last->start%100, vo_sub_last->end/360000, (vo_sub_last->end/6000)%60, (vo_sub_last->end/100)%60, vo_sub_last->end%100); } else { fprintf(f, "N: %s S: %d E: %d\n", filename, vo_sub_last->start, vo_sub_last->end); } for (i = 0; i < vo_sub_last->lines; i++) { fprintf(f, "%s\n", vo_sub_last->text[i]); } fclose(f);}#endifint main(int argc,char* argv[]){char * mem_ptr;static demux_stream_t *d_audio=NULL;static demux_stream_t *d_video=NULL;static demux_stream_t *d_dvdsub=NULL;int file_format=DEMUXER_TYPE_UNKNOWN;int delay_corrected=1;// movie info:int osd_function=OSD_PLAY;int osd_last_pts=-303;int osd_show_av_delay = 0;int osd_show_text = 0;int osd_show_speed = 0;int osd_show_sub_delay = 0;int osd_show_sub_pos = 0;int osd_show_sub_visibility = 0;int osd_show_sub_alignment = 0;int osd_show_vobsub_changed = 0;int osd_show_sub_changed = 0;int osd_show_percentage = 0;int osd_show_tv_channel = 25;int osd_show_ontop = 0;int osd_show_rootwin = 0;int osd_show_framedropping = 0;int rtc_fd=-1;//float a_frame=0; // Audioint i;char *tmp;int gui_no_filename=0; srand((int) time(NULL)); mp_msg_init(); mp_msg_set_level(MSGL_STATUS); mp_msg(MSGT_CPLAYER,MSGL_INFO, "MPlayer " VERSION " (C) 2000-2005 MPlayer Team\n"); /* Test for cpu capabilities (and corresponding OS support) for optimizing */ GetCpuCaps(&gCpuCaps);#if defined(ARCH_X86) || defined(ARCH_X86_64) mp_msg(MSGT_CPLAYER,MSGL_INFO,"CPUflags: MMX: %d MMX2: %d 3DNow: %d 3DNow2: %d SSE: %d SSE2: %d\n", gCpuCaps.hasMMX,gCpuCaps.hasMMX2, gCpuCaps.has3DNow, gCpuCaps.has3DNowExt, gCpuCaps.hasSSE, gCpuCaps.hasSSE2);#ifdef RUNTIME_CPUDETECT mp_msg(MSGT_CPLAYER,MSGL_INFO, MSGTR_CompiledWithRuntimeDetection);#else mp_msg(MSGT_CPLAYER,MSGL_INFO, MSGTR_CompiledWithCPUExtensions);#ifdef HAVE_MMX mp_msg(MSGT_CPLAYER,MSGL_INFO," MMX");#endif#ifdef HAVE_MMX2 mp_msg(MSGT_CPLAYER,MSGL_INFO," MMX2");#endif#ifdef HAVE_3DNOW mp_msg(MSGT_CPLAYER,MSGL_INFO," 3DNow");#endif#ifdef HAVE_3DNOWEX mp_msg(MSGT_CPLAYER,MSGL_INFO," 3DNowEx");#endif#ifdef HAVE_SSE mp_msg(MSGT_CPLAYER,MSGL_INFO," SSE");#endif#ifdef HAVE_SSE2 mp_msg(MSGT_CPLAYER,MSGL_INFO," SSE2");#endif mp_msg(MSGT_CPLAYER,MSGL_INFO,"\n\n");#endif#endif#if defined(WIN32) && defined(USE_WIN32DLL){ /*make our codec dirs available for LoadLibraryA()*/ char tmppath[MAX_PATH*2 + 1]; char win32path[MAX_PATH]; char realpath[MAX_PATH];#ifdef __CYGWIN__ cygwin_conv_to_full_win32_path(WIN32_PATH,win32path); strcpy(tmppath,win32path);#ifdef USE_REALCODECS cygwin_conv_to_full_win32_path(REALCODEC_PATH,realpath); sprintf(tmppath,"%s;%s",win32path,realpath);#endif /*USE_REALCODECS*/#else if(!strstr(WIN32_PATH,":")){ GetModuleFileNameA(NULL, win32path, MAX_PATH); strcpy(win32path + strlen(win32path) - strlen("mplayer.exe"), WIN32_PATH); } else strcpy(win32path,WIN32_PATH); strcpy(tmppath,win32path);#ifdef USE_REALCODECS if(!strstr(REALCODEC_PATH,":")){ GetModuleFileNameA(NULL, realpath, MAX_PATH); strcpy(realpath + strlen(realpath) - strlen("mplayer.exe"), REALCODEC_PATH); } else strcpy(realpath,REALCODEC_PATH); sprintf(tmppath,"%s;%s",win32path,realpath);#endif /*USE_REALCODECS*/#endif /*__CYGWIN__*/ SetEnvironmentVariableA("PATH", tmppath);}#endif /*WIN32 && USE_WIN32DLL*/#ifdef USE_TV tv_param_immediate = 1;#endif if ( argv[0] ) if(!strcmp(argv[0],"gmplayer") || (strrchr(argv[0],'/') && !strcmp(strrchr(argv[0],'/'),"/gmplayer") ) ) use_gui=1; mconfig = m_config_new(); m_config_register_options(mconfig,mplayer_opts); // TODO : add something to let modules register their options mp_input_register_options(mconfig); parse_cfgfiles(mconfig);#ifdef HAVE_NEW_GUI if ( use_gui ) cfg_read();#endif playtree = m_config_parse_mp_command_line(mconfig, argc, argv); if(playtree == NULL) exit_player(NULL); playtree = play_tree_cleanup(playtree); if(playtree) { playtree_iter = play_tree_iter_new(playtree,mconfig); if(playtree_iter) { if(play_tree_iter_step(playtree_iter,0,0) != PLAY_TREE_ITER_ENTRY) { play_tree_iter_free(playtree_iter); playtree_iter = NULL; } filename = play_tree_iter_get_file(playtree_iter,1); } } #ifdef WIN32 if(proc_priority){ int i; for(i=0; priority_presets_defs[i].name; i++){ if(strcasecmp(priority_presets_defs[i].name, proc_priority) == 0) break; } mp_msg(MSGT_CPLAYER,MSGL_STATUS,"Setting process priority: %s\n", priority_presets_defs[i].name); SetPriorityClass(GetCurrentProcess(), priority_presets_defs[i].prio); }#endif #ifndef HAVE_NEW_GUI if(use_gui){ mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoGui); use_gui=0; }#else if(use_gui && !vo_init()){ mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_GuiNeedsX); use_gui=0; } if (use_gui && playtree_iter){ char cwd[PATH_MAX+2]; // Remove Playtree and Playtree-Iter from memory as its not used by gui play_tree_iter_free(playtree_iter); playtree_iter=NULL; if (getcwd(cwd, PATH_MAX) != (char *)NULL) { strcat(cwd, "/"); // Prefix relative paths with current working directory play_tree_add_bpf(playtree, cwd); } // Import initital playtree into gui import_initial_playtree_into_gui(playtree, mconfig, enqueue); }#endif if(video_driver_list && strcmp(video_driver_list[0],"help")==0){ list_video_out(); exit_player_with_rc(NULL, 0); } if(audio_driver_list && strcmp(audio_driver_list[0],"help")==0){ list_audio_out(); exit_player_with_rc(NULL, 0); }// check codec.confif(!codecs_file || !parse_codec_cfg(codecs_file)){ if(!parse_codec_cfg(mem_ptr=get_path("codecs.conf"))){ if(!parse_codec_cfg(MPLAYER_CONFDIR "/codecs.conf")){ if(!parse_codec_cfg(NULL)){ mp_msg(MSGT_CPLAYER,MSGL_HINT,MSGTR_CopyCodecsConf); exit_player_with_rc(NULL, 0); } mp_msg(MSGT_CPLAYER,MSGL_V,MSGTR_BuiltinCodecsConf); } } free( mem_ptr ); // release the buffer created by get_path()}#if 0 if(video_codec_list){ int i; video_codec=video_codec_list[0]; for(i=0;video_codec_list[i];i++) mp_msg(MSGT_FIXME,MSGL_FIXME,"vc#%d: '%s'\n",i,video_codec_list[i]); }#endif if(audio_codec_list && strcmp(audio_codec_list[0],"help")==0){ mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableAudioCodecs); list_codecs(1); mp_msg(MSGT_FIXME, MSGL_FIXME, "\n"); exit_player_with_rc(NULL, 0); } if(video_codec_list && strcmp(video_codec_list[0],"help")==0){ mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_AvailableVideoCodecs); list_codecs(0); mp_msg(MSGT_FIXME, MSGL_FIXME, "\n"); exit_player_with_rc(NULL, 0); } if(video_fm_list && strcmp(video_fm_list[0],"help")==0){ vfm_help(); mp_msg(MSGT_FIXME, MSGL_FIXME, "\n"); exit_player_with_rc(NULL, 0); } if(audio_fm_list && strcmp(audio_fm_list[0],"help")==0){ afm_help(); mp_msg(MSGT_FIXME, MSGL_FIXME, "\n"); exit_player_with_rc(NULL, 0); } if(af_cfg.list && strcmp(af_cfg.list[0],"help")==0){ af_help(); printf("\n"); exit_player_with_rc(NULL, 0); }#ifdef HAVE_X11 if(vo_fstype_list && strcmp(vo_fstype_list[0],"help")==0){ fstype_help(); mp_msg(MSGT_FIXME, MSGL_FIXME, "\n"); exit_player_with_rc(NULL, 0); }#endif#ifdef USE_EDLif (edl_check_mode() == EDL_ERROR && edl_filename){ mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlCantUseBothModes); exit_player(NULL);} else if (edl_filename){ if (edl_records) free_edl(edl_records); next_edl_record = edl_records = edl_parse_file();} else if (edl_output_filename){ if ((edl_fd = fopen(edl_output_filename, "w")) == NULL) { mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlCantOpenForWrite, edl_output_filename); exit_player(NULL); }}#endif if(!filename){ if(!use_gui){ // no file/vcd/dvd -> show HELP: mp_msg(MSGT_CPLAYER, MSGL_INFO, help_text); exit_player_with_rc(NULL, 0); } else gui_no_filename=1; } // Many users forget to include command line in bugreports... if(verbose>0){ mp_msg(MSGT_CPLAYER, MSGL_INFO, MSGTR_CommandLine); for(i=1;i<argc;i++)mp_msg(MSGT_CPLAYER, MSGL_INFO," '%s'",argv[i]); mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n"); } mp_msg_set_level(verbose+MSGL_STATUS);//------ load global data first ------// check font#ifdef USE_OSD#ifdef HAVE_FREETYPE init_freetype();#endif#ifdef HAVE_FONTCONFIG if(!font_fontconfig) {#endif if(font_name){ vo_font=read_font_desc(font_name,font_factor,verbose>1); if(!vo_font) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name); } else { // try default: vo_font=read_font_desc( mem_ptr=get_path("font/font.desc"),font_factor,verbose>1); free(mem_ptr); // release the buffer created by get_path() if(!vo_font) vo_font=read_font_desc(MPLAYER_DATADIR "/font/font.desc",font_factor,verbose>1); }#ifdef HAVE_FONTCONFIG }#endif#endif vo_init_osd();#ifdef HAVE_RTC if(!nortc) { // seteuid(0); /* Can't hurt to try to get root here */ if ((rtc_fd = open(rtc_device ? rtc_device : "/dev/rtc", O_RDONLY)) < 0) mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_RTCDeviceNotOpenable, rtc_device ? rtc_device : "/dev/rtc", strerror(errno)); else { unsigned long irqp = 1024; /* 512 seemed OK. 128 is jerky. */ if (ioctl(rtc_fd, RTC_IRQP_SET, irqp) < 0) { mp_msg(MSGT_CPLAYER, MSGL_WARN, MSGTR_LinuxRTCInitErrorIrqpSet, irqp, strerror(errno)); mp_msg(MSGT_CPLAYER, MSGL_HINT, MSGTR_IncreaseRTCMaxUserFreq, irqp); close (rtc_fd); rtc_fd = -1; } else if (ioctl(rtc_fd, RTC_PIE_ON, 0) < 0) { /* variable only by the root */ mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_LinuxRTCInitErrorPieOn, strerror(errno)); close (rtc_fd); rtc_fd = -1; } else mp_msg(MSGT_CPLAYER, MSGL_V, MSGTR_UsingRTCTiming, irqp); } }#ifdef HAVE_NEW_GUI// breaks DGA and SVGAlib and VESA drivers: --A'rpi// and now ? -- Pontscho if(use_gui) setuid( getuid() ); // strongly test, please check this.#endif if(rtc_fd<0)#endif mp_msg(MSGT_CPLAYER, MSGL_V, "Using %s timing\n", softsleep?"software":timer_name);#ifdef USE_TERMCAP if ( !use_gui ) load_termcap(NULL); // load key-codes#endif// ========== Init keyboard FIFO (connection to libvo) ============// Init input systemcurrent_module = "init_input";mp_input_init();#if 0make_pipe(&keyb_fifo_get,&keyb_fifo_put);if(keyb_fifo_get > 0) mp_input_add_key_fd(keyb_fifo_get,1,NULL,NULL);#else mp_input_add_key_fd(-1,0,mplayer_get_key,NULL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -