📄 lfplayer.cxx
字号:
fwrite(start,in_size,1,pDumpStream);
}
fclose(pDumpStream);
message("Core dumped!");
// mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_CoreDumped);
// exit_player_with_rc(MSGTR_Exit_eof, 0);
}
sh_audio=d_audio->sh;
sh_video=d_video->sh;
if(sh_video)
{
//current_module="video_read_properties";
if(!video_read_properties(sh_video))
{
message("Can't read video properties !");
// mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotReadVideoProperties);
sh_video=d_video->sh=NULL;
}
else
{
// mp_msg(MSGT_CPLAYER,MSGL_V,"[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.2f ftime:=%6.4f\n",
// demuxer->file_format,sh_video->format, sh_video->disp_w,sh_video->disp_h,
// sh_video->fps,sh_video->frametime );
/* need to set fps here for output encoders to pick it up in their init */
if(force_fps)
{
sh_video->fps=force_fps;
sh_video->frametime=1.0f/sh_video->fps;
}
vo_fps = sh_video->fps;
if(!sh_video->fps && !force_fps)
{
message(" Can't specify FPS");
// mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_FPSnotspecified);
sh_video=d_video->sh=NULL;
}
}
}
fflush(stdout);
if(!sh_video && !sh_audio)
{
// mp_msg(MSGT_CPLAYER,MSGL_FATAL, MSGTR_NoStreamFound);
message("Sorry, No stream found ");
#ifdef HAS_DVBIN_SUPPORT
if((stream->type == STREAMTYPE_DVB) && stream->priv)
{
dvb_priv_t *priv = (dvb_priv_t*) stream->priv;
if(priv->is_on)
{
int dir;
int v = last_dvb_step;
if(v > 0)
dir = DVB_CHANNEL_HIGHER;
else
dir = DVB_CHANNEL_LOWER;
if(dvb_step_channel(priv, dir))
eof = dvbin_reopen = 1;
}
}
#endif
goto goto_next_file; // exit_player(MSGTR_Exit_error);
}
/* display clip info */
demux_info_print(demuxer);
return LF_TRUE;
}
//================== Read SUBTITLES (DVD & TEXT) ==========================
void LIFAN_ReadSubtitles(void)
{
LF_UDWORD palette[16];
LF_UDWORD width;
LF_UDWORD height;
LF_DWORD i;
LF_BYTE* psub;
LF_BYTE** tmp;
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_DVDNAV
if (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_DVDREAD
if (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
if ((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;
}
if (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 subs
if (vo_spudec!=NULL)
spudec_set_forced_subs_only(vo_spudec,forced_subs_only);
#ifdef USE_SUB
if(sh_video)
{
// after reading video params we should load subtitles because
// we know fps so now we can adjust subtitle 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);
psub = get_path("sub/");
tmp = sub_filenames((psub ? psub : """),filename);
// int i = 0;
i = 0;
free(psub); // release the buffer created by get_path() above
while (tmp[i])
{
add_subtitles (tmp[i], sh_video->fps, 0);
free(tmp[i++]);
}
free(tmp);
}
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;
}
}
#endif /* USE_SUB */
if (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_property_do("sub",M_PROPERTY_STEP_UP,NULL);
if(subdata)
switch (stream_dump_type)
{
case 3:
list_sub_file(subdata);
break;
case 4:
dump_mpsub(subdata, sh_video->fps);
break;
case 6:
dump_srt(subdata, sh_video->fps);
break;
case 7:
dump_microdvd(subdata, sh_video->fps);
break;
case 8:
dump_jacosub(subdata, sh_video->fps);
break;
case 9:
dump_sami(subdata, sh_video->fps);
break;
default:
break;
}
}
}
//================== Init AUDIO (codec) ==========================
void LIFAN_InitAudioCodec(void)
{
if(sh_audio)
{
/* Go through codecs.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 0 // zero by jack
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_FILENAME=%s\n", filename);
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_DEMUXER=%s\n", demuxer->desc->name);
if (sh_video)
{
/* Assume FOURCC if all bytes >= 0x20 (' ') */
if (sh_video->format >= 0x20202020)
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_FORMAT=%.4s\n", (char *)&sh_video->format);
else
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_FORMAT=0x%08X\n", sh_video->format);
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_BITRATE=%d\n", sh_video->i_bps*8);
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_WIDTH=%d\n", sh_video->disp_w);
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_HEIGHT=%d\n", sh_video->disp_h);
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_FPS=%5.3f\n", sh_video->fps);
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_VIDEO_ASPECT=%1.4f\n", sh_video->aspect);
}
if (sh_audio)
{
if (sh_audio->codec)
/ mp_msg(MSGT_IDENTIFY,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_IDENTIFY,MSGL_INFO, "ID_AUDIO_FORMAT=%.4s\n", (char *)&sh_audio->format);
else
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_AUDIO_FORMAT=%d\n", sh_audio->format);
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_AUDIO_BITRATE=%d\n", sh_audio->i_bps*8);
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_AUDIO_RATE=%d\n", sh_audio->samplerate);
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_AUDIO_NCH=%d\n", sh_audio->channels);
}
mp_msg(MSGT_IDENTIFY,MSGL_INFO,"ID_LENGTH=%.2lf\n", demuxer_get_time_length(demuxer));
#endif // zero by jack
if(!sh_video)
goto main; // audio-only
}
//================== Init VIDEO (codec & libvo) ==========================
void LIFAN_InitVideoCodec(void)
{
LF_BYTE* vf_arg[] = { "_oldargs_", (char*)video_out , NULL };
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)))
{
message(" Error initializing video device ");
// 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);
// }
#if 0 // zero by Jack
#ifdef HAVE_MENU
if(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
#endif
#endif // zero by Jack
sh_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 (sh_video->codec)
// mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_CODEC=%s\n", sh_video->codec->name);
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";
void LIFAN_InitVo(void)
{
if(vo_flags & 0x08 && vo_spudec)
spudec_set_hw_spu(vo_spudec,video_out);
#ifdef HAVE_FREETYPE
force_load_font = 1;
#endif
}
///////////////////////////////////////////////////////////////////////////////////////////////////
LF_VOID LIFAN_OpenEdlFile(void)
{
//////////////////////////////////////////
//init edl filename.
/////////////////////////////////////////
if (edl_filename)
{
if (edl_records)
free_edl(edl_records);
next_edl_record = edl_records = edl_parse_file();
}
if (edl_output_filename)
{
if (edl_fd)
fclose(edl_fd);
if ((edl_fd = fopen(edl_output_filename, "w")) == NULL)
{
message(";;;");
//mp_msg(MSGT_CPLAYER, MSGL_ERR, MSGTR_EdlCantOpenForWrite,edl_output_filename);
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
LF_VOID LIFAN_ConstructPlayerEnvironment(LF_BYTE* pPlayfile)
{
if(!vo_init())
return;
LIFAN_OpenEdlFile();
LIFAN_OpenVOBSub();
LIFAN_OpenStream();
LIFAN_OpenDemux();
LIFAN_ReadSubtitles();
LIFAN_InitAudioCodec();
LIFAN_InitVideoCodec();
LIFAN_InitVo();
if(pPlayfile)
LIFAN_StartPlay();
}
LF_BYTE LIFAN_Argument(LF_DWORD argc,LF_BYTE **args)
{
return LF_TRUE;
}
////////////////////////////////////////////////////////////
// LFPlayer entrance .
LF_DWORD main(LF_DWORD argc, LF_BYTE **argv)
{
if(LIFAN_Argument(argc, argv) == LF_FALSE)
{
message("Invalid argumnent invoke ..");
return 0;
}
LIFAN_ConstructPlayerWindow(0);
//if(LIFAN_Playfile())
LIFAN_ConstructPlayerEnvironment(LIFAN_Playfile());
return run();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -