• «
  • 1
  • 2
  • »
  • Pages: 1/2     Go
主题 : 实现mplayer在mini2440播放显示位置可变 复制链接 | 浏览器收藏 | 打印
大笑笑大
级别: 骑士
UID: 25314
精华: 8
发帖: 184
金钱: 1320 两
威望: 264 点
贡献值: 8 点
综合积分: 528 分
注册时间: 2010-07-22
最后登录: 2014-10-11
楼主  发表于: 2011-02-11 16:04

 实现mplayer在mini2440播放显示位置可变

管理提醒: 本帖被 kasim 执行加亮操作(2012-12-13)
一直以来都在研究Mplayer能否在mini2440开发板上的控件上播放,即利用-wid 指定到对应控件的Id上显示图像。



然而-wid仅支持openGL x11 DirectX
一开始是认为在开发板上行移植openGL,花了不少时间去研究,openGL有编译移植后,Mplayer却没有识别。
后来发现mplayer移植时也没有编译gl的库。如下为configuer的消息
./configure --host-cc=gcc --cc=arm-linux-gcc --target=arm --enable-static --disable-win32dll --disable-dvdread --disable-dvdread-internal --disable-dvdnav --disable-libdvdcss-internal --enable-fbdev --disable-live --enable-mad --enable-gl --enable-libavcodec_a \
--disable-live 2>&1 | tee logfile

Detected operating system: arm
Detected host architecture: arm
Checking for arm-linux-gcc version ... 4.3.2, ok
Checking for host cc ... gcc
Checking for cross compilation ... ./configure: line 1501: /tmp/mplayer-conf-22834-7462: cannot execute binary file
yes
Checking for assembler support of -pipe option ... yes
Checking for compiler support of named assembler arguments ... yes
Checking for .align is a power of two ... yes
Checking for ARMv5TE (Enhanced DSP Extensions) ... no
Checking for ARMv6 (SIMD instructions) ... no
Checking for iWMMXt (Intel XScale SIMD instructions) ... no
Checking for -lposix ... no
Checking for -lm ... yes
Checking for langinfo ... yes
Checking for language ... using en (man pages: en )
Checking for enable sighandler ... yes
Checking for runtime cpudetection ... no
Checking for restrict keyword ... __restrict
Checking for __builtin_expect ... yes
Checking for kstat ... no
Checking for posix4 ... no
Checking for lrintf ... yes
Checking for mkstemp ... yes
Checking for nanosleep ... yes
Checking for socklib ... yes
Checking for inet_pton() ... yes (using )
Checking for network ... yes
Checking for inttypes.h (required) ... yes
Checking for int_fastXY_t in inttypes.h ... yes
Checking for word size ... ./configure: line 2946: /tmp/mplayer-conf-22834-7462: cannot execute binary file

Checking for malloc.h ... yes
Checking for memalign() ... yes
Checking for alloca.h ... yes
Checking for mman.h ... yes
Checking for dynamic loader ... yes
Checking for dynamic a/v plugins support ... no
Checking for pthread ... yes (using -lpthread)
Checking for w32threads ... no (using pthread instead)
Checking for rpath ... no
Checking for iconv ... yes
Checking for soundcard.h ... yes (sys/soundcard.h)
Checking for sys/dvdio.h ... no
Checking for sys/cdio.h ... no
Checking for linux/cdrom.h ... yes
Checking for dvd.h ... no
Checking for termcap ... no
Checking for termios ... yes (sys/termios.h)
Checking for shm ... yes
Checking for strsep() ... yes
Checking for vsscanf() ... yes
Checking for swab() ... yes
Checking for POSIX select() ... yes
Checking for gettimeofday() ... yes
Checking for glob() ... yes
Checking for setenv() ... yes
Checking for sys/sysinfo.h ... yes
Checking for pkg-config ... yes
Checking for Samba support (libsmbclient) ... no
Checking for tdfxfb ... no
Checking for s3fb ... no
Checking for tdfxvid ... no
Checking for xvr100 ... no
Checking for tga ... yes
Checking for md5sum support ... yes
Checking for bl ... no
Checking for DirectFB ... no
Checking for X11 headers presence ... yes
Checking for X11 ... no (check if the dev(el) packages are installed)
Checking for DPMS ... no
Checking for Xv ... no
Checking for XvMC ... no
Checking for Xinerama ... no
Checking for Xxf86vm ... no
Checking for XF86keysym ... no
Checking for DGA ... no
Checking for 3dfx ... no
Checking for OpenGL ... no
Checking for VIDIX ... no
Checking for /dev/mga_vid ... no
Checking for xmga ... no
Checking for GGI ... no
Checking for GGI extension: libggiwmh ... no
Checking for AA ... no
Checking for CACA ... no
Checking for SVGAlib ... no
Checking for FBDev ... yes
Checking for DVB ... no
Checking for DVB HEAD ... yes
Checking for zr ... no
Checking for PNG support ... yes
Checking for JPEG support ... yes
Checking for PNM support ... yes
Checking for GIF support ... no
Checking for VESA support ... no
Checking for SDL ... no
Checking for NAS ... no
Checking for DXR2 ... no
Checking for DXR3/H+ ... no
Checking for IVTV TV-Out ... no
Checking for V4L2 MPEG Decoder ... yes
Checking for OSS Audio ... yes
Checking for aRts ... no
Checking for EsounD ... no
Checking for Polyp ... no
Checking for JACK ... no
Checking for OpenAL ... no
Checking for ALSA audio ... no
Checking for Sun audio ... no
Checking for VCD support ... no (not supported on this OS)
Checking for dvdread ... no
Checking for internal libdvdcss ... no
Checking for cdparanoia ... no
Checking for libcdio ... no
Checking for bitmap font support ... yes
Checking for freetype >= 2.0.9 ... no
Checking for fontconfig ... no (freetype support needed)
Checking for SSA/ASS support ... no (FreeType support needed)
Checking for fribidi with charsets ... no
Checking for ENCA ... no
Checking for zlib ... yes
Checking for RTC ... yes
Checking for liblzo2 support ... no
Checking for mad support ... yes
Checking for Twolame ... no
Checking for Toolame ... no
Checking for OggVorbis support ... yes (internal Tremor)
Checking for libspeex (version >= 1.1 required) ... no
Checking for OggTheora support ... no
Checking for internal mp3lib support ... yes
Checking for internal liba52 support ... yes
Checking for libdca support ... no
Checking for internal libmpeg2 support ... yes
Checking for libmpcdec (musepack, version >= 1.2.1 required) ... no
Checking for FAAC (AAC encoder) support ... no (in libavcodec: )
Checking for FAAD2 (AAC) support ... yes (internal floating-point)
Checking for LADSPA plugin support ... no
Checking for Win32 codecs ... no
Checking for XAnim codecs ... yes (using /usr/lib/codecs)
Checking for RealPlayer codecs ... no (dynamic loader support needed)
Checking for QuickTime codecs ... auto
Checking for Nemesi Streaming Media libraries ... no
Checking for LIVE555 Streaming Media libraries ... no
Checking for FFmpeg libavutil ... yes (static)
Checking for FFmpeg libavcodec ... yes (libavcodec.so is discouraged over static libavcodec)
Checking for FFmpeg libavformat ... yes (static)
Checking for FFmpeg libpostproc ... yes (static)
Checking for libamr narrowband ... no
Checking for libamr wideband ... no
Checking for libdv-0.9.5+ ... no
Checking for XviD ... no
Checking for x264 ... no (in libavcodec: no)
Checking for libnut ... no
Checking for libmp3lame (for mencoder) ... no
Checking for mencoder ... yes
Checking for fastmemcpy ... yes
Checking for UniquE RAR File Library ... yes
Checking for TV interface ... yes
Checking for Video 4 Linux TV interface ... no
Checking for Video 4 Linux 2 TV interface ... no
Checking for TV teletext interface ... no
Checking for Radio interface ... no
Checking for Capture for Radio interface ... no
Checking for Video 4 Linux 2 Radio interface ... no
Checking for Video 4 Linux Radio interface ... no
Checking for Video 4 Linux 2 MPEG PVR interface ... no
Checking for audio select() ... yes
Checking for ftp ... yes
Checking for vstream client ... no
Checking for byte order ... little-endian
Checking for OSD menu ... no
Checking for Subtitles sorting ... yes
Checking for XMMS inputplugin support ... no
Checking for inet6 ... yes
Checking for gethostbyname2 ... yes
Checking for GUI ... no
Checking for automatic gdb attach ... no
Checking for compiler support for noexecstack ... yes
Checking for joystick ... no
Checking for lirc ... no
Checking for lircc ... no
Checking for maemo (Nokia 770) ... no
Checking for color console output ... no
Checking for DVD support (libdvdnav) ... no
Creating config.mak
Creating config.h

  Install prefix: /usr/local
  Data directory: /usr/local/share/mplayer
  Config direct.: /usr/local/etc/mplayer

  Byte order: little-endian
  Optimizing for:

  Languages:
    Messages/GUI: en
    Manual pages: en  

  Enabled optional drivers:
    Input: ftp tv dvb network
    Codecs: libavcodec xanim faad2 libmpeg2 liba52 mp3lib tremor(internal) libmad
    Audio output: oss v4l2 mpegpes(dvb)
    Video output: v4l2 pnm jpeg png mpegpes(dvb) fbdev md5sum tga
    Audio filters:
  Disabled optional drivers:
    Input: dvdnav vstream pvr radio tv-teletext tv-v4l2 tv-v4l1 live555 nemesi cddb cdda libdvdcss(internal) dvdread vcd smb
    Codecs: x264 xvid libdv libamr_wb libamr_nb qtx real win32 faac musepack libdca libtheora speex toolame twolame liblzo gif
    Audio output: sun alsa openal jack polyp esd arts ivtv dxr2 nas sdl
    Video output: ivtv dxr3 dxr2 sdl vesa gif89a zr zr2 svga caca aa ggi xmga mga xvidix winvidix cvidix opengl 3dfx dga xvmc xv x11 dfbmga directfb bl xvr100 tdfx_vid s3fb tdfxfb
    Audio filters: ladspa

'config.h' and 'config.mak' contain your configuration options.
Note: If you alter theses files (for instance CFLAGS) MPlayer may no longer
      compile *** DO NOT REPORT BUGS if you tweak these files ***

'make' will now compile MPlayer and 'make install' will install it.
Note: On non-Linux systems you might need to use 'gmake' instead of 'make'.

NOTE: Win32 codec DLLs are not supported on your CPU (arm) or your
operating system (arm). You may encounter a few files that cannot
be played due to missing open source video/audio codec support.

Check configure.log if you wonder why an autodetection failed (make sure
development headers/packages are installed).

NOTE: The --enable-* parameters unconditionally force options on, completely
skipping autodetection. This behavior is unlike what you may be used to from
autoconf-based configure scripts that can decide to override you. This greater
level of control comes at a price. You may have to provide the correct compiler
and linker flags yourself.
If you used one of these options (except --enable-gui and similar ones that
turn on internal features) and experience a compilation or linking failure,
make sure you have passed the necessary compiler/linker flags to configure.

If you suspect a bug, please read DOCS/HTML/en/bugreports.html.


在网上搜索不到解决方法,有的朋友说mini2440即s3c2440 armv4t没有硬件解码支持,所以编译永远也不会加载opengl进去。

另外通过一段时间将播放器的大概界面写了下,用的是qtopia编译环境,出现的其中一个问题是视频输出为-vo fbdev ,是从坐标0,0开始刷新内存的。如图2,理想的状态是如图3.

        
图2                                      图1
图3

从网上学到一点资料:
mplayer中关于framebuffer设备的流程
2009-09-25 20:22
http://blog.csdn.net/houdiney/archive/2009/03/10/3973882.aspx
注:本文只关注FBDEV相关的内容,其他的或不提,或略过。[由于时间比较紧,许多地方肯定还有不足的地方,欢迎指教]
首先从Mplayer.c中的main函数开始,
注意到
//================== Init VIDEO (codec & libvo) ==========================
current_module=”preinit_libvo”;
if(!(video_out=init_best_video_out(video_driver_list)))
--
mpctx->video_out=init_best_video_out(video_driver_list);
--
这将跳进Video_out.c
for(i=0;video_out_drivers;i++){
if(!video_driver->preinit(vo_subdevice))
如果你的FBDEV打开的话,即若有
#ifdef HAVE_FBDEV
&video_out_fbdev,
&video_out_fbdev2,
那么,video_driver->preinit(vo_subdevice)这句话将跳进Vo_fbdev.c中执行preinit操作。
Preinit中进行了
fb_dev_fd = open(fb_dev_name, O_RDWR)
和一些ioctl对framebuffer设备的信息进行读取:
ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)
至此,FBDEV相关的pre初始化操作基本结束。
。。。省略其他无关的信息
进入
/*========================== PLAY VIDEO =============
这里面最重要的一个操作就是解出一帧:
//——————– Decode a frame: ———————-
// get it!
current_module=”video_read_frame”;
具体如何解赞不提,但应关注一下结果:
in_size=video_read_frame(sh_video,&next_frame_time,&start,force_fps);
其中video_read_frame是Video.c中的函数,这个操作得到了这一帧的数据信息在
内存区的起始值start和长度in_size;
由于现在得到的帧还只是未解码的信息,
下一步就是要进行解码操作:
// decode:
current_module=”decode_video”;
blit_frame=decode_video(sh_video,start,in_size,drop_frame);
执行时将跳进Dec_video.c中的decode_video函数,
mpi=mpvdec->decode(sh_video, start, in_size, drop_frame);
之后,得到了这一帧的原始的mp_image_t的图像格式,基本上可以说是最终可用的数据了。
下一步就是如何将数据刷进Fb设备中了。
vf=sh_video->vfilter;
ret = vf->put_image(vf,mpi); // apply video filters and call the leaf vo/ve
这段实际上就是我们想要的。
原来的作者曾有一句注释掉的,则更为清晰:
//vo_draw_image(video_out,mpi);
意思则是说将mpi数据直接刷到已经初始化好的video_out中去。
Vf_vo.c中实现了上述一段的主要功能:
#define video_out ((vo_functions_t*)(vf->priv)) 定义了video_out实际为vo_functions_t类型,
而vf->put_image(vf,mpi)的实现中
video_out->draw_slice(mpi->planes,mpi->stride,mpi->w,mpi->h,mpi->x,mpi->y);
调用draw_slice函数的原型为在Video_out.h中的
/*
* Draw a planar YUV slice to the buffer:
* params:
* src[3] = source image planes (Y,U,V)
* stride[3] = source image planes line widths (in bytes)
* w,h = width*height of area to be copied (in Y pixels)
* x,y = position at the destination image (in Y pixels)
*/
uint32_t (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
也就是此时将调用Vo_fbdev.c中的
static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
{
uint8_t *d;
uint8_t *s;
d = center + (fb_line_len * y + x) * fb_pixel_size;
s = src[0];
while (h) {
memcpy(d, s, w * fb_pixel_size);
d += fb_line_len;
s += stride[0];
h–;
}
return 0;
}
从而完成从mpi到framebuffer的内存拷贝!

转帖(Mplayer 分析 FBDEV)
http://hi.baidu.com/zhang_xuming/blog/item/83799c0ae24f041595ca6b3d.html(原文地址)

注:本文只关注FBDEV相关的内容,其他的或不提,或略过。[由于时间比较紧,许多地方肯定还有不足的地方,欢迎指教]

首先从Mplayer.c中的main函数开始,
注意到
//================== Init VIDEO (codec & libvo) ==========================
current_module=”preinit_libvo”;
if(!(video_out=init_best_video_out(video_driver_list)))
这将跳进Video_out.c
for(i=0;video_out_drivers;i++){
if(!video_driver->preinit(vo_subdevice))
如果你的FBDEV打开的话,即若有
#ifdef HAVE_FBDEV
&video_out_fbdev,
&video_out_fbdev2,
那么,video_driver->preinit(vo_subdevice)这句话将跳进Vo_fbdev.c中执行preinit操作。
Preinit中进行了
fb_dev_fd = open(fb_dev_name, O_RDWR)
和一些ioctl对framebuffer设备的信息进行读取:
ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)
至此,FBDEV相关的pre初始化操作基本结束。
。。。省略其他无关的信息
进入
uint32_t (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
也就是此时将调用Vo_fbdev.c中的
static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, int y)
{
uint8_t *d;
uint8_t *s;
d = center + (fb_line_len * y + x) * fb_pixel_size;
s = src[0];
while (h) {
memcpy(d, s, w * fb_pixel_size);
d += fb_line_len;
s += stride[0];
h–;
}
return 0;
}
从而完成从mpi到framebuffer的内存拷贝!
---------------------------------------------------
Mplayer 中的版本管理
原文地址: http://kware.blogbus.com/logs/17613567.html
1. Mplayer 中的版本管理
   1) 文件 Makefile 中处理
      depend: help_mp.h
        ./version.sh `$(CC) -dumpversion`
      # 这里将编译器的版本号也追加在整体版本号
   2) 文件中 version.sh 中的处理
      #!/bin/sh
      echo "#define VERSION "1.0pre7try2-$1-josa1.0"" > version.h
      #自动生成 version.h 文件。这里增加了 josa 版本号
      #文件 version.h 里只有一行:#define VERSION "1.0pre7try2-3.2.3-josa1.0"
   3) 版本号使用
      // 初始化,消息系统 …… mplayer.c 中
      mp_msg(MSGT_CPLAYER, MSGL_INFO, "MPlayer " VERSION " (C) 2000-2005 Yifang NTT Team\n");
   4) 编解码器的版本号问题 libancodec/utils.c
      unsigned avcodec_version( void ) { return LIBAVCODEC_VERSION_INT; }
      unsigned avcodec_build( void ) { return LIBAVCODEC_BUILD; }
2. Mplayer 安全禁用函数的使用
   错误:“utils.c: undefined reference to `time_is_forbidden_due_to_security_issues'”
   解决方案:
   #undef fprintf
   #undef time
     josaf = fopen(fn, "wt");
     time(&rawtime);                       // 获取当地时间
     fprintf(josaf, "Josa Begin! " VERSION ", Yuchun Ji, %s\n", ctime(&rawtime));
     av_log_callback = josa;
   #define fprintf please_use_av_log
   #define time time_is_forbidden_due_to_security_issues
3. 原始技术资料文本
   F:\MPlayer-1.0pre7try2\DOCS\tech\libmpcodecs.txt
   The libMPcodecs API details, hints - by A'rpi
   ==================================
   See also: colorspaces.txt, codec-devel.txt, dr-methods.txt, codecs.conf.txt
       [MPlayer core]
             | (1)
        _____V______   (2)  /~~~~~~~~~~\    (3,4) |~~~~~~|
        |          | -----> | vd_XXX.c | -------> | vd.c |
        | decvideo |        \__________/ <-(3a)-- |______|
        |          | -----, ,.............(3a,4a).....:
        ~~~~~~~~~~~~ (6) V V
          /~~~~~~~~\     /~~~~~~~~\ (8)
          | vf_X.c | --> | vf_Y.c | ----> vf_vo.c / ve_XXX.c
          \________/     \________/
              |              ^
          (7) |   |~~~~~~|   : (7a)
              `-> | vf.c |...:
                  |______|
4. 音视频解码器选择
   1) 在 libmpcodec/dec_audio.c 文件 init_best_audio_codec() 函数中
      // 输出的三项信息分别为“编解码器名称、驱动程序、描述信息”
      tprintf("\nACD:%s AFM:%s(%s)",
        sh_audio->codec->name, sh_audio->codec->drv, sh_audio->codec->info);
   2) 在 libmpcodec/dec_video.c 文件 init_best_video_codec() 函数中
      // 输出的三项信息分别为“编解码器名称、驱动程序、描述信息”
      tprintf("\nVCD:%s VFM:%s(%s)\n",
        sh_video->codec->name, sh_video->codec->drv, sh_video->codec->info);
5. 文件 codecs.conf.h 的自动生成机制
   1) 元工具 codec_cfg.exe 的生成,在 Makefile 文件里
      PRG_CFG = codec-cfg
      $(PRG_CFG): version.h codec-cfg.c codec-cfg.h
        $(HOST_CC) $(HOST_CFLAGS) -I. -g codec-cfg.c mp_msg.c -o $(PRG_CFG) -DCODECS2HTML \
          $(EXTRA_LIB) $(EXTRA_INC) $(I18NLIBS)
   2) 使用生成的 codec_cfg.exe 工具生成 codecs.conf.h 头文件,在 Makefile 文件里
      codecs.conf.h: $(PRG_CFG) etc/codecs.conf
        ./$(PRG_CFG) ./etc/codecs.conf > $@
   3) 元工具 codec-cfg.c 分析
      目的是将编解码器配置文件 etc/codecs.conf 转化为 codecs.conf.h 文件。源配置格式见下节,目标格
      式如下:
    
      codecs_t builtin_video_codecs[] = {
      {{0x10000001, 0x10000002, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
       {0x10000001, 0x10000002, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0},                                
       {0x4D504553, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},
       {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},                          
       {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1},          
       {0,0,0,0,0,0,0,0,0, 0, 0, 0, 0, 0, 0, 0 },                  
       "mpegpes",                                                  
       "MPEG-PES output (.mpg or DXR3/DVB card)",                  
       "for hardware decoding",                                    
       NULL,                                                      
       "mpegpes",                                                  
       {0x00000000,0,0,{0, 0, 0, 0, 0, 0, 0, 0}},                  
       0, 1, 0                                                    
      }
   4) 编解码器配置文件 etc/codecs.conf 分析
      ;=============================================================================
      ; Default codecs config file. It replaces the old codecs.c file!
      ; Before editing this file, please read DOCS/tech/codecs.conf.txt !
      ;=============================================================================
      release 20030724
      ; MPEG-1/2 decoding:
      ; Note: mpegpes is preferred for hw decoders:
      videocodec mpegpes
        info "MPEG-PES output (.mpg or DXR3/DVB card)"
        comment "for hardware decoding"
        status working
        format 0x10000001 ; mpeg 1
        format 0x10000002 ; mpeg 2
        driver mpegpes
        out MPES
6. 打包源代码 MPlayer-1.0pre7try2-josa1.0.rar
   原始容量 33.20MB, 234,832,312 字节, 2341 个文件 115 个目录;
   压 缩 后 8.99MB    9,432,977 字节

   这篇文章讲的时间比较早了,其实内容可以用粗旷形容。尽管说的基本上都是对的,但我还是不懂他想说些什么。题目起的莫名其妙哦~,还有,作者有版权声明的 “版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
http://kware.blogbus.com/logs/17613567.html”,要是转载的话要注意了哈。

----------------------------------------------------
Mplayer代码阅读
原文地址: http://qzone.qq.com/blog/81182980-1228458373
此文还有另外版本的链接:http://uthz.com/tag/%E8%A7%86%E9%A2%91/
从Mplayer.c的main开始
处理参数
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);
初始化mpctx结构体,mpctx应该是mplayer context的意思,顾名思义是一个统筹全局的变量。
static MPContext *mpctx = &mpctx_s;
// Not all functions in mplayer.c take the context as an argument yet
static MPContext mpctx_s = {
.osd_function = OSD_PLAY,
.begin_skip = MP_NOPTS_VALUE,
.play_tree_step = 1,
.global_sub_pos = -1,
.set_of_sub_pos = -1,
.file_format = DEMUXER_TYPE_UNKNOWN,
.loop_times = -1,
#ifdef HAS_DVBIN_SUPPORT
.last_dvb_step = 1,
#endif
};
原型
typedef struct MPContext {
int osd_show_percentage;
int osd_function;
ao_functions_t *audio_out;
play_tree_t *playtree;
play_tree_iter_t *playtree_iter;
int eof;
int play_tree_step;
int loop_times;
stream_t *stream;
demuxer_t *demuxer;
sh_audio_t *sh_audio;
sh_video_t *sh_video;
demux_stream_t *d_audio;
demux_stream_t *d_video;
demux_stream_t *d_sub;
mixer_t mixer;
vo_functions_t *video_out;
// Frames buffered in the vo ready to flip. Currently always 0 or 1.
// This is really a vo variable but currently there’s no suitable vo
// struct.
int num_buffered_frames;
// AV sync: the next frame should be shown when the audio out has this
// much (in seconds) buffered data left. Increased when more data is
// written to the ao, decreased when moving to the next frame.
// In the audio-only case used as a timer since the last seek
// by the audio CPU usage meter.
double delay;
float begin_skip; ///< start time of the current skip while on edlout mode
// audio is muted if either EDL or user activates mute
short edl_muted; ///< Stores whether EDL is currently in muted mode.
short user_muted; ///< Stores whether user wanted muted mode.
int global_sub_size; // this encompasses all subtitle sources
int global_sub_pos; // this encompasses all subtitle sources
int set_of_sub_pos;
int set_of_sub_size;
int global_sub_indices[SUB_SOURCES];
一些GUI相关的操作
打开字幕流
打开音视频流
mpctx->stream=open_stream(filename,0,&mpctx->file_format);
fileformat文件还是TV流DEMUXER_TYPE_PLAYLIST或DEMUXER_TYPE_UNKNOWN DEMUXER_TYPE_TV
current_module记录状态vobsub open_stream handle_playlist dumpstream
stream_reset(mpctx->stream);
stream_seek(mpctx->stream,mpctx->stream->start_pos);
f=fopen(stream_dump_name,”wb”); dump文件流
stream->type==STREAMTYPE_DVD
//============ Open DEMUXERS — DETECT file type ======================
Demux。分离视频流和音频流
mpctx->demuxer=demux_open(mpctx->stream,mpctx->file_format,audio_id,video_id,dvdsub_id,filename);
Demux过程
demux_open
get_demuxer_type_from_name
……
mpctx->d_audio=mpctx->demuxer->audio;
mpctx->d_video=mpctx->demuxer->video;
mpctx->d_sub=mpctx->demuxer->sub;
mpctx->sh_audio=mpctx->d_audio->sh;
mpctx->sh_video=mpctx->d_video->sh;
分离了之后就开始分别Play audio和video
这里只关心play video
vo_pts=mpctx->sh_video->timer*90000.0;
vo_fps=mpctx->sh_video->fps;
if (!mpctx->num_buffered_frames) {
double frame_time = update_video(&blit_frame);
mp_dbg(MSGT_AVSYNC,MSGL_DBG2,”*** ftime=%5.3f ***\n”,frame_time);
if (mpctx->sh_video->vf_inited < 0) {
mp_msg(MSGT_CPLAYER,MSGL_FATAL, MSGTR_NotInitializeVOPorVO);
mpctx->eof = 1; goto goto_next_file;
}
if (frame_time < 0)
mpctx->eof = 1;
else {
// might return with !eof && !blit_frame if !correct_pts
mpctx->num_buffered_frames += blit_frame;
time_frame += frame_time / playback_speed; // for nosound
}
}
关键的函数是update_video
根据pts是否正确调整一下同步并在必要的时候丢帧处理。
最终调用decode_video开始解码(包括generate_video_frame里)。
mpi = mpvdec->decode(sh_video, start, in_size, drop_frame);
mpvdec是在main里通过reinit_video_chain的一系列调用动态选定的解码程序。
其实就一结构体。它的原型是
typedef struct vd_functions_s
{
vd_info_t *info;
int (*init)(sh_video_t *sh);
void (*uninit)(sh_video_t *sh);
int (*control)(sh_video_t *sh,int cmd,void* arg, …);
mp_image_t* (*decode)(sh_video_t *sh,void* data,int len,int flags);
} vd_functions_t;
这是所有解码器必须实现的接口。
int (*init)(sh_video_t *sh);是一个名为init的指针,指向一个接受sh_video_t *类型参数,并返回int类型值的函数地址。
那些vd_开头的文件都是解码相关的。随便打开一个vd文件以上几个函数和info变量肯定都包含了。
mpi被mplayer用来存储解码后的图像。在mp_image.h里定义。
typedef struct mp_image_s {
unsigned short flags;
unsigned char type;
unsigned char bpp; // bits/pixel. NOT depth! for RGB it will be n*8
unsigned int imgfmt;
int width,height; // stored dimensions
int x,y,w,h; // visible dimensions
unsigned char* planes[MP_MAX_PLANES];
int stride[MP_MAX_PLANES];
char * qscale;
int qstride;
int pict_type; // 0->unknown, 1->I, 2->P, 3->B
int fields;
int qscale_type; // 0->mpeg1/4/h263, 1->mpeg2
int num_planes;
int chroma_width;
int chroma_height;
int chroma_x_shift; // horizontal
int chroma_y_shift; // vertical
void* priv;
} mp_image_t;
图像在解码以后会输出到显示器,mplayer本来就是一个视频播放器么。但也有可能作为输入提供给编码器进行二次编码,MP附带的mencoder.exe就是专门用来编码的。在这之前可以定义filter对图像进行处理,以实现各种效果。所有以vf_开头的文件,都是这样的filter。
图像的显示是通过vo,即video out来实现的。解码器只负责把解码完成的帧传给vo,怎样显示就不用管了。这也是平台相关性最大的部分,单独分出来的好处是不言而喻的,像在Windows下有通过direcx实现的vo,Linux下有输出到X的vo。vo_*文件是各种不同的vo实现,只是他们不都是以显示为目的,像vo_md5sum.c只是计算一下图像的md5值。
在解码完成以后,即得到mpi以后,filter_video被调用,其结果是整个filter链上的所有filter都被调用了一遍,包括最后的VO,在vo的put_image里把图像输出到显示器。这个时候需要考虑的是图像存储的方法即用哪种色彩空间。
[MPlayer core]
| (1)
_____V______   (2) /~~~~~~~~~~\    (3,4) |~~~~~~|
|          | —–> | vd_XXX.c | ——-> | vd.c |
| decvideo |        \__________/ <-(3a)– |______|
|          | —–, ,………….(3a,4a)…..:
~~~~~~~~~~~~ (6) V V
/~~~~~~~~\     /~~~~~~~~\ (8)
| vf_X.c | –> | vf_Y.c | —-> vf_vo.c / ve_XXX.c
\________/     \________/
|              ^
(7) |   |~~~~~~|   : (7a)
`-> | vf.c |…:
|______|
感觉Mplayer的开发人员们都是无比的牛,硬是用原始的C实现了很多OO语言才支持的特性,带来不好的结果是代码看起来比较费劲.

这位兄弟说出了俺的心里话:"感觉Mplayer的开发人员们都是无比的牛".哦,他还有一篇大作在下面,嘿嘿。

Mplayer的目录结构和子文件夹说明
原文地址:http://qzone.qq.com/blog/81182980-1235106011
libavcodec libavformat libavutil三个文件夹来自ffmpeg的库 ;
libfaad2 libao2 liba52 libmpg2 mp3lib vidix几个文件夹是其它的三方库 ;
libmpcodecs libmpdemux 文件夹中为mplayer 的 demux 和codecs。 ;
其中demux_XXX.c为处理各种不同的container.
vd_XXX.c为mplayer的内置视频解码器,ad_xxx.c是音频解码器。
vf_XXX.c 和af_XXX.c 为视,音频的各种filter。
vo_XXX.c 为解码后视频输出。
libvo 视频输出模块的 Make 文件配置部分头
libao2 音频输出模块的 Make 文件配置部分头
drivers    使用 VIDIX 技术用到的直接硬件访问驱动程序

怎么样,还是很注重条理的吧?不过,vo_XXX.c是在libvo下说的哦
========================================================================================================================以上为网络参考资料============================================


通过对vo_fbdev.c里面的:
static int draw_slice(uint8_t *src[], int stride[], int w, int h, int x,
        int y)
{
    uint8_t *d;
    uint8_t *s;
    
    d = center + fb_line_len * y + fb_pixel_size * x;

    s = src[0];
    while (h) {
        fast_memcpy(d, s, w * fb_pixel_size);
        d += fb_line_len;
        s += stride[0];
        h--;
    }

    return 0;
}
的分析,可以看出,x,y为缓存图像坐标的起始点
只要改d = center + fb_line_len * y + fb_pixel_size * x;为d = center + fb_line_len * (y+15) + fb_pixel_size * x;后保存重新编译就可以了。
然而编译后全屏播放也一样会偏移15pix,即标题栏没有覆盖!
引发出能否自己添加外部命令参数,通过对geometry.c,vo_s3fb.c,vo_fbdev.c进行分析,可以利用geometry的x y参数赋值。因为-geometry本来只对x11 xmga xv xvmc xvidix gl gl2 directx和tdfxfb有效,现在我们添加上对fbdev也有效!
其他均不变!
在vo_fbdev.c开头添加库文件
#include "geometry.h"
定义四个变量
static uint32_t fbwidth, fbheight, fbx, fby;
在static int config(uint32_t width, uint32_t height, uint32_t d_width,
        uint32_t d_height, uint32_t flags, char *title,
        uint32_t format)的末尾添加参数获取命令:
geometry(&fbx, &fby, &fbwidth, &fbheight, 240, 320);//注意,后面的为screenwidth和screenheight.不能为0,0
mp_msg(MSGT_VO, MSGL_INFO, "fbdev: output is at %dx%d +%dx%d\n", fbx, fby, fbwidth, fbheight);
在将d = center + fb_line_len * y + fb_pixel_size * x改为d = center + fb_line_len * (y + fby) + fb_pixel_size * (x + fbx);
重新编译后得到Mplyaer文件即可
执行./mplayer_cxy /root/Documents/videos/panda.mpg -vo fbdev -geometry +0+15
效果如图3所示

附件为doc 含有图
自由,自强,共享,共创。
级别: 论坛版主
UID: 12573
精华: 27
发帖: 8838
金钱: 46490 两
威望: 9298 点
贡献值: 27 点
综合积分: 18216 分
注册时间: 2010-01-09
最后登录: 2019-07-16
1楼  发表于: 2011-02-11 16:19
专家,给力
新手如何向我们反馈有效的信息,以便解决问题,见此贴:
http://www.arm9home.net/read.php?tid-14431.html

[注]: 此处签名链接仅为指引方向,而非解答问题本身.
大笑笑大
级别: 骑士
UID: 25314
精华: 8
发帖: 184
金钱: 1320 两
威望: 264 点
贡献值: 8 点
综合积分: 528 分
注册时间: 2010-07-22
最后登录: 2014-10-11
2楼  发表于: 2011-02-12 15:08

 回 1楼(mindee) 的帖子

版主也很给力 ,但俺还是菜鸟一个,多谢支持
级别: 新手上路
UID: 35993
精华: 0
发帖: 15
金钱: 75 两
威望: 15 点
贡献值: 0 点
综合积分: 30 分
注册时间: 2011-01-10
最后登录: 2017-09-13
3楼  发表于: 2011-05-02 12:24
给了啊!!!
级别: 新手上路
UID: 30467
精华: 0
发帖: 14
金钱: 70 两
威望: 14 点
贡献值: 0 点
综合积分: 28 分
注册时间: 2010-10-17
最后登录: 2011-10-29
4楼  发表于: 2011-05-06 04:20
强。。。来学习。
级别: 新手上路
UID: 54419
精华: 0
发帖: 2
金钱: 10 两
威望: 2 点
贡献值: 0 点
综合积分: 4 分
注册时间: 2011-08-30
最后登录: 2011-11-25
5楼  发表于: 2011-08-30 15:07
这篇太给力了
级别: 侠客
UID: 14158
精华: 0
发帖: 52
金钱: 260 两
威望: 52 点
贡献值: 0 点
综合积分: 104 分
注册时间: 2010-02-03
最后登录: 2012-03-08
6楼  发表于: 2011-11-02 21:08
星星之火,可以燎原
级别: 骑士
UID: 42844
精华: 2
发帖: 140
金钱: 805 两
威望: 161 点
贡献值: 2 点
综合积分: 320 分
注册时间: 2011-04-11
最后登录: 2016-05-23
7楼  发表于: 2011-11-03 17:15
研究的很彻底啊!学习学习了!
星星之火,可以燎原!
级别: 新手上路
UID: 81590
精华: 0
发帖: 13
金钱: 65 两
威望: 13 点
贡献值: 0 点
综合积分: 26 分
注册时间: 2012-11-11
最后登录: 2012-11-13
8楼  发表于: 2012-11-12 11:40
这个很好
级别: 新手上路
UID: 87590
精华: 0
发帖: 17
金钱: 85 两
威望: 17 点
贡献值: 0 点
综合积分: 34 分
注册时间: 2013-02-21
最后登录: 2014-03-04
9楼  发表于: 2013-02-22 09:29
谢谢分享了,提供一种比较方便的方法,以后不用每次都编译了
  • «
  • 1
  • 2
  • »
  • Pages: 1/2     Go