不同平台下移植x264
一. 编译环境
mips移植x264相关记录,mips交叉编译工具采用buildroot-gcc342版本,x264 版本x264-snapshot-20140831-2245。
android 平台下移植, 采用android-ndk-r9d
二. 移植到android 或者x86平台时候,配置脚本如下
android ndk 编译脚本如下
mkdir platform/
mkdir platform/android/
export ARM_ROOT=/home/soft/linux_eclipse_tar/android-ndk-r9d
export ARM_INC=$ARM_ROOT/platforms/android-9/arch-arm/usr/include/
export ARM_LIB=$ARM_ROOT/platforms/android-9/arch-arm/usr/lib/
export ARM_TOOL=$ARM_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86
export ARM_LIBO=$ARM_TOOL/lib/gcc/arm-linux-androideabi/4.8
export PATH=$ARM_TOOL/bin:$PATH
export ARM_PRE=arm-linux-androideabi
export PLATFORM=$ARM_ROOT/platforms/android-9/arch-arm/
CPU=android
PREFIX=$(pwd)/platform/$CPU
./configure --prefix=$PREFIX \
--enable-static \
--enable-shared \
--disable-asm \
--host=arm-linux \
--cross-prefix=arm-linux-androideabi- \
--sysroot=$PLATFORM
make clean
make -j2
make install
x86 平台编译脚本
mkdir x86
CPU=x86
PREFIX=$(pwd)/platform/$CPU
function build_one
{
./configure \
--prefix=$PREFIX\
--enable-shared\
--enable-static\
--disable-asm
}
build_one
make clean
make -j2
make install
mips 编译脚本
mkdir mips
export ARM_ROOT=/opt/buildroot-gcc342
export ARM_INC=$ARM_ROOT/include/
export ARM_LIB=$ARM_ROOT/lib
export ARM_PRE=$ARM_ROOT/bin/mipsel-linux
CPU=mips
PREFIX=$(pwd)/android/$CPU
HOST=mipsel-linux
function build_one
{
./configure \
--disable-gpac\
--prefix=$PREFIX\
--enable-static\
--enable-shared\
--disable-asm\
--host=$HOST\
--cross-prefix=${ARM_PRE}-\
--extra-cflags="-I$ARM_INC -fPIC -DANDROID -ffunction-sections -funwind-tables -fno-short-enums -msoft-float -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -Wa,--noexecstack -MMD -MP "\
--extra-ldflags="-L$ARM_LIB -lmath"
}
build_one
make clean
make -j2
make install
三. android 和x86 平台移植编译都没问题
mips 下编译出现如下错误
错误 1:
common/cpu.c: In function `x264_cpu_num_processors':
common/cpu.c:447: error: `cpu_set_t' undeclared (first use in this function)
common/cpu.c:447: error: (Each undeclared identifier is reported only once
common/cpu.c:447: error: for each function iint x264_cpu_num_processors( void )
t appears in.)
common/cpu.c:447: error: parse error before "p_aff"
common/cpu.c:448: error: `p_aff' undeclared (first use in this function)
common/cpu.c:449: warning: implicit declaration of function `sched_getaffinity'
make: *** [common/cpu.o] Error 1
make: *** Waiting for unfinished jobs....
/opt/buildroot-gcc342/bin/mipsel-linux-gcc -Wshadow -O3 -ffast-math -Wall -I. -I. -std=gnu99 -fPIC -fomit-frame-pointer -c -o common/cpu.o common/cpu.c
这个函数主要是检测当前cpu个数,需要屏蔽如下代码
int x264_cpu_num_processors( void )
{
#if !HAVE_THREAD
return 1;
#elif SYS_WINDOWS
return x264_pthread_num_processors_np();
#elif SYS_CYGWIN || SYS_SunOS
return sysconf( _SC_NPROCESSORS_ONLN );
#elif SYS_LINUX
#ifdef __ANDROID__
// Android NDK does not expose sched_getaffinity
return sysconf( _SC_NPROCESSORS_CONF );
#else
//cpu_set_t p_aff;
//memset( &p_aff, 0, sizeof(p_aff) );
//if( sched_getaffinity( 0, sizeof(p_aff), &p_aff ) )
return 1;
#if HAVE_CPU_COUNT
return CPU_COUNT(&p_aff);
#else
//int np = 0;
//for( unsigned int bit = 0; bit < 8 * sizeof(p_aff); bit++ )
// np += (((uint8_t *)&p_aff)[bit / 8] >> (bit % 8)) & 1;
// return np;
return 1;
}
错误 2:
input/timecode.o: In function `correct_fps':timecode.c:(.text.correct_fps+0x148): undefined reference to `round'
input/timecode.o: In function `try_mkv_timebase_den':timecode.c:(.text.try_mkv_timebase_den+0xa8): undefined reference to `round'
input/timecode.o: In function `open_file':timecode.c:(.text.open_file+0xa00): undefined reference to `round'
:timecode.c:(.text.open_file+0xafc): undefined reference to `round'
:timecode.c:(.text.open_file+0x11c4): undefined reference to `round'
libx264.a(set.o): In function `x264_sps_init':set.c:(.text.x264_sps_init+0x904): undefined reference to `log2f'
libx264.a(encoder.o): In function `x264_validate_parameters':encoder.c:(.text.x264_validate_parameters+0x95c): undefined reference to `log2f'
:encoder.c:(.text.x264_validate_parameters+0x9a8): undefined reference to `log2f'
libx264.a(analyse.o): In function `x264_analyse_prepare_costs':analyse.c:(.text.x264_analyse_prepare_costs+0x70): undefined reference to `log2f'
libx264.a(analyse.o): In function `x264_weights_analyse':analyse.c:(.text.x264_weights_analyse+0x550): undefined reference to `roundf'
:analyse.c:(.text.x264_weights_analyse+0x5d4): undefined reference to `roundf'
libx264.a(analyse.o): In function `x264_macroblock_tree_finish':analyse.c:(.text.x264_macroblock_tree_finish+0x238): undefined reference to `round'
libx264.a(ratecontrol.o): In function `x264_ratecontrol_summary':ratecontrol.c:(.text.x264_ratecontrol_summary+0x1dc): undefined reference to `log2f'
libx264.a(ratecontrol.o): In function `x264_ratecontrol_slice_type':ratecontrol.c:(.text.x264_ratecontrol_slice_type+0x1c4): undefined reference to `log2f'
:ratecontrol.c:(.text.x264_ratecontrol_slice_type+0x32c): undefined reference to `log2f'
libx264.a(ratecontrol.o): In function `rate_estimate_qscale':ratecontrol.c:(.text.rate_estimate_qscale+0xf84): undefined reference to `log2f'
:ratecontrol.c:(.text.rate_estimate_qscale+0x1dd8): undefined reference to `log2f'
libx264.a(ratecontrol.o):ratecontrol.c:(.text.x264_ratecontrol_start+0x934): more undefined references to `log2f' follow
libx264.a(ratecontrol.o): In function `x264_ratecontrol_new':ratecontrol.c:(.text.x264_ratecontrol_new+0x508): undefined reference to `log2'
:ratecontrol.c:(.text.x264_ratecontrol_new+0x56c): undefined reference to `log2'
:ratecontrol.c:(.text.x264_ratecontrol_new+0x5bc): undefined reference to `log2'
:ratecontrol.c:(.text.x264_ratecontrol_new+0x83c): undefined reference to `log2f'
:ratecontrol.c:(.text.x264_ratecontrol_new+0x8ac): undefined reference to `log2f'
:ratecontrol.c:(.text.x264_ratecontrol_new+0x3f14): undefined reference to `log2f'
:ratecontrol.c:(.text.x264_ratecontrol_new+0x4ecc): undefined reference to `log2f'
解决:
log2 未定义,修改生成的config.h
把#define HAVE_LOG2F 1 改成
#define HAVE_LOG2F 0
round 是系统数学库函数,在mips 编译工具里面 lib 里面执行 objdump -tT *.so | grep "round" 查找所有库函数没有发现这个函数标签号,需要到网上下载这个数学库函数
#if defined MIPS_ROUND
#include <sys/cdefs.h>
/* __FBSDID("$FreeBSD: src/lib/msun/src/s_round.c,v 1.4 2005/12/02 13:45:06 bde Exp $"); */
#include <math.h>
#include <fpmath.h>
int
__isfinite(double d)
{
union IEEEd2bits u;
u.d = d;
return (u.bits.exp != 2047);
}
int
__isfinitef(float f)
{
union IEEEf2bits u;
u.f = f;
return (u.bits.exp != 255);
}
int
__isfinitel(long double e)
{
union IEEEl2bits u;
u.e = e;
return (u.bits.exp != 32767);
}
double
round(double x)
{
double t;
if (!isfinite(x))
return (x);
if (x >= 0.0) {
t = floor(x);
if (t - x <= -0.5)
t += 1.0;
return (t);
} else {
t = floor(-x);
if (t + x <= -0.5)
t += 1.0;
return (-t);
}
}
float
roundf(float x)
{
float t;
if (!isfinite(x))
return (x);
if (x >= 0.0) {
t = floorf(x);
if (t - x <= -0.5)
t += 1.0;
return (t);
} else {
t = floorf(-x);
if (t + x <= -0.5)
t += 1.0;
return (-t);
}
}
将以上代码编译生成动态库, 拷贝到 buildroot-gcc342/lib/
编译成功
不同平台下移植x264相关推荐
- 1013.windows平台下移植qtmqtt三方库
windows平台下移植Qt版本qtmqtt 1 下载qtmqtt源码 git clone https://github.com/qt/qtmqtt 2 安装perl软件 http://strawbe ...
- linux 2440网卡驱动,Linux-2.6.30平台下移植DM9000网卡驱动到TQ2440
平台:虚拟机Ubuntu 12.04 内核:linux-2.6.30 开发板:TQ2440 包括编译内核.制作文件系统,到目前可以在虚拟机上可以通过交叉网线可以和开发板互通,用了弄了差不多快两天时间 ...
- linux-2.6.30平台下移植DM9000网卡驱动到TQ2440
平台:虚拟机ubuntu12.04 内核:linux-2.6.30 开发板:TQ2440 包括编译内核.制作文件系统,到目前可以在虚拟机上可以通过交叉网线可以和开发板互通,用了弄了差不多快两天时间吧 ...
- 基于Stm32F746g_disg平台下移植zephry使用TinyML预测模型
前言 本文没有使用文件系统,以最小RTOS为例来调用Tensor Flow TFLite模型 Tensor FLow TFLite的工作流程就是先训练好模型,然后转换为TFLite模型文件,最后在通过 ...
- STM32平台下官方DMP库6.12超详细移植教程
前记 Motion Driver官方库:Motion_Driver_6.12 STM32工程源码:STM32F103C8-软件MPU6050(DMP) MPU6050软件I2C驱动,带OLED显示,移 ...
- .NET平台下开源框架
一.AOP框架 Encase 是C#编写开发的为.NET平台提供的AOP框架.Encase 独特的提供了把方面(aspects)部署到运行时代码,而其它AOP框架依赖配置文件的方式.这种部署方面(as ...
- ubuntu平台下编译vlc-android视频播放器实践
音视频实践学习 android全平台编译ffmpeg以及x264与fdk-aac实践 ubuntu下使用nginx和nginx-rtmp-module配置直播推流服务器 android全平台编译ffm ...
- 【转】在 Linux 平台下使用 JNI
引言 Java 的出现给大家开发带来的极大的方便.但是,如果我们有大量原有的经过广泛测试的非 Java 代码,将它们全部用 Java 来重写,恐怕会带来巨大的工作量和长期的测试:如果我们的应用中需要访 ...
- Office文件的奥秘——.NET平台下不借助Office实现Word、Powerpoint等文件的解析(一)...
[题外话] 这是2010年参加比赛时候做的研究,当时为了实现对Word.Excel.PowerPoint文件文字内容的抽取研究了很久,由于Java有POI库,可以轻松的抽取各种Office文档,而.N ...
最新文章
- Nova Conductor 与 Versioned Object Model 机制
- bzoj 3224 普通平衡树 vactor的妙用
- HD 1159 Common Subsequence (最长公共子序列)
- 深度学习(八)——fine-tuning, 李飞飞
- ssh 与 locale
- .NET 6新特性试用 | record struct
- 数据库5 索引 动态哈希(Dynamic Hashing)
- 并发并行,异步同步,阻塞非阻塞
- visdom可视化工具
- 【Quartz.net】- Cron表达式
- linux下解压 编译 安装,Linux 下开发环境安装配置-编译、解压、超链、
- 白盒测试 | 用例设计方法之条件组合覆盖
- BMZCTF misc1
- AADL Inspector 故障树安全分析模块
- s2 安恒 漏洞验证工具_Struts2漏洞检查工具2018版本V2.1.exe
- 作为一个程序员,如何保持优秀
- VMware Workstation中安装Windows10系统
- Spark SQL 在SparkStreaming中的运用
- 蓝牙耳机哪款性价比高?2023年高性价比蓝牙耳机盘点
- html文本框颜色填充颜色设置,文本框填充色怎么设置