MPlayer在ARM开发板的移植

 
MPlayer1.0已经把大部分解码库都自带了,如ffmpeg,但是自带的音频库在S32440下效果非常不好.换成使用libmad效果不错.因此MPlayer在ARM-Linux的最简单的移植只需要移植这两个即可.移植后即进行字符界面的播放.ARM的版本由我学生程磊最早运行成功.
 
但完整版本需要如下库.
  如果需要字幕支持.需要移植freetype库.支持JPG皮肤需要libjpeg库,打开DVD光盘格式,需要dvdread,dvdnav等,支持pnm库需要libpnm
 
MPlayer的皮肤主要采用X11支持.但移植X11需要大量工作.这一部分程序由我的学生童军实现,已经在S3C2440开发板上看皮肤的效果.
MPlayer也支持SDL,但是实测好象其实现并不支持皮肤显示.一般将其关掉.
ARM版同样可以加入live555支持,支持远程的RTSP的流媒体播放器,方法同X86版类似.
 
 
MPlayer的简单移植
 
按照移植规范,libmad在libs目录下,MPlayer本身在项目目录下.
 
libmad的移植
CC=arm-linux-gcc ./configure  --prefix=$PWD/../../output/arm_linux  --enable-fpm=arm --host=arm-linux  --disable-debugging  --enable-shared--enable-static
 
修改Makefile 去掉129行-fforce-mem标志,因为arm-eabi编译器都不支持这个选项,否则将会报错
cc1: error: unrecognized command line option"-fforce-mem"
   make[2]: *** [version.lo]Error 1
   make[2]: Leaving directory`/arm/madplay/libs/libmad-0.15.1b''
   make[1]: *** [all-recursive]Error 1
   make[1]: Leaving directory`/arm/madplay/libs/libmad-0.15.1b''
   make: *** [all] Error2
 
 
make
make install
 
MPlayer 的移植
0.下载
 
编译环境:
    在arm-linux-gcc 3.3.2+ARM-Linux 2.6.13.
      arm-linux-gcc 4.3.2 + ARM-Linux 2.6.29
      arm-linux-gcc4.3.3 + ARM-Linux 2.6.30 均测试通过.
 
1.生成Makefile
 
./configure --prefix=$PWD/../output/arm_linux--cc=arm-linux-gcc --ar=arm-linux-ar  \
 --ranlib=arm-linux-ranlib--disable-gui   \
--target=arm-armv4-linux --host-cc=gcc --disable-freetype\
 --enable-fbdev--disable-mencoder --disable-sdl --disable-live --disable-dvdread \
 --disable-libdvdcss-internal --disable-x11--enable-cross-compile --disable-mp3lib \
  --enable-mad --with-extraincdir="$PWD/../output/arm_linux/include --with-extralibdir="$PWD/../output/arm_linux/lib " \
  --disable-dvdnav --disable-dvdread-internal   --disable-jpeg --disable-tga \
 --disable-dvbhead --disable-pnm --disable-tv--disable-ivtv \
 --disable-fontconfig --disable-xanim--disable-win32dll --disable-armv5te --disable-armv6
移植注意.
 
  • MPlayer不支持常见的--host来修改编译工具前缀.必须用--cc,--ar,--ranlib这样参数来修改.而且交叉编译--enable-cross-compile 是必须的.
  • --disable-gui  关闭图形界面,只采用字符界面控制
  • --disable-mp3lib是关闭默认的MP3解码库,--enable-mad 是使用libmad支持.
  • --disable-dvbhead --disable-dvdread--disable-dvdnav --disable-dvdread-internal 都是跟DVD相关库,基本版可以不用安装.
  • --disable-x11 --enable-fbdev 关闭X11视频输出,打开framebuffer支持.ARM开发板必须的.
  • --enable-static如果使用静态编译尺寸大约是8M,动态编译是6M多,这样可能是无论哪种编译方式,mplayer都把自带的解码库链接到自身,多出2M应该是系统标准库的尺寸。

2.编译:

   如果有编译错误,修改源码

  • 在某一些编译器下,会提示找不到intptr_t定义,如果是这样 libavcodec/bitstream.h:181行 ,加入如下语句.

#ifdefined(ARCH_ARMV4L)
typedef int32_t intptr_t ;
#endif

否则会产生如下编译错误,intptr_t在标准C中有定义,但在这里死活找不到,因此直接定义:

arm-linux-gcc -I../libswscale -I../libavcodec -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE-D_ISOC9X_SOURCE -I.. -I.. -I../libavutil -Wdisabled-optimization-Wno-pointer-sign -Wdeclaration-after-statement -I. -I..-I../libavutil -Wall -Wno-switch -Wpointer-arith -Wredundant-decls-O4   -pipe -ffast-math-fomit-frame-pointer -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64-D_LARGEFILE64_SOURCE -DHAVE_CONFIG_H-I/usr/X11R6/include   -c -ocyuv.o cyuv.c
    cc1:warning: include location "/usr/X11R6/include" is unsafe forcross-compilation
In file included from mpegvideo.h:32,
                from cyuv.c:38:
bitstream.h: In function ''put_bits'':
bitstream.h:233: error: ''intptr_t'' undeclared (first usein this function)
bitstream.h:233: error: (Each undeclared identifier is reportedonly once
bitstream.h:233: error: for each function it appears in.)
bitstream.h:233: error: expected '')'' before ''s''
bitstream.h: In function ''init_get_bits'':
bitstream.h:777: error: ''intptr_t'' undeclared (first use in thisfunction)
bitstream.h:777: error: expected '')'' before ''buffer''
bitstream.h:778: error: expected '')'' before ''buffer''
make[1]: *** [cyuv.o] Error 1
  • 去掉ARM pld指令的支持

 修改源码 libavcodec\armv4l\dsputil_arm_s.S,libmpeg2\motion_comp_arm_s.S
在其开始的加入,这段代码意思是定义一个空的ARM汇编宏 pld,这样当代码出现pld指令,就变成一条空指令

#ifndefHAVE_PLD
.macro pld reg
.endm
#endif


pld指令只在armv5te以上版本有效,在2440(armv4l)无效.必须取消掉,这个指令的格式是
预读取PLD指令
功能:cache预读取(PLD,PreLoad),使用PLD指示存储系统从后面几条指令所指定的存储器地址读取,存储系统可使用这种方法加速以后的存储器访问。

格式:
PLD[Rn,{offset}]
其中:
Rn        存储器的基址寄存器。
Offset    加在Rn上的偏移量。含义同3。2。3节第1条指令。

如果不取消,将会产生如下错误

arm-linux-gcc -I../libswscale -I../libavcodec -DHAVE_AV_CONFIG_H-D_FILE_OFFSET                                             _BITS=64 -D_LARGEFILE_SOURCE -D_ISOC9X_SOURCE -I.. -I..-I../libavutil-Wdisable                                             d-optimization -Wno-pointer-sign -Wdeclaration-after-statement -I.-I..-I../lib                                             avutil -Wall -Wno-switch -Wpointer-arith -Wredundant-decls-O4   -pipe-ffast-ma                                             th -fomit-frame-pointer -D_REENTRANT -DHAVE_CONFIG_H-I/home/workspace/MPlayer/M                                             Player-1.0rc2/../output/linux_arm/include-I/usr/X11R6/include  -c -oarmv4l/dsp                                             util_arm_s.o armv4l/dsputil_arm_s.S
cc1: warning: include location "/usr/X11R6/include" is unsafe forcross-compilat                                             ion
armv4l/dsputil_arm_s.S: Assembler messages:
armv4l/dsputil_arm_s.S:79: Error: selected processor doesnot support `pld [r1]''
armv4l/dsputil_arm_s.S:90: Error: selected processor does notsupport `pld [r1]''
armv4l/dsputil_arm_s.S:100: Error: selected processor does notsupport `pld[r1]                                             ''
armv4l/dsputil_arm_s.S:111: Error: selected processor does notsupport `pld[r1]                                             ''
armv4l/dsputil_arm_s.S:122: Error: selected processor does notsupport `pld[r1]                                             ''
armv4l/dsputil_arm_s.S:141: Error: selected processor does notsupport `pld [r1] 

     make

修改make install的bug

执行make install时会提示

install -m 755 -s mplayer/home/hxy/MPlayer/
MPlayer-1.0rc2/../output/arm_linux/bin
strip: Unable to recognise the format of the inputfile
`/home/hxy/MPlayer/MPlayer-1.0rc2/../output/arm_linux/bin/mplayer'

查资料看install带-s参数时会自动调用strip来strip应用程序。但是arm编译时要调用arm-linux-strip才有正确处理。解决办法是取消-s参数,查看Makefile可以发现-s是如下

$(INSTALL) -m 755 $(INSTALLSTRIP)mplayer$(EXESUF)    $(BINDIR)

的INSTALLSTRIP设置的,它默认是-s,因此只要简单在Makefile的前面(95行)加入

INSTALLSTRIP := #将其置为空即可惟

4.执行:

  exportLD_LIBRARY_PATH=${LIB};./mplayer -acmad demo.mpg

 其中$LIB是保存有Mplayer所需的库的路径 -ac mad是必须,表示强制用libmad解码.

这是我的成功执行一段脚本:

export APP_ROOT=/mnt/nfs/MPlayer/output/arm_linuxexport LD_LIBRARY_PATH=$APP_ROOT,OOT/lib;./mplayer -ac mad 2.mpg 

测试mpg,avi,mp3,mp4均可播放,默认是按视频的原始分辨率播放的。如果想让MPlayer完整在LCD上显示,可以用videofilter 参数 scale来设置

./mplayer -vfscale=240:320

另外有人测试发现在有一些开发板下.Mplayer播放后,输出会干扰后续shell的执行行.用下面比较长的参数一般没事

export APP_ROOT=/mnt/nfs/MPlayer/output/arm_linuxexport LD_LIBRARY_PATH=$APP_ROOT,OOT/lib;./mplayer -ac mad 2.mpg -quiet \
 -vf scale=320:240 2>&1 1>/dev/null && 

如果搞不清自己分辩率的,可在MPlayer用-fullscreen参数 .或者执行busybox shell命令fbset查看自n己板的分辩率

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值