移植、验证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 Source Version 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 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值