版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、.一.mplayer支持的格式mplayer是一个linux下的视频播放器,它支持相当多的媒体格式,无论在音频播放还是在视频播放方面,可以说它支持的格式是相当全面的。视频格式支持:mpeg、avi、asf 与wmv、quicktime 与 ogg/ogm、sdp、pva、gif。音频格式支持:mp3、wav、ogg/ogm 文件(vorbis)、wma 与 asf、mp4、cd音频、xmms。二. mplayer 中头文件的功能分析1. config.h/各种本地配置宏定义头2. version.h/版本定义头#defineversion1.0pre7try2-3.4.23. mp_msg.h
2、/消息处理头4. help_mp.h/根据配置自动生成的帮助头#includehelp/help_mpen.h5. cfg-mplayer-def.h/mplayer运行时的选项缺省值头文件char*6. default_config=7. sub_reader.h/拥有格式自动发现功能的字幕(subtitle)阅读器8. libvo/video_out.h/该文件包含libvo视频输出的公共函数、变量9. libvo/font_load.h/有关字体装载的例程10. libao2/audio_out.h/音频输出驱动程序相关结构定义和全局数据11. libmpcodecs/dec_audio
3、.h/音频解码12. libmpcodecs/dec_video.h/视频解码13. libmpdemux/matroska.h/多路解复用,媒体容器格式matroska处理头14. libmpdemux/stream.h/流处理15. libmpdemux/demuxer.h/多路解复用头文件16. libmpdemux/stheader.h/媒体流头处理17. get_path.c/路径获取头文件18. spudec.h/spu子画面单元头,dvd字幕流19. edl.h/剪辑控制清单20. m_option.h/选项类型处理头21. m_config.h/配置处理头文件三. mplaye
4、r.main 主流程简要说明1. intmain()2. 1)变量声明,电影信息movieinfo:3. 2)初始化,消息系统4. play_next_file:5. 3)播放文件filename的循环gotoplay_next_file开始6. main:7. 4)主处理main精品.8. 5)播放真正主循环20103541while(!eof)9. while(!eof)10. 5.1)播放音频playaudio20172064decode_audio(sh_audio,.);11. 5.2)播放视频playvideo,20682300decode_video(sh_video,.);12
5、. 5.3)处理暂停pause13. 5.4)处理edl14. 5.5)键盘事件处理,搜索24003216while(!brk_cmd&15. (cmd=mp_input_get_cmd(0,0,0)!=null)16. 5.6)时间寻道(秒)if(seek_to_sec)17. 5.7)寻道32433306,if(rel_seek_secs|abs_seek_pos)18. 5.8)处理gui19. 5.9)变更updateosd20. 5.10)找到字幕findsub21. 5.11)处理x11窗口22. 5.12)dvd字幕sub:23. 24. goto_next_file:25. 6
6、)播放结束,转到下个文件goto_next_file:26. 四.mplayer源码分析从mplayer.c的main开始处理参数1. mconfig=m_config_new();2. m_config_register_options(mconfig,mplayer_opts);3. /todo:addsomethingtoletmodulesregistertheiroptions4. mp_input_register_options(mconfig);5. parse_cfgfiles(mconfig);初始化mpctx结构体,mpctx应该是mplayer context的意思,顾
7、名思义是一个统筹全局的变量。cppview plaincopy1. staticmpcontext*mpctx=&mpctx_s;2. /notallfunctionsinmplayer.ctakethecontextasanargumentyet3. staticmpcontextmpctx_s=4. .osd_function=osd_play,5. .begin_skip=mp_nopts_value,6. .play_tree_step=1,7. .global_sub_pos=-1,8. .set_of_sub_pos=-1,9. .file_format=demuxer_type_
8、unknown,精品.10. .loop_times=-1,11. #ifdefhas_dvbin_support12. .last_dvb_step=1,13. #endif14. ;原型1. /真正统筹全局的结构2. typedefstructmpcontext3. intosd_show_percentage;4. intosd_function;5. constao_functions_t*audio_out;6. play_tree_t*playtree;7. play_tree_iter_t*playtree_iter;8. inteof;9. intplay_tree_step;
9、10. intloop_times;11. 12. stream_t*stream;13. demuxer_t*demuxer;14. sh_audio_t*sh_audio;15. sh_video_t*sh_video;16. demux_stream_t*d_audio;17. demux_stream_t*d_video;18. demux_stream_t*d_sub;19. mixer_tmixer;20. constvo_functions_t*video_out;21. /framesbufferedinthevoreadytoflip.currentlyalways0or1.
10、22. /thisisreallyavovariablebutcurrentlytheresnosuitablevo23. /struct.24. intnum_buffered_frames;25. 26. /usedtoretrydecodingafterstartup/seekingtocompensateforcodecdelay27. intstartup_decode_retry;28. /howlonguntilweneedtodisplaythecurrentframe29. floattime_frame;30. 31. /avsync:thenextframeshouldb
11、eshownwhentheaudioouthasthis32. /much(inseconds)buffereddataleft.increasedwhenmoredatais33. /writtentotheao,decreasedwhenmovingtothenextframe.34. /intheaudio-onlycaseusedasatimersincethelastseek35. /bytheaudiocpuusagemeter.精品.36. doubledelay;37. 38. floatbegin_skip;/starttimeofthecurrentskipwhileone
12、dloutmode39. /audioismutedifeitheredloruseractivatesmute40. shortedl_muted;/storeswhetheredliscurrentlyinmutedmode.41. shortuser_muted;/storeswhetheruserwantedmutedmode.42. 43. intglobal_sub_size;/thisencompassesallsubtitlesources44. intglobal_sub_pos;/thisencompassesallsubtitlesources45. intset_of_
13、sub_pos;46. intset_of_sub_size;47. intsub_countssub_sources;48. #ifdefconfig_ass49. /set_of_ass_tracksicontainssubtitlesfromset_of_subtitlesi50. /parsedbylibassornullifformatunsupported51. ass_track*set_of_ass_tracksmax_subtitle_files;52. #endif53. sub_data*set_of_subtitlesmax_subtitle_files;54. 55.
14、 intfile_format;56. 57. #ifdefconfig_dvbin58. intlast_dvb_step;59. intdvbin_reopen;60. #endif61. 62. intwas_paused;63. 64. #ifdefconfig_dvdnav65. structmp_image*nav_smpi;/lastdecodeddvdnavvideoimage66. unsignedchar*nav_buffer;/lastreaddvdnavvideoframe67. unsignedchar*nav_start;/pointertolastreadvide
15、obuffer68. intnav_in_size;/stream=open_stream(filename,0,&mpctx-file_format);2. fileformat文件还是tv流demuxer_type_playlist或demuxer_type_unknown3. demuxer_type_tv精品.4. current_module记录状态vobsubopen_streamhandle_playlistdumpstream5. stream_reset(mpctx-stream);6. stream_seek(mpctx-stream,mpctx-stream-start_
16、pos);7. f=fopen(stream_dump_name,”wb”);dump文件流8. stream-type=streamtype_dvd/= open demuxers detect file type =demux。分离视频流和音频流1. mpctx-demuxer=demux_open(mpctx-stream,mpctx-2. file_format,audio_id,video_id,dvdsub_id,filename);3. demux过程4. demux_open5. get_demuxer_type_from_name6. 7. mpctx-d_audio=mpc
17、tx-demuxer-audio;8. mpctx-d_video=mpctx-demuxer-video;9. mpctx-d_sub=mpctx-demuxer-sub;10. mpctx-sh_audio=mpctx-d_audio-sh;11. mpctx-sh_video=mpctx-d_video-sh;分离了之后就开始分别play audio和video这里只关心play video1. /*=playvideo=*/2. vo_pts=mpctx-sh_video-timer*90000.0;3. vo_fps=mpctx-sh_video-fps;4. if(!mpctx-n
18、um_buffered_frames)5. doubleframe_time=update_video(&blit_frame);6. mp_dbg(msgt_avsync,msgl_dbg2,”*ftime=%5.3f*n”,frame_time);7. if(mpctx-sh_video-vf_initedeof=1;gotogoto_next_file;10. 11. if(frame_timeeof=1;13. else14. /mightreturnwith!eof&!blit_frameif!correct_pts15. mpctx-num_buffered_frames+=bli
19、t_frame;16. time_frame+=frame_time/playback_speed;/fornosound17. 18. 精品.关键的函数是update_video根据pts是否正确调整一下同步并在必要的时候丢帧处理。最终调用decode_video开始解码(包括generate_video_frame里)。mpi = mpvdec-decode(sh_video, start, in_size, drop_frame);mpvdec是在main里通过reinit_video_chain的一系列调用动态选定的解码程序。其实就一结构体。它的原型是1. typedefstructv
20、d_functions_s2. 3. vd_info_t*info;4. int(*init)(sh_video_t*sh);5. void(*uninit)(sh_video_t*sh);6. int(*control)(sh_video_t*sh,intcmd,void*arg,);7. mp_image_t*(*decode)(sh_video_t*sh,void*data,intlen,intflags);8. vd_functions_t;这是所有解码器必须实现的接口。int (*init)(sh_video_t *sh);是一个名为init的指针,指向一个接受sh_video_t
21、*类型参数,并返回int类型值的函数地址。那些vd_开头的文件都是解码相关的。随便打开一个vd文件以上几个函数和info变量肯定都包含了。mpi被mplayer用来存储解码后的图像。在mp_image.h里定义。1. typedefstructmp_image_s2. unsignedshortflags;3. unsignedchartype;4. unsignedcharbpp;/bits/pixel.notdepth!forrgbitwillben*85. unsignedintimgfmt;6. intwidth,height;/storeddimensions7. intx,y,w,h;/visibledimensions8. unsignedchar*planesmp_max_planes;9. intstridemp_max_planes;10. char*qscale;11. intqstride;12. intpict_type;/0-unknown,1-i,2-p,3-b13. intfields;14. intqscale_type;/0-mpeg1/4/h263,1-mpeg215. intnum_planes;16. /*th
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 四平职业大学《功能高分子材料》2024-2025学年第二学期期末试卷
- 上海应用技术大学《广播电视新闻研究》2024-2025学年第二学期期末试卷
- 厦门兴才职业技术学院《纳米光电子学》2024-2025学年第二学期期末试卷
- 星海音乐学院《中韩歌曲赏析与学唱》2024-2025学年第二学期期末试卷
- 门诊就诊制度
- 重庆信息技术职业学院《神经生物学1》2024-2025学年第二学期期末试卷
- 陕西工商职业学院《软件工程项目》2024-2025学年第二学期期末试卷
- 2026广西贵港桂平市木乐镇人民法庭招聘安检员1人考试参考题库及答案解析
- 2026四川九洲教育投资管理有限公司招聘数据中心等岗位9人笔试备考题库及答案解析
- 2026江西宜春市人力资源服务有限责任公司招聘1人(宜春市三鑫车辆安全技术检测)笔试备考试题及答案解析
- 2025中国高净值人群金融投资需求与趋势白皮书
- 围手术期高血糖的危害与血糖控制方案
- 互动式内科临床思维模拟教学平台开发
- 管理信息系统2382 历年真题 附答案
- 煤矿反三违行为培训课件
- 中国口腔清洁用品行业研究及十五五规划分析报告
- 2025ACOG产时胎心监测指南解读课件
- 2025年烟台工程职业技术学院单招职业适应性考试题库带答案详解(b卷)
- 2025-2030老年人力资源开发与银发人才价值实现路径研究
- 高级心理统计(第2版)课件 10-结构方程模型
- 云南省专升本2025年烹饪与营养学重点题型练习试卷(含答案)
评论
0/150
提交评论