diff options
author | Ralph Giles <giles@thaumas.net> | 2020-06-13 13:56:47 -0700 |
---|---|---|
committer | Ralph Giles <giles@thaumas.net> | 2020-06-13 13:56:47 -0700 |
commit | 44e185265023385573edbb5f4198c352a43339ac (patch) | |
tree | 4316c08d8c5a3be07007967c80efb2c69d2da712 | |
parent | d99495f41dfb8e48b68d3026344ca41bbada69a4 (diff) | |
parent | 3cb71dbefd5a0a2ec4d692c6dd71c9ed6d207ffb (diff) | |
download | opus-draft.tar.gz |
Merge branch 'draft-willson' into draftdraft
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | .gitlab-ci.yml | 16 | ||||
-rw-r--r-- | CMakeLists.txt | 525 | ||||
-rw-r--r-- | Makefile.am | 18 | ||||
-rw-r--r-- | README | 4 | ||||
-rw-r--r-- | README.draft | 4 | ||||
-rw-r--r-- | celt/arch.h | 3 | ||||
-rw-r--r-- | celt/celt_encoder.c | 2 | ||||
-rw-r--r-- | celt/ecintrin.h | 4 | ||||
-rw-r--r-- | celt/os_support.h | 1 | ||||
-rw-r--r-- | cmake/CFeatureCheck.cmake | 4 | ||||
-rw-r--r-- | cmake/OpusBuildtype.cmake (renamed from opus_buildtype.cmake) | 4 | ||||
-rw-r--r-- | cmake/OpusConfig.cmake (renamed from opus_config.cmake) | 27 | ||||
-rw-r--r-- | cmake/OpusConfig.cmake.in (renamed from OpusConfig.cmake.in) | 0 | ||||
-rw-r--r-- | cmake/OpusFunctions.cmake (renamed from opus_functions.cmake) | 17 | ||||
-rw-r--r-- | cmake/OpusSources.cmake (renamed from opus_sources.cmake) | 10 | ||||
-rw-r--r-- | cmake/config.h.cmake.in (renamed from config.h.cmake.in) | 0 | ||||
-rw-r--r-- | doc/Doxyfile.in | 14 | ||||
-rwxr-xr-x | doc/build_draft.sh | 2 | ||||
-rw-r--r-- | doc/footer.html | 8 | ||||
-rw-r--r-- | doc/header.html | 17 | ||||
-rw-r--r-- | doc/release.txt | 4 | ||||
-rw-r--r-- | doc/trivial_example.c | 19 | ||||
-rw-r--r-- | include/opus_custom.h | 4 | ||||
-rw-r--r-- | silk/MacroCount.h | 2 | ||||
-rw-r--r-- | silk/debug.c | 3 | ||||
-rw-r--r-- | silk/debug.h | 25 | ||||
-rw-r--r-- | silk/typedef.h | 3 | ||||
-rw-r--r-- | src/analysis.c | 2 | ||||
-rw-r--r-- | tests/test_opus_common.h | 3 |
30 files changed, 415 insertions, 331 deletions
@@ -38,6 +38,7 @@ opus_demo repacketizer_demo stamp-h1 test-driver +trivial_example *.sw* *.o *.lo diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ddf8a228..5dd6ef15 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,8 @@ -# Image from https://hub.docker.com/_/gcc/ based on Debian -image: gcc +default: + tags: + - docker + # Image from https://hub.docker.com/_/gcc/ based on Debian + image: gcc autoconf: stage: build @@ -19,8 +22,6 @@ autoconf: - "silk/.libs/*.o" - "celt/*.o" - "celt/.libs/*.o" - tags: - - docker cmake: stage: build @@ -29,10 +30,9 @@ cmake: apt-get install -y cmake ninja-build script: - mkdir build - - cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release + - cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DOPUS_BUILD_TESTING=ON -DOPUS_BUILD_PROGRAMS=ON - cmake --build build - tags: - - docker + - cd build && ctest --output-on-failure doc: stage: build @@ -45,5 +45,3 @@ doc: cache: paths: - doc/opus_testvectors.tar.gz - tags: - - docker diff --git a/CMakeLists.txt b/CMakeLists.txt index b69aab29..0dc4b176 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.1) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -include(opus_functions.cmake) +include(OpusFunctions) get_library_version(OPUS_LIBRARY_VERSION OPUS_LIBRARY_VERSION_MAJOR) message(STATUS "Opus library version: ${OPUS_LIBRARY_VERSION}") @@ -17,148 +17,192 @@ string(REGEX message(STATUS "Opus project version: ${PROJECT_VERSION}") project(Opus LANGUAGES C VERSION ${PROJECT_VERSION}) -include(opus_buildtype.cmake) - -option(OPUS_BUILD_SHARED_LIBRARY "Build shared library" OFF) -option(OPUS_STACK_PROTECTOR "Use stack protection" ON) -option(OPUS_CUSTOM_MODES "Enable non-Opus modes, e.g. 44.1 kHz & 2^n frames" - OFF) -option(OPUS_BUILD_PROGRAMS "Build programs" OFF) -option(OPUS_BUILD_TESTING "Build tests" OFF) -option(OPUS_FIXED_POINT - "Compile as fixed-point (for machines without a fast enough FPU)" OFF) -option(OPUS_ENABLE_FLOAT_API - "Compile with the floating point API (for machines with float library" - ON) -option(OPUS_FLOAT_APPROX - "Enable floating point approximations (Ensure your platform supports IEEE 754 before enabling)" - OFF) -option(OPUS_INSTALL_PKG_CONFIG_MODULE "Install PkgConfig module" ON) -option(OPUS_INSTALL_CMAKE_CONFIG_MODULE "Install CMake package config module" - ON) - -include(opus_config.cmake) -include(opus_sources.cmake) + +include(OpusBuildtype) +include(OpusConfig) +include(OpusSources) include(GNUInstallDirs) include(CMakeDependentOption) include(FeatureSummary) -cmake_dependent_option(OPUS_VAR_ARRAYS - "Use variable length arrays for stack arrays" +set(OPUS_BUILD_SHARED_LIBRARY_HELP_STR "build shared library.") +option(OPUS_BUILD_SHARED_LIBRARY ${OPUS_BUILD_SHARED_LIBRARY_HELP_STR} OFF) +if(OPUS_BUILD_SHARED_LIBRARY OR BUILD_SHARED_LIBS OR OPUS_BUILD_FRAMEWORK) + # Global flag to cause add_library() to create shared libraries if on. + set(BUILD_SHARED_LIBS ON) + set(OPUS_BUILD_SHARED_LIBRARY ON) +endif() +add_feature_info(OPUS_BUILD_SHARED_LIBRARY OPUS_BUILD_SHARED_LIBRARY ${OPUS_BUILD_SHARED_LIBRARY_HELP_STR}) + +set(OPUS_BUILD_TESTING_HELP_STR "build tests.") +option(OPUS_BUILD_TESTING ${OPUS_BUILD_TESTING_HELP_STR} OFF) +if(OPUS_BUILD_TESTING OR BUILD_TESTING) + set(OPUS_BUILD_TESTING ON) + set(BUILD_TESTING ON) +endif() +add_feature_info(OPUS_BUILD_TESTING OPUS_BUILD_TESTING ${OPUS_BUILD_TESTING_HELP_STR}) + +set(OPUS_CUSTOM_MODES_HELP_STR "enable non-Opus modes, e.g. 44.1 kHz & 2^n frames.") +option(OPUS_CUSTOM_MODES ${OPUS_CUSTOM_MODES_HELP_STR} OFF) +add_feature_info(OPUS_CUSTOM_MODES OPUS_CUSTOM_MODES ${OPUS_CUSTOM_MODES_HELP_STR}) + +set(OPUS_BUILD_PROGRAMS_HELP_STR "build programs.") +option(OPUS_BUILD_PROGRAMS ${OPUS_BUILD_PROGRAMS_HELP_STR} OFF) +add_feature_info(OPUS_BUILD_PROGRAMS OPUS_BUILD_PROGRAMS ${OPUS_BUILD_PROGRAMS_HELP_STR}) + +set(OPUS_DISABLE_INTRINSICS_HELP_STR "disable all intrinsics optimizations.") +option(OPUS_DISABLE_INTRINSICS ${OPUS_DISABLE_INTRINSICS_HELP_STR} OFF) +add_feature_info(OPUS_DISABLE_INTRINSICS OPUS_DISABLE_INTRINSICS ${OPUS_DISABLE_INTRINSICS_HELP_STR}) + +set(OPUS_FIXED_POINT_HELP_STR "compile as fixed-point (for machines without a fast enough FPU).") +option(OPUS_FIXED_POINT ${OPUS_FIXED_POINT_HELP_STR} OFF) +add_feature_info(OPUS_FIXED_POINT OPUS_FIXED_POINT ${OPUS_FIXED_POINT_HELP_STR}) + +set(OPUS_ENABLE_FLOAT_API_HELP_STR "compile with the floating point API (for machines with float library).") +option(OPUS_ENABLE_FLOAT_API ${OPUS_ENABLE_FLOAT_API_HELP_STR} ON) +add_feature_info(OPUS_FLOAT_API OPUS_ENABLE_FLOAT_API ${OPUS_ENABLE_FLOAT_API_HELP_STR}) + +set(OPUS_FLOAT_APPROX_HELP_STR "enable floating point approximations (Ensure your platform supports IEEE 754 before enabling).") +option(OPUS_FLOAT_APPROX ${OPUS_FLOAT_APPROX_HELP_STR} OFF) +add_feature_info(OPUS_FLOAT_APPROX OPUS_FLOAT_APPROX ${OPUS_FLOAT_APPROX_HELP_STR}) + +set(OPUS_INSTALL_PKG_CONFIG_MODULE_HELP_STR "install pkg-config module.") +option(OPUS_INSTALL_PKG_CONFIG_MODULE ${OPUS_INSTALL_PKG_CONFIG_MODULE_HELP_STR} ON) +add_feature_info(OPUS_INSTALL_PKG_CONFIG_MODULE OPUS_INSTALL_PKG_CONFIG_MODULE ${OPUS_INSTALL_PKG_CONFIG_MODULE_HELP_STR}) + +set(OPUS_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR "install CMake package config module.") +option(OPUS_INSTALL_CMAKE_CONFIG_MODULE ${OPUS_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR} ON) +add_feature_info(OPUS_INSTALL_CMAKE_CONFIG_MODULE OPUS_INSTALL_CMAKE_CONFIG_MODULE ${OPUS_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR}) + +if(APPLE) + set(OPUS_BUILD_FRAMEWORK_HELP_STR "build Framework bundle for Apple systems.") + option(OPUS_BUILD_FRAMEWORK ${OPUS_BUILD_FRAMEWORK_HELP_STR} OFF) + add_feature_info(OPUS_BUILD_FRAMEWORK OPUS_BUILD_FRAMEWORK ${OPUS_BUILD_FRAMEWORK_HELP_STR}) +endif() + +set(OPUS_VAR_ARRAYS_HELP_STR "use variable length arrays for stack arrays.") +cmake_dependent_option(OPUS_VAR_ARRAYS + ${OPUS_VAR_ARRAYS_HELP_STR} ON "VLA_SUPPORTED; NOT OPUS_USE_ALLOCA; NOT OPUS_NONTHREADSAFE_PSEUDOSTACK" OFF) -cmake_dependent_option(OPUS_USE_ALLOCA - "Use alloca for stack arrays (on non-C99 compilers)" +add_feature_info(OPUS_VAR_ARRAYS OPUS_VAR_ARRAYS ${OPUS_VAR_ARRAYS_HELP_STR}) + +set(OPUS_USE_ALLOCA_HELP_STR "use alloca for stack arrays (on non-C99 compilers).") +cmake_dependent_option(OPUS_USE_ALLOCA + ${OPUS_USE_ALLOCA_HELP_STR} ON "USE_ALLOCA_SUPPORTED; NOT OPUS_VAR_ARRAYS; NOT OPUS_NONTHREADSAFE_PSEUDOSTACK" OFF) -cmake_dependent_option(OPUS_NONTHREADSAFE_PSEUDOSTACK - "Use a non threadsafe pseudostack when neither variable length arrays or alloca is supported" +add_feature_info(OPUS_USE_ALLOCA OPUS_USE_ALLOCA ${OPUS_USE_ALLOCA_HELP_STR}) + +set(OPUS_NONTHREADSAFE_PSEUDOSTACK_HELP_STR "use a non threadsafe pseudostack when neither variable length arrays or alloca is supported.") +cmake_dependent_option(OPUS_NONTHREADSAFE_PSEUDOSTACK + ${OPUS_NONTHREADSAFE_PSEUDOSTACK_HELP_STR} ON "NOT OPUS_VAR_ARRAYS; NOT OPUS_USE_ALLOCA" OFF) +add_feature_info(OPUS_NONTHREADSAFE_PSEUDOSTACK OPUS_NONTHREADSAFE_PSEUDOSTACK ${OPUS_NONTHREADSAFE_PSEUDOSTACK_HELP_STR}) +set(OPUS_FAST_MATH_HELP_STR "enable fast math (unsupported and discouraged use, as code is not well tested with this build option).") cmake_dependent_option(OPUS_FAST_MATH - "Enable fast math" + ${OPUS_FAST_MATH_HELP_STR} ON - "OPUS_FLOAT_APPROX; OPUS_FAST_MATH" + "OPUS_FLOAT_APPROX; OPUS_FAST_MATH; FAST_MATH_SUPPORTED" OFF) +add_feature_info(OPUS_FAST_MATH OPUS_FAST_MATH ${OPUS_FAST_MATH_HELP_STR}) -if(OPUS_FAST_MATH) - if(MSVC) - check_and_set_flag(FAST_MATH /fp:fast) - else() - check_and_set_flag(FAST_MATH -ffast-math) - endif() -endif() - -if(OPUS_BUILD_SHARED_LIBRARY OR BUILD_SHARED_LIBS) - # Global flag to cause add_library() to create shared libraries if on. - set(BUILD_SHARED_LIBS ON) - set(OPUS_BUILD_SHARED_LIBRARY ON) -endif() - -if(OPUS_BUILD_TESTING OR BUILD_TESTING) - set(OPUS_BUILD_TESTING ON) - set(BUILD_TESTING ON) -endif() - -if(OPUS_STACK_PROTECTOR) - if(MSVC) # GC on by default on MSVC - check_and_set_flag(STACK_PROTECTOR /GS) - else() - check_and_set_flag(STACK_PROTECTOR -fstack-protector-strong) - endif() -else() - if(MSVC) - check_and_set_flag(STACK_PROTECTOR_DISABLED /GS-) - if (STACK_PROTECTOR_DISABLED_SUPPORTED) - set(STACK_PROTECTOR_SUPPORTED OFF) - endif() - else() - set(STACK_PROTECTOR_SUPPORTED OFF) - endif() -endif() +set(OPUS_STACK_PROTECTOR_HELP_STR "use stack protection.") +cmake_dependent_option(OPUS_STACK_PROTECTOR + ${OPUS_STACK_PROTECTOR_HELP_STR} + ON + "STACK_PROTECTOR_SUPPORTED" + OFF) +add_feature_info(OPUS_STACK_PROTECTOR OPUS_STACK_PROTECTOR ${OPUS_STACK_PROTECTOR_HELP_STR}) if(OPUS_CPU_X86 OR OPUS_CPU_X64) + set(OPUS_X86_MAY_HAVE_SSE_HELP_STR "does runtime check for SSE1 support.") cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE - "Does runtime check for SSE1 support" + ${OPUS_X86_MAY_HAVE_SSE_HELP_STR} ON - "SSE1_SUPPORTED" + "SSE1_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" OFF) + add_feature_info(OPUS_X86_MAY_HAVE_SSE OPUS_X86_MAY_HAVE_SSE ${OPUS_X86_MAY_HAVE_SSE_HELP_STR}) + + set(OPUS_X86_MAY_HAVE_SSE2_HELP_STR "does runtime check for SSE2 support.") cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE2 - "Does runtime check for SSE2 support" + ${OPUS_X86_MAY_HAVE_SSE2_HELP_STR} ON - "SSE2_SUPPORTED" + "SSE2_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" OFF) + add_feature_info(OPUS_X86_MAY_HAVE_SSE2 OPUS_X86_MAY_HAVE_SSE2 ${OPUS_X86_MAY_HAVE_SSE2_HELP_STR}) + + set(OPUS_X86_MAY_HAVE_SSE4_1_HELP_STR "does runtime check for SSE4.1 support.") cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE4_1 - "Does runtime check for SSE4.1 support" + ${OPUS_X86_MAY_HAVE_SSE4_1_HELP_STR} ON - "SSE4_1_SUPPORTED" + "SSE4_1_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" OFF) + add_feature_info(OPUS_X86_MAY_HAVE_SSE4_1 OPUS_X86_MAY_HAVE_SSE4_1 ${OPUS_X86_MAY_HAVE_SSE4_1_HELP_STR}) + + set(OPUS_X86_MAY_HAVE_AVX_HELP_STR "does runtime check for AVX support.") cmake_dependent_option(OPUS_X86_MAY_HAVE_AVX - "Does runtime check for AVX support" + ${OPUS_X86_MAY_HAVE_AVX_HELP_STR} ON - "AVX_SUPPORTED" + "AVX_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" OFF) + add_feature_info(OPUS_X86_MAY_HAVE_AVX OPUS_X86_MAY_HAVE_AVX ${OPUS_X86_MAY_HAVE_AVX_HELP_STR}) # PRESUME depends on MAY HAVE, but PRESUME will override runtime detection - if(OPUS_CPU_X64) # Assume 64 bit has SSE2 support + set(OPUS_X86_PRESUME_SSE_HELP_STR "assume target CPU has SSE1 support (override runtime check).") + set(OPUS_X86_PRESUME_SSE2_HELP_STR "assume target CPU has SSE2 support (override runtime check).") + if(OPUS_CPU_X64) # Assume x86_64 has up to SSE2 support cmake_dependent_option(OPUS_X86_PRESUME_SSE - "Assume target CPU has SSE1 support" + ${OPUS_X86_PRESUME_SSE_HELP_STR} ON - "OPUS_X86_MAY_HAVE_SSE" + "OPUS_X86_MAY_HAVE_SSE; NOT OPUS_DISABLE_INTRINSICS" OFF) + cmake_dependent_option(OPUS_X86_PRESUME_SSE2 - "Assume target CPU has SSE2 support" + ${OPUS_X86_PRESUME_SSE2_HELP_STR} ON - "OPUS_X86_MAY_HAVE_SSE2" + "OPUS_X86_MAY_HAVE_SSE2; NOT OPUS_DISABLE_INTRINSICS" OFF) else() cmake_dependent_option(OPUS_X86_PRESUME_SSE - "Assume target CPU has SSE1 support" + ${OPUS_X86_PRESUME_SSE_HELP_STR} OFF - "OPUS_X86_MAY_HAVE_SSE" + "OPUS_X86_MAY_HAVE_SSE; NOT OPUS_DISABLE_INTRINSICS" OFF) + cmake_dependent_option(OPUS_X86_PRESUME_SSE2 - "Assume target CPU has SSE2 support" + ${OPUS_X86_PRESUME_SSE2_HELP_STR} OFF - "OPUS_X86_MAY_HAVE_SSE2" + "OPUS_X86_MAY_HAVE_SSE2; NOT OPUS_DISABLE_INTRINSICS" OFF) endif() + add_feature_info(OPUS_X86_PRESUME_SSE OPUS_X86_PRESUME_SSE ${OPUS_X86_PRESUME_SSE_HELP_STR}) + add_feature_info(OPUS_X86_PRESUME_SSE2 OPUS_X86_PRESUME_SSE2 ${OPUS_X86_PRESUME_SSE2_HELP_STR}) + + set(OPUS_X86_PRESUME_SSE4_1_HELP_STR "assume target CPU has SSE4.1 support (override runtime check).") cmake_dependent_option(OPUS_X86_PRESUME_SSE4_1 - "Assume target CPU has SSE4.1 support" + ${OPUS_X86_PRESUME_SSE4_1_HELP_STR} OFF - "OPUS_X86_MAY_HAVE_SSE4_1" + "OPUS_X86_MAY_HAVE_SSE4_1; NOT OPUS_DISABLE_INTRINSICS" OFF) + add_feature_info(OPUS_X86_PRESUME_SSE4_1 OPUS_X86_PRESUME_SSE4_1 ${OPUS_X86_PRESUME_SSE4_1_HELP_STR}) + + set(OPUS_X86_PRESUME_AVX_HELP_STR "assume target CPU has AVX support (override runtime check).") cmake_dependent_option(OPUS_X86_PRESUME_AVX - "Assume target CPU has AVX support" + ${OPUS_X86_PRESUME_AVX_HELP_STR} OFF - "OPUS_X86_MAY_HAVE_AVX" + "OPUS_X86_MAY_HAVE_AVX; NOT OPUS_DISABLE_INTRINSICS" OFF) + add_feature_info(OPUS_X86_PRESUME_AVX OPUS_X86_PRESUME_AVX ${OPUS_X86_PRESUME_AVX_HELP_STR}) endif() +feature_summary(WHAT ALL) + set_package_properties(Git PROPERTIES TYPE @@ -170,65 +214,20 @@ set_package_properties(Git PURPOSE "required to set up package version") -add_feature_info(OPUS_BUILD_SHARED_LIBRARY OPUS_BUILD_SHARED_LIBRARY "Build shared library") -add_feature_info(OPUS_STACK_PROTECTOR STACK_PROTECTOR_SUPPORTED "Use stack protection") -add_feature_info(OPUS_VAR_ARRAYS OPUS_VAR_ARRAYS - "Use variable length arrays for stack arrays") -add_feature_info(OPUS_USE_ALLOCA OPUS_USE_ALLOCA - "Use alloca for stack arrays (on non-C99 compilers)") -add_feature_info(OPUS_NONTHREADSAFE_PSEUDOSTACK OPUS_NONTHREADSAFE_PSEUDOSTACK - "Use a non threadsafe pseudostack when neither variable length arrays or alloca is supported") -add_feature_info(OPUS_CUSTOM_MODES OPUS_CUSTOM_MODES - "Enable non-Opus modes, e.g. 44.1 kHz & 2^n frames") -add_feature_info(OPUS_BUILD_TESTING OPUS_BUILD_TESTING "Build test programs") -add_feature_info(OPUS_BUILD_PROGRAMS OPUS_BUILD_PROGRAMS "Build programs") -add_feature_info( - OPUS_FIXED_POINT OPUS_FIXED_POINT - "compile as fixed-point (for machines without a fast enough FPU)") -add_feature_info( - OPUS_FLOAT_API OPUS_ENABLE_FLOAT_API - "compile with the floating point API (for machines with float library)") -add_feature_info(OPUS_FLOAT_APPROX OPUS_FLOAT_APPROX - "Enable floating point approximations (Ensure your platform supports IEEE 754 before enabling)") -add_feature_info(OPUS_FAST_MATH FAST_MATH_SUPPORTED "Enable fast math, (depending on OPUS_FLOAT_APPROX to be enabled)") -add_feature_info(OPUS_INSTALL_PKG_CONFIG_MODULE OPUS_INSTALL_PKG_CONFIG_MODULE - "install PkgConfig module") -add_feature_info(OPUS_INSTALL_CMAKE_CONFIG_MODULE OPUS_INSTALL_CMAKE_CONFIG_MODULE - "install CMake package config module") - -if(OPUS_CPU_X86 OR OPUS_CPU_X64) - add_feature_info(OPUS_X86_MAY_HAVE_SSE OPUS_X86_MAY_HAVE_SSE - "does runtime check for SSE1 support") - add_feature_info(OPUS_X86_MAY_HAVE_SSE2 OPUS_X86_MAY_HAVE_SSE2 - "does runtime check for SSE2 support") - add_feature_info(OPUS_X86_MAY_HAVE_SSE4_1 OPUS_X86_MAY_HAVE_SSE4_1 - "does runtime check for SSE4_1 support") - add_feature_info(OPUS_X86_MAY_HAVE_AVX OPUS_X86_MAY_HAVE_AVX - "does runtime check for AVX support") - add_feature_info(OPUS_X86_PRESUME_SSE OPUS_X86_PRESUME_SSE - "assume target CPU has SSE1 support will override the runtime check") - add_feature_info(OPUS_X86_PRESUME_SSE2 OPUS_X86_PRESUME_SSE2 - "assume target CPU has SSE2 support will override the runtime check") - add_feature_info(OPUS_X86_PRESUME_SSE4_1 OPUS_X86_PRESUME_SSE4_1 - "assume target CPU has SSE4_1 support will override the runtime check") - add_feature_info(OPUS_X86_PRESUME_AVX OPUS_X86_PRESUME_AVX - "assume target CPU has AVX support will override the runtime check") -endif() - -feature_summary(WHAT ALL) - -add_library(opus ${opus_sources} ${opus_sources_float}) - -add_library(Opus::opus ALIAS opus) - set(Opus_PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/opus.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_custom.h ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_defines.h ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_multistream.h ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_projection.h ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_types.h) +if(OPUS_CUSTOM_MODES) + list(APPEND Opus_PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_custom.h) +endif() + +add_library(opus ${opus_headers} ${opus_sources} ${opus_sources_float} ${Opus_PUBLIC_HEADER}) +add_library(Opus::opus ALIAS opus) + set_target_properties(opus PROPERTIES SOVERSION ${OPUS_LIBRARY_VERSION_MAJOR} @@ -265,27 +264,41 @@ elseif(OPUS_USE_ALLOCA) elseif(OPUS_NONTHREADSAFE_PSEUDOSTACK) target_compile_definitions(opus PRIVATE NONTHREADSAFE_PSEUDOSTACK) else() - message(ERROR Neet to set a define for stack allocation) + message(ERROR "Need to set a define for stack allocation") endif() if(OPUS_CUSTOM_MODES) target_compile_definitions(opus PRIVATE CUSTOM_MODES) endif() +if(OPUS_FAST_MATH) + if(MSVC) + target_compile_options(opus PRIVATE /fp:fast) + else() + target_compile_options(opus PRIVATE -ffast-math) + endif() +endif() + +if(OPUS_STACK_PROTECTOR) + if(MSVC) + target_compile_options(opus PRIVATE /GS) + else() + target_compile_options(opus PRIVATE -fstack-protector-strong) + endif() +elseif(STACK_PROTECTOR_DISABLED_SUPPORTED) + target_compile_options(opus PRIVATE /GS-) +endif() + if(BUILD_SHARED_LIBS) if(WIN32) target_compile_definitions(opus PRIVATE DLL_EXPORT) - else() - include(CheckCCompilerFlag) - check_c_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) - if(COMPILER_HAS_HIDDEN_VISIBILITY) - set_target_properties(opus PROPERTIES C_VISIBILITY_PRESET hidden) - endif() + elseif(HIDDEN_VISIBILITY_SUPPORTED) + set_target_properties(opus PROPERTIES C_VISIBILITY_PRESET hidden) endif() endif() -add_sources_group(opus silk ${silk_sources}) -add_sources_group(opus celt ${celt_sources}) +add_sources_group(opus silk ${silk_headers} ${silk_sources}) +add_sources_group(opus celt ${celt_headers} ${celt_sources}) if(OPUS_FIXED_POINT) add_sources_group(opus silk ${silk_sources_fixed}) @@ -300,137 +313,131 @@ if(NOT OPUS_ENABLE_FLOAT_API) target_compile_definitions(opus PRIVATE DISABLE_FLOAT_API) endif() -#[[Build flags for SSE will be set the following way: -MSVC: If OPUS_X86_PRESUME_X is set then we will set the highest possible /arch:X -we won't set any ARCH flag for OPUS_X86_MAY_HAVE_SSE due to: -https://randomascii.wordpress.com/2016/12/05/vc-archavx-option-unsafe-at-any-speed/ -For non MSVC: we will set the compiler flags on per file basis for OPUS_X86_MAY_HAVE_SSE -for OPUS_X86_PRESUME_X we will set it for the target]] - -if((OPUS_X86_MAY_HAVE_SSE AND NOT OPUS_X86_PRESUME_SSE) OR - (OPUS_X86_MAY_HAVE_SSE2 AND NOT OPUS_X86_PRESUME_SSE2) OR - (OPUS_X86_MAY_HAVE_SSE4_1 AND NOT OPUS_X86_PRESUME_SSE4_1) OR - (OPUS_X86_MAY_HAVE_AVX AND NOT OPUS_X86_PRESUME_AVX)) - target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD) -endif() +if(NOT OPUS_DISABLE_INTRINSICS) + if((OPUS_X86_MAY_HAVE_SSE AND NOT OPUS_X86_PRESUME_SSE) OR + (OPUS_X86_MAY_HAVE_SSE2 AND NOT OPUS_X86_PRESUME_SSE2) OR + (OPUS_X86_MAY_HAVE_SSE4_1 AND NOT OPUS_X86_PRESUME_SSE4_1) OR + (OPUS_X86_MAY_HAVE_AVX AND NOT OPUS_X86_PRESUME_AVX)) + target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD) + endif() -if(SSE1_SUPPORTED) - if(OPUS_X86_MAY_HAVE_SSE) - add_sources_group(opus celt ${celt_sources_sse}) - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE) - if(NOT MSVC) - set_source_files_properties(${celt_sources_sse} PROPERTIES COMPILE_FLAGS -msse) + if(SSE1_SUPPORTED) + if(OPUS_X86_MAY_HAVE_SSE) + add_sources_group(opus celt ${celt_sources_sse}) + target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE) + if(NOT MSVC) + set_source_files_properties(${celt_sources_sse} PROPERTIES COMPILE_FLAGS -msse) + endif() endif() - endif() - if(OPUS_X86_PRESUME_SSE) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE) - if(NOT MSVC) - target_compile_options(opus PRIVATE -msse) + if(OPUS_X86_PRESUME_SSE) + target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE) + if(NOT MSVC) + target_compile_options(opus PRIVATE -msse) + endif() endif() endif() -endif() -if(SSE2_SUPPORTED) - if(OPUS_X86_MAY_HAVE_SSE2) - add_sources_group(opus celt ${celt_sources_sse2}) - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE2) - if(NOT MSVC) - set_source_files_properties(${celt_sources_sse2} PROPERTIES COMPILE_FLAGS -msse2) + if(SSE2_SUPPORTED) + if(OPUS_X86_MAY_HAVE_SSE2) + add_sources_group(opus celt ${celt_sources_sse2}) + target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE2) + if(NOT MSVC) + set_source_files_properties(${celt_sources_sse2} PROPERTIES COMPILE_FLAGS -msse2) + endif() endif() - endif() - if(OPUS_X86_PRESUME_SSE2) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE2) - if(NOT MSVC) - target_compile_options(opus PRIVATE -msse2) + if(OPUS_X86_PRESUME_SSE2) + target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE2) + if(NOT MSVC) + target_compile_options(opus PRIVATE -msse2) + endif() endif() endif() -endif() - -if(SSE4_1_SUPPORTED) - if(OPUS_X86_MAY_HAVE_SSE4_1) - add_sources_group(opus celt ${celt_sources_sse4_1}) - add_sources_group(opus silk ${silk_sources_sse4_1}) - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE4_1) - if(NOT MSVC) - set_source_files_properties(${celt_sources_sse4_1} ${silk_sources_sse4_1} PROPERTIES COMPILE_FLAGS -msse4.1) - endif() - if(OPUS_FIXED_POINT) - add_sources_group(opus silk ${silk_sources_fixed_sse4_1}) + if(SSE4_1_SUPPORTED) + if(OPUS_X86_MAY_HAVE_SSE4_1) + add_sources_group(opus celt ${celt_sources_sse4_1}) + add_sources_group(opus silk ${silk_sources_sse4_1}) + target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE4_1) if(NOT MSVC) - set_source_files_properties(${silk_sources_fixed_sse4_1} PROPERTIES COMPILE_FLAGS -msse4.1) + set_source_files_properties(${celt_sources_sse4_1} ${silk_sources_sse4_1} PROPERTIES COMPILE_FLAGS -msse4.1) + endif() + + if(OPUS_FIXED_POINT) + add_sources_group(opus silk ${silk_sources_fixed_sse4_1}) + if(NOT MSVC) + set_source_files_properties(${silk_sources_fixed_sse4_1} PROPERTIES COMPILE_FLAGS -msse4.1) + endif() endif() endif() - endif() - if(OPUS_X86_PRESUME_SSE4_1) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE4_1) - if(NOT MSVC) - target_compile_options(opus PRIVATE -msse4.1) + if(OPUS_X86_PRESUME_SSE4_1) + target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE4_1) + if(NOT MSVC) + target_compile_options(opus PRIVATE -msse4.1) + endif() endif() endif() -endif() -if(AVX_SUPPORTED) - # mostly placeholder in case of avx intrinsics is added - if(OPUS_X86_MAY_HAVE_AVX) - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_AVX) - endif() - if(OPUS_X86_PRESUME_AVX) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_AVX) - if(NOT MSVC) - target_compile_options(opus PRIVATE -mavx) + if(AVX_SUPPORTED) + # mostly placeholder in case of avx intrinsics is added + if(OPUS_X86_MAY_HAVE_AVX) + target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_AVX) + endif() + if(OPUS_X86_PRESUME_AVX) + target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_AVX) + if(NOT MSVC) + target_compile_options(opus PRIVATE -mavx) + endif() endif() endif() -endif() -if(MSVC) - if(AVX_SUPPORTED AND OPUS_X86_PRESUME_AVX) # on 64 bit and 32 bits - add_definitions(/arch:AVX) - elseif(OPUS_CPU_X86) # if AVX not supported then set SSE flag - if((SSE4_1_SUPPORTED AND OPUS_X86_PRESUME_SSE4_1) - OR (SSE2_SUPPORTED AND OPUS_X86_PRESUME_SSE2)) - target_compile_definitions(opus PRIVATE /arch:SSE2) - elseif(SSE1_SUPPORTED AND OPUS_X86_PRESUME_SSE) - target_compile_definitions(opus PRIVATE /arch:SSE) + if(MSVC) + if(AVX_SUPPORTED AND OPUS_X86_PRESUME_AVX) # on 64 bit and 32 bits + add_definitions(/arch:AVX) + elseif(OPUS_CPU_X86) # if AVX not supported then set SSE flag + if((SSE4_1_SUPPORTED AND OPUS_X86_PRESUME_SSE4_1) + OR (SSE2_SUPPORTED AND OPUS_X86_PRESUME_SSE2)) + target_compile_definitions(opus PRIVATE /arch:SSE2) + elseif(SSE1_SUPPORTED AND OPUS_X86_PRESUME_SSE) + target_compile_definitions(opus PRIVATE /arch:SSE) + endif() endif() endif() -endif() - -if(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)") - add_sources_group(opus celt ${celt_sources_arm}) -endif() -if(COMPILER_SUPPORT_NEON AND OPUS_USE_NEON) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)") + add_sources_group(opus celt ${celt_sources_arm}) + endif() - if(OPUS_MAY_HAVE_NEON) - if(RUNTIME_CPU_CAPABILITY_DETECTION) - message(STATUS "OPUS_MAY_HAVE_NEON enabling runtime detection") - target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD) - else() - message(ERROR "Runtime cpu capability detection needed for MAY_HAVE_NEON") + if(COMPILER_SUPPORT_NEON) + if(OPUS_MAY_HAVE_NEON) + if(RUNTIME_CPU_CAPABILITY_DETECTION) + message(STATUS "OPUS_MAY_HAVE_NEON enabling runtime detection") + target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD) + else() + message(ERROR "Runtime cpu capability detection needed for MAY_HAVE_NEON") + endif() + # Do runtime check for NEON + target_compile_definitions(opus + PRIVATE + OPUS_ARM_MAY_HAVE_NEON + OPUS_ARM_MAY_HAVE_NEON_INTR) endif() - # Do runtime check for NEON - target_compile_definitions(opus - PRIVATE - OPUS_ARM_MAY_HAVE_NEON - OPUS_ARM_MAY_HAVE_NEON_INTR) - endif() - add_sources_group(opus celt ${celt_sources_arm_neon_intr}) - add_sources_group(opus silk ${silk_sources_arm_neon_intr}) + add_sources_group(opus celt ${celt_sources_arm_neon_intr}) + add_sources_group(opus silk ${silk_sources_arm_neon_intr}) - # silk arm neon depends on main_Fix.h - target_include_directories(opus PRIVATE silk/fixed) + # silk arm neon depends on main_Fix.h + target_include_directories(opus PRIVATE silk/fixed) - if(OPUS_FIXED_POINT) - add_sources_group(opus silk ${silk_sources_fixed_arm_neon_intr}) - endif() + if(OPUS_FIXED_POINT) + add_sources_group(opus silk ${silk_sources_fixed_arm_neon_intr}) + endif() - if(OPUS_PRESUME_NEON) - target_compile_definitions(opus - PRIVATE - OPUS_ARM_PRESUME_NEON - OPUS_ARM_PRESUME_NEON_INTR) + if(OPUS_PRESUME_NEON) + target_compile_definitions(opus + PRIVATE + OPUS_ARM_PRESUME_NEON + OPUS_ARM_PRESUME_NEON_INTR) + endif() endif() endif() @@ -439,11 +446,23 @@ target_compile_definitions(opus $<$<BOOL:${HAVE_LRINT}>:HAVE_LRINT> $<$<BOOL:${HAVE_LRINTF}>:HAVE_LRINTF>) +if(OPUS_BUILD_FRAMEWORK) + set_target_properties(opus PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION ${PROJECT_VERSION} + MACOSX_FRAMEWORK_IDENTIFIER org.xiph.opus + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION} + MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION} + XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" + OUTPUT_NAME Opus) +endif() + install(TARGETS opus EXPORT OpusTargets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/opus) if(OPUS_INSTALL_PKG_CONFIG_MODULE) @@ -471,7 +490,7 @@ if(OPUS_INSTALL_CMAKE_CONFIG_MODULE) include(CMakePackageConfigHelpers) set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) - configure_package_config_file(OpusConfig.cmake.in + configure_package_config_file(${CMAKE_SOURCE_DIR}/cmake/OpusConfig.cmake.in OpusConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} diff --git a/Makefile.am b/Makefile.am index 470b8e70..e3847bf8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -103,7 +103,8 @@ noinst_PROGRAMS = celt/tests/test_unit_cwrs32 \ tests/test_opus_decode \ tests/test_opus_encode \ tests/test_opus_padding \ - tests/test_opus_projection + tests/test_opus_projection \ + trivial_example TESTS = celt/tests/test_unit_cwrs32 \ celt/tests/test_unit_dft \ @@ -131,6 +132,9 @@ repacketizer_demo_LDADD = libopus.la $(NE10_LIBS) $(LIBM) opus_compare_SOURCES = src/opus_compare.c opus_compare_LDADD = $(LIBM) +trivial_example_SOURCES = doc/trivial_example.c +trivial_example_LDADD = libopus.la $(LIBM) + tests_test_opus_api_SOURCES = tests/test_opus_api.c tests/test_opus_common.h tests_test_opus_api_LDADD = libopus.la $(NE10_LIBS) $(LIBM) @@ -211,13 +215,13 @@ EXTRA_DIST = opus.pc.in \ Makefile.mips \ Makefile.unix \ CMakeLists.txt \ - config.h.cmake.in \ - opus_buildtype.cmake \ - opus_config.cmake \ - opus_functions.cmake \ - opus_sources.cmake \ - OpusConfig.cmake.in \ cmake/CFeatureCheck.cmake \ + cmake/OpusBuildtype.cmake \ + cmake/OpusConfig.cmake \ + cmake/OpusConfig.cmake.in \ + cmake/OpusFunctions.cmake \ + cmake/OpusSources.cmake \ + cmake/config.h.cmake.in \ cmake/vla.c \ tests/run_vectors.sh \ celt/arm/arm2gnu.pl \ @@ -35,7 +35,7 @@ An opus-tools package is available which provides encoding and decoding of Ogg encapsulated Opus files and includes a number of useful features. Opus-tools can be found at: - https://git.xiph.org/?p=opus-tools.git + https://gitlab.xiph.org/xiph/opus-tools.git or on the main Opus website: https://opus-codec.org/ @@ -68,7 +68,7 @@ On Apple macOS, install Xcode and brew.sh, then in the Terminal enter: 1) Clone the repository: - % git clone https://git.xiph.org/opus.git + % git clone https://gitlab.xiph.org/xiph/opus.git % cd opus 2) Compiling the source diff --git a/README.draft b/README.draft index 8d8e24df..9c31bd02 100644 --- a/README.draft +++ b/README.draft @@ -7,7 +7,7 @@ If this does not work, or if you want to change the default configuration in the Makefile. An up-to-date implementation conforming to this standard is available in a -Git repository at https://git.xiph.org/opus.git or on a website at: +Git repository at https://gitlab.xiph.org/xiph/opus.git or on a website at: https://opus-codec.org/ However, although that implementation is expected to remain conformant with the standard, it is the code in this RFC that shall remain normative. @@ -17,7 +17,7 @@ steps: 1) Clone the repository (latest implementation of this standard at the time of publication) -% git clone https://git.xiph.org/opus.git +% git clone https://gitlab.xiph.org/xiph/opus.git % cd opus 2) Compile diff --git a/celt/arch.h b/celt/arch.h index 08b07db5..3845c3a0 100644 --- a/celt/arch.h +++ b/celt/arch.h @@ -73,6 +73,9 @@ __attribute__((noreturn)) void celt_fatal(const char *str, const char *file, int line) { fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str); +#if defined(_MSC_VER) + _set_abort_behavior( 0, _WRITE_ABORT_MSG); +#endif abort(); } #endif diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c index 44cb0850..d6f8afc2 100644 --- a/celt/celt_encoder.c +++ b/celt/celt_encoder.c @@ -1571,7 +1571,7 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm, (tmp+4*mode->Fs)/(8*mode->Fs)-!!st->signalling)); effectiveBytes = nbCompressedBytes - nbFilledBytes; } - equiv_rate = ((opus_int32)nbCompressedBytes*8*50 >> (3-LM)) - (40*C+20)*((400>>LM) - 50); + equiv_rate = ((opus_int32)nbCompressedBytes*8*50 << (3-LM)) - (40*C+20)*((400>>LM) - 50); if (st->bitrate != OPUS_BITRATE_MAX) equiv_rate = IMIN(equiv_rate, st->bitrate - (40*C+20)*((400>>LM) - 50)); diff --git a/celt/ecintrin.h b/celt/ecintrin.h index 2263cff6..66a4c36e 100644 --- a/celt/ecintrin.h +++ b/celt/ecintrin.h @@ -49,7 +49,11 @@ This macro should only be used for implementing ec_ilog(), if it is defined. All other code should use EC_ILOG() instead.*/ #if defined(_MSC_VER) && (_MSC_VER >= 1400) +#if defined(_MSC_VER) && (_MSC_VER >= 1910) +# include <intrin0.h> /* Improve compiler throughput. */ +#else # include <intrin.h> +#endif /*In _DEBUG mode this is not an intrinsic by default.*/ # pragma intrinsic(_BitScanReverse) diff --git a/celt/os_support.h b/celt/os_support.h index a2171971..009bf861 100644 --- a/celt/os_support.h +++ b/celt/os_support.h @@ -39,7 +39,6 @@ #include "opus_defines.h" #include <string.h> -#include <stdio.h> #include <stdlib.h> /** Opus wrapper for malloc(). To do your own dynamic allocation, all you need to do is replace this function and opus_free */ diff --git a/cmake/CFeatureCheck.cmake b/cmake/CFeatureCheck.cmake index 4059f434..08828f58 100644 --- a/cmake/CFeatureCheck.cmake +++ b/cmake/CFeatureCheck.cmake @@ -27,7 +27,7 @@ function(c_feature_check FILE) if (NOT DEFINED COMPILE_${FEATURE}) message(STATUS "Performing Test ${FEATURE}") - try_compile(COMPILE_${FEATURE} ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/${FILE}.c) + try_compile(COMPILE_${FEATURE} ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/${FILE}.c) endif() if(COMPILE_${FEATURE}) @@ -36,4 +36,4 @@ function(c_feature_check FILE) else() message(STATUS "Performing Test ${FEATURE} -- failed to compile") endif() -endfunction()
\ No newline at end of file +endfunction() diff --git a/opus_buildtype.cmake b/cmake/OpusBuildtype.cmake index aaee9eff..557cc89b 100644 --- a/opus_buildtype.cmake +++ b/cmake/OpusBuildtype.cmake @@ -1,4 +1,8 @@ # Set a default build type if none was specified +if(__opus_buildtype) + return() +endif() +set(__opus_buildtype INCLUDED) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if(CMAKE_C_FLAGS) diff --git a/opus_config.cmake b/cmake/OpusConfig.cmake index bcc78ccf..63054617 100644 --- a/opus_config.cmake +++ b/cmake/OpusConfig.cmake @@ -1,6 +1,11 @@ -include(opus_functions.cmake) +if(__opus_config) + return() +endif() +set(__opus_config INCLUDED) + +include(OpusFunctions) -configure_file(config.h.cmake.in config.h @ONLY) +configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake.in config.h @ONLY) add_definitions(-DHAVE_CONFIG_H) set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -44,11 +49,13 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)") set(OPUS_CPU_ARM 1) endif() -opus_supports_cpu_detection(RUNTIME_CPU_CAPABILITY_DETECTION) +if(NOT OPUS_DISABLE_INTRINSICS) + opus_supports_cpu_detection(RUNTIME_CPU_CAPABILITY_DETECTION) +endif() -if(OPUS_CPU_X86 OR OPUS_CPU_X64) +if(OPUS_CPU_X86 OR OPUS_CPU_X64 AND NOT OPUS_DISABLE_INTRINSICS) opus_detect_sse(COMPILER_SUPPORT_SIMD) -elseif(OPUS_CPU_ARM) +elseif(OPUS_CPU_ARM AND NOT OPUS_DISABLE_INTRINSICS) opus_detect_neon(COMPILER_SUPPORT_NEON) if(COMPILER_SUPPORT_NEON) option(OPUS_USE_NEON "Option to enable NEON" ON) @@ -61,3 +68,13 @@ elseif(OPUS_CPU_ARM) endif() endif() endif() + +if(MSVC) + check_flag(FAST_MATH /fp:fast) + check_flag(STACK_PROTECTOR /GS) + check_flag(STACK_PROTECTOR_DISABLED /GS-) +else() + check_flag(FAST_MATH -ffast-math) + check_flag(STACK_PROTECTOR -fstack-protector-strong) + check_flag(HIDDEN_VISIBILITY -fvisibility=hidden) +endif() diff --git a/OpusConfig.cmake.in b/cmake/OpusConfig.cmake.in index 0b21231d..0b21231d 100644 --- a/OpusConfig.cmake.in +++ b/cmake/OpusConfig.cmake.in diff --git a/opus_functions.cmake b/cmake/OpusFunctions.cmake index a3ac1c09..2eb83f4e 100644 --- a/opus_functions.cmake +++ b/cmake/OpusFunctions.cmake @@ -1,8 +1,7 @@ -#[[Cmake helper function to parse source files from make files -this is to avoid breaking existing make and auto make support -but still have the option to use CMake with only lists at one place]] - -cmake_minimum_required(VERSION 3.1) +if(__opus_functions) + return() +endif() +set(__opus_functions INCLUDED) function(get_library_version OPUS_LIBRARY_VERSION OPUS_LIBRARY_VERSION_MAJOR) file(STRINGS configure.ac opus_lt_current_string @@ -93,14 +92,6 @@ function(get_package_version PACKAGE_VERSION) set(PACKAGE_VERSION 0 PARENT_SCOPE) endfunction() -function(check_and_set_flag NAME FLAG) - include(CheckCCompilerFlag) - check_c_compiler_flag(${FLAG} ${NAME}_SUPPORTED) - if(${NAME}_SUPPORTED) - add_definitions(${FLAG}) - endif() -endfunction() - function(check_flag NAME FLAG) include(CheckCCompilerFlag) check_c_compiler_flag(${FLAG} ${NAME}_SUPPORTED) diff --git a/opus_sources.cmake b/cmake/OpusSources.cmake index 225543af..01e75d1a 100644 --- a/opus_sources.cmake +++ b/cmake/OpusSources.cmake @@ -1,5 +1,11 @@ -include(opus_functions.cmake) +if(__opus_sources) + return() +endif() +set(__opus_sources INCLUDED) +include(OpusFunctions) + +get_opus_sources(SILK_HEAD silk_headers.mk silk_headers) get_opus_sources(SILK_SOURCES silk_sources.mk silk_sources) get_opus_sources(SILK_SOURCES_FLOAT silk_sources.mk silk_sources_float) get_opus_sources(SILK_SOURCES_FIXED silk_sources.mk silk_sources_fixed) @@ -11,9 +17,11 @@ get_opus_sources(SILK_SOURCES_ARM_NEON_INTR silk_sources.mk get_opus_sources(SILK_SOURCES_FIXED_ARM_NEON_INTR silk_sources.mk silk_sources_fixed_arm_neon_intr) +get_opus_sources(OPUS_HEAD opus_headers.mk opus_headers) get_opus_sources(OPUS_SOURCES opus_sources.mk opus_sources) get_opus_sources(OPUS_SOURCES_FLOAT opus_sources.mk opus_sources_float) +get_opus_sources(CELT_HEAD celt_headers.mk celt_headers) get_opus_sources(CELT_SOURCES celt_sources.mk celt_sources) get_opus_sources(CELT_SOURCES_SSE celt_sources.mk celt_sources_sse) get_opus_sources(CELT_SOURCES_SSE2 celt_sources.mk celt_sources_sse2) diff --git a/config.h.cmake.in b/cmake/config.h.cmake.in index 5550842c..5550842c 100644 --- a/config.h.cmake.in +++ b/cmake/config.h.cmake.in diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index 36eee0b5..6d25f1fb 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -1,4 +1,4 @@ -# Doxyfile 1.8.10 +# Doxyfile 1.8.18 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -101,7 +101,7 @@ EXTRACT_PRIVATE = NO # names in lower-case letters. If set to YES, upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. +# (including Cygwin) ands Mac users are advised to set this option to NO. # The default value is: system dependent. CASE_SENSE_NAMES = YES @@ -248,8 +248,8 @@ HTML_TIMESTAMP = YES # MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of -# MathJax from http://www.mathjax.org before deployment. -# The default value is: http://cdn.mathjax.org/mathjax/latest. +# MathJax from https://www.mathjax.org before deployment. +# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = https://www.mathjax.org/mathjax @@ -326,10 +326,12 @@ PREDEFINED = OPUS_EXPORT= \ # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz (see: # http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent -# Bell Labs. +# Bell Labs. The other options in this section have no effect if this option is +# set to NO +# The default value is: NO. # Debian defaults to YES here, while Fedora and Homebrew default to NO. # So we set this based on whether the graphviz package is available at # configure time. # -HAVE_DOT = @HAVE_DOT@ +HAVE_DOT = @HAVE_DOT@ diff --git a/doc/build_draft.sh b/doc/build_draft.sh index 664edfdd..7f570bcc 100755 --- a/doc/build_draft.sh +++ b/doc/build_draft.sh @@ -91,7 +91,7 @@ cat opus_source.tar.gz| base64 | tr -d '\n' | fold -w 64 | \ #echo '</artwork>' >> opus_compare_escaped.c #echo '</figure>' >> opus_compare_escaped.c -if test ! -d ../opus_testvectors ; then +if [ ! -d ../opus_testvectors ] ; then echo "Downloading test vectors..." wget 'https://opus-codec.org/testvectors/opus_testvectors.tar.gz' tar -C .. -xvzf opus_testvectors.tar.gz diff --git a/doc/footer.html b/doc/footer.html index ad4a9259..346c40ab 100644 --- a/doc/footer.html +++ b/doc/footer.html @@ -1,6 +1,10 @@ +<!-- HTML footer for doxygen 1.8.18--> +<!-- start footer part --> <!--BEGIN GENERATE_TREEVIEW--> +<div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> + <ul> <li class="footer">Generated by - <a href="https://www.stack.nl/~dimitri/doxygen/"> + <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> $doxygenversion </li> </ul> </div> @@ -16,7 +20,7 @@ For more information visit the <a href="https://opus-codec.org">Opus Website</a> <td> <address class="footer"><small> Generated by - <a href="https://www.stack.nl/~dimitri/doxygen/">doxygen</a> + <a href="http://www.doxygen.org/index.html">doxygen</a> $doxygenversion </small></address> </td> diff --git a/doc/header.html b/doc/header.html index b2c906be..babdcf6d 100644 --- a/doc/header.html +++ b/doc/header.html @@ -1,18 +1,24 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<!-- HTML header for doxygen 1.8.18--> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> +<meta name="generator" content="Doxygen $doxygenversion"/> +<meta name="viewport" content="width=device-width, initial-scale=1"/> <!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME--> <!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME--> -<link href="$relpath$tabs.css" rel="stylesheet" type="text/css"/> -<link href="$relpath$customdoxygen.css" rel="stylesheet" type="text/css" /> +<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/> +<script type="text/javascript" src="$relpath^jquery.js"></script> +<script type="text/javascript" src="$relpath^dynsections.js"></script> $treeview $search $mathjax +<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" /> +$extrastylesheet </head> <body> -<div id="top"><!-- do not remove this div! --> +<div id="top"><!-- do not remove this div, it is closed by doxygen! --> <!--BEGIN TITLEAREA--> <div id="titlearea"> @@ -20,7 +26,7 @@ $mathjax <tbody> <tr style="height: 64px;"> <!--BEGIN PROJECT_LOGO--> - <td id="projectlogo"><img alt="Logo" src="$relpath$$projectlogo"/></td> + <td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo"/></td> <!--END PROJECT_LOGO--> <!--BEGIN PROJECT_NAME--> <td style="padding-left: 0.5em;"> @@ -52,3 +58,4 @@ $mathjax </table> </div> <!--END TITLEAREA--> +<!-- end header part --> diff --git a/doc/release.txt b/doc/release.txt index 6d3ffa23..411ab7f4 100644 --- a/doc/release.txt +++ b/doc/release.txt @@ -15,7 +15,7 @@ - svn commit - Copy to archive.mozilla.org/pub/opus/ - Update checksum files there as well. -- Add release notes to https://git.xiph.org/opus-website.git +- Add release notes to https://gitlab.xiph.org/xiph/opus-website.git - Update links and checksums on the downloads page. - Add a copy of the documentation to <https://www.opus-codec.org/docs/> and update the links. @@ -25,7 +25,7 @@ Releases are commited to https://svn.xiph.org/releases/opus/ which propagates to downloads.xiph.org, and copied manually to https://archive.mozilla.org/pub/opus/ -Website updates are committed to https://git.xiph.org/opus-website.git +Website updates are committed to https://gitlab.xiph.org/xiph/opus-website.git which propagates to https://opus-codec.org/ == Binary release == diff --git a/doc/trivial_example.c b/doc/trivial_example.c index 047ca0a2..9cf435b4 100644 --- a/doc/trivial_example.c +++ b/doc/trivial_example.c @@ -85,7 +85,7 @@ int main(int argc, char **argv) return EXIT_FAILURE; } inFile = argv[1]; - fin = fopen(inFile, "r"); + fin = fopen(inFile, "rb"); if (fin==NULL) { fprintf(stderr, "failed to open input file: %s\n", strerror(errno)); @@ -101,7 +101,7 @@ int main(int argc, char **argv) return EXIT_FAILURE; } outFile = argv[2]; - fout = fopen(outFile, "w"); + fout = fopen(outFile, "wb"); if (fout==NULL) { fprintf(stderr, "failed to open output file: %s\n", strerror(errno)); @@ -113,14 +113,25 @@ int main(int argc, char **argv) int i; unsigned char pcm_bytes[MAX_FRAME_SIZE*CHANNELS*2]; int frame_size; + size_t samples; /* Read a 16 bits/sample audio frame. */ - fread(pcm_bytes, sizeof(short)*CHANNELS, FRAME_SIZE, fin); - if (feof(fin)) + samples = fread(pcm_bytes, sizeof(short)*CHANNELS, FRAME_SIZE, fin); + + /* For simplicity, only read whole frames. In a real application, + * we'd pad the final partial frame with zeroes, record the exact + * duration, and trim the decoded audio to match. + */ + if (samples != FRAME_SIZE) + { break; + } + /* Convert from little-endian ordering. */ for (i=0;i<CHANNELS*FRAME_SIZE;i++) + { in[i]=pcm_bytes[2*i+1]<<8|pcm_bytes[2*i]; + } /* Encode the frame. */ nbBytes = opus_encode(encoder, in, FRAME_SIZE, cbits, MAX_PACKET_SIZE); diff --git a/include/opus_custom.h b/include/opus_custom.h index 41f36bf2..2227be01 100644 --- a/include/opus_custom.h +++ b/include/opus_custom.h @@ -178,7 +178,7 @@ OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomEncoder *opus_custom_encode ) OPUS_ARG_NONNULL(1); -/** Destroys a an encoder state. +/** Destroys an encoder state. * @param[in] st <tt>OpusCustomEncoder*</tt>: State to be freed. */ OPUS_CUSTOM_EXPORT void opus_custom_encoder_destroy(OpusCustomEncoder *st); @@ -286,7 +286,7 @@ OPUS_CUSTOM_EXPORT OPUS_WARN_UNUSED_RESULT OpusCustomDecoder *opus_custom_decode int *error ) OPUS_ARG_NONNULL(1); -/** Destroys a an decoder state. +/** Destroys a decoder state. * @param[in] st <tt>OpusCustomDecoder*</tt>: State to be freed. */ OPUS_CUSTOM_EXPORT void opus_custom_decoder_destroy(OpusCustomDecoder *st); diff --git a/silk/MacroCount.h b/silk/MacroCount.h index 78100ffe..dab2f57a 100644 --- a/silk/MacroCount.h +++ b/silk/MacroCount.h @@ -27,9 +27,9 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef SIGPROCFIX_API_MACROCOUNT_H #define SIGPROCFIX_API_MACROCOUNT_H -#include <stdio.h> #ifdef silk_MACRO_COUNT +#include <stdio.h> #define varDefine opus_int64 ops_count = 0; extern opus_int64 ops_count; diff --git a/silk/debug.c b/silk/debug.c index 9253faf7..71e69cc6 100644 --- a/silk/debug.c +++ b/silk/debug.c @@ -30,7 +30,10 @@ POSSIBILITY OF SUCH DAMAGE. #endif #include "debug.h" + +#if SILK_DEBUG || SILK_TIC_TOC #include "SigProc_FIX.h" +#endif #if SILK_TIC_TOC diff --git a/silk/debug.h b/silk/debug.h index 6f68c1ca..36163e47 100644 --- a/silk/debug.h +++ b/silk/debug.h @@ -28,28 +28,29 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef SILK_DEBUG_H #define SILK_DEBUG_H -#include "typedef.h" -#include <stdio.h> /* file writing */ -#include <string.h> /* strcpy, strcmp */ - -#ifdef __cplusplus -extern "C" -{ -#endif - -unsigned long GetHighResolutionTime(void); /* O time in usec*/ - /* Set to 1 to enable DEBUG_STORE_DATA() macros for dumping * intermediate signals from the codec. */ #define SILK_DEBUG 0 /* Flag for using timers */ -#define SILK_TIC_TOC 0 +#define SILK_TIC_TOC 0 +#if SILK_DEBUG || SILK_TIC_TOC +#include "typedef.h" +#include <string.h> /* strcpy, strcmp */ +#include <stdio.h> /* file writing */ +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif #if SILK_TIC_TOC +unsigned long GetHighResolutionTime(void); /* O time in usec*/ + #if (defined(_WIN32) || defined(_WINCE)) #include <windows.h> /* timer */ #else /* Linux or Mac*/ diff --git a/silk/typedef.h b/silk/typedef.h index 97b7e709..793d2c0c 100644 --- a/silk/typedef.h +++ b/silk/typedef.h @@ -67,6 +67,9 @@ __attribute__((noreturn)) static OPUS_INLINE void _silk_fatal(const char *str, const char *file, int line) { fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str); +#if defined(_MSC_VER) + _set_abort_behavior( 0, _WRITE_ABORT_MSG); +#endif abort(); } # define silk_assert(COND) {if (!(COND)) {silk_fatal("assertion failed: " #COND);}} diff --git a/src/analysis.c b/src/analysis.c index cb46dec5..058328f0 100644 --- a/src/analysis.c +++ b/src/analysis.c @@ -31,7 +31,9 @@ #define ANALYSIS_C +#ifdef MLP_TRAINING #include <stdio.h> +#endif #include "mathops.h" #include "kiss_fft.h" diff --git a/tests/test_opus_common.h b/tests/test_opus_common.h index 235cf1c1..d96c7d84 100644 --- a/tests/test_opus_common.h +++ b/tests/test_opus_common.h @@ -75,6 +75,9 @@ static OPUS_INLINE void _test_failed(const char *file, int line) fprintf(stderr,"Please report this failure and include\n"); fprintf(stderr,"'make check SEED=%u fails %s at line %d for %s'\n",iseed,file,line,opus_get_version_string()); fprintf(stderr,"and any relevant details about your system.\n\n"); +#if defined(_MSC_VER) + _set_abort_behavior( 0, _WRITE_ABORT_MSG); +#endif abort(); } #define test_failed() _test_failed(__FILE__, __LINE__); |