KBEngine官方论坛

 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 配置 开服
查看: 1421|回复: 4

Opus-Android

[复制链接]

8

主题

3374

帖子

7586

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
7586
QQ
发表于 2016-12-9 17:01:32 | 显示全部楼层 |阅读模式
A build Android NDK script from: http://stackoverflow.com/questions/17869333/makefile-needed-for-compiling-the-opus-codec-for-android

Android.mk 放到源码目录下

  1. <div>LOCAL_PATH := $(call my-dir)</div><div>include $(CLEAR_VARS)</div><div>MY_MODULE_DIR       := opus</div><div>LOCAL_MODULE        := $(MY_MODULE_DIR)
  2. LOCAL_SRC_FILES     := \
  3.     $(subst $(ROOT_DIR)/$(MY_MODULE_DIR)/,,$(wildcard $(ROOT_DIR)/$(MY_MODULE_DIR)/src/*.c*)) \
  4.     $(subst $(ROOT_DIR)/$(MY_MODULE_DIR)/,,$(wildcard $(ROOT_DIR)/$(MY_MODULE_DIR)/celt/*.c*)) \
  5.     $(subst $(ROOT_DIR)/$(MY_MODULE_DIR)/,,$(wildcard $(ROOT_DIR)/$(MY_MODULE_DIR)/silk/*.c*)) \
  6.     $(subst $(ROOT_DIR)/$(MY_MODULE_DIR)/,,$(wildcard $(ROOT_DIR)/$(MY_MODULE_DIR)/silk/fixed/*.c*))
  7. LOCAL_LDLIBS        := -lm -llog
  8. LOCAL_C_INCLUDES    := \
  9.     $(ROOT_DIR)/$(MY_MODULE_DIR)/include \
  10.     $(ROOT_DIR)/$(MY_MODULE_DIR)/silk \
  11.     $(ROOT_DIR)/$(MY_MODULE_DIR)/silk/fixed \
  12.     $(ROOT_DIR)/$(MY_MODULE_DIR)/celt
  13. LOCAL_CFLAGS        := -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
  14. LOCAL_CFLAGS    += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -O3 -fno-math-errno
  15. LOCAL_CPPFLAGS      := -DBSD=1
  16. LOCAL_CPPFLAGS          += -ffast-math -O3 -funroll-loops</div><div>include $(BUILD_STATIC_LIBRARY)</div>
复制代码


Steps:
  • Download the opus source files into 'opus' directory.  Opus version 1.1 works well: http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz For latest version 1.1.1-beta, a build error happens in the next build step.
  • Build it using Android 'ndk-build' command:
    ndk-build APP_BUILD_SCRIPT=Android.mk NDK_PROJECT_PATH=build
  • Find the built static library at 'build/obj/local/armeabi/libopus.a'.
柯标
3603661@qq.com
回复

使用道具 举报

8

主题

3374

帖子

7586

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
7586
QQ
 楼主| 发表于 2016-12-9 17:14:43 | 显示全部楼层
  1. LOCAL_PATH := $(call my-dir)

  2. include $(CLEAR_VARS)

  3. include $(LOCAL_PATH)/celt_sources.mk
  4. include $(LOCAL_PATH)/opus_sources.mk
  5. include $(LOCAL_PATH)/silk_sources.mk

  6. LOCAL_MODULE    := libopus
  7. OGG_DIR         := external/libogg
  8. LOCAL_C_INCLUDES += $(LOCAL_PATH)/include $(LOCAL_PATH)/src $(LOCAL_PATH)/silk \
  9.                     $(LOCAL_PATH)/celt $(LOCAL_PATH)/silk/fixed $(OGG_DIR)/include
  10. LOCAL_SRC_FILES := $(CELT_SOURCES) $(SILK_SOURCES) $(SILK_SOURCES_FIXED) \
  11.                    $(OPUS_SOURCES) $(OPUS_SOURCES_FLOAT) src/repacketizer_demo.c

  12. LOCAL_CFLAGS        := -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED \
  13.                        -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 \
  14.                        -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT \
  15.                        -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -O2 -fno-math-errno
  16. LOCAL_CPPFLAGS      := -DBSD=1 -ffast-math -O2 -funroll-loops

  17. # Note: OPUS enhanced DSP/NEON implementation is not yet compatible with arm64.
  18. # Only add the appropriate defines for 32-bit arm architecture.
  19. LOCAL_SRC_FILES_arm += $(CELT_SOURCES_ARM)
  20. LOCAL_CFLAGS_arm += -DOPUS_ARM_ASM -DOPUS_ARM_INLINE_ASM \
  21.                     -DOPUS_ARM_MAY_HAVE_EDSP -DOPUS_ARM_INLINE_EDSP \
  22.                     -DOPUS_ARM_MAY_HAVE_MEDIA -DOPUS_ARM_INLINE_MEDIA \
  23.                     -DOPUS_HAVE_RTCD
  24. # DSP, MEDIA and NEON instructions are in the same assembler file - thus we
  25. # need to include it even if NEON is not supported on target platform.
  26. LOCAL_SRC_FILES_arm += $(subst .s,_gnu.s,$(CELT_SOURCES_ARM_ASM))
  27. ifeq ($(ARCH_ARM_HAVE_NEON),true)
  28. LOCAL_SRC_FILES_arm += $(CELT_SOURCES_ARM_NEON_INTR) \
  29.                        $(SILK_SOURCES_ARM_NEON_INTR)
  30. LOCAL_CFLAGS_arm += -DOPUS_ARM_MAY_HAVE_NEON -DOPUS_ARM_MAY_HAVE_NEON_INTR \
  31.                     -DOPUS_ARM_PRESUME_NEON -DOPUS_ARM_INLINE_NEON
  32. endif

  33. LIBOPUS_X86_FILES :=
  34. LIBOPUS_X86_CFLAGS :=
  35. ifeq ($(ARCH_X86_HAVE_SSSE3),true)
  36. LIBOPUS_X86_FILES += $(CELT_SOURCES_SSE) $(CELT_SOURCES_SSE2)
  37. LIBOPUS_X86_CFLAGS += -DOPUS_X86_MAY_HAVE_SSE -DOPUS_X86_PRESUME_SSE \
  38.                       -DOPUS_X86_MAY_HAVE_SSE2 -DOPUS_X86_PRESUME_SSE2
  39. endif

  40. ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
  41. LIBOPUS_X86_FILES += $(CELT_SOURCES_SSE4_1) \
  42.                    $(SILK_SOURCES_SSE4_1) $(SILK_SOURCES_FIXED_SSE4_1)
  43. LIBOPUS_X86_CFLAGS += -DOPUS_X86_MAY_HAVE_SSE4_1 -DOPUS_X86_PRESUME_SSE4_1
  44. endif

  45. LOCAL_SRC_FILES_x86 += $(LIBOPUS_X86_FILES)
  46. LOCAL_SRC_FILES_x86_64 += $(LIBOPUS_X86_FILES)
  47. LOCAL_CFLAGS_x86 += $(LIBOPUS_X86_CFLAGS)
  48. LOCAL_CFLAGS_x86_64 += $(LIBOPUS_X86_CFLAGS)

  49. LOCAL_STATIC_LIBRARIES := libogg

  50. include $(BUILD_SHARED_LIBRARY)
复制代码



适用unreal    https://android.googlesource.com ... al/libopus/+/master
柯标
3603661@qq.com
回复

使用道具 举报

8

主题

3374

帖子

7586

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
7586
QQ
 楼主| 发表于 2016-12-9 17:15:34 | 显示全部楼层


  1. libopus is currently supported on Windows, Mac, and Linux in UE4. I haven't tried making it for Android, but these steps may work.
  2. There is an android.mk for libopus here: https://android.googlesource.com/platform/external/libopus/+/master
  3. Compile a libopus.a and libspeex_resampler.a for ARM and optionally x86. Create an opus-1.1/Android/ARMv7 directory and optional opus-1.1/Android/x86 directory and copy the .a files into them.
  4. Making the following addition to libOpus.build.cs in Engine/Source/ThirdParty/libOpus:
  5. else if (Target.Platform == UnrealTargetPlatform.Android)
  6. {
  7.              PublicAdditionalLibraries.Add(LibraryPath + "/Android/ARMv7/libopus.a");
  8.              PublicAdditionalLibraries.Add(LibraryPath + "/Android/ARMv7/libspeex_resampler.a");
  9.              PublicAdditionalLibraries.Add(LibraryPath + "/Android/x86/libopus.a");
  10.              PublicAdditionalLibraries.Add(LibraryPath + "/Android/x86/libspeex_resampler.a");
  11. }

  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
复制代码
柯标
3603661@qq.com
回复

使用道具 举报

8

主题

3374

帖子

7586

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
7586
QQ
 楼主| 发表于 2016-12-9 17:29:14 | 显示全部楼层
柯标
3603661@qq.com
回复

使用道具 举报

8

主题

3374

帖子

7586

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
7586
QQ
 楼主| 发表于 2016-12-9 17:45:35 | 显示全部楼层
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=./Android.mk APP_ABI="armeabi armeabi-v7a"
柯标
3603661@qq.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|KBEngine Forum

GMT+8, 2018-12-11 17:25 , Processed in 0.043312 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表