移植、验证AAC解码库FAAD2到android详解必看

aac是针对音频 进行压缩的一种算法 该编码优点很多。音质好 支持的采样率 声道都很多。在Android上使用非常常见


之前使用ffmepeg 1.1的decode_audio4这个函数 解码有误 双声道16位 居然解码成单声道32位 (nb_sample_fm=8) 

没找到好的解决方法 (据说换老版本的ffmpeg0.5可以解决 )

之后有尝试提炼opcore 中的aac decode 发现太复杂

再之后尝试使用OPSLes 但是 居然在源代码里面 有个结构体定义的bug 导致无法编译 不得不移植faad2


整个过程:1:下载源代码

2:使用NDK编译

3:编写JNI测试函数,使用aac文件测试效果。




1:http://www.audiocoding.com/downloads.html 下载2.7

FAAD2 SourceVersion 2.7 ZIP Package
到一个android工程下新建一个jni目录  解压到此处

目录结构

---jni

    |---faad2

             |-----aacDe

             |----libfaad

            .

            .

            .

    我们之关心libfaad 和include这两个文件夹


2:编写mk脚本

在jni目录下编写Android.mk文件,内容如下

  1. LOCAL_PATH := $(call my-dir)  
  2. FAAD2_TOP := $(LOCAL_PATH)/faad2  
  3. include $(CLEAR_VARS)  
  4. include $(FAAD2_TOP)/libfaad/Android.mk    
  5.   
  6. LOCAL_C_INCLUDES :=         \  
  7.     $(LOCAL_PATH)       \  
  8.     $(FAAD2_TOP)/android    \  
  9.     $(FAAD2_TOP)/include    \  
  10.     $(LOCAL_PATH)/codebook  
在/jni/faad2/libfaad/编写Android.mk 内容如下
  1. LOCAL_PATH:= $(call my-dir)  
  2.   
  3. include $(CLEAR_VARS)  
  4.   
  5. LOCAL_SRC_FILES:=bits.c     \  
  6.         cfft.c      \  
  7.         decoder.c   \  
  8.         drc.c       \  
  9.         drm_dec.c   \  
  10.         error.c     \  
  11.         filtbank.c  \  
  12.         ic_predict.c    \  
  13.         is.c        \  
  14.         lt_predict.c    \  
  15.         mdct.c      \  
  16.         mp4.c       \  
  17.         ms.c        \  
  18.         output.c    \  
  19.         pns.c       \  
  20.         ps_dec.c    \  
  21.         ps_syntax.c     \  
  22.         pulse.c     \  
  23.         specrec.c   \  
  24.         syntax.c    \  
  25.         tns.c       \  
  26.         hcr.c       \  
  27.         huffman.c   \  
  28.         rvlc.c      \  
  29.         ssr.c       \  
  30.         ssr_fb.c    \  
  31.         ssr_ipqf.c  \  
  32.         common.c    \  
  33.         sbr_dct.c   \  
  34.         sbr_e_nf.c  \  
  35.         sbr_fbt.c   \  
  36.         sbr_hfadj.c     \  
  37.         sbr_hfgen.c     \  
  38.         sbr_huff.c  \  
  39.         sbr_qmf.c   \  
  40.         sbr_syntax.c    \  
  41.         sbr_tf_grid.c   \  
  42.         sbr_dec.c     
  43.   
  44.   
  45. LOCAL_MODULE:=faad  
  46. LOCAL_C_INCLUDES :=         \  
  47.     $(LOCAL_PATH)       \  
  48.     $(FAAD2_TOP)/android    \  
  49.     $(FAAD2_TOP)/include    \  
  50.     $(LOCAL_PATH)/codebook  
  51.   
  52. LOCAL_CFLAGS:=      \  
  53.     -DHAVE_CONFIG_H  
  54.   
  55. include $(BUILD_SHARED_LIBRARY)  

最后在/jnifaad/下面编写config.h文件
  1. /* config.h.  Generated from config.h.in by configure.  */  
  2. /* config.h.in.  Generated from configure.in by autoheader.  */  
  3.   
  4. /* Define if you want to use libfaad together with Digital Radio Mondiale 
  5.    (DRM) */  
  6. /* #undef DRM */  
  7.   
  8. /* Define if you want support for Digital Radio Mondiale (DRM) parametric 
  9.    stereo */  
  10. /* #undef DRM_PS */  
  11.   
  12. /* Define to 1 if you have the <dlfcn.h> header file. */  
  13. #define HAVE_DLFCN_H 1  
  14.   
  15. /* Define to 1 if you have the <errno.h> header file. */  
  16. #define HAVE_ERRNO_H 1  
  17.   
  18. /* Define if needed */  
  19. /* #undef HAVE_FLOAT32_T */  
  20.   
  21. /* Define to 1 if you have the <float.h> header file. */  
  22. #define HAVE_FLOAT_H 1  
  23.   
  24. /* Define to 1 if you have the `getpwuid' function. */  
  25. #define HAVE_GETPWUID 1  
  26.   
  27. /* Define to 1 if you have the <inttypes.h> header file. */  
  28. #define HAVE_INTTYPES_H 1  
  29.   
  30. /* Define if you have the IOKit API */  
  31. /* #undef HAVE_IOKIT_IOKITLIB_H */  
  32.   
  33. /* Define to 1 if you have the <limits.h> header file. */  
  34. #define HAVE_LIMITS_H 1  
  35.   
  36. /* Define if you have C99's lrintf function. */  
  37. #define HAVE_LRINTF 1  
  38.   
  39. /* Define to 1 if you have the <mathf.h> header file. */  
  40. /* #undef HAVE_MATHF_H */  
  41.   
  42. /* Define to 1 if you have the `memcpy' function. */  
  43. #define HAVE_MEMCPY 1  
  44.   
  45. /* Define to 1 if you have the <memory.h> header file. */  
  46. #define HAVE_MEMORY_H 1  
  47.   
  48. /* Define to 1 if you have the <stdint.h> header file. */  
  49. #define HAVE_STDINT_H 1  
  50.   
  51. /* Define to 1 if you have the <stdlib.h> header file. */  
  52. #define HAVE_STDLIB_H 1  
  53.   
  54. /* Define to 1 if you have the `strchr' function. */  
  55. #define HAVE_STRCHR 1  
  56.   
  57. /* Define to 1 if you have the <strings.h> header file. */  
  58. #define HAVE_STRINGS_H 1  
  59.   
  60. /* Define to 1 if you have the <string.h> header file. */  
  61. #define HAVE_STRING_H 1  
  62.   
  63. /* Define to 1 if you have the `strsep' function. */  
  64. #define HAVE_STRSEP 1  
  65.   
  66. /* Define to 1 if you have the <sysfs/libsysfs.h> header file. */  
  67. /* #undef HAVE_SYSFS_LIBSYSFS_H */  
  68.   
  69. /* Define to 1 if you have the <sys/stat.h> header file. */  
  70. #define HAVE_SYS_STAT_H 1  
  71.   
  72. /* Define to 1 if you have the <sys/time.h> header file. */  
  73. #define HAVE_SYS_TIME_H 1  
  74.   
  75. /* Define to 1 if you have the <sys/types.h> header file. */  
  76. #define HAVE_SYS_TYPES_H 1  
  77.   
  78. /* Define to 1 if you have the <unistd.h> header file. */  
  79. #define HAVE_UNISTD_H 1  
  80.   
  81. /* Define to 1 if your C compiler doesn't accept -c and -o together. */  
  82. /* #undef NO_MINUS_C_MINUS_O */  
  83.   
  84. /* Name of package */  
  85. #define PACKAGE "faad2"  
  86.   
  87. /* Define to the address where bug reports for this package should be sent. */  
  88. #define PACKAGE_BUGREPORT ""  
  89.   
  90. /* Define to the full name of this package. */  
  91. #define PACKAGE_NAME ""  
  92.   
  93. /* Define to the full name and version of this package. */  
  94. #define PACKAGE_STRING ""  
  95.   
  96. /* Define to the one symbol short name of this package. */  
  97. #define PACKAGE_TARNAME ""  
  98.   
  99. /* Define to the version of this package. */  
  100. #define PACKAGE_VERSION ""  
  101.   
  102. /* Define to 1 if you have the ANSI C header files. */  
  103. #define STDC_HEADERS 1  
  104.   
  105. /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */  
  106. #define TIME_WITH_SYS_TIME 1  
  107.   
  108. /* Version number of package */  
  109. #define VERSION "2.7.0"  
  110.   
  111. /* Define to 1 if your processor stores words with the most significant byte 
  112.    first (like Motorola and SPARC, unlike Intel and VAX). */  
  113. /* #undef WORDS_BIGENDIAN */  
  114.   
  115. /* Define to `__inline__' or `__inline' if that's what the C compiler 
  116.    calls it, or to nothing if 'inline' is not supported under any name.  */  
  117. #ifndef __cplusplus  
  118. /* #undef inline */  
  119. #endif  
  120.   
  121. /* Define to `long int' if <sys/types.h> does not define. */  
  122. /* #undef off_t */  

使用NDK 命令 ndk-build(我的版本为ndk-linux-x64-r8)

如果没有问题 会在/libs/下面生成一个libfaad2.a文件  没错 就是一个静态库 为什么是静态库 看下面

如果运行NDK编译命令没有动静 则在/jni/目录下编译个Application.mk文件

  1. APP_STL:= gnustl_static  
  2. APP_ABI := armeabi-v7a  
  3. APP_PLATFORM := android-14  
  4. APP_MODULES := libfaad  

上面语句的意思 

第一行 用GNU库
第二行 针对arme-v7a的CPU

第三行  针对设备的版本 4.0.3

最后一行 静态库的名称

能用的库就出来了 然后怎么调用它呢 ? 

 JNI技术


修改jni/Android.mk如下 

  1. LOCAL_PATH := $(call my-dir)  
  2.   
  3. include $(CLEAR_VARS)  
  4. LOCAL_MODULE    := libfaad  
  5. LOCAL_SRC_FILES := lib/libfaad.a  
  6. include $(PREBUILT_STATIC_LIBRARY)  
  7.   
  8. LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \  
  9.         $(call include-path-for, wilhelm)  
  10. LOCAL_MODULE    := pcmNativePlayer  
  11.   
  12. LOCAL_LDLIBS := -L$(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-arm/usr/lib -L$(LOCAL_PATH)   
  13. LOCAL_LDLIBS    += -lOpenSLES -llog -lz -ldl   
  14. #-ljnigraphics  -cpu -lgcc  
  15. LOCAL_SRC_FILES :=    decode_aac_adts.cpp   
  1. #native-audio-jni.cpp  
  2. LOCAL_STATIC_LIBRARIES:= libfaad  
  3. LOCAL_SHARED_LIBRARIES := \  
  4.     libutils \  
  5.     libOpenSLES  
  6. include $(BUILD_SHARED_LIBRARY)  

然后编写一个/jni/decode_aac_adts.cpp
  1. /** 
  2.  * faaddec.c 
  3.  * use faad library to decode AAC, only can decode frame with ADTS head 
  4.  */  
  5. #include <stdio.h>  
  6. #include <memory.h>  
  7.   
  8. extern "C"{  
  9. #include "faad.h"  
  10. #include "neaacdec.h"  
  11. }  
  12. #include <jni.h>  
  13.   
  14. //#include "native-audio-jni.h"  
  15. #include <stdio.h>  
  16. #include <stdlib.h>  
  17. #include <android/log.h>  
  18. #define  LOG_TAG "faad2_decode_aac_adts"  
  19. #define  LOGI(...)   __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)  
  20. #define  LOGE(...)   __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)  
  21. #define  LOGW(...)   __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)  
  22. #define FRAME_MAX_LEN 1024*5  
  23. #define BUFFER_MAX_LEN 1024*1024  
  24. void show_usage()  
  25. {  
  26.     LOGI("usage\nfaaddec src_file dst_file");  
  27. }  
  28.   
  29. /** 
  30.  * fetch one ADTS frame 
  31.  */  
  32. int get_one_ADTS_frame(unsigned char* buffer, size_t buf_size,  
  33.         unsigned char* data, size_t* data_size)  
  34. {  
  35.     size_t size = 0;  
  36.   
  37.     if (!buffer || !data || !data_size)  
  38.     {  
  39.         return -1;  
  40.     }  
  41.   
  42.     while (1)  
  43.     {  
  44.         if (buf_size < 7)  
  45.         {  
  46.             return -1;  
  47.         }  
  48.   
  49.         if ((buffer[0] == 0xff) && ((buffer[1] & 0xf0) == 0xf0))  
  50.         {  
  51.             size |= ((buffer[3] & 0x03) << 11); //high 2 bit  
  52.             size |= buffer[4] << 3; //middle 8 bit  
  53.             size |= ((buffer[5] & 0xe0) >> 5); //low 3bit  
  54.             break;  
  55.         }  
  56.         --buf_size;  
  57.         ++buffer;  
  58.     }  
  59.   
  60.     if (buf_size < size)  
  61.     {  
  62.         return -1;  
  63.     }  
  64.   
  65.     memcpy(data, buffer, size);  
  66.     *data_size = size;  
  67.   
  68.     return 0;  
  69. }  
  70.   
  71. int main2(int argc, char* argv[])  
  72. {  
  73.     static unsigned char frame[FRAME_MAX_LEN];  
  74.         static unsigned char buffer[BUFFER_MAX_LEN] =  
  75.         { 0 };  
  76.   
  77.         char src_file[128] =  
  78.         { 0 };  
  79.         char dst_file[128] =  
  80.         { 0 };  
  81.         FILE* ifile = NULL;  
  82.         FILE* ofile = NULL;  
  83.   
  84.         unsigned long samplerate;  
  85.         unsigned char channels;  
  86.         NeAACDecHandle decoder = 0;  
  87.   
  88.         size_t data_size = 0;  
  89.         size_t size = 0;  
  90.   
  91.         NeAACDecFrameInfo frame_info;  
  92.         unsigned char* input_data = buffer;  
  93.         unsigned char* pcm_data = NULL;  
  94.   
  95.         //analyse parameter  
  96.         if (argc < 3)  
  97.         {  
  98.             show_usage();  
  99.             return -1;  
  100.         }  
  101.         sscanf(argv[1], "%s", src_file);  
  102.         sscanf(argv[2], "%s", dst_file);  
  103.         LOGI("source file is null%s",argv[1]);  
  104.         LOGI("dst file is null%s",argv[2]);  
  105.         ifile = fopen(src_file, "rb");  
  106.         ofile = fopen(dst_file, "wb");  
  107.         if (!ifile || !ofile)  
  108.         {  
  109.             LOGI("source or destination file is null");  
  110.             return -1;  
  111.         }  
  112.   
  113.         data_size = fread(buffer, 1, BUFFER_MAX_LEN, ifile);  
  114.   
  115.         //open decoder  
  116.         decoder = NeAACDecOpen();  
  117.         if (get_one_ADTS_frame(buffer, data_size, frame, &size) < 0)  
  118.         {  
  119.             return -1;  
  120.         }  
  121.   
  122.         //initialize decoder  
  123.         NeAACDecInit(decoder, frame, size, &samplerate, &channels);  
  124.         LOGI("samplerate %d, channels %d\n", samplerate, channels);  
  125.   
  126.         while (get_one_ADTS_frame(input_data, data_size, frame, &size) == 0)  
  127.         {  
  128.             // LOGI("frame size %d\n", size);  
  129.   
  130.             //decode ADTS frame  
  131.             pcm_data = (unsigned char*) NeAACDecDecode(decoder, &frame_info, frame,  
  132.                     size);  
  133.   
  134.             if (frame_info.error > 0)  
  135.             {  
  136.                 LOGI("%s\n", NeAACDecGetErrorMessage(frame_info.error));  
  137.   
  138.             }  
  139.             else if (pcm_data && frame_info.samples > 0)  
  140.             {  
  141.                 LOGI(  
  142.                         "frame info: bytesconsumed %d, channels %d, header_type %d\  
  143.                     object_type %d, samples %d, samplerate %d\n",  
  144.                         frame_info.bytesconsumed, frame_info.channels,  
  145.                         frame_info.header_type, frame_info.object_type,  
  146.                         frame_info.samples, frame_info.samplerate);  
  147.                 //put openSL queue to render  
  148.                 //updateAudioData(pcm_data,frame_info.samples * frame_info.channels,0);  
  149.                 fwrite(pcm_data, 1, frame_info.samples * frame_info.channels,  
  150.                         ofile); //2个通道  
  151.                 fflush(ofile);  
  152.             }  
  153.             data_size -= size;  
  154.             input_data += size;  
  155.         }  
  156.   
  157.         NeAACDecClose(decoder);  
  158.   
  159.         fclose(ifile);  
  160.         fclose(ofile);  
  161.     return 0;  
  162. }  
  163. extern "C"  
  164. {  
  165. jint Java_org_gl_jni_JNI_fileBackPlay(JNIEnv* env, jobject thiz,  
  166.         jstring filepath, jint fileRealLength)  
  167. {  
  168. //  if (stats == stats_ING)  
  169. //  {  
  170. //      LOGE( "is playing");  
  171. //      return stats;  
  172. //  }  
  173.     char * fileName = (char*) (env)->GetStringUTFChars(filepath, NULL);  
  174.     LOGI( "fileName:%s", fileName);  
  175.     char* files[3] ;  
  176.     files[0] = "0";  
  177.     files[1] = fileName;  
  178.     files[2] = "/sdcard/pcm_faac_out";  
  179.     main2(4,files);  
  180.     env->ReleaseStringUTFChars(filepath, fileName);  
  181.     return 0;  
  182. }  
  183. }  
将位于/libs/faad2.a移动到/jni/lib/下面
再一次运行ndk-build编译出一个动态库 faad2.so

编译工作完成



编写测试函数 

细节不多说

java代码 src/org/gl/jni/JNI.java

  1. package org.gl.jni;  
  2.   
  3. public class JNI {  
  4.   
  5.     static {  
  6.         System.loadLibrary("faad");  
  7.     }  
  8.   
  9.     public static native int fileBackPlay(String fileName);  
  10. }  
  1. 调用代码如下 <pre name="code" class="java">   new Thread() {  
  2.                     public void run() {  
  3.                         try {  
  4.                             JNI.fileBackPlay("/sdcard/test1.aac");  
  5.                         } catch (Exception e) {  
  6.                             // TODO: handle exception  
  7.                         }  
  8.                     };  
  9.                 }.start();</pre><br>  
  10. <pre></pre>  
  11. <p></p>  
  12. 完成后会在sdcard下面产生一个PCM格式的输出文件 <pre name="code" class="cpp">/sdcard/pcm_faac_out</pre>  
  13. <p>拿出来在windows下面 用cooledit播放一下。具体参数跟 下面调用函数中的文件 的编码设置有关</p>  
  14. <p>AAC格式编码介绍:AAC编码就是将PCMGE格式的音频信号压缩 有利于网络传输和存储</p>  
  15. <p>pcm:声音模拟信号数字化后的数据</p>  
  16. <p><br>  
  17. </p>  
  18. <p></p>  
  19. <p><br>  
  20. </p>  
  21. <pre></pre>  
  22.     


由于最近要做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

  1. LOCAL_PATH := $(call my-dir)  
  2.   
  3. FAAD2_TOP := $(LOCAL_PATH)  
  4.   
  5. include $(CLEAR_VARS)  
  6.   
  7. include $(FAAD2_TOP)/libfaad/Android.mk  

然后就是Application.mk,当然不创建Application.mk也没有问题
  1. APP_ABI :armeabi  
5.创建config.h
  1. /* config.h.  Generated from config.h.in by configure.  */  
  2. /* config.h.in.  Generated from configure.in by autoheader.  */  
  3.   
  4. /* Define if you want to use libfaad together with Digital Radio Mondiale 
  5.    (DRM) */  
  6. /* #undef DRM */  
  7.   
  8. /* Define if you want support for Digital Radio Mondiale (DRM) parametric 
  9.    stereo */  
  10. /* #undef DRM_PS */  
  11.   
  12. /* Define to 1 if you have the <dlfcn.h> header file. */  
  13. #define HAVE_DLFCN_H 1  
  14.   
  15. /* Define to 1 if you have the <errno.h> header file. */  
  16. #define HAVE_ERRNO_H 1  
  17.   
  18. /* Define if needed */  
  19. /* #undef HAVE_FLOAT32_T */  
  20.   
  21. /* Define to 1 if you have the <float.h> header file. */  
  22. #define HAVE_FLOAT_H 1  
  23.   
  24. /* Define to 1 if you have the `getpwuid' function. */  
  25. #define HAVE_GETPWUID 1  
  26.   
  27. /* Define to 1 if you have the <inttypes.h> header file. */  
  28. #define HAVE_INTTYPES_H 1  
  29.   
  30. /* Define if you have the IOKit API */  
  31. /* #undef HAVE_IOKIT_IOKITLIB_H */  
  32.   
  33. /* Define to 1 if you have the <limits.h> header file. */  
  34. #define HAVE_LIMITS_H 1  
  35.   
  36. /* Define if you have C99's lrintf function. */  
  37. #define HAVE_LRINTF 1  
  38.   
  39. /* Define to 1 if you have the <mathf.h> header file. */  
  40. /* #undef HAVE_MATHF_H */  
  41.   
  42. /* Define to 1 if you have the `memcpy' function. */  
  43. #define HAVE_MEMCPY 1  
  44.   
  45. /* Define to 1 if you have the <memory.h> header file. */  
  46. #define HAVE_MEMORY_H 1  
  47.   
  48. /* Define to 1 if you have the <stdint.h> header file. */  
  49. #define HAVE_STDINT_H 1  
  50.   
  51. /* Define to 1 if you have the <stdlib.h> header file. */  
  52. #define HAVE_STDLIB_H 1  
  53.   
  54. /* Define to 1 if you have the `strchr' function. */  
  55. #define HAVE_STRCHR 1  
  56.   
  57. /* Define to 1 if you have the <strings.h> header file. */  
  58. #define HAVE_STRINGS_H 1  
  59.   
  60. /* Define to 1 if you have the <string.h> header file. */  
  61. #define HAVE_STRING_H 1  
  62.   
  63. /* Define to 1 if you have the `strsep' function. */  
  64. #define HAVE_STRSEP 1  
  65.   
  66. /* Define to 1 if you have the <sysfs/libsysfs.h> header file. */  
  67. /* #undef HAVE_SYSFS_LIBSYSFS_H */  
  68.   
  69. /* Define to 1 if you have the <sys/stat.h> header file. */  
  70. #define HAVE_SYS_STAT_H 1  
  71.   
  72. /* Define to 1 if you have the <sys/time.h> header file. */  
  73. #define HAVE_SYS_TIME_H 1  
  74.   
  75. /* Define to 1 if you have the <sys/types.h> header file. */  
  76. #define HAVE_SYS_TYPES_H 1  
  77.   
  78. /* Define to 1 if you have the <unistd.h> header file. */  
  79. #define HAVE_UNISTD_H 1  
  80.   
  81. /* Define to 1 if your C compiler doesn't accept -c and -o together. */  
  82. /* #undef NO_MINUS_C_MINUS_O */  
  83.   
  84. /* Name of package */  
  85. #define PACKAGE "faad2"  
  86.   
  87. /* Define to the address where bug reports for this package should be sent. */  
  88. #define PACKAGE_BUGREPORT ""  
  89.   
  90. /* Define to the full name of this package. */  
  91. #define PACKAGE_NAME ""  
  92.   
  93. /* Define to the full name and version of this package. */  
  94. #define PACKAGE_STRING ""  
  95.   
  96. /* Define to the one symbol short name of this package. */  
  97. #define PACKAGE_TARNAME ""  
  98.   
  99. /* Define to the version of this package. */  
  100. #define PACKAGE_VERSION ""  
  101.   
  102. /* Define to 1 if you have the ANSI C header files. */  
  103. #define STDC_HEADERS 1  
  104.   
  105. /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */  
  106. #define TIME_WITH_SYS_TIME 1  
  107.   
  108. /* Version number of package */  
  109. #define VERSION "2.7.0"  
  110.   
  111. /* Define to 1 if your processor stores words with the most significant byte 
  112.    first (like Motorola and SPARC, unlike Intel and VAX). */  
  113. /* #undef WORDS_BIGENDIAN */  
  114.   
  115. /* Define to `__inline__' or `__inline' if that's what the C compiler 
  116.    calls it, or to nothing if 'inline' is not supported under any name.  */  
  117. #ifndef __cplusplus  
  118. /* #undef inline */  
  119. #endif  
  120.   
  121. /* Define to `long int' if <sys/types.h> does not define. */  
  122. /* #undef off_t */  

6.进入libfaad文件夹下面创建Android.mk
  1. LOCAL_PATH:= $(call my-dir)  
  2.   
  3. include $(CLEAR_VARS)  
  4.   
  5. LOCAL_SRC_FILES:=       \  
  6.         bits.c      \  
  7.         cfft.c      \  
  8.         decoder.c   \  
  9.         drc.c       \  
  10.             drm_dec.c   \  
  11.         error.c     \  
  12.         filtbank.c  \  
  13.         ic_predict.c    \  
  14.         is.c        \  
  15.         lt_predict.c    \  
  16.         mdct.c      \  
  17.         mp4.c       \  
  18.         ms.c        \  
  19.         output.c    \  
  20.         pns.c       \  
  21.         ps_dec.c    \  
  22.         ps_syntax.c     \  
  23.         pulse.c     \  
  24.         specrec.c   \  
  25.         syntax.c    \  
  26.         tns.c       \  
  27.         hcr.c       \  
  28.         huffman.c   \  
  29.         rvlc.c      \  
  30.         ssr.c       \  
  31.         ssr_fb.c    \  
  32.         ssr_ipqf.c  \  
  33.         common.c    \  
  34.         sbr_dct.c   \  
  35.         sbr_e_nf.c  \  
  36.         sbr_fbt.c   \  
  37.         sbr_hfadj.c     \  
  38.         sbr_hfgen.c     \  
  39.         sbr_huff.c  \  
  40.         sbr_qmf.c   \  
  41.         sbr_syntax.c    \  
  42.         sbr_tf_grid.c   \  
  43.         sbr_dec.c   
  44.   
  45. LOCAL_MODULE:= libfaad  
  46.   
  47. LOCAL_C_INCLUDES :=         \  
  48.     $(LOCAL_PATH)       \  
  49.     $(FAAD2_TOP)/android    \  
  50.     $(FAAD2_TOP)/include    \  
  51.     $(LOCAL_PATH)/codebook  
  52.   
  53. LOCAL_CFLAGS:=      \  
  54.     -DHAVE_CONFIG_H  
  55.   
  56. include $(BUILD_SHARED_LIBRARY)  

7、在jni目录下面运行ndk-build

8、运行结果如下:

  1. root@zhangjie:/home/AACDecoder/jni# ndk-build  
  2. Compile thumb  : faad <= bits.c  
  3. Compile thumb  : faad <= cfft.c  
  4. Compile thumb  : faad <= decoder.c  
  5. Compile thumb  : faad <= drc.c  
  6. Compile thumb  : faad <= drm_dec.c  
  7. Compile thumb  : faad <= error.c  
  8. Compile thumb  : faad <= filtbank.c  
  9. Compile thumb  : faad <= ic_predict.c  
  10. Compile thumb  : faad <= is.c  
  11. Compile thumb  : faad <= lt_predict.c  
  12. Compile thumb  : faad <= mdct.c  
  13. Compile thumb  : faad <= mp4.c  
  14. Compile thumb  : faad <= ms.c  
  15. Compile thumb  : faad <= output.c  
  16. Compile thumb  : faad <= pns.c  
  17. Compile thumb  : faad <= ps_dec.c  
  18. Compile thumb  : faad <= ps_syntax.c  
  19. Compile thumb  : faad <= pulse.c  
  20. Compile thumb  : faad <= specrec.c  
  21. Compile thumb  : faad <= syntax.c  
  22. Compile thumb  : faad <= tns.c  
  23. Compile thumb  : faad <= hcr.c  
  24. Compile thumb  : faad <= huffman.c  
  25. Compile thumb  : faad <= rvlc.c  
  26. Compile thumb  : faad <= ssr.c  
  27. Compile thumb  : faad <= ssr_fb.c  
  28. Compile thumb  : faad <= ssr_ipqf.c  
  29. Compile thumb  : faad <= common.c  
  30. Compile thumb  : faad <= sbr_dct.c  
  31. Compile thumb  : faad <= sbr_e_nf.c  
  32. Compile thumb  : faad <= sbr_fbt.c  
  33. Compile thumb  : faad <= sbr_hfadj.c  
  34. Compile thumb  : faad <= sbr_hfgen.c  
  35. Compile thumb  : faad <= sbr_huff.c  
  36. Compile thumb  : faad <= sbr_qmf.c  
  37. Compile thumb  : faad <= sbr_syntax.c  
  38. Compile thumb  : faad <= sbr_tf_grid.c  
  39. Compile thumb  : faad <= sbr_dec.c  
  40. SharedLibrary  : libfaad.so  
  41. Install        : libfaad.so => libs/armeabi/libfaad.so 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值