chore: update

This commit is contained in:
skdhg committed 2023-08-09 23:22:32 +05:45
1 parent 345a8c44ca
commit 71b3dc90ee
136 files changed
+3928 -2157

No files matched your search

+5 -4
View File
@@ -8,13 +8,14 @@ crate-type = ["cdylib"]
[dependencies]
dasp = { version = "0.11.0" }
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
napi = { version = "2.12.2", default-features = false, features = ["napi4"] }
napi-derive = "2.12.2"
napi = { git = "https://github.com/napi-rs/napi-rs", default-features = false, features = [
"napi4",
] }
napi-derive = { git = "https://github.com/napi-rs/napi-rs" }
symphonia = { version = "0.5.3", features = ["all"] }
[build-dependencies]
napi-build = "2.0.1"
napi-build = { git = "https://github.com/napi-rs/napi-rs" }
cmake = "0.1"
bindgen = "0.59.1"
pkg-config = "0.3.17"
+1
View File
@@ -38,6 +38,7 @@ opus_demo
repacketizer_demo
stamp-h1
test-driver
trivial_example
*.sw*
*.o
*.lo
+114
View File
@@ -0,0 +1,114 @@
include:
- template: 'Workflows/Branch-Pipelines.gitlab-ci.yml'
# https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
when: never
- if: $CI_COMMIT_BRANCH
- if: $CI_COMMIT_TAG
default:
tags:
- docker
image: 'debian:bookworm-slim'
# https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html#reference-tags
.snippets:
git_prep:
# Make sure we have a recent annotated tag, otherwise meson/get-version.py
# might fail later (e.g. shallow clone without enough history) or return
# a bogus version based on a much older tag. This can happen in merge request
# pipelines from a personal fork, as the fork might not have the latest
# upstream tags if it has been forked a long time ago. Also affects the
# git version picked up by autotools and cmake, not just meson.
- git fetch https://gitlab.xiph.org/xiph/opus.git refs/tags/v1.4:refs/tags/v1.4
- git describe
whitespace:
stage: test
before_script:
- apt-get update &&
apt-get install -y git
script:
- git diff-tree --check origin/master HEAD
# Make sure commits are GPG signed
ci-fairy:
stage: test
script:
- apt update
- apt install -y python3-pip git
- pip3 install --break-system-packages git+https://gitlab.freedesktop.org/freedesktop/ci-templates@7811ba9814a3bad379377241c6c6b62d78b20eac
- echo Checking commits $CI_FAIRY_BASE_COMMIT..HEAD
- ci-fairy check-commits --gpg-signed-commit $CI_FAIRY_BASE_COMMIT..HEAD
tags:
- 'docker'
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
variables:
CI_FAIRY_BASE_COMMIT: $CI_MERGE_REQUEST_DIFF_BASE_SHA
- if: $CI_PIPELINE_SOURCE != "merge_request_event"
variables:
CI_FAIRY_BASE_COMMIT: 'HEAD^1'
autoconf:
stage: build
before_script:
- apt-get update &&
apt-get install -y zip doxygen git automake libtool make
- !reference [.snippets, git_prep]
script:
- ./autogen.sh
- ./configure
- make -j4
- make distcheck
cache:
paths:
- "src/*.o"
- "src/.libs/*.o"
- "silk/*.o"
- "silk/.libs/*.o"
- "celt/*.o"
- "celt/.libs/*.o"
cmake:
stage: build
before_script:
- apt-get update &&
apt-get install -y cmake ninja-build git
- !reference [.snippets, git_prep]
script:
- mkdir build
- cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DOPUS_BUILD_TESTING=ON -DOPUS_BUILD_PROGRAMS=ON
- cmake --build build
- cd build && ctest --output-on-failure
.meson:
image: 'debian:bookworm-slim'
stage: build
before_script:
- apt-get update &&
apt-get install -y ninja-build doxygen meson git
- !reference [.snippets, git_prep]
script:
- mkdir builddir
- meson setup -Dtests=enabled -Ddocs=enabled -Dbuildtype=release builddir ${MESON_EXTRA_ARGS}
- meson compile -C builddir
- meson test -C builddir
#- meson dist --no-tests -C builddir
meson x86_64:
extends: '.meson'
variables:
MESON_EXTRA_ARGS: '--werror'
meson arm64:
extends: '.meson'
tags:
- 'gstreamer-arm64-linux-docker'
variables:
# arm64 build has a compiler warning still, so let's not use --werror for now
MESON_EXTRA_ARGS: '-Dwerror=false'
+455 -220
View File
@@ -1,110 +1,236 @@
cmake_minimum_required(VERSION 3.1)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(opus_functions.cmake)
get_library_version(OPUS_LIBRARY_VERSION OPUS_LIBRARY_VERSION_MAJOR)
message(STATUS "Opus library version: ${OPUS_LIBRARY_VERSION}")
get_package_version(PACKAGE_VERSION)
message(STATUS "Opus package version: ${PACKAGE_VERSION}")
string(REGEX
REPLACE "^([0-9]+.[0-9]+\\.?([0-9]+)?).*"
"\\1"
PROJECT_VERSION
${PACKAGE_VERSION})
message(STATUS "Opus project version: ${PROJECT_VERSION}")
include(OpusPackageVersion)
get_package_version(PACKAGE_VERSION PROJECT_VERSION)
project(Opus LANGUAGES C VERSION ${PROJECT_VERSION})
include(opus_buildtype.cmake)
option(OPUS_STACK_PROTECTOR "Use stack protection" ON)
option(OPUS_USE_ALLOCA "Use alloca for stack arrays (on non-C99 compilers)" OFF)
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_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_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(OpusFunctions)
include(OpusBuildtype)
include(OpusConfig)
include(OpusSources)
include(GNUInstallDirs)
include(CMakeDependentOption)
include(FeatureSummary)
if(OPUS_STACK_PROTECTOR)
if(NOT MSVC) # GC on by default on MSVC
check_and_set_flag(STACK_PROTECTION_STRONG -fstack-protector-strong)
endif()
else()
if(MSVC)
check_and_set_flag(BUFFER_SECURITY_CHECK /GS-)
endif()
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_ENABLE_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_ASSERTIONS_HELP_STR "additional software error checking.")
option(OPUS_ASSERTIONS ${OPUS_ASSERTIONS_HELP_STR} OFF)
add_feature_info(OPUS_ASSERTIONS OPUS_ASSERTIONS ${OPUS_ASSERTIONS_HELP_STR})
set(OPUS_HARDENING_HELP_STR "run-time checks that are cheap and safe for use in production.")
option(OPUS_HARDENING ${OPUS_HARDENING_HELP_STR} ON)
add_feature_info(OPUS_HARDENING OPUS_HARDENING ${OPUS_HARDENING_HELP_STR})
set(OPUS_FUZZING_HELP_STR "causes the encoder to make random decisions (do not use in production).")
option(OPUS_FUZZING ${OPUS_FUZZING_HELP_STR} OFF)
add_feature_info(OPUS_FUZZING OPUS_FUZZING ${OPUS_FUZZING_HELP_STR})
set(OPUS_CHECK_ASM_HELP_STR "enable bit-exactness checks between optimized and c implementations.")
option(OPUS_CHECK_ASM ${OPUS_CHECK_ASM_HELP_STR} OFF)
add_feature_info(OPUS_CHECK_ASM OPUS_CHECK_ASM ${OPUS_CHECK_ASM_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_FIXED_POINT_DEBUG_HELP_STR "debug fixed-point implementation.")
cmake_dependent_option(OPUS_FIXED_POINT_DEBUG
${OPUS_FIXED_POINT_DEBUG_HELP_STR}
ON
"OPUS_FIXED_POINT; OPUS_FIXED_POINT_DEBUG"
OFF)
add_feature_info(OPUS_FIXED_POINT_DEBUG OPUS_FIXED_POINT_DEBUG ${OPUS_FIXED_POINT_DEBUG_HELP_STR})
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)
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)
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
${OPUS_FAST_MATH_HELP_STR}
ON
"OPUS_FLOAT_APPROX; OPUS_FAST_MATH; FAST_MATH_SUPPORTED"
OFF)
add_feature_info(OPUS_FAST_MATH OPUS_FAST_MATH ${OPUS_FAST_MATH_HELP_STR})
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(NOT MSVC)
set(OPUS_FORTIFY_SOURCE_HELP_STR "add protection against buffer overflows.")
cmake_dependent_option(OPUS_FORTIFY_SOURCE
${OPUS_FORTIFY_SOURCE_HELP_STR}
ON
"FORTIFY_SOURCE_SUPPORTED"
OFF)
add_feature_info(OPUS_FORTIFY_SOURCE OPUS_FORTIFY_SOURCE ${OPUS_FORTIFY_SOURCE_HELP_STR})
endif()
if(MINGW AND (OPUS_FORTIFY_SOURCE OR OPUS_STACK_PROTECTOR))
# ssp lib is needed for security features for MINGW
list(APPEND OPUS_REQUIRED_LIBRARIES ssp)
endif()
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"
OFF)
cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE2
"Does runtime check for SSE2 support"
ON
"SSE2_SUPPORTED"
OFF)
cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE4_1
"Does runtime check for SSE4.1 support"
ON
"SSE4_1_SUPPORTED"
OFF)
cmake_dependent_option(OPUS_X86_MAY_HAVE_AVX
"Does runtime check for AVX support"
ON
"AVX_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})
if(OPUS_CPU_X64) # Assume 64 bit has SSE2 support
set(OPUS_X86_MAY_HAVE_SSE2_HELP_STR "does runtime check for SSE2 support.")
cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE2
${OPUS_X86_MAY_HAVE_SSE2_HELP_STR}
ON
"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
${OPUS_X86_MAY_HAVE_SSE4_1_HELP_STR}
ON
"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
${OPUS_X86_MAY_HAVE_AVX_HELP_STR}
ON
"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
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
@@ -116,55 +242,23 @@ set_package_properties(Git
PURPOSE
"required to set up package version")
add_feature_info(STACK_PROTECTOR OPUS_STACK_PROTECTOR "Use stack protection")
add_feature_info(USE_ALLOCA OPUS_USE_ALLOCA
"Use alloca for stack arrays (on non-C99 compilers)")
add_feature_info(CUSTOM_MODES OPUS_CUSTOM_MODES
"Enable non-Opus modes, e.g. 44.1 kHz & 2^n frames")
add_feature_info(BUILD_PROGRAMS OPUS_BUILD_PROGRAMS "Build programs")
add_feature_info(
FIXED_POINT OPUS_FIXED_POINT
"compile as fixed-point (for machines without a fast enough FPU)")
add_feature_info(
FLOAT_API OPUS_ENABLE_FLOAT_API
"compile with the floating point API (for machines with float library)")
add_feature_info(INSTALL_PKG_CONFIG_MODULE OPUS_INSTALL_PKG_CONFIG_MODULE
"install PkgConfig module")
add_feature_info(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(X86_MAY_HAVE_SSE OPUS_X86_MAY_HAVE_SSE
"does runtime check for SSE1 support")
add_feature_info(X86_MAY_HAVE_SSE2 OPUS_X86_MAY_HAVE_SSE2
"does runtime check for SSE2 support")
add_feature_info(X86_MAY_HAVE_SSE4_1 OPUS_X86_MAY_HAVE_SSE4_1
"does runtime check for SSE4_1 support")
add_feature_info(X86_MAY_HAVE_AVX OPUS_X86_MAY_HAVE_AVX
"does runtime check for AVX support")
add_feature_info(X86_PRESUME_SSE OPUS_X86_PRESUME_SSE
"assume target CPU has SSE1 support")
add_feature_info(X86_PRESUME_SSE2 OPUS_X86_PRESUME_SSE2
"assume target CPU has SSE2 support")
add_feature_info(X86_PRESUME_SSE4_1 OPUS_X86_PRESUME_SSE4_1
"assume target CPU has SSE4_1 support")
add_feature_info(X86_PRESUME_AVX OPUS_X86_PRESUME_AVX
"assume target CPU has AVX support")
endif()
feature_summary(WHAT ALL)
add_library(opus ${opus_sources} ${opus_sources_float})
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)
get_library_version(OPUS_LIBRARY_VERSION OPUS_LIBRARY_VERSION_MAJOR)
message(DEBUG "Opus library version: ${OPUS_LIBRARY_VERSION}")
set_target_properties(opus
PROPERTIES SOVERSION
${OPUS_LIBRARY_VERSION_MAJOR}
@@ -177,46 +271,86 @@ target_include_directories(
opus
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/opus>
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
celt
silk)
target_link_libraries(opus PRIVATE ${OPUS_REQUIRED_LIBRARIES})
target_compile_definitions(opus PRIVATE OPUS_BUILD ENABLE_HARDENING)
target_compile_definitions(opus PRIVATE OPUS_BUILD)
if(NOT MSVC)
target_compile_definitions(opus PRIVATE FORTIFY_SOURCE=2)
if(OPUS_FIXED_POINT_DEBUG)
target_compile_definitions(opus PRIVATE FIXED_DEBUG)
endif()
# It is strongly recommended to uncomment one of these VAR_ARRAYS: Use C99
# variable-length arrays for stack allocation USE_ALLOCA: Use alloca() for stack
# allocation If none is defined, then the fallback is a non-threadsafe global
# array
if(OPUS_USE_ALLOCA OR MSVC)
target_compile_definitions(opus PRIVATE USE_ALLOCA)
else()
if(OPUS_FORTIFY_SOURCE AND NOT MSVC)
target_compile_definitions(opus PRIVATE
$<$<NOT:$<CONFIG:debug>>:_FORTIFY_SOURCE=2>)
endif()
if(OPUS_FLOAT_APPROX)
target_compile_definitions(opus PRIVATE FLOAT_APPROX)
endif()
if(OPUS_ASSERTIONS)
target_compile_definitions(opus PRIVATE ENABLE_ASSERTIONS)
endif()
if(OPUS_HARDENING)
target_compile_definitions(opus PRIVATE ENABLE_HARDENING)
endif()
if(OPUS_FUZZING)
target_compile_definitions(opus PRIVATE FUZZING)
endif()
if(OPUS_CHECK_ASM)
target_compile_definitions(opus PRIVATE OPUS_CHECK_ASM)
endif()
if(OPUS_VAR_ARRAYS)
target_compile_definitions(opus PRIVATE VAR_ARRAYS)
elseif(OPUS_USE_ALLOCA)
target_compile_definitions(opus PRIVATE USE_ALLOCA)
elseif(OPUS_NONTHREADSAFE_PSEUDOSTACK)
target_compile_definitions(opus PRIVATE NONTHREADSAFE_PSEUDOSTACK)
else()
message(ERROR "Need to set a define for stack allocation")
endif()
if(OPUS_CUSTOM_MODES)
target_compile_definitions(opus PRIVATE CUSTOM_MODES)
endif()
if(BUILD_SHARED_LIBS)
if(WIN32)
target_compile_definitions(opus PRIVATE DLL_EXPORT)
if(OPUS_FAST_MATH)
if(MSVC)
target_compile_options(opus PRIVATE /fp:fast)
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()
target_compile_options(opus PRIVATE -ffast-math)
endif()
endif()
add_sources_group(opus silk ${silk_sources})
add_sources_group(opus celt ${celt_sources})
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)
elseif(HIDDEN_VISIBILITY_SUPPORTED)
set_target_properties(opus PROPERTIES C_VISIBILITY_PRESET hidden)
endif()
endif()
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})
@@ -231,77 +365,158 @@ if(NOT OPUS_ENABLE_FLOAT_API)
target_compile_definitions(opus PRIVATE DISABLE_FLOAT_API)
endif()
if(OPUS_X86_MAY_HAVE_SSE
OR OPUS_X86_MAY_HAVE_SSE2
OR OPUS_X86_MAY_HAVE_SSE4_1
OR OPUS_X86_MAY_HAVE_AVX)
target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD)
endif()
if(OPUS_X86_MAY_HAVE_SSE)
add_sources_group(opus celt ${celt_sources_sse})
target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE)
endif()
if(OPUS_X86_PRESUME_SSE)
target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE)
endif()
if(OPUS_X86_MAY_HAVE_SSE2)
add_sources_group(opus celt ${celt_sources_sse2})
target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE2)
endif()
if(OPUS_X86_PRESUME_SSE2)
target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE2)
endif()
if(OPUS_X86_MAY_HAVE_SSE)
add_sources_group(opus celt ${celt_sources_sse4_1})
add_sources_group(opus silk ${silk_sources_sse4_1})
if(OPUS_FIXED_POINT)
add_sources_group(opus silk ${silk_sources_fixed_sse4_1})
endif()
target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE4_1)
endif()
if(OPUS_X86_PRESUME_SSE4_1)
target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE4_1)
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(armv7-a)")
add_sources_group(opus celt ${celt_sources_arm})
endif()
if(COMPILER_SUPPORT_NEON AND OPUS_USE_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")
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)) AND
RUNTIME_CPU_CAPABILITY_DETECTION)
target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD)
if(NOT MSVC)
if(CPU_INFO_BY_ASM_SUPPORTED)
target_compile_definitions(opus PRIVATE CPU_INFO_BY_ASM)
elseif(CPU_INFO_BY_C_SUPPORTED)
target_compile_definitions(opus PRIVATE CPU_INFO_BY_C)
else()
message(ERROR "Runtime cpu capability detection is enabled while CPU_INFO is not supported")
endif()
endif()
# Do runtime check for NEON
target_compile_definitions(opus
PRIVATE
OPUS_ARM_MAY_HAVE_NEON
OPUS_ARM_MAY_HAVE_NEON_INTR)
add_sources_group(opus celt ${celt_sources_x86_rtcd})
add_sources_group(opus silk ${silk_sources_x86_rtcd})
endif()
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)
if(OPUS_FIXED_POINT)
add_sources_group(opus silk ${silk_sources_fixed_arm_neon_intr})
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()
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()
if(OPUS_PRESUME_NEON)
target_compile_definitions(opus
PRIVATE
OPUS_ARM_PRESUME_NEON
OPUS_ARM_PRESUME_NEON_INTR)
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()
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()
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(NOT MSVC)
set_source_files_properties(${silk_sources_fixed_sse4_1} PROPERTIES COMPILE_FLAGS -msse4.1)
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)
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)
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)
endif()
endif()
endif()
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)
add_sources_group(opus celt ${celt_sources_arm_rtcd})
add_sources_group(opus silk ${silk_sources_arm_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()
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)
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)
endif()
endif()
endif()
target_compile_definitions(opus
PRIVATE
$<$<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
@@ -309,6 +524,7 @@ install(TARGETS opus
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)
@@ -316,8 +532,7 @@ if(OPUS_INSTALL_PKG_CONFIG_MODULE)
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
set(VERSION ${OPUS_LIBRARY_VERSION})
set(VERSION ${OPUS_LIBRARY_VERSION})
set(VERSION ${PACKAGE_VERSION})
if(HAVE_LIBM)
set(LIBM "-lm")
endif()
@@ -327,6 +542,8 @@ if(OPUS_INSTALL_PKG_CONFIG_MODULE)
endif()
if(OPUS_INSTALL_CMAKE_CONFIG_MODULE)
set(CPACK_GENERATOR TGZ)
include(CPack)
set(CMAKE_INSTALL_PACKAGEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
install(EXPORT OpusTargets
NAMESPACE Opus::
@@ -335,7 +552,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(${PROJECT_SOURCE_DIR}/cmake/OpusConfig.cmake.in
OpusConfig.cmake
INSTALL_DESTINATION
${CMAKE_INSTALL_PACKAGEDIR}
@@ -358,21 +575,27 @@ if(OPUS_BUILD_PROGRAMS)
target_include_directories(opus_custom_demo
PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(opus_custom_demo PRIVATE opus)
target_compile_definitions(opus_custom_demo PRIVATE OPUS_BUILD)
endif()
add_executable(opus_demo ${opus_demo_sources})
target_include_directories(opus_demo PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(opus_demo PRIVATE silk) # debug.h
target_include_directories(opus_demo PRIVATE celt) # arch.h
target_link_libraries(opus_demo PRIVATE opus)
target_link_libraries(opus_demo PRIVATE opus ${OPUS_REQUIRED_LIBRARIES})
target_compile_definitions(opus_demo PRIVATE OPUS_BUILD)
# compare
add_executable(opus_compare ${opus_compare_sources})
target_include_directories(opus_compare PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(opus_compare PRIVATE opus)
target_link_libraries(opus_compare PRIVATE opus ${OPUS_REQUIRED_LIBRARIES})
if(MSVC)
# move cosmetic warning to level 4 for opus_compare
target_compile_options(opus_compare PRIVATE /w44244)
endif()
endif()
if(BUILD_TESTING)
if(BUILD_TESTING AND NOT BUILD_SHARED_LIBS)
enable_testing()
# tests
@@ -380,32 +603,44 @@ if(BUILD_TESTING)
target_include_directories(test_opus_decode
PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(test_opus_decode PRIVATE opus)
target_compile_definitions(test_opus_decode PRIVATE OPUS_BUILD)
if(OPUS_FIXED_POINT)
target_compile_definitions(test_opus_decode PRIVATE DISABLE_FLOAT_API)
endif()
add_test(test_opus_decode test_opus_decode)
add_test(NAME test_opus_decode COMMAND ${CMAKE_COMMAND}
-DTEST_EXECUTABLE=$<TARGET_FILE:test_opus_decode>
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
-P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake")
add_executable(test_opus_padding ${test_opus_padding_sources})
target_include_directories(test_opus_padding
PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(test_opus_padding PRIVATE opus)
add_test(test_opus_padding test_opus_padding)
add_test(NAME test_opus_padding COMMAND ${CMAKE_COMMAND}
-DTEST_EXECUTABLE=$<TARGET_FILE:test_opus_padding>
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
-P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake")
if(NOT BUILD_SHARED_LIBS)
# disable tests that depends on private API when building shared lib
add_executable(test_opus_api ${test_opus_api_sources})
target_include_directories(test_opus_api
PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt)
target_link_libraries(test_opus_api PRIVATE opus)
if(OPUS_FIXED_POINT)
target_compile_definitions(test_opus_api PRIVATE DISABLE_FLOAT_API)
endif()
add_test(test_opus_api test_opus_api)
add_executable(test_opus_encode ${test_opus_encode_sources})
target_include_directories(test_opus_encode
PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt)
target_link_libraries(test_opus_encode PRIVATE opus)
add_test(test_opus_encode test_opus_encode)
add_executable(test_opus_api ${test_opus_api_sources})
target_include_directories(test_opus_api
PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt)
target_link_libraries(test_opus_api PRIVATE opus)
target_compile_definitions(test_opus_api PRIVATE OPUS_BUILD)
if(OPUS_FIXED_POINT)
target_compile_definitions(test_opus_api PRIVATE DISABLE_FLOAT_API)
endif()
add_test(NAME test_opus_api COMMAND ${CMAKE_COMMAND}
-DTEST_EXECUTABLE=$<TARGET_FILE:test_opus_api>
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
-P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake")
add_executable(test_opus_encode ${test_opus_encode_sources})
target_include_directories(test_opus_encode
PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt)
target_link_libraries(test_opus_encode PRIVATE opus)
target_compile_definitions(test_opus_encode PRIVATE OPUS_BUILD)
add_test(NAME test_opus_encode COMMAND ${CMAKE_COMMAND}
-DTEST_EXECUTABLE=$<TARGET_FILE:test_opus_encode>
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
-P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake")
endif()
+39 -8
View File
@@ -36,6 +36,11 @@ else
OPUS_SOURCES += $(OPUS_SOURCES_FLOAT)
endif
if CPU_X86
if HAVE_RTCD
CELT_SOURCES += $(CELT_SOURCES_X86_RTCD)
SILK_SOURCES += $(SILK_SOURCES_X86_RTCD)
endif
if HAVE_SSE
CELT_SOURCES += $(CELT_SOURCES_SSE)
endif
@@ -45,10 +50,13 @@ endif
if HAVE_SSE4_1
CELT_SOURCES += $(CELT_SOURCES_SSE4_1)
endif
endif
if CPU_ARM
CELT_SOURCES += $(CELT_SOURCES_ARM)
SILK_SOURCES += $(SILK_SOURCES_ARM)
if HAVE_RTCD
CELT_SOURCES += $(CELT_SOURCES_ARM_RTCD)
SILK_SOURCES += $(SILK_SOURCES_ARM_RTCD)
endif
if HAVE_ARM_NEON_INTR
CELT_SOURCES += $(CELT_SOURCES_ARM_NEON_INTR)
@@ -103,7 +111,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 +140,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,11 +223,30 @@ EXTRA_DIST = opus.pc.in \
Makefile.mips \
Makefile.unix \
CMakeLists.txt \
config.h.cmake.in \
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/OpusPackageVersion.cmake \
cmake/OpusSources.cmake \
cmake/RunTest.cmake \
cmake/config.h.cmake.in \
cmake/vla.c \
cmake/cpu_info_by_asm.c \
cmake/cpu_info_by_c.c \
meson/get-version.py \
meson/read-sources-list.py \
meson.build \
meson_options.txt \
include/meson.build \
celt/meson.build \
celt/tests/meson.build \
silk/meson.build \
silk/tests/meson.build \
src/meson.build \
tests/meson.build \
doc/meson.build \
tests/run_vectors.sh \
celt/arm/arm2gnu.pl \
celt/arm/celt_pitch_xcorr_arm.s \
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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
+3
View File
@@ -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
+10 -1
View File
@@ -93,6 +93,8 @@ static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){
#elif defined(__linux__)
/* Linux based */
#include <stdio.h>
opus_uint32 opus_cpu_capabilities(void)
{
opus_uint32 flags = 0;
@@ -154,7 +156,7 @@ opus_uint32 opus_cpu_capabilities(void)
"your platform. Reconfigure with --disable-rtcd (or send patches)."
#endif
int opus_select_arch(void)
static int opus_select_arch_impl(void)
{
opus_uint32 flags = opus_cpu_capabilities();
int arch = 0;
@@ -182,4 +184,11 @@ int opus_select_arch(void)
return arch;
}
int opus_select_arch(void) {
int arch = opus_select_arch_impl();
#ifdef FUZZING
arch = rand()%(arch+1);
#endif
return arch;
}
#endif
+21 -30
View File
@@ -137,22 +137,27 @@ void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, const opus
/* celt_inner_prod_neon_float_c_simulation() simulates the floating-point */
/* operations of celt_inner_prod_neon(), and both functions should have bit */
/* exact output. */
static opus_val32 celt_inner_prod_neon_float_c_simulation(const opus_val16 *x, const opus_val16 *y, int N)
static opus_val32 celt_inner_prod_neon_float_c_simulation(const opus_val16 *x, const opus_val16 *y, float *err, int N)
{
int i;
*err = 0;
opus_val32 xy, xy0 = 0, xy1 = 0, xy2 = 0, xy3 = 0;
for (i = 0; i < N - 3; i += 4) {
xy0 = MAC16_16(xy0, x[i + 0], y[i + 0]);
xy1 = MAC16_16(xy1, x[i + 1], y[i + 1]);
xy2 = MAC16_16(xy2, x[i + 2], y[i + 2]);
xy3 = MAC16_16(xy3, x[i + 3], y[i + 3]);
*err += ABS32(xy0)+ABS32(xy1)+ABS32(xy2)+ABS32(xy3);
}
xy0 += xy2;
xy1 += xy3;
xy = xy0 + xy1;
*err += ABS32(xy1)+ABS32(xy0)+ABS32(xy);
for (; i < N; i++) {
xy = MAC16_16(xy, x[i], y[i]);
*err += ABS32(xy);
}
*err = *err*2e-7 + N*1e-37;
return xy;
}
@@ -160,32 +165,10 @@ static opus_val32 celt_inner_prod_neon_float_c_simulation(const opus_val16 *x, c
/* operations of dual_inner_prod_neon(), and both functions should have bit */
/* exact output. */
static void dual_inner_prod_neon_float_c_simulation(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02,
int N, opus_val32 *xy1, opus_val32 *xy2)
int N, opus_val32 *xy1, opus_val32 *xy2, float *err)
{
int i;
opus_val32 xy01, xy02, xy01_0 = 0, xy01_1 = 0, xy01_2 = 0, xy01_3 = 0, xy02_0 = 0, xy02_1 = 0, xy02_2 = 0, xy02_3 = 0;
for (i = 0; i < N - 3; i += 4) {
xy01_0 = MAC16_16(xy01_0, x[i + 0], y01[i + 0]);
xy01_1 = MAC16_16(xy01_1, x[i + 1], y01[i + 1]);
xy01_2 = MAC16_16(xy01_2, x[i + 2], y01[i + 2]);
xy01_3 = MAC16_16(xy01_3, x[i + 3], y01[i + 3]);
xy02_0 = MAC16_16(xy02_0, x[i + 0], y02[i + 0]);
xy02_1 = MAC16_16(xy02_1, x[i + 1], y02[i + 1]);
xy02_2 = MAC16_16(xy02_2, x[i + 2], y02[i + 2]);
xy02_3 = MAC16_16(xy02_3, x[i + 3], y02[i + 3]);
}
xy01_0 += xy01_2;
xy02_0 += xy02_2;
xy01_1 += xy01_3;
xy02_1 += xy02_3;
xy01 = xy01_0 + xy01_1;
xy02 = xy02_0 + xy02_1;
for (; i < N; i++) {
xy01 = MAC16_16(xy01, x[i], y01[i]);
xy02 = MAC16_16(xy02, x[i], y02[i]);
}
*xy1 = xy01;
*xy2 = xy02;
*xy1 = celt_inner_prod_neon_float_c_simulation(x, y01, &err[0], N);
*xy2 = celt_inner_prod_neon_float_c_simulation(x, y02, &err[1], N);
}
#endif /* OPUS_CHECK_ASM */
@@ -225,7 +208,12 @@ opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N)
}
#ifdef OPUS_CHECK_ASM
celt_assert(ABS32(celt_inner_prod_neon_float_c_simulation(x, y, N) - xy) <= VERY_SMALL);
{
float err, res;
res = celt_inner_prod_neon_float_c_simulation(x, y, &err, N);
/*if (ABS32(res - xy) > err) fprintf(stderr, "%g %g %g\n", res, xy, err);*/
celt_assert(ABS32(res - xy) <= err);
}
#endif
return xy;
@@ -280,9 +268,12 @@ void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, const opus
#ifdef OPUS_CHECK_ASM
{
opus_val32 xy1_c, xy2_c;
dual_inner_prod_neon_float_c_simulation(x, y01, y02, N, &xy1_c, &xy2_c);
celt_assert(ABS32(xy1_c - *xy1) <= VERY_SMALL);
celt_assert(ABS32(xy2_c - *xy2) <= VERY_SMALL);
float err[2];
dual_inner_prod_neon_float_c_simulation(x, y01, y02, N, &xy1_c, &xy2_c, err);
/*if (ABS32(xy1_c - *xy1) > err[0]) fprintf(stderr, "dual1 fail: %g %g %g\n", xy1_c, *xy1, err[0]);
if (ABS32(xy2_c - *xy2) > err[1]) fprintf(stderr, "dual2 fail: %g %g %g\n", xy2_c, *xy2, err[1]);*/
celt_assert(ABS32(xy1_c - *xy1) <= err[0]);
celt_assert(ABS32(xy2_c - *xy2) <= err[1]);
}
#endif
}
+5 -4
View File
@@ -901,7 +901,7 @@ static void compute_theta(struct band_ctx *ctx, struct split_ctx *sctx,
sctx->itheta = itheta;
sctx->qalloc = qalloc;
}
static unsigned quant_band_n1(struct band_ctx *ctx, celt_norm *X, celt_norm *Y, int b,
static unsigned quant_band_n1(struct band_ctx *ctx, celt_norm *X, celt_norm *Y,
celt_norm *lowband_out)
{
int c;
@@ -926,7 +926,6 @@ static unsigned quant_band_n1(struct band_ctx *ctx, celt_norm *X, celt_norm *Y,
sign = ec_dec_bits(ec, 1);
}
ctx->remaining_bits -= 1<<BITRES;
b-=1<<BITRES;
}
if (ctx->resynth)
x[0] = sign ? -NORM_SCALING : NORM_SCALING;
@@ -1134,7 +1133,7 @@ static unsigned quant_band(struct band_ctx *ctx, celt_norm *X,
/* Special case for one sample */
if (N==1)
{
return quant_band_n1(ctx, X, NULL, b, lowband_out);
return quant_band_n1(ctx, X, NULL, lowband_out);
}
if (tf_change>0)
@@ -1256,7 +1255,7 @@ static unsigned quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm
/* Special case for one sample */
if (N==1)
{
return quant_band_n1(ctx, X, Y, b, lowband_out);
return quant_band_n1(ctx, X, Y, lowband_out);
}
orig_fill = fill;
@@ -1381,6 +1380,7 @@ static unsigned quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm
return cm;
}
#ifndef DISABLE_UPDATE_DRAFT
static void special_hybrid_folding(const CELTMode *m, celt_norm *norm, celt_norm *norm2, int start, int M, int dual_stereo)
{
int n1, n2;
@@ -1393,6 +1393,7 @@ static void special_hybrid_folding(const CELTMode *m, celt_norm *norm, celt_norm
if (dual_stereo)
OPUS_COPY(&norm2[n1], &norm2[2*n1 - n2], n2-n1);
}
#endif
void quant_all_bands(int encode, const CELTMode *m, int start, int end,
celt_norm *X_, celt_norm *Y_, unsigned char *collapse_masks,
+34 -31
View File
@@ -90,7 +90,7 @@ struct OpusCustomDecoder {
opus_uint32 rng;
int error;
int last_pitch_index;
int loss_count;
int loss_duration;
int skip_plc;
int postfilter_period;
int postfilter_period_old;
@@ -117,13 +117,19 @@ void validate_celt_decoder(CELTDecoder *st)
#ifndef CUSTOM_MODES
celt_assert(st->mode == opus_custom_mode_create(48000, 960, NULL));
celt_assert(st->overlap == 120);
celt_assert(st->end <= 21);
#else
/* From Section 4.3 in the spec: "The normal CELT layer uses 21 of those bands,
though Opus Custom (see Section 6.2) may use a different number of bands"
Check if it's within the maximum number of Bark frequency bands instead */
celt_assert(st->end <= 25);
#endif
celt_assert(st->channels == 1 || st->channels == 2);
celt_assert(st->stream_channels == 1 || st->stream_channels == 2);
celt_assert(st->downsample > 0);
celt_assert(st->start == 0 || st->start == 17);
celt_assert(st->start < st->end);
celt_assert(st->end <= 21);
#ifdef OPUS_ARCHMASK
celt_assert(st->arch >= 0);
celt_assert(st->arch <= OPUS_ARCHMASK);
@@ -506,7 +512,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
int nbEBands;
int overlap;
int start;
int loss_count;
int loss_duration;
int noise_based;
const opus_int16 *eBands;
SAVE_STACK;
@@ -526,9 +532,9 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
oldLogE2 = oldLogE + 2*nbEBands;
backgroundLogE = oldLogE2 + 2*nbEBands;
loss_count = st->loss_count;
loss_duration = st->loss_duration;
start = st->start;
noise_based = loss_count >= 5 || start != 0 || st->skip_plc;
noise_based = loss_duration >= 40 || start != 0 || st->skip_plc;
if (noise_based)
{
/* Noise-based PLC/CNG */
@@ -551,9 +557,13 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
#else
ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */
#endif
c=0; do {
OPUS_MOVE(decode_mem[c], decode_mem[c]+N,
DECODE_BUFFER_SIZE-N+(overlap>>1));
} while (++c<C);
/* Energy decay */
decay = loss_count==0 ? QCONST16(1.5f, DB_SHIFT) : QCONST16(.5f, DB_SHIFT);
decay = loss_duration==0 ? QCONST16(1.5f, DB_SHIFT) : QCONST16(.5f, DB_SHIFT);
c=0; do
{
for (i=start;i<end;i++)
@@ -579,11 +589,6 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
}
st->rng = seed;
c=0; do {
OPUS_MOVE(decode_mem[c], decode_mem[c]+N,
DECODE_BUFFER_SIZE-N+(overlap>>1));
} while (++c<C);
celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, C, C, 0, LM, st->downsample, 0, st->arch);
} else {
int exc_length;
@@ -596,7 +601,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
VARDECL(opus_val16, _exc);
VARDECL(opus_val16, fir_tmp);
if (loss_count == 0)
if (loss_duration == 0)
{
st->last_pitch_index = pitch_index = celt_plc_pitch_search(decode_mem, C, st->arch);
} else {
@@ -624,9 +629,9 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
buf = decode_mem[c];
for (i=0;i<MAX_PERIOD+LPC_ORDER;i++)
exc[i-LPC_ORDER] = ROUND16(buf[DECODE_BUFFER_SIZE-MAX_PERIOD-LPC_ORDER+i], SIG_SHIFT);
exc[i-LPC_ORDER] = SROUND16(buf[DECODE_BUFFER_SIZE-MAX_PERIOD-LPC_ORDER+i], SIG_SHIFT);
if (loss_count == 0)
if (loss_duration == 0)
{
opus_val32 ac[LPC_ORDER+1];
/* Compute LPC coefficients for the last MAX_PERIOD samples before
@@ -726,7 +731,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
exc[extrapolation_offset+j])), SIG_SHIFT);
/* Compute the energy of the previously decoded signal whose
excitation we're copying. */
tmp = ROUND16(
tmp = SROUND16(
buf[DECODE_BUFFER_SIZE-MAX_PERIOD-N+extrapolation_offset+j],
SIG_SHIFT);
S1 += SHR32(MULT16_16(tmp, tmp), 10);
@@ -736,7 +741,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
/* Copy the last decoded samples (prior to the overlap region) to
synthesis filter memory so we can have a continuous signal. */
for (i=0;i<LPC_ORDER;i++)
lpc_mem[i] = ROUND16(buf[DECODE_BUFFER_SIZE-N-1-i], SIG_SHIFT);
lpc_mem[i] = SROUND16(buf[DECODE_BUFFER_SIZE-N-1-i], SIG_SHIFT);
/* Apply the synthesis filter to convert the excitation back into
the signal domain. */
celt_iir(buf+DECODE_BUFFER_SIZE-N, lpc+c*LPC_ORDER,
@@ -755,7 +760,7 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
opus_val32 S2=0;
for (i=0;i<extrapolation_len;i++)
{
opus_val16 tmp = ROUND16(buf[DECODE_BUFFER_SIZE-N+i], SIG_SHIFT);
opus_val16 tmp = SROUND16(buf[DECODE_BUFFER_SIZE-N+i], SIG_SHIFT);
S2 += SHR32(MULT16_16(tmp, tmp), 10);
}
/* This checks for an "explosion" in the synthesis. */
@@ -806,7 +811,8 @@ static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM)
} while (++c<C);
}
st->loss_count = loss_count+1;
/* Saturate to soemthing large to avoid wrap-around. */
st->loss_duration = IMIN(10000, loss_duration+(1<<LM));
RESTORE_STACK;
}
@@ -862,6 +868,7 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
int nbEBands;
int overlap;
const opus_int16 *eBands;
opus_val16 max_background_increase;
ALLOC_STACK;
VALIDATE_CELT_DECODER(st);
@@ -936,7 +943,7 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
/* Check if there are at least two packets received consecutively before
* turning on the pitch-based PLC */
st->skip_plc = st->loss_count != 0;
st->skip_plc = st->loss_duration != 0;
if (dec == NULL)
{
@@ -1134,25 +1141,21 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
if (C==1)
OPUS_COPY(&oldBandE[nbEBands], oldBandE, nbEBands);
/* In case start or end were to change */
if (!isTransient)
{
opus_val16 max_background_increase;
OPUS_COPY(oldLogE2, oldLogE, 2*nbEBands);
OPUS_COPY(oldLogE, oldBandE, 2*nbEBands);
/* In normal circumstances, we only allow the noise floor to increase by
up to 2.4 dB/second, but when we're in DTX, we allow up to 6 dB
increase for each update.*/
if (st->loss_count < 10)
max_background_increase = M*QCONST16(0.001f,DB_SHIFT);
else
max_background_increase = QCONST16(1.f,DB_SHIFT);
for (i=0;i<2*nbEBands;i++)
backgroundLogE[i] = MIN16(backgroundLogE[i] + max_background_increase, oldBandE[i]);
} else {
for (i=0;i<2*nbEBands;i++)
oldLogE[i] = MIN16(oldLogE[i], oldBandE[i]);
}
/* In normal circumstances, we only allow the noise floor to increase by
up to 2.4 dB/second, but when we're in DTX we give the weight of
all missing packets to the update packet. */
max_background_increase = IMIN(160, st->loss_duration+M)*QCONST16(0.001f,DB_SHIFT);
for (i=0;i<2*nbEBands;i++)
backgroundLogE[i] = MIN16(backgroundLogE[i] + max_background_increase, oldBandE[i]);
/* In case start or end were to change */
c=0; do
{
for (i=0;i<start;i++)
@@ -1169,7 +1172,7 @@ int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *dat
st->rng = dec->rng;
deemphasis(out_syn, pcm, N, CC, st->downsample, mode->preemph, st->preemph_memD, accum);
st->loss_count = 0;
st->loss_duration = 0;
RESTORE_STACK;
if (ec_tell(dec) > 8*len)
return OPUS_INTERNAL_ERROR;
+11 -5
View File
@@ -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));
@@ -1719,8 +1719,11 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm,
compute_mdcts(mode, 0, in, freq, C, CC, LM, st->upsample, st->arch);
compute_band_energies(mode, freq, bandE, effEnd, C, LM, st->arch);
amp2Log2(mode, effEnd, end, bandE, bandLogE2, C);
for (i=0;i<C*nbEBands;i++)
bandLogE2[i] += HALF16(SHL16(LM, DB_SHIFT));
for (c=0;c<C;c++)
{
for (i=0;i<end;i++)
bandLogE2[nbEBands*c+i] += HALF16(SHL16(LM, DB_SHIFT));
}
}
compute_mdcts(mode, shortBlocks, in, freq, C, CC, LM, st->upsample, st->arch);
@@ -1856,8 +1859,11 @@ int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_val16 * pcm,
compute_band_energies(mode, freq, bandE, effEnd, C, LM, st->arch);
amp2Log2(mode, effEnd, end, bandE, bandLogE, C);
/* Compensate for the scaling of short vs long mdcts */
for (i=0;i<C*nbEBands;i++)
bandLogE2[i] += HALF16(SHL16(LM, DB_SHIFT));
for (c=0;c<C;c++)
{
for (i=0;i<end;i++)
bandLogE2[nbEBands*c+i] += HALF16(SHL16(LM, DB_SHIFT));
}
tf_estimate = QCONST16(.2f,14);
}
}
+60 -12
View File
@@ -50,17 +50,21 @@ int p
#endif
OPUS_CLEAR(lpc, p);
#ifdef FIXED_POINT
if (ac[0] != 0)
#else
if (ac[0] > 1e-10f)
#endif
{
for (i = 0; i < p; i++) {
/* Sum up this iteration's reflection coefficient */
opus_val32 rr = 0;
for (j = 0; j < i; j++)
rr += MULT32_32_Q31(lpc[j],ac[i - j]);
rr += SHR32(ac[i + 1],3);
r = -frac_div32(SHL32(rr,3), error);
rr += SHR32(ac[i + 1],6);
r = -frac_div32(SHL32(rr,6), error);
/* Update LPC coefficients and total error */
lpc[i] = SHR32(r,3);
lpc[i] = SHR32(r,6);
for (j = 0; j < (i+1)>>1; j++)
{
opus_val32 tmp1, tmp2;
@@ -73,17 +77,61 @@ int p
error = error - MULT32_32_Q31(MULT32_32_Q31(r,r),error);
/* Bail out once we get 30 dB gain */
#ifdef FIXED_POINT
if (error<SHR32(ac[0],10))
if (error<=SHR32(ac[0],10))
break;
#else
if (error<.001f*ac[0])
if (error<=.001f*ac[0])
break;
#endif
}
}
#ifdef FIXED_POINT
for (i=0;i<p;i++)
_lpc[i] = ROUND16(lpc[i],16);
{
/* Convert the int32 lpcs to int16 and ensure there are no wrap-arounds.
This reuses the logic in silk_LPC_fit() and silk_bwexpander_32(). Any bug
fixes should also be applied there. */
int iter, idx = 0;
opus_val32 maxabs, absval, chirp_Q16, chirp_minus_one_Q16;
for (iter = 0; iter < 10; iter++) {
maxabs = 0;
for (i = 0; i < p; i++) {
absval = ABS32(lpc[i]);
if (absval > maxabs) {
maxabs = absval;
idx = i;
}
}
maxabs = PSHR32(maxabs, 13); /* Q25->Q12 */
if (maxabs > 32767) {
maxabs = MIN32(maxabs, 163838);
chirp_Q16 = QCONST32(0.999, 16) - DIV32(SHL32(maxabs - 32767, 14),
SHR32(MULT32_32_32(maxabs, idx + 1), 2));
chirp_minus_one_Q16 = chirp_Q16 - 65536;
/* Apply bandwidth expansion. */
for (i = 0; i < p - 1; i++) {
lpc[i] = MULT32_32_Q16(chirp_Q16, lpc[i]);
chirp_Q16 += PSHR32(MULT32_32_32(chirp_Q16, chirp_minus_one_Q16), 16);
}
lpc[p - 1] = MULT32_32_Q16(chirp_Q16, lpc[p - 1]);
} else {
break;
}
}
if (iter == 10) {
/* If the coeffs still do not fit into the 16 bit range after 10 iterations,
fall back to the A(z)=1 filter. */
OPUS_CLEAR(lpc, p);
_lpc[0] = 4096; /* Q12 */
} else {
for (i = 0; i < p; i++) {
_lpc[i] = EXTRACT16(PSHR32(lpc[i], 13)); /* Q25->Q12 */
}
}
}
#endif
}
@@ -111,17 +159,17 @@ void celt_fir_c(
sum[2] = SHL32(EXTEND32(x[i+2]), SIG_SHIFT);
sum[3] = SHL32(EXTEND32(x[i+3]), SIG_SHIFT);
xcorr_kernel(rnum, x+i-ord, sum, ord, arch);
y[i ] = ROUND16(sum[0], SIG_SHIFT);
y[i+1] = ROUND16(sum[1], SIG_SHIFT);
y[i+2] = ROUND16(sum[2], SIG_SHIFT);
y[i+3] = ROUND16(sum[3], SIG_SHIFT);
y[i ] = SROUND16(sum[0], SIG_SHIFT);
y[i+1] = SROUND16(sum[1], SIG_SHIFT);
y[i+2] = SROUND16(sum[2], SIG_SHIFT);
y[i+3] = SROUND16(sum[3], SIG_SHIFT);
}
for (;i<N;i++)
{
opus_val32 sum = SHL32(EXTEND32(x[i]), SIG_SHIFT);
for (j=0;j<ord;j++)
sum = MAC16_16(sum,rnum[j],x[i+j-ord]);
y[i] = ROUND16(sum, SIG_SHIFT);
y[i] = SROUND16(sum, SIG_SHIFT);
}
RESTORE_STACK;
}
+3 -2
View File
@@ -43,10 +43,11 @@
*/
#define OPUS_ARCHMASK 3
#elif (defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE)) || \
#elif defined(OPUS_HAVE_RTCD) && \
((defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE)) || \
(defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2)) || \
(defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1)) || \
(defined(OPUS_X86_MAY_HAVE_AVX) && !defined(OPUS_X86_PRESUME_AVX))
(defined(OPUS_X86_MAY_HAVE_AVX) && !defined(OPUS_X86_PRESUME_AVX)))
#include "x86/x86cpu.h"
/* We currently support 5 x86 variants:
+4
View File
@@ -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)
+58 -13
View File
@@ -167,7 +167,7 @@ static OPUS_INLINE short SHR16_(int a, int shift, char *file, int line)
#define SHL16(a, shift) SHL16_(a, shift, __FILE__, __LINE__)
static OPUS_INLINE short SHL16_(int a, int shift, char *file, int line)
{
int res;
opus_int32 res;
if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift))
{
fprintf (stderr, "SHL16: inputs are not short: %d %d in %s: line %d\n", a, shift, file, line);
@@ -175,7 +175,7 @@ static OPUS_INLINE short SHL16_(int a, int shift, char *file, int line)
celt_assert(0);
#endif
}
res = a<<shift;
res = (opus_int32)((opus_uint32)a<<shift);
if (!VERIFY_SHORT(res))
{
fprintf (stderr, "SHL16: output is not short: %d in %s: line %d\n", res, file, line);
@@ -214,15 +214,15 @@ static OPUS_INLINE int SHL32_(opus_int64 a, int shift, char *file, int line)
opus_int64 res;
if (!VERIFY_INT(a) || !VERIFY_SHORT(shift))
{
fprintf (stderr, "SHL32: inputs are not int: %lld %d in %s: line %d\n", a, shift, file, line);
fprintf (stderr, "SHL32: inputs are not int: %lld %d in %s: line %d\n", (long long)a, shift, file, line);
#ifdef FIXED_DEBUG_ASSERT
celt_assert(0);
#endif
}
res = a<<shift;
res = (opus_int64)((opus_uint64)a<<shift);
if (!VERIFY_INT(res))
{
fprintf (stderr, "SHL32: output is not int: %lld<<%d = %lld in %s: line %d\n", a, shift, res, file, line);
fprintf (stderr, "SHL32: output is not int: %lld<<%d = %lld in %s: line %d\n", (long long)a, shift, (long long)res, file, line);
#ifdef FIXED_DEBUG_ASSERT
celt_assert(0);
#endif
@@ -339,7 +339,7 @@ static OPUS_INLINE unsigned int UADD32_(opus_uint64 a, opus_uint64 b, char *file
opus_uint64 res;
if (!VERIFY_UINT(a) || !VERIFY_UINT(b))
{
fprintf (stderr, "UADD32: inputs are not uint32: %llu %llu in %s: line %d\n", a, b, file, line);
fprintf (stderr, "UADD32: inputs are not uint32: %llu %llu in %s: line %d\n", (unsigned long long)a, (unsigned long long)b, file, line);
#ifdef FIXED_DEBUG_ASSERT
celt_assert(0);
#endif
@@ -347,7 +347,7 @@ static OPUS_INLINE unsigned int UADD32_(opus_uint64 a, opus_uint64 b, char *file
res = a+b;
if (!VERIFY_UINT(res))
{
fprintf (stderr, "UADD32: output is not uint32: %llu in %s: line %d\n", res, file, line);
fprintf (stderr, "UADD32: output is not uint32: %llu in %s: line %d\n", (unsigned long long)res, file, line);
#ifdef FIXED_DEBUG_ASSERT
celt_assert(0);
#endif
@@ -363,14 +363,14 @@ static OPUS_INLINE unsigned int USUB32_(opus_uint64 a, opus_uint64 b, char *file
opus_uint64 res;
if (!VERIFY_UINT(a) || !VERIFY_UINT(b))
{
fprintf (stderr, "USUB32: inputs are not uint32: %llu %llu in %s: line %d\n", a, b, file, line);
fprintf (stderr, "USUB32: inputs are not uint32: %llu %llu in %s: line %d\n", (unsigned long long)a, (unsigned long long)b, file, line);
#ifdef FIXED_DEBUG_ASSERT
celt_assert(0);
#endif
}
if (a<b)
{
fprintf (stderr, "USUB32: inputs underflow: %llu < %llu in %s: line %d\n", a, b, file, line);
fprintf (stderr, "USUB32: inputs underflow: %llu < %llu in %s: line %d\n", (unsigned long long)a, (unsigned long long)b, file, line);
#ifdef FIXED_DEBUG_ASSERT
celt_assert(0);
#endif
@@ -378,7 +378,7 @@ static OPUS_INLINE unsigned int USUB32_(opus_uint64 a, opus_uint64 b, char *file
res = a-b;
if (!VERIFY_UINT(res))
{
fprintf (stderr, "USUB32: output is not uint32: %llu - %llu = %llu in %s: line %d\n", a, b, res, file, line);
fprintf (stderr, "USUB32: output is not uint32: %llu - %llu = %llu in %s: line %d\n", (unsigned long long)a, (unsigned long long)b, (unsigned long long)res, file, line);
#ifdef FIXED_DEBUG_ASSERT
celt_assert(0);
#endif
@@ -410,6 +410,51 @@ static OPUS_INLINE short MULT16_16_16(int a, int b)
return res;
}
/* result fits in 32 bits */
static OPUS_INLINE int MULT32_32_32(opus_int64 a, opus_int64 b)
{
opus_int64 res;
if (!VERIFY_INT(a) || !VERIFY_INT(b))
{
fprintf (stderr, "MULT32_32_32: inputs are not int: %lld %lld\n", (long long)a, (long long)b);
#ifdef FIXED_DEBUG_ASSERT
celt_assert(0);
#endif
}
res = a*b;
if (!VERIFY_INT(res))
{
fprintf (stderr, "MULT32_32_32: output is not int: %lld\n", (long long)res);
#ifdef FIXED_DEBUG_ASSERT
celt_assert(0);
#endif
}
celt_mips+=5;
return res;
}
static OPUS_INLINE int MULT32_32_Q16(opus_int64 a, opus_int64 b)
{
opus_int64 res;
if (!VERIFY_INT(a) || !VERIFY_INT(b))
{
fprintf (stderr, "MULT32_32_Q16: inputs are not int: %lld %lld\n", (long long)a, (long long)b);
#ifdef FIXED_DEBUG_ASSERT
celt_assert(0);
#endif
}
res = ((opus_int64)(a)*(opus_int64)(b)) >> 16;
if (!VERIFY_INT(res))
{
fprintf (stderr, "MULT32_32_Q16: output is not int: %lld*%lld=%lld\n", (long long)a, (long long)b, (long long)res);
#ifdef FIXED_DEBUG_ASSERT
celt_assert(0);
#endif
}
celt_mips+=5;
return res;
}
#define MULT16_16(a, b) MULT16_16_(a, b, __FILE__, __LINE__)
static OPUS_INLINE int MULT16_16_(int a, int b, char *file, int line)
{
@@ -446,7 +491,7 @@ static OPUS_INLINE int MULT16_32_QX_(int a, opus_int64 b, int Q, char *file, int
celt_assert(0);
#endif
}
if (ABS32(b)>=((opus_val32)(1)<<(15+Q)))
if (ABS32(b)>=((opus_int64)(1)<<(16+Q)))
{
fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line);
#ifdef FIXED_DEBUG_ASSERT
@@ -479,7 +524,7 @@ static OPUS_INLINE int MULT16_32_PX_(int a, opus_int64 b, int Q, char *file, int
celt_assert(0);
#endif
}
if (ABS32(b)>=((opus_int64)(1)<<(15+Q)))
if (ABS32(b)>=((opus_int64)(1)<<(16+Q)))
{
fprintf (stderr, "MULT16_32_Q%d: second operand too large: %d %d in %s: line %d\n\n", Q, (int)a, (int)b,file, line);
#ifdef FIXED_DEBUG_ASSERT
@@ -786,6 +831,6 @@ static OPUS_INLINE opus_val16 SIG2WORD16_generic(celt_sig x)
#undef PRINT_MIPS
#define PRINT_MIPS(file) do {fprintf (file, "total complexity = %llu MIPS\n", celt_mips);} while (0);
#define PRINT_MIPS(file) do {fprintf (file, "total complexity = %llu MIPS\n", (unsigned long long)celt_mips);} while (0);
#endif
+12 -2
View File
@@ -57,6 +57,13 @@
#define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),((b)&0x0000ffff)),15))
#endif
/** 32x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */
#if OPUS_FAST_INT64
#define MULT32_32_Q16(a,b) ((opus_val32)SHR((opus_int64)(a)*(opus_int64)(b),16))
#else
#define MULT32_32_Q16(a,b) (ADD32(ADD32(ADD32((opus_val32)(SHR32(((opus_uint32)((a)&0x0000ffff)*(opus_uint32)((b)&0x0000ffff)),16)), MULT16_16SU(SHR32(a,16),((b)&0x0000ffff))), MULT16_16SU(SHR32(b,16),((a)&0x0000ffff))), SHL32(MULT16_16(SHR32(a,16),SHR32(b,16)),16)))
#endif
/** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */
#if OPUS_FAST_INT64
#define MULT32_32_Q31(a,b) ((opus_val32)SHR((opus_int64)(a)*(opus_int64)(b),31))
@@ -102,9 +109,9 @@
#define SATURATE16(x) (EXTRACT16((x)>32767 ? 32767 : (x)<-32768 ? -32768 : (x)))
/** Shift by a and round-to-neareast 32-bit value. Result is a 16-bit value */
/** Shift by a and round-to-nearest 32-bit value. Result is a 16-bit value */
#define ROUND16(x,a) (EXTRACT16(PSHR32((x),(a))))
/** Shift by a and round-to-neareast 32-bit value. Result is a saturated 16-bit value */
/** Shift by a and round-to-nearest 32-bit value. Result is a saturated 16-bit value */
#define SROUND16(x,a) EXTRACT16(SATURATE(PSHR32(x,a), 32767));
/** Divide by two */
@@ -131,6 +138,9 @@
/** 16x16 multiplication where the result fits in 16 bits */
#define MULT16_16_16(a,b) ((((opus_val16)(a))*((opus_val16)(b))))
/** 32x32 multiplication where the result fits in 32 bits */
#define MULT32_32_32(a,b) ((((opus_val32)(a))*((opus_val32)(b))))
/* (opus_val32)(opus_val16) gives TI compiler a hint that it's 16x16->32 multiply */
/** 16x16 multiplication where the result fits in 32 bits */
#define MULT16_16(a,b) (((opus_val32)(opus_val16)(a))*((opus_val32)(opus_val16)(b)))
+34 -28
View File
@@ -67,7 +67,39 @@
#include <xmmintrin.h>
static OPUS_INLINE opus_int32 float2int(float x) {return _mm_cvt_ss2si(_mm_set_ss(x));}
#elif defined(HAVE_LRINTF)
#elif (defined(_MSC_VER) && _MSC_VER >= 1400) && (defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 1))
#include <xmmintrin.h>
static OPUS_INLINE opus_int32 float2int(float value)
{
/* _mm_load_ss will generate same code as _mm_set_ss
** in _MSC_VER >= 1914 /02 so keep __mm_load__ss
** for backward compatibility.
*/
return _mm_cvtss_si32(_mm_load_ss(&value));
}
#elif (defined(_MSC_VER) && _MSC_VER >= 1400) && defined (_M_IX86)
#include <math.h>
/* Win32 doesn't seem to have these functions.
** Therefore implement OPUS_INLINE versions of these functions here.
*/
static OPUS_INLINE opus_int32
float2int (float flt)
{ int intgr;
_asm
{ fld flt
fistp intgr
} ;
return intgr ;
}
#elif defined(HAVE_LRINTF) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* These defines enable functionality introduced with the 1999 ISO C
** standard. They must be defined before the inclusion of math.h to
@@ -85,7 +117,7 @@ static OPUS_INLINE opus_int32 float2int(float x) {return _mm_cvt_ss2si(_mm_set_s
#include <math.h>
#define float2int(x) lrintf(x)
#elif (defined(HAVE_LRINT))
#elif defined(HAVE_LRINT) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
@@ -96,32 +128,6 @@ static OPUS_INLINE opus_int32 float2int(float x) {return _mm_cvt_ss2si(_mm_set_s
#include <math.h>
#define float2int(x) lrint(x)
#elif (defined(_MSC_VER) && _MSC_VER >= 1400) && (defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 1))
#include <xmmintrin.h>
static __inline long int float2int(float value)
{
return _mm_cvtss_si32(_mm_load_ss(&value));
}
#elif (defined(_MSC_VER) && _MSC_VER >= 1400) && defined (_M_IX86)
#include <math.h>
/* Win32 doesn't seem to have these functions.
** Therefore implement OPUS_INLINE versions of these functions here.
*/
static __inline long int
float2int (float flt)
{ int intgr;
_asm
{ fld flt
fistp intgr
} ;
return intgr ;
}
#else
#if (defined(__GNUC__) && defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L)
+11 -1
View File
@@ -52,6 +52,10 @@ extern "C" {
# define kiss_fft_scalar opus_int32
# define kiss_twiddle_scalar opus_int16
/* Some 32-bit CPUs would load/store a kiss_twiddle_cpx with a single memory
* access, and could benefit from additional alignment.
*/
# define KISS_TWIDDLE_CPX_ALIGNMENT (sizeof(opus_int32))
#else
# ifndef kiss_fft_scalar
@@ -62,6 +66,12 @@ extern "C" {
# endif
#endif
#if defined(__GNUC__) && defined(KISS_TWIDDLE_CPX_ALIGNMENT)
#define KISS_TWIDDLE_CPX_ALIGNED __attribute__((aligned(KISS_TWIDDLE_CPX_ALIGNMENT)))
#else
#define KISS_TWIDDLE_CPX_ALIGNED
#endif
typedef struct {
kiss_fft_scalar r;
kiss_fft_scalar i;
@@ -70,7 +80,7 @@ typedef struct {
typedef struct {
kiss_twiddle_scalar r;
kiss_twiddle_scalar i;
}kiss_twiddle_cpx;
} KISS_TWIDDLE_CPX_ALIGNED kiss_twiddle_cpx;
#define MAXFACTORS 8
/* e.g. an fft of length 128 has 4 factors
+3 -3
View File
@@ -137,7 +137,7 @@ static OPUS_INLINE float celt_log2(float x)
} in;
in.f = x;
integer = (in.i>>23)-127;
in.i -= integer<<23;
in.i -= (opus_uint32)integer<<23;
frac = in.f - 1.5f;
frac = -0.41445418f + frac*(0.95909232f
+ frac*(-0.33951290f + frac*0.16541097f));
@@ -153,14 +153,14 @@ static OPUS_INLINE float celt_exp2(float x)
float f;
opus_uint32 i;
} res;
integer = floor(x);
integer = (int)floor(x);
if (integer < -50)
return 0;
frac = x-integer;
/* K0 = 1, K1 = log(2), K2 = 3-4*log(2), K3 = 3*log(2) - 2 */
res.f = 0.99992522f + frac * (0.69583354f
+ frac * (0.22606716f + 0.078024523f*frac));
res.i = (res.i + (integer<<23)) & 0x7fffffff;
res.i = (res.i + ((opus_uint32)integer<<23)) & 0x7fffffff;
return res.f;
}
+69
View File
@@ -0,0 +1,69 @@
celt_sources = sources['CELT_SOURCES']
celt_sse_sources = sources['CELT_SOURCES_SSE']
celt_sse2_sources = sources['CELT_SOURCES_SSE2']
celt_sse4_1_sources = sources['CELT_SOURCES_SSE4_1']
celt_neon_intr_sources = sources['CELT_SOURCES_ARM_NEON_INTR']
celt_static_libs = []
if host_cpu_family in ['x86', 'x86_64'] and opus_conf.has('OPUS_HAVE_RTCD')
celt_sources += sources['CELT_SOURCES_X86_RTCD']
endif
foreach intr_name : ['sse', 'sse2', 'sse4_1', 'neon_intr']
have_intr = get_variable('have_' + intr_name)
if not have_intr
continue
endif
intr_sources = get_variable('celt_@0@_sources'.format(intr_name))
intr_args = get_variable('opus_@0@_args'.format(intr_name), [])
celt_static_libs += static_library('celt_' + intr_name, intr_sources,
c_args: intr_args,
include_directories: opus_includes,
install: false)
endforeach
have_arm_intrinsics_or_asm = have_arm_ne10
if (intrinsics_support.length() + asm_optimization.length() + inline_optimization.length()) > 0
have_arm_intrinsics_or_asm = true
endif
if host_cpu_family in ['arm', 'aarch64'] and have_arm_intrinsics_or_asm
if opus_conf.has('OPUS_HAVE_RTCD')
celt_sources += sources['CELT_SOURCES_ARM_RTCD']
endif
if have_arm_ne10
celt_sources += sources['CELT_SOURCES_ARM_NE10']
endif
if opus_arm_external_asm
arm2gnu = [find_program('arm/arm2gnu.pl')] + arm2gnu_args
celt_sources_arm_asm = configure_file(input: 'arm/celt_pitch_xcorr_arm.s',
output: '@[email protected]',
command: arm2gnu + ['@INPUT@'],
capture: true)
celt_arm_armopts_s = configure_file(input: 'arm/armopts.s.in',
output: 'arm/armopts.s',
configuration: opus_conf)
celt_static_libs += static_library('celt-armasm',
celt_arm_armopts_s, celt_sources_arm_asm,
install: false)
endif
endif
celt_c_args = []
if host_system == 'windows'
celt_c_args += ['-DDLL_EXPORT']
endif
celt_lib = static_library('opus-celt',
celt_sources,
c_args: celt_c_args,
include_directories: opus_includes,
link_whole: celt_static_libs,
dependencies: libm,
install: false)
+3
View File
@@ -173,7 +173,10 @@ static void compute_allocation_table(CELTMode *mode)
mode->nbAllocVectors = BITALLOC_SIZE;
allocVectors = opus_alloc(sizeof(unsigned char)*(BITALLOC_SIZE*mode->nbEBands));
if (allocVectors==NULL)
{
mode->allocVectors = NULL;
return;
}
/* Check for standard mode */
if (mode->Fs == 400*(opus_int32)mode->shortMdctSize)
-1
View File
@@ -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 */
+16 -7
View File
@@ -161,17 +161,26 @@ void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x
shift=0;
if (C==2)
shift++;
#endif
for (i=1;i<len>>1;i++)
x_lp[i] = SHR32(HALF32(HALF32(x[0][(2*i-1)]+x[0][(2*i+1)])+x[0][2*i]), shift);
x_lp[0] = SHR32(HALF32(HALF32(x[0][1])+x[0][0]), shift);
x_lp[i] = SHR32(x[0][(2*i-1)], shift+2) + SHR32(x[0][(2*i+1)], shift+2) + SHR32(x[0][2*i], shift+1);
x_lp[0] = SHR32(x[0][1], shift+2) + SHR32(x[0][0], shift+1);
if (C==2)
{
for (i=1;i<len>>1;i++)
x_lp[i] += SHR32(HALF32(HALF32(x[1][(2*i-1)]+x[1][(2*i+1)])+x[1][2*i]), shift);
x_lp[0] += SHR32(HALF32(HALF32(x[1][1])+x[1][0]), shift);
x_lp[i] += SHR32(x[1][(2*i-1)], shift+2) + SHR32(x[1][(2*i+1)], shift+2) + SHR32(x[1][2*i], shift+1);
x_lp[0] += SHR32(x[1][1], shift+2) + SHR32(x[1][0], shift+1);
}
#else
for (i=1;i<len>>1;i++)
x_lp[i] = .25f*x[0][(2*i-1)] + .25f*x[0][(2*i+1)] + .5f*x[0][2*i];
x_lp[0] = .25f*x[0][1] + .5f*x[0][0];
if (C==2)
{
for (i=1;i<len>>1;i++)
x_lp[i] += .25f*x[1][(2*i-1)] + .25f*x[1][(2*i+1)] + .5f*x[1][2*i];
x_lp[0] += .25f*x[1][1] + .5f*x[1][0];
}
#endif
_celt_autocorr(x_lp, ac, NULL, 0,
4, len>>1, arch);
@@ -249,7 +258,7 @@ celt_pitch_xcorr_c(const opus_val16 *_x, const opus_val16 *_y,
opus_val32 maxcorr=1;
#endif
celt_assert(max_pitch>0);
celt_sig_assert((((unsigned char *)_x-(unsigned char *)NULL)&3)==0);
celt_sig_assert(((size_t)_x&3)==0);
for (i=0;i<max_pitch-3;i+=4)
{
opus_val32 sum[4]={0,0,0,0};
+2
View File
@@ -356,6 +356,8 @@ static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end,
else
depth_threshold = 0;
#ifdef FUZZING
(void)signalBandwidth;
(void)depth_threshold;
if ((rand()&0x1) == 0)
#else
if (codedBands<=start+2 || (band_bits > (depth_threshold*band_width<<LM<<BITRES)>>4 && j<=signalBandwidth))
+2 -2
View File
@@ -40,7 +40,7 @@
#endif
#ifdef USE_ALLOCA
# ifdef WIN32
# ifdef _WIN32
# include <malloc.h>
# else
# ifdef HAVE_ALLOCA_H
@@ -102,7 +102,7 @@
#define VARDECL(type, var) type *var
# ifdef WIN32
# ifdef _WIN32
# define ALLOC(var, size, type) var = ((type*)_alloca(sizeof(type)*(size)))
# else
# define ALLOC(var, size, type) var = ((type*)alloca(sizeof(type)*(size)))
+19
View File
@@ -0,0 +1,19 @@
tests = [
'test_unit_types',
'test_unit_mathops',
'test_unit_entropy',
'test_unit_laplace',
'test_unit_dft',
'test_unit_mdct',
'test_unit_rotation',
'test_unit_cwrs32',
]
foreach test_name : tests
exe = executable(test_name, '@[email protected]'.format(test_name),
include_directories : opus_includes,
link_with : [celt_lib, celt_static_libs],
dependencies : libm,
install : false)
test(test_name, exe)
endforeach
+2 -1
View File
@@ -144,8 +144,9 @@ void test1d(int nfft,int isinverse,int arch)
int main(int argc,char ** argv)
{
int arch;
ALLOC_STACK;
int arch = opus_select_arch();
arch = opus_select_arch();
if (argc>1) {
int k;
+2 -2
View File
@@ -104,7 +104,7 @@ int main(int _argc,char **_argv){
nbits=ec_tell_frac(&enc);
ec_enc_done(&enc);
fprintf(stderr,
"Encoded %0.2lf bits of entropy to %0.2lf bits (%0.3lf%% wasted).\n",
"Encoded %0.2f bits of entropy to %0.2f bits (%0.3f%% wasted).\n",
entropy,ldexp(nbits,-3),100*(nbits-ldexp(entropy,3))/nbits);
fprintf(stderr,"Packed to %li bytes.\n",(long)ec_range_bytes(&enc));
ec_dec_init(&dec,ptr,DATA_SIZE);
@@ -129,7 +129,7 @@ int main(int _argc,char **_argv){
nbits2=ec_tell_frac(&dec);
if(nbits!=nbits2){
fprintf(stderr,
"Reported number of bits used was %0.2lf, should be %0.2lf.\n",
"Reported number of bits used was %0.2f, should be %0.2f.\n",
ldexp(nbits2,-3),ldexp(nbits,-3));
ret=-1;
}
+3 -3
View File
@@ -143,7 +143,7 @@ void testbitexactlog2tan(void)
void testlog2(void)
{
float x;
for (x=0.001;x<1677700.0;x+=(x/8.0))
for (x=0.001f;x<1677700.0;x+=(x/8.0))
{
float error = fabs((1.442695040888963387*log(x))-celt_log2(x));
if (error>0.0009)
@@ -157,7 +157,7 @@ void testlog2(void)
void testexp2(void)
{
float x;
for (x=-11.0;x<24.0;x+=0.0007)
for (x=-11.0;x<24.0;x+=0.0007f)
{
float error = fabs(x-(1.442695040888963387*log(celt_exp2(x))));
if (error>0.0002)
@@ -171,7 +171,7 @@ void testexp2(void)
void testexp2log2(void)
{
float x;
for (x=-11.0;x<24.0;x+=0.0007)
for (x=-11.0;x<24.0;x+=0.0007f)
{
float error = fabs(x-(celt_log2(celt_exp2(x))));
if (error>0.001)
+2 -1
View File
@@ -184,8 +184,9 @@ void test1d(int nfft,int isinverse,int arch)
int main(int argc,char ** argv)
{
int arch;
ALLOC_STACK;
int arch = opus_select_arch();
arch = opus_select_arch();
if (argc>1) {
int k;
+3 -2
View File
@@ -33,7 +33,6 @@
#endif
#if defined(OPUS_X86_MAY_HAVE_SSE4_1) && defined(FIXED_POINT)
#define OVERRIDE_CELT_FIR
void celt_fir_sse4_1(
const opus_val16 *x,
@@ -44,10 +43,11 @@ void celt_fir_sse4_1(
int arch);
#if defined(OPUS_X86_PRESUME_SSE4_1)
#define OVERRIDE_CELT_FIR
#define celt_fir(x, num, y, N, ord, arch) \
((void)arch, celt_fir_sse4_1(x, num, y, N, ord, arch))
#else
#elif defined(OPUS_HAVE_RTCD)
extern void (*const CELT_FIR_IMPL[OPUS_ARCHMASK + 1])(
const opus_val16 *x,
@@ -57,6 +57,7 @@ extern void (*const CELT_FIR_IMPL[OPUS_ARCHMASK + 1])(
int ord,
int arch);
#define OVERRIDE_CELT_FIR
# define celt_fir(x, num, y, N, ord, arch) \
((*CELT_FIR_IMPL[(arch) & OPUS_ARCHMASK])(x, num, y, N, ord, arch))
+4 -4
View File
@@ -63,7 +63,7 @@ void xcorr_kernel_sse(
#define xcorr_kernel(x, y, sum, len, arch) \
((void)arch, xcorr_kernel_sse(x, y, sum, len))
#elif (defined(OPUS_X86_MAY_HAVE_SSE4_1) && defined(FIXED_POINT)) || (defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT))
#elif defined(OPUS_HAVE_RTCD) && ((defined(OPUS_X86_MAY_HAVE_SSE4_1) && defined(FIXED_POINT)) || (defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT)))
extern void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])(
const opus_val16 *x,
@@ -91,7 +91,7 @@ opus_val32 celt_inner_prod_sse2(
int N);
#endif
#if defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(FIXED_POINT)
#if defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT)
opus_val32 celt_inner_prod_sse(
const opus_val16 *x,
const opus_val16 *y,
@@ -115,8 +115,8 @@ opus_val32 celt_inner_prod_sse(
((void)arch, celt_inner_prod_sse(x, y, N))
#elif ((defined(OPUS_X86_MAY_HAVE_SSE4_1) || defined(OPUS_X86_MAY_HAVE_SSE2)) && defined(FIXED_POINT)) || \
(defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT))
#elif defined(OPUS_HAVE_RTCD) && (((defined(OPUS_X86_MAY_HAVE_SSE4_1) || defined(OPUS_X86_MAY_HAVE_SSE2)) && defined(FIXED_POINT)) || \
(defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT)))
extern opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])(
const opus_val16 *x,
+48 -3
View File
@@ -117,6 +117,14 @@ void xcorr_kernel_sse4_1(const opus_val16 * x, const opus_val16 * y, opus_val32
__m128i sum0, sum1, sum2, sum3, vecSum;
__m128i initSum;
#ifdef OPUS_CHECK_ASM
opus_val32 sum_c[4];
for (j=0;j<4;j++) {
sum_c[j] = sum[j];
}
xcorr_kernel_c(x, y, sum_c, len);
#endif
celt_assert(len >= 3);
sum0 = _mm_setzero_si128();
@@ -177,19 +185,56 @@ void xcorr_kernel_sse4_1(const opus_val16 * x, const opus_val16 * y, opus_val32
vecSum = _mm_add_epi32(vecSum, sum2);
}
for (;j<len;j++)
vecX = OP_CVTEPI16_EPI32_M64(&x[len - 4]);
if (len - j == 3)
{
vecX = OP_CVTEPI16_EPI32_M64(&x[j + 0]);
vecX0 = _mm_shuffle_epi32(vecX, 0x00);
vecX0 = _mm_shuffle_epi32(vecX, 0x55);
vecX1 = _mm_shuffle_epi32(vecX, 0xaa);
vecX2 = _mm_shuffle_epi32(vecX, 0xff);
vecY0 = OP_CVTEPI16_EPI32_M64(&y[j + 0]);
vecY1 = OP_CVTEPI16_EPI32_M64(&y[j + 1]);
vecY2 = OP_CVTEPI16_EPI32_M64(&y[j + 2]);
sum0 = _mm_mullo_epi32(vecX0, vecY0);
sum1 = _mm_mullo_epi32(vecX1, vecY1);
sum2 = _mm_mullo_epi32(vecX2, vecY2);
vecSum = _mm_add_epi32(vecSum, sum0);
vecSum = _mm_add_epi32(vecSum, sum1);
vecSum = _mm_add_epi32(vecSum, sum2);
}
else if (len - j == 2)
{
vecX0 = _mm_shuffle_epi32(vecX, 0xaa);
vecX1 = _mm_shuffle_epi32(vecX, 0xff);
vecY0 = OP_CVTEPI16_EPI32_M64(&y[j + 0]);
vecY1 = OP_CVTEPI16_EPI32_M64(&y[j + 1]);
sum0 = _mm_mullo_epi32(vecX0, vecY0);
sum1 = _mm_mullo_epi32(vecX1, vecY1);
vecSum = _mm_add_epi32(vecSum, sum0);
vecSum = _mm_add_epi32(vecSum, sum1);
}
else if (len - j == 1)
{
vecX0 = _mm_shuffle_epi32(vecX, 0xff);
vecY0 = OP_CVTEPI16_EPI32_M64(&y[j + 0]);
sum0 = _mm_mullo_epi32(vecX0, vecY0);
vecSum = _mm_add_epi32(vecSum, sum0);
}
initSum = _mm_loadu_si128((__m128i *)(&sum[0]));
initSum = _mm_add_epi32(initSum, vecSum);
_mm_storeu_si128((__m128i *)sum, initSum);
#ifdef OPUS_CHECK_ASM
celt_assert(!memcmp(sum_c, sum, sizeof(sum_c)));
#endif
}
#endif
+29 -8
View File
@@ -35,11 +35,11 @@
#include "pitch.h"
#include "x86cpu.h"
#if (defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE)) || \
#if defined(OPUS_HAVE_RTCD) && \
((defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE)) || \
(defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2)) || \
(defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1)) || \
(defined(OPUS_X86_MAY_HAVE_AVX) && !defined(OPUS_X86_PRESUME_AVX))
(defined(OPUS_X86_MAY_HAVE_AVX) && !defined(OPUS_X86_PRESUME_AVX)))
#if defined(_MSC_VER)
@@ -68,7 +68,8 @@ static void cpuid(unsigned int CPUInfo[4], unsigned int InfoType)
"=r" (CPUInfo[1]),
"=c" (CPUInfo[2]),
"=d" (CPUInfo[3]) :
"0" (InfoType)
/* We clear ECX to avoid a valgrind false-positive prior to v3.17.0. */
"0" (InfoType), "2" (0)
);
#else
__asm__ __volatile__ (
@@ -77,11 +78,22 @@ static void cpuid(unsigned int CPUInfo[4], unsigned int InfoType)
"=b" (CPUInfo[1]),
"=c" (CPUInfo[2]),
"=d" (CPUInfo[3]) :
"0" (InfoType)
/* We clear ECX to avoid a valgrind false-positive prior to v3.17.0. */
"0" (InfoType), "2" (0)
);
#endif
#elif defined(CPU_INFO_BY_C)
__get_cpuid(InfoType, &(CPUInfo[0]), &(CPUInfo[1]), &(CPUInfo[2]), &(CPUInfo[3]));
/* We use __get_cpuid_count to clear ECX to avoid a valgrind false-positive
prior to v3.17.0.*/
if (!__get_cpuid_count(InfoType, 0, &(CPUInfo[0]), &(CPUInfo[1]), &(CPUInfo[2]), &(CPUInfo[3]))) {
/* Our function cannot fail, but __get_cpuid{_count} can.
Returning all zeroes will effectively disable all SIMD, which is
what we want on CPUs that don't support CPUID. */
CPUInfo[3] = CPUInfo[2] = CPUInfo[1] = CPUInfo[0] = 0;
}
#else
# error "Configured to use x86 RTCD, but no CPU detection method available. " \
"Reconfigure with --disable-rtcd (or send patches)."
#endif
}
@@ -98,7 +110,7 @@ typedef struct CPU_Feature{
static void opus_cpu_feature_check(CPU_Feature *cpu_feature)
{
unsigned int info[4] = {0};
unsigned int info[4];
unsigned int nIds = 0;
cpuid(info, 0);
@@ -119,7 +131,7 @@ static void opus_cpu_feature_check(CPU_Feature *cpu_feature)
}
}
int opus_select_arch(void)
static int opus_select_arch_impl(void)
{
CPU_Feature cpu_feature;
int arch;
@@ -154,4 +166,13 @@ int opus_select_arch(void)
return arch;
}
int opus_select_arch(void) {
int arch = opus_select_arch_impl();
#ifdef FUZZING
/* Randomly downgrade the architecture. */
arch = rand()%(arch+1);
#endif
return arch;
}
#endif
+10 -32
View File
@@ -56,40 +56,18 @@
int opus_select_arch(void);
# endif
/*gcc appears to emit MOVDQA's to load the argument of an _mm_cvtepi8_epi32()
or _mm_cvtepi16_epi32() when optimizations are disabled, even though the
actual PMOVSXWD instruction takes an m32 or m64. Unlike a normal memory
reference, these require 16-byte alignment and load a full 16 bytes (instead
of 4 or 8), possibly reading out of bounds.
/*MOVD should not impose any alignment restrictions, but the C standard does,
and UBSan will report errors if we actually make unaligned accesses.
Use this to work around those restrictions (which should hopefully all get
optimized to a single MOVD instruction).*/
#define OP_LOADU_EPI32(x) \
(int)((*(unsigned char *)(x) | *((unsigned char *)(x) + 1) << 8U |\
*((unsigned char *)(x) + 2) << 16U | (opus_uint32)*((unsigned char *)(x) + 3) << 24U))
We can insert an explicit MOVD or MOVQ using _mm_cvtsi32_si128() or
_mm_loadl_epi64(), which should have the same semantics as an m32 or m64
reference in the PMOVSXWD instruction itself, but gcc is not smart enough to
optimize this out when optimizations ARE enabled.
#define OP_CVTEPI8_EPI32_M32(x) \
(_mm_cvtepi8_epi32(_mm_cvtsi32_si128(OP_LOADU_EPI32(x))))
Clang, in contrast, requires us to do this always for _mm_cvtepi8_epi32
(which is fair, since technically the compiler is always allowed to do the
dereference before invoking the function implementing the intrinsic).
However, it is smart enough to eliminate the extra MOVD instruction.
For _mm_cvtepi16_epi32, it does the right thing, though does *not* optimize out
the extra MOVQ if it's specified explicitly */
# if defined(__clang__) || !defined(__OPTIMIZE__)
# define OP_CVTEPI8_EPI32_M32(x) \
(_mm_cvtepi8_epi32(_mm_cvtsi32_si128(*(int *)(x))))
# else
# define OP_CVTEPI8_EPI32_M32(x) \
(_mm_cvtepi8_epi32(*(__m128i *)(x)))
#endif
/* similar reasoning about the instruction sequence as in the 32-bit macro above,
*/
# if defined(__clang__) || !defined(__OPTIMIZE__)
# define OP_CVTEPI16_EPI32_M64(x) \
#define OP_CVTEPI16_EPI32_M64(x) \
(_mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(x))))
# else
# define OP_CVTEPI16_EPI32_M64(x) \
(_mm_cvtepi16_epi32(*(__m128i *)(x)))
# endif
#endif
+5 -3
View File
@@ -18,9 +18,11 @@ celt/quant_bands.c \
celt/rate.c \
celt/vq.c
CELT_SOURCES_SSE = \
CELT_SOURCES_X86_RTCD = \
celt/x86/x86cpu.c \
celt/x86/x86_celt_map.c \
celt/x86/x86_celt_map.c
CELT_SOURCES_SSE = \
celt/x86/pitch_sse.c
CELT_SOURCES_SSE2 = \
@@ -31,7 +33,7 @@ CELT_SOURCES_SSE4_1 = \
celt/x86/celt_lpc_sse4_1.c \
celt/x86/pitch_sse4_1.c
CELT_SOURCES_ARM = \
CELT_SOURCES_ARM_RTCD = \
celt/arm/armcpu.c \
celt/arm/arm_celt_map.c
+39
View File
@@ -0,0 +1,39 @@
# - Compile and run code to check for C features
#
# This functions compiles a source file under the `cmake` folder
# and adds the corresponding `HAVE_[FILENAME]` flag to the CMake
# environment
#
# c_feature_check(<FLAG> [<VARIANT>])
#
# - Example
#
# include(CFeatureCheck)
# c_feature_check(VLA)
if(__c_feature_check)
return()
endif()
set(__c_feature_check INCLUDED)
function(c_feature_check FILE)
string(TOLOWER ${FILE} FILE)
string(TOUPPER ${FILE} VAR)
string(TOUPPER "${VAR}_SUPPORTED" FEATURE)
if (DEFINED ${VAR}_SUPPORTED)
set(${VAR}_SUPPORTED 1 PARENT_SCOPE)
return()
endif()
if (NOT DEFINED COMPILE_${FEATURE})
message(STATUS "Performing Test ${FEATURE}")
try_compile(COMPILE_${FEATURE} ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/${FILE}.c)
endif()
if(COMPILE_${FEATURE})
message(STATUS "Performing Test ${FEATURE} -- success")
set(${VAR}_SUPPORTED 1 PARENT_SCOPE)
else()
message(STATUS "Performing Test ${FEATURE} -- failed to compile")
endif()
endfunction()
@@ -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)
+115
View File
@@ -0,0 +1,115 @@
if(__opus_config)
return()
endif()
set(__opus_config INCLUDED)
include(OpusFunctions)
configure_file(cmake/config.h.cmake.in config.h @ONLY)
add_definitions(-DHAVE_CONFIG_H)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(MSVC)
# For compilers that have no notion of a C standard level,
# such as Microsoft Visual C++ before VS 16.7,
# this property has no effect.
set(CMAKE_C_STANDARD 11)
else()
set(CMAKE_C_STANDARD 99)
endif()
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
include(CFeatureCheck)
c_feature_check(VLA)
include(CheckIncludeFile)
check_include_file(alloca.h HAVE_ALLOCA_H)
include(CheckSymbolExists)
if(HAVE_ALLOCA_H)
add_definitions(-DHAVE_ALLOCA_H)
check_symbol_exists(alloca "alloca.h" USE_ALLOCA_SUPPORTED)
else()
check_symbol_exists(alloca "stdlib.h;malloc.h" USE_ALLOCA_SUPPORTED)
endif()
include(CMakePushCheckState)
cmake_push_check_state(RESET)
include(CheckLibraryExists)
check_library_exists(m floor "" HAVE_LIBM)
if(HAVE_LIBM)
list(APPEND OPUS_REQUIRED_LIBRARIES m)
set(CMAKE_REQUIRED_LIBRARIES m)
endif()
check_symbol_exists(lrintf "math.h" HAVE_LRINTF)
check_symbol_exists(lrint "math.h" HAVE_LRINT)
cmake_pop_check_state()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(i[0-9]86|x86|X86|amd64|AMD64|x86_64)")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(OPUS_CPU_X64 1)
else()
set(OPUS_CPU_X86 1)
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)")
set(OPUS_CPU_ARM 1)
endif()
if(NOT OPUS_DISABLE_INTRINSICS)
opus_supports_cpu_detection(RUNTIME_CPU_CAPABILITY_DETECTION)
endif()
if(OPUS_CPU_X86 OR OPUS_CPU_X64 AND NOT OPUS_DISABLE_INTRINSICS)
opus_detect_sse(COMPILER_SUPPORT_SIMD)
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)
option(OPUS_MAY_HAVE_NEON "Does runtime check for neon support" ON)
option(OPUS_PRESUME_NEON "Assume target CPU has NEON support" OFF)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(OPUS_PRESUME_NEON ON)
elseif(CMAKE_SYSTEM_NAME MATCHES "iOS")
set(OPUS_PRESUME_NEON ON)
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)
set(FORTIFY_SOURCE_SUPPORTED 1)
endif()
if(MINGW)
# For MINGW we need to link ssp lib for security features such as
# stack protector and fortify_sources
check_library_exists(ssp __stack_chk_fail "" HAVE_LIBSSP)
if(NOT HAVE_LIBSSP)
message(WARNING "Could not find libssp in MinGW, disabling STACK_PROTECTOR and FORTIFY_SOURCE")
set(STACK_PROTECTOR_SUPPORTED 0)
set(FORTIFY_SOURCE_SUPPORTED 0)
endif()
endif()
if(NOT MSVC)
set(WARNING_LIST -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow)
include(CheckCCompilerFlag)
foreach(WARNING_FLAG ${WARNING_LIST})
string(REPLACE - "" WARNING_VAR ${WARNING_FLAG})
check_c_compiler_flag(${WARNING_FLAG} ${WARNING_VAR}_SUPPORTED)
if(${WARNING_VAR}_SUPPORTED)
add_compile_options(${WARNING_FLAG})
endif()
endforeach()
endif()
@@ -7,7 +7,8 @@ set(OPUS_VERSION_PATCH @PROJECT_VERSION_PATCH@)
@PACKAGE_INIT@
set_and_check(OPUS_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
set_and_check(OPUS_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@")
set(OPUS_INCLUDE_DIR ${OPUS_INCLUDE_DIR};${OPUS_INCLUDE_DIR}/opus)
set(OPUS_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@;@PACKAGE_INCLUDE_INSTALL_DIR@/opus")
include(${CMAKE_CURRENT_LIST_DIR}/OpusTargets.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
@@ -42,60 +41,6 @@ function(get_library_version OPUS_LIBRARY_VERSION OPUS_LIBRARY_VERSION_MAJOR)
set(OPUS_LIBRARY_VERSION_MAJOR ${OPUS_LIBRARY_VERSION_MAJOR} PARENT_SCOPE)
endfunction()
function(get_package_version PACKAGE_VERSION)
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --match "v*"
OUTPUT_VARIABLE OPUS_PACKAGE_VERSION)
if(OPUS_PACKAGE_VERSION)
string(STRIP ${OPUS_PACKAGE_VERSION}, OPUS_PACKAGE_VERSION)
string(REPLACE \n
""
OPUS_PACKAGE_VERSION
${OPUS_PACKAGE_VERSION})
string(REPLACE ,
""
OPUS_PACKAGE_VERSION
${OPUS_PACKAGE_VERSION})
string(SUBSTRING ${OPUS_PACKAGE_VERSION}
1
-1
OPUS_PACKAGE_VERSION)
set(PACKAGE_VERSION ${OPUS_PACKAGE_VERSION} PARENT_SCOPE)
return()
endif()
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/package_version")
# Not a git repo, lets' try to parse it from package_version file if exists
file(STRINGS package_version opus_package_version_string
LIMIT_COUNT 1
REGEX "PACKAGE_VERSION=")
string(REPLACE "PACKAGE_VERSION="
""
opus_package_version_string
${opus_package_version_string})
string(REPLACE "\""
""
opus_package_version_string
${opus_package_version_string})
set(PACKAGE_VERSION ${opus_package_version_string} PARENT_SCOPE)
return()
endif()
# if all else fails set to 0
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)
@@ -115,13 +60,17 @@ function(opus_detect_sse COMPILER_SUPPORT_SIMD)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
check_flag(SSE1 /arch:SSE)
else()
set(SSE1_SUPPORTED 1 PARENT_SCOPE)
set(SSE1_SUPPORTED
1
PARENT_SCOPE)
endif()
else()
check_and_set_flag(SSE1 -msse)
check_flag(SSE1 -msse)
endif()
else()
set(SSE1_SUPPORTED 0 PARENT_SCOPE)
set(SSE1_SUPPORTED
0
PARENT_SCOPE)
endif()
check_include_file(emmintrin.h HAVE_EMMINTRIN_H) # SSE2
@@ -130,13 +79,17 @@ function(opus_detect_sse COMPILER_SUPPORT_SIMD)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
check_flag(SSE2 /arch:SSE2)
else()
set(SSE2_SUPPORTED 1 PARENT_SCOPE)
set(SSE2_SUPPORTED
1
PARENT_SCOPE)
endif()
else()
check_and_set_flag(SSE2 -msse2)
check_flag(SSE2 -msse2)
endif()
else()
set(SSE2_SUPPORTED 0 PARENT_SCOPE)
set(SSE2_SUPPORTED
0
PARENT_SCOPE)
endif()
check_include_file(smmintrin.h HAVE_SMMINTRIN_H) # SSE4.1
@@ -145,13 +98,17 @@ function(opus_detect_sse COMPILER_SUPPORT_SIMD)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
check_flag(SSE4_1 /arch:SSE2) # SSE2 and above
else()
set(SSE4_1_SUPPORTED 1 PARENT_SCOPE)
set(SSE4_1_SUPPORTED
1
PARENT_SCOPE)
endif()
else()
check_and_set_flag(SSE4_1 -msse4.1)
check_flag(SSE4_1 -msse4.1)
endif()
else()
set(SSE4_1_SUPPORTED 0 PARENT_SCOPE)
set(SSE4_1_SUPPORTED
0
PARENT_SCOPE)
endif()
check_include_file(immintrin.h HAVE_IMMINTRIN_H) # AVX
@@ -159,22 +116,12 @@ function(opus_detect_sse COMPILER_SUPPORT_SIMD)
if(MSVC)
check_flag(AVX /arch:AVX)
else()
check_and_set_flag(AVX -mavx)
check_flag(AVX -mavx)
endif()
else()
set(AVX_SUPPORTED 0 PARENT_SCOPE)
endif()
if(MSVC) # To avoid warning D9025 of overriding compiler options
if(AVX_SUPPORTED) # on 64 bit and 32 bits
add_definitions(/arch:AVX)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) # if AVX not supported then set SSE flag
if(SSE4_1_SUPPORTED OR SSE2_SUPPORTED)
add_definitions(/arch:SSE2)
elseif(SSE1_SUPPORTED)
add_definitions(/arch:SSE)
endif()
endif()
set(AVX_SUPPORTED
0
PARENT_SCOPE)
endif()
if(SSE1_SUPPORTED OR SSE2_SUPPORTED OR SSE4_1_SUPPORTED OR AVX_SUPPORTED)
@@ -185,7 +132,7 @@ function(opus_detect_sse COMPILER_SUPPORT_SIMD)
endfunction()
function(opus_detect_neon COMPILER_SUPPORT_NEON)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(armv7-a|aarch64)")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64)")
message(STATUS "Check NEON support by compiler")
check_include_file(arm_neon.h HAVE_ARM_NEON_H)
if(HAVE_ARM_NEON_H)
@@ -195,13 +142,33 @@ function(opus_detect_neon COMPILER_SUPPORT_NEON)
endfunction()
function(opus_supports_cpu_detection RUNTIME_CPU_CAPABILITY_DETECTION)
if(MSVC)
check_include_file(intrin.h HAVE_INTRIN_H)
else()
check_include_file(cpuid.h HAVE_CPUID_H)
endif()
if(HAVE_INTRIN_H OR HAVE_CPUID_H)
set(RUNTIME_CPU_CAPABILITY_DETECTION 1 PARENT_SCOPE)
set(RUNTIME_CPU_CAPABILITY_DETECTION 0 PARENT_SCOPE)
if(OPUS_CPU_X86 OR OPUS_CPU_X64)
if(MSVC)
check_include_file(intrin.h HAVE_INTRIN_H)
if(HAVE_INTRIN_H)
# if intrin.h is available we assume __cpuid is there
set(RUNTIME_CPU_CAPABILITY_DETECTION 1 PARENT_SCOPE)
endif()
else()
include(CFeatureCheck)
c_feature_check(CPU_INFO_BY_ASM)
set(CPU_INFO_BY_ASM_SUPPORTED ${CPU_INFO_BY_ASM_SUPPORTED} PARENT_SCOPE)
check_include_file(cpuid.h HAVE_CPUID_H)
if(HAVE_CPUID_H)
c_feature_check(CPU_INFO_BY_C)
set(CPU_INFO_BY_C_SUPPORTED ${CPU_INFO_BY_C_SUPPORTED} PARENT_SCOPE)
endif()
if(CPU_INFO_BY_ASM_SUPPORTED OR CPU_INFO_BY_C_SUPPORTED)
set(RUNTIME_CPU_CAPABILITY_DETECTION 1 PARENT_SCOPE)
endif()
endif()
elseif(OPUS_CPU_ARM)
# ARM cpu detection is implemented for Windows and anything
# using a Linux kernel (such as Android).
if (CMAKE_SYSTEM_NAME MATCHES "(Windows|Linux|Android)")
set(RUNTIME_CPU_CAPABILITY_DETECTION 1 PARENT_SCOPE)
endif ()
else()
set(RUNTIME_CPU_CAPABILITY_DETECTION 0 PARENT_SCOPE)
endif()
+70
View File
@@ -0,0 +1,70 @@
if(__opus_version)
return()
endif()
set(__opus_version INCLUDED)
function(get_package_version PACKAGE_VERSION PROJECT_VERSION)
find_package(Git)
if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git")
execute_process(COMMAND ${GIT_EXECUTABLE}
--git-dir=${CMAKE_CURRENT_LIST_DIR}/.git describe
--tags --match "v*" OUTPUT_VARIABLE OPUS_PACKAGE_VERSION)
if(OPUS_PACKAGE_VERSION)
string(STRIP ${OPUS_PACKAGE_VERSION}, OPUS_PACKAGE_VERSION)
string(REPLACE \n
""
OPUS_PACKAGE_VERSION
${OPUS_PACKAGE_VERSION})
string(REPLACE ,
""
OPUS_PACKAGE_VERSION
${OPUS_PACKAGE_VERSION})
string(SUBSTRING ${OPUS_PACKAGE_VERSION}
1
-1
OPUS_PACKAGE_VERSION)
message(STATUS "Opus package version from git repo: ${OPUS_PACKAGE_VERSION}")
endif()
elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/package_version"
AND NOT OPUS_PACKAGE_VERSION)
# Not a git repo, lets' try to parse it from package_version file if exists
file(STRINGS package_version OPUS_PACKAGE_VERSION
LIMIT_COUNT 1
REGEX "PACKAGE_VERSION=")
string(REPLACE "PACKAGE_VERSION="
""
OPUS_PACKAGE_VERSION
${OPUS_PACKAGE_VERSION})
string(REPLACE "\""
""
OPUS_PACKAGE_VERSION
${OPUS_PACKAGE_VERSION})
# In case we have a unknown dist here we just replace it with 0
string(REPLACE "unknown"
"0"
OPUS_PACKAGE_VERSION
${OPUS_PACKAGE_VERSION})
message(STATUS "Opus package version from package_version file: ${OPUS_PACKAGE_VERSION}")
endif()
if(OPUS_PACKAGE_VERSION)
string(REGEX
REPLACE "^([0-9]+.[0-9]+\\.?([0-9]+)?).*"
"\\1"
OPUS_PROJECT_VERSION
${OPUS_PACKAGE_VERSION})
else()
# fail to parse version from git and package version
message(WARNING "Could not get package version.")
set(OPUS_PACKAGE_VERSION 0)
set(OPUS_PROJECT_VERSION 0)
endif()
message(STATUS "Opus project version: ${OPUS_PROJECT_VERSION}")
set(PACKAGE_VERSION ${OPUS_PACKAGE_VERSION} PARENT_SCOPE)
set(PROJECT_VERSION ${OPUS_PROJECT_VERSION} PARENT_SCOPE)
endfunction()
@@ -1,24 +1,35 @@
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)
get_opus_sources(SILK_SOURCES_X86_RTCD silk_sources.mk silk_sources_x86_rtcd)
get_opus_sources(SILK_SOURCES_SSE4_1 silk_sources.mk silk_sources_sse4_1)
get_opus_sources(SILK_SOURCES_FIXED_SSE4_1 silk_sources.mk
silk_sources_fixed_sse4_1)
get_opus_sources(SILK_SOURCES_ARM_RTCD silk_sources.mk silk_sources_arm_rtcd)
get_opus_sources(SILK_SOURCES_ARM_NEON_INTR silk_sources.mk
silk_sources_arm_neon_intr)
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_X86_RTCD celt_sources.mk celt_sources_x86_rtcd)
get_opus_sources(CELT_SOURCES_SSE celt_sources.mk celt_sources_sse)
get_opus_sources(CELT_SOURCES_SSE2 celt_sources.mk celt_sources_sse2)
get_opus_sources(CELT_SOURCES_SSE4_1 celt_sources.mk celt_sources_sse4_1)
get_opus_sources(CELT_SOURCES_ARM celt_sources.mk celt_sources_arm)
get_opus_sources(CELT_SOURCES_ARM_RTCD celt_sources.mk celt_sources_arm_rtcd)
get_opus_sources(CELT_SOURCES_ARM_ASM celt_sources.mk celt_sources_arm_asm)
get_opus_sources(CELT_AM_SOURCES_ARM_ASM celt_sources.mk
celt_am_sources_arm_asm)
+132
View File
@@ -0,0 +1,132 @@
# Using CMake for the Opus Project
This guide provides instructions for using CMake to build the Opus project with various configuration options. CMake is a widely used build system generator that helps manage the build process across different platforms.
Note: Please keep in mind that software documentation can sometimes go out of date as new versions are released. It is always recommended to refer to the official CMake documentation for the most up-to-date and accurate information. You can find the official CMake documentation at [cmake.org/documentation](https://cmake.org/documentation/).
## Prerequisites
Before proceeding, make sure you have the following prerequisites installed:
- CMake
- Git (optional, but recommended for version control integration)
- Working C compiler
## Build Instructions
Follow the steps below to build the Opus project using CMake:
1. Clone the Opus repository using Git:
```shell
git clone https://gitlab.xiph.org/xiph/opus
```
2. Create a build directory within the Opus repository:
```shell
cd opus
mkdir build
cd build
```
3. Configure the build with CMake. You can set the desired configuration options using CMake's `-D` flag. Here are some available options:
- `OPUS_BUILD_SHARED_LIBRARY`: build shared library.
- `OPUS_BUILD_TESTING`: build tests.
- `OPUS_BUILD_PROGRAMS`: build programs.
- `OPUS_CUSTOM_MODES`, enable non-Opus modes, e.g. 44.1 kHz & 2^n frames.
For example, to enable the custom modes and build programs, use the following command:
```shell
cmake .. -DOPUS_BUILD_PROGRAMS=ON -DOPUS_BUILD_TESTING=ON
```
4. Build the Opus project:
```shell
cmake --build .
```
5. After a successful build, you can find the compiled Opus library and associated files in the build directory.
## Testing with CTest
Opus provides a comprehensive test suite to ensure the functionality and correctness of the project. You can execute the tests using CTest, a part of the CMake build system. CTest allows for automated testing and provides useful features for managing and evaluating the test results.
To run the Opus tests using CTest, follow these steps:
1. Navigate to the build directory after configuring and building the project with CMake:
```shell
cd build
```
2. Execute the tests using CTest:
```shell
ctest
```
Note: For Windows you need to specify which configuration to test
```shell
ctest -C Debug
```
## Platform Support and Bug Reporting
CMake aims to provide broad platform support, allowing the Opus project to be built and used on major operating systems and platforms. The supported platforms include:
- Windows
- macOS
- Linux
- Android
- iOS
CMake achieves platform support by generating platform-specific build files (e.g., Makefiles, Visual Studio projects) based on the target platform. This allows developers to build and configure the Opus project consistently across different operating systems and environments.
While CMake strives to ensure compatibility and stability across platforms, bugs or issues may still arise in specific configurations. If you encounter any problems during the configuration process or while building the Opus project, we encourage you to file an issue in the [project's issue tracker](https://gitlab.xiph.org/xiph/opus/-/issues).
When reporting an issue, please provide the following information to help us understand and reproduce the configuration problem effectively:
1. Detailed description of the issue, including any error messages or unexpected behavior observed.
2. Steps to reproduce the problem, including the CMake command and any specific configuration options used.
3. Operating system and version (e.g., Windows 10, macOS Big Sur, Ubuntu 20.04).
4. CMake version (e.g., CMake 3.21.1).
5. Any relevant information about the platform, toolchain, or dependencies used.
6. Additional context or details that might assist in troubleshooting the issue.
By providing thorough information when reporting configuration issues, you contribute to improving the Opus project's compatibility and reliability across different platforms.
We appreciate your help in identifying and addressing any configuration-related problems, ensuring a better experience for all users of the Opus project.
## Platform Specific Examples
Note: Examples can go out of date. Always refer to documentation for latest reference.
### Cross compiling for Android
```shell
cmake .. -DCMAKE_TOOLCHAIN_FILE=${ANDROID_HOME}/ndk/25.2.9519653/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a
```
For more information about cross compiling for android, you can refer to the [Cross compiling for Android documentation](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-android).
### Cross compiling for iOS
```shell
cmake .. -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64
```
For more information about cross compilation for iOS, you can refer to the [Cross compiling for iOS documentation](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-or-watchos).
### Windows Visual Studio
```shell
cmake .. -G "Visual Studio 17 2022" -A x64
```
For more information about the Visual Studio generator options and additional customization, you can refer to the [Visual Studio Generator documentation](https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2017%202022.html).
+61
View File
@@ -0,0 +1,61 @@
if(NOT EXISTS ${TEST_EXECUTABLE})
message(FATAL_ERROR "Error could not find ${TEST_EXECUTABLE}, ensure that you built the test binary")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
# support to run plain old binary on android devices
# requires android debug bridge to be installed
find_program(adb_executable adb)
if(NOT adb_executable)
message(FATAL_ERROR "Error could not find adb")
endif()
# check if any device emulator is attached
execute_process(COMMAND ${adb_executable} shell echo RESULT_VARIABLE CMD_RESULT)
if(CMD_RESULT)
message(FATAL_ERROR "Error adb: no devices/emulators found")
endif()
# push binary
set(android_path /data/local/tmp)
execute_process(COMMAND ${adb_executable} push ${TEST_EXECUTABLE} ${android_path} RESULT_VARIABLE CMD_RESULT)
if(CMD_RESULT)
message(FATAL_ERROR "Error running ${adb_executable} push ${TEST_EXECUTABLE} ${android_path} failed with result ${CMD_RESULT}")
endif()
# set permissions
get_filename_component(test_executable ${TEST_EXECUTABLE} NAME)
set(test_executable_on_android /data/local/tmp/${test_executable})
execute_process(COMMAND ${adb_executable} shell chmod 555 ${test_executable_on_android} RESULT_VARIABLE CMD_RESULT)
if(CMD_RESULT)
message(FATAL_ERROR "Error running ${adb_executable} shell chmod 555 ${test_executable_on_android} failed with result ${CMD_RESULT}")
endif()
# run executable
execute_process(COMMAND ${adb_executable} shell ${test_executable_on_android} RESULT_VARIABLE CMD_RESULT)
if(CMD_RESULT)
message(FATAL_ERROR "Error running ${adb_executable} shell ${test_executable_on_android} failed with result ${CMD_RESULT}")
endif()
# clean up binary
execute_process(COMMAND ${adb_executable} shell rm ${test_executable_on_android} RESULT_VARIABLE CMD_RESULT)
if(CMD_RESULT)
message(FATAL_ERROR "Error running ${adb_executable} shell rm ${test_executable_on_android} failed with result ${CMD_RESULT}")
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
# CTest doesn't support iOS
message(FATAL_ERROR "Error CTest is not supported on iOS")
else()
# for other platforms just execute test binary on host
execute_process(COMMAND ${TEST_EXECUTABLE} RESULT_VARIABLE CMD_RESULT)
if(CMD_RESULT)
message(FATAL_ERROR "Error running ${TEST_EXECUTABLE} failed with result ${CMD_RESULT}")
endif()
endif()
File renamed without changes.
+31
View File
@@ -0,0 +1,31 @@
#include <stdio.h>
int main() {
unsigned int CPUInfo0;
unsigned int CPUInfo1;
unsigned int CPUInfo2;
unsigned int CPUInfo3;
unsigned int InfoType;
#if defined(__i386__) && defined(__PIC__)
/* %ebx is PIC register in 32-bit, so mustn't clobber it. */
__asm__ __volatile__ (
"xchg %%ebx, %1\n"
"cpuid\n"
"xchg %%ebx, %1\n":
"=a" (CPUInfo0),
"=r" (CPUInfo1),
"=c" (CPUInfo2),
"=d" (CPUInfo3) :
"0" (InfoType), "2" (0)
);
#else
__asm__ __volatile__ (
"cpuid":
"=a" (CPUInfo0),
"=b" (CPUInfo1),
"=c" (CPUInfo2),
"=d" (CPUInfo3) :
"0" (InfoType), "2" (0)
);
#endif
return 0;
}
+9
View File
@@ -0,0 +1,9 @@
#include <cpuid.h>
int main() {
unsigned int CPUInfo0;
unsigned int CPUInfo1;
unsigned int CPUInfo2;
unsigned int CPUInfo3;
unsigned int InfoType;
return __get_cpuid_count(InfoType, 0, &CPUInfo0, &CPUInfo1, &CPUInfo2, &CPUInfo3);
}
+7
View File
@@ -0,0 +1,7 @@
int main() {
static int x;
char a[++x];
a[sizeof a - 1] = 0;
int N;
return a[0];
}
+21 -3
View File
@@ -22,9 +22,9 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# For libtool.
dnl Please update these for releases.
OPUS_LT_CURRENT=8
OPUS_LT_CURRENT=9
OPUS_LT_REVISION=0
OPUS_LT_AGE=8
OPUS_LT_AGE=9
AC_SUBST(OPUS_LT_CURRENT)
AC_SUBST(OPUS_LT_REVISION)
@@ -195,6 +195,7 @@ AC_ARG_ENABLE([intrinsics],
rtcd_support=no
cpu_arm=no
cpu_x86=no
AS_IF([test x"${enable_asm}" = x"yes"],[
inline_optimization="No inline ASM for your platform, please send patches"
@@ -535,6 +536,7 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[
],
[i?86|x86_64],
[
cpu_x86=yes
OPUS_CHECK_INTRINSICS(
[SSE],
[$X86_SSE_CFLAGS],
@@ -691,6 +693,18 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[
unsigned int CPUInfo2;
unsigned int CPUInfo3;
unsigned int InfoType;
#if defined(__i386__) && defined(__PIC__)
__asm__ __volatile__ (
"xchg %%ebx, %1\n"
"cpuid\n"
"xchg %%ebx, %1\n":
"=a" (CPUInfo0),
"=r" (CPUInfo1),
"=c" (CPUInfo2),
"=d" (CPUInfo3) :
"a" (InfoType), "c" (0)
);
#else
__asm__ __volatile__ (
"cpuid":
"=a" (CPUInfo0),
@@ -699,6 +713,7 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[
"=d" (CPUInfo3) :
"a" (InfoType), "c" (0)
);
#endif
]])],
[get_cpuid_by_asm="yes"
AC_MSG_RESULT([Inline Assembly])
@@ -711,7 +726,7 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[
unsigned int CPUInfo2;
unsigned int CPUInfo3;
unsigned int InfoType;
__get_cpuid(InfoType, &CPUInfo0, &CPUInfo1, &CPUInfo2, &CPUInfo3);
__get_cpuid_count(InfoType, 0, &CPUInfo0, &CPUInfo1, &CPUInfo2, &CPUInfo3);
]])],
[AC_MSG_RESULT([C method])
AC_DEFINE([CPU_INFO_BY_C], [1], [Get CPU Info by c method])],
@@ -731,6 +746,7 @@ AM_CONDITIONAL([HAVE_ARM_NEON_INTR],
[test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"])
AM_CONDITIONAL([HAVE_ARM_NE10],
[test x"$HAVE_ARM_NE10" = x"1"])
AM_CONDITIONAL([CPU_X86], [test "$cpu_x86" = "yes"])
AM_CONDITIONAL([HAVE_SSE],
[test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"])
AM_CONDITIONAL([HAVE_SSE2],
@@ -740,6 +756,8 @@ AM_CONDITIONAL([HAVE_SSE4_1],
AM_CONDITIONAL([HAVE_AVX],
[test x"$OPUS_X86_MAY_HAVE_AVX" = x"1"])
AM_CONDITIONAL([HAVE_RTCD],
[test x"$enable_rtcd" = x"yes" -a x"$rtcd_support" != x"no"])
AS_IF([test x"$enable_rtcd" = x"yes"],[
AS_IF([test x"$rtcd_support" != x"no"],[
AC_DEFINE([OPUS_HAVE_RTCD], [1],
+11 -6
View File
@@ -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,15 @@ 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@
# move docs to the correct place
OUTPUT_DIRECTORY = @top_builddir@/doc
+10 -1
View File
@@ -48,7 +48,16 @@ mkdir "${destdir}/src"
mkdir "${destdir}/silk"
mkdir "${destdir}/silk/float"
mkdir "${destdir}/silk/fixed"
mkdir "${destdir}/silk/fixed/x86"
mkdir "${destdir}/silk/fixed/arm"
mkdir "${destdir}/silk/fixed/mips"
mkdir "${destdir}/silk/x86"
mkdir "${destdir}/silk/arm"
mkdir "${destdir}/silk/mips"
mkdir "${destdir}/celt"
mkdir "${destdir}/celt/x86"
mkdir "${destdir}/celt/arm"
mkdir "${destdir}/celt/mips"
mkdir "${destdir}/include"
for f in `cat "${toplevel}"/opus_sources.mk "${toplevel}"/celt_sources.mk \
"${toplevel}"/silk_sources.mk "${toplevel}"/opus_headers.mk \
@@ -82,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 [[ ! -d ../opus_testvectors ]] ; then
if [ ! -d ../opus_testvectors ] ; then
echo "Downloading test vectors..."
wget 'http://opus-codec.org/testvectors/opus_testvectors.tar.gz'
tar -C .. -xvzf opus_testvectors.tar.gz
+1 -1
View File
@@ -46,5 +46,5 @@ cat ${HTML} | sed -e 's/ *$//g' > ${HTML}+ && mv ${HTML}+ ${HTML}
cat ${CSS} | sed -e 's/ *$//g' > ${CSS}+ && mv ${CSS}+ ${CSS}
VERSION=$(fgrep Version ${HTML} | sed 's/.*Version \([0-9]\.[0-9]\.[0-9]\).*/\1/')
VERSION=$(grep -F Version ${HTML} | sed 's/.*Version \([0-9]\.[0-9]\.[0-9]\).*/\1/')
echo Now at version ${VERSION}
+6 -2
View File
@@ -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>
+12 -5
View File
@@ -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 -->
+33
View File
@@ -0,0 +1,33 @@
have_dot = find_program('dot', required: false).found()
doxyfile_conf = configuration_data()
doxyfile_conf.set('VERSION', opus_version)
doxyfile_conf.set('HAVE_DOT', have_dot)
doxyfile_conf.set('top_srcdir', top_srcdir)
doxyfile_conf.set('top_builddir', top_builddir)
doxyfile = configure_file(input: 'Doxyfile.in',
output: 'Doxyfile',
configuration: doxyfile_conf,
install: false)
docdir = join_paths(get_option('datadir'), get_option('docdir'))
doc_inputs = [
'customdoxygen.css',
'footer.html',
'header.html',
'opus_logo.svg',
top_srcdir + '/include/opus.h',
top_srcdir + '/include/opus_multistream.h',
top_srcdir + '/include/opus_defines.h',
top_srcdir + '/include/opus_types.h',
top_srcdir + '/include/opus_custom.h',
]
custom_target('doc',
input: [ doxyfile ] + doc_inputs,
output: [ 'html' ],
command: [ doxygen, doxyfile ],
install_dir: docdir,
install: true)
+2 -2
View File
@@ -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 ==
+15 -4
View File
@@ -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);
+13
View File
@@ -0,0 +1,13 @@
opus_headers = [
'opus.h',
'opus_multistream.h',
'opus_projection.h',
'opus_types.h',
'opus_defines.h',
]
if opt_custom_modes
opus_headers += ['opus_custom.h']
endif
install_headers(opus_headers, subdir: 'opus')
+2 -2
View File
@@ -198,7 +198,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT int opus_encoder_get_size(int channels);
* This must be one of 8000, 12000, 16000,
* 24000, or 48000.
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal
* @param [in] application <tt>int</tt>: Coding mode (@ref OPUS_APPLICATION_VOIP/@ref OPUS_APPLICATION_AUDIO/@ref OPUS_APPLICATION_RESTRICTED_LOWDELAY)
* @param [in] application <tt>int</tt>: Coding mode (one of @ref OPUS_APPLICATION_VOIP, @ref OPUS_APPLICATION_AUDIO, or @ref OPUS_APPLICATION_RESTRICTED_LOWDELAY)
* @param [out] error <tt>int*</tt>: @ref opus_errorcodes
* @note Regardless of the sampling rate and number channels selected, the Opus encoder
* can switch to a lower audio bandwidth or number of channels if the bitrate
@@ -222,7 +222,7 @@ OPUS_EXPORT OPUS_WARN_UNUSED_RESULT OpusEncoder *opus_encoder_create(
* This must be one of 8000, 12000, 16000,
* 24000, or 48000.
* @param [in] channels <tt>int</tt>: Number of channels (1 or 2) in input signal
* @param [in] application <tt>int</tt>: Coding mode (OPUS_APPLICATION_VOIP/OPUS_APPLICATION_AUDIO/OPUS_APPLICATION_RESTRICTED_LOWDELAY)
* @param [in] application <tt>int</tt>: Coding mode (one of OPUS_APPLICATION_VOIP, OPUS_APPLICATION_AUDIO, or OPUS_APPLICATION_RESTRICTED_LOWDELAY)
* @retval #OPUS_OK Success or @ref opus_errorcodes
*/
OPUS_EXPORT int opus_encoder_init(
+4 -3
View File
@@ -104,7 +104,8 @@ typedef struct OpusCustomDecoder OpusCustomDecoder;
/** The mode contains all the information necessary to create an
encoder. Both the encoder and decoder need to be initialized
with exactly the same mode, otherwise the output will be
corrupted.
corrupted. The mode MUST NOT BE DESTROYED until the encoders and
decoders that use it are destroyed as well.
@brief Mode configuration
*/
typedef struct OpusCustomMode OpusCustomMode;
@@ -178,7 +179,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 +287,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);
+5 -3
View File
@@ -64,7 +64,7 @@ extern "C" {
/**Export control for opus functions */
#ifndef OPUS_EXPORT
# if defined(WIN32)
# if defined(_WIN32)
# if defined(OPUS_BUILD) && defined(DLL_EXPORT)
# define OPUS_EXPORT __declspec(dllexport)
# else
@@ -482,7 +482,8 @@ extern "C" {
* @param[in] x <tt>opus_int32</tt>: Allowed values:
* <dl>
* <dt>0</dt><dd>Disable inband FEC (default).</dd>
* <dt>1</dt><dd>Enable inband FEC.</dd>
* <dt>1</dt><dd>Inband FEC enabled. If the packet loss rate is sufficiently high, Opus will automatically switch to SILK even at high rates to enable use of that FEC.</dd>
* <dt>2</dt><dd>Inband FEC enabled, but does not necessarily switch to SILK if we have music.</dd>
* </dl>
* @hideinitializer */
#define OPUS_SET_INBAND_FEC(x) OPUS_SET_INBAND_FEC_REQUEST, __opus_check_int(x)
@@ -491,7 +492,8 @@ extern "C" {
* @param[out] x <tt>opus_int32 *</tt>: Returns one of the following values:
* <dl>
* <dt>0</dt><dd>Inband FEC disabled (default).</dd>
* <dt>1</dt><dd>Inband FEC enabled.</dd>
* <dt>1</dt><dd>Inband FEC enabled. If the packet loss rate is sufficiently high, Opus will automatically switch to SILK even at high rates to enable use of that FEC.</dd>
* <dt>2</dt><dd>Inband FEC enabled, but does not necessarily switch to SILK if we have music.</dd>
* </dl>
* @hideinitializer */
#define OPUS_GET_INBAND_FEC(x) OPUS_GET_INBAND_FEC_REQUEST, __opus_check_int_ptr(x)
+675
View File
@@ -0,0 +1,675 @@
project('opus', 'c',
version: run_command('meson/get-version.py', '--package-version', check: true).stdout().strip(),
meson_version: '>=0.54.0',
default_options: ['warning_level=2',
'c_std=gnu99',
'buildtype=debugoptimized'])
libversion = run_command('meson/get-version.py', '--libtool-version', check: true).stdout().strip()
macosversion = run_command('meson/get-version.py', '--darwin-version', check: true).stdout().strip()
cc = meson.get_compiler('c')
host_system = host_machine.system()
host_cpu_family = host_machine.cpu_family()
top_srcdir = meson.current_source_dir()
top_builddir = meson.current_build_dir()
opus_includes = include_directories('.', 'include', 'celt', 'silk')
opus_public_includes = include_directories('include')
add_project_arguments('-DOPUS_BUILD', language: 'c')
add_project_arguments('-DHAVE_CONFIG_H', language: 'c')
if host_system == 'windows'
if cc.get_argument_syntax() == 'msvc'
add_project_arguments('-D_CRT_SECURE_NO_WARNINGS', language: 'c')
endif
endif
if cc.get_argument_syntax() == 'gnu'
add_project_arguments('-D_FORTIFY_SOURCE=2', language: 'c')
endif
# Check for extra compiler args
additional_c_args = []
if cc.get_argument_syntax() != 'msvc'
additional_c_args += [
'-fvisibility=hidden',
'-Wcast-align',
'-Wnested-externs',
'-Wshadow',
'-Wstrict-prototypes',
]
# On Windows, -fstack-protector-strong adds a libssp-0.dll dependency and
# prevents static linking
if host_system != 'windows'
additional_c_args += ['-fstack-protector-strong']
endif
endif
foreach arg : additional_c_args
if cc.has_argument(arg)
add_project_arguments(arg, language: 'c')
endif
endforeach
# Windows MSVC warnings
if cc.get_id() == 'msvc'
# Ignore several spurious warnings.
# If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
# If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
# NOTE: Only add warnings here if you are sure they're spurious
add_project_arguments('/wd4035', '/wd4715', '/wd4116', '/wd4046', '/wd4068',
'/wd4820', '/wd4244', '/wd4255', '/wd4668',
language : 'c')
endif
opus_version = meson.project_version()
opus_conf = configuration_data()
opus_conf.set('PACKAGE_BUGREPORT', '"[email protected]"')
opus_conf.set('PACKAGE_NAME', '"opus"')
opus_conf.set('PACKAGE_STRING', '"opus @0@"'.format(opus_version))
opus_conf.set('PACKAGE_TARNAME', '"opus"')
opus_conf.set('PACKAGE_URL', '""')
opus_conf.set('PACKAGE_VERSION', '"@0@"'.format(opus_version))
# FIXME: optional Ne10 dependency
have_arm_ne10 = false
libm = cc.find_library('m', required : false)
opus_conf.set('HAVE_LRINTF', cc.has_function('lrintf', prefix: '#include <math.h>', dependencies: libm))
opus_conf.set('HAVE_LRINT', cc.has_function('lrint', prefix: '#include <math.h>', dependencies: libm))
opus_conf.set('HAVE___MALLOC_HOOK', cc.has_function('__malloc_hook', prefix: '#include <malloc.h>'))
opus_conf.set('HAVE_STDINT_H', cc.check_header('stdint.h'))
# Check for restrict keyword
restrict_tmpl = '''
typedef int * int_ptr;
int foo (int_ptr @0@ ip, int * @0@ baz[]) {
return ip[0];
}
int main (int argc, char ** argv) {
int s[1];
int * @0@ t = s;
t[0] = 0;
return foo(t, (void *)0);
}'''
# Define restrict to the equivalent of the C99 restrict keyword, or to
# nothing if this is not supported. Do not define if restrict is
# supported directly.
if not cc.compiles(restrict_tmpl.format('restrict'), name : 'restrict keyword')
if cc.compiles(restrict_tmpl.format('__restrict'), name : '__restrict')
opus_conf.set('restrict', '__restrict')
elif cc.compiles(restrict_tmpl.format('__restrict__'), name : '__restrict__')
opus_conf.set('restrict', '__restrict')
elif cc.compiles(restrict_tmpl.format('_Restrict'), name : '_Restrict')
opus_conf.set('restrict', '_Restrict')
else
opus_conf.set('restrict', '/**/')
endif
endif
# Check for C99 variable-size arrays, or alloca() as fallback
msg_use_alloca = false
if cc.compiles('''static int x;
char some_func (void) {
char a[++x];
a[sizeof a - 1] = 0;
int N;
return a[0];
}''', name : 'C99 variable-size arrays')
opus_conf.set('VAR_ARRAYS', 1)
msg_use_alloca = 'NO (using C99 variable-size arrays instead)'
elif cc.compiles('''#include <alloca.h>
void some_func (void) {
int foo=10;
int * array = alloca(foo);
}''', name : 'alloca (alloca.h)')
opus_conf.set('USE_ALLOCA', true)
opus_conf.set('HAVE_ALLOCA_H', true)
msg_use_alloca = true
elif cc.compiles('''#include <malloc.h>
#include <stdlib.h>
void some_func (void) {
int foo=10;
int * array = alloca(foo);
}''', name : 'alloca (std)')
opus_conf.set('USE_ALLOCA', true)
msg_use_alloca = true
endif
opts = [
[ 'fixed-point', 'FIXED_POINT' ],
[ 'fixed-point-debug', 'FIXED_DEBUG' ],
[ 'custom-modes', 'CUSTOM_MODES' ],
[ 'float-approx', 'FLOAT_APPROX' ],
[ 'assertions', 'ENABLE_ASSERTIONS' ],
[ 'hardening', 'ENABLE_HARDENING' ],
[ 'fuzzing', 'FUZZING' ],
[ 'check-asm', 'OPUS_CHECK_ASM' ],
]
foreach opt : opts
# we assume these are all boolean options
opt_foo = get_option(opt[0])
if opt_foo
opus_conf.set(opt[1], 1)
endif
set_variable('opt_' + opt[0].underscorify(), opt_foo)
endforeach
opt_asm = get_option('asm')
opt_rtcd = get_option('rtcd')
opt_intrinsics = get_option('intrinsics')
extra_programs = get_option('extra-programs')
opt_tests = get_option('tests')
disable_float_api = not get_option('float-api')
if disable_float_api
opus_conf.set('DISABLE_FLOAT_API', 1)
endif
# This is for the description in the pkg-config .pc file
if opt_fixed_point
pc_build = 'fixed-point'
else
pc_build = 'floating-point'
endif
if opt_custom_modes
pc_build = pc_build + ', custom modes'
endif
rtcd_support = []
# With GCC, Clang, ICC, etc, we differentiate between 'may support this SIMD'
# and 'presume we have this SIMD' by checking whether the SIMD / intrinsics can
# be compiled by the compiler as-is (presume) or with SIMD cflags (may have).
# With MSVC, the compiler will always build SIMD/intrinsics targeting all
# specific instruction sets supported by that version of the compiler. No
# special arguments are ever needed. If runtime CPU detection is not disabled,
# we must always assume that we only 'may have' it.
opus_can_presume_simd = true
if cc.get_argument_syntax() == 'msvc'
if opt_rtcd.disabled()
warning('Building with an MSVC-like compiler and runtime CPU detection is disabled. Outputs may not run on all @0@ CPUs.'.format(host_cpu_family))
else
opus_can_presume_simd = false
endif
endif
opus_arm_external_asm = false
asm_tmpl = '''
int main (int argc, char ** argv) {
__asm__("@0@");
return 0;
}'''
asm_optimization = []
inline_optimization = []
if not opt_asm.disabled()
# Currently we only have inline asm for fixed-point
if host_cpu_family == 'arm' and opt_fixed_point
opus_conf.set('OPUS_ARM_ASM', true)
# Check if compiler supports gcc-style inline assembly
if cc.compiles('''#ifdef __GNUC_MINOR__
#if (__GNUC__ * 1000 + __GNUC_MINOR__) < 3004
#error GCC before 3.4 has critical bugs compiling inline assembly
#endif
#endif
__asm__ (""::)''',
name : 'compiler supports gcc-style inline assembly')
opus_conf.set('OPUS_ARM_INLINE_ASM', 1)
# AS_ASM_ARM_EDSP
if cc.compiles(asm_tmpl.format('qadd r3,r3,r3'),
name : 'assembler supports EDSP instructions on ARM')
opus_conf.set('OPUS_ARM_INLINE_EDSP', 1)
inline_optimization += ['ESDP']
endif
# AS_ASM_ARM_MEDIA
if cc.compiles(asm_tmpl.format('shadd8 r3,r3,r3'),
name : 'assembler supports ARMv6 media instructions on ARM')
opus_conf.set('OPUS_ARM_INLINE_MEDIA', 1)
inline_optimization += ['Media']
endif
# AS_ASM_ARM_NEON
if cc.compiles(asm_tmpl.format('vorr d0,d0,d0'),
name : 'assembler supports NEON instructions on ARM')
opus_conf.set('OPUS_ARM_INLINE_NEON', 1)
inline_optimization += ['NEON']
endif
endif
# We need Perl to translate RVCT-syntax asm to gas syntax
perl = find_program('perl', required: get_option('asm'))
if perl.found()
opus_arm_external_asm = true
# opus_arm_presume_* mean we can and will use those instructions
# directly without doing runtime CPU detection.
# opus_arm_may_have_* mean we can emit those instructions, but we can
# only use them after runtime detection.
# The same rules apply for x86 assembly and intrinsics.
opus_arm_may_have_edsp = opus_conf.has('OPUS_ARM_INLINE_EDSP')
opus_arm_presume_edsp = opus_arm_may_have_edsp and opus_can_presume_simd
opus_arm_may_have_media = opus_conf.has('OPUS_ARM_INLINE_MEDIA')
opus_arm_presume_media = opus_arm_may_have_media and opus_can_presume_simd
opus_arm_may_have_neon = opus_conf.has('OPUS_ARM_INLINE_NEON')
opus_arm_presume_neon = opus_arm_may_have_neon and opus_can_presume_simd
if not opt_rtcd.disabled()
if not opus_arm_may_have_edsp
message('Trying to force-enable armv5e EDSP instructions...')
# AS_ASM_ARM_EDSP_FORCE
opus_arm_may_have_edsp = cc.compiles(asm_tmpl.format('.arch armv5te\n.object_arch armv4t\nqadd r3,r3,r3'),
name : 'Assembler supports EDSP instructions on ARM (forced)')
endif
if not opus_arm_may_have_media
message('Trying to force-enable ARMv6 media instructions...')
opus_arm_may_have_media = cc.compiles(asm_tmpl.format('.arch armv6\n.object_arch armv4t\nshadd8 r3,r3,r3'),
name : 'Assembler supports ARMv6 media instructions on ARM (forced)')
endif
if not opus_arm_may_have_neon
message('Trying to force-enable NEON instructions...')
opus_arm_may_have_neon = cc.compiles(asm_tmpl.format('.arch armv7-a\n.fpu neon\n.object_arch armv4t\nvorr d0,d0,d0'),
name : 'Assembler supports NEON instructions on ARM (forced)')
endif
endif
if opus_arm_may_have_edsp
opus_conf.set('OPUS_ARM_MAY_HAVE_EDSP', 1)
if opus_arm_presume_edsp
opus_conf.set('OPUS_ARM_PRESUME_EDSP', 1)
asm_optimization += ['EDSP']
else
rtcd_support += ['EDSP']
endif
endif
if opus_arm_may_have_media
opus_conf.set('OPUS_ARM_MAY_HAVE_MEDIA', 1)
if opus_arm_presume_media
opus_conf.set('OPUS_ARM_PRESUME_MEDIA', 1)
asm_optimization += ['Media']
else
rtcd_support += ['Media']
endif
endif
if opus_arm_may_have_neon
opus_conf.set('OPUS_ARM_MAY_HAVE_NEON', 1)
if opus_arm_presume_neon
opus_conf.set('OPUS_ARM_PRESUME_NEON', 1)
asm_optimization += ['NEON']
else
rtcd_support += ['NEON']
endif
endif
if cc.get_define('__APPLE__')
arm2gnu_args = ['--apple']
else
arm2gnu_args = []
endif
endif # found perl
else # arm + enable fixed point
if opt_asm.enabled()
error('asm option is enabled, but no assembly support for ' + host_cpu_family)
endif
endif
endif # enable asm
# Check whether we require assembly and we support assembly on this arch,
# but none were detected. Can happen because of incorrect compiler flags, such
# as missing -mfloat-abi=softfp on ARM32 softfp architectures.
if opt_asm.enabled() and (asm_optimization.length() + inline_optimization.length()) == 0
error('asm option was enabled, but no assembly support was detected')
endif
# XXX: NEON has hardfp vs softfp compiler configuration issues
# When targeting ARM32 softfp, we sometimes need to explicitly pass
# -mfloat-abi=softfp to enable NEON. F.ex., on Android. It should
# be set in the cross file.
arm_neon_intr_link_args = ['-mfpu=neon']
have_sse = false
have_sse2 = false
have_sse4_1 = false
have_avx = false # no avx opus code yet
have_neon_intr = false
intrinsics_support = []
if not opt_intrinsics.disabled()
if host_cpu_family in ['arm', 'aarch64']
# Check for ARMv7/AArch64 neon intrinsics
intrin_check = '''
#include <arm_neon.h>
int main (void) {
static float32x4_t A0, A1, SUMM;
SUMM = vmlaq_f32(SUMM, A0, A1);
return (int)vgetq_lane_f32(SUMM, 0);
}'''
intrin_name = 'ARMv7/AArch64 NEON'
if cc.links(intrin_check,
name: 'compiler supports @0@ intrinsics'.format(intrin_name))
opus_arm_presume_neon_intr = opus_can_presume_simd
opus_arm_may_have_neon_intr = true
else
opus_arm_presume_neon_intr = false
if cc.links(intrin_check,
args: arm_neon_intr_link_args,
name: 'compiler supports @0@ intrinsics with @1@'.format(intrin_name, ' '.join(arm_neon_intr_link_args)))
opus_arm_may_have_neon_intr = true
else
opus_arm_may_have_neon_intr = false
endif
endif
if opus_arm_may_have_neon_intr
have_neon_intr = true
intrinsics_support += [intrin_name]
opus_conf.set('OPUS_ARM_MAY_HAVE_NEON_INTR', 1)
if opus_arm_presume_neon_intr
opus_conf.set('OPUS_ARM_PRESUME_NEON_INTR', 1)
else
rtcd_support += [intrin_name]
opus_neon_intr_args = arm_neon_intr_link_args
endif
else
message('Compiler does not support @0@ intrinsics'.format(intrin_name))
endif
# Check for aarch64 neon intrinsics
intrin_check = '''
#include <arm_neon.h>
int main (void) {
static int32_t IN;
static int16_t OUT;
OUT = vqmovns_s32(IN);
}'''
intrin_name = 'AArch64 NEON'
if cc.links(intrin_check,
name: 'compiler supports @0@ intrinsics'.format(intrin_name))
opus_arm_presume_aarch64_neon_intr = opus_can_presume_simd
opus_arm_may_have_aarch64_neon_intr = true
else
opus_arm_presume_aarch64_neon_intr = false
if cc.links(intrin_check,
args: arm_neon_intr_link_args,
name: 'compiler supports @0@ intrinsics with @1@'.format(intrin_name, ' '.join(arm_neon_intr_link_args)))
opus_arm_may_have_aarch64_neon_intr = true
else
opus_arm_may_have_aarch64_neon_intr = false
endif
endif
if opus_arm_may_have_aarch64_neon_intr
intrinsics_support += [intrin_name]
opus_conf.set('OPUS_X86_MAY_HAVE_AARCH64_NEON_INTR', 1)
if opus_arm_presume_aarch64_neon_intr
opus_conf.set('OPUS_X86_PRESUME_AARCH64_NEON_INTR', 1)
endif
else
message('Compiler does not support @0@ intrinsics'.format(intrin_name))
endif
elif host_cpu_family in ['x86', 'x86_64']
# XXX: allow external override/specification of the flags
x86_intrinsics = [
[ 'SSE', 'xmmintrin.h', '__m128', '_mm_setzero_ps()', ['-msse'] ],
[ 'SSE2', 'emmintrin.h', '__m128i', '_mm_setzero_si128()', ['-msse2'] ],
[ 'SSE4.1', 'smmintrin.h', '__m128i', '_mm_setzero_si128(); mtest = _mm_cmpeq_epi64(mtest, mtest)', ['-msse4.1'] ],
[ 'AVX', 'immintrin.h', '__m256', '_mm256_setzero_ps()', ['-mavx'] ],
]
foreach intrin : x86_intrinsics
intrin_check = '''#include <@0@>
int main (int argc, char ** argv) {
static @1@ mtest;
mtest = @2@;
return *((unsigned char *) &mtest) != 0;
}'''.format(intrin[1],intrin[2],intrin[3])
intrin_name = intrin[0]
# Intrinsics arguments are not available with MSVC-like compilers
intrin_args = cc.get_argument_syntax() == 'msvc' ? [] : intrin[4]
if cc.links(intrin_check, name : 'compiler supports @0@ intrinsics'.format(intrin_name))
may_have_intrin = true
presume_intrin = opus_can_presume_simd
elif intrin_args.length() > 0
presume_intrin = false
if cc.links(intrin_check,
args : intrin_args,
name : 'compiler supports @0@ intrinsics with @1@'.format(intrin_name, ' '.join(intrin_args)))
may_have_intrin = true
else
may_have_intrin = false
endif
endif
if may_have_intrin
intrinsics_support += [intrin_name]
intrin_lower_name = intrin_name.to_lower().underscorify()
set_variable('have_' + intrin_lower_name, true)
opus_conf.set('OPUS_X86_MAY_HAVE_' + intrin_name.underscorify(), 1)
if presume_intrin
opus_conf.set('OPUS_X86_PRESUME_' + intrin_name.underscorify(), 1)
else
rtcd_support += [intrin_name]
set_variable('opus_@0@_args'.format(intrin_lower_name), intrin_args)
endif
else
message('Compiler does not support @0@ intrinsics'.format(intrin_name))
endif
endforeach
if not opt_rtcd.disabled()
get_cpuid_by_asm = false
cpuid_asm_code = '''
#include <stdio.h>
int main (int argc, char ** argv) {
unsigned int CPUInfo0;
unsigned int CPUInfo1;
unsigned int CPUInfo2;
unsigned int CPUInfo3;
unsigned int InfoType;
#if defined(__i386__) && defined(__PIC__)
__asm__ __volatile__ (
"xchg %%ebx, %1\n"
"cpuid\n"
"xchg %%ebx, %1\n":
"=a" (CPUInfo0),
"=r" (CPUInfo1),
"=c" (CPUInfo2),
"=d" (CPUInfo3) :
"a" (InfoType), "c" (0)
);
#else
__asm__ __volatile__ (
"cpuid":
"=a" (CPUInfo0),
"=b" (CPUInfo1),
"=c" (CPUInfo2),
"=d" (CPUInfo3) :
"a" (InfoType), "c" (0)
);
#endif
return 0;
}'''
cpuid_c_code = '''
#include <cpuid.h>
int main (int argc, char ** argv) {
unsigned int CPUInfo0;
unsigned int CPUInfo1;
unsigned int CPUInfo2;
unsigned int CPUInfo3;
unsigned int InfoType;
__get_cpuid(InfoType, &CPUInfo0, &CPUInfo1, &CPUInfo2, &CPUInfo3);
return 0;
}'''
cpuid_msvc_code = '''
#include <intrin.h>
int main (void) {
int CPUInfo, InfoType;
__cpuid(&CPUInfo, InfoType);
}'''
if cc.links(cpuid_asm_code, name : 'Get X86 CPU info via inline assembly')
opus_conf.set('CPU_INFO_BY_ASM', 1)
elif cc.links(cpuid_c_code, name : 'Get X86 CPU info via C method')
opus_conf.set('CPU_INFO_BY_C', 1)
elif cc.get_define('_MSC_VER') != '' and cc.links(cpuid_msvc_code)
message('Getting X86 CPU info via __cpuid')
else
if opt_intrinsics.enabled() and opt_rtcd.enabled()
error('intrinsics and rtcd options are enabled, but no Get CPU Info method detected')
endif
warning('Get CPU Info method not detected, no rtcd for intrinsics')
endif
endif # opt_rtcd
else
if opt_intrinsics.enabled()
error('intrinsics option enabled, but no intrinsics support for ' + host_cpu_family)
endif
warning('No intrinsics support for ' + host_cpu_family)
endif
endif
# Check whether we require intrinsics and we support intrinsics on this arch,
# but none were detected. Can happen because of incorrect compiler flags, such
# as missing -mfloat-abi=softfp on ARM32 softfp architectures.
if opt_intrinsics.enabled() and intrinsics_support.length() == 0
error('intrinsics option was enabled, but none were detected')
endif
if opt_rtcd.disabled()
rtcd_support = 'disabled'
else
if rtcd_support.length() > 0
opus_conf.set('OPUS_HAVE_RTCD', 1)
else
if intrinsics_support.length() == 0
rtcd_support = 'none'
if opt_rtcd.enabled()
error('rtcd option is enabled, but no support for intrinsics or assembly is available')
endif
else
rtcd_support = 'not needed'
endif
endif
endif
# extract source file lists from .mk files
mk_files = ['silk_sources.mk', 'opus_headers.mk', 'opus_sources.mk', 'silk_headers.mk', 'celt_sources.mk', 'celt_headers.mk']
lines = run_command('meson/read-sources-list.py', mk_files, check: true).stdout().strip().split('\n')
sources = {}
foreach l : lines
a = l.split(' = ')
var_name = a[0]
file_list = a[1].split()
sources += {var_name: files(file_list)}
endforeach
subdir('include')
subdir('celt')
subdir('silk')
subdir('src')
configure_file(output: 'config.h', configuration: opus_conf)
if not opt_tests.disabled()
subdir('celt/tests')
subdir('silk/tests')
subdir('tests')
endif
# pkg-config files (not using pkg module so we can use the existing .pc.in file)
pkgconf = configuration_data()
pkgconf.set('prefix', join_paths(get_option('prefix')))
pkgconf.set('exec_prefix', '${prefix}')
pkgconf.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
pkgconf.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
pkgconf.set('VERSION', opus_version)
pkgconf.set('PC_BUILD', pc_build)
pkgconf.set('LIBM', libm.found() ? '-lm' : '')
pkg_install_dir = '@0@/pkgconfig'.format(get_option('libdir'))
configure_file(input : 'opus.pc.in',
output : 'opus.pc',
configuration : pkgconf,
install_dir : pkg_install_dir)
# The uninstalled one has hardcoded libtool + static lib stuff, skip it for now
#configure_file(input : 'opus-uninstalled.pc.in',
# output : 'opus-uninstalled.pc',
# configuration : pkgconf,
# install : false)
doxygen = find_program('doxygen', required: get_option('docs'))
if doxygen.found()
subdir('doc')
endif
summary(
{
'C99 var arrays': opus_conf.has('VAR_ARRAYS'),
'C99 lrintf': opus_conf.has('HAVE_LRINTF'),
'Use alloca': msg_use_alloca,
},
section: 'Compiler support',
bool_yn: true,
list_sep: ', ',
)
# Parse optimization status
foreach status : [['inline_optimization', opt_asm],
['asm_optimization', opt_asm],
['intrinsics_support', opt_intrinsics]]
res = status[0]
opt = status[1]
resval = get_variable(res)
if opt.disabled()
set_variable(res, 'disabled')
elif resval.length() == 0
if host_cpu_family not in ['arm', 'aarch64', 'x86', 'x86_64']
set_variable(res, 'No optimizations for your platform, please send patches')
else
set_variable(res, 'none')
endif
endif
endforeach
summary(
{
'Floating point support': not opt_fixed_point,
'Fast float approximations': opt_float_approx,
'Fixed point debugging': opt_fixed_point_debug,
'Inline assembly optimizations': inline_optimization,
'External assembly optimizations': asm_optimization,
'Intrinsics optimizations': intrinsics_support,
'Run-time CPU detection': rtcd_support,
},
section: 'Optimizations',
bool_yn: true,
list_sep: ', ',
)
summary(
{
'Custom modes': opt_custom_modes,
'Assertions': opt_assertions,
'Hardening': opt_hardening,
'Fuzzing': opt_fuzzing,
'Check ASM': opt_check_asm,
'API documentation': doxygen.found(),
'Extra programs': not extra_programs.disabled(),
'Tests': not opt_tests.disabled(),
},
section: 'General configuration',
bool_yn: true,
list_sep: ', ',
)
+86
View File
@@ -0,0 +1,86 @@
#!/usr/bin/env python3
#
# Opus get-version.py
#
# Extracts versions for build:
# - Opus package version based on 'git describe' or $srcroot/package_version
# - libtool version based on configure.ac
# - macos lib version based on configure.ac
#
# Usage:
# get-version.py [--package-version | --libtool-version | --darwin-version]
import argparse
import subprocess
import os
import sys
import shutil
if __name__ == '__main__':
arg_parser = argparse.ArgumentParser(description='Extract Opus package version or libtool version')
group = arg_parser.add_mutually_exclusive_group(required=True)
group.add_argument('--libtool-version', action='store_true')
group.add_argument('--package-version', action='store_true')
group.add_argument('--darwin-version', action='store_true')
args = arg_parser.parse_args()
srcroot = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
# package version
if args.package_version:
package_version = None
# check if git checkout
git_dir = os.path.join(srcroot, '.git')
is_git = os.path.isdir(git_dir) or os.path.isfile(git_dir)
have_git = shutil.which('git') is not None
if is_git and have_git:
git_cmd = subprocess.run(['git', '--git-dir=' + git_dir, 'describe', 'HEAD'], stdout=subprocess.PIPE)
if git_cmd.returncode:
print('ERROR: Could not extract package version via `git describe` in', srcroot, file=sys.stderr)
sys.exit(-1)
package_version = git_cmd.stdout.decode('ascii').strip().lstrip('v')
else:
with open(os.path.join(srcroot, 'package_version'), 'r') as f:
for line in f:
if line.startswith('PACKAGE_VERSION="'):
package_version = line[17:].strip().lstrip('v').rstrip('"')
if package_version:
break
if not package_version:
print('ERROR: Could not extract package version from package_version file in', srcroot, file=sys.stderr)
sys.exit(-1)
print(package_version)
sys.exit(0)
# libtool version + darwin version
elif args.libtool_version or args.darwin_version:
opus_lt_cur = None
opus_lt_rev = None
opus_lt_age = None
with open(os.path.join(srcroot, 'configure.ac'), 'r') as f:
for line in f:
if line.strip().startswith('OPUS_LT_CURRENT='):
opus_lt_cur = line[16:].strip()
elif line.strip().startswith('OPUS_LT_REVISION='):
opus_lt_rev = line[17:].strip()
elif line.strip().startswith('OPUS_LT_AGE='):
opus_lt_age = line[12:].strip()
if opus_lt_cur and opus_lt_rev and opus_lt_age:
opus_lt_cur = int(opus_lt_cur)
opus_lt_rev = int(opus_lt_rev)
opus_lt_age = int(opus_lt_age)
if args.libtool_version:
print('{}.{}.{}'.format(opus_lt_cur - opus_lt_age, opus_lt_age, opus_lt_rev))
elif args.darwin_version:
print('{}.{}.{}'.format(opus_lt_cur + 1, 0, 0))
sys.exit(0)
else:
print('ERROR: Could not extract libtool version from configure.ac file in', srcroot, file=sys.stderr)
sys.exit(-1)
else:
sys.exit(-1)
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env python3
#
# opus/read-sources-list.py
#
# Parses .mk files and extracts list of source files.
# Prints one line per source file list, with filenames space-separated.
import sys
if len(sys.argv) < 2:
sys.exit('Usage: {} sources_foo.mk [sources_bar.mk...]'.format(sys.argv[0]))
for input_fn in sys.argv[1:]:
with open(input_fn, 'r', encoding='utf8') as f:
text = f.read()
text = text.replace('\\\n', '')
# Remove empty lines
lines = [line for line in text.split('\n') if line.strip()]
# Print SOURCES_XYZ = file1.c file2.c
for line in lines:
values = line.strip().split('=', maxsplit=2)
if len(values) != 2:
raise RuntimeError('Unable to parse line "{}" from file "{}"'.format(line, input_fn))
var, files = values
sources_list = [f for f in files.split(' ') if f]
print(var.strip(), '=', ' '.join(sources_list))
+22
View File
@@ -0,0 +1,22 @@
# Optimizations
option('fixed-point', type : 'boolean', value : false, description : 'Compile without floating point (for machines without a fast enough FPU')
option('fixed-point-debug', type : 'boolean', value : false, description : 'Debug fixed-point implementation')
option('float-api', type : 'boolean', value : true, description : 'Compile with or without the floating point API (for machines with no float library')
option('float-approx', type : 'boolean', value : false, description : 'Enable fast approximations for floating point (not supported on all platforms)')
option('rtcd', type : 'feature', value : 'auto', description : 'Run-time CPU capabilities detection')
option('asm', type : 'feature', value : 'auto', description : 'Assembly optimizations for ARM (fixed-point)')
option('intrinsics', type : 'feature', value : 'auto', description : 'Intrinsics optimizations for ARM NEON or x86')
option('custom-modes', type : 'boolean', value : false, description : 'Enable non-Opus modes, e.g. 44.1 kHz & 2^n frames')
option('extra-programs', type : 'feature', value : 'auto', description : 'Extra programs (demo and tests)')
option('assertions', type : 'boolean', value : false, description : 'Additional software error checking')
option('hardening', type : 'boolean', value : true, description : 'Run-time checks that are cheap and safe for use in production')
option('fuzzing', type : 'boolean', value : false, description : 'Causes the encoder to make random decisions')
option('check-asm', type : 'boolean', value : false, description : 'Run bit-exactness checks between optimized and c implementations')
# common feature options
option('tests', type : 'feature', value : 'auto', description : 'Build tests')
option('docs', type: 'feature', value: 'auto', description: 'Build API documentation')
# other options
option('docdir', type: 'string', value: 'doc/opus', description: 'Directory to install documentation into (default: DATADIR/doc/opus')
+1 -1
View File
@@ -63,7 +63,7 @@ dnl
#include <string.h>
#include <opus.h>
int main ()
int main (void)
{
system("touch conf.opustest");
return 0;
-43
View File
@@ -1,43 +0,0 @@
include(opus_functions.cmake)
configure_file(config.h.cmake.in config.h @ONLY)
add_definitions(-DHAVE_CONFIG_H)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY C_STANDARD 99)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
include(CheckLibraryExists)
check_library_exists(m floor "" HAVE_LIBM)
if(HAVE_LIBM)
list(APPEND OPUS_REQUIRED_LIBRARIES m)
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(i[0-9]86|x86|X86|amd64|AMD64|x86_64)")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(OPUS_CPU_X64 1)
else()
set(OPUS_CPU_X86 1)
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
set(OPUS_CPU_ARM 1)
endif()
opus_supports_cpu_detection(RUNTIME_CPU_CAPABILITY_DETECTION)
if(OPUS_CPU_X86 OR OPUS_CPU_X64)
opus_detect_sse(COMPILER_SUPPORT_SIMD)
elseif(OPUS_CPU_ARM)
opus_detect_neon(COMPILER_SUPPORT_NEON)
if(COMPILER_SUPPORT_NEON)
option(OPUS_USE_NEON "Option to turn off SSE" ON)
option(OPUS_MAY_SUPPORT_NEON "Does runtime check for neon support" ON)
option(OPUS_PRESUME_NEON "Assume target CPU has NEON support" OFF)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(OPUS_PRESUME_NEON ON)
endif()
endif()
endif()
+1
View File
@@ -40,6 +40,7 @@ cfafd339ccd9c5ef8d6ab15d7e1a412c054bf4cb4ecbbbcc78c12ef2def70732 opus-1.2.1.tar
96fa28598e8ccd558b297277ad59a045c551ba0e06d65a9675938e084f837669 opus-1.3-rc.tar.gz
f6bab321fb81db984766f1e4d340a9e71a5ca2c5d4d53f4ee072e84afda271ca opus-1.3-rc2.tar.gz
4f3d69aefdf2dbaf9825408e452a8a414ffc60494c70633560700398820dc550 opus-1.3.tar.gz
65b58e1e25b2a114157014736a3d9dfeaad8d41be1c8179866f144a2fb44ff9d opus-1.3.1.tar.gz
94ac78ca4f74c4e43bc9fe4ec1ad0aa36f38ab90f45b0727c40dd1e96096e767 opus_testvectors-draft11.tar.gz
94ac78ca4f74c4e43bc9fe4ec1ad0aa36f38ab90f45b0727c40dd1e96096e767 opus_testvectors.tar.gz
6b26a22f9ba87b2b836906a9bb7afec5f8e54d49553b1200382520ee6fedfa55 opus_testvectors-rfc8251.tar.gz
+4
View File
@@ -118,6 +118,10 @@ void silk_CNG(
/* Smooth gains */
for( i = 0; i < psDec->nb_subfr; i++ ) {
psCNG->CNG_smth_Gain_Q16 += silk_SMULWB( psDecCtrl->Gains_Q16[ i ] - psCNG->CNG_smth_Gain_Q16, CNG_GAIN_SMTH_Q16 );
/* If the smoothed gain is 3 dB greater than this subframe's gain, use this subframe's gain to adapt faster. */
if( silk_SMULWW( psCNG->CNG_smth_Gain_Q16, CNG_GAIN_SMTH_THRESHOLD_Q16 ) > psDecCtrl->Gains_Q16[ i ] ) {
psCNG->CNG_smth_Gain_Q16 = psDecCtrl->Gains_Q16[ i ];
}
}
}
+2 -1
View File
@@ -31,7 +31,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "SigProc_FIX.h"
/* Convert int32 coefficients to int16 coefs and make sure there's no wrap-around */
/* Convert int32 coefficients to int16 coefs and make sure there's no wrap-around.
This logic is reused in _celt_lpc(). Any bug fixes should also be applied there. */
void silk_LPC_fit(
opus_int16 *a_QOUT, /* O Output signal */
opus_int32 *a_QIN, /* I/O Input signal */
+1 -1
View File
@@ -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;
+24 -30
View File
@@ -55,7 +55,7 @@ static OPUS_INLINE opus_int16 silk_ADD16_(opus_int16 a, opus_int16 b, char *file
static OPUS_INLINE opus_int32 silk_ADD32_(opus_int32 a, opus_int32 b, char *file, int line){
opus_int32 ret;
ret = a + b;
ret = (opus_int32)((opus_uint32)a + (opus_uint32)b);
if ( ret != silk_ADD_SAT32( a, b ) )
{
fprintf (stderr, "silk_ADD32(%d, %d) in %s: line %d\n", a, b, file, line);
@@ -101,9 +101,9 @@ static OPUS_INLINE opus_int16 silk_SUB16_(opus_int16 a, opus_int16 b, char *file
#undef silk_SUB32
#define silk_SUB32(a,b) silk_SUB32_((a), (b), __FILE__, __LINE__)
static OPUS_INLINE opus_int32 silk_SUB32_(opus_int32 a, opus_int32 b, char *file, int line){
opus_int32 ret;
opus_int64 ret;
ret = a - b;
ret = a - (opus_int64)b;
if ( ret != silk_SUB_SAT32( a, b ) )
{
fprintf (stderr, "silk_SUB32(%d, %d) in %s: line %d\n", a, b, file, line);
@@ -257,7 +257,7 @@ static OPUS_INLINE opus_int64 silk_SUB_SAT64_( opus_int64 a64, opus_int64 b64, c
static OPUS_INLINE opus_int32 silk_MUL_(opus_int32 a32, opus_int32 b32, char *file, int line){
opus_int32 ret;
opus_int64 ret64;
ret = a32 * b32;
ret = (opus_int32)((opus_uint32)a32 * (opus_uint32)b32);
ret64 = (opus_int64)a32 * (opus_int64)b32;
if ( (opus_int64)ret != ret64 )
{
@@ -333,8 +333,8 @@ static OPUS_INLINE opus_int32 silk_SMULWB_(opus_int32 a32, opus_int32 b32, char
#define silk_SMLAWB(a,b,c) silk_SMLAWB_((a), (b), (c), __FILE__, __LINE__)
static OPUS_INLINE opus_int32 silk_SMLAWB_(opus_int32 a32, opus_int32 b32, opus_int32 c32, char *file, int line){
opus_int32 ret;
ret = silk_ADD32( a32, silk_SMULWB( b32, c32 ) );
if ( silk_ADD32( a32, silk_SMULWB( b32, c32 ) ) != silk_ADD_SAT32( a32, silk_SMULWB( b32, c32 ) ) )
ret = silk_ADD32_ovflw( a32, silk_SMULWB( b32, c32 ) );
if ( ret != silk_ADD_SAT32( a32, silk_SMULWB( b32, c32 ) ) )
{
fprintf (stderr, "silk_SMLAWB(%d, %d, %d) in %s: line %d\n", a32, b32, c32, file, line);
#ifdef FIXED_DEBUG_ASSERT
@@ -465,7 +465,7 @@ static OPUS_INLINE opus_int32 silk_SMULWW_(opus_int32 a32, opus_int32 b32, char
if ( fail )
{
fprintf (stderr, "silk_SMULWT(%d, %d) in %s: line %d\n", a32, b32, file, line);
fprintf (stderr, "silk_SMULWW(%d, %d) in %s: line %d\n", a32, b32, file, line);
#ifdef FIXED_DEBUG_ASSERT
silk_assert( 0 );
#endif
@@ -491,12 +491,6 @@ static OPUS_INLINE opus_int32 silk_SMLAWW_(opus_int32 a32, opus_int32 b32, opus_
return ret;
}
/* Multiply-accumulate macros that allow overflow in the addition (ie, no asserts in debug mode) */
#undef silk_MLA_ovflw
#define silk_MLA_ovflw(a32, b32, c32) ((a32) + ((b32) * (c32)))
#undef silk_SMLABB_ovflw
#define silk_SMLABB_ovflw(a32, b32, c32) ((a32) + ((opus_int32)((opus_int16)(b32))) * (opus_int32)((opus_int16)(c32)))
/* no checking needed for silk_SMULL
no checking needed for silk_SMLAL
no checking needed for silk_SMLALBB
@@ -546,10 +540,10 @@ static OPUS_INLINE opus_int32 silk_DIV32_16_(opus_int32 a32, opus_int32 b32, cha
static OPUS_INLINE opus_int8 silk_LSHIFT8_(opus_int8 a, opus_int32 shift, char *file, int line){
opus_int8 ret;
int fail = 0;
ret = a << shift;
ret = (opus_int8)((opus_uint8)a << shift);
fail |= shift < 0;
fail |= shift >= 8;
fail |= (opus_int64)ret != ((opus_int64)a) << shift;
fail |= (opus_int64)ret != (opus_int64)(((opus_uint64)a) << shift);
if ( fail )
{
fprintf (stderr, "silk_LSHIFT8(%d, %d) in %s: line %d\n", a, shift, file, line);
@@ -565,10 +559,10 @@ static OPUS_INLINE opus_int8 silk_LSHIFT8_(opus_int8 a, opus_int32 shift, char *
static OPUS_INLINE opus_int16 silk_LSHIFT16_(opus_int16 a, opus_int32 shift, char *file, int line){
opus_int16 ret;
int fail = 0;
ret = a << shift;
ret = (opus_int16)((opus_uint16)a << shift);
fail |= shift < 0;
fail |= shift >= 16;
fail |= (opus_int64)ret != ((opus_int64)a) << shift;
fail |= (opus_int64)ret != (opus_int64)(((opus_uint64)a) << shift);
if ( fail )
{
fprintf (stderr, "silk_LSHIFT16(%d, %d) in %s: line %d\n", a, shift, file, line);
@@ -584,10 +578,10 @@ static OPUS_INLINE opus_int16 silk_LSHIFT16_(opus_int16 a, opus_int32 shift, cha
static OPUS_INLINE opus_int32 silk_LSHIFT32_(opus_int32 a, opus_int32 shift, char *file, int line){
opus_int32 ret;
int fail = 0;
ret = a << shift;
ret = (opus_int32)((opus_uint32)a << shift);
fail |= shift < 0;
fail |= shift >= 32;
fail |= (opus_int64)ret != ((opus_int64)a) << shift;
fail |= (opus_int64)ret != (opus_int64)(((opus_uint64)a) << shift);
if ( fail )
{
fprintf (stderr, "silk_LSHIFT32(%d, %d) in %s: line %d\n", a, shift, file, line);
@@ -603,7 +597,7 @@ static OPUS_INLINE opus_int32 silk_LSHIFT32_(opus_int32 a, opus_int32 shift, cha
static OPUS_INLINE opus_int64 silk_LSHIFT64_(opus_int64 a, opus_int shift, char *file, int line){
opus_int64 ret;
int fail = 0;
ret = a << shift;
ret = (opus_int64)((opus_uint64)a << shift);
fail |= shift < 0;
fail |= shift >= 64;
fail |= (ret>>shift) != ((opus_int64)a);
@@ -714,8 +708,8 @@ static OPUS_INLINE opus_uint32 silk_RSHIFT_uint_(opus_uint32 a, opus_int32 shift
#define silk_ADD_LSHIFT(a,b,c) silk_ADD_LSHIFT_((a), (b), (c), __FILE__, __LINE__)
static OPUS_INLINE int silk_ADD_LSHIFT_(int a, int b, int shift, char *file, int line){
opus_int16 ret;
ret = a + (b << shift);
if ( (shift < 0) || (shift>15) || ((opus_int64)ret != (opus_int64)a + (((opus_int64)b) << shift)) )
ret = a + (opus_int16)((opus_uint16)b << shift);
if ( (shift < 0) || (shift>15) || ((opus_int64)ret != (opus_int64)a + (opus_int64)(((opus_uint64)b) << shift)) )
{
fprintf (stderr, "silk_ADD_LSHIFT(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line);
#ifdef FIXED_DEBUG_ASSERT
@@ -729,8 +723,8 @@ static OPUS_INLINE int silk_ADD_LSHIFT_(int a, int b, int shift, char *file, int
#define silk_ADD_LSHIFT32(a,b,c) silk_ADD_LSHIFT32_((a), (b), (c), __FILE__, __LINE__)
static OPUS_INLINE opus_int32 silk_ADD_LSHIFT32_(opus_int32 a, opus_int32 b, opus_int32 shift, char *file, int line){
opus_int32 ret;
ret = a + (b << shift);
if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a + (((opus_int64)b) << shift)) )
ret = silk_ADD32_ovflw(a, (opus_int32)((opus_uint32)b << shift));
if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a + (opus_int64)(((opus_uint64)b) << shift)) )
{
fprintf (stderr, "silk_ADD_LSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line);
#ifdef FIXED_DEBUG_ASSERT
@@ -774,7 +768,7 @@ static OPUS_INLINE int silk_ADD_RSHIFT_(int a, int b, int shift, char *file, int
#define silk_ADD_RSHIFT32(a,b,c) silk_ADD_RSHIFT32_((a), (b), (c), __FILE__, __LINE__)
static OPUS_INLINE opus_int32 silk_ADD_RSHIFT32_(opus_int32 a, opus_int32 b, opus_int32 shift, char *file, int line){
opus_int32 ret;
ret = a + (b >> shift);
ret = silk_ADD32_ovflw(a, (b >> shift));
if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a + (((opus_int64)b) >> shift)) )
{
fprintf (stderr, "silk_ADD_RSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line);
@@ -804,8 +798,8 @@ static OPUS_INLINE opus_uint32 silk_ADD_RSHIFT_uint_(opus_uint32 a, opus_uint32
#define silk_SUB_LSHIFT32(a,b,c) silk_SUB_LSHIFT32_((a), (b), (c), __FILE__, __LINE__)
static OPUS_INLINE opus_int32 silk_SUB_LSHIFT32_(opus_int32 a, opus_int32 b, opus_int32 shift, char *file, int line){
opus_int32 ret;
ret = a - (b << shift);
if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a - (((opus_int64)b) << shift)) )
ret = silk_SUB32_ovflw(a, (opus_int32)((opus_uint32)b << shift));
if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a - (opus_int64)(((opus_uint64)b) << shift)) )
{
fprintf (stderr, "silk_SUB_LSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line);
#ifdef FIXED_DEBUG_ASSERT
@@ -819,7 +813,7 @@ static OPUS_INLINE opus_int32 silk_SUB_LSHIFT32_(opus_int32 a, opus_int32 b, opu
#define silk_SUB_RSHIFT32(a,b,c) silk_SUB_RSHIFT32_((a), (b), (c), __FILE__, __LINE__)
static OPUS_INLINE opus_int32 silk_SUB_RSHIFT32_(opus_int32 a, opus_int32 b, opus_int32 shift, char *file, int line){
opus_int32 ret;
ret = a - (b >> shift);
ret = silk_SUB32_ovflw(a, (b >> shift));
if ( (shift < 0) || (shift>31) || ((opus_int64)ret != (opus_int64)a - (((opus_int64)b) >> shift)) )
{
fprintf (stderr, "silk_SUB_RSHIFT32(%d, %d, %d) in %s: line %d\n", a, b, shift, file, line);
@@ -835,7 +829,7 @@ static OPUS_INLINE opus_int32 silk_SUB_RSHIFT32_(opus_int32 a, opus_int32 b, opu
static OPUS_INLINE opus_int32 silk_RSHIFT_ROUND_(opus_int32 a, opus_int32 shift, char *file, int line){
opus_int32 ret;
ret = shift == 1 ? (a >> 1) + (a & 1) : ((a >> (shift - 1)) + 1) >> 1;
/* the marco definition can't handle a shift of zero */
/* the macro definition can't handle a shift of zero */
if ( (shift <= 0) || (shift>31) || ((opus_int64)ret != ((opus_int64)a + ((opus_int64)1 << (shift - 1))) >> shift) )
{
fprintf (stderr, "silk_RSHIFT_ROUND(%d, %d) in %s: line %d\n", a, shift, file, line);
@@ -850,7 +844,7 @@ static OPUS_INLINE opus_int32 silk_RSHIFT_ROUND_(opus_int32 a, opus_int32 shift,
#define silk_RSHIFT_ROUND64(a,b) silk_RSHIFT_ROUND64_((a), (b), __FILE__, __LINE__)
static OPUS_INLINE opus_int64 silk_RSHIFT_ROUND64_(opus_int64 a, opus_int32 shift, char *file, int line){
opus_int64 ret;
/* the marco definition can't handle a shift of zero */
/* the macro definition can't handle a shift of zero */
if ( (shift <= 0) || (shift>=64) )
{
fprintf (stderr, "silk_RSHIFT_ROUND64(%lld, %d) in %s: line %d\n", (long long)a, shift, file, line);
+18 -18
View File
@@ -75,21 +75,21 @@ static OPUS_INLINE void silk_noise_shape_quantizer(
void silk_NSQ_c
(
const silk_encoder_state *psEncC, /* I Encoder State */
silk_nsq_state *NSQ, /* I/O NSQ state */
SideInfoIndices *psIndices, /* I/O Quantization Indices */
const silk_encoder_state *psEncC, /* I Encoder State */
silk_nsq_state *NSQ, /* I/O NSQ state */
SideInfoIndices *psIndices, /* I/O Quantization Indices */
const opus_int16 x16[], /* I Input */
opus_int8 pulses[], /* O Quantized pulse signal */
const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */
const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */
const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */
const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */
const opus_int LTP_scale_Q14 /* I LTP state scaling */
opus_int8 pulses[], /* O Quantized pulse signal */
const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */
const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */
const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */
const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */
const opus_int LTP_scale_Q14 /* I LTP state scaling */
)
{
opus_int k, lag, start_idx, LSF_interpolation_flag;
@@ -173,9 +173,9 @@ void silk_NSQ_c
RESTORE_STACK;
}
/***********************************/
/* silk_noise_shape_quantizer */
/***********************************/
/******************************/
/* silk_noise_shape_quantizer */
/******************************/
#if !defined(OPUS_X86_MAY_HAVE_SSE4_1)
static OPUS_INLINE
@@ -262,7 +262,7 @@ void silk_noise_shape_quantizer(
tmp1 = silk_SUB32( tmp1, n_LF_Q12 ); /* Q12 */
if( lag > 0 ) {
/* Symmetric, packed FIR coefficients */
n_LTP_Q13 = silk_SMULWB( silk_ADD32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 );
n_LTP_Q13 = silk_SMULWB( silk_ADD_SAT32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 );
n_LTP_Q13 = silk_SMLAWT( n_LTP_Q13, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 );
n_LTP_Q13 = silk_LSHIFT( n_LTP_Q13, 1 );
shp_lag_ptr++;
+20 -20
View File
@@ -115,21 +115,21 @@ static OPUS_INLINE void silk_noise_shape_quantizer_del_dec(
);
void silk_NSQ_del_dec_c(
const silk_encoder_state *psEncC, /* I Encoder State */
silk_nsq_state *NSQ, /* I/O NSQ state */
SideInfoIndices *psIndices, /* I/O Quantization Indices */
const silk_encoder_state *psEncC, /* I Encoder State */
silk_nsq_state *NSQ, /* I/O NSQ state */
SideInfoIndices *psIndices, /* I/O Quantization Indices */
const opus_int16 x16[], /* I Input */
opus_int8 pulses[], /* O Quantized pulse signal */
const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */
const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */
const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */
const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */
const opus_int LTP_scale_Q14 /* I LTP state scaling */
opus_int8 pulses[], /* O Quantized pulse signal */
const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */
const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */
const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */
const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */
const opus_int LTP_scale_Q14 /* I LTP state scaling */
)
{
opus_int i, k, lag, start_idx, LSF_interpolation_flag, Winner_ind, subfr;
@@ -394,8 +394,8 @@ static OPUS_INLINE void silk_noise_shape_quantizer_del_dec(
/* Long-term shaping */
if( lag > 0 ) {
/* Symmetric, packed FIR coefficients */
n_LTP_Q14 = silk_SMULWB( silk_ADD32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 );
n_LTP_Q14 = silk_SMLAWT( n_LTP_Q14, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 );
n_LTP_Q14 = silk_SMULWB( silk_ADD_SAT32( shp_lag_ptr[ 0 ], shp_lag_ptr[ -2 ] ), HarmShapeFIRPacked_Q14 );
n_LTP_Q14 = silk_SMLAWT( n_LTP_Q14, shp_lag_ptr[ -1 ], HarmShapeFIRPacked_Q14 );
n_LTP_Q14 = silk_SUB_LSHIFT32( LTP_pred_Q14, n_LTP_Q14, 2 ); /* Q12 -> Q14 */
shp_lag_ptr++;
} else {
@@ -451,9 +451,9 @@ static OPUS_INLINE void silk_noise_shape_quantizer_del_dec(
/* Input minus prediction plus noise feedback */
/* r = x[ i ] - LTP_pred - LPC_pred + n_AR + n_Tilt + n_LF + n_LTP */
tmp1 = silk_ADD32( n_AR_Q14, n_LF_Q14 ); /* Q14 */
tmp1 = silk_ADD_SAT32( n_AR_Q14, n_LF_Q14 ); /* Q14 */
tmp2 = silk_ADD32( n_LTP_Q14, LPC_pred_Q14 ); /* Q13 */
tmp1 = silk_SUB32( tmp2, tmp1 ); /* Q13 */
tmp1 = silk_SUB_SAT32( tmp2, tmp1 ); /* Q13 */
tmp1 = silk_RSHIFT_ROUND( tmp1, 4 ); /* Q10 */
r_Q10 = silk_SUB32( x_Q10[ i ], tmp1 ); /* residual error Q10 */
@@ -535,7 +535,7 @@ static OPUS_INLINE void silk_noise_shape_quantizer_del_dec(
/* Update states */
psSS[ 0 ].Diff_Q14 = silk_SUB_LSHIFT32( xq_Q14, x_Q10[ i ], 4 );
sLF_AR_shp_Q14 = silk_SUB32( psSS[ 0 ].Diff_Q14, n_AR_Q14 );
psSS[ 0 ].sLTP_shp_Q14 = silk_SUB32( sLF_AR_shp_Q14, n_LF_Q14 );
psSS[ 0 ].sLTP_shp_Q14 = silk_SUB_SAT32( sLF_AR_shp_Q14, n_LF_Q14 );
psSS[ 0 ].LF_AR_Q14 = sLF_AR_shp_Q14;
psSS[ 0 ].LPC_exc_Q14 = LPC_exc_Q14;
psSS[ 0 ].xq_Q14 = xq_Q14;
@@ -555,7 +555,7 @@ static OPUS_INLINE void silk_noise_shape_quantizer_del_dec(
/* Update states */
psSS[ 1 ].Diff_Q14 = silk_SUB_LSHIFT32( xq_Q14, x_Q10[ i ], 4 );
sLF_AR_shp_Q14 = silk_SUB32( psSS[ 1 ].Diff_Q14, n_AR_Q14 );
psSS[ 1 ].sLTP_shp_Q14 = silk_SUB32( sLF_AR_shp_Q14, n_LF_Q14 );
psSS[ 1 ].sLTP_shp_Q14 = silk_SUB_SAT32( sLF_AR_shp_Q14, n_LF_Q14 );
psSS[ 1 ].LF_AR_Q14 = sLF_AR_shp_Q14;
psSS[ 1 ].LPC_exc_Q14 = LPC_exc_Q14;
psSS[ 1 ].xq_Q14 = xq_Q14;
+2 -4
View File
@@ -328,10 +328,8 @@ static OPUS_INLINE void silk_PLC_conceal(
for( j = 0; j < LTP_ORDER; j++ ) {
B_Q14[ j ] = silk_RSHIFT( silk_SMULBB( harm_Gain_Q15, B_Q14[ j ] ), 15 );
}
if ( psDec->indices.signalType != TYPE_NO_VOICE_ACTIVITY ) {
/* Gradually reduce excitation gain */
rand_scale_Q14 = silk_RSHIFT( silk_SMULBB( rand_scale_Q14, rand_Gain_Q15 ), 15 );
}
/* Gradually reduce excitation gain */
rand_scale_Q14 = silk_RSHIFT( silk_SMULBB( rand_scale_Q14, rand_Gain_Q15 ), 15 );
/* Slowly increase pitch lag */
psPLC->pitchL_Q8 = silk_SMLAWB( psPLC->pitchL_Q8, psPLC->pitchL_Q8, PITCH_DRIFT_FAC_Q16 );
+6 -4
View File
@@ -381,7 +381,7 @@ opus_int32 silk_inner_prod_aligned_scale(
const opus_int len /* I vector lengths */
);
opus_int64 silk_inner_prod16_aligned_64_c(
opus_int64 silk_inner_prod16_c(
const opus_int16 *inVec1, /* I input vector 1 */
const opus_int16 *inVec2, /* I input vector 2 */
const opus_int len /* I vector lengths */
@@ -609,12 +609,14 @@ static OPUS_INLINE opus_int64 silk_max_64(opus_int64 a, opus_int64 b)
/* the following seems faster on x86 */
#define silk_SMMUL(a32, b32) (opus_int32)silk_RSHIFT64(silk_SMULL((a32), (b32)), 32)
#if !defined(OPUS_X86_MAY_HAVE_SSE4_1)
#if !defined(OVERRIDE_silk_burg_modified)
#define silk_burg_modified(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch) \
((void)(arch), silk_burg_modified_c(res_nrg, res_nrg_Q, A_Q16, x, minInvGain_Q30, subfr_length, nb_subfr, D, arch))
#endif
#define silk_inner_prod16_aligned_64(inVec1, inVec2, len, arch) \
((void)(arch),silk_inner_prod16_aligned_64_c(inVec1, inVec2, len))
#if !defined(OVERRIDE_silk_inner_prod16)
#define silk_inner_prod16(inVec1, inVec2, len, arch) \
((void)(arch),silk_inner_prod16_c(inVec1, inVec2, len))
#endif
#include "Inlines.h"
+2 -2
View File
@@ -64,7 +64,7 @@ void silk_VQ_WMat_EC_c(
*rate_dist_Q8 = silk_int32_MAX;
*res_nrg_Q15 = silk_int32_MAX;
cb_row_Q7 = cb_Q7;
/* In things go really bad, at least *ind is set to something safe. */
/* If things go really bad, at least *ind is set to something safe. */
*ind = 0;
for( k = 0; k < L; k++ ) {
opus_int32 penalty;
@@ -115,7 +115,7 @@ void silk_VQ_WMat_EC_c(
if( sum1_Q15 >= 0 ) {
/* Translate residual energy to bits using high-rate assumption (6 dB ==> 1 bit/sample) */
bits_res_Q8 = silk_SMULBB( subfr_len, silk_lin2log( sum1_Q15 + penalty) - (15 << 7) );
/* In the following line we reduce the codelength component by half ("-1"); seems to slghtly improve quality */
/* In the following line we reduce the codelength component by half ("-1"); seems to slightly improve quality */
bits_tot_Q8 = silk_ADD_LSHIFT32( bits_res_Q8, cl_Q5[ k ], 3-1 );
if( bits_tot_Q8 <= *rate_dist_Q8 ) {
*rate_dist_Q8 = bits_tot_Q8;
+15 -7
View File
@@ -210,19 +210,23 @@ opus_int32 silk_LPC_inverse_pred_gain_neon( /* O Returns inverse predi
/* Increase Q domain of the AR coefficients */
t0_s16x8 = vld1q_s16( A_Q12 + 0 );
t1_s16x8 = vld1q_s16( A_Q12 + 8 );
t2_s16x8 = vld1q_s16( A_Q12 + 16 );
if ( order > 16 ) {
t2_s16x8 = vld1q_s16( A_Q12 + 16 );
}
t0_s32x4 = vpaddlq_s16( t0_s16x8 );
switch( order - leftover )
{
case 24:
t0_s32x4 = vpadalq_s16( t0_s32x4, t2_s16x8 );
vst1q_s32( Atmp_QA + 16, vshll_n_s16( vget_low_s16 ( t2_s16x8 ), QA - 12 ) );
vst1q_s32( Atmp_QA + 20, vshll_n_s16( vget_high_s16( t2_s16x8 ), QA - 12 ) );
/* FALLTHROUGH */
case 16:
t0_s32x4 = vpadalq_s16( t0_s32x4, t1_s16x8 );
vst1q_s32( Atmp_QA + 16, vshll_n_s16( vget_low_s16 ( t2_s16x8 ), QA - 12 ) );
vst1q_s32( Atmp_QA + 20, vshll_n_s16( vget_high_s16( t2_s16x8 ), QA - 12 ) );
vst1q_s32( Atmp_QA + 8, vshll_n_s16( vget_low_s16 ( t1_s16x8 ), QA - 12 ) );
vst1q_s32( Atmp_QA + 12, vshll_n_s16( vget_high_s16( t1_s16x8 ), QA - 12 ) );
/* FALLTHROUGH */
case 8:
@@ -230,8 +234,8 @@ opus_int32 silk_LPC_inverse_pred_gain_neon( /* O Returns inverse predi
const int32x2_t t_s32x2 = vpadd_s32( vget_low_s32( t0_s32x4 ), vget_high_s32( t0_s32x4 ) );
const int64x1_t t_s64x1 = vpaddl_s32( t_s32x2 );
DC_resp = vget_lane_s32( vreinterpret_s32_s64( t_s64x1 ), 0 );
vst1q_s32( Atmp_QA + 8, vshll_n_s16( vget_low_s16 ( t1_s16x8 ), QA - 12 ) );
vst1q_s32( Atmp_QA + 12, vshll_n_s16( vget_high_s16( t1_s16x8 ), QA - 12 ) );
vst1q_s32( Atmp_QA + 0, vshll_n_s16( vget_low_s16 ( t0_s16x8 ), QA - 12 ) );
vst1q_s32( Atmp_QA + 4, vshll_n_s16( vget_high_s16( t0_s16x8 ), QA - 12 ) );
}
break;
@@ -246,16 +250,22 @@ opus_int32 silk_LPC_inverse_pred_gain_neon( /* O Returns inverse predi
case 6:
DC_resp += (opus_int32)A_Q12[ 5 ];
DC_resp += (opus_int32)A_Q12[ 4 ];
Atmp_QA[ order - leftover + 5 ] = silk_LSHIFT32( (opus_int32)A_Q12[ 5 ], QA - 12 );
Atmp_QA[ order - leftover + 4 ] = silk_LSHIFT32( (opus_int32)A_Q12[ 4 ], QA - 12 );
/* FALLTHROUGH */
case 4:
DC_resp += (opus_int32)A_Q12[ 3 ];
DC_resp += (opus_int32)A_Q12[ 2 ];
Atmp_QA[ order - leftover + 3 ] = silk_LSHIFT32( (opus_int32)A_Q12[ 3 ], QA - 12 );
Atmp_QA[ order - leftover + 2 ] = silk_LSHIFT32( (opus_int32)A_Q12[ 2 ], QA - 12 );
/* FALLTHROUGH */
case 2:
DC_resp += (opus_int32)A_Q12[ 1 ];
DC_resp += (opus_int32)A_Q12[ 0 ];
Atmp_QA[ order - leftover + 1 ] = silk_LSHIFT32( (opus_int32)A_Q12[ 1 ], QA - 12 );
Atmp_QA[ order - leftover + 0 ] = silk_LSHIFT32( (opus_int32)A_Q12[ 0 ], QA - 12 );
/* FALLTHROUGH */
default:
@@ -266,8 +276,6 @@ opus_int32 silk_LPC_inverse_pred_gain_neon( /* O Returns inverse predi
if( DC_resp >= 4096 ) {
invGain_Q30 = 0;
} else {
vst1q_s32( Atmp_QA + 0, vshll_n_s16( vget_low_s16 ( t0_s16x8 ), QA - 12 ) );
vst1q_s32( Atmp_QA + 4, vshll_n_s16( vget_high_s16( t0_s16x8 ), QA - 12 ) );
invGain_Q30 = LPC_inverse_pred_gain_QA_neon( Atmp_QA, order );
}
}
+2 -1
View File
@@ -31,7 +31,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "SigProc_FIX.h"
/* Chirp (bandwidth expand) LP AR filter */
/* Chirp (bandwidth expand) LP AR filter.
This logic is reused in _celt_lpc(). Any bug fixes should also be applied there. */
void silk_bwexpander_32(
opus_int32 *ar, /* I/O AR filter to be expanded (without leading 1) */
const opus_int d, /* I Length of ar */
+1 -1
View File
@@ -415,7 +415,7 @@ static OPUS_INLINE opus_int silk_setup_LBRR(
/* Previous packet did not have LBRR, and was therefore coded at a higher bitrate */
psEncC->LBRR_GainIncreases = 7;
} else {
psEncC->LBRR_GainIncreases = silk_max_int( 7 - silk_SMULWB( (opus_int32)psEncC->PacketLoss_perc, SILK_FIX_CONST( 0.4, 16 ) ), 2 );
psEncC->LBRR_GainIncreases = silk_max_int( 7 - silk_SMULWB( (opus_int32)psEncC->PacketLoss_perc, SILK_FIX_CONST( 0.2, 16 ) ), 3 );
}
}
+8 -4
View File
@@ -29,19 +29,23 @@ POSSIBILITY OF SUCH DAMAGE.
#include "config.h"
#endif
typedef int prevent_empty_translation_unit_warning;
#include "debug.h"
#if SILK_DEBUG || SILK_TIC_TOC
#include "SigProc_FIX.h"
#endif
#if SILK_TIC_TOC
#ifdef _WIN32
#if (defined(_WIN32) || defined(_WINCE))
#include <windows.h> /* timer */
#else /* Linux or Mac*/
#include <sys/time.h>
#endif
#ifdef _WIN32
unsigned long silk_GetHighResolutionTime(void) /* O time in usec*/
{
/* Returns a time counter in microsec */
@@ -65,7 +69,7 @@ unsigned long GetHighResolutionTime(void) /* O time in usec*/
int silk_Timer_nTimers = 0;
int silk_Timer_depth_ctr = 0;
char silk_Timer_tags[silk_NUM_TIMERS_MAX][silk_NUM_TIMERS_MAX_TAG_LEN];
#ifdef WIN32
#ifdef _WIN32
LARGE_INTEGER silk_Timer_start[silk_NUM_TIMERS_MAX];
#else
unsigned long silk_Timer_start[silk_NUM_TIMERS_MAX];
@@ -76,7 +80,7 @@ opus_int64 silk_Timer_sum[silk_NUM_TIMERS_MAX];
opus_int64 silk_Timer_max[silk_NUM_TIMERS_MAX];
opus_int64 silk_Timer_depth[silk_NUM_TIMERS_MAX];
#ifdef WIN32
#ifdef _WIN32
void silk_TimerSave(char *file_name)
{
if( silk_Timer_nTimers > 0 )
+13 -12
View File
@@ -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*/
-1
View File
@@ -97,7 +97,6 @@ opus_int silk_decode_frame(
psDec->first_frame_after_reset = 0;
} else {
/* Handle packet loss by extrapolation */
psDec->indices.signalType = psDec->prevSignalType;
silk_PLC( psDec, psDecCtrl, pOut, 1, arch );
}
+1
View File
@@ -225,6 +225,7 @@ extern "C"
/* Defines for CN generation */
#define CNG_BUF_MASK_MAX 255 /* 2^floor(log2(MAX_FRAME_LENGTH))-1 */
#define CNG_GAIN_SMTH_Q16 4634 /* 0.25^(1/4) */
#define CNG_GAIN_SMTH_THRESHOLD_Q16 46396 /* -3 dB */
#define CNG_NLSF_SMTH_Q16 16348 /* 0.25 */
#ifdef __cplusplus
+13 -2
View File
@@ -270,6 +270,7 @@ opus_int silk_Encode( /* O Returns error co
psEnc->state_Fxx[ 0 ].sCmn.fs_kHz * 1000 );
ALLOC( buf, nSamplesFromInputMax, opus_int16 );
while( 1 ) {
int curr_nBitsUsedLBRR = 0;
nSamplesToBuffer = psEnc->state_Fxx[ 0 ].sCmn.frame_length - psEnc->state_Fxx[ 0 ].sCmn.inputBufIx;
nSamplesToBuffer = silk_min( nSamplesToBuffer, nSamplesToBufferMax );
nSamplesFromInput = silk_DIV32_16( nSamplesToBuffer * psEnc->state_Fxx[ 0 ].sCmn.API_fs_Hz, psEnc->state_Fxx[ 0 ].sCmn.fs_kHz * 1000 );
@@ -342,6 +343,7 @@ opus_int silk_Encode( /* O Returns error co
opus_uint8 iCDF[ 2 ] = { 0, 0 };
iCDF[ 0 ] = 256 - silk_RSHIFT( 256, ( psEnc->state_Fxx[ 0 ].sCmn.nFramesPerPacket + 1 ) * encControl->nChannelsInternal );
ec_enc_icdf( psRangeEnc, 0, iCDF, 8 );
curr_nBitsUsedLBRR = ec_tell( psRangeEnc );
/* Encode any LBRR data from previous packet */
/* Encode LBRR flags */
@@ -386,8 +388,7 @@ opus_int silk_Encode( /* O Returns error co
for( n = 0; n < encControl->nChannelsInternal; n++ ) {
silk_memset( psEnc->state_Fxx[ n ].sCmn.LBRR_flags, 0, sizeof( psEnc->state_Fxx[ n ].sCmn.LBRR_flags ) );
}
psEnc->nBitsUsedLBRR = ec_tell( psRangeEnc );
curr_nBitsUsedLBRR = ec_tell( psRangeEnc ) - curr_nBitsUsedLBRR;
}
silk_HP_variable_cutoff( psEnc->state_Fxx );
@@ -396,6 +397,16 @@ opus_int silk_Encode( /* O Returns error co
nBits = silk_DIV32_16( silk_MUL( encControl->bitRate, encControl->payloadSize_ms ), 1000 );
/* Subtract bits used for LBRR */
if( !prefillFlag ) {
/* psEnc->nBitsUsedLBRR is an exponential moving average of the LBRR usage,
except that for the first LBRR frame it does no averaging and for the first
frame after after LBRR, it goes back to zero immediately. */
if ( curr_nBitsUsedLBRR < 10 ) {
psEnc->nBitsUsedLBRR = 0;
} else if ( psEnc->nBitsUsedLBRR < 10) {
psEnc->nBitsUsedLBRR = curr_nBitsUsedLBRR;
} else {
psEnc->nBitsUsedLBRR = ( psEnc->nBitsUsedLBRR + curr_nBitsUsedLBRR ) / 2;
}
nBits -= psEnc->nBitsUsedLBRR;
}
/* Divide by number of uncoded frames left in packet */
+8 -3
View File
@@ -42,9 +42,14 @@ void silk_LTP_scale_ctrl_FIX(
if( condCoding == CODE_INDEPENDENTLY ) {
/* Only scale if first frame in packet */
round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket;
psEnc->sCmn.indices.LTP_scaleIndex = (opus_int8)silk_LIMIT(
silk_SMULWB( silk_SMULBB( round_loss, psEncCtrl->LTPredCodGain_Q7 ), SILK_FIX_CONST( 0.1, 9 ) ), 0, 2 );
round_loss = psEnc->sCmn.PacketLoss_perc * psEnc->sCmn.nFramesPerPacket;
if ( psEnc->sCmn.LBRR_flag ) {
/* LBRR reduces the effective loss. In practice, it does not square the loss because
losses aren't independent, but that still seems to work best. We also never go below 2%. */
round_loss = 2 + silk_SMULBB( round_loss, round_loss ) / 100;
}
psEnc->sCmn.indices.LTP_scaleIndex = silk_SMULBB( psEncCtrl->LTPredCodGain_Q7, round_loss ) > silk_log2lin( 128*7 + 2900-psEnc->sCmn.SNR_dB_Q7 );
psEnc->sCmn.indices.LTP_scaleIndex += silk_SMULBB( psEncCtrl->LTPredCodGain_Q7, round_loss ) > silk_log2lin( 128*7 + 3900-psEnc->sCmn.SNR_dB_Q7 );
} else {
/* Default is minimum scaling */
psEnc->sCmn.indices.LTP_scaleIndex = 0;
@@ -84,7 +84,9 @@ void silk_warped_autocorrelation_FIX_neon(
silk_assert( ( order & 1 ) == 0 );
silk_assert( 2 * QS - QC >= 0 );
ALLOC( input_QST, length + 2 * MAX_SHAPE_LPC_ORDER, opus_int32 );
/* The additional +4 is to ensure a later vld1q_s32 call does not overflow. */
/* Strictly, only +3 is needed but +4 simplifies initialization using the 4x32 neon load. */
ALLOC( input_QST, length + 2 * MAX_SHAPE_LPC_ORDER + 4, opus_int32 );
input_QS = input_QST;
/* input_QS has zero paddings in the beginning and end. */
@@ -121,6 +123,8 @@ void silk_warped_autocorrelation_FIX_neon(
vst1q_s32( input_QS, vdupq_n_s32( 0 ) );
input_QS += 4;
vst1q_s32( input_QS, vdupq_n_s32( 0 ) );
input_QS += 4;
vst1q_s32( input_QS, vdupq_n_s32( 0 ) );
input_QS = input_QST + MAX_SHAPE_LPC_ORDER - orderT;
/* The following loop runs ( length + order ) times, with ( order ) extra epilogues. */
@@ -153,7 +157,8 @@ void silk_warped_autocorrelation_FIX_neon(
opus_int o = orderT;
int32x4_t state_QS_s32x4[ 3 ][ 2 ];
ALLOC( state, length + orderT, opus_int32 );
/* The additional +4 is to ensure a later vld1q_s32 call does not overflow. */
ALLOC( state, length + order + 4, opus_int32 );
state_QS_s32x4[ 2 ][ 1 ] = vdupq_n_s32( 0 );
/* Calculate 8 taps of all inputs in each loop. */
+4 -4
View File
@@ -68,7 +68,7 @@ void silk_burg_modified_c(
celt_assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE );
/* Compute autocorrelations, added over subframes */
C0_64 = silk_inner_prod16_aligned_64( x, x, subfr_length*nb_subfr, arch );
C0_64 = silk_inner_prod16( x, x, subfr_length*nb_subfr, arch );
lz = silk_CLZ64(C0_64);
rshifts = 32 + 1 + N_BITS_HEAD_ROOM - lz;
if (rshifts > MAX_RSHIFTS) rshifts = MAX_RSHIFTS;
@@ -87,7 +87,7 @@ void silk_burg_modified_c(
x_ptr = x + s * subfr_length;
for( n = 1; n < D + 1; n++ ) {
C_first_row[ n - 1 ] += (opus_int32)silk_RSHIFT64(
silk_inner_prod16_aligned_64( x_ptr, x_ptr + n, subfr_length - n, arch ), rshifts );
silk_inner_prod16( x_ptr, x_ptr + n, subfr_length - n, arch ), rshifts );
}
}
} else {
@@ -150,7 +150,7 @@ void silk_burg_modified_c(
C_first_row[ k ] = silk_MLA( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts ) */
C_last_row[ k ] = silk_MLA( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts ) */
Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 17 ); /* Q17 */
/* We sometimes have get overflows in the multiplications (even beyond +/- 2^32),
/* We sometimes get overflows in the multiplications (even beyond +/- 2^32),
but they cancel each other and the real result seems to always fit in a 32-bit
signed integer. This was determined experimentally, not theoretically (unfortunately). */
tmp1 = silk_MLA_ovflw( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); /* Q17 */
@@ -253,7 +253,7 @@ void silk_burg_modified_c(
if( rshifts > 0 ) {
for( s = 0; s < nb_subfr; s++ ) {
x_ptr = x + s * subfr_length;
C0 -= (opus_int32)silk_RSHIFT64( silk_inner_prod16_aligned_64( x_ptr, x_ptr, D, arch ), rshifts );
C0 -= (opus_int32)silk_RSHIFT64( silk_inner_prod16( x_ptr, x_ptr, D, arch ), rshifts );
}
} else {
for( s = 0; s < nb_subfr; s++ ) {
+2 -1
View File
@@ -42,7 +42,8 @@ void silk_find_pred_coefs_FIX(
{
opus_int i;
opus_int32 invGains_Q16[ MAX_NB_SUBFR ], local_gains[ MAX_NB_SUBFR ];
opus_int16 NLSF_Q15[ MAX_LPC_ORDER ];
/* Set to NLSF_Q15 to zero so we don't copy junk to the state. */
opus_int16 NLSF_Q15[ MAX_LPC_ORDER ]={0};
const opus_int16 *x_ptr;
opus_int16 *x_pre_ptr;
VARDECL( opus_int16, LPC_in_pre );
+1 -1
View File
@@ -87,7 +87,7 @@ opus_int32 silk_inner_prod_aligned(
#endif
}
opus_int64 silk_inner_prod16_aligned_64_c(
opus_int64 silk_inner_prod16_c(
const opus_int16 *inVec1, /* I input vector 1 */
const opus_int16 *inVec2, /* I input vector 2 */
const opus_int len /* I vector lengths */
+46 -23
View File
@@ -1,5 +1,5 @@
/* Copyright (c) 2014, Cisco Systems, INC
Written by XiangMingZhu WeiZhou MinPeng YanWang
/* Copyright (c) 2014-2020, Cisco Systems, INC
Written by XiangMingZhu WeiZhou MinPeng YanWang FrancisQuiers
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@@ -42,7 +42,7 @@
#define MAX_FRAME_SIZE 384 /* subfr_length * nb_subfr = ( 0.005 * 16000 + 16 ) * 4 = 384 */
#define QA 25
#define N_BITS_HEAD_ROOM 2
#define N_BITS_HEAD_ROOM 3
#define MIN_RSHIFTS -16
#define MAX_RSHIFTS (32 - QA)
@@ -59,7 +59,7 @@ void silk_burg_modified_sse4_1(
int arch /* I Run-time architecture */
)
{
opus_int k, n, s, lz, rshifts, rshifts_extra, reached_max_gain;
opus_int k, n, s, lz, rshifts, reached_max_gain;
opus_int32 C0, num, nrg, rc_Q31, invGain_Q30, Atmp_QA, Atmp1, tmp1, tmp2, x1, x2;
const opus_int16 *x_ptr;
opus_int32 C_first_row[ SILK_MAX_ORDER_LPC ];
@@ -68,6 +68,7 @@ void silk_burg_modified_sse4_1(
opus_int32 CAf[ SILK_MAX_ORDER_LPC + 1 ];
opus_int32 CAb[ SILK_MAX_ORDER_LPC + 1 ];
opus_int32 xcorr[ SILK_MAX_ORDER_LPC ];
opus_int64 C0_64;
__m128i FIRST_3210, LAST_3210, ATMP_3210, TMP1_3210, TMP2_3210, T1_3210, T2_3210, PTR_3210, SUBFR_3210, X1_3210, X2_3210;
__m128i CONST1 = _mm_set1_epi32(1);
@@ -75,23 +76,18 @@ void silk_burg_modified_sse4_1(
celt_assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE );
/* Compute autocorrelations, added over subframes */
silk_sum_sqr_shift( &C0, &rshifts, x, nb_subfr * subfr_length );
if( rshifts > MAX_RSHIFTS ) {
C0 = silk_LSHIFT32( C0, rshifts - MAX_RSHIFTS );
silk_assert( C0 > 0 );
rshifts = MAX_RSHIFTS;
C0_64 = silk_inner_prod16( x, x, subfr_length*nb_subfr, arch );
lz = silk_CLZ64(C0_64);
rshifts = 32 + 1 + N_BITS_HEAD_ROOM - lz;
if (rshifts > MAX_RSHIFTS) rshifts = MAX_RSHIFTS;
if (rshifts < MIN_RSHIFTS) rshifts = MIN_RSHIFTS;
if (rshifts > 0) {
C0 = (opus_int32)silk_RSHIFT64(C0_64, rshifts );
} else {
lz = silk_CLZ32( C0 ) - 1;
rshifts_extra = N_BITS_HEAD_ROOM - lz;
if( rshifts_extra > 0 ) {
rshifts_extra = silk_min( rshifts_extra, MAX_RSHIFTS - rshifts );
C0 = silk_RSHIFT32( C0, rshifts_extra );
} else {
rshifts_extra = silk_max( rshifts_extra, MIN_RSHIFTS - rshifts );
C0 = silk_LSHIFT32( C0, -rshifts_extra );
}
rshifts += rshifts_extra;
C0 = silk_LSHIFT32((opus_int32)C0_64, -rshifts );
}
CAb[ 0 ] = CAf[ 0 ] = C0 + silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ) + 1; /* Q(-rshifts) */
silk_memset( C_first_row, 0, SILK_MAX_ORDER_LPC * sizeof( opus_int32 ) );
if( rshifts > 0 ) {
@@ -99,7 +95,7 @@ void silk_burg_modified_sse4_1(
x_ptr = x + s * subfr_length;
for( n = 1; n < D + 1; n++ ) {
C_first_row[ n - 1 ] += (opus_int32)silk_RSHIFT64(
silk_inner_prod16_aligned_64( x_ptr, x_ptr + n, subfr_length - n, arch ), rshifts );
silk_inner_prod16( x_ptr, x_ptr + n, subfr_length - n, arch ), rshifts );
}
}
} else {
@@ -203,8 +199,11 @@ void silk_burg_modified_sse4_1(
C_first_row[ k ] = silk_MLA( C_first_row[ k ], x1, x_ptr[ n - k - 1 ] ); /* Q( -rshifts ) */
C_last_row[ k ] = silk_MLA( C_last_row[ k ], x2, x_ptr[ subfr_length - n + k ] ); /* Q( -rshifts ) */
Atmp1 = silk_RSHIFT_ROUND( Af_QA[ k ], QA - 17 ); /* Q17 */
tmp1 = silk_MLA( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); /* Q17 */
tmp2 = silk_MLA( tmp2, x_ptr[ subfr_length - n + k ], Atmp1 ); /* Q17 */
/* We sometimes get overflows in the multiplications (even beyond +/- 2^32),
but they cancel each other and the real result seems to always fit in a 32-bit
signed integer. This was determined experimentally, not theoretically (unfortunately). */
tmp1 = silk_MLA_ovflw( tmp1, x_ptr[ n - k - 1 ], Atmp1 ); /* Q17 */
tmp2 = silk_MLA_ovflw( tmp2, x_ptr[ subfr_length - n + k ], Atmp1 ); /* Q17 */
}
tmp1 = -tmp1; /* Q17 */
@@ -350,7 +349,7 @@ void silk_burg_modified_sse4_1(
if( rshifts > 0 ) {
for( s = 0; s < nb_subfr; s++ ) {
x_ptr = x + s * subfr_length;
C0 -= (opus_int32)silk_RSHIFT64( silk_inner_prod16_aligned_64( x_ptr, x_ptr, D, arch ), rshifts );
C0 -= (opus_int32)silk_RSHIFT64( silk_inner_prod16( x_ptr, x_ptr, D, arch ), rshifts );
}
} else {
for( s = 0; s < nb_subfr; s++ ) {
@@ -374,4 +373,28 @@ void silk_burg_modified_sse4_1(
*res_nrg = silk_SMLAWW( nrg, silk_SMMUL( SILK_FIX_CONST( FIND_LPC_COND_FAC, 32 ), C0 ), -tmp1 );/* Q( -rshifts ) */
*res_nrg_Q = -rshifts;
}
#ifdef OPUS_CHECK_ASM
{
opus_int32 res_nrg_c = 0;
opus_int res_nrg_Q_c = 0;
opus_int32 A_Q16_c[ MAX_LPC_ORDER ] = {0};
silk_burg_modified_c(
&res_nrg_c,
&res_nrg_Q_c,
A_Q16_c,
x,
minInvGain_Q30,
subfr_length,
nb_subfr,
D,
0
);
silk_assert( *res_nrg == res_nrg_c );
silk_assert( *res_nrg_Q == res_nrg_Q_c );
silk_assert( !memcmp( A_Q16, A_Q16_c, D * sizeof( *A_Q16 ) ) );
}
#endif
}
-160
View File
@@ -1,160 +0,0 @@
/* Copyright (c) 2014, Cisco Systems, INC
Written by XiangMingZhu WeiZhou MinPeng YanWang
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <xmmintrin.h>
#include <emmintrin.h>
#include <smmintrin.h>
#include "main.h"
#include "celt/x86/x86cpu.h"
void silk_warped_LPC_analysis_filter_FIX_sse4_1(
opus_int32 state[], /* I/O State [order + 1] */
opus_int32 res_Q2[], /* O Residual signal [length] */
const opus_int16 coef_Q13[], /* I Coefficients [order] */
const opus_int16 input[], /* I Input signal [length] */
const opus_int16 lambda_Q16, /* I Warping factor */
const opus_int length, /* I Length of input signal */
const opus_int order /* I Filter order (even) */
)
{
opus_int n, i;
opus_int32 acc_Q11, tmp1, tmp2;
/* Order must be even */
celt_assert( ( order & 1 ) == 0 );
if (order == 10)
{
if (0 == lambda_Q16)
{
__m128i coef_Q13_3210, coef_Q13_7654;
__m128i coef_Q13_0123, coef_Q13_4567;
__m128i state_0123, state_4567;
__m128i xmm_product1, xmm_product2;
__m128i xmm_tempa, xmm_tempb;
register opus_int32 sum;
register opus_int32 state_8, state_9, state_a;
register opus_int64 coef_Q13_8, coef_Q13_9;
celt_assert( length > 0 );
coef_Q13_3210 = OP_CVTEPI16_EPI32_M64( &coef_Q13[ 0 ] );
coef_Q13_7654 = OP_CVTEPI16_EPI32_M64( &coef_Q13[ 4 ] );
coef_Q13_0123 = _mm_shuffle_epi32( coef_Q13_3210, _MM_SHUFFLE( 0, 1, 2, 3 ) );
coef_Q13_4567 = _mm_shuffle_epi32( coef_Q13_7654, _MM_SHUFFLE( 0, 1, 2, 3 ) );
coef_Q13_8 = (opus_int64) coef_Q13[ 8 ];
coef_Q13_9 = (opus_int64) coef_Q13[ 9 ];
state_0123 = _mm_loadu_si128( (__m128i *)(&state[ 0 ] ) );
state_4567 = _mm_loadu_si128( (__m128i *)(&state[ 4 ] ) );
state_0123 = _mm_shuffle_epi32( state_0123, _MM_SHUFFLE( 0, 1, 2, 3 ) );
state_4567 = _mm_shuffle_epi32( state_4567, _MM_SHUFFLE( 0, 1, 2, 3 ) );
state_8 = state[ 8 ];
state_9 = state[ 9 ];
state_a = 0;
for( n = 0; n < length; n++ )
{
xmm_product1 = _mm_mul_epi32( coef_Q13_0123, state_0123 ); /* 64-bit multiply, only 2 pairs */
xmm_product2 = _mm_mul_epi32( coef_Q13_4567, state_4567 );
xmm_tempa = _mm_shuffle_epi32( state_0123, _MM_SHUFFLE( 0, 1, 2, 3 ) );
xmm_tempb = _mm_shuffle_epi32( state_4567, _MM_SHUFFLE( 0, 1, 2, 3 ) );
xmm_product1 = _mm_srli_epi64( xmm_product1, 16 ); /* >> 16, zero extending works */
xmm_product2 = _mm_srli_epi64( xmm_product2, 16 );
xmm_tempa = _mm_mul_epi32( coef_Q13_3210, xmm_tempa );
xmm_tempb = _mm_mul_epi32( coef_Q13_7654, xmm_tempb );
xmm_tempa = _mm_srli_epi64( xmm_tempa, 16 );
xmm_tempb = _mm_srli_epi64( xmm_tempb, 16 );
xmm_tempa = _mm_add_epi32( xmm_tempa, xmm_product1 );
xmm_tempb = _mm_add_epi32( xmm_tempb, xmm_product2 );
xmm_tempa = _mm_add_epi32( xmm_tempa, xmm_tempb );
sum = (opus_int32)((coef_Q13_8 * state_8) >> 16);
sum += (opus_int32)((coef_Q13_9 * state_9) >> 16);
xmm_tempa = _mm_add_epi32( xmm_tempa, _mm_shuffle_epi32( xmm_tempa, _MM_SHUFFLE( 0, 0, 0, 2 ) ) );
sum += _mm_cvtsi128_si32( xmm_tempa);
res_Q2[ n ] = silk_LSHIFT( (opus_int32)input[ n ], 2 ) - silk_RSHIFT_ROUND( ( 5 + sum ), 9);
/* move right */
state_a = state_9;
state_9 = state_8;
state_8 = _mm_cvtsi128_si32( state_4567 );
state_4567 = _mm_alignr_epi8( state_0123, state_4567, 4 );
state_0123 = _mm_alignr_epi8( _mm_cvtsi32_si128( silk_LSHIFT( input[ n ], 14 ) ), state_0123, 4 );
}
_mm_storeu_si128( (__m128i *)( &state[ 0 ] ), _mm_shuffle_epi32( state_0123, _MM_SHUFFLE( 0, 1, 2, 3 ) ) );
_mm_storeu_si128( (__m128i *)( &state[ 4 ] ), _mm_shuffle_epi32( state_4567, _MM_SHUFFLE( 0, 1, 2, 3 ) ) );
state[ 8 ] = state_8;
state[ 9 ] = state_9;
state[ 10 ] = state_a;
return;
}
}
for( n = 0; n < length; n++ ) {
/* Output of lowpass section */
tmp2 = silk_SMLAWB( state[ 0 ], state[ 1 ], lambda_Q16 );
state[ 0 ] = silk_LSHIFT( input[ n ], 14 );
/* Output of allpass section */
tmp1 = silk_SMLAWB( state[ 1 ], state[ 2 ] - tmp2, lambda_Q16 );
state[ 1 ] = tmp2;
acc_Q11 = silk_RSHIFT( order, 1 );
acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ 0 ] );
/* Loop over allpass sections */
for( i = 2; i < order; i += 2 ) {
/* Output of allpass section */
tmp2 = silk_SMLAWB( state[ i ], state[ i + 1 ] - tmp1, lambda_Q16 );
state[ i ] = tmp1;
acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ i - 1 ] );
/* Output of allpass section */
tmp1 = silk_SMLAWB( state[ i + 1 ], state[ i + 2 ] - tmp2, lambda_Q16 );
state[ i + 1 ] = tmp2;
acc_Q11 = silk_SMLAWB( acc_Q11, tmp2, coef_Q13[ i ] );
}
state[ order ] = tmp1;
acc_Q11 = silk_SMLAWB( acc_Q11, tmp1, coef_Q13[ order - 1 ] );
res_Q2[ n ] = silk_LSHIFT( (opus_int32)input[ n ], 2 ) - silk_RSHIFT_ROUND( acc_Q11, 9 );
}
}
+24 -19
View File
@@ -36,40 +36,38 @@
#include "SigProc_FIX.h"
#include "pitch.h"
#include "celt/x86/x86cpu.h"
opus_int64 silk_inner_prod16_aligned_64_sse4_1(
opus_int64 silk_inner_prod16_sse4_1(
const opus_int16 *inVec1, /* I input vector 1 */
const opus_int16 *inVec2, /* I input vector 2 */
const opus_int len /* I vector lengths */
)
{
opus_int i, dataSize8;
opus_int i, dataSize4;
opus_int64 sum;
__m128i xmm_tempa;
__m128i inVec1_76543210, acc1;
__m128i inVec2_76543210, acc2;
__m128i xmm_prod_20, xmm_prod_31;
__m128i inVec1_3210, acc1;
__m128i inVec2_3210, acc2;
sum = 0;
dataSize8 = len & ~7;
dataSize4 = len & ~3;
acc1 = _mm_setzero_si128();
acc2 = _mm_setzero_si128();
for( i = 0; i < dataSize8; i += 8 ) {
inVec1_76543210 = _mm_loadu_si128( (__m128i *)(&inVec1[i + 0] ) );
inVec2_76543210 = _mm_loadu_si128( (__m128i *)(&inVec2[i + 0] ) );
for( i = 0; i < dataSize4; i += 4 ) {
inVec1_3210 = OP_CVTEPI16_EPI32_M64( &inVec1[i + 0] );
inVec2_3210 = OP_CVTEPI16_EPI32_M64( &inVec2[i + 0] );
xmm_prod_20 = _mm_mul_epi32( inVec1_3210, inVec2_3210 );
/* only when all 4 operands are -32768 (0x8000), this results in wrap around */
inVec1_76543210 = _mm_madd_epi16( inVec1_76543210, inVec2_76543210 );
inVec1_3210 = _mm_shuffle_epi32( inVec1_3210, _MM_SHUFFLE( 0, 3, 2, 1 ) );
inVec2_3210 = _mm_shuffle_epi32( inVec2_3210, _MM_SHUFFLE( 0, 3, 2, 1 ) );
xmm_prod_31 = _mm_mul_epi32( inVec1_3210, inVec2_3210 );
xmm_tempa = _mm_cvtepi32_epi64( inVec1_76543210 );
/* equal shift right 8 bytes */
inVec1_76543210 = _mm_shuffle_epi32( inVec1_76543210, _MM_SHUFFLE( 0, 0, 3, 2 ) );
inVec1_76543210 = _mm_cvtepi32_epi64( inVec1_76543210 );
acc1 = _mm_add_epi64( acc1, xmm_tempa );
acc2 = _mm_add_epi64( acc2, inVec1_76543210 );
acc1 = _mm_add_epi64( acc1, xmm_prod_20 );
acc2 = _mm_add_epi64( acc2, xmm_prod_31 );
}
acc1 = _mm_add_epi64( acc1, acc2 );
@@ -81,8 +79,15 @@ opus_int64 silk_inner_prod16_aligned_64_sse4_1(
_mm_storel_epi64( (__m128i *)&sum, acc1 );
for( ; i < len; i++ ) {
sum = silk_SMLABB( sum, inVec1[ i ], inVec2[ i ] );
sum = silk_SMLALBB( sum, inVec1[ i ], inVec2[ i ] );
}
#ifdef OPUS_CHECK_ASM
{
opus_int64 sum_c = silk_inner_prod16_c( inVec1, inVec2, len );
silk_assert( sum == sum_c );
}
#endif
return sum;
}
+8 -2
View File
@@ -41,8 +41,14 @@ void silk_LTP_scale_ctrl_FLP(
if( condCoding == CODE_INDEPENDENTLY ) {
/* Only scale if first frame in packet */
round_loss = psEnc->sCmn.PacketLoss_perc + psEnc->sCmn.nFramesPerPacket;
psEnc->sCmn.indices.LTP_scaleIndex = (opus_int8)silk_LIMIT( round_loss * psEncCtrl->LTPredCodGain * 0.1f, 0.0f, 2.0f );
round_loss = psEnc->sCmn.PacketLoss_perc * psEnc->sCmn.nFramesPerPacket;
if ( psEnc->sCmn.LBRR_flag ) {
/* LBRR reduces the effective loss. In practice, it does not square the loss because
losses aren't independent, but that still seems to work best. We also never go below 2%. */
round_loss = 2 + silk_SMULBB( round_loss, round_loss) / 100;
}
psEnc->sCmn.indices.LTP_scaleIndex = silk_SMULBB( psEncCtrl->LTPredCodGain, round_loss ) > silk_log2lin( 2900 - psEnc->sCmn.SNR_dB_Q7 );
psEnc->sCmn.indices.LTP_scaleIndex += silk_SMULBB( psEncCtrl->LTPredCodGain, round_loss ) > silk_log2lin( 3900 - psEnc->sCmn.SNR_dB_Q7 );
} else {
/* Default is minimum scaling */
psEnc->sCmn.indices.LTP_scaleIndex = 0;
+2 -1
View File
@@ -44,7 +44,8 @@ void silk_find_pred_coefs_FLP(
silk_float XXLTP[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ];
silk_float xXLTP[ MAX_NB_SUBFR * LTP_ORDER ];
silk_float invGains[ MAX_NB_SUBFR ];
opus_int16 NLSF_Q15[ MAX_LPC_ORDER ];
/* Set to NLSF_Q15 to zero so we don't copy junk to the state. */
opus_int16 NLSF_Q15[ MAX_LPC_ORDER ]={0};
const silk_float *x_ptr;
silk_float *x_pre_ptr, LPC_in_pre[ MAX_NB_SUBFR * MAX_LPC_ORDER + MAX_FRAME_LENGTH ];
silk_float minInvGain;
+6 -4
View File
@@ -190,12 +190,14 @@ void silk_quant_LTP_gains_FLP(
opus_int32 XX_Q17[ MAX_NB_SUBFR * LTP_ORDER * LTP_ORDER ];
opus_int32 xX_Q17[ MAX_NB_SUBFR * LTP_ORDER ];
for( i = 0; i < nb_subfr * LTP_ORDER * LTP_ORDER; i++ ) {
i = 0;
do {
XX_Q17[ i ] = (opus_int32)silk_float2int( XX[ i ] * 131072.0f );
}
for( i = 0; i < nb_subfr * LTP_ORDER; i++ ) {
} while ( ++i < nb_subfr * LTP_ORDER * LTP_ORDER );
i = 0;
do {
xX_Q17[ i ] = (opus_int32)silk_float2int( xX[ i ] * 131072.0f );
}
} while ( ++i < nb_subfr * LTP_ORDER );
silk_quant_LTP_gains( B_Q14, cbk_index, periodicity_index, sum_log_gain_Q7, &pred_gain_dB_Q7, XX_Q17, xX_Q17, subfr_len, nb_subfr, arch );
+30 -30
View File
@@ -247,21 +247,21 @@ void silk_VQ_WMat_EC_c(
/************************************/
void silk_NSQ_c(
const silk_encoder_state *psEncC, /* I Encoder State */
silk_nsq_state *NSQ, /* I/O NSQ state */
SideInfoIndices *psIndices, /* I/O Quantization Indices */
const opus_int16 x16[], /* I Input */
opus_int8 pulses[], /* O Quantized pulse signal */
const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */
const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */
const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */
const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */
const opus_int LTP_scale_Q14 /* I LTP state scaling */
const silk_encoder_state *psEncC, /* I Encoder State */
silk_nsq_state *NSQ, /* I/O NSQ state */
SideInfoIndices *psIndices, /* I/O Quantization Indices */
const opus_int16 x16[], /* I Input */
opus_int8 pulses[], /* O Quantized pulse signal */
const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */
const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */
const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */
const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */
const opus_int LTP_scale_Q14 /* I LTP state scaling */
);
#if !defined(OVERRIDE_silk_NSQ)
@@ -273,21 +273,21 @@ void silk_NSQ_c(
/* Noise shaping using delayed decision */
void silk_NSQ_del_dec_c(
const silk_encoder_state *psEncC, /* I Encoder State */
silk_nsq_state *NSQ, /* I/O NSQ state */
SideInfoIndices *psIndices, /* I/O Quantization Indices */
const opus_int16 x16[], /* I Input */
opus_int8 pulses[], /* O Quantized pulse signal */
const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */
const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */
const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */
const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */
const opus_int LTP_scale_Q14 /* I LTP state scaling */
const silk_encoder_state *psEncC, /* I Encoder State */
silk_nsq_state *NSQ, /* I/O NSQ state */
SideInfoIndices *psIndices, /* I/O Quantization Indices */
const opus_int16 x16[], /* I Input */
opus_int8 pulses[], /* O Quantized pulse signal */
const opus_int16 PredCoef_Q12[ 2 * MAX_LPC_ORDER ], /* I Short term prediction coefs */
const opus_int16 LTPCoef_Q14[ LTP_ORDER * MAX_NB_SUBFR ], /* I Long term prediction coefs */
const opus_int16 AR_Q13[ MAX_NB_SUBFR * MAX_SHAPE_LPC_ORDER ], /* I Noise shaping coefs */
const opus_int HarmShapeGain_Q14[ MAX_NB_SUBFR ], /* I Long term shaping coefs */
const opus_int Tilt_Q14[ MAX_NB_SUBFR ], /* I Spectral tilt */
const opus_int32 LF_shp_Q14[ MAX_NB_SUBFR ], /* I Low frequency shaping coefs */
const opus_int32 Gains_Q16[ MAX_NB_SUBFR ], /* I Quantization step sizes */
const opus_int pitchL[ MAX_NB_SUBFR ], /* I Pitch lags */
const opus_int Lambda_Q10, /* I Rate/distortion tradeoff */
const opus_int LTP_scale_Q14 /* I LTP state scaling */
);
#if !defined(OVERRIDE_silk_NSQ_del_dec)
Loaded 100 of 136 files, more files were not shown because too many files have changed in this diff. Show more