android音频(三)——利用ndk直接编译faac和faad

本文介绍如何使用Android NDK直接编译FAAC库。通过新建Android工程、库模块及JNI目录,并配置Android.mk等文件,最终实现FAAC库的跨平台编译。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前面的两篇文章描述的编译方式是利用ndk的编译链,基于Make方式编译的。下面介绍如何用ndk直接编译。

假设ndk环境和源码均已准备好。

step1 新建android工程


step2 在工程下新建faac和faad库模块



step3 在库模块faac和faad下分别新建jni目录


step4 把faac和faad的源码分别解压到faac和faad库项目里的jni目录下


step5 编译faac

1、在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
APP_ABI := all
2、将根目录下的config.h.in文件复制重命名为config.h
3、在jni/libfaac下编写Android.mk如下
Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
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_MODULE:= libfaac
LOCAL_C_INCLUDES :=         \
    $(LOCAL_PATH)           \
    $(FAAC_TOP)             \
    $(FAAC_TOP)/include
LOCAL_CFLAGS:= -DHAVE_CONFIG_H
include $(BUILD_SHARED_LIBRARY)


4、在jni目录下运行ndk-build
运行编译命令得到
E:\AV-study\MakeTest\faac\jni>E:\android-ndk-r14-beta2\ndk-build
[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
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: remove extraneous parentheses around the comparison to silence this warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
1 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
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: remove extraneous parentheses around the comparison to silence this warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
1 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
[mips64] Compile        : faac <= aacquant.c
[mips64] Compile        : faac <= backpred.c
[mips64] Compile        : faac <= bitstream.c
[mips64] Compile        : faac <= channels.c
[mips64] Compile        : faac <= fft.c
[mips64] Compile        : faac <= filtbank.c
[mips64] Compile        : faac <= frame.c
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: remove extraneous parentheses around the comparison to silence this warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
1 warning generated.
[mips64] Compile        : faac <= huffman.c
[mips64] Compile        : faac <= ltp.c
[mips64] Compile        : faac <= midside.c
[mips64] Compile        : faac <= psychkni.c
[mips64] Compile        : faac <= tns.c
[mips64] Compile        : faac <= util.c
[mips64] SharedLibrary  : libfaac.so
[mips64] Install        : libfaac.so => libs/mips64/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
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: remove extraneous parentheses around the comparison to silence this warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
1 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
[armeabi] Compile thumb  : faac <= aacquant.c
[armeabi] Compile thumb  : faac <= backpred.c
[armeabi] Compile thumb  : faac <= bitstream.c
[armeabi] Compile thumb  : faac <= channels.c
[armeabi] Compile thumb  : faac <= fft.c
[armeabi] Compile thumb  : faac <= filtbank.c
[armeabi] Compile thumb  : faac <= frame.c
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: remove extraneous parentheses around the comparison to silence this warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
1 warning generated.
[armeabi] Compile thumb  : faac <= huffman.c
[armeabi] Compile thumb  : faac <= ltp.c
[armeabi] Compile thumb  : faac <= midside.c
[armeabi] Compile thumb  : faac <= psychkni.c
[armeabi] Compile thumb  : faac <= tns.c
[armeabi] Compile thumb  : faac <= util.c
[armeabi] SharedLibrary  : libfaac.so
[armeabi] Install        : libfaac.so => libs/armeabi/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
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: remove extraneous parentheses around the comparison to silence this warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
1 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
[mips] Compile        : faac <= aacquant.c
[mips] Compile        : faac <= backpred.c
[mips] Compile        : faac <= bitstream.c
[mips] Compile        : faac <= channels.c
[mips] Compile        : faac <= fft.c
[mips] Compile        : faac <= filtbank.c
[mips] Compile        : faac <= frame.c
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: remove extraneous parentheses around the comparison to silence this warning
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
            ~                              ^                   ~
E:/AV-study/MakeTest/faac/jni/libfaac/frame.c:829:44: note: use '=' to turn this equality comparison into an assignment
        if ((coderInfo[channel].block_type == ONLY_SHORT_WINDOW)) {
                                           ^~
                                           =
1 warning generated.
[mips] Compile        : faac <= huffman.c
[mips] Compile        : faac <= ltp.c
[mips] Compile        : faac <= midside.c
[mips] Compile        : faac <= psychkni.c
[mips] Compile        : faac <= tns.c
[mips] Compile        : faac <= util.c
[mips] SharedLibrary  : libfaac.so
[mips] Install        : libfaac.so => libs/mips/libfaac.so
此时查看libs





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值