From 41acc5033e2d4c4af3b2d3ba0446ed652fb5ab26 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 22 Mar 2020 19:26:26 +0800 Subject: [PATCH] For #307, support disable asm for FFMPEG --- .../ffmpeg-4.2-fit/libavutil/avconfig.h | 2 +- trunk/auto/depends.sh | 18 ++++++++++++------ trunk/auto/options.sh | 6 ++++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/trunk/3rdparty/ffmpeg-4.2-fit/libavutil/avconfig.h b/trunk/3rdparty/ffmpeg-4.2-fit/libavutil/avconfig.h index c289fbb55..8558b3502 100644 --- a/trunk/3rdparty/ffmpeg-4.2-fit/libavutil/avconfig.h +++ b/trunk/3rdparty/ffmpeg-4.2-fit/libavutil/avconfig.h @@ -2,5 +2,5 @@ #ifndef AVUTIL_AVCONFIG_H #define AVUTIL_AVCONFIG_H #define AV_HAVE_BIGENDIAN 0 -#define AV_HAVE_FAST_UNALIGNED 1 +#define AV_HAVE_FAST_UNALIGNED 0 #endif /* AVUTIL_AVCONFIG_H */ diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index 81e6f1f4b..870bb8f51 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -84,11 +84,13 @@ function Ubuntu_prepare() echo "The unzip is installed." fi - nasm -v >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then - echo "Installing nasm." - require_sudoer "sudo apt-get install -y --force-yes nasm" - sudo apt-get install -y --force-yes nasm; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi - echo "The nasm is installed." + if [[ $SRS_NASM == YES ]]; then + nasm -v >/dev/null 2>&1; ret=$?; if [[ 0 -ne $ret ]]; then + echo "Installing nasm." + require_sudoer "sudo apt-get install -y --force-yes nasm" + sudo apt-get install -y --force-yes nasm; ret=$?; if [[ 0 -ne $ret ]]; then return $ret; fi + echo "The nasm is installed." + fi fi if [[ $SRS_VALGRIND == YES ]]; then @@ -420,6 +422,10 @@ fi # ffmpeg-fix, for WebRTC to transcode AAC with Opus. ##################################################################################### if [[ $SRS_EXPORT_LIBRTMP_PROJECT == NO && $SRS_RTC == YES ]]; then + FFMPEG_OPTIONS="" + if [[ $SRS_NASM == NO ]]; then + FFMPEG_OPTIONS="--disable-asm --disable-x86asm --disable-inline-asm" + fi if [[ -f ${SRS_OBJS}/ffmpeg/lib/libavcodec.a ]]; then echo "The ffmpeg-4.2-fit is ok."; else @@ -429,7 +435,7 @@ if [[ $SRS_EXPORT_LIBRTMP_PROJECT == NO && $SRS_RTC == YES ]]; then ln -sf ../3rdparty/ffmpeg-4.2-fit && cd ffmpeg-4.2-fit && PKG_CONFIG_PATH=$ABS_OBJS/opus/lib/pkgconfig ./configure \ --prefix=`pwd`/_release \ - --pkg-config-flags="--static" --extra-libs=-lpthread --extra-libs=-lm \ + --pkg-config-flags="--static" --extra-libs=-lpthread --extra-libs=-lm ${FFMPEG_OPTIONS} \ --disable-programs --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages \ --disable-avdevice --disable-avformat --disable-swscale --disable-postproc --disable-avfilter --disable-network \ --disable-dct --disable-dwt --disable-error-resilience --disable-lsp --disable-lzo --disable-faan --disable-pixelutils \ diff --git a/trunk/auto/options.sh b/trunk/auto/options.sh index 3f142b4a8..97de92ec2 100755 --- a/trunk/auto/options.sh +++ b/trunk/auto/options.sh @@ -18,6 +18,7 @@ help=no SRS_HDS=NO SRS_SRT=NO SRS_RTC=YES +SRS_NASM=YES SRS_NGINX=NO SRS_FFMPEG_TOOL=NO SRS_LIBRTMP=NO @@ -179,6 +180,8 @@ Toolchain options: @see https://github.com/ossrs/srs/issues/1547#issuec --ld= Use linker tool LD, default is ld. --randlib= Use randlib tool RANDLIB, default is randlib. --extra-flags= Set EFLAGS as CFLAGS and CXXFLAGS. Also passed to ST as EXTRA_CFLAGS. + --with-nasm Build FFMPEG for RTC with nasm support. + --without-nasm Build FFMPEG for RTC without nasm support, for CentOS6 nasm is too old. Conflicts: 1. --with-gmc vs --with-gmp: @@ -229,6 +232,7 @@ function parse_user_option() { --with-utest) SRS_UTEST=YES ;; --with-srt) SRS_SRT=YES ;; --with-rtc) SRS_RTC=YES ;; + --with-nasm) SRS_NASM=YES ;; --with-gperf) SRS_GPERF=YES ;; --with-gmc) SRS_GPERF_MC=YES ;; --with-gmd) SRS_GPERF_MD=YES ;; @@ -246,6 +250,7 @@ function parse_user_option() { --without-utest) SRS_UTEST=NO ;; --without-srt) SRS_SRT=NO ;; --without-rtc) SRS_RTC=NO ;; + --without-nasm) SRS_NASM=NO ;; --without-gperf) SRS_GPERF=NO ;; --without-gmc) SRS_GPERF_MC=NO ;; --without-gmd) SRS_GPERF_MD=NO ;; @@ -545,6 +550,7 @@ function regenerate_options() { if [ $SRS_UTEST = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-utest"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-utest"; fi if [ $SRS_SRT = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-srt"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-srt"; fi if [ $SRS_RTC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-rtc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-rtc"; fi + if [ $SRS_NASM = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-nasm"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-nasm"; fi if [ $SRS_GPERF = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gperf"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gperf"; fi if [ $SRS_GPERF_MC = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmc"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmc"; fi if [ $SRS_GPERF_MD = YES ]; then SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --with-gmd"; else SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --without-gmd"; fi