mac 下移植 x264 使用 neon 多线程加速

来源:互联网 发布:淘宝店花呗怎么开通 编辑:程序博客网 时间:2024/06/13 22:07

mac 下移植 x264 使用 neon加速


1.获取x264源码
git clone http://git.videolan.org/git/x264.git

2. 再x264上级目录创建build_x264.sh
sudo chmod 777 build_x264.sh

3.更改build_x264.sh的内容
#!/bin/shCONFIGURE_FLAGS="--enable-static --enable-pic --disable-cli"ARCHS="arm64 x86_64 i386 armv7 armv7s"# directoriesSOURCE="x264"FAT="x264-iOS"SCRATCH="scratch-x264"# must be an absolute pathTHIN=/Users/chenglong/Documents/x264-ios-master/"thin-x264"# the one included in x264 does not work; specify full path to working oneGAS_PREPROCESSOR=/usr/local/bin/gas-preprocessor.plCOMPILE="y"LIPO="y"if [ "$*" ]thenif [ "$*" = "lipo" ]then# skip compileCOMPILE=elseARCHS="$*"if [ $# -eq 1 ]then# skip lipoLIPO=fififiif [ "$COMPILE" ]thenCWD=/Users/chenglong/Documents/x264-ios-masterfor ARCH in $ARCHSdoecho "building $ARCH..."mkdir -p "$SCRATCH/$ARCH"cd "$SCRATCH/$ARCH"CFLAGS="-arch $ARCH"                ASFLAGS=if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]then    PLATFORM="iPhoneSimulator"    CPU=    if [ "$ARCH" = "x86_64" ]    then    CFLAGS="$CFLAGS -mios-simulator-version-min=7.0"    HOST=    else    CFLAGS="$CFLAGS -mios-simulator-version-min=5.0"HOST="--host=i386-apple-darwin"    fielse    PLATFORM="iPhoneOS"    if [ $ARCH = "arm64" ]    then        HOST="--host=aarch64-apple-darwin"XARCH="-arch aarch64"    else        HOST="--host=arm-apple-darwin"XARCH="-arch arm"    fi                    CFLAGS="$CFLAGS -fembed-bitcode -mios-version-min=7.0"                    ASFLAGS="$CFLAGS"fiXCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`CC="xcrun -sdk $XCRUN_SDK clang"if [ $PLATFORM = "iPhoneOS" ]then    export AS="gas-preprocessor.pl $XARCH -- $CC"else    export -n ASfiCXXFLAGS="$CFLAGS"LDFLAGS="$CFLAGS"CC=$CC $CWD/$SOURCE/configure \    $CONFIGURE_FLAGS \    $HOST \    --extra-cflags="$CFLAGS" \    --extra-asflags="$ASFLAGS" \    --extra-ldflags="$LDFLAGS" \    --prefix="$THIN/$ARCH" || exit 1mkdir extrasln -s $GAS_PREPROCESSOR extrasmake -j3 install || exit 1cd $CWDdonefiif [ "$LIPO" ]thenecho "building fat binaries..."mkdir -p $FAT/libset - $ARCHSCWD=`pwd`cd $THIN/$1/libfor LIB in *.adocd $CWDlipo -create `find $THIN -name $LIB` -output $FAT/lib/$LIBdonecd $CWDcp -rf $THIN/$1/include $FATfi
4. 下载 gas-preprocessor.pl
https://github.com/libav/gas-preprocessor.git
把gas-preprocessor.pl放到/usr/local/bin/ 目录下
cp gas-preprocessor.pl /usr/local/bin/

5. 执行 ./build_x264
platform:      AARCH64byte order:    little-endiansystem:        MACOSXcli:           nolibx264:       internalshared:        nostatic:        yesasm:           yesinterlaced:    yesavs:           nolavf:          noffms:          nomp4:           nogpl:           yesthread:        posixopencl:        yesfilters:       crop select_every lto:           nodebug:         nogprof:         nostrip:         noPIC:           yesbit depth:     8chroma format: all
从上边可以看出来开启asm加速,开启多线程加速

6. 最终会再x264-iOS 文件夹打包好的lib

7.放到工程里边输出信息
[libx264 @ 0x1408b9400] using cpu capabilities: ARMv8 NEON[libx264 @ 0x1408b9400] profile High, level 3.0
说x264再ios能够正常的跑





原创粉丝点击