天天看點

androidStudio編譯faac為動态庫

下載下傳faac源碼包,位址:https://sourceforge.net/projects/faac/files/faac-src/faac-1.28/,注意要下載下傳.tar.gz的,我試過.zip中的源碼用ndk編譯不通過。
androidStudio編譯faac為動态庫
然後建立一個android項目工程,并建立一個jni目錄,并将源碼所有檔案全部粘貼到jni目錄下,如圖:
androidStudio編譯faac為動态庫

其中有一個config.h.in檔案,直接去掉後面的.in,讓擴充名為.h,否則在frame.h中會報錯。

并在jni根目錄中建立Android.mk和Application.mk檔案。

Android.mk:

LOCAL_PATH := $(call my-dir)
FAAC_TOP := $(LOCAL_PATH)
include $(CLEAR_VARS)
include $(FAAC_TOP)/libfaac/Android.mk
           

Application.mk:

然後再在libfaac目錄中建立一個Android.mk檔案。

Android.mk:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:= libfaac
LOCAL_SRC_FILES:=       \
        aacquant.c      \
        backpred.c      \
        bitstream.c     \
        channels.c      \
        fft.c           \
        filtbank.c      \
        frame.c         \
        huffman.c       \
        ltp.c           \
        midside.c       \
        psychkni.c      \
        tns.c           \
        util.c          \

LOCAL_C_INCLUDES :=     \
    $(LOCAL_PATH)       \
    $(FAAC_TOP)         \
    $(FAAC_TOP)/include
LOCAL_CFLAGS:= -DHAVE_CONFIG_H
include $(BUILD_SHARED_LIBRARY)
           
在build.gradle中加入:
sourceSets { main { jni.srcDirs = ['src/main/jni/'] } }
    externalNativeBuild {
        ndkBuild {
            path 'src/main/jni/Android.mk'
        }
    }
           
然後 rebuild Project項目,執行完後,在如圖目錄下生成了libfaac.so
androidStudio編譯faac為動态庫
或者在jni目錄中執行ndk-build指令:
localhost:jni xuyan$ /Users/xuyan/Library/Android/sdk/ndk-bundle/ndk-build
Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-    
Android NDK: WARNING: APP_PLATFORM android- is higher than android:minSdkVersion  in /Users/xuyan/androidproject/AACProject/faac/src/main/AndroidManifest.xml. NDK binaries will *not* be compatible with devices older than android- See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.    
[arm64-v8a] Compile        : faac <= aacquant.c
[arm64-v8a] Compile        : faac <= backpred.c
[arm64-v8a] Compile        : faac <= bitstream.c
[arm64-v8a] Compile        : faac <= channels.c
[arm64-v8a] Compile        : faac <= fft.c
[arm64-v8a] Compile        : faac <= filtbank.c
[arm64-v8a] Compile        : faac <= frame.c
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c::: warning: 
      equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c::: note: 
      remove extraneous parentheses around the comparison to silence this
      warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c::: note: 
      use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
 warning generated.
[arm64-v8a] Compile        : faac <= huffman.c
[arm64-v8a] Compile        : faac <= ltp.c
[arm64-v8a] Compile        : faac <= midside.c
[arm64-v8a] Compile        : faac <= psychkni.c
[arm64-v8a] Compile        : faac <= tns.c
[arm64-v8a] Compile        : faac <= util.c
[arm64-v8a] SharedLibrary  : libfaac.so
[arm64-v8a] Install        : libfaac.so => libs/arm64-v8a/libfaac.so
[x86_64] Compile        : faac <= aacquant.c
[x86_64] Compile        : faac <= backpred.c
[x86_64] Compile        : faac <= bitstream.c
[x86_64] Compile        : faac <= channels.c
[x86_64] Compile        : faac <= fft.c
[x86_64] Compile        : faac <= filtbank.c
[x86_64] Compile        : faac <= frame.c
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c::: warning: 
      equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c::: note: 
      remove extraneous parentheses around the comparison to silence this
      warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c::: note: 
      use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
 warning generated.
[x86_64] Compile        : faac <= huffman.c
[x86_64] Compile        : faac <= ltp.c
[x86_64] Compile        : faac <= midside.c
[x86_64] Compile        : faac <= psychkni.c
[x86_64] Compile        : faac <= tns.c
[x86_64] Compile        : faac <= util.c
[x86_64] SharedLibrary  : libfaac.so
[x86_64] Install        : libfaac.so => libs/x86_64/libfaac.so
[armeabi-v7a] Compile thumb  : faac <= aacquant.c
[armeabi-v7a] Compile thumb  : faac <= backpred.c
[armeabi-v7a] Compile thumb  : faac <= bitstream.c
[armeabi-v7a] Compile thumb  : faac <= channels.c
[armeabi-v7a] Compile thumb  : faac <= fft.c
[armeabi-v7a] Compile thumb  : faac <= filtbank.c
[armeabi-v7a] Compile thumb  : faac <= frame.c
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c::: warning: 
      equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c::: note: 
      remove extraneous parentheses around the comparison to silence this
      warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c::: note: 
      use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
 warning generated.
[armeabi-v7a] Compile thumb  : faac <= huffman.c
[armeabi-v7a] Compile thumb  : faac <= ltp.c
[armeabi-v7a] Compile thumb  : faac <= midside.c
[armeabi-v7a] Compile thumb  : faac <= psychkni.c
[armeabi-v7a] Compile thumb  : faac <= tns.c
[armeabi-v7a] Compile thumb  : faac <= util.c
[armeabi-v7a] SharedLibrary  : libfaac.so
[armeabi-v7a] Install        : libfaac.so => libs/armeabi-v7a/libfaac.so
[x86] Compile        : faac <= aacquant.c
[x86] Compile        : faac <= backpred.c
[x86] Compile        : faac <= bitstream.c
[x86] Compile        : faac <= channels.c
[x86] Compile        : faac <= fft.c
[x86] Compile        : faac <= filtbank.c
[x86] Compile        : faac <= frame.c
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c::: warning: 
      equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c::: note: 
      remove extraneous parentheses around the comparison to silence this
      warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
/Users/xuyan/androidproject/AACProject/faac/src/main/jni/libfaac/frame.c::: note: 
      use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
 warning generated.
[x86] Compile        : faac <= huffman.c
[x86] Compile        : faac <= ltp.c
[x86] Compile        : faac <= midside.c
[x86] Compile        : faac <= psychkni.c
[x86] Compile        : faac <= tns.c
[x86] Compile        : faac <= util.c
[x86] SharedLibrary  : libfaac.so
[x86] Install        : libfaac.so => libs/x86/libfaac.so
           
androidStudio編譯faac為動态庫
肯定有哥們懶的不願意自己編譯,那我也把編譯好的so庫貢獻出來了,下載下傳位址:https://download.csdn.net/download/xy1213236113/10652226,希望給個好評!

繼續閱讀