Speex编解码在Android上实现


以前在应用中使用到了Speex编解码,近来总结了一下Speex在Android上的实现。Speex是一套主要针对语音的开源免费,无专利保护的音频压缩格式。Speex工程着力于通过提供一个可以替代高性能语音编解码来降低语音应用输入门槛 。另外,相对于其它编解码,Speex也很适合网络应用,在网络应用上有着自己独特的优势。同时,Speex还是GNU工程的一部分,在改版的BSD协议中得到了很好的支持。Speex是基于CELP并且专门为码率在2-44kbps的语音压缩而设计的。Speex源码是基于c语音实现的(也有java实现,效率相对较低)。

1、去Speex官网下载最新Speex源码。

2、创建新的android工程,并创建jni文件夹。

3、把speex源码目录下的libspeex和include目录及其子目录文件全部拷贝到$project/jni目录下。

4、在jni目录下新增Android.mk文件,编辑内容如下:

  1. LOCAL_PATH := $(call my-dir)  
  2.    
  3. include $(CLEAR_VARS)  
  4.    
  5. LOCAL_MODULE:= libspeex  
  6. LOCAL_CFLAGS = -DFIXED_POINT -DUSE_KISS_FFT -DEXPORT="" -UHAVE_CONFIG_H  
  7. LOCAL_C_INCLUDES := $(LOCAL_PATH)/include  
  8.    
  9. LOCAL_SRC_FILES :=\  
  10. libspeex/bits.c \  
  11. libspeex/buffer.c \  
  12. libspeex/cb_search.c \  
  13. libspeex/exc_10_16_table.c \  
  14. libspeex/exc_10_32_table.c \  
  15. libspeex/exc_20_32_table.c \  
  16. libspeex/exc_5_256_table.c \  
  17. libspeex/exc_5_64_table.c \  
  18. libspeex/exc_8_128_table.c \  
  19. libspeex/fftwrap.c \  
  20. libspeex/filterbank.c \  
  21. libspeex/filters.c \  
  22. libspeex/gain_table.c \  
  23. libspeex/gain_table_lbr.c \  
  24. libspeex/hexc_10_32_table.c \  
  25. libspeex/hexc_table.c \  
  26. libspeex/high_lsp_tables.c \  
  27. libspeex/jitter.c \  
  28. libspeex/kiss_fft.c \  
  29. libspeex/kiss_fftr.c \  
  30. libspeex/lpc.c \  
  31. libspeex/lsp.c \  
  32. libspeex/lsp_tables_nb.c \  
  33. libspeex/ltp.c \  
  34. libspeex/mdf.c \  
  35. libspeex/modes.c \  
  36. libspeex/modes_wb.c \  
  37. libspeex/nb_celp.c \  
  38. libspeex/preprocess.c \  
  39. libspeex/quant_lsp.c \  
  40. libspeex/resample.c \  
  41. libspeex/sb_celp.c \  
  42. libspeex/scal.c \  
  43. libspeex/smallft.c \  
  44. libspeex/speex.c \  
  45. libspeex/speex_callbacks.c \  
  46. libspeex/speex_header.c \  
  47. libspeex/stereo.c \  
  48. libspeex/vbr.c \  
  49. libspeex/vq.c \  
  50. libspeex/window.c \  
  51. speex_jni.cpp \  
  52.   
  53.   
  54. include $(BUILD_SHARED_LIBRARY)  
  • 1
  • 2
  • 3
  • 下一页

相关内容