From 80108ac10926e98f7b99b2c64256b1cae007beed Mon Sep 17 00:00:00 2001 From: Martin Foo Date: Fri, 21 Oct 2016 22:59:37 +0800 Subject: [PATCH 1/3] Add android platform support. --- README.android | 17 +++++ android/jni/Android.mk | 72 ++++++++++++++++++++ android/jni/Application.mk | 8 +++ android/jni/speex-jni.cpp | 128 +++++++++++++++++++++++++++++++++++ android/speex_config_types.h | 12 ++++ 5 files changed, 237 insertions(+) create mode 100644 README.android create mode 100644 android/jni/Android.mk create mode 100644 android/jni/Application.mk create mode 100644 android/jni/speex-jni.cpp create mode 100644 android/speex_config_types.h diff --git a/README.android b/README.android new file mode 100644 index 00000000..32bd3264 --- /dev/null +++ b/README.android @@ -0,0 +1,17 @@ +#Using Speex on Android + +##Introduction +------------ + +The android/ directory contains android ndk-build dependent files: +-config.h Configuration options for android arm platform +-speex_config_types.h Configuration options for android arm platform +-jni Build script for android ndk-build + +##Build +Just need run cmd: cd android && ndk-build + +##Standalone toolchain +If you have ndk standalone toolchain, just need run cmd: +export CC=arm-linux-androideabi-gcc && ./configure --host=arm --enable-arm5e-asm --enable-fixed-point --disable-float-api && make -j4 + diff --git a/android/jni/Android.mk b/android/jni/Android.mk new file mode 100644 index 00000000..d8e69498 --- /dev/null +++ b/android/jni/Android.mk @@ -0,0 +1,72 @@ +LOCAL_PATH := $(call my-dir) + +SPEEX_PATH=$(realpath $(LOCAL_PATH)/../..) +SPX_ANDROID_PATH=$(realpath $(LOCAL_PATH)/..) +$(info SPEEX_PATH = $(SPEEX_PATH)) + +########################## +# libspeex static library # + ########################## + +include $(CLEAR_VARS) + +LOCAL_MODULE := libspeex +LOCAL_CFLAGS := -DHAVE_CONFIG_H +LOCAL_C_INCLUDES := $(SPX_ANDROID_PATH) +LOCAL_C_INCLUDES += $(SPEEX_PATH)/include + +LOCAL_ARM_MODE := arm + +LOCAL_SRC_FILES := \ + $(SPEEX_PATH)/libspeex/bits.c \ + $(SPEEX_PATH)/libspeex/cb_search.c \ + $(SPEEX_PATH)/libspeex/exc_10_32_table.c \ + $(SPEEX_PATH)/libspeex/exc_10_16_table.c \ + $(SPEEX_PATH)/libspeex/exc_20_32_table.c \ + $(SPEEX_PATH)/libspeex/exc_5_256_table.c \ + $(SPEEX_PATH)/libspeex/exc_5_64_table.c \ + $(SPEEX_PATH)/libspeex/exc_8_128_table.c \ + $(SPEEX_PATH)/libspeex/filters.c \ + $(SPEEX_PATH)/libspeex/gain_table.c \ + $(SPEEX_PATH)/libspeex/hexc_table.c \ + $(SPEEX_PATH)/libspeex/high_lsp_tables.c \ + $(SPEEX_PATH)/libspeex/lsp.c \ + $(SPEEX_PATH)/libspeex/ltp.c \ + $(SPEEX_PATH)/libspeex/speex.c \ + $(SPEEX_PATH)/libspeex/stereo.c \ + $(SPEEX_PATH)/libspeex/vbr.c \ + $(SPEEX_PATH)/libspeex/vq.c \ + $(SPEEX_PATH)/libspeex/gain_table_lbr.c \ + $(SPEEX_PATH)/libspeex/hexc_10_32_table.c \ + $(SPEEX_PATH)/libspeex/lpc.c \ + $(SPEEX_PATH)/libspeex/lsp_tables_nb.c \ + $(SPEEX_PATH)/libspeex/modes.c \ + $(SPEEX_PATH)/libspeex/modes_wb.c \ + $(SPEEX_PATH)/libspeex/nb_celp.c \ + $(SPEEX_PATH)/libspeex/quant_lsp.c \ + $(SPEEX_PATH)/libspeex/sb_celp.c \ + $(SPEEX_PATH)/libspeex/speex_callbacks.c \ + $(SPEEX_PATH)/libspeex/speex_header.c \ + $(SPEEX_PATH)/libspeex/window.c + +include $(BUILD_STATIC_LIBRARY) + +########################## +# libspeex-jni shared library # + ########################## + +include $(CLEAR_VARS) + +LOCAL_MODULE := libspeex-jni + +LOCAL_CFLAGS += -Wall -fvisibility=hidden -DHAVE_CONFIG_H +LOCAL_C_INCLUDES := $(SPX_ANDROID_PATH) +LOCAL_C_INCLUDES += $(SPEEX_PATH)/include + +LOCAL_SRC_FILES := speex-jni.cpp +LOCAL_STATIC_LIBRARIES := libspeex + +LOCAL_LDLIBS := -llog +LOCAL_LDFLAGS := -Wl,--as-needed + +include $(BUILD_SHARED_LIBRARY) diff --git a/android/jni/Application.mk b/android/jni/Application.mk new file mode 100644 index 00000000..4dbbaa2d --- /dev/null +++ b/android/jni/Application.mk @@ -0,0 +1,8 @@ +# The ARMv7 is significanly faster due to the use of the hardware FPU +# APP_ABI := armeabi-v7a armeabi x86 mips +APP_ABI := armeabi-v7a +APP_PLATFORM := android-14 + +APP_STL := gnustl_static + +APP_CPPFLAGS += -fexceptions diff --git a/android/jni/speex-jni.cpp b/android/jni/speex-jni.cpp new file mode 100644 index 00000000..0184a699 --- /dev/null +++ b/android/jni/speex-jni.cpp @@ -0,0 +1,128 @@ +/* + * ComicsReader is an Android application to read comics + * Copyright (C) 2011-2015 Cedric OCHS + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#include + +#include +#include + +#include "speex/speex.h" + +static int codec_open = 0; + +static int dec_frame_size; +static int enc_frame_size; + +static SpeexBits ebits, dbits; +void *enc_state; +void *dec_state; + +static JavaVM *gJavaVM; + +extern "C" +JNIEXPORT jint JNICALL Java_com_audio_Speex_open + (JNIEnv *env, jobject obj, jint compression) { + int tmp; + + if (codec_open++ != 0) + return (jint)0; + + speex_bits_init(&ebits); + speex_bits_init(&dbits); + + enc_state = speex_encoder_init(&speex_nb_mode); + dec_state = speex_decoder_init(&speex_nb_mode); + tmp = compression; + speex_encoder_ctl(enc_state, SPEEX_SET_QUALITY, &tmp); + speex_encoder_ctl(enc_state, SPEEX_GET_FRAME_SIZE, &enc_frame_size); + speex_decoder_ctl(dec_state, SPEEX_GET_FRAME_SIZE, &dec_frame_size); + + return (jint)0; +} + +extern "C" +JNIEXPORT jint Java_com_audio_Speex_encode + (JNIEnv *env, jobject obj, jshortArray lin, jint offset, jbyteArray encoded, jint size) { + + jshort buffer[enc_frame_size]; + jbyte output_buffer[enc_frame_size]; + int nsamples = (size-1)/enc_frame_size + 1; + int i, tot_bytes = 0; + + if (!codec_open) + return 0; + + speex_bits_reset(&ebits); + + for (i = 0; i < nsamples; i++) { + env->GetShortArrayRegion(lin, offset + i*enc_frame_size, enc_frame_size, buffer); + speex_encode_int(enc_state, buffer, &ebits); + } + //env->GetShortArrayRegion(lin, offset, enc_frame_size, buffer); + //speex_encode_int(enc_state, buffer, &ebits); + + tot_bytes = speex_bits_write(&ebits, (char *)output_buffer, + enc_frame_size); + env->SetByteArrayRegion(encoded, 0, tot_bytes, + output_buffer); + + return (jint)tot_bytes; +} + +extern "C" +JNIEXPORT jint JNICALL Java_com_audio_Speex_decode + (JNIEnv *env, jobject obj, jbyteArray encoded, jshortArray lin, jint size) { + + jbyte buffer[dec_frame_size]; + jshort output_buffer[dec_frame_size]; + jsize encoded_length = size; + + if (!codec_open) + return 0; + + env->GetByteArrayRegion(encoded, 0, encoded_length, buffer); + speex_bits_read_from(&dbits, (char *)buffer, encoded_length); + speex_decode_int(dec_state, &dbits, output_buffer); + env->SetShortArrayRegion(lin, 0, dec_frame_size, + output_buffer); + + return (jint)dec_frame_size; +} + +extern "C" +JNIEXPORT jint JNICALL Java_com_audio_getFrameSize + (JNIEnv *env, jobject obj) { + + if (!codec_open) + return 0; + return (jint)enc_frame_size; + +} + +extern "C" +JNIEXPORT void JNICALL Java_com_audio_Speex_close + (JNIEnv *env, jobject obj) { + + if (--codec_open != 0) + return; + + speex_bits_destroy(&ebits); + speex_bits_destroy(&dbits); + speex_decoder_destroy(dec_state); + speex_encoder_destroy(enc_state); +} diff --git a/android/speex_config_types.h b/android/speex_config_types.h new file mode 100644 index 00000000..ca1f5a3c --- /dev/null +++ b/android/speex_config_types.h @@ -0,0 +1,12 @@ +#ifndef __SPEEX_TYPES_H__ +#define __SPEEX_TYPES_H__ + +#include + +typedef int16_t spx_int16_t; +typedef uint16_t spx_uint16_t; +typedef int32_t spx_int32_t; +typedef uint32_t spx_uint32_t; + +#endif + From 30af4f565aaa62b399e3e41a25fbefcf04ed32ec Mon Sep 17 00:00:00 2001 From: Martin Foo Date: Fri, 21 Oct 2016 23:05:53 +0800 Subject: [PATCH 2/3] Add missing config.h(define it in .gitignore). --- android/config.h | 212 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 android/config.h diff --git a/android/config.h b/android/config.h new file mode 100644 index 00000000..c2ef38fe --- /dev/null +++ b/android/config.h @@ -0,0 +1,212 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Make use of ARM4 assembly optimizations */ +/* #undef ARM4_ASM */ + +/* Make use of ARM5E assembly optimizations */ +#define ARM5E_ASM /**/ + +/* Make use of Blackfin assembly optimizations */ +/* #undef BFIN_ASM */ + +/* Disable all parts of the API that are using floats */ +#define DISABLE_FLOAT_API /**/ + +/* Disable VBR and VAD from the codec */ +/* #undef DISABLE_VBR */ + +/* Enable valgrind extra checks */ +/* #undef ENABLE_VALGRIND */ + +/* Symbol visibility prefix */ +#define EXPORT __attribute__((visibility("default"))) + +/* Debug fixed-point implementation */ +/* #undef FIXED_DEBUG */ + +/* Compile as fixed-point */ +#define FIXED_POINT /**/ + +/* Compile as floating-point */ +/* #undef FLOATING_POINT */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GETOPT_H 1 + +/* Define to 1 if you have the `getopt_long' function. */ +#define HAVE_GETOPT_LONG 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SOUNDCARD_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "speex-dev@xiph.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "speex" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "speex 1.2rc2" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "speex" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.2rc2" + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `int16_t', as computed by sizeof. */ +#define SIZEOF_INT16_T 2 + +/* The size of `int32_t', as computed by sizeof. */ +#define SIZEOF_INT32_T 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `uint16_t', as computed by sizeof. */ +#define SIZEOF_UINT16_T 2 + +/* The size of `uint32_t', as computed by sizeof. */ +#define SIZEOF_UINT32_T 4 + +/* The size of `u_int16_t', as computed by sizeof. */ +#define SIZEOF_U_INT16_T 2 + +/* The size of `u_int32_t', as computed by sizeof. */ +#define SIZEOF_U_INT32_T 4 + +/* Version extra */ +#define SPEEX_EXTRA_VERSION "" + +/* Version major */ +#define SPEEX_MAJOR_VERSION 1 + +/* Version micro */ +#define SPEEX_MICRO_VERSION 16 + +/* Version minor */ +#define SPEEX_MINOR_VERSION 1 + +/* Complete version string */ +#define SPEEX_VERSION "1.2rc2" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Enable support for TI C55X DSP */ +/* #undef TI_C55X */ + +/* Make use of alloca */ +/* #undef USE_ALLOCA */ + +/* Use FFTW3 for FFT */ +/* #undef USE_GPL_FFTW3 */ + +/* Use Intel Math Kernel Library for FFT */ +/* #undef USE_INTEL_MKL */ + +/* Use KISS Fast Fourier Transform */ +#define USE_KISS_FFT /**/ + +/* Use FFT from OggVorbis */ +/* #undef USE_SMALLFT */ + +/* Use SpeexDSP library */ +/* #undef USE_SPEEXDSP */ + +/* Use C99 variable-size arrays */ +#define VAR_ARRAYS /**/ + +/* Enable support for the Vorbis psy model */ +/* #undef VORBIS_PSYCHO */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Enable SSE support */ +/* #undef _USE_SSE */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* 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 the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#define restrict __restrict +/* Work around a bug in Sun C++: it does not support _Restrict or + __restrict__, even though the corresponding Sun C compiler ends up with + "#define restrict _Restrict" or "#define restrict __restrict__" in the + previous line. Perhaps some future version of Sun C++ will work with + restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +# define __restrict__ +#endif From 6b5f4ca8b5349397d67bdcae74918839e81bb58a Mon Sep 17 00:00:00 2001 From: Martin Foo Date: Sun, 23 Oct 2016 12:38:47 +0800 Subject: [PATCH 3/3] Add android x86 platform support. --- android/{ => inc/arm}/config.h | 0 android/{ => inc/arm}/speex_config_types.h | 0 android/inc/x86/config.h | 212 +++++++++++++++++++++ android/inc/x86/speex_config_types.h | 12 ++ android/jni/Android.mk | 19 +- android/jni/Application.mk | 4 +- 6 files changed, 242 insertions(+), 5 deletions(-) rename android/{ => inc/arm}/config.h (100%) rename android/{ => inc/arm}/speex_config_types.h (100%) create mode 100644 android/inc/x86/config.h create mode 100644 android/inc/x86/speex_config_types.h diff --git a/android/config.h b/android/inc/arm/config.h similarity index 100% rename from android/config.h rename to android/inc/arm/config.h diff --git a/android/speex_config_types.h b/android/inc/arm/speex_config_types.h similarity index 100% rename from android/speex_config_types.h rename to android/inc/arm/speex_config_types.h diff --git a/android/inc/x86/config.h b/android/inc/x86/config.h new file mode 100644 index 00000000..43d0200e --- /dev/null +++ b/android/inc/x86/config.h @@ -0,0 +1,212 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Make use of ARM4 assembly optimizations */ +/* #undef ARM4_ASM */ + +/* Make use of ARM5E assembly optimizations */ +/* #undef ARM5E_ASM */ + +/* Make use of Blackfin assembly optimizations */ +/* #undef BFIN_ASM */ + +/* Disable all parts of the API that are using floats */ +/* #undef DISABLE_FLOAT_API */ + +/* Disable VBR and VAD from the codec */ +/* #undef DISABLE_VBR */ + +/* Enable valgrind extra checks */ +/* #undef ENABLE_VALGRIND */ + +/* Symbol visibility prefix */ +#define EXPORT __attribute__((visibility("default"))) + +/* Debug fixed-point implementation */ +/* #undef FIXED_DEBUG */ + +/* Compile as fixed-point */ +/* #undef FIXED_POINT */ + +/* Compile as floating-point */ +#define FLOATING_POINT /**/ + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_GETOPT_H 1 + +/* Define to 1 if you have the `getopt_long' function. */ +#define HAVE_GETOPT_LONG 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SOUNDCARD_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#define LT_OBJDIR ".libs/" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "speex-dev@xiph.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "speex" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "speex 1.2rc2" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "speex" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.2rc2" + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `int16_t', as computed by sizeof. */ +#define SIZEOF_INT16_T 2 + +/* The size of `int32_t', as computed by sizeof. */ +#define SIZEOF_INT32_T 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `uint16_t', as computed by sizeof. */ +#define SIZEOF_UINT16_T 2 + +/* The size of `uint32_t', as computed by sizeof. */ +#define SIZEOF_UINT32_T 4 + +/* The size of `u_int16_t', as computed by sizeof. */ +#define SIZEOF_U_INT16_T 2 + +/* The size of `u_int32_t', as computed by sizeof. */ +#define SIZEOF_U_INT32_T 4 + +/* Version extra */ +#define SPEEX_EXTRA_VERSION "" + +/* Version major */ +#define SPEEX_MAJOR_VERSION 1 + +/* Version micro */ +#define SPEEX_MICRO_VERSION 16 + +/* Version minor */ +#define SPEEX_MINOR_VERSION 1 + +/* Complete version string */ +#define SPEEX_VERSION "1.2rc2" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Enable support for TI C55X DSP */ +/* #undef TI_C55X */ + +/* Make use of alloca */ +/* #undef USE_ALLOCA */ + +/* Use FFTW3 for FFT */ +/* #undef USE_GPL_FFTW3 */ + +/* Use Intel Math Kernel Library for FFT */ +/* #undef USE_INTEL_MKL */ + +/* Use KISS Fast Fourier Transform */ +/* #undef USE_KISS_FFT */ + +/* Use FFT from OggVorbis */ +#define USE_SMALLFT /**/ + +/* Use SpeexDSP library */ +/* #undef USE_SPEEXDSP */ + +/* Use C99 variable-size arrays */ +#define VAR_ARRAYS /**/ + +/* Enable support for the Vorbis psy model */ +/* #undef VORBIS_PSYCHO */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Enable SSE support */ +#define _USE_SSE /**/ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* 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 the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#define restrict __restrict +/* Work around a bug in Sun C++: it does not support _Restrict or + __restrict__, even though the corresponding Sun C compiler ends up with + "#define restrict _Restrict" or "#define restrict __restrict__" in the + previous line. Perhaps some future version of Sun C++ will work with + restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +# define __restrict__ +#endif diff --git a/android/inc/x86/speex_config_types.h b/android/inc/x86/speex_config_types.h new file mode 100644 index 00000000..ca1f5a3c --- /dev/null +++ b/android/inc/x86/speex_config_types.h @@ -0,0 +1,12 @@ +#ifndef __SPEEX_TYPES_H__ +#define __SPEEX_TYPES_H__ + +#include + +typedef int16_t spx_int16_t; +typedef uint16_t spx_uint16_t; +typedef int32_t spx_int32_t; +typedef uint32_t spx_uint32_t; + +#endif + diff --git a/android/jni/Android.mk b/android/jni/Android.mk index d8e69498..473556b0 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -4,15 +4,28 @@ SPEEX_PATH=$(realpath $(LOCAL_PATH)/../..) SPX_ANDROID_PATH=$(realpath $(LOCAL_PATH)/..) $(info SPEEX_PATH = $(SPEEX_PATH)) +ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) + $(info Build speex for arm platform...) + SPX_INCLUDE_PATH := $(SPX_ANDROID_PATH)/inc/arm +else + ifeq ($(TARGET_ARCH_ABI), x86) + $(info Build speex for x86 platform...) + SPX_INCLUDE_PATH := $(SPX_ANDROID_PATH)/inc/x86 + else + $(error Unsupport platform!) + endif +endif + ########################## # libspeex static library # - ########################## +########################## include $(CLEAR_VARS) LOCAL_MODULE := libspeex + LOCAL_CFLAGS := -DHAVE_CONFIG_H -LOCAL_C_INCLUDES := $(SPX_ANDROID_PATH) +LOCAL_C_INCLUDES := $(SPX_INCLUDE_PATH) LOCAL_C_INCLUDES += $(SPEEX_PATH)/include LOCAL_ARM_MODE := arm @@ -60,7 +73,7 @@ include $(CLEAR_VARS) LOCAL_MODULE := libspeex-jni LOCAL_CFLAGS += -Wall -fvisibility=hidden -DHAVE_CONFIG_H -LOCAL_C_INCLUDES := $(SPX_ANDROID_PATH) +LOCAL_C_INCLUDES := $(SPX_INCLUDE_PATH) LOCAL_C_INCLUDES += $(SPEEX_PATH)/include LOCAL_SRC_FILES := speex-jni.cpp diff --git a/android/jni/Application.mk b/android/jni/Application.mk index 4dbbaa2d..fe91cdfc 100644 --- a/android/jni/Application.mk +++ b/android/jni/Application.mk @@ -1,6 +1,6 @@ # The ARMv7 is significanly faster due to the use of the hardware FPU -# APP_ABI := armeabi-v7a armeabi x86 mips -APP_ABI := armeabi-v7a + +APP_ABI := armeabi-v7a x86 APP_PLATFORM := android-14 APP_STL := gnustl_static