android 編譯libmad

來源:互聯網
上載者:User

之前項目裡面需要轉歌曲,不過是通過java來實現的比較慢,最近有時間在網上查看mp3解碼,找到libmad,能夠實現mp3的解碼,所以編譯成庫測試一下效能。

1、下載源碼,到官網 http://sourceforge.net/projects/mad/files/libmad/0.15.1b/ 現在最新的版本是libmad-0.15.1b

2、解壓下載的檔案,進入並建立jni目錄,然後將裡面的檔案都拷貝到jni目錄下面

3、組建組態檔案,建立config.sh,來組建組態檔案,內容如下:

#!/bin/shNDK=/opt/android-ndk-r8dPLATFORM=$NDK/platforms/android-8/arch-arm/PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86CC=$PREBUILT/bin/arm-linux-androideabi-gcc ./configure --prefix=/home/libmad-0.15.1b/jni/dist --host=arm --enable-speed --enable-static --enable-fpm=arm --with-pic  CC="$CC --sysroot=$PLATFORM" 

4、在終端運行config.sh,會得到配置config.h等檔案,然後根據Makefile檔案便下Android.mk,內容如下:

LOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_SRC_FILES := \   version.c \   fixed.c \   bit.c \   timer.c \   stream.c \   frame.c \   synth.c \   decoder.c \   layer12.c \   layer3.c \   huffman.c \   imdct_l_arm.S \   minimad.cLOCAL_C_INCLUDES := $(LOCAL_PATH)LOCAL_ARM_MODE := armLOCAL_MODULE:= libmadLOCAL_CFLAGS := -DHAVE_CONFIG_H -DFPM_ARM -ffast-math \-O3 -Wall  -g -O  -fforce-addr \-fthread-jumps -fcse-follow-jumps -fcse-skip-blocks \-fexpensive-optimizations -fregmove -fschedule-insns2 \-fstrength-reduce -fPICinclude $(BUILD_SHARED_LIBRARY)

5、在終端運行ndk-build,得到結果如下:

root@zhangjie:/home/libmad-0.15.1b/jni# ndk-buildCompile arm    : mad <= version.cCompile arm    : mad <= fixed.cCompile arm    : mad <= bit.cCompile arm    : mad <= timer.cCompile arm    : mad <= stream.cCompile arm    : mad <= frame.cCompile arm    : mad <= synth.cCompile arm    : mad <= decoder.cCompile arm    : mad <= layer12.cCompile arm    : mad <= layer3.cCompile arm    : mad <= huffman.cCompile arm    : mad <= imdct_l_arm.SCompile arm    : mad <= minimad.cSharedLibrary  : libmad.soInstall        : libmad.so => libs/armeabi/libmad.so

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.