diff --git a/android/ffmpeg-kit-android-lib/src/main/cpp/.gitignore b/android/ffmpeg-kit-android-lib/src/main/cpp/.gitignore index 419b715..cc5bb74 100644 --- a/android/ffmpeg-kit-android-lib/src/main/cpp/.gitignore +++ b/android/ffmpeg-kit-android-lib/src/main/cpp/.gitignore @@ -1,2 +1 @@ -/android_lts_support.o -/libandroidltssupport.a +/*.o diff --git a/android/ffmpeg-kit-android-lib/src/main/cpp/android_lts_support.c b/android/ffmpeg-kit-android-lib/src/main/cpp/android_support.c similarity index 89% rename from android/ffmpeg-kit-android-lib/src/main/cpp/android_lts_support.c rename to android/ffmpeg-kit-android-lib/src/main/cpp/android_support.c index 97d8a8b..f0d5c14 100644 --- a/android/ffmpeg-kit-android-lib/src/main/cpp/android_lts_support.c +++ b/android/ffmpeg-kit-android-lib/src/main/cpp/android_support.c @@ -35,6 +35,8 @@ extern "C" { #endif +// posix_memalign() and memalign() are not available in the NDK __INTRODUCED_IN(17) + #if __ANDROID_API__ < 17 int posix_memalign(void** memptr, size_t alignment, size_t size) { @@ -56,6 +58,10 @@ int posix_memalign(void** memptr, size_t alignment, size_t size) { #endif /* __ANDROID_API__ < 17 */ +// log2() and log2f() are C99 functions, but they're not available in the NDK __INTRODUCED_IN(18) + +#if __ANDROID_API__ < 18 + double log2(double x) { return (log(x) / M_LN2); } @@ -64,6 +70,8 @@ float log2f(float x) { return (float) log2((double) x); } +#endif /* __ANDROID_API__ < 18 */ + #ifdef __cplusplus }; /* end of extern "C" */ #endif \ No newline at end of file diff --git a/android/jni/Android.mk b/android/jni/Android.mk index ee65090..5777567 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -69,13 +69,7 @@ include $(BUILD_SHARED_LIBRARY) $(call import-module, cpu-features) -MY_SRC_FILES := ffmpegkit.c ffprobekit.c ffmpegkit_exception.c fftools_cmdutils.c fftools_ffmpeg.c fftools_ffprobe.c fftools_ffmpeg_mux.c fftools_ffmpeg_mux_init.c fftools_ffmpeg_demux.c fftools_ffmpeg_opt.c fftools_opt_common.c fftools_ffmpeg_hw.c fftools_ffmpeg_filter.c fftools_objpool.c fftools_sync_queue.c fftools_thread_queue.c - -ifeq ($(TARGET_PLATFORM),android-16) - MY_SRC_FILES += android_lts_support.c -else ifeq ($(TARGET_PLATFORM),android-17) - MY_SRC_FILES += android_lts_support.c -endif +MY_SRC_FILES := ffmpegkit.c ffprobekit.c ffmpegkit_exception.c fftools_cmdutils.c fftools_ffmpeg.c fftools_ffprobe.c fftools_ffmpeg_mux.c fftools_ffmpeg_mux_init.c fftools_ffmpeg_demux.c fftools_ffmpeg_opt.c fftools_opt_common.c fftools_ffmpeg_hw.c fftools_ffmpeg_filter.c fftools_objpool.c fftools_sync_queue.c fftools_thread_queue.c android_support.c MY_CFLAGS := -Wall -Werror -Wno-unused-parameter -Wno-switch -Wno-sign-compare MY_LDLIBS := -llog -lz -landroid diff --git a/scripts/android/ffmpeg.sh b/scripts/android/ffmpeg.sh index 5f8aca1..51f7c46 100755 --- a/scripts/android/ffmpeg.sh +++ b/scripts/android/ffmpeg.sh @@ -340,11 +340,6 @@ fi export LDFLAGS+=" -L${ANDROID_NDK_ROOT}/platforms/android-${API}/arch-${TOOLCHAIN_ARCH}/usr/lib" -# LINKING WITH ANDROID LTS SUPPORT LIBRARY IS NECESSARY FOR API < 18 -if [[ -n ${FFMPEG_KIT_LTS_BUILD} ]] && [[ ${API} -lt 18 ]]; then - export LDFLAGS+=" -Wl,--whole-archive ${BASEDIR}/android/ffmpeg-kit-android-lib/src/main/cpp/libandroidltssupport.a -Wl,--no-whole-archive" -fi - # ALWAYS BUILD SHARED LIBRARIES BUILD_LIBRARY_OPTIONS="--disable-static --enable-shared" diff --git a/scripts/android/kvazaar.sh b/scripts/android/kvazaar.sh index f668c43..bab1990 100755 --- a/scripts/android/kvazaar.sh +++ b/scripts/android/kvazaar.sh @@ -8,18 +8,10 @@ if [[ ! -f "${BASEDIR}"/src/"${LIB_NAME}"/configure ]] || [[ ${RECONF_kvazaar} - autoreconf_library "${LIB_NAME}" 1>>"${BASEDIR}"/build.log 2>&1 || return 1 fi -# UPDATE BUILD FLAGS -# LINKING WITH ANDROID LTS SUPPORT LIBRARY IS NECESSARY FOR API < 18 -if [[ -n ${FFMPEG_KIT_LTS_BUILD} ]] && [[ ${API} -lt 18 ]]; then - LTS_SUPPORT_LIBS=" -Wl,--no-whole-archive ${BASEDIR}/android/ffmpeg-kit-android-lib/src/main/cpp/libandroidltssupport.a -Wl,--no-whole-archive" -else - LTS_SUPPORT_LIBS="" -fi - # WORKAROUND TO DISABLE LINKING TO -lrt ${SED_INLINE} 's/\-lrt//g' "${BASEDIR}"/src/"${LIB_NAME}"/configure || return 1 -LIBS="${LTS_SUPPORT_LIBS}" ./configure \ +./configure \ --prefix="${LIB_INSTALL_PREFIX}" \ --with-pic \ --with-sysroot="${ANDROID_SYSROOT}" \ diff --git a/scripts/function-android.sh b/scripts/function-android.sh index 9459e5e..9c267fb 100755 --- a/scripts/function-android.sh +++ b/scripts/function-android.sh @@ -416,15 +416,19 @@ get_common_linked_libraries() { case $1 in ffmpeg) + local LIB_ANDROID_SUPPORT_PATHS="-L${LIB_INSTALL_BASE}/android-support/lib -Wl,--whole-archive -landroidsupport -Wl,--no-whole-archive" # SUPPORTED ON API LEVEL 24 AND LATER if [[ ${API} -ge 24 ]]; then - echo "-lc -lm -ldl -llog -landroid -lcamera2ndk -lmediandk ${COMMON_LIBRARY_PATHS}" + echo "-lc -lm -ldl -llog -landroid -lcamera2ndk -lmediandk ${COMMON_LIBRARY_PATHS} ${LIB_ANDROID_SUPPORT_PATHS}" else - echo "-lc -lm -ldl -llog -landroid ${COMMON_LIBRARY_PATHS}" + echo "-lc -lm -ldl -llog -landroid ${COMMON_LIBRARY_PATHS} ${LIB_ANDROID_SUPPORT_PATHS}" echo -e "INFO: Building ffmpeg without native camera API which is not supported on Android API Level ${API}\n" 1>>"${BASEDIR}"/build.log 2>&1 fi ;; + kvazaar) + echo "-L${LIB_INSTALL_BASE}/android-support/lib -Wl,--no-whole-archive -landroidsupport -Wl,--no-whole-archive" + ;; libvpx) echo "-lc -lm ${COMMON_LIBRARY_PATHS}" ;; @@ -1082,16 +1086,19 @@ set_toolchain_paths() { fi } -build_android_lts_support() { +build_android_support() { + local LIBRARY_PATH="${LIB_INSTALL_BASE}/android-support" - # CLEAN OLD BUILD - rm -f "${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/cpp/android_lts_support.o 1>>"${BASEDIR}"/build.log 2>&1 - rm -f "${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/cpp/android_lts_support.a 1>>"${BASEDIR}"/build.log 2>&1 + # DELETE THE PREVIOUS BUILD OF THE LIBRARY + if [ -d "${LIBRARY_PATH}" ]; then + rm -rf "${LIBRARY_PATH}" || return 1 + fi + rm -f "${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/cpp/android_support.o 1>>"${BASEDIR}"/build.log 2>&1 - echo -e "INFO: Building android-lts-support objects for ${ARCH}\n" 1>>"${BASEDIR}"/build.log 2>&1 + echo -e "INFO: Building android-support objects for ${ARCH}\n" 1>>"${BASEDIR}"/build.log 2>&1 # PREPARE PATHS - LIB_NAME="android-lts-support" + LIB_NAME="android-support" set_toolchain_paths ${LIB_NAME} # PREPARE FLAGS @@ -1100,6 +1107,7 @@ build_android_lts_support() { LDFLAGS=$(get_ldflags ${LIB_NAME}) # BUILD - "${CC}" ${CFLAGS} -Wno-unused-command-line-argument -c "${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/cpp/android_lts_support.c -o "${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/cpp/android_lts_support.o ${LDFLAGS} 1>>"${BASEDIR}"/build.log 2>&1 - "${AR}" rcs "${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/cpp/libandroidltssupport.a "${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/cpp/android_lts_support.o 1>>"${BASEDIR}"/build.log 2>&1 + mkdir -p "${LIBRARY_PATH}"/lib 1>>"${BASEDIR}"/build.log 2>&1 + "${CC}" ${CFLAGS} -Wno-unused-command-line-argument -c "${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/cpp/android_support.c -o "${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/cpp/android_support.o ${LDFLAGS} 1>>"${BASEDIR}"/build.log 2>&1 + "${AR}" rcs "${LIBRARY_PATH}"/lib/libandroidsupport.a "${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/cpp/android_support.o 1>>"${BASEDIR}"/build.log 2>&1 } diff --git a/scripts/main-android.sh b/scripts/main-android.sh index 2f3eb56..9f0bfd7 100755 --- a/scripts/main-android.sh +++ b/scripts/main-android.sh @@ -44,10 +44,8 @@ for library in {1..50}; do fi done -# BUILD LTS SUPPORT LIBRARY FOR API < 18 -if [[ -n ${FFMPEG_KIT_LTS_BUILD} ]] && [[ ${API} -lt 18 ]]; then - build_android_lts_support -fi +# BUILD SUPPORT LIBRARY +build_android_support # BUILD ENABLED LIBRARIES AND THEIR DEPENDENCIES let completed=0