android 编译faad2

来源:互联网 发布:传奇地图编辑器软件 编辑:程序博客网 时间:2024/06/05 13:36

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

[html] view plain copy
 print?
  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也没有问题

[html] view plain copy
 print?
  1. APP_ABI :armeabi  
5.创建config.h

[java] view plain copy
 print?
  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

[java] view plain copy
 print?
  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、运行结果如下:

[java] view plain copy
 print?
  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
原创粉丝点击