编译android用的x264
来源:互联网 发布:上海浦东机场有没有mac 编辑:程序博客网 时间:2024/05/25 20:01
本文很多内容转载自:
http://bashell.sinaapp.com/archives/cross-complie-pthread-android-x264-library.html
因为编译过程中根据自己的需要修改了部分内容,记录下以供自己及其它人以后参考。
编译工具为:ndkr9c, API9, GCC4.6
x264版本是:x264-20120827-2245
原文中第一步需制作自己的交叉编译工具链,因为发现制作前后的一样,所以直接跳过第一步,进行第二步:修改x264中的configure文件
if [ "$thread" = "auto" ]; then
thread="no"
case $SYS in
BEOS)
thread="beos"
define HAVE_BEOSTHREAD
;;
WINDOWS)
if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
thread="posix"
libpthread="-lpthread"
elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
thread="posix"
libpthread="-lpthreadGC2"
elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
thread="posix"
libpthread="-lpthreadGC2 -lwsock32"
define PTW32_STATIC_LIB
elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
thread="posix"
libpthread="-lpthreadGC2 -lws2_32"
define PTW32_STATIC_LIB
else
# default to native threading if pthread-win32 is unavailable
thread="win32"
fi
;;
OPENBSD)
cc_check pthread.h -pthread && thread="posix" && libpthread="-pthread"
;;
*)
cc_check pthread.h -lc && thread="posix" && libpthread="-lc"
;;
esac
fi
蓝色字体部分即为修改部分;
修改完configure并make,发现确实已经提示支持posix多线程,在此再次感谢原博文作者;
但是配置完编译的过程中,却发现在x264/common/cpu.c中的x264_cpu_num_processors函数中有未声明类型cpu_set_t p_aff,导致编译不过,
不过原博文已经提供了解决办法,通过读取sys/devices/system/cpu/present文件来读取cpu核心数量,代码如下:
int getNrOfCPUs()
{
FILE* fp;
int res, i = -1, j = -1;
/* open file */
fp = fopen("/sys/devices/system/cpu/present", "r");
if (fp == 0)
{
return -1; /* failure */
}
/* read and interpret line */
res = fscanf(fp, "%d-%d", &i, &j);
/* close file */
fclose(fp);
/* interpret result */
if (res == 1 && i == 0) /* single-core? */
{
return 1;
}
if (res == 2 && i == 0) /* 2+ cores */
{
return j+1;
}
return 1; /* failure */
}
int x264_cpu_num_processors( void )
{
return getNrOfCPUs();
}
修改cpu.c之后,x264顺利编译完成,生成 libx264.a库;
可能原文并没有遇到下述问题,在后续的调用x264过程中出现问题:
cannot scan executable section 1 of libx264.a(dct-a.o) for Cortex-A8 erratum because it has no mapping symbols
查找后从http://code.google.com/p/android/issues/detail?id=40794#c4得出答案,在makefile文件的182及186行需要修改
-@ $(if $(STRIP), $(STRIP) -x $@) # delete local/anonymous symbols, so they don't show up in oprofile修改为以下蓝字
-@ $(if $(STRIP), $(STRIP) -x -K \$$a -K \$$t -K \$$d $@) #delete local/anonymous symbols, so they don't show up in oprofile, except the mapping symbols
接下来就可以顺利对视频进行转码压缩了;
之后的一段时间因为需要提高转码效率,读了原博文作者的http://bashell.sinaapp.com/archives/x264-encoding-live-stream-config-and-optimization-on-android-ios-platform.html,受益匪浅,非常感谢!
- 编译android用的x264
- x264 for Android 的编译
- 编译Android下可用的FFmpeg+x264
- ffmpeg支持x264的android平台编译
- 编译用于Android的FFmpeg&x264
- android编译ffmpeg+x264
- android编译ffmpeg+x264
- android编译ffmpeg+x264
- android编译ffmpeg+x264
- Android 编译x264
- Android 编译FFmpeg x264
- Android 编译FFmpeg x264
- Android 编译FFmpeg x264
- android编译x264
- <android编译ffmpeg+x264+faac> <Android/NDK环境下FFmpeg及AAC,MP3,X264的编译>
- x264的编译
- 开源库x264的编译
- android ndk 编译ffmpeg+x264
- 如何在编程生涯中有一个好的开端
- java学习笔记: 实现简易局域网聊天程序
- 算法摘记 最近公共祖先LCA Tarjan算法
- iOS本地化数据存储的常用方式介绍
- eclipse安装SVN插件地址
- 编译android用的x264
- weixin
- IOS应用开发16——UIViewContentMode各类型参数样式效果
- poj 1128
- 轻松实现图片上传并回显
- 汇编调用c函数为什么要设置栈
- java客户端与服务端同步实例
- c程序中,右移位符>>表示什么含义
- shell中的单引号、双引号、反引号