aac是针对音频 进行压缩的一种算法 该编码优点很多。音质好 支持的采样率 声道都很多。在Android上使用非常常见
之前使用ffmepeg 1.1的decode_audio4这个函数 解码有误 双声道16位 居然解码成单声道32位 (nb_sample_fm=8)
没找到好的解决方法 (据说换老版本的ffmpeg0.5可以解决 )
之后有尝试提炼opcore 中的aac decode 发现太复杂
再之后尝试使用OPSLes 但是 居然在源代码里面 有个结构体定义的bug 导致无法编译 不得不移植faad2
2:使用NDK编译
3:编写JNI测试函数,使用aac文件测试效果。
1:http://www.audiocoding.com/downloads.html 下载2.7
FAAD2 Source | Version 2.7 ZIP Package |
目录结构
---jni
|---faad2
|-----aacDe
|----libfaad
.
.
.
我们之关心libfaad 和include这两个文件夹
2:编写mk脚本
在jni目录下编写Android.mk文件,内容如下
- LOCAL_PATH := $(call my-dir)
- FAAD2_TOP := $(LOCAL_PATH)/faad2
- include $(CLEAR_VARS)
- include $(FAAD2_TOP)/libfaad/Android.mk
- LOCAL_C_INCLUDES := \
- $(LOCAL_PATH) \
- $(FAAD2_TOP)/android \
- $(FAAD2_TOP)/include \
- $(LOCAL_PATH)/codebook
- 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:=faad
- LOCAL_C_INCLUDES := \
- $(LOCAL_PATH) \
- $(FAAD2_TOP)/android \
- $(FAAD2_TOP)/include \
- $(LOCAL_PATH)/codebook
- LOCAL_CFLAGS:= \
- -DHAVE_CONFIG_H
- include $(BUILD_SHARED_LIBRARY)
最后在/jnifaad/下面编写config.h文件
- /* config.h. Generated from config.h.in by configure. */
- /* config.h.in. Generated from configure.in by autoheader. */
- /* Define if you want to use libfaad together with Digital Radio Mondiale
- (DRM) */
- /* #undef DRM */
- /* Define if you want support for Digital Radio Mondiale (DRM) parametric
- stereo */
- /* #undef DRM_PS */
- /* Define to 1 if you have the <dlfcn.h> header file. */
- #define HAVE_DLFCN_H 1
- /* Define to 1 if you have the <errno.h> header file. */
- #define HAVE_ERRNO_H 1
- /* Define if needed */
- /* #undef HAVE_FLOAT32_T */
- /* Define to 1 if you have the <float.h> header file. */
- #define HAVE_FLOAT_H 1
- /* Define to 1 if you have the `getpwuid' function. */
- #define HAVE_GETPWUID 1
- /* Define to 1 if you have the <inttypes.h> header file. */
- #define HAVE_INTTYPES_H 1
- /* Define if you have the IOKit API */
- /* #undef HAVE_IOKIT_IOKITLIB_H */
- /* Define to 1 if you have the <limits.h> header file. */
- #define HAVE_LIMITS_H 1
- /* Define if you have C99's lrintf function. */
- #define HAVE_LRINTF 1
- /* Define to 1 if you have the <mathf.h> header file. */
- /* #undef HAVE_MATHF_H */
- /* Define to 1 if you have the `memcpy' function. */
- #define HAVE_MEMCPY 1
- /* Define to 1 if you have the <memory.h> header file. */
- #define HAVE_MEMORY_H 1
- /* Define to 1 if you have the <stdint.h> header file. */
- #define HAVE_STDINT_H 1
- /* Define to 1 if you have the <stdlib.h> header file. */
- #define HAVE_STDLIB_H 1
- /* Define to 1 if you have the `strchr' function. */
- #define HAVE_STRCHR 1
- /* Define to 1 if you have the <strings.h> header file. */
- #define HAVE_STRINGS_H 1
- /* Define to 1 if you have the <string.h> header file. */
- #define HAVE_STRING_H 1
- /* Define to 1 if