Bug 674225 - Add libopus to the mozilla build system. - r=ted
authorRalph Giles <giles@mozilla.com>
Mon, 30 Apr 2012 16:20:22 -0700
changeset 96897 32e001c1351b8f84e72945241adf453008e50c8a
parent 96896 8bb81a28639c3546a6dc1167b9e2e26eda8f0d73
child 96898 46e22a07d53a3d97d3c709f935b7821fd846451f
push idunknown
push userunknown
push dateunknown
reviewersted
bugs674225
milestone15.0a1
Bug 674225 - Add libopus to the mozilla build system. - r=ted This builds the opus reference library in media/libopus. We support both fixed and floating point builds, switched by MOZ_OPUS_FIXED. Currently this isn't defined by anything but should probably offer a configure option, and default to true on arm. Thanks to Tim Terriberry for additional review.
config/autoconf.mk.in
configure.in
layout/media/Makefile.in
layout/media/symbols.def.in
media/libopus/Makefile.in
toolkit/toolkit-makefiles.sh
toolkit/toolkit-tiers.mk
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -165,16 +165,17 @@ MOZ_OGG = @MOZ_OGG@
 MOZ_RAW = @MOZ_RAW@
 MOZ_SYDNEYAUDIO = @MOZ_SYDNEYAUDIO@
 MOZ_CUBEB = @MOZ_CUBEB@
 MOZ_WAVE = @MOZ_WAVE@
 MOZ_MEDIA = @MOZ_MEDIA@
 MOZ_VORBIS = @MOZ_VORBIS@
 MOZ_TREMOR = @MOZ_TREMOR@
 MOZ_NO_THEORA_ASM = @MOZ_NO_THEORA_ASM@
+MOZ_OPUS = @MOZ_OPUS@
 MOZ_WEBM = @MOZ_WEBM@
 MOZ_GSTREAMER = @MOZ_GSTREAMER@
 MOZ_VP8_ERROR_CONCEALMENT = @MOZ_VP8_ERROR_CONCEALMENT@
 MOZ_VP8_ENCODER = @MOZ_VP8_ENCODER@
 VPX_AS = @VPX_AS@
 VPX_ASFLAGS = @VPX_ASFLAGS@
 VPX_DASH_C_FLAG = @VPX_DASH_C_FLAG@
 VPX_AS_CONVERSION = @VPX_AS_CONVERSION@
--- a/configure.in
+++ b/configure.in
@@ -4557,16 +4557,17 @@ MOZ_AUTH_EXTENSION=1
 MOZ_OGG=1
 MOZ_RAW=
 MOZ_SYDNEYAUDIO=
 MOZ_CUBEB=
 MOZ_VORBIS=
 MOZ_TREMOR=
 MOZ_WAVE=1
 MOZ_MEDIA=
+MOZ_OPUS=1
 MOZ_WEBM=1
 MOZ_VP8_ERROR_CONCEALMENT=
 MOZ_VP8_ENCODER=
 VPX_AS=
 VPX_ASFLAGS=
 VPX_AS_DASH_C_FLAG=
 VPX_AS_CONVERSION=
 VPX_ASM_SUFFIX=
@@ -5620,16 +5621,24 @@ if test -n "$MOZ_OGG"; then
            CFLAGS="${CFLAGS_save}"])
     if test "${ac_cv_c_attribute_aligned}" != "0"; then
       AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX],
                          [${ac_cv_c_attribute_aligned}],[Maximum supported data alignment])
     fi
 fi
 
 dnl ========================================================
+dnl = Disable Opus audio codec support
+dnl ========================================================
+MOZ_ARG_DISABLE_BOOL(opus,
+[  --disable-opus          Disable support for Opus audio],
+    MOZ_OPUS=,
+    MOZ_OPUS=1)
+
+dnl ========================================================
 dnl = Disable VP8 decoder support
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(webm,
 [  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)],
     MOZ_WEBM=,
     MOZ_WEBM=1)
 
 dnl system libvpx Support
@@ -5817,16 +5826,20 @@ fi
 if test -n "$MOZ_VORBIS"; then
     AC_DEFINE(MOZ_VORBIS)
 fi
 
 if test -n "$MOZ_TREMOR"; then
     AC_DEFINE(MOZ_TREMOR)
 fi
 
+if test -n "$MOZ_OPUS"; then
+    AC_DEFINE(MOZ_OPUS)
+fi
+
 dnl ========================================================
 dnl = Check alsa availability on Linux if using sydneyaudio
 dnl ========================================================
 
 dnl If using sydneyaudio with Linux, ensure that the alsa library is available
 if test -n "$MOZ_SYDNEYAUDIO" -a "$OS_TARGET" = "Linux"; then
     PKG_CHECK_MODULES(MOZ_ALSA, alsa, ,
          [echo "$MOZ_ALSA_PKG_ERRORS"
@@ -8704,16 +8717,17 @@ AC_SUBST(MOZ_APP_COMPONENT_LIBS)
 AC_SUBST(MOZ_APP_EXTRA_LIBS)
 
 AC_SUBST(MOZ_MEDIA)
 AC_SUBST(MOZ_SYDNEYAUDIO)
 AC_SUBST(MOZ_CUBEB)
 AC_SUBST(MOZ_WAVE)
 AC_SUBST(MOZ_VORBIS)
 AC_SUBST(MOZ_TREMOR)
+AC_SUBST(MOZ_OPUS)
 AC_SUBST(MOZ_WEBM)
 AC_SUBST(MOZ_VP8_ERROR_CONCEALMENT)
 AC_SUBST(MOZ_VP8_ENCODER)
 AC_SUBST(MOZ_OGG)
 AC_SUBST(MOZ_ALSA_LIBS)
 AC_SUBST(MOZ_ALSA_CFLAGS)
 AC_SUBST(VPX_AS)
 AC_SUBST(VPX_ASFLAGS)
--- a/layout/media/Makefile.in
+++ b/layout/media/Makefile.in
@@ -66,16 +66,22 @@ SHARED_LIBRARY_LIBS	+= \
 endif
 
 ifdef MOZ_OGG
 SHARED_LIBRARY_LIBS 	+= \
 	$(DEPTH)/media/libtheora/lib/$(LIB_PREFIX)theora.$(LIB_SUFFIX) \
 	$(NULL)
 endif
 
+ifdef MOZ_OPUS
+SHARED_LIBRARY_LIBS += \
+  $(DEPTH)/media/libopus/$(LIB_PREFIX)opus.$(LIB_SUFFIX) \
+  $(NULL)
+endif
+
 ifdef MOZ_WEBM
 SHARED_LIBRARY_LIBS 	+= \
 	$(DEPTH)/media/libnestegg/src/$(LIB_PREFIX)nestegg.$(LIB_SUFFIX) \
 	$(NULL)
 ifndef MOZ_NATIVE_LIBVPX
 SHARED_LIBRARY_LIBS 	+= $(DEPTH)/media/libvpx/$(LIB_PREFIX)vpx.$(LIB_SUFFIX)
 endif
 endif
--- a/layout/media/symbols.def.in
+++ b/layout/media/symbols.def.in
@@ -92,16 +92,24 @@ th_decode_packetin
 th_decode_ycbcr_out
 th_granule_frame
 th_info_clear
 th_info_init
 th_packet_isheader
 th_packet_iskeyframe
 th_setup_free
 #endif
+#ifdef MOZ_OPUS
+opus_decoder_create
+opus_decoder_destroy
+opus_decoder_ctl
+opus_decoder_get_nb_samples
+opus_decode
+opus_decode_float
+#endif
 ShInitialize
 ShFinalize
 ShGetObjectCode
 ShDestruct
 ShGetInfoLog
 ShCompile
 ShGetInfo
 ShConstructCompiler
new file mode 100644
--- /dev/null
+++ b/media/libopus/Makefile.in
@@ -0,0 +1,76 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
+DEPTH = ../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = opus
+LIBRARY_NAME = opus
+FORCE_STATIC_LIB= 1
+
+DEFINES += \
+  -DOPUS_BUILD \
+  -DOPUS_VERSION='"draft-11-mozilla"' \
+  -DUSE_ALLOCA \
+  -Drestrict= \
+  $(NULL)
+
+ifneq ($(filter $(OS_ARCH),Linux Darwin),)
+  DEFINES += -DHAVE_LRINTF
+endif
+ifeq ($(OS_ARCH), WINNT)
+  DEFINES += -Dinline=__inline
+endif
+ifeq ($(OS_ARCH),AIX)
+DEFINES += -Dalloca=__alloca
+endif
+
+EXPORTS_NAMESPACES = opus
+
+EXPORTS_opus = \
+  include/opus.h \
+  include/opus_defines.h \
+  include/opus_types.h \
+  include/opus_multistream.h \
+  $(NULL)
+
+LOCAL_INCLUDES += \
+  -I$(srcdir)/include \
+  -I$(srcdir)/celt \
+  -I$(srcdir)/silk \
+  -I$(srcdir)/src \
+  $(NULL)
+
+VPATH += \
+  $(srcdir)/celt \
+  $(srcdir)/silk \
+  $(srcdir)/src \
+  $(NULL)
+
+include $(srcdir)/celt_sources.mk
+include $(srcdir)/silk_sources.mk
+include $(srcdir)/opus_sources.mk
+
+CSRCS = \
+  $(notdir $(CELT_SOURCES)) \
+  $(notdir $(SILK_SOURCES)) \
+  $(notdir $(OPUS_SOURCES)) \
+  $(NULL)
+
+ifdef MOZ_OPUS_FIXED
+DEFINES += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
+LOCAL_INCLUDES += -I$(srcdir)/silk/fixed
+VPATH += $(srcdir)/silk/fixed
+CSRCS += $(notdir $(SILK_SOURCES_FIXED))
+else
+LOCAL_INCLUDES += -I$(srcdir)/silk/float
+VPATH += $(srcdir)/silk/float
+CSRCS += $(notdir $(SILK_SOURCES_FLOAT))
+endif
+
+include $(topsrcdir)/config/rules.mk
--- a/toolkit/toolkit-makefiles.sh
+++ b/toolkit/toolkit-makefiles.sh
@@ -1570,16 +1570,22 @@ fi
 if [ "$MOZ_TREMOR" ]; then
   add_makefiles "
     media/libtremor/Makefile
     media/libtremor/lib/Makefile
     media/libtremor/include/tremor/Makefile
   "
 fi
 
+if [ "$MOZ_OPUS" ]; then
+ add_makefiles "
+   media/libopus/Makefile
+ "
+fi
+
 if [ "$MOZ_OGG" ]; then
   add_makefiles "
     content/media/ogg/Makefile
     media/libogg/Makefile
     media/libogg/src/Makefile
     media/libogg/include/Makefile
     media/libogg/include/ogg/Makefile
     media/libtheora/Makefile
--- a/toolkit/toolkit-tiers.mk
+++ b/toolkit/toolkit-tiers.mk
@@ -128,16 +128,22 @@ tier_platform_dirs += \
 endif
 
 ifdef MOZ_TREMOR
 tier_platform_dirs += \
 		media/libtremor \
 		$(NULL)
 endif
 
+ifdef MOZ_OPUS
+tier_platform_dirs += \
+  media/libopus \
+  $(NULL)
+endif
+
 ifdef MOZ_WEBM
 tier_platform_dirs += media/libnestegg
 ifndef MOZ_NATIVE_LIBVPX
 tier_platform_dirs += media/libvpx
 endif
 endif
 
 ifdef MOZ_OGG