本文共 6192 字,大约阅读时间需要 20 分钟。
由于最近要做AAC解码,查看了网上最初有两种思路:第一章种是ffmpeg,我查看./configure --list-decoders的时候,有看到aac解码器,同时在x86上编译也能够打开aac解码器,但是用用ndk交叉编译的时候即使--enable-decoder=aac也没有打开AAC解码器,所以这种方法暂停。第二中方法是使用faad2解码,在x86上调试,写一个demo能够解码aac,然后就是交叉编译,也得到库,所以就使用第二种方法。在这里记录下来,帮助解码AAC的同仁。
1、到官网http://www.audiocoding.com/downloads.html 下载faad,当前的版本是2.7,
2、创建一个文件夹AACDecoder,进入AACDecoder
3、将下载的faad加压,并且重新命名为jni
4、然后就是创建Android.mk, Application.mk,首先在jni目录下面创建Android.mk
- LOCAL_PATH := $(call my-dir)
-
- FAAD2_TOP := $(LOCAL_PATH)
-
- include $(CLEAR_VARS)
-
- include $(FAAD2_TOP)/libfaad/Android.mk
然后就是Application.mk,当然不创建Application.mk也没有问题
5.创建config.h
-
-
-
-
-
-
-
-
-
-
-
-
- #define HAVE_DLFCN_H 1
-
-
- #define HAVE_ERRNO_H 1
-
-
-
-
-
- #define HAVE_FLOAT_H 1
-
-
- #define HAVE_GETPWUID 1
-
-
- #define HAVE_INTTYPES_H 1
-
-
-
-
-
- #define HAVE_LIMITS_H 1
-
-
- #define HAVE_LRINTF 1
-
-
-
-
-
- #define HAVE_MEMCPY 1
-
-
- #define HAVE_MEMORY_H 1
-
-
- #define HAVE_STDINT_H 1
-
-
- #define HAVE_STDLIB_H 1
-
-
- #define HAVE_STRCHR 1
-
-
- #define HAVE_STRINGS_H 1
-
-
- #define HAVE_STRING_H 1
-
-
- #define HAVE_STRSEP 1
-
-
-
-
-
- #define HAVE_SYS_STAT_H 1
-
-
- #define HAVE_SYS_TIME_H 1
-
-
- #define HAVE_SYS_TYPES_H 1
-
-
- #define HAVE_UNISTD_H 1
-
-
-
-
-
- #define PACKAGE "faad2"
-
-
- #define PACKAGE_BUGREPORT ""
-
-
- #define PACKAGE_NAME ""
-
-
- #define PACKAGE_STRING ""
-
-
- #define PACKAGE_TARNAME ""
-
-
- #define PACKAGE_VERSION ""
-
-
- #define STDC_HEADERS 1
-
-
- #define TIME_WITH_SYS_TIME 1
-
-
- #define VERSION "2.7.0"
-
-
-
-
-
-
-
- #ifndef __cplusplus
-
- #endif
-
-
-
6.进入libfaad文件夹下面创建Android.mk
- LOCAL_PATH:= $(call my-dir)
-
- include $(CLEAR_VARS)
-
- LOCAL_SRC_FILES:= \
- bits.c \
- cfft.c \
- decoder.c \
- drc.c \
- drm_dec.c \
- error.c \
- filtbank.c \
- ic_predict.c \
- is.c \
- lt_predict.c \
- mdct.c \
- mp4.c \
- ms.c \
- output.c \
- pns.c \
- ps_dec.c \
- ps_syntax.c \
- pulse.c \
- specrec.c \
- syntax.c \
- tns.c \
- hcr.c \
- huffman.c \
- rvlc.c \
- ssr.c \
- ssr_fb.c \
- ssr_ipqf.c \
- common.c \
- sbr_dct.c \
- sbr_e_nf.c \
- sbr_fbt.c \
- sbr_hfadj.c \
- sbr_hfgen.c \
- sbr_huff.c \
- sbr_qmf.c \
- sbr_syntax.c \
- sbr_tf_grid.c \
- sbr_dec.c
-
- LOCAL_MODULE:= libfaad
-
- LOCAL_C_INCLUDES := \
- $(LOCAL_PATH) \
- $(FAAD2_TOP)/android \
- $(FAAD2_TOP)/include \
- $(LOCAL_PATH)/codebook
-
- LOCAL_CFLAGS:= \
- -DHAVE_CONFIG_H
-
- include $(BUILD_SHARED_LIBRARY)
7、在jni目录下面运行ndk-build
8、运行结果如下:
- root@zhangjie:/home/AACDecoder/jni# ndk-build
- Compile thumb : faad <= bits.c
- Compile thumb : faad <= cfft.c
- Compile thumb : faad <= decoder.c
- Compile thumb : faad <= drc.c
- Compile thumb : faad <= drm_dec.c
- Compile thumb : faad <= error.c
- Compile thumb : faad <= filtbank.c
- Compile thumb : faad <= ic_predict.c
- Compile thumb : faad <= is.c
- Compile thumb : faad <= lt_predict.c
- Compile thumb : faad <= mdct.c
- Compile thumb : faad <= mp4.c
- Compile thumb : faad <= ms.c
- Compile thumb : faad <= output.c
- Compile thumb : faad <= pns.c
- Compile thumb : faad <= ps_dec.c
- Compile thumb : faad <= ps_syntax.c
- Compile thumb : faad <= pulse.c
- Compile thumb : faad <= specrec.c
- Compile thumb : faad <= syntax.c
- Compile thumb : faad <= tns.c
- Compile thumb : faad <= hcr.c
- Compile thumb : faad <= huffman.c
- Compile thumb : faad <= rvlc.c
- Compile thumb : faad <= ssr.c
- Compile thumb : faad <= ssr_fb.c
- Compile thumb : faad <= ssr_ipqf.c
- Compile thumb : faad <= common.c
- Compile thumb : faad <= sbr_dct.c
- Compile thumb : faad <= sbr_e_nf.c
- Compile thumb : faad <= sbr_fbt.c
- Compile thumb : faad <= sbr_hfadj.c
- Compile thumb : faad <= sbr_hfgen.c
- Compile thumb : faad <= sbr_huff.c
- Compile thumb : faad <= sbr_qmf.c
- Compile thumb : faad <= sbr_syntax.c
- Compile thumb : faad <= sbr_tf_grid.c
- Compile thumb : faad <= sbr_dec.c
- SharedLibrary : libfaad.so
- Install : libfaad.so => libs/armeabi/libfaad.so
转载地址:http://sfzoi.baihongyu.com/