Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> android 編譯faad2

android 編譯faad2

編輯:關於Android編程

由於最近要做AAC解碼,查看了網上最初有兩種思路:第一章種是ffmpeg,我查看./configure --list-decoders的時候,有看到aac解碼器,同時在x86上編譯也能夠打開aac解碼器,但是用用ndk交叉編譯的時候即使--enable-decoder=aac也沒有打開AAC解碼器,所以這種方法暫停。第二中方法是使用faad2解碼,在x86上調試,寫一個demo能夠解碼aac,然後就是交叉編譯,也得到庫,所以就使用第二種方法。在這裡記錄下來,幫助解碼AAC的同仁。

1、到官網
下載faad,當前的版本是2.7,

2、創建一個文件夾AACDecoder,進入AACDecoder

3、將下載的faad加壓,並且重新命名為jni

4、然後就是創建Android.mk, Application.mk,首先在jni目錄下面創建Android.mk


[html]
LOCAL_PATH := $(call my-dir) 
 
FAAD2_TOP := $(LOCAL_PATH) 
 
include $(CLEAR_VARS) 
 
include $(FAAD2_TOP)/libfaad/Android.mk 

LOCAL_PATH := $(call my-dir)

FAAD2_TOP := $(LOCAL_PATH)

include $(CLEAR_VARS)

include $(FAAD2_TOP)/libfaad/Android.mk
然後就是Application.mk,當然不創建Application.mk也沒有問題


[html]
APP_ABI := armeabi 

APP_ABI := armeabi
5.創建config.h


[java]
/* 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 you have the `strsep' function. */ 
#define HAVE_STRSEP 1 
 
/* Define to 1 if you have the <sysfs/libsysfs.h> header file. */ 
/* #undef HAVE_SYSFS_LIBSYSFS_H */ 
 
/* Define to 1 if you have the <sys/stat.h> header file. */ 
#define HAVE_SYS_STAT_H 1 
 
/* Define to 1 if you have the <sys/time.h> header file. */ 
#define HAVE_SYS_TIME_H 1 
 
/* Define to 1 if you have the <sys/types.h> header file. */ 
#define HAVE_SYS_TYPES_H 1 
 
/* Define to 1 if you have the <unistd.h> header file. */ 
#define HAVE_UNISTD_H 1 
 
/* Define to 1 if your C compiler doesn't accept -c and -o together. */ 
/* #undef NO_MINUS_C_MINUS_O */ 
 
/* Name of package */ 
#define PACKAGE "faad2" 
 
/* Define to the address where bug reports for this package should be sent. */ 
#define PACKAGE_BUGREPORT "" 
 
/* Define to the full name of this package. */ 
#define PACKAGE_NAME "" 
 
/* Define to the full name and version of this package. */ 
#define PACKAGE_STRING "" 
 
/* Define to the one symbol short name of this package. */ 
#define PACKAGE_TARNAME "" 
 
/* Define to the version of this package. */ 
#define PACKAGE_VERSION "" 
 
/* Define to 1 if you have the ANSI C header files. */ 
#define STDC_HEADERS 1 
 
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ 
#define TIME_WITH_SYS_TIME 1 
 
/* Version number of package */ 
#define VERSION "2.7.0" 
 
/* Define to 1 if your processor stores words with the most significant byte
   first (like Motorola and SPARC, unlike Intel and VAX). */ 
/* #undef WORDS_BIGENDIAN */ 
 
/* Define to `__inline__' or `__inline' if that's what the C compiler
   calls it, or to nothing if 'inline' is not supported under any name.  */ 
#ifndef __cplusplus 
/* #undef inline */ 
#endif 
 
/* Define to `long int' if <sys/types.h> does not define. */ 
/* #undef off_t */ 

/* 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 you have the `strsep' function. */
#define HAVE_STRSEP 1

/* Define to 1 if you have the <sysfs/libsysfs.h> header file. */
/* #undef HAVE_SYSFS_LIBSYSFS_H */

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1

/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1

/* Define to 1 if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */

/* Name of package */
#define PACKAGE "faad2"

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""

/* Define to the full name of this package. */
#define PACKAGE_NAME ""

/* Define to the full name and version of this package. */
#define PACKAGE_STRING ""

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME ""

/* Define to the version of this package. */
#define PACKAGE_VERSION ""

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1

/* Version number of package */
#define VERSION "2.7.0"

/* Define to 1 if your processor stores words with the most significant byte
   first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */

/* Define to `__inline__' or `__inline' if that's what the C compiler
   calls it, or to nothing if 'inline' is not supported under any name.  */
#ifndef __cplusplus
/* #undef inline */
#endif

/* Define to `long int' if <sys/types.h> does not define. */
/* #undef off_t */
6.進入libfaad文件夾下面創建Android.mk


[java]
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) 

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、運行結果如下:


[java]
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 

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

 

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved