diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 17945345a..20a663d32 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -28,7 +28,7 @@ jobs: run: | which cmake cmake --version - cmake .. -DOPUS_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON + cmake .. -DOAC_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON - name: Build working-directory: ./build run: make -j 2 -s @@ -53,7 +53,7 @@ jobs: run: cmake --version - name: Configure working-directory: ./build - run: cmake .. -DOPUS_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc + run: cmake .. -DOAC_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc - name: Build working-directory: ./build run: cmake --build . -j 2 --config Release --target package @@ -206,25 +206,25 @@ jobs: name: "CustomModes/Linux/Lib/X64/Release", os: ubuntu-latest, config: Release, - args: "-DOPUS_CUSTOM_MODES=ON" + args: "-DOAC_CUSTOM_MODES=ON" } - { name: "AssertionsFuzz/Windows/Lib/X64/Release", os: windows-latest, config: Release, - args: -G "Visual Studio 17 2022" -A Win32 -DOPUS_ASSERTIONS=ON -DOPUS_FUZZING=ON + args: -G "Visual Studio 17 2022" -A Win32 -DOAC_ASSERTIONS=ON -DOAC_FUZZING=ON } - { name: "AssertionsFuzz/Linux/Lib/X64/Release", os: ubuntu-latest, config: Release, - args: -DOPUS_ASSERTIONS=ON -DOPUS_FUZZING=ON + args: -DOAC_ASSERTIONS=ON -DOAC_FUZZING=ON } - { name: "AssertionsFuzz/MacOSX/Lib/X64/Release", os: macos-latest, config: Release, - args: -DOPUS_ASSERTIONS=ON -DOPUS_FUZZING=ON + args: -DOAC_ASSERTIONS=ON -DOAC_FUZZING=ON } steps: @@ -249,7 +249,7 @@ jobs: run: cmake --version - name: Configure working-directory: ./build - run: cmake .. ${{ matrix.config.args }} -DCMAKE_BUILD_TYPE=${{ matrix.config.config }} -DOPUS_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON + run: cmake .. ${{ matrix.config.args }} -DCMAKE_BUILD_TYPE=${{ matrix.config.config }} -DOAC_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON - name: Build working-directory: ./build run: cmake --build . -j 2 --config ${{ matrix.config.config }} --target package diff --git a/.github/workflows/dred.yml b/.github/workflows/dred.yml index ad316357a..527ded655 100644 --- a/.github/workflows/dred.yml +++ b/.github/workflows/dred.yml @@ -18,7 +18,7 @@ jobs: name: "Windows/Lib/X64/Release", os: windows-latest, config: Release, - args: -G "Visual Studio 17 2022" -DOPUS_X86_PRESUME_AVX2=ON + args: -G "Visual Studio 17 2022" -DOAC_X86_PRESUME_AVX2=ON } - { name: "Windows/Lib/armv8/Release", @@ -30,7 +30,7 @@ jobs: name: "Linux/Lib/X64/Release", os: ubuntu-latest, config: Release, - args: -DOPUS_X86_PRESUME_AVX2=ON + args: -DOAC_X86_PRESUME_AVX2=ON } - { name: "Android/Lib/X64/Release", @@ -49,7 +49,7 @@ jobs: os: macos-latest, config: Release, # some macs are really old in githubs lab so they don't support avx - args: -DOPUS_X86_PRESUME_AVX2=OFF + args: -DOAC_X86_PRESUME_AVX2=OFF } - { name: "iOS/Lib/arm64/Release", @@ -77,7 +77,7 @@ jobs: run: mkdir build - name: Configure working-directory: ./build - run: cmake .. ${{ matrix.config.args }} -DCMAKE_BUILD_TYPE=${{ matrix.config.config }} -DOPUS_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON -DOPUS_FAST_MATH=ON -DOPUS_FLOAT_APPROX=ON -DOPUS_DRED=ON -DOPUS_OSCE=ON + run: cmake .. ${{ matrix.config.args }} -DCMAKE_BUILD_TYPE=${{ matrix.config.config }} -DOAC_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON -DOAC_FAST_MATH=ON -DOAC_FLOAT_APPROX=ON -DOAC_DRED=ON -DOAC_OSCE=ON - name: Build working-directory: ./build run: cmake --build . -j 2 --config ${{ matrix.config.config }} --target package diff --git a/.gitignore b/.gitignore index 5a49669ce..bb86fa591 100644 --- a/.gitignore +++ b/.gitignore @@ -33,8 +33,8 @@ m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 -opus_compare -opus_demo +oac_compare +oac_demo repacketizer_demo stamp-h1 test-driver @@ -46,12 +46,12 @@ trivial_example *.tar.gz *~ tests/*test -tests/test_opus_api -tests/test_opus_decode -tests/test_opus_encode -tests/test_opus_extensions -tests/test_opus_padding -tests/test_opus_projection +tests/test_oac_api +tests/test_oac_decode +tests/test_oac_encode +tests/test_oac_extensions +tests/test_oac_padding +tests/test_oac_projection celt/arm/armopts.s celt/dump_modes/dump_modes celt/tests/test_unit_cwrs32 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 6f8a81f9c..000000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,134 +0,0 @@ -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/main 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 - tags: - - avx2 - before_script: - - apt-get update && - apt-get install -y zip doxygen git automake libtool make wget - - !reference [.snippets, git_prep] - script: - - ./autogen.sh - - CFLAGS="-mavx -mfma -mavx2 -O2 -ffast-math" ./configure --enable-float-approx --enable-dred --enable-osce - - make -j16 - - DISTCHECK_CONFIGURE_FLAGS="--enable-float-approx --enable-dred --enable-osce CFLAGS='-mavx -mfma -mavx2 -O2'" make distcheck -j16 - cache: - paths: - - "src/*.o" - - "src/.libs/*.o" - - "silk/*.o" - - "silk/.libs/*.o" - - "celt/*.o" - - "celt/.libs/*.o" - -cmake: - stage: build - tags: - - avx2 - before_script: - - apt-get update && - apt-get install -y cmake ninja-build git automake libtool wget - - !reference [.snippets, git_prep] - script: - - ./autogen.sh - - mkdir build - - cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DOPUS_BUILD_PROGRAMS=ON -DBUILD_TESTING=ON -DOPUS_FAST_MATH=ON -DOPUS_FLOAT_APPROX=ON -DOPUS_DRED=ON -DOPUS_OSCE=ON -DOPUS_X86_PRESUME_AVX2=ON - - cmake --build build - - cd build && ctest --output-on-failure -j 16 - -.meson: - image: 'debian:bookworm-slim' - stage: build - before_script: - - apt-get update && - apt-get install -y ninja-build doxygen meson git automake libtool wget - - !reference [.snippets, git_prep] - script: - - ./autogen.sh - - mkdir builddir - - meson setup -Ddeep-plc=enabled -Dosce=enabled -Ddred=enabled -Dtests=enabled -Ddocs=enabled -Dbuildtype=release builddir - - meson compile -C builddir - - meson test -C builddir - #- meson dist --no-tests -C builddir - -meson x86_64: - extends: '.meson' - tags: - - avx2 - 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' - -makefile: - stage: build - image: 'gcc' - before_script: - - apt-get update && - apt-get install -y zip doxygen git make wget - - !reference [.snippets, git_prep] - script: - - make -f Makefile.unix -j8 - - make -f Makefile.unix check -j8 - - make -f Makefile.unix clean diff --git a/CMakeLists.txt b/CMakeLists.txt index fcf034b19..61f23455a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,15 @@ cmake_minimum_required(VERSION 3.16) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -include(OpusPackageVersion) +include(OacPackageVersion) get_package_version(PACKAGE_VERSION PROJECT_VERSION) -project(Opus LANGUAGES C VERSION ${PROJECT_VERSION}) +project(Oac LANGUAGES C VERSION ${PROJECT_VERSION}) -include(OpusFunctions) -include(OpusBuildtype) -include(OpusConfig) -include(OpusSources) +include(OacFunctions) +include(OacBuildtype) +include(OacConfig) +include(OacSources) include(GNUInstallDirs) include(CMakeDependentOption) include(FeatureSummary) @@ -22,237 +22,237 @@ if (MSVC) endif() 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) +set(OAC_BUILD_SHARED_LIBRARY_HELP_STR "build shared library.") +option(OAC_BUILD_SHARED_LIBRARY ${OAC_BUILD_SHARED_LIBRARY_HELP_STR} OFF) +if(OAC_BUILD_SHARED_LIBRARY OR BUILD_SHARED_LIBS OR OAC_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) + set(OAC_BUILD_SHARED_LIBRARY ON) endif() -add_feature_info(OPUS_BUILD_SHARED_LIBRARY OPUS_BUILD_SHARED_LIBRARY ${OPUS_BUILD_SHARED_LIBRARY_HELP_STR}) +add_feature_info(OAC_BUILD_SHARED_LIBRARY OAC_BUILD_SHARED_LIBRARY ${OAC_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(OAC_BUILD_TESTING_HELP_STR "build tests.") +option(OAC_BUILD_TESTING ${OAC_BUILD_TESTING_HELP_STR} OFF) +if(OAC_BUILD_TESTING OR BUILD_TESTING) + set(OAC_BUILD_TESTING ON) set(BUILD_TESTING ON) endif() -add_feature_info(OPUS_BUILD_TESTING OPUS_BUILD_TESTING ${OPUS_BUILD_TESTING_HELP_STR}) +add_feature_info(OAC_BUILD_TESTING OAC_BUILD_TESTING ${OAC_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(OAC_CUSTOM_MODES_HELP_STR "enable non-Oac modes, e.g. 44.1 kHz & 2^n frames.") +option(OAC_CUSTOM_MODES ${OAC_CUSTOM_MODES_HELP_STR} OFF) +add_feature_info(OAC_CUSTOM_MODES OAC_CUSTOM_MODES ${OAC_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(OAC_BUILD_PROGRAMS_HELP_STR "build programs.") +option(OAC_BUILD_PROGRAMS ${OAC_BUILD_PROGRAMS_HELP_STR} OFF) +add_feature_info(OAC_BUILD_PROGRAMS OAC_BUILD_PROGRAMS ${OAC_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(OAC_DISABLE_INTRINSICS_HELP_STR "disable all intrinsics optimizations.") +option(OAC_DISABLE_INTRINSICS ${OAC_DISABLE_INTRINSICS_HELP_STR} OFF) +add_feature_info(OAC_DISABLE_INTRINSICS OAC_DISABLE_INTRINSICS ${OAC_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(OAC_FIXED_POINT_HELP_STR "compile as fixed-point (for machines without a fast enough FPU).") +option(OAC_FIXED_POINT ${OAC_FIXED_POINT_HELP_STR} OFF) +add_feature_info(OAC_FIXED_POINT OAC_FIXED_POINT ${OAC_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(OAC_ENABLE_FLOAT_API_HELP_STR "compile with the floating point API (for machines with float library).") +option(OAC_ENABLE_FLOAT_API ${OAC_ENABLE_FLOAT_API_HELP_STR} ON) +add_feature_info(OAC_ENABLE_FLOAT_API OAC_ENABLE_FLOAT_API ${OAC_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(OAC_FLOAT_APPROX_HELP_STR "enable floating point approximations (Ensure your platform supports IEEE 754 before enabling).") +option(OAC_FLOAT_APPROX ${OAC_FLOAT_APPROX_HELP_STR} OFF) +add_feature_info(OAC_FLOAT_APPROX OAC_FLOAT_APPROX ${OAC_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(OAC_ASSERTIONS_HELP_STR "additional software error checking.") +option(OAC_ASSERTIONS ${OAC_ASSERTIONS_HELP_STR} OFF) +add_feature_info(OAC_ASSERTIONS OAC_ASSERTIONS ${OAC_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(OAC_HARDENING_HELP_STR "run-time checks that are cheap and safe for use in production.") +option(OAC_HARDENING ${OAC_HARDENING_HELP_STR} ON) +add_feature_info(OAC_HARDENING OAC_HARDENING ${OAC_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(OAC_FUZZING_HELP_STR "causes the encoder to make random decisions (do not use in production).") +option(OAC_FUZZING ${OAC_FUZZING_HELP_STR} OFF) +add_feature_info(OAC_FUZZING OAC_FUZZING ${OAC_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(OAC_CHECK_ASM_HELP_STR "enable bit-exactness checks between optimized and c implementations.") +option(OAC_CHECK_ASM ${OAC_CHECK_ASM_HELP_STR} OFF) +add_feature_info(OAC_CHECK_ASM OAC_CHECK_ASM ${OAC_CHECK_ASM_HELP_STR}) -set(OPUS_DNN_FLOAT_DEBUG_HELP_STR "Run DNN computations as float for debugging purposes.") -option(OPUS_DNN_FLOAT_DEBUG ${OPUS_DNN_FLOAT_DEBUG_HELP_STR} OFF) -add_feature_info(OPUS_DNN_FLOAT_DEBUG OPUS_DNN_FLOAT_DEBUG ${OPUS_DNN_FLOAT_DEBUG_HELP_STR}) +set(OAC_DNN_FLOAT_DEBUG_HELP_STR "Run DNN computations as float for debugging purposes.") +option(OAC_DNN_FLOAT_DEBUG ${OAC_DNN_FLOAT_DEBUG_HELP_STR} OFF) +add_feature_info(OAC_DNN_FLOAT_DEBUG OAC_DNN_FLOAT_DEBUG ${OAC_DNN_FLOAT_DEBUG_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(OAC_INSTALL_PKG_CONFIG_MODULE_HELP_STR "install pkg-config module.") +option(OAC_INSTALL_PKG_CONFIG_MODULE ${OAC_INSTALL_PKG_CONFIG_MODULE_HELP_STR} ON) +add_feature_info(OAC_INSTALL_PKG_CONFIG_MODULE OAC_INSTALL_PKG_CONFIG_MODULE ${OAC_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}) +set(OAC_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR "install CMake package config module.") +option(OAC_INSTALL_CMAKE_CONFIG_MODULE ${OAC_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR} ON) +add_feature_info(OAC_INSTALL_CMAKE_CONFIG_MODULE OAC_INSTALL_CMAKE_CONFIG_MODULE ${OAC_INSTALL_CMAKE_CONFIG_MODULE_HELP_STR}) -set(OPUS_DRED_HELP_STR "enable DRED.") -option(OPUS_DRED ${OPUS_DRED_HELP_STR} OFF) -add_feature_info(OPUS_DRED OPUS_DRED ${OPUS_DRED_HELP_STR}) +set(OAC_DRED_HELP_STR "enable DRED.") +option(OAC_DRED ${OAC_DRED_HELP_STR} OFF) +add_feature_info(OAC_DRED OAC_DRED ${OAC_DRED_HELP_STR}) -set(OPUS_OSCE_HELP_STR "enable OSCE.") -option(OPUS_OSCE ${OPUS_OSCE_HELP_STR} OFF) -add_feature_info(OPUS_OSCE OPUS_OSCE ${OPUS_OSCE_HELP_STR}) +set(OAC_OSCE_HELP_STR "enable OSCE.") +option(OAC_OSCE ${OAC_OSCE_HELP_STR} OFF) +add_feature_info(OAC_OSCE OAC_OSCE ${OAC_OSCE_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}) + set(OAC_BUILD_FRAMEWORK_HELP_STR "build Framework bundle for Apple systems.") + option(OAC_BUILD_FRAMEWORK ${OAC_BUILD_FRAMEWORK_HELP_STR} OFF) + add_feature_info(OAC_BUILD_FRAMEWORK OAC_BUILD_FRAMEWORK ${OAC_BUILD_FRAMEWORK_HELP_STR}) endif() if(MSVC) - set(OPUS_STATIC_RUNTIME_HELP_STR "build with static runtime library.") - option(OPUS_STATIC_RUNTIME ${OPUS_STATIC_RUNTIME_HELP_STR} OFF) - add_feature_info(OPUS_STATIC_RUNTIME OPUS_STATIC_RUNTIME ${OPUS_STATIC_RUNTIME_HELP_STR}) + set(OAC_STATIC_RUNTIME_HELP_STR "build with static runtime library.") + option(OAC_STATIC_RUNTIME ${OAC_STATIC_RUNTIME_HELP_STR} OFF) + add_feature_info(OAC_STATIC_RUNTIME OAC_STATIC_RUNTIME ${OAC_STATIC_RUNTIME_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} +set(OAC_FIXED_POINT_DEBUG_HELP_STR "debug fixed-point implementation.") +cmake_dependent_option(OAC_FIXED_POINT_DEBUG + ${OAC_FIXED_POINT_DEBUG_HELP_STR} ON - "OPUS_FIXED_POINT; OPUS_FIXED_POINT_DEBUG" + "OAC_FIXED_POINT; OAC_FIXED_POINT_DEBUG" OFF) -add_feature_info(OPUS_FIXED_POINT_DEBUG OPUS_FIXED_POINT_DEBUG ${OPUS_FIXED_POINT_DEBUG_HELP_STR}) +add_feature_info(OAC_FIXED_POINT_DEBUG OAC_FIXED_POINT_DEBUG ${OAC_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} +set(OAC_VAR_ARRAYS_HELP_STR "use variable length arrays for stack arrays.") +cmake_dependent_option(OAC_VAR_ARRAYS + ${OAC_VAR_ARRAYS_HELP_STR} ON - "VLA_SUPPORTED; NOT OPUS_USE_ALLOCA; NOT OPUS_NONTHREADSAFE_PSEUDOSTACK" + "VLA_SUPPORTED; NOT OAC_USE_ALLOCA; NOT OAC_NONTHREADSAFE_PSEUDOSTACK" OFF) -add_feature_info(OPUS_VAR_ARRAYS OPUS_VAR_ARRAYS ${OPUS_VAR_ARRAYS_HELP_STR}) +add_feature_info(OAC_VAR_ARRAYS OAC_VAR_ARRAYS ${OAC_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} +set(OAC_USE_ALLOCA_HELP_STR "use alloca for stack arrays (on non-C99 compilers).") +cmake_dependent_option(OAC_USE_ALLOCA + ${OAC_USE_ALLOCA_HELP_STR} ON - "USE_ALLOCA_SUPPORTED; NOT OPUS_VAR_ARRAYS; NOT OPUS_NONTHREADSAFE_PSEUDOSTACK" + "USE_ALLOCA_SUPPORTED; NOT OAC_VAR_ARRAYS; NOT OAC_NONTHREADSAFE_PSEUDOSTACK" OFF) -add_feature_info(OPUS_USE_ALLOCA OPUS_USE_ALLOCA ${OPUS_USE_ALLOCA_HELP_STR}) +add_feature_info(OAC_USE_ALLOCA OAC_USE_ALLOCA ${OAC_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} +set(OAC_NONTHREADSAFE_PSEUDOSTACK_HELP_STR "use a non threadsafe pseudostack when neither variable length arrays or alloca is supported.") +cmake_dependent_option(OAC_NONTHREADSAFE_PSEUDOSTACK + ${OAC_NONTHREADSAFE_PSEUDOSTACK_HELP_STR} ON - "NOT OPUS_VAR_ARRAYS; NOT OPUS_USE_ALLOCA" + "NOT OAC_VAR_ARRAYS; NOT OAC_USE_ALLOCA" OFF) -add_feature_info(OPUS_NONTHREADSAFE_PSEUDOSTACK OPUS_NONTHREADSAFE_PSEUDOSTACK ${OPUS_NONTHREADSAFE_PSEUDOSTACK_HELP_STR}) +add_feature_info(OAC_NONTHREADSAFE_PSEUDOSTACK OAC_NONTHREADSAFE_PSEUDOSTACK ${OAC_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} +set(OAC_FAST_MATH_HELP_STR "enable fast math (unsupported and discouraged use, as code is not well tested with this build option).") +cmake_dependent_option(OAC_FAST_MATH + ${OAC_FAST_MATH_HELP_STR} ON - "OPUS_FLOAT_APPROX; OPUS_FAST_MATH; FAST_MATH_SUPPORTED" + "OAC_FLOAT_APPROX; OAC_FAST_MATH; FAST_MATH_SUPPORTED" OFF) -add_feature_info(OPUS_FAST_MATH OPUS_FAST_MATH ${OPUS_FAST_MATH_HELP_STR}) +add_feature_info(OAC_FAST_MATH OAC_FAST_MATH ${OAC_FAST_MATH_HELP_STR}) -set(OPUS_STACK_PROTECTOR_HELP_STR "use stack protection.") -cmake_dependent_option(OPUS_STACK_PROTECTOR - ${OPUS_STACK_PROTECTOR_HELP_STR} +set(OAC_STACK_PROTECTOR_HELP_STR "use stack protection.") +cmake_dependent_option(OAC_STACK_PROTECTOR + ${OAC_STACK_PROTECTOR_HELP_STR} ON "STACK_PROTECTOR_SUPPORTED" OFF) -add_feature_info(OPUS_STACK_PROTECTOR OPUS_STACK_PROTECTOR ${OPUS_STACK_PROTECTOR_HELP_STR}) +add_feature_info(OAC_STACK_PROTECTOR OAC_STACK_PROTECTOR ${OAC_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} + set(OAC_FORTIFY_SOURCE_HELP_STR "add protection against buffer overflows.") + cmake_dependent_option(OAC_FORTIFY_SOURCE + ${OAC_FORTIFY_SOURCE_HELP_STR} ON "FORTIFY_SOURCE_SUPPORTED" OFF) - add_feature_info(OPUS_FORTIFY_SOURCE OPUS_FORTIFY_SOURCE ${OPUS_FORTIFY_SOURCE_HELP_STR}) + add_feature_info(OAC_FORTIFY_SOURCE OAC_FORTIFY_SOURCE ${OAC_FORTIFY_SOURCE_HELP_STR}) endif() -if(MINGW AND (OPUS_FORTIFY_SOURCE OR OPUS_STACK_PROTECTOR)) +if(MINGW AND (OAC_FORTIFY_SOURCE OR OAC_STACK_PROTECTOR)) # ssp lib is needed for security features for MINGW - list(APPEND OPUS_REQUIRED_LIBRARIES ssp) + list(APPEND OAC_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 - ${OPUS_X86_MAY_HAVE_SSE_HELP_STR} +if(OAC_CPU_X86 OR OAC_CPU_X64) + set(OAC_X86_MAY_HAVE_SSE_HELP_STR "does runtime check for SSE1 support.") + cmake_dependent_option(OAC_X86_MAY_HAVE_SSE + ${OAC_X86_MAY_HAVE_SSE_HELP_STR} ON - "SSE1_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" + "SSE1_SUPPORTED; NOT OAC_DISABLE_INTRINSICS" OFF) - add_feature_info(OPUS_X86_MAY_HAVE_SSE OPUS_X86_MAY_HAVE_SSE ${OPUS_X86_MAY_HAVE_SSE_HELP_STR}) + add_feature_info(OAC_X86_MAY_HAVE_SSE OAC_X86_MAY_HAVE_SSE ${OAC_X86_MAY_HAVE_SSE_HELP_STR}) - set(OPUS_X86_MAY_HAVE_SSE2_HELP_STR "does runtime check for SSE2 support.") - cmake_dependent_option(OPUS_X86_MAY_HAVE_SSE2 - ${OPUS_X86_MAY_HAVE_SSE2_HELP_STR} + set(OAC_X86_MAY_HAVE_SSE2_HELP_STR "does runtime check for SSE2 support.") + cmake_dependent_option(OAC_X86_MAY_HAVE_SSE2 + ${OAC_X86_MAY_HAVE_SSE2_HELP_STR} ON - "SSE2_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" + "SSE2_SUPPORTED; NOT OAC_DISABLE_INTRINSICS" OFF) - add_feature_info(OPUS_X86_MAY_HAVE_SSE2 OPUS_X86_MAY_HAVE_SSE2 ${OPUS_X86_MAY_HAVE_SSE2_HELP_STR}) + add_feature_info(OAC_X86_MAY_HAVE_SSE2 OAC_X86_MAY_HAVE_SSE2 ${OAC_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} + set(OAC_X86_MAY_HAVE_SSE4_1_HELP_STR "does runtime check for SSE4.1 support.") + cmake_dependent_option(OAC_X86_MAY_HAVE_SSE4_1 + ${OAC_X86_MAY_HAVE_SSE4_1_HELP_STR} ON - "SSE4_1_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" + "SSE4_1_SUPPORTED; NOT OAC_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}) + add_feature_info(OAC_X86_MAY_HAVE_SSE4_1 OAC_X86_MAY_HAVE_SSE4_1 ${OAC_X86_MAY_HAVE_SSE4_1_HELP_STR}) - set(OPUS_X86_MAY_HAVE_AVX2_HELP_STR "does runtime check for AVX FMA AVX2 support.") - cmake_dependent_option(OPUS_X86_MAY_HAVE_AVX2 - ${OPUS_X86_MAY_HAVE_AVX2_HELP_STR} + set(OAC_X86_MAY_HAVE_AVX2_HELP_STR "does runtime check for AVX FMA AVX2 support.") + cmake_dependent_option(OAC_X86_MAY_HAVE_AVX2 + ${OAC_X86_MAY_HAVE_AVX2_HELP_STR} ON - "AVX2_SUPPORTED; NOT OPUS_DISABLE_INTRINSICS" + "AVX2_SUPPORTED; NOT OAC_DISABLE_INTRINSICS" OFF) - add_feature_info(OPUS_X86_MAY_HAVE_AVX2 OPUS_X86_MAY_HAVE_AVX2 ${OPUS_X86_MAY_HAVE_AVX2_HELP_STR}) + add_feature_info(OAC_X86_MAY_HAVE_AVX2 OAC_X86_MAY_HAVE_AVX2 ${OAC_X86_MAY_HAVE_AVX2_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 - ${OPUS_X86_PRESUME_SSE_HELP_STR} + set(OAC_X86_PRESUME_SSE_HELP_STR "assume target CPU has SSE1 support (override runtime check).") + set(OAC_X86_PRESUME_SSE2_HELP_STR "assume target CPU has SSE2 support (override runtime check).") + if(OAC_CPU_X64) # Assume x86_64 has up to SSE2 support + cmake_dependent_option(OAC_X86_PRESUME_SSE + ${OAC_X86_PRESUME_SSE_HELP_STR} ON - "OPUS_X86_MAY_HAVE_SSE; NOT OPUS_DISABLE_INTRINSICS" + "OAC_X86_MAY_HAVE_SSE; NOT OAC_DISABLE_INTRINSICS" OFF) - cmake_dependent_option(OPUS_X86_PRESUME_SSE2 - ${OPUS_X86_PRESUME_SSE2_HELP_STR} + cmake_dependent_option(OAC_X86_PRESUME_SSE2 + ${OAC_X86_PRESUME_SSE2_HELP_STR} ON - "OPUS_X86_MAY_HAVE_SSE2; NOT OPUS_DISABLE_INTRINSICS" + "OAC_X86_MAY_HAVE_SSE2; NOT OAC_DISABLE_INTRINSICS" OFF) else() - cmake_dependent_option(OPUS_X86_PRESUME_SSE - ${OPUS_X86_PRESUME_SSE_HELP_STR} + cmake_dependent_option(OAC_X86_PRESUME_SSE + ${OAC_X86_PRESUME_SSE_HELP_STR} OFF - "OPUS_X86_MAY_HAVE_SSE; NOT OPUS_DISABLE_INTRINSICS" + "OAC_X86_MAY_HAVE_SSE; NOT OAC_DISABLE_INTRINSICS" OFF) - cmake_dependent_option(OPUS_X86_PRESUME_SSE2 - ${OPUS_X86_PRESUME_SSE2_HELP_STR} + cmake_dependent_option(OAC_X86_PRESUME_SSE2 + ${OAC_X86_PRESUME_SSE2_HELP_STR} OFF - "OPUS_X86_MAY_HAVE_SSE2; NOT OPUS_DISABLE_INTRINSICS" + "OAC_X86_MAY_HAVE_SSE2; NOT OAC_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}) + add_feature_info(OAC_X86_PRESUME_SSE OAC_X86_PRESUME_SSE ${OAC_X86_PRESUME_SSE_HELP_STR}) + add_feature_info(OAC_X86_PRESUME_SSE2 OAC_X86_PRESUME_SSE2 ${OAC_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 - ${OPUS_X86_PRESUME_SSE4_1_HELP_STR} + set(OAC_X86_PRESUME_SSE4_1_HELP_STR "assume target CPU has SSE4.1 support (override runtime check).") + cmake_dependent_option(OAC_X86_PRESUME_SSE4_1 + ${OAC_X86_PRESUME_SSE4_1_HELP_STR} OFF - "OPUS_X86_MAY_HAVE_SSE4_1; NOT OPUS_DISABLE_INTRINSICS" + "OAC_X86_MAY_HAVE_SSE4_1; NOT OAC_DISABLE_INTRINSICS" OFF) - add_feature_info(OPUS_X86_PRESUME_SSE4_1 OPUS_X86_PRESUME_SSE4_1 ${OPUS_X86_PRESUME_SSE4_1_HELP_STR}) + add_feature_info(OAC_X86_PRESUME_SSE4_1 OAC_X86_PRESUME_SSE4_1 ${OAC_X86_PRESUME_SSE4_1_HELP_STR}) - set(OPUS_X86_PRESUME_AVX2_HELP_STR "assume target CPU has AVX FMA AVX2 support (override runtime check).") - cmake_dependent_option(OPUS_X86_PRESUME_AVX2 - ${OPUS_X86_PRESUME_AVX2_HELP_STR} + set(OAC_X86_PRESUME_AVX2_HELP_STR "assume target CPU has AVX FMA AVX2 support (override runtime check).") + cmake_dependent_option(OAC_X86_PRESUME_AVX2 + ${OAC_X86_PRESUME_AVX2_HELP_STR} OFF - "OPUS_X86_MAY_HAVE_AVX2; NOT OPUS_DISABLE_INTRINSICS" + "OAC_X86_MAY_HAVE_AVX2; NOT OAC_DISABLE_INTRINSICS" OFF) - add_feature_info(OPUS_X86_PRESUME_AVX2 OPUS_X86_PRESUME_AVX2 ${OPUS_X86_PRESUME_AVX2_HELP_STR}) + add_feature_info(OAC_X86_PRESUME_AVX2 OAC_X86_PRESUME_AVX2 ${OAC_X86_PRESUME_AVX2_HELP_STR}) endif() feature_summary(WHAT ALL) @@ -268,260 +268,260 @@ set_package_properties(Git PURPOSE "required to set up package version") -set(Opus_PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR}/include/opus.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) +set(Oac_PUBLIC_HEADER + ${CMAKE_CURRENT_SOURCE_DIR}/include/oac.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/oac_defines.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/oac_multistream.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/oac_projection.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/oac_types.h) -if(OPUS_CUSTOM_MODES) - list(APPEND Opus_PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/opus_custom.h) +if(OAC_CUSTOM_MODES) + list(APPEND Oac_PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/oac_custom.h) endif() if(MSVC) - if(OPUS_STATIC_RUNTIME) + if(OAC_STATIC_RUNTIME) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") else() set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") endif() endif() -add_library(opus ${opus_headers} ${opus_sources} ${opus_sources_float} ${Opus_PUBLIC_HEADER}) -add_library(Opus::opus ALIAS opus) +add_library(oac ${oac_headers} ${oac_sources} ${oac_sources_float} ${Oac_PUBLIC_HEADER}) +add_library(Oac::oac ALIAS oac) -get_library_version(OPUS_LIBRARY_VERSION OPUS_LIBRARY_VERSION_MAJOR) -message(DEBUG "Opus library version: ${OPUS_LIBRARY_VERSION}") +get_library_version(OAC_LIBRARY_VERSION OAC_LIBRARY_VERSION_MAJOR) +message(DEBUG "Oac library version: ${OAC_LIBRARY_VERSION}") -set_target_properties(opus +set_target_properties(oac PROPERTIES SOVERSION - ${OPUS_LIBRARY_VERSION_MAJOR} + ${OAC_LIBRARY_VERSION_MAJOR} VERSION - ${OPUS_LIBRARY_VERSION} + ${OAC_LIBRARY_VERSION} PUBLIC_HEADER - "${Opus_PUBLIC_HEADER}") + "${Oac_PUBLIC_HEADER}") target_include_directories( - opus + oac PUBLIC $ $ - $ + $ PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/dnn celt silk) -target_link_libraries(opus PRIVATE ${OPUS_REQUIRED_LIBRARIES}) -target_compile_definitions(opus PRIVATE OPUS_BUILD) +target_link_libraries(oac PRIVATE ${OAC_REQUIRED_LIBRARIES}) +target_compile_definitions(oac PRIVATE OAC_BUILD) -if(OPUS_FIXED_POINT_DEBUG) - target_compile_definitions(opus PRIVATE FIXED_DEBUG) +if(OAC_FIXED_POINT_DEBUG) + target_compile_definitions(oac PRIVATE FIXED_DEBUG) endif() -if(OPUS_FORTIFY_SOURCE AND NOT MSVC) - target_compile_definitions(opus PRIVATE +if(OAC_FORTIFY_SOURCE AND NOT MSVC) + target_compile_definitions(oac PRIVATE $<$>:_FORTIFY_SOURCE=2>) endif() -if(OPUS_FLOAT_APPROX) - target_compile_definitions(opus PRIVATE FLOAT_APPROX) +if(OAC_FLOAT_APPROX) + target_compile_definitions(oac PRIVATE FLOAT_APPROX) endif() -if(OPUS_ASSERTIONS) - target_compile_definitions(opus PRIVATE ENABLE_ASSERTIONS) +if(OAC_ASSERTIONS) + target_compile_definitions(oac PRIVATE ENABLE_ASSERTIONS) endif() -if(OPUS_HARDENING) - target_compile_definitions(opus PRIVATE ENABLE_HARDENING) +if(OAC_HARDENING) + target_compile_definitions(oac PRIVATE ENABLE_HARDENING) endif() -if(OPUS_FUZZING) - target_compile_definitions(opus PRIVATE FUZZING) +if(OAC_FUZZING) + target_compile_definitions(oac PRIVATE FUZZING) endif() -if(OPUS_CHECK_ASM) - target_compile_definitions(opus PRIVATE OPUS_CHECK_ASM) +if(OAC_CHECK_ASM) + target_compile_definitions(oac PRIVATE OAC_CHECK_ASM) endif() -if(NOT OPUS_DNN_FLOAT_DEBUG) - target_compile_definitions(opus PRIVATE DISABLE_DEBUG_FLOAT) +if(NOT OAC_DNN_FLOAT_DEBUG) + target_compile_definitions(oac PRIVATE DISABLE_DEBUG_FLOAT) 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) +if(OAC_VAR_ARRAYS) + target_compile_definitions(oac PRIVATE VAR_ARRAYS) +elseif(OAC_USE_ALLOCA) + target_compile_definitions(oac PRIVATE USE_ALLOCA) +elseif(OAC_NONTHREADSAFE_PSEUDOSTACK) + target_compile_definitions(oac 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) +if(OAC_CUSTOM_MODES) + target_compile_definitions(oac PRIVATE CUSTOM_MODES) endif() -if(OPUS_FAST_MATH) +if(OAC_FAST_MATH) if(MSVC) - target_compile_options(opus PRIVATE /fp:fast) + target_compile_options(oac PRIVATE /fp:fast) else() - target_compile_options(opus PRIVATE -ffast-math) + target_compile_options(oac PRIVATE -ffast-math) endif() endif() -if(OPUS_STACK_PROTECTOR) +if(OAC_STACK_PROTECTOR) if(MSVC) - target_compile_options(opus PRIVATE /GS) + target_compile_options(oac PRIVATE /GS) else() - target_compile_options(opus PRIVATE -fstack-protector-strong) + target_compile_options(oac PRIVATE -fstack-protector-strong) endif() elseif(STACK_PROTECTOR_DISABLED_SUPPORTED) - target_compile_options(opus PRIVATE /GS-) + target_compile_options(oac PRIVATE /GS-) endif() if(BUILD_SHARED_LIBS) if(WIN32) - target_compile_definitions(opus PRIVATE DLL_EXPORT) + target_compile_definitions(oac PRIVATE DLL_EXPORT) elseif(HIDDEN_VISIBILITY_SUPPORTED) - set_target_properties(opus PROPERTIES C_VISIBILITY_PRESET hidden) + set_target_properties(oac 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}) +add_sources_group(oac silk ${silk_headers} ${silk_sources}) +add_sources_group(oac celt ${celt_headers} ${celt_sources}) -if(OPUS_FIXED_POINT) - add_sources_group(opus silk ${silk_sources_fixed}) - target_include_directories(opus PRIVATE silk/fixed) - target_compile_definitions(opus PRIVATE FIXED_POINT=1) +if(OAC_FIXED_POINT) + add_sources_group(oac silk ${silk_sources_fixed}) + target_include_directories(oac PRIVATE silk/fixed) + target_compile_definitions(oac PRIVATE FIXED_POINT=1) else() - add_sources_group(opus silk ${silk_sources_float}) - target_include_directories(opus PRIVATE silk/float) + add_sources_group(oac silk ${silk_sources_float}) + target_include_directories(oac PRIVATE silk/float) endif() -if(NOT OPUS_ENABLE_FLOAT_API) - target_compile_definitions(opus PRIVATE DISABLE_FLOAT_API) +if(NOT OAC_ENABLE_FLOAT_API) + target_compile_definitions(oac PRIVATE DISABLE_FLOAT_API) endif() -if (OPUS_DEEP_PLC OR OPUS_DRED OR OPUS_OSCE) - add_sources_group(opus lpcnet ${deep_plc_headers} ${deep_plc_sources}) - set(OPUS_DNN TRUE) +if (OAC_DEEP_PLC OR OAC_DRED OR OAC_OSCE) + add_sources_group(oac lpcnet ${deep_plc_headers} ${deep_plc_sources}) + set(OAC_DNN TRUE) else() - set(OPUS_DNN FALSE) + set(OAC_DNN FALSE) endif() -if (OPUS_DNN) - add_sources_group(opus lpcnet ${deep_plc_headers} ${deep_plc_sources}) - target_compile_definitions(opus PRIVATE ENABLE_DEEP_PLC) +if (OAC_DNN) + add_sources_group(oac lpcnet ${deep_plc_headers} ${deep_plc_sources}) + target_compile_definitions(oac PRIVATE ENABLE_DEEP_PLC) endif() -if (OPUS_DRED) - add_sources_group(opus lpcnet ${dred_headers} ${dred_sources}) - target_compile_definitions(opus PRIVATE ENABLE_DRED) +if (OAC_DRED) + add_sources_group(oac lpcnet ${dred_headers} ${dred_sources}) + target_compile_definitions(oac PRIVATE ENABLE_DRED) endif() -if (OPUS_OSCE) - add_sources_group(opus lpcnet ${osce_headers} ${osce_sources}) - target_compile_definitions(opus PRIVATE ENABLE_OSCE) +if (OAC_OSCE) + add_sources_group(oac lpcnet ${osce_headers} ${osce_sources}) + target_compile_definitions(oac PRIVATE ENABLE_OSCE) endif() -if(NOT OPUS_DISABLE_INTRINSICS) - if(((OPUS_X86_MAY_HAVE_SSE AND NOT OPUS_X86_PRESUME_SSE) OR - (OPUS_X86_MAY_HAVE_SSE2 AND NOT OPUS_X86_PRESUME_SSE2) OR - (OPUS_X86_MAY_HAVE_SSE4_1 AND NOT OPUS_X86_PRESUME_SSE4_1) OR - (OPUS_X86_MAY_HAVE_AVX2 AND NOT OPUS_X86_PRESUME_AVX2)) AND +if(NOT OAC_DISABLE_INTRINSICS) + if(((OAC_X86_MAY_HAVE_SSE AND NOT OAC_X86_PRESUME_SSE) OR + (OAC_X86_MAY_HAVE_SSE2 AND NOT OAC_X86_PRESUME_SSE2) OR + (OAC_X86_MAY_HAVE_SSE4_1 AND NOT OAC_X86_PRESUME_SSE4_1) OR + (OAC_X86_MAY_HAVE_AVX2 AND NOT OAC_X86_PRESUME_AVX2)) AND RUNTIME_CPU_CAPABILITY_DETECTION) - target_compile_definitions(opus PRIVATE OPUS_HAVE_RTCD) + target_compile_definitions(oac PRIVATE OAC_HAVE_RTCD) if(NOT MSVC) if(CPU_INFO_BY_ASM_SUPPORTED) - target_compile_definitions(opus PRIVATE CPU_INFO_BY_ASM) + target_compile_definitions(oac PRIVATE CPU_INFO_BY_ASM) elseif(CPU_INFO_BY_C_SUPPORTED) - target_compile_definitions(opus PRIVATE CPU_INFO_BY_C) + target_compile_definitions(oac PRIVATE CPU_INFO_BY_C) else() message(ERROR "Runtime cpu capability detection is enabled while CPU_INFO is not supported") endif() endif() - add_sources_group(opus celt ${celt_sources_x86_rtcd}) - add_sources_group(opus silk ${silk_sources_x86_rtcd}) - if (OPUS_DNN) - add_sources_group(opus lpcnet ${dnn_sources_x86_rtcd}) + add_sources_group(oac celt ${celt_sources_x86_rtcd}) + add_sources_group(oac silk ${silk_sources_x86_rtcd}) + if (OAC_DNN) + add_sources_group(oac lpcnet ${dnn_sources_x86_rtcd}) endif() endif() if(SSE1_SUPPORTED) - if(OPUS_X86_MAY_HAVE_SSE) - add_sources_group(opus celt ${celt_sources_sse}) - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE) + if(OAC_X86_MAY_HAVE_SSE) + add_sources_group(oac celt ${celt_sources_sse}) + target_compile_definitions(oac PRIVATE OAC_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(OAC_X86_PRESUME_SSE) + target_compile_definitions(oac PRIVATE OAC_X86_PRESUME_SSE) if(NOT MSVC) - target_compile_options(opus PRIVATE -msse) + target_compile_options(oac PRIVATE -msse) endif() endif() endif() if(SSE2_SUPPORTED) - if(OPUS_X86_MAY_HAVE_SSE2) - add_sources_group(opus celt ${celt_sources_sse2}) - if (OPUS_DNN) - add_sources_group(opus lpcnet ${dnn_sources_sse2}) + if(OAC_X86_MAY_HAVE_SSE2) + add_sources_group(oac celt ${celt_sources_sse2}) + if (OAC_DNN) + add_sources_group(oac lpcnet ${dnn_sources_sse2}) endif() - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE2) + target_compile_definitions(oac PRIVATE OAC_X86_MAY_HAVE_SSE2) if(NOT MSVC) set_source_files_properties(${celt_sources_sse2} ${dnn_sources_sse2} PROPERTIES COMPILE_FLAGS -msse2) endif() endif() - if(OPUS_X86_PRESUME_SSE2) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE2) + if(OAC_X86_PRESUME_SSE2) + target_compile_definitions(oac PRIVATE OAC_X86_PRESUME_SSE2) if(NOT MSVC) - target_compile_options(opus PRIVATE -msse2) + target_compile_options(oac 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}) - if (OPUS_DNN) - add_sources_group(opus lpcnet ${dnn_sources_sse4_1}) + if(OAC_X86_MAY_HAVE_SSE4_1) + add_sources_group(oac celt ${celt_sources_sse4_1}) + add_sources_group(oac silk ${silk_sources_sse4_1}) + if (OAC_DNN) + add_sources_group(oac lpcnet ${dnn_sources_sse4_1}) endif() - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_SSE4_1) + target_compile_definitions(oac PRIVATE OAC_X86_MAY_HAVE_SSE4_1) if(NOT MSVC OR MSVC_CLANG_CL) set_source_files_properties(${celt_sources_sse4_1} ${silk_sources_sse4_1} ${dnn_sources_sse4_1} PROPERTIES COMPILE_FLAGS -msse4.1) endif() - if(OPUS_FIXED_POINT) - add_sources_group(opus silk ${silk_sources_fixed_sse4_1}) + if(OAC_FIXED_POINT) + add_sources_group(oac silk ${silk_sources_fixed_sse4_1}) if(NOT MSVC OR MSVC_CLANG_CL) 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(OAC_X86_PRESUME_SSE4_1) + target_compile_definitions(oac PRIVATE OAC_X86_PRESUME_SSE4_1) if(NOT MSVC OR MSVC_CLANG_CL) - target_compile_options(opus PRIVATE -msse4.1) + target_compile_options(oac PRIVATE -msse4.1) endif() endif() endif() if(AVX2_SUPPORTED) - if(OPUS_X86_MAY_HAVE_AVX2) - add_sources_group(opus celt ${celt_sources_avx2}) - add_sources_group(opus silk ${silk_sources_avx2}) - if (NOT OPUS_FIXED_POINT) - add_sources_group(opus silk ${silk_sources_float_avx2}) + if(OAC_X86_MAY_HAVE_AVX2) + add_sources_group(oac celt ${celt_sources_avx2}) + add_sources_group(oac silk ${silk_sources_avx2}) + if (NOT OAC_FIXED_POINT) + add_sources_group(oac silk ${silk_sources_float_avx2}) endif() - if (OPUS_DNN) - add_sources_group(opus lpcnet ${dnn_sources_avx2}) + if (OAC_DNN) + add_sources_group(oac lpcnet ${dnn_sources_avx2}) endif() - target_compile_definitions(opus PRIVATE OPUS_X86_MAY_HAVE_AVX2) + target_compile_definitions(oac PRIVATE OAC_X86_MAY_HAVE_AVX2) if(MSVC) set(AVX2_FLAGS "${AVX2_FLAGS} /arch:AVX2") else() @@ -529,99 +529,99 @@ if(NOT OPUS_DISABLE_INTRINSICS) endif() set_source_files_properties(${celt_sources_avx2} PROPERTIES COMPILE_FLAGS ${AVX2_FLAGS}) set_source_files_properties(${silk_sources_avx2} PROPERTIES COMPILE_FLAGS ${AVX2_FLAGS}) - if (NOT OPUS_FIXED_POINT) + if (NOT OAC_FIXED_POINT) set_source_files_properties(${silk_sources_float_avx2} PROPERTIES COMPILE_FLAGS ${AVX2_FLAGS}) endif() set_source_files_properties(${dnn_sources_avx2} PROPERTIES COMPILE_FLAGS ${AVX2_FLAGS}) endif() - if(OPUS_X86_PRESUME_AVX2) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_AVX2) - target_compile_definitions(opus PRIVATE OPUS_X86_PRESUME_SSE4_1) + if(OAC_X86_PRESUME_AVX2) + target_compile_definitions(oac PRIVATE OAC_X86_PRESUME_AVX2) + target_compile_definitions(oac PRIVATE OAC_X86_PRESUME_SSE4_1) if(NOT MSVC) - target_compile_options(opus PRIVATE -mavx2 -mfma -mavx) + target_compile_options(oac PRIVATE -mavx2 -mfma -mavx) endif() endif() endif() if(MSVC) - if(AVX2_SUPPORTED AND OPUS_X86_PRESUME_AVX2) # on 64 bit and 32 bits + if(AVX2_SUPPORTED AND OAC_X86_PRESUME_AVX2) # on 64 bit and 32 bits add_definitions(/arch:AVX2) - 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) + elseif(OAC_CPU_X86) # if AVX not supported then set SSE flag + if((SSE4_1_SUPPORTED AND OAC_X86_PRESUME_SSE4_1) + OR (SSE2_SUPPORTED AND OAC_X86_PRESUME_SSE2)) + target_compile_definitions(oac PRIVATE /arch:SSE2) + elseif(SSE1_SUPPORTED AND OAC_X86_PRESUME_SSE) + target_compile_definitions(oac PRIVATE /arch:SSE) endif() endif() endif() if(COMPILER_SUPPORT_NEON) - if(OPUS_MAY_HAVE_NEON) + if(OAC_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}) - add_sources_group(opus lpcnet ${dnn_sources_arm_rtcd}) + message(STATUS "OAC_MAY_HAVE_NEON enabling runtime detection") + target_compile_definitions(oac PRIVATE OAC_HAVE_RTCD) + add_sources_group(oac celt ${celt_sources_arm_rtcd}) + add_sources_group(oac silk ${silk_sources_arm_rtcd}) + add_sources_group(oac lpcnet ${dnn_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 + target_compile_definitions(oac PRIVATE - OPUS_ARM_MAY_HAVE_NEON - OPUS_ARM_MAY_HAVE_NEON_INTR) + OAC_ARM_MAY_HAVE_NEON + OAC_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}) - if (OPUS_DNN) - add_sources_group(opus lpcnet ${dnn_sources_arm_neon}) + add_sources_group(oac celt ${celt_sources_arm_neon_intr}) + add_sources_group(oac silk ${silk_sources_arm_neon_intr}) + if (OAC_DNN) + add_sources_group(oac lpcnet ${dnn_sources_arm_neon}) endif() # silk arm neon depends on main_Fix.h - target_include_directories(opus PRIVATE silk/fixed) + target_include_directories(oac PRIVATE silk/fixed) - if(OPUS_FIXED_POINT) - add_sources_group(opus silk ${silk_sources_fixed_arm_neon_intr}) + if(OAC_FIXED_POINT) + add_sources_group(oac silk ${silk_sources_fixed_arm_neon_intr}) endif() - if(OPUS_PRESUME_NEON) - target_compile_definitions(opus + if(OAC_PRESUME_NEON) + target_compile_definitions(oac PRIVATE - OPUS_ARM_PRESUME_NEON - OPUS_ARM_PRESUME_NEON_INTR) + OAC_ARM_PRESUME_NEON + OAC_ARM_PRESUME_NEON_INTR) endif() endif() endif() -target_compile_definitions(opus +target_compile_definitions(oac PRIVATE $<$:HAVE_LRINT> $<$:HAVE_LRINTF> $<$:HAVE_ELF_AUX_INFO>) -if(OPUS_BUILD_FRAMEWORK) - set_target_properties(opus PROPERTIES +if(OAC_BUILD_FRAMEWORK) + set_target_properties(oac PROPERTIES FRAMEWORK TRUE FRAMEWORK_VERSION ${PROJECT_VERSION} - MACOSX_FRAMEWORK_IDENTIFIER org.xiph.opus + MACOSX_FRAMEWORK_IDENTIFIER org.xiph.oac MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION} MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION} XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" - OUTPUT_NAME Opus) + OUTPUT_NAME Oac) endif() -install(TARGETS opus - EXPORT OpusTargets +install(TARGETS oac + EXPORT OacTargets 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) + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/oac) -if(OPUS_INSTALL_PKG_CONFIG_MODULE) +if(OAC_INSTALL_PKG_CONFIG_MODULE) set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix ${CMAKE_INSTALL_PREFIX}) set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) @@ -630,136 +630,136 @@ if(OPUS_INSTALL_PKG_CONFIG_MODULE) if(HAVE_LIBM) set(LIBM "-lm") endif() - configure_file(opus.pc.in opus.pc) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/opus.pc + configure_file(oac.pc.in oac.pc) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/oac.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endif() -if(OPUS_INSTALL_CMAKE_CONFIG_MODULE) +if(OAC_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:: + install(EXPORT OacTargets + NAMESPACE Oac:: DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}) include(CMakePackageConfigHelpers) set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) - configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/OpusConfig.cmake.in - OpusConfig.cmake + configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/OacConfig.cmake.in + OacConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} PATH_VARS INCLUDE_INSTALL_DIR INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) - write_basic_package_version_file(OpusConfigVersion.cmake + write_basic_package_version_file(OacConfigVersion.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpusConfig.cmake - ${CMAKE_CURRENT_BINARY_DIR}/OpusConfigVersion.cmake + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OacConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/OacConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}) endif() -if(OPUS_BUILD_PROGRAMS) +if(OAC_BUILD_PROGRAMS) # demo - if(OPUS_CUSTOM_MODES) - add_executable(opus_custom_demo ${opus_custom_demo_sources}) - target_include_directories(opus_custom_demo + if(OAC_CUSTOM_MODES) + add_executable(oac_custom_demo ${oac_custom_demo_sources}) + target_include_directories(oac_custom_demo PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(opus_custom_demo PRIVATE opus) - target_compile_definitions(opus_custom_demo PRIVATE OPUS_BUILD) + target_link_libraries(oac_custom_demo PRIVATE oac) + target_compile_definitions(oac_custom_demo PRIVATE OAC_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_include_directories(opus_demo PRIVATE dnn) - target_link_libraries(opus_demo PRIVATE opus ${OPUS_REQUIRED_LIBRARIES}) - target_compile_definitions(opus_demo PRIVATE OPUS_BUILD) + add_executable(oac_demo ${oac_demo_sources}) + target_include_directories(oac_demo PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + target_include_directories(oac_demo PRIVATE silk) # debug.h + target_include_directories(oac_demo PRIVATE celt) # arch.h + target_include_directories(oac_demo PRIVATE dnn) + target_link_libraries(oac_demo PRIVATE oac ${OAC_REQUIRED_LIBRARIES}) + target_compile_definitions(oac_demo PRIVATE OAC_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 ${OPUS_REQUIRED_LIBRARIES}) + add_executable(oac_compare ${oac_compare_sources}) + target_include_directories(oac_compare PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + target_link_libraries(oac_compare PRIVATE oac ${OAC_REQUIRED_LIBRARIES}) endif() if(BUILD_TESTING AND NOT BUILD_SHARED_LIBS) enable_testing() # tests - add_executable(test_opus_decode ${test_opus_decode_sources}) - target_include_directories(test_opus_decode + add_executable(test_oac_decode ${test_oac_decode_sources}) + target_include_directories(test_oac_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) + target_link_libraries(test_oac_decode PRIVATE oac) + target_compile_definitions(test_oac_decode PRIVATE OAC_BUILD) + if(OAC_FIXED_POINT) + target_compile_definitions(test_oac_decode PRIVATE DISABLE_FLOAT_API) endif() - add_test(NAME test_opus_decode COMMAND ${CMAKE_COMMAND} - -DTEST_EXECUTABLE=$ + add_test(NAME test_oac_decode COMMAND ${CMAKE_COMMAND} + -DTEST_EXECUTABLE=$ -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 + add_executable(test_oac_padding ${test_oac_padding_sources}) + target_include_directories(test_oac_padding PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(test_opus_padding PRIVATE opus) - add_test(NAME test_opus_padding COMMAND ${CMAKE_COMMAND} - -DTEST_EXECUTABLE=$ + target_link_libraries(test_oac_padding PRIVATE oac) + add_test(NAME test_oac_padding COMMAND ${CMAKE_COMMAND} + -DTEST_EXECUTABLE=$ -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake") - add_executable(test_opus_api ${test_opus_api_sources}) - target_include_directories(test_opus_api + add_executable(test_oac_api ${test_oac_api_sources}) + target_include_directories(test_oac_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) + target_link_libraries(test_oac_api PRIVATE oac) + target_compile_definitions(test_oac_api PRIVATE OAC_BUILD) + if(OAC_FIXED_POINT) + target_compile_definitions(test_oac_api PRIVATE DISABLE_FLOAT_API) endif() - add_test(NAME test_opus_api COMMAND ${CMAKE_COMMAND} - -DTEST_EXECUTABLE=$ + add_test(NAME test_oac_api COMMAND ${CMAKE_COMMAND} + -DTEST_EXECUTABLE=$ -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 + add_executable(test_oac_encode ${test_oac_encode_sources}) + target_include_directories(test_oac_encode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt dnn) - 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_link_libraries(test_oac_encode PRIVATE oac) + target_compile_definitions(test_oac_encode PRIVATE OAC_BUILD) + add_test(NAME test_oac_encode COMMAND ${CMAKE_COMMAND} + -DTEST_EXECUTABLE=$ -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake") - add_executable(test_opus_extensions ${test_opus_extensions_sources}) - target_include_directories(test_opus_extensions + add_executable(test_oac_extensions ${test_oac_extensions_sources}) + target_include_directories(test_oac_extensions PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt dnn) - target_link_libraries(test_opus_extensions PRIVATE opus) - target_compile_definitions(test_opus_extensions PRIVATE OPUS_BUILD) - add_test(NAME test_opus_extensions COMMAND ${CMAKE_COMMAND} - -DTEST_EXECUTABLE=$ + target_link_libraries(test_oac_extensions PRIVATE oac) + target_compile_definitions(test_oac_extensions PRIVATE OAC_BUILD) + add_test(NAME test_oac_extensions COMMAND ${CMAKE_COMMAND} + -DTEST_EXECUTABLE=$ -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake") - if(OPUS_DRED) - add_executable(test_opus_dred ${test_opus_dred_sources}) - target_include_directories(test_opus_dred + if(OAC_DRED) + add_executable(test_oac_dred ${test_oac_dred_sources}) + target_include_directories(test_oac_dred PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - target_link_libraries(test_opus_dred PRIVATE opus) - target_compile_definitions(test_opus_dred PRIVATE OPUS_BUILD) - add_test(NAME test_opus_dred COMMAND ${CMAKE_COMMAND} - -DTEST_EXECUTABLE=$ + target_link_libraries(test_oac_dred PRIVATE oac) + target_compile_definitions(test_oac_dred PRIVATE OAC_BUILD) + add_test(NAME test_oac_dred COMMAND ${CMAKE_COMMAND} + -DTEST_EXECUTABLE=$ -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -P "${PROJECT_SOURCE_DIR}/cmake/RunTest.cmake") endif() - if(OPUS_CUSTOM_MODES) - add_executable(test_opus_custom ${test_opus_custom_sources}) - target_include_directories(test_opus_custom + if(OAC_CUSTOM_MODES) + add_executable(test_oac_custom ${test_oac_custom_sources}) + target_include_directories(test_oac_custom PRIVATE ${CMAKE_CURRENT_BINARY_DIR} celt dnn) - target_link_libraries(test_opus_custom PRIVATE opus) - target_compile_definitions(test_opus_custom PRIVATE OPUS_BUILD) + target_link_libraries(test_oac_custom PRIVATE oac) + target_compile_definitions(test_oac_custom PRIVATE OAC_BUILD) endif() endif() diff --git a/LICENSE_PLEASE_READ.txt b/LICENSE_PLEASE_READ.txt deleted file mode 100644 index bc88efa6c..000000000 --- a/LICENSE_PLEASE_READ.txt +++ /dev/null @@ -1,22 +0,0 @@ -Contributions to the collaboration shall not be considered confidential. - -Each contributor represents and warrants that it has the right and -authority to license copyright in its contributions to the collaboration. - -Each contributor agrees to license the copyright in the contributions -under the Modified (2-clause or 3-clause) BSD License or the Clear BSD License. - -Please see the IPR statements submitted to the IETF for the complete -patent licensing details: - -Xiph.Org Foundation: -https://datatracker.ietf.org/ipr/1524/ - -Microsoft Corporation: -https://datatracker.ietf.org/ipr/1914/ - -Skype Limited: -https://datatracker.ietf.org/ipr/1602/ - -Broadcom Corporation: -https://datatracker.ietf.org/ipr/1526/ diff --git a/Makefile.am b/Makefile.am index cc03cd37b..331a10d4a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ export VERBOSE = yes AUTOMAKE_OPTIONS = subdir-objects ACLOCAL_AMFLAGS = -I m4 -lib_LTLIBRARIES = libopus.la +lib_LTLIBRARIES = liboac.la DIST_SUBDIRS = doc @@ -16,7 +16,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/celt -I$(top_srcdir)/silk include celt_sources.mk include lpcnet_sources.mk include silk_sources.mk -include opus_sources.mk +include oac_sources.mk LPCNET_SOURCES = if ENABLE_DEEP_PLC @@ -49,7 +49,7 @@ endif if DISABLE_FLOAT_API else -OPUS_SOURCES += $(OPUS_SOURCES_FLOAT) +OAC_SOURCES += $(OAC_SOURCES_FLOAT) endif if CPU_X86 @@ -111,7 +111,7 @@ if HAVE_ARM_NE10 CELT_SOURCES += $(CELT_SOURCES_ARM_NE10) endif -if OPUS_ARM_EXTERNAL_ASM +if OAC_ARM_EXTERNAL_ASM noinst_LTLIBRARIES = libarmasm.la libarmasm_la_SOURCES = $(CELT_SOURCES_ARM_ASM:.s=-gnu.S) BUILT_SOURCES = $(CELT_SOURCES_ARM_ASM:.s=-gnu.S) \ @@ -126,7 +126,7 @@ CLEANFILES = $(CELT_SOURCES_ARM_ASM:.s=-gnu.S) \ include celt_headers.mk include lpcnet_headers.mk include silk_headers.mk -include opus_headers.mk +include oac_headers.mk LPCNET_HEAD = if ENABLE_DEEP_PLC @@ -142,16 +142,16 @@ if ENABLE_LOSSGEN LPCNET_HEAD += $(LOSSGEN_HEAD) endif -libopus_la_SOURCES = $(CELT_SOURCES) $(SILK_SOURCES) $(LPCNET_SOURCES) $(OPUS_SOURCES) -libopus_la_LDFLAGS = -no-undefined -version-info @OPUS_LT_CURRENT@:@OPUS_LT_REVISION@:@OPUS_LT_AGE@ -libopus_la_LIBADD = $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM -libopus_la_LIBADD += libarmasm.la +liboac_la_SOURCES = $(CELT_SOURCES) $(SILK_SOURCES) $(LPCNET_SOURCES) $(OAC_SOURCES) +liboac_la_LDFLAGS = -no-undefined -version-info @OAC_LT_CURRENT@:@OAC_LT_REVISION@:@OAC_LT_AGE@ +liboac_la_LIBADD = $(NE10_LIBS) $(LIBM) +if OAC_ARM_EXTERNAL_ASM +liboac_la_LIBADD += libarmasm.la endif -pkginclude_HEADERS = include/opus.h include/opus_multistream.h include/opus_types.h include/opus_defines.h include/opus_projection.h +pkginclude_HEADERS = include/oac.h include/oac_multistream.h include/oac_types.h include/oac_defines.h include/oac_projection.h -noinst_HEADERS = $(OPUS_HEAD) $(SILK_HEAD) $(CELT_HEAD) $(LPCNET_HEAD) +noinst_HEADERS = $(OAC_HEAD) $(SILK_HEAD) $(CELT_HEAD) $(LPCNET_HEAD) if EXTRA_PROGRAMS noinst_PROGRAMS = celt/tests/test_unit_cwrs32 \ @@ -163,17 +163,17 @@ noinst_PROGRAMS = celt/tests/test_unit_cwrs32 \ celt/tests/test_unit_mdct \ celt/tests/test_unit_rotation \ celt/tests/test_unit_types \ - opus_compare \ - opus_demo \ + oac_compare \ + oac_demo \ repacketizer_demo \ silk/tests/test_unit_LPC_inv_pred_gain \ - tests/test_opus_api \ - tests/test_opus_decode \ - tests/test_opus_dred \ - tests/test_opus_encode \ - tests/test_opus_extensions \ - tests/test_opus_padding \ - tests/test_opus_projection \ + tests/test_oac_api \ + tests/test_oac_decode \ + tests/test_oac_dred \ + tests/test_oac_encode \ + tests/test_oac_extensions \ + tests/test_oac_padding \ + tests/test_oac_projection \ trivial_example TESTS = celt/tests/test_unit_cwrs32 \ @@ -186,70 +186,70 @@ TESTS = celt/tests/test_unit_cwrs32 \ celt/tests/test_unit_rotation \ celt/tests/test_unit_types \ silk/tests/test_unit_LPC_inv_pred_gain \ - tests/test_opus_api \ - tests/test_opus_decode \ - tests/test_opus_encode \ - tests/test_opus_extensions \ - tests/test_opus_padding \ - tests/test_opus_projection - -opus_demo_SOURCES = src/opus_demo.c + tests/test_oac_api \ + tests/test_oac_decode \ + tests/test_oac_encode \ + tests/test_oac_extensions \ + tests/test_oac_padding \ + tests/test_oac_projection + +oac_demo_SOURCES = src/oac_demo.c if ENABLE_LOSSGEN -opus_demo_SOURCES += $(LOSSGEN_SOURCES) +oac_demo_SOURCES += $(LOSSGEN_SOURCES) endif -opus_demo_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +oac_demo_LDADD = liboac.la $(NE10_LIBS) $(LIBM) repacketizer_demo_SOURCES = src/repacketizer_demo.c -repacketizer_demo_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +repacketizer_demo_LDADD = liboac.la $(NE10_LIBS) $(LIBM) -opus_compare_SOURCES = src/opus_compare.c -opus_compare_LDADD = $(LIBM) +oac_compare_SOURCES = src/oac_compare.c +oac_compare_LDADD = $(LIBM) trivial_example_SOURCES = doc/trivial_example.c -trivial_example_LDADD = libopus.la $(LIBM) +trivial_example_LDADD = liboac.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) +tests_test_oac_api_SOURCES = tests/test_oac_api.c tests/test_oac_common.h +tests_test_oac_api_LDADD = liboac.la $(NE10_LIBS) $(LIBM) -tests_test_opus_encode_SOURCES = tests/test_opus_encode.c tests/opus_encode_regressions.c tests/test_opus_common.h -tests_test_opus_encode_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +tests_test_oac_encode_SOURCES = tests/test_oac_encode.c tests/oac_encode_regressions.c tests/test_oac_common.h +tests_test_oac_encode_LDADD = liboac.la $(NE10_LIBS) $(LIBM) -tests_test_opus_decode_SOURCES = tests/test_opus_decode.c tests/test_opus_common.h -tests_test_opus_decode_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +tests_test_oac_decode_SOURCES = tests/test_oac_decode.c tests/test_oac_common.h +tests_test_oac_decode_LDADD = liboac.la $(NE10_LIBS) $(LIBM) -tests_test_opus_padding_SOURCES = tests/test_opus_padding.c tests/test_opus_common.h -tests_test_opus_padding_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +tests_test_oac_padding_SOURCES = tests/test_oac_padding.c tests/test_oac_common.h +tests_test_oac_padding_LDADD = liboac.la $(NE10_LIBS) $(LIBM) -tests_test_opus_dred_SOURCES = tests/test_opus_dred.c tests/test_opus_common.h -tests_test_opus_dred_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +tests_test_oac_dred_SOURCES = tests/test_oac_dred.c tests/test_oac_common.h +tests_test_oac_dred_LDADD = liboac.la $(NE10_LIBS) $(LIBM) if CUSTOM_MODES -tests_test_opus_custom_SOURCES = tests/test_opus_custom.c tests/test_opus_common.h -tests_test_opus_custom_LDADD = libopus.la $(NE10_LIBS) $(LIBM) +tests_test_oac_custom_SOURCES = tests/test_oac_custom.c tests/test_oac_common.h +tests_test_oac_custom_LDADD = liboac.la $(NE10_LIBS) $(LIBM) endif CELT_OBJ = $(CELT_SOURCES:.c=.lo) SILK_OBJ = $(SILK_SOURCES:.c=.lo) LPCNET_OBJ = $(LPCNET_SOURCES:.c=.lo) -OPUS_OBJ = $(OPUS_SOURCES:.c=.lo) +OAC_OBJ = $(OAC_SOURCES:.c=.lo) -tests_test_opus_extensions_SOURCES = tests/test_opus_extensions.c tests/test_opus_common.h -tests_test_opus_extensions_LDADD = $(OPUS_OBJ) $(SILK_OBJ) $(LPCNET_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM -tests_test_opus_extensions_LDADD += libarmasm.la +tests_test_oac_extensions_SOURCES = tests/test_oac_extensions.c tests/test_oac_common.h +tests_test_oac_extensions_LDADD = $(OAC_OBJ) $(SILK_OBJ) $(LPCNET_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM) +if OAC_ARM_EXTERNAL_ASM +tests_test_oac_extensions_LDADD += libarmasm.la endif -tests_test_opus_projection_SOURCES = tests/test_opus_projection.c tests/test_opus_common.h -tests_test_opus_projection_LDADD = $(OPUS_OBJ) $(SILK_OBJ) $(LPCNET_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM -tests_test_opus_projection_LDADD += libarmasm.la +tests_test_oac_projection_SOURCES = tests/test_oac_projection.c tests/test_oac_common.h +tests_test_oac_projection_LDADD = $(OAC_OBJ) $(SILK_OBJ) $(LPCNET_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM) +if OAC_ARM_EXTERNAL_ASM +tests_test_oac_projection_LDADD += libarmasm.la endif silk_tests_test_unit_LPC_inv_pred_gain_SOURCES = silk/tests/test_unit_LPC_inv_pred_gain.c silk_tests_test_unit_LPC_inv_pred_gain_LDADD = $(SILK_OBJ) $(LPCNET_OBJ) $(CELT_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM +if OAC_ARM_EXTERNAL_ASM silk_tests_test_unit_LPC_inv_pred_gain_LDADD += libarmasm.la endif @@ -258,7 +258,7 @@ celt_tests_test_unit_cwrs32_LDADD = $(LIBM) celt_tests_test_unit_dft_SOURCES = celt/tests/test_unit_dft.c celt_tests_test_unit_dft_LDADD = $(CELT_OBJ) $(LPCNET_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM +if OAC_ARM_EXTERNAL_ASM celt_tests_test_unit_dft_LDADD += libarmasm.la endif @@ -273,19 +273,19 @@ celt_tests_test_unit_laplace_LDADD = $(LIBM) celt_tests_test_unit_mathops_SOURCES = celt/tests/test_unit_mathops.c celt_tests_test_unit_mathops_LDADD = $(CELT_OBJ) $(LPCNET_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM +if OAC_ARM_EXTERNAL_ASM celt_tests_test_unit_mathops_LDADD += libarmasm.la endif celt_tests_test_unit_mdct_SOURCES = celt/tests/test_unit_mdct.c celt_tests_test_unit_mdct_LDADD = $(CELT_OBJ) $(LPCNET_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM +if OAC_ARM_EXTERNAL_ASM celt_tests_test_unit_mdct_LDADD += libarmasm.la endif celt_tests_test_unit_rotation_SOURCES = celt/tests/test_unit_rotation.c celt_tests_test_unit_rotation_LDADD = $(CELT_OBJ) $(LPCNET_OBJ) $(NE10_LIBS) $(LIBM) -if OPUS_ARM_EXTERNAL_ASM +if OAC_ARM_EXTERNAL_ASM celt_tests_test_unit_rotation_LDADD += libarmasm.la endif @@ -294,14 +294,14 @@ celt_tests_test_unit_types_LDADD = $(LIBM) endif if CUSTOM_MODES -pkginclude_HEADERS += include/opus_custom.h +pkginclude_HEADERS += include/oac_custom.h if EXTRA_PROGRAMS -noinst_PROGRAMS += opus_custom_demo -opus_custom_demo_SOURCES = celt/opus_custom_demo.c -opus_custom_demo_LDADD = libopus.la $(LIBM) +noinst_PROGRAMS += oac_custom_demo +oac_custom_demo_SOURCES = celt/oac_custom_demo.c +oac_custom_demo_LDADD = liboac.la $(LIBM) -TESTS += tests/test_opus_custom -noinst_PROGRAMS += tests/test_opus_custom +TESTS += tests/test_oac_custom +noinst_PROGRAMS += tests/test_oac_custom endif endif @@ -322,7 +322,7 @@ dump_weights_blob_LDADD = $(LIBM) dump_weights_blob_CFLAGS = $(AM_CFLAGS) -DDUMP_BINARY_WEIGHTS endif if ENABLE_DRED -TESTS += tests/test_opus_dred +TESTS += tests/test_oac_dred endif if ENABLE_LOSSGEN @@ -340,24 +340,24 @@ endif if ENABLE_QEXT noinst_PROGRAMS += qext_compare qext_compare_SOURCES = src/qext_compare.c -qext_compare_LDADD = libopus.la $(LIBM) +qext_compare_LDADD = liboac.la $(LIBM) endif endif -EXTRA_DIST = opus.pc.in \ - opus-uninstalled.pc.in \ - opus.m4 \ +EXTRA_DIST = oac.pc.in \ + oac-uninstalled.pc.in \ + oac.m4 \ Makefile.unix \ CMakeLists.txt \ cmake/CFeatureCheck.cmake \ - cmake/OpusBuildtype.cmake \ - cmake/OpusConfig.cmake \ - cmake/OpusConfig.cmake.in \ - cmake/OpusFunctions.cmake \ - cmake/OpusPackageVersion.cmake \ - cmake/OpusSources.cmake \ + cmake/OacBuildtype.cmake \ + cmake/OacConfig.cmake \ + cmake/OacConfig.cmake.in \ + cmake/OacFunctions.cmake \ + cmake/OacPackageVersion.cmake \ + cmake/OacSources.cmake \ cmake/README.md \ cmake/RunTest.cmake \ cmake/config.h.cmake.in \ @@ -386,17 +386,17 @@ EXTRA_DIST = opus.pc.in \ celt/arm/celt_pitch_xcorr_arm.s pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = opus.pc +pkgconfig_DATA = oac.pc m4datadir = $(datadir)/aclocal -m4data_DATA = opus.m4 +m4data_DATA = oac.m4 # Targets to build and install just the library without the docs -opus check-opus install-opus: export NO_DOXYGEN = 1 +oac check-oac install-oac: export NO_DOXYGEN = 1 -opus: all -check-opus: check -install-opus: install +oac: all +check-oac: check +install-oac: install # Or just the docs @@ -457,7 +457,7 @@ dist-hook: echo 'PACKAGE_VERSION="$(PACKAGE_VERSION)"' > $(top_distdir)/package_version -.PHONY: opus check-opus install-opus docs install-docs +.PHONY: oac check-oac install-oac docs install-docs # automake doesn't do dependency tracking for asm files, that I can tell $(CELT_SOURCES_ARM_ASM:%.s=%-gnu.S): celt/arm/armopts-gnu.S @@ -478,13 +478,13 @@ OPT_UNIT_TEST_OBJ = $(celt_tests_test_unit_mathops_SOURCES:.c=.o) \ if HAVE_SSE SSE_OBJ = $(CELT_SOURCES_SSE:.c=.lo) -$(SSE_OBJ): CFLAGS += $(OPUS_X86_SSE_CFLAGS) +$(SSE_OBJ): CFLAGS += $(OAC_X86_SSE_CFLAGS) endif if HAVE_SSE2 SSE2_OBJ = $(CELT_SOURCES_SSE2:.c=.lo) \ $(DNN_SOURCES_SSE2:.c=.lo) -$(SSE2_OBJ): CFLAGS += $(OPUS_X86_SSE2_CFLAGS) +$(SSE2_OBJ): CFLAGS += $(OAC_X86_SSE2_CFLAGS) endif if HAVE_SSE4_1 @@ -492,7 +492,7 @@ SSE4_1_OBJ = $(CELT_SOURCES_SSE4_1:.c=.lo) \ $(DNN_SOURCES_SSE4_1:.c=.lo) \ $(SILK_SOURCES_SSE4_1:.c=.lo) \ $(SILK_SOURCES_FIXED_SSE4_1:.c=.lo) -$(SSE4_1_OBJ): CFLAGS += $(OPUS_X86_SSE4_1_CFLAGS) +$(SSE4_1_OBJ): CFLAGS += $(OAC_X86_SSE4_1_CFLAGS) endif if HAVE_AVX2 @@ -500,7 +500,7 @@ AVX2_OBJ = $(CELT_SOURCES_AVX2:.c=.lo) \ $(SILK_SOURCES_AVX2:.c=.lo) \ $(SILK_SOURCES_FLOAT_AVX2:.c=.lo) \ $(DNN_SOURCES_AVX2:.c=.lo) -$(AVX2_OBJ): CFLAGS += $(OPUS_X86_AVX2_CFLAGS) +$(AVX2_OBJ): CFLAGS += $(OAC_X86_AVX2_CFLAGS) endif if HAVE_ARM_NEON_INTR @@ -509,7 +509,7 @@ ARM_NEON_INTR_OBJ = $(CELT_SOURCES_ARM_NEON_INTR:.c=.lo) \ $(DNN_SOURCES_NEON:.c=.lo) \ $(SILK_SOURCES_FIXED_ARM_NEON_INTR:.c=.lo) $(ARM_NEON_INTR_OBJ): CFLAGS += \ - $(OPUS_ARM_NEON_INTR_CFLAGS) $(NE10_CFLAGS) + $(OAC_ARM_NEON_INTR_CFLAGS) $(NE10_CFLAGS) endif if HAVE_ARM_DOTPROD diff --git a/Makefile.unix b/Makefile.unix index 0242992d2..87b8e2a43 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -20,13 +20,13 @@ CFLAGS := -DUSE_ALLOCA $(CFLAGS) include silk_sources.mk include celt_sources.mk -include opus_sources.mk +include oac_sources.mk ifdef FIXED_POINT SILK_SOURCES += $(SILK_SOURCES_FIXED) else SILK_SOURCES += $(SILK_SOURCES_FLOAT) -OPUS_SOURCES += $(OPUS_SOURCES_FLOAT) +OAC_SOURCES += $(OAC_SOURCES_FLOAT) endif EXESUFFIX = @@ -45,7 +45,7 @@ ldflags-from-ldlibdirs = $(addprefix -L,$(1)) ldlibs-from-libs = $(addprefix -l,$(1)) WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow -CFLAGS += -O2 -g $(WARNINGS) -DOPUS_BUILD +CFLAGS += -O2 -g $(WARNINGS) -DOAC_BUILD CINCLUDES = include silk celt ifdef FIXED_POINT @@ -81,38 +81,38 @@ ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@ # Variable definitions -LIB_NAME = opus +LIB_NAME = oac TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX) -SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES) +SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OAC_SOURCES) OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C)) -OPUSDEMO_SRCS_C = src/opus_demo.c -OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C)) +OACDEMO_SRCS_C = src/oac_demo.c +OACDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OACDEMO_SRCS_C)) -TESTOPUSAPI_SRCS_C = tests/test_opus_api.c -TESTOPUSAPI_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSAPI_SRCS_C)) +TESTOACAPI_SRCS_C = tests/test_oac_api.c +TESTOACAPI_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACAPI_SRCS_C)) -TESTOPUSDECODE_SRCS_C = tests/test_opus_decode.c -TESTOPUSDECODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSDECODE_SRCS_C)) +TESTOACDECODE_SRCS_C = tests/test_oac_decode.c +TESTOACDECODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACDECODE_SRCS_C)) -TESTOPUSENCODE_SRCS_C = tests/test_opus_encode.c tests/opus_encode_regressions.c -TESTOPUSENCODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSENCODE_SRCS_C)) +TESTOACENCODE_SRCS_C = tests/test_oac_encode.c tests/oac_encode_regressions.c +TESTOACENCODE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACENCODE_SRCS_C)) -TESTOPUSEXTENSIONS_SRCS_C = tests/test_opus_extensions.c -TESTOPUSEXTENSIONS_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSEXTENSIONS_SRCS_C)) +TESTOACEXTENSIONS_SRCS_C = tests/test_oac_extensions.c +TESTOACEXTENSIONS_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACEXTENSIONS_SRCS_C)) -TESTOPUSPADDING_SRCS_C = tests/test_opus_padding.c -TESTOPUSPADDING_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOPUSPADDING_SRCS_C)) +TESTOACPADDING_SRCS_C = tests/test_oac_padding.c +TESTOACPADDING_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(TESTOACPADDING_SRCS_C)) -OPUSCOMPARE_SRCS_C = src/opus_compare.c -OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C)) +OACCOMPARE_SRCS_C = src/oac_compare.c +OACCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OACCOMPARE_SRCS_C)) -TESTS := test_opus_api test_opus_decode test_opus_encode test_opus_extensions test_opus_padding +TESTS := test_oac_api test_oac_decode test_oac_encode test_oac_extensions test_oac_padding # Rules -all: lib opus_demo opus_compare $(TESTS) +all: lib oac_demo oac_compare $(TESTS) lib: $(TARGET) @@ -122,25 +122,25 @@ check: all $(TARGET): $(OBJS) $(ARCHIVE.cmdline) -opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET) +oac_demo$(EXESUFFIX): $(OACDEMO_OBJS) $(TARGET) $(LINK.o.cmdline) -test_opus_api$(EXESUFFIX): $(TESTOPUSAPI_OBJS) $(TARGET) +test_oac_api$(EXESUFFIX): $(TESTOACAPI_OBJS) $(TARGET) $(LINK.o.cmdline) -test_opus_decode$(EXESUFFIX): $(TESTOPUSDECODE_OBJS) $(TARGET) +test_oac_decode$(EXESUFFIX): $(TESTOACDECODE_OBJS) $(TARGET) $(LINK.o.cmdline) -test_opus_encode$(EXESUFFIX): $(TESTOPUSENCODE_OBJS) $(TARGET) +test_oac_encode$(EXESUFFIX): $(TESTOACENCODE_OBJS) $(TARGET) $(LINK.o.cmdline) -test_opus_extensions$(EXESUFFIX): $(TESTOPUSEXTENSIONS_OBJS) $(TARGET) +test_oac_extensions$(EXESUFFIX): $(TESTOACEXTENSIONS_OBJS) $(TARGET) $(LINK.o.cmdline) -test_opus_padding$(EXESUFFIX): $(TESTOPUSPADDING_OBJS) $(TARGET) +test_oac_padding$(EXESUFFIX): $(TESTOACPADDING_OBJS) $(TARGET) $(LINK.o.cmdline) -opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS) +oac_compare$(EXESUFFIX): $(OACCOMPARE_OBJS) $(LINK.o.cmdline) celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)' @@ -156,12 +156,12 @@ package_version: force force: clean: - rm -f opus_demo$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) \ - test_opus_api$(EXESUFFIX) test_opus_decode$(EXESUFFIX) \ - test_opus_encode$(EXESUFFIX) test_opus_extensions$(EXESUFFIX) \ - test_opus_padding$(EXESUFFIX) \ - $(OBJS) $(OPUSDEMO_OBJS) $(OPUSCOMPARE_OBJS) $(TESTOPUSAPI_OBJS) \ - $(TESTOPUSDECODE_OBJS) $(TESTOPUSENCODE_OBJS) \ - $(TESTOPUSEXTENSIONS_OBJS) $(TESTOPUSPADDING_OBJS) + rm -f oac_demo$(EXESUFFIX) oac_compare$(EXESUFFIX) $(TARGET) \ + test_oac_api$(EXESUFFIX) test_oac_decode$(EXESUFFIX) \ + test_oac_encode$(EXESUFFIX) test_oac_extensions$(EXESUFFIX) \ + test_oac_padding$(EXESUFFIX) \ + $(OBJS) $(OACDEMO_OBJS) $(OACCOMPARE_OBJS) $(TESTOACAPI_OBJS) \ + $(TESTOACDECODE_OBJS) $(TESTOACENCODE_OBJS) \ + $(TESTOACEXTENSIONS_OBJS) $(TESTOACPADDING_OBJS) .PHONY: all lib clean force check diff --git a/README b/README index bcf2376db..c0ab92ee4 100644 --- a/README +++ b/README @@ -1,67 +1,15 @@ -== Opus audio codec == +== OAC audio codec == -Opus is a codec for interactive speech and audio transmission over the Internet. +OAC is the Alliance for Open Media's planned successor to Opus. It is +currently a work in progress. - Opus can handle a wide range of interactive audio applications, including -Voice over IP, videoconferencing, in-game chat, and even remote live music -performances. It can scale from low bit-rate narrowband speech to very high -quality stereo music. - - Opus, when coupled with an appropriate container format, is also suitable -for non-realtime stored-file applications such as music distribution, game -soundtracks, portable music players, jukeboxes, and other applications that -have historically used high latency formats such as MP3, AAC, or Vorbis. - - Opus is specified by IETF RFC 6716: - https://tools.ietf.org/html/rfc6716 - - The Opus format and this implementation of it are subject to the royalty- -free patent and copyright licenses specified in the file COPYING. - -This package implements a shared library for encoding and decoding raw Opus -bitstreams. Raw Opus bitstreams should be used over RTP according to - https://tools.ietf.org/html/rfc7587 - -The package also includes a number of test tools used for testing the +This package implements a shared library for encoding and decoding raw OAC +bitstreams. It also includes a number of test tools used for testing the correct operation of the library. The bitstreams read/written by these -tools should not be used for Opus file distribution: They include +tools should not be used for OAC file distribution: they include additional debugging data and cannot support seeking. -Opus stored in files should use the Ogg encapsulation for Opus which is -described at: - https://tools.ietf.org/html/rfc7845 - -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://gitlab.xiph.org/xiph/opus-tools.git -or on the main Opus website: - https://opus-codec.org/ - -== Deep Learning and Opus == - -Lossy networks continue to be a challenge for real-time communications. -While the original implementation of Opus provides an excellent packet loss -concealment mechanism, the team has continued to advance the methodology used -to improve audio quality in challenge network environments. - -In Opus 1.5, we added a deep learning based redundancy encoder that enhances -audio in lossy networks by embedding one second of recovery data in the padding -data of each packet. The underlying algorithm behind encoding and decoding the -recovery data is called the deep redundancy (DRED) algorithm. By leveraging -the padding data within the packet, Opus 1.5 is fully backward compatible with -prior revisions of Opus. Please see the README under the "dnn" subdirectory to -understand DRED. - -DRED was developed by a team that Amazon Web Services initially sponsored, -who open-sourced the implementation as well as began the -standardization process at the IETF: - https://datatracker.ietf.org/doc/draft-ietf-mlcodec-opus-extension/ -The license behind Opus or the intellectual property position of Opus does -not change with Opus 1.5. - -== Compiling libopus == +== Compiling liboac == To build from a distribution tarball, you only need to do the following: @@ -90,8 +38,8 @@ On Apple macOS, install Xcode and brew.sh, then in the Terminal enter: 1) Clone the repository: - % git clone https://gitlab.xiph.org/xiph/opus.git - % cd opus + % git clone https://github.com/AOMediaCodec/oac.git + % cd oac 2) Compiling the source @@ -105,12 +53,12 @@ On x86, it's a good idea to use a -march= option that allows the use of AVX2. % sudo make install -Once you have compiled the codec, there will be a opus_demo executable +Once you have compiled the codec, there will be a oac_demo executable in the top directory. -Usage: opus_demo [-e] +Usage: oac_demo [-e] [options] - opus_demo -d [options] + oac_demo -d [options] mode: voip | audio | restricted-lowdelay @@ -134,8 +82,8 @@ options: -dtx : enable SILK DTX -loss : simulate packet loss, in percent (0-100); default: 0 -input and output are little-endian signed 16-bit PCM files or opus -bitstreams with simple opus_demo proprietary framing. +input and output are little-endian signed 16-bit PCM files, WAV files (for encoding), or OAC +bitstreams with simple oac_demo custom framing. WAV input now auto-detects 16-bit, 24-bit, and 32-bit PCM formats from the header. == Testing == @@ -147,17 +95,7 @@ To run the integrated tests: % make check -There is also collection of standard test vectors which are not -included in this package for size reasons but can be obtained from: -https://opus-codec.org/docs/opus_testvectors-rfc8251.tar.gz - -To run compare the code to these test vectors: - - % curl -OL https://opus-codec.org/docs/opus_testvectors-rfc8251.tar.gz - % tar -zxf opus_testvectors-rfc8251.tar.gz - % ./tests/run_vectors.sh ./ opus_newvectors 48000 - -== Compiling libopus for Windows and alternative build systems == +== Compiling liboac for Windows and alternative build systems == See cmake/README.md or meson/README.md. @@ -170,7 +108,7 @@ The fixed point implementation has somewhat lower audio quality and is slower on platforms with fast FPUs, it is normally only used in embedded environments. -The implementation can be compiled with either a C89 or a C99 compiler. +The implementation can be compiled with any compiler supporting C89 or later. While it does not rely on any _undefined behavior_ as defined by C89 or C99, it relies on common _implementation-defined behavior_ for two's complement architectures: diff --git a/README.draft b/README.draft deleted file mode 100644 index 9c31bd023..000000000 --- a/README.draft +++ /dev/null @@ -1,54 +0,0 @@ -To build this source code, simply type: - -% make - -If this does not work, or if you want to change the default configuration -(e.g., to compile for a fixed-point architecture), simply edit the options -in the Makefile. - -An up-to-date implementation conforming to this standard is available in a -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. -To build from the git repository instead of using this RFC, follow these -steps: - -1) Clone the repository (latest implementation of this standard at the time -of publication) - -% git clone https://gitlab.xiph.org/xiph/opus.git -% cd opus - -2) Compile - -% ./autogen.sh -% ./configure -% make - -Once you have compiled the codec, there will be a opus_demo executable in -the top directory. - -Usage: opus_demo [-e] - [options] - opus_demo -d [options] - - -mode: voip | audio | restricted-lowdelay -options: --e : only runs the encoder (output the bit-stream) --d : only runs the decoder (reads the bit-stream as input) --cbr : enable constant bitrate; default: variable bitrate --cvbr : enable constrained variable bitrate; default: unconstrained --bandwidth : audio bandwidth (from narrowband to fullband); - default: sampling rate --framesize <2.5|5|10|20|40|60> : frame size in ms; default: 20 --max_payload : maximum payload size in bytes, default: 1024 --complexity : complexity, 0 (lowest) ... 10 (highest); default: 10 --inbandfec : enable SILK inband FEC --forcemono : force mono encoding, even for stereo input --dtx : enable SILK DTX --loss : simulate packet loss, in percent (0-100); default: 0 - -input and output are little endian signed 16-bit PCM files or opus bitstreams -with simple opus_demo proprietary framing. diff --git a/celt/_kiss_fft_guts.h b/celt/_kiss_fft_guts.h index db443c053..0db357668 100644 --- a/celt/_kiss_fft_guts.h +++ b/celt/_kiss_fft_guts.h @@ -1,33 +1,33 @@ /*Copyright (c) 2003-2004, Mark Borgerding - All rights reserved. + All rights reserved. - Redistribution and use in source and binary forms, with or without + 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, + * 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, + * 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.*/ + 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.*/ #ifndef KISS_FFT_GUTS_H #define KISS_FFT_GUTS_H -#define MIN(a,b) ((a)<(b) ? (a):(b)) -#define MAX(a,b) ((a)>(b) ? (a):(b)) +#define MIN(a, b) ((a) < (b) ? (a):(b)) +#define MAX(a, b) ((a) > (b) ? (a):(b)) /* kiss_fft.h defines kiss_fft_scalar as either short or a float type @@ -36,7 +36,7 @@ #include "kiss_fft.h" /* - Explanation of macros dealing with complex math: + Explanation of macros dealing with complex math: C_MUL(m,a,b) : m = a*b C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise @@ -45,144 +45,136 @@ C_ADDTO( res , a) : res += a * */ #ifdef FIXED_POINT -#include "arch.h" +# include "arch.h" -#define SAMP_MAX 2147483647 -#define TWID_MAX 32767 -#define TRIG_UPSCALE 1 +# define SAMP_MAX 2147483647 +# define TWID_MAX 32767 +# define TRIG_UPSCALE 1 -#define SAMP_MIN -SAMP_MAX +# define SAMP_MIN -SAMP_MAX -#ifdef ENABLE_QEXT -# define S_MUL(a,b) MULT32_32_P31_ovflw(b, a) -# define S_MUL2(a,b) MULT32_32_P31_ovflw(b, a) -#else -# define S_MUL(a,b) MULT16_32_Q15(b, a) -# define S_MUL2(a,b) MULT16_32_Q16(b, a) -#endif +# define S_MUL(a, b) MULT32_32_P31_ovflw(b, a) +# define S_MUL2(a, b) MULT32_32_P31_ovflw(b, a) -# define C_MUL(m,a,b) \ - do{ (m).r = SUB32_ovflw(S_MUL((a).r,(b).r) , S_MUL((a).i,(b).i)); \ - (m).i = ADD32_ovflw(S_MUL((a).r,(b).i) , S_MUL((a).i,(b).r)); }while(0) - -# define C_MULC(m,a,b) \ - do{ (m).r = ADD32_ovflw(S_MUL((a).r,(b).r) , S_MUL((a).i,(b).i)); \ - (m).i = SUB32_ovflw(S_MUL((a).i,(b).r) , S_MUL((a).r,(b).i)); }while(0) - -# define C_MULBYSCALAR( c, s ) \ - do{ (c).r = S_MUL( (c).r , s ) ;\ - (c).i = S_MUL( (c).i , s ) ; }while(0) - -# define DIVSCALAR(x,k) \ - (x) = S_MUL( x, (TWID_MAX-((k)>>1))/(k)+1 ) - -# define C_FIXDIV(c,div) \ - do { DIVSCALAR( (c).r , div); \ - DIVSCALAR( (c).i , div); }while (0) - -#define C_ADD( res, a,b)\ - do {(res).r=ADD32_ovflw((a).r,(b).r); (res).i=ADD32_ovflw((a).i,(b).i); \ - }while(0) -#define C_SUB( res, a,b)\ - do {(res).r=SUB32_ovflw((a).r,(b).r); (res).i=SUB32_ovflw((a).i,(b).i); \ - }while(0) -#define C_ADDTO( res , a)\ - do {(res).r = ADD32_ovflw((res).r, (a).r); (res).i = ADD32_ovflw((res).i,(a).i);\ - }while(0) - -#define C_SUBFROM( res , a)\ - do {(res).r = ADD32_ovflw((res).r,(a).r); (res).i = SUB32_ovflw((res).i,(a).i); \ - }while(0) - -#if defined(OPUS_ARM_INLINE_ASM) -#include "arm/kiss_fft_armv4.h" -#endif +# define C_MUL(m, a, b) \ + do { (m).r = SUB32_ovflw(S_MUL((a).r, (b).r), S_MUL((a).i, (b).i)); \ + (m).i = ADD32_ovflw(S_MUL((a).r, (b).i), S_MUL((a).i, (b).r)); } while (0) -#if defined(OPUS_ARM_INLINE_EDSP) -#include "arm/kiss_fft_armv5e.h" -#endif -#if defined(__mips) -#include "mips/kiss_fft_mipsr1.h" -#endif +# define C_MULC(m, a, b) \ + do { (m).r = ADD32_ovflw(S_MUL((a).r, (b).r), S_MUL((a).i, (b).i)); \ + (m).i = SUB32_ovflw(S_MUL((a).i, (b).r), S_MUL((a).r, (b).i)); } while (0) + +# define C_MULBYSCALAR( c, s ) \ + do { (c).r = S_MUL((c).r, s ); \ + (c).i = S_MUL((c).i, s ); } while (0) + +# define DIVSCALAR(x, k) \ + (x) = S_MUL( x, (TWID_MAX - ((k)>>1))/(k) + 1 ) + +# define C_FIXDIV(c, div) \ + do { DIVSCALAR((c).r, div); \ + DIVSCALAR((c).i, div); } while (0) + +# define C_ADD( res, a, b) \ + do {(res).r = ADD32_ovflw((a).r, (b).r); (res).i = ADD32_ovflw((a).i, (b).i); \ + } while (0) +# define C_SUB( res, a, b) \ + do {(res).r = SUB32_ovflw((a).r, (b).r); (res).i = SUB32_ovflw((a).i, (b).i); \ + } while (0) +# define C_ADDTO( res, a) \ + do {(res).r = ADD32_ovflw((res).r, (a).r); (res).i = ADD32_ovflw((res).i, (a).i); \ + } while (0) + +# define C_SUBFROM( res, a) \ + do {(res).r = ADD32_ovflw((res).r, (a).r); (res).i = SUB32_ovflw((res).i, (a).i); \ + } while (0) + +# if defined(OAC_ARM_INLINE_ASM) +# include "arm/kiss_fft_armv4.h" +# endif + +# if defined(OAC_ARM_INLINE_EDSP) +# include "arm/kiss_fft_armv5e.h" +# endif #else /* not FIXED_POINT*/ -# define S_MUL(a,b) ( (a)*(b) ) -# define S_MUL2(a,b) ( (a)*(b) ) -#define C_MUL(m,a,b) \ - do{ (m).r = (a).r*(b).r - (a).i*(b).i;\ - (m).i = (a).r*(b).i + (a).i*(b).r; }while(0) -#define C_MULC(m,a,b) \ - do{ (m).r = (a).r*(b).r + (a).i*(b).i;\ - (m).i = (a).i*(b).r - (a).r*(b).i; }while(0) - -#define C_MUL4(m,a,b) C_MUL(m,a,b) - -# define C_FIXDIV(c,div) /* NOOP */ -# define C_MULBYSCALAR( c, s ) \ - do{ (c).r *= (s);\ - (c).i *= (s); }while(0) +# define S_MUL(a, b) ((a)*(b)) +# define S_MUL2(a, b) ((a)*(b)) +# define C_MUL(m, a, b) \ + do { (m).r = (a).r*(b).r - (a).i*(b).i; \ + (m).i = (a).r*(b).i + (a).i*(b).r; } while (0) +# define C_MULC(m, a, b) \ + do { (m).r = (a).r*(b).r + (a).i*(b).i; \ + (m).i = (a).i*(b).r - (a).r*(b).i; } while (0) + +# define C_MUL4(m, a, b) C_MUL(m, a, b) + +# define C_FIXDIV(c, div) /* NOOP */ +# define C_MULBYSCALAR( c, s ) \ + do { (c).r *= (s); \ + (c).i *= (s); } while (0) #endif #ifndef CHECK_OVERFLOW_OP -# define CHECK_OVERFLOW_OP(a,op,b) /* noop */ +# define CHECK_OVERFLOW_OP(a, op, b) /* noop */ #endif #ifndef C_ADD -#define C_ADD( res, a,b)\ - do { \ - CHECK_OVERFLOW_OP((a).r,+,(b).r)\ - CHECK_OVERFLOW_OP((a).i,+,(b).i)\ - (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \ - }while(0) -#define C_SUB( res, a,b)\ - do { \ - CHECK_OVERFLOW_OP((a).r,-,(b).r)\ - CHECK_OVERFLOW_OP((a).i,-,(b).i)\ - (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \ - }while(0) -#define C_ADDTO( res , a)\ - do { \ - CHECK_OVERFLOW_OP((res).r,+,(a).r)\ - CHECK_OVERFLOW_OP((res).i,+,(a).i)\ - (res).r += (a).r; (res).i += (a).i;\ - }while(0) - -#define C_SUBFROM( res , a)\ - do {\ - CHECK_OVERFLOW_OP((res).r,-,(a).r)\ - CHECK_OVERFLOW_OP((res).i,-,(a).i)\ +# define C_ADD( res, a, b) \ + do { \ + CHECK_OVERFLOW_OP((a).r, +, (b).r) \ + CHECK_OVERFLOW_OP((a).i, +, (b).i) \ + (res).r = (a).r + (b).r; (res).i = (a).i + (b).i; \ + } while (0) +# define C_SUB( res, a, b) \ + do { \ + CHECK_OVERFLOW_OP((a).r, -, (b).r) \ + CHECK_OVERFLOW_OP((a).i, -, (b).i) \ + (res).r = (a).r - (b).r; (res).i = (a).i - (b).i; \ + } while (0) +# define C_ADDTO( res, a) \ + do { \ + CHECK_OVERFLOW_OP((res).r, +, (a).r) \ + CHECK_OVERFLOW_OP((res).i, +, (a).i) \ + (res).r += (a).r; (res).i += (a).i; \ + } while (0) + +# define C_SUBFROM( res, a) \ + do { \ + CHECK_OVERFLOW_OP((res).r, -, (a).r) \ + CHECK_OVERFLOW_OP((res).i, -, (a).i) \ (res).r -= (a).r; (res).i -= (a).i; \ - }while(0) + } while (0) #endif /* C_ADD defined */ #ifdef FIXED_POINT /*# define KISS_FFT_COS(phase) TRIG_UPSCALE*floor(MIN(32767,MAX(-32767,.5+32768 * cos (phase)))) # define KISS_FFT_SIN(phase) TRIG_UPSCALE*floor(MIN(32767,MAX(-32767,.5+32768 * sin (phase))))*/ -# define KISS_FFT_COS(phase) floor(.5+TWID_MAX*cos (phase)) -# define KISS_FFT_SIN(phase) floor(.5+TWID_MAX*sin (phase)) -# define HALF_OF(x) ((x)>>1) +# define KISS_FFT_COS(phase) floor(.5 + TWID_MAX*cos (phase)) +# define KISS_FFT_SIN(phase) floor(.5 + TWID_MAX*sin (phase)) +# define HALF_OF(x) ((x)>>1) #elif defined(USE_SIMD) -# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase) ) -# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase) ) -# define HALF_OF(x) ((x)*_mm_set1_ps(.5f)) +# define KISS_FFT_COS(phase) _mm_set1_ps( cos(phase)) +# define KISS_FFT_SIN(phase) _mm_set1_ps( sin(phase)) +# define HALF_OF(x) ((x)*_mm_set1_ps(.5f)) #else -# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase) -# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase) -# define HALF_OF(x) ((x)*.5f) +# define KISS_FFT_COS(phase) (kiss_fft_scalar) cos(phase) +# define KISS_FFT_SIN(phase) (kiss_fft_scalar) sin(phase) +# define HALF_OF(x) ((x)*.5f) #endif -#define kf_cexp(x,phase) \ - do{ \ - (x)->r = KISS_FFT_COS(phase);\ - (x)->i = KISS_FFT_SIN(phase);\ - }while(0) - -#define kf_cexp2(x,phase) \ - do{ \ - (x)->r = TRIG_UPSCALE*celt_cos_norm((phase));\ - (x)->i = TRIG_UPSCALE*celt_cos_norm((phase)-32768);\ -}while(0) +#define kf_cexp(x, phase) \ + do { \ + (x)->r = KISS_FFT_COS(phase); \ + (x)->i = KISS_FFT_SIN(phase); \ + } while (0) + +#define kf_cexp2(x, phase) \ + do { \ + (x)->r = TRIG_UPSCALE*oaci_celt_cos_norm((phase)); \ + (x)->i = TRIG_UPSCALE*oaci_celt_cos_norm((phase) - 32768); \ + } while (0) #endif /* KISS_FFT_GUTS_H */ diff --git a/celt/arch.h b/celt/arch.h index 63b8ebe60..e7c486383 100644 --- a/celt/arch.h +++ b/celt/arch.h @@ -5,7 +5,7 @@ /** @file arch.h @brief Various architecture definitions for CELT -*/ + */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -29,182 +29,155 @@ 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. -*/ + */ #ifndef ARCH_H #define ARCH_H -#include "opus_types.h" -#include "opus_defines.h" +#include "oac_types.h" +#include "oac_defines.h" -# if !defined(__GNUC_PREREQ) -# if defined(__GNUC__)&&defined(__GNUC_MINOR__) -# define __GNUC_PREREQ(_maj,_min) \ - ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min)) -# else -# define __GNUC_PREREQ(_maj,_min) 0 -# endif +#if !defined(__GNUC_PREREQ) +# if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define __GNUC_PREREQ(_maj, _min) \ + ((__GNUC__<<16) + __GNUC_MINOR__ >= ((_maj)<<16) + (_min)) +# else +# define __GNUC_PREREQ(_maj, _min) 0 # endif +#endif -#if OPUS_GNUC_PREREQ(3, 0) -#define opus_likely(x) (__builtin_expect(!!(x), 1)) -#define opus_unlikely(x) (__builtin_expect(!!(x), 0)) +#if OAC_GNUC_PREREQ(3, 0) +# define oac_likely(x) (__builtin_expect(!!(x), 1)) +# define oac_unlikely(x) (__builtin_expect(!!(x), 0)) #else -#define opus_likely(x) (!!(x)) -#define opus_unlikely(x) (!!(x)) +# define oac_likely(x) (!!(x)) +# define oac_unlikely(x) (!!(x)) #endif #define CELT_SIG_SCALE 32768.f -#define CELT_FATAL(str) celt_fatal(str, __FILE__, __LINE__) +#define CELT_FATAL(str) oaci_celt_fatal(str, __FILE__, __LINE__) #if defined(ENABLE_ASSERTIONS) || defined(ENABLE_HARDENING) -#ifdef __GNUC__ +# ifdef __GNUC__ __attribute__((noreturn)) -#endif -void celt_fatal(const char *str, const char *file, int line); +# endif +void oaci_celt_fatal(const char *str, const char *file, int line); -#if defined(CELT_C) && !defined(OVERRIDE_celt_fatal) -#include -#include -#ifdef __GNUC__ +# if defined(CELT_C) && !defined(OVERRIDE_oaci_celt_fatal) +# include +# include +# ifdef __GNUC__ __attribute__((noreturn)) -#endif -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 +void oaci_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 +# endif -#define celt_assert(cond) {if (!(cond)) {CELT_FATAL("assertion failed: " #cond);}} -#define celt_assert2(cond, message) {if (!(cond)) {CELT_FATAL("assertion failed: " #cond "\n" message);}} -#define MUST_SUCCEED(call) celt_assert((call) == OPUS_OK) +# define celt_assert(cond) {if (!(cond)) {CELT_FATAL("assertion failed: " #cond);}} +# define celt_assert2(cond, message) {if (!(cond)) {CELT_FATAL("assertion failed: " #cond "\n" message);}} +# define MUST_SUCCEED(call) celt_assert((call) == OAC_OK) #else -#define celt_assert(cond) ((void)(cond)) -#define celt_assert2(cond, message) ((void)(cond)) -#define MUST_SUCCEED(call) do {if((call) != OPUS_OK) {RESTORE_STACK; return OPUS_INTERNAL_ERROR;} } while (0) +# define celt_assert(cond) ((void)(cond)) +# define celt_assert2(cond, message) ((void)(cond)) +# define MUST_SUCCEED(call) do {if ((call) != OAC_OK) {RESTORE_STACK; return OAC_INTERNAL_ERROR;} } while (0) #endif #if defined(ENABLE_ASSERTIONS) -#define celt_sig_assert(cond) {if (!(cond)) {CELT_FATAL("signal assertion failed: " #cond);}} +# define celt_sig_assert(cond) {if (!(cond)) {CELT_FATAL("signal assertion failed: " #cond);}} #else -#define celt_sig_assert(cond) ((void)(cond)) +# define celt_sig_assert(cond) ((void)(cond)) #endif -#define IMUL32(a,b) ((a)*(b)) - -#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */ -#define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ -#define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */ -#define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ -#define IMIN(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum int value. */ -#define IMAX(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum int value. */ -#define FMIN(a,b) ((a) < (b) ? (a) : (b)) /**< Minimum float value. */ -#define FMAX(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum float value. */ -#define UADD32(a,b) ((a)+(b)) -#define USUB32(a,b) ((a)-(b)) -#define MAXG(a,b) MAX32(a, b) -#define MING(a,b) MIN32(a, b) +#define IMUL32(a, b) ((a)*(b)) + +#define MIN16(a, b) ((a) < (b) ? (a) : (b)) /**< Minimum 16-bit value. */ +#define MAX16(a, b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ +#define MIN32(a, b) ((a) < (b) ? (a) : (b)) /**< Minimum 32-bit value. */ +#define MAX32(a, b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ +#define IMIN(a, b) ((a) < (b) ? (a) : (b)) /**< Minimum int value. */ +#define IMAX(a, b) ((a) > (b) ? (a) : (b)) /**< Maximum int value. */ +#define FMIN(a, b) ((a) < (b) ? (a) : (b)) /**< Minimum float value. */ +#define FMAX(a, b) ((a) > (b) ? (a) : (b)) /**< Maximum float value. */ +#define UADD32(a, b) ((a) + (b)) +#define USUB32(a, b) ((a) - (b)) +#define MAXG(a, b) MAX32(a, b) +#define MING(a, b) MIN32(a, b) /* Throughout the code, we use the following scaling for signals: FLOAT: used for float API, normalized to +/-1. INT16: used for 16-bit API, normalized to +/- 32768 - RES: internal Opus resolution, defined as +/-1. in float builds, or either 16-bit or 24-bit int for fixed-point builds + RES: internal Oac resolution, defined as +/-1. in float builds, or either 16-bit or 24-bit int for fixed-point builds SIG: internal CELT resolution: defined as +/- 32768. in float builds, or Q27 in fixed-point builds (int16 shifted by 12) -*/ + */ -/* Set this if opus_int64 is a native type of the CPU. */ +/* Set this if oac_int64 is a native type of the CPU. */ /* Assume that all LP64 architectures have fast 64-bit types; also x86_64 (which can be ILP32 for x32) and Win64 (which is LLP64). */ #if defined(__x86_64__) || defined(__LP64__) || defined(_WIN64) || defined (__mips) -#define OPUS_FAST_INT64 1 +# define OAC_FAST_INT64 1 #else -#define OPUS_FAST_INT64 0 +# define OAC_FAST_INT64 0 #endif #ifdef FIXED_POINT -#define ARG_FIXED(arg) , arg +# define ARG_FIXED(arg) , arg #else -#define ARG_FIXED(arg) +# define ARG_FIXED(arg) #endif #define PRINT_MIPS(file) #ifdef FIXED_POINT -typedef opus_int16 opus_val16; -typedef opus_int32 opus_val32; -typedef opus_int64 opus_val64; - -typedef opus_val32 celt_sig; -typedef opus_val32 celt_norm; -typedef opus_val32 celt_ener; -typedef opus_val32 celt_glog; - -#ifdef ENABLE_RES24 -typedef opus_val32 opus_res; -#define RES_SHIFT 8 -#define SIG2RES(a) PSHR32(a, SIG_SHIFT-RES_SHIFT) -#define RES2INT16(a) SAT16(PSHR32(a, RES_SHIFT)) -#define RES2INT24(a) (a) -#define RES2FLOAT(a) ((1.f/32768.f/256.f)*(a)) -#define INT16TORES(a) SHL32(EXTEND32(a), RES_SHIFT) -#define INT24TORES(a) (a) -#define ADD_RES(a, b) ADD32(a, b) -#define FLOAT2RES(a) FLOAT2INT24(a) -#define RES2SIG(a) SHL32((a), SIG_SHIFT-RES_SHIFT) -#define MULT16_RES_Q15(a,b) MULT16_32_Q15(a,b) -#define MAX_ENCODING_DEPTH 24 -#else -typedef opus_val16 opus_res; -#define RES_SHIFT 0 -#define SIG2RES(a) SIG2WORD16(a) -#define RES2INT16(a) (a) -#define RES2INT24(a) SHL32(EXTEND32(a), 8) -#define RES2FLOAT(a) ((1.f/32768.f)*(a)) -#define INT16TORES(a) (a) -#define INT24TORES(a) SAT16(PSHR32(a, 8)) -#define ADD_RES(a, b) SAT16(ADD32((a), (b))); -#define FLOAT2RES(a) FLOAT2INT16(a) -#define RES2SIG(a) SHL32(EXTEND32(a), SIG_SHIFT) -#define MULT16_RES_Q15(a,b) MULT16_16_Q15(a,b) -#define MAX_ENCODING_DEPTH 16 -#endif - -#define RES2VAL16(a) RES2INT16(a) -#define INT16TOSIG(a) SHL32(EXTEND32(a), SIG_SHIFT) -#define INT24TOSIG(a) SHL32(a, SIG_SHIFT-8) - -#define NORM_SHIFT 24 -#ifdef ENABLE_QEXT -typedef opus_val32 celt_coef; -#define COEF_ONE Q31ONE -#define MULT_COEF_32(a, b) MULT32_32_P31(a,b) -#define MAC_COEF_32_ARM(c, a, b) ADD32((c), MULT32_32_Q32(a,b)) -#define MULT_COEF(a, b) MULT32_32_Q31(a,b) -#define MULT_COEF_TAPS(a, b) SHL32(MULT16_16(a,b), 1) -#define COEF2VAL16(x) EXTRACT16(SHR32(x, 16)) -#else -typedef opus_val16 celt_coef; -#define COEF_ONE Q15ONE -#define MULT_COEF_32(a, b) MULT16_32_Q15(a,b) -#define MAC_COEF_32_ARM(a, b, c) MAC16_32_Q16(a,b,c) -#define MULT_COEF(a, b) MULT16_16_Q15(a,b) -#define MULT_COEF_TAPS(a, b) MULT16_16_P15(a,b) -#define COEF2VAL16(x) (x) -#endif - -#define celt_isnan(x) 0 - -#define Q15ONE 32767 -#define Q31ONE 2147483647 - -#define SIG_SHIFT 12 +typedef oac_int16 oac_val16; +typedef oac_int32 oac_val32; +typedef oac_int64 oac_val64; + +typedef oac_val32 celt_sig; +typedef oac_val32 celt_norm; +typedef oac_val32 celt_ener; +typedef oac_val32 celt_glog; + +typedef oac_val32 oac_res; +# define RES_SHIFT 8 +# define SIG2RES(a) PSHR32(a, SIG_SHIFT - RES_SHIFT) +# define RES2INT16(a) SAT16(PSHR32(a, RES_SHIFT)) +# define RES2INT24(a) (a) +# define RES2FLOAT(a) ((1.f/32768.f/256.f)*(a)) +# define INT16TORES(a) SHL32(EXTEND32(a), RES_SHIFT) +# define INT24TORES(a) (a) +# define ADD_RES(a, b) ADD32(a, b) +# define FLOAT2RES(a) FLOAT2INT24(a) +# define RES2SIG(a) SHL32((a), SIG_SHIFT - RES_SHIFT) +# define MULT16_RES_Q15(a, b) MULT16_32_Q15(a, b) +# define MAX_ENCODING_DEPTH 24 + +# define RES2VAL16(a) RES2INT16(a) +# define INT16TOSIG(a) SHL32(EXTEND32(a), SIG_SHIFT) +# define INT24TOSIG(a) SHL32(a, SIG_SHIFT - 8) + +# define NORM_SHIFT 24 +typedef oac_val32 celt_coef; +# define COEF_ONE Q31ONE +# define MULT_COEF_32(a, b) MULT32_32_P31(a, b) +# define MAC_COEF_32_ARM(c, a, b) ADD32((c), MULT32_32_Q32(a, b)) +# define MULT_COEF(a, b) MULT32_32_Q31(a, b) +# define MULT_COEF_TAPS(a, b) SHL32(MULT16_16(a, b), 1) +# define COEF2VAL16(x) EXTRACT16(SHR32(x, 16)) + +# define oaci_celt_isnan(x) 0 + +# define Q15ONE 32767 +# define Q31ONE 2147483647 + +# define SIG_SHIFT 12 /* Safe saturation value for 32-bit signals. We need to make sure that we can add two sig values and that the first stages of the MDCT don't cause an overflow. The most constraining is the ARM_ASM comb filter where we shift left by one @@ -212,189 +185,189 @@ typedef opus_val16 celt_coef; enough to fit a full-scale high-freq tone through the prefilter and comb filter, meaning 1.85*1.75*2^(15+SIG_SHIFT) = 434529895. so the limit should be about 2^31*sqrt(.5). */ -#define SIG_SAT (536870911) +# define SIG_SAT (536870911) -#define NORM_SCALING (1< 32767 ? 32767 : x < -32768 ? -32768 : (opus_int16)x; +static OAC_INLINE oac_int16 SAT16(oac_int32 x) { + return x > 32767 ? 32767 : x < -32768 ? -32768 : (oac_int16)x; } -#ifdef FIXED_DEBUG -#include "fixed_debug.h" -#else - -#include "fixed_generic.h" - -#ifdef OPUS_ARM_PRESUME_AARCH64_NEON_INTR -#include "arm/fixed_arm64.h" -#elif defined (OPUS_ARM_INLINE_EDSP) -#include "arm/fixed_armv5e.h" -#elif defined (OPUS_ARM_INLINE_ASM) -#include "arm/fixed_armv4.h" -#elif defined (BFIN_ASM) -#include "fixed_bfin.h" -#elif defined (TI_C5X_ASM) -#include "fixed_c5x.h" -#elif defined (TI_C6X_ASM) -#include "fixed_c6x.h" -#endif +# ifdef FIXED_DEBUG +# include "fixed_debug.h" +# else + +# include "fixed_generic.h" + +# ifdef OAC_ARM_PRESUME_AARCH64_NEON_INTR +# include "arm/fixed_arm64.h" +# elif defined (OAC_ARM_INLINE_EDSP) +# include "arm/fixed_armv5e.h" +# elif defined (OAC_ARM_INLINE_ASM) +# include "arm/fixed_armv4.h" +# elif defined (BFIN_ASM) +# include "fixed_bfin.h" +# elif defined (TI_C5X_ASM) +# include "fixed_c5x.h" +# elif defined (TI_C6X_ASM) +# include "fixed_c6x.h" +# endif -#endif +# endif #else /* FIXED_POINT */ -typedef float opus_val16; -typedef float opus_val32; -typedef float opus_val64; +typedef float oac_val16; +typedef float oac_val32; +typedef float oac_val64; typedef float celt_sig; typedef float celt_norm; typedef float celt_ener; typedef float celt_glog; -typedef float opus_res; +typedef float oac_res; typedef float celt_coef; -#ifdef FLOAT_APPROX +# ifdef FLOAT_APPROX /* This code should reliably detect NaN/inf even when -ffast-math is used. Assumes IEEE 754 format. */ -static OPUS_INLINE int celt_isnan(float x) -{ - union {float f; opus_uint32 i;} in; - in.f = x; - return ((in.i>>23)&0xFF)==0xFF && (in.i&0x007FFFFF)!=0; +static OAC_INLINE int oaci_celt_isnan(float x) { + union {float f; oac_uint32 i;} in; + in.f = x; + return ((in.i>>23)&0xFF) == 0xFF && (in.i&0x007FFFFF) != 0; } -#else -#ifdef __FAST_MATH__ -#error Cannot build libopus with -ffast-math unless FLOAT_APPROX is defined. This could result in crashes on extreme (e.g. NaN) input -#endif -#define celt_isnan(x) ((x)!=(x)) -#endif +# else +# ifdef __FAST_MATH__ +# error \ + Cannot build liboac with -ffast-math unless FLOAT_APPROX is defined. This could result in crashes on extreme (e.g. NaN) input +# endif +# define oaci_celt_isnan(x) ((x) != (x)) +# endif -#define Q15ONE 1.0f -#define Q31ONE 1.0f -#define COEF_ONE 1.0f -#define COEF2VAL16(x) (x) +# define Q15ONE 1.0f +# define Q31ONE 1.0f +# define COEF_ONE 1.0f +# define COEF2VAL16(x) (x) -#define NORM_SCALING 1.f +# define NORM_SCALING 1.f -#define EPSILON 1e-15f -#define VERY_SMALL 1e-30f -#define VERY_LARGE16 1e15f -#define Q15_ONE ((opus_val16)1.f) +# define EPSILON 1e-15f +# define VERY_SMALL 1e-30f +# define VERY_LARGE16 1e15f +# define Q15_ONE ((oac_val16)1.f) /* This appears to be the same speed as C99's fabsf() but it's more portable. */ -#define ABS16(x) ((float)fabs(x)) -#define ABS32(x) ((float)fabs(x)) - -#define QCONST16(x,bits) (x) -#define QCONST32(x,bits) (x) -#define GCONST(x) (x) - -#define NEG16(x) (-(x)) -#define NEG32(x) (-(x)) -#define NEG32_ovflw(x) (-(x)) -#define EXTRACT16(x) (x) -#define EXTEND32(x) (x) -#define SHR16(a,shift) (a) -#define SHL16(a,shift) (a) -#define SHR32(a,shift) (a) -#define SHL32(a,shift) (a) -#define PSHR32(a,shift) (a) -#define VSHR32(a,shift) (a) - -#define SHR64(a,shift) (a) - -#define PSHR(a,shift) (a) -#define SHR(a,shift) (a) -#define SHL(a,shift) (a) -#define SATURATE(x,a) (x) -#define SATURATE16(x) (x) - -#define ROUND16(a,shift) (a) -#define SROUND16(a,shift) (a) -#define HALF16(x) (.5f*(x)) -#define HALF32(x) (.5f*(x)) - -#define ADD16(a,b) ((a)+(b)) -#define SUB16(a,b) ((a)-(b)) -#define ADD32(a,b) ((a)+(b)) -#define SUB32(a,b) ((a)-(b)) -#define ADD32_ovflw(a,b) ((a)+(b)) -#define SUB32_ovflw(a,b) ((a)-(b)) -#define SHL32_ovflw(a,shift) (a) -#define PSHR32_ovflw(a,shift) (a) - -#define MULT16_16_16(a,b) ((a)*(b)) -#define MULT16_16(a,b) ((opus_val32)(a)*(opus_val32)(b)) -#define MAC16_16(c,a,b) ((c)+(opus_val32)(a)*(opus_val32)(b)) - -#define MULT16_32_Q15(a,b) ((a)*(b)) -#define MULT16_32_Q16(a,b) ((a)*(b)) - -#define MULT32_32_Q16(a,b) ((a)*(b)) -#define MULT32_32_Q31(a,b) ((a)*(b)) -#define MULT32_32_P31(a,b) ((a)*(b)) -#define MULT32_32_P31_ovflw(a,b) ((a)*(b)) - -#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) -#define MAC16_32_Q16(c,a,b) ((c)+(a)*(b)) -#define MAC_COEF_32_ARM(c,a,b) ((c)+(a)*(b)) - -#define MULT16_16_Q11_32(a,b) ((a)*(b)) -#define MULT16_16_Q11(a,b) ((a)*(b)) -#define MULT16_16_Q13(a,b) ((a)*(b)) -#define MULT16_16_Q14(a,b) ((a)*(b)) -#define MULT16_16_Q15(a,b) ((a)*(b)) -#define MULT16_16_P15(a,b) ((a)*(b)) -#define MULT16_16_P13(a,b) ((a)*(b)) -#define MULT16_16_P14(a,b) ((a)*(b)) -#define MULT16_32_P16(a,b) ((a)*(b)) - -#define MULT_COEF_32(a, b) ((a)*(b)) -#define MULT_COEF(a, b) ((a)*(b)) -#define MULT_COEF_TAPS(a, b) ((a)*(b)) - -#define DIV32_16(a,b) (((opus_val32)(a))/(opus_val16)(b)) -#define DIV32(a,b) (((opus_val32)(a))/(opus_val32)(b)) - -#define SIG2RES(a) ((1/CELT_SIG_SCALE)*(a)) -#define RES2INT16(a) FLOAT2INT16(a) -#define RES2INT24(a) float2int(32768.f*256.f*(a)) -#define RES2FLOAT(a) (a) -#define INT16TORES(a) ((a)*(1/CELT_SIG_SCALE)) -#define INT24TORES(a) ((1.f/32768.f/256.f)*(a)) -#define ADD_RES(a, b) ADD32(a, b) -#define FLOAT2RES(a) (a) -#define RES2SIG(a) (CELT_SIG_SCALE*(a)) -#define MULT16_RES_Q15(a,b) MULT16_16_Q15(a,b) - -#define RES2VAL16(a) (a) -#define FLOAT2SIG(a) ((a)*CELT_SIG_SCALE) -#define INT16TOSIG(a) ((float)(a)) -#define INT24TOSIG(a) ((float)(a)*(1.f/256.f)) -#define MAX_ENCODING_DEPTH 24 +# define ABS16(x) ((float)fabs(x)) +# define ABS32(x) ((float)fabs(x)) + +# define QCONST16(x, bits) (x) +# define QCONST32(x, bits) (x) +# define GCONST(x) (x) + +# define NEG16(x) (-(x)) +# define NEG32(x) (-(x)) +# define NEG32_ovflw(x) (-(x)) +# define EXTRACT16(x) (x) +# define EXTEND32(x) (x) +# define SHR16(a, shift) (a) +# define SHL16(a, shift) (a) +# define SHR32(a, shift) (a) +# define SHL32(a, shift) (a) +# define PSHR32(a, shift) (a) +# define VSHR32(a, shift) (a) + +# define SHR64(a, shift) (a) + +# define PSHR(a, shift) (a) +# define SHR(a, shift) (a) +# define SHL(a, shift) (a) +# define SATURATE(x, a) (x) +# define SATURATE16(x) (x) + +# define ROUND16(a, shift) (a) +# define SROUND16(a, shift) (a) +# define HALF16(x) (.5f*(x)) +# define HALF32(x) (.5f*(x)) + +# define ADD16(a, b) ((a) + (b)) +# define SUB16(a, b) ((a) - (b)) +# define ADD32(a, b) ((a) + (b)) +# define SUB32(a, b) ((a) - (b)) +# define ADD32_ovflw(a, b) ((a) + (b)) +# define SUB32_ovflw(a, b) ((a) - (b)) +# define SHL32_ovflw(a, shift) (a) +# define PSHR32_ovflw(a, shift) (a) + +# define MULT16_16_16(a, b) ((a)*(b)) +# define MULT16_16(a, b) ((oac_val32)(a)*(oac_val32)(b)) +# define MAC16_16(c, a, b) ((c) + (oac_val32)(a)*(oac_val32)(b)) + +# define MULT16_32_Q15(a, b) ((a)*(b)) +# define MULT16_32_Q16(a, b) ((a)*(b)) + +# define MULT32_32_Q16(a, b) ((a)*(b)) +# define MULT32_32_Q31(a, b) ((a)*(b)) +# define MULT32_32_P31(a, b) ((a)*(b)) +# define MULT32_32_P31_ovflw(a, b) ((a)*(b)) + +# define MAC16_32_Q15(c, a, b) ((c) + (a)*(b)) +# define MAC16_32_Q16(c, a, b) ((c) + (a)*(b)) +# define MAC_COEF_32_ARM(c, a, b) ((c) + (a)*(b)) + +# define MULT16_16_Q11_32(a, b) ((a)*(b)) +# define MULT16_16_Q11(a, b) ((a)*(b)) +# define MULT16_16_Q13(a, b) ((a)*(b)) +# define MULT16_16_Q14(a, b) ((a)*(b)) +# define MULT16_16_Q15(a, b) ((a)*(b)) +# define MULT16_16_P15(a, b) ((a)*(b)) +# define MULT16_16_P13(a, b) ((a)*(b)) +# define MULT16_16_P14(a, b) ((a)*(b)) +# define MULT16_32_P16(a, b) ((a)*(b)) + +# define MULT_COEF_32(a, b) ((a)*(b)) +# define MULT_COEF(a, b) ((a)*(b)) +# define MULT_COEF_TAPS(a, b) ((a)*(b)) + +# define DIV32_16(a, b) (((oac_val32)(a))/(oac_val16)(b)) +# define DIV32(a, b) (((oac_val32)(a))/(oac_val32)(b)) + +# define SIG2RES(a) ((1/CELT_SIG_SCALE)*(a)) +# define RES2INT16(a) FLOAT2INT16(a) +# define RES2INT24(a) oaci_float2int(32768.f*256.f*(a)) +# define RES2FLOAT(a) (a) +# define INT16TORES(a) ((a)*(1/CELT_SIG_SCALE)) +# define INT24TORES(a) ((1.f/32768.f/256.f)*(a)) +# define ADD_RES(a, b) ADD32(a, b) +# define FLOAT2RES(a) (a) +# define RES2SIG(a) (CELT_SIG_SCALE*(a)) +# define MULT16_RES_Q15(a, b) MULT16_16_Q15(a, b) + +# define RES2VAL16(a) (a) +# define FLOAT2SIG(a) ((a)*CELT_SIG_SCALE) +# define INT16TOSIG(a) ((float)(a)) +# define INT24TOSIG(a) ((float)(a)*(1.f/256.f)) +# define MAX_ENCODING_DEPTH 24 #endif /* !FIXED_POINT */ #ifndef GLOBAL_STACK_SIZE -#ifdef FIXED_POINT -#define GLOBAL_STACK_SIZE 120000 -#else -#define GLOBAL_STACK_SIZE 120000 -#endif +# ifdef FIXED_POINT +# define GLOBAL_STACK_SIZE 120000 +# else +# define GLOBAL_STACK_SIZE 120000 +# endif #endif #endif /* ARCH_H */ diff --git a/celt/arm/arm_celt_map.c b/celt/arm/arm_celt_map.c index 931c011dd..04a9c8ae7 100644 --- a/celt/arm/arm_celt_map.c +++ b/celt/arm/arm_celt_map.c @@ -24,10 +24,10 @@ 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" +# include "config.h" #endif #include "kiss_fft.h" @@ -35,159 +35,160 @@ #include "mdct.h" #include "pitch.h" -#if defined(OPUS_HAVE_RTCD) +#if defined(OAC_HAVE_RTCD) # if !defined(DISABLE_FLOAT_API) -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR) -void (*const CELT_FLOAT2INT16_IMPL[OPUS_ARCHMASK+1])(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT out, int cnt) = { - celt_float2int16_c, /* ARMv4 */ - celt_float2int16_c, /* EDSP */ - celt_float2int16_c, /* Media */ - celt_float2int16_neon,/* NEON */ - celt_float2int16_neon /* DOTPROD */ +# if defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR) +void (*const CELT_FLOAT2INT16_IMPL[OAC_ARCHMASK + 1])(const float * OAC_RESTRICT in, short * OAC_RESTRICT out, +int cnt) = { + oaci_celt_float2int16_c, /* ARMv4 */ + oaci_celt_float2int16_c, /* EDSP */ + oaci_celt_float2int16_c, /* Media */ + oaci_celt_float2int16_neon,/* NEON */ + oaci_celt_float2int16_neon /* DOTPROD */ }; -int (*const OPUS_LIMIT2_CHECKWITHIN1_IMPL[OPUS_ARCHMASK+1])(float * samples, int cnt) = { - opus_limit2_checkwithin1_c, /* ARMv4 */ - opus_limit2_checkwithin1_c, /* EDSP */ - opus_limit2_checkwithin1_c, /* Media */ - opus_limit2_checkwithin1_neon,/* NEON */ - opus_limit2_checkwithin1_neon /* DOTPROD */ +int (*const OAC_LIMIT2_CHECKWITHIN1_IMPL[OAC_ARCHMASK + 1])(float * samples, int cnt) = { + oac_limit2_checkwithin1_c, /* ARMv4 */ + oac_limit2_checkwithin1_c, /* EDSP */ + oac_limit2_checkwithin1_c, /* Media */ + oac_limit2_checkwithin1_neon,/* NEON */ + oac_limit2_checkwithin1_neon /* DOTPROD */ }; # endif # endif -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR) -opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, const opus_val16 *y, int N) = { - celt_inner_prod_c, /* ARMv4 */ - celt_inner_prod_c, /* EDSP */ - celt_inner_prod_c, /* Media */ - celt_inner_prod_neon,/* NEON */ - celt_inner_prod_neon /* DOTPROD */ +# if defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR) +oac_val32 (*const oaci_CELT_INNER_PROD_IMPL[OAC_ARCHMASK + 1])(const oac_val16 *x, const oac_val16 *y, int N) = { + oaci_celt_inner_prod_c, /* ARMv4 */ + oaci_celt_inner_prod_c, /* EDSP */ + oaci_celt_inner_prod_c, /* Media */ + oaci_celt_inner_prod_neon,/* NEON */ + oaci_celt_inner_prod_neon /* DOTPROD */ }; -void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2) = { - dual_inner_prod_c, /* ARMv4 */ - dual_inner_prod_c, /* EDSP */ - dual_inner_prod_c, /* Media */ - dual_inner_prod_neon,/* NEON */ - dual_inner_prod_neon /* DOTPROD */ +void (*const DUAL_INNER_PROD_IMPL[OAC_ARCHMASK + 1])(const oac_val16 *x, const oac_val16 *y01, const oac_val16 *y02, + int N, oac_val32 *xy1, oac_val32 *xy2) = { + oaci_dual_inner_prod_c, /* ARMv4 */ + oaci_dual_inner_prod_c, /* EDSP */ + oaci_dual_inner_prod_c, /* Media */ + oaci_dual_inner_prod_neon,/* NEON */ + oaci_dual_inner_prod_neon /* DOTPROD */ }; # endif # if defined(FIXED_POINT) -# if ((defined(OPUS_ARM_MAY_HAVE_NEON) && !defined(OPUS_ARM_PRESUME_NEON)) || \ - (defined(OPUS_ARM_MAY_HAVE_MEDIA) && !defined(OPUS_ARM_PRESUME_MEDIA)) || \ - (defined(OPUS_ARM_MAY_HAVE_EDSP) && !defined(OPUS_ARM_PRESUME_EDSP))) -opus_val32 (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, - const opus_val16 *, opus_val32 *, int, int, int) = { - celt_pitch_xcorr_c, /* ARMv4 */ - MAY_HAVE_EDSP(celt_pitch_xcorr), /* EDSP */ - MAY_HAVE_MEDIA(celt_pitch_xcorr), /* Media */ - MAY_HAVE_NEON(celt_pitch_xcorr), /* NEON */ - MAY_HAVE_NEON(celt_pitch_xcorr) /* DOTPROD */ +# if ((defined(OAC_ARM_MAY_HAVE_NEON) && !defined(OAC_ARM_PRESUME_NEON)) || \ + (defined(OAC_ARM_MAY_HAVE_MEDIA) && !defined(OAC_ARM_PRESUME_MEDIA)) || \ + (defined(OAC_ARM_MAY_HAVE_EDSP) && !defined(OAC_ARM_PRESUME_EDSP))) +oac_val32 (*const CELT_PITCH_XCORR_IMPL[OAC_ARCHMASK + 1])(const oac_val16 *, + const oac_val16 *, oac_val32 *, int, int, int) = { + oaci_celt_pitch_xcorr_c, /* ARMv4 */ + MAY_HAVE_EDSP(oaci_celt_pitch_xcorr), /* EDSP */ + MAY_HAVE_MEDIA(oaci_celt_pitch_xcorr), /* Media */ + MAY_HAVE_NEON(oaci_celt_pitch_xcorr), /* NEON */ + MAY_HAVE_NEON(oaci_celt_pitch_xcorr) /* DOTPROD */ }; # endif # else /* !FIXED_POINT */ -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR) -void (*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, - const opus_val16 *, opus_val32 *, int, int, int) = { - celt_pitch_xcorr_c, /* ARMv4 */ - celt_pitch_xcorr_c, /* EDSP */ - celt_pitch_xcorr_c, /* Media */ - celt_pitch_xcorr_float_neon, /* Neon */ - celt_pitch_xcorr_float_neon /* DOTPROD */ +# if defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR) +void (*const CELT_PITCH_XCORR_IMPL[OAC_ARCHMASK + 1])(const oac_val16 *, + const oac_val16 *, oac_val32 *, int, int, int) = { + oaci_celt_pitch_xcorr_c, /* ARMv4 */ + oaci_celt_pitch_xcorr_c, /* EDSP */ + oaci_celt_pitch_xcorr_c, /* Media */ + oaci_celt_pitch_xcorr_float_neon, /* Neon */ + oaci_celt_pitch_xcorr_float_neon /* DOTPROD */ }; # endif # endif /* FIXED_POINT */ -#if defined(FIXED_POINT) && defined(OPUS_HAVE_RTCD) && \ - defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR) - -void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y, - opus_val32 sum[4], - int len -) = { - xcorr_kernel_c, /* ARMv4 */ - xcorr_kernel_c, /* EDSP */ - xcorr_kernel_c, /* Media */ - xcorr_kernel_neon_fixed, /* Neon */ - xcorr_kernel_neon_fixed /* DOTPROD */ +# if defined(FIXED_POINT) && defined(OAC_HAVE_RTCD) && \ + defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR) + +void (*const oaci_XCORR_KERNEL_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y, + oac_val32 sum[4], + int len + ) = { + oaci_xcorr_kernel_c, /* ARMv4 */ + oaci_xcorr_kernel_c, /* EDSP */ + oaci_xcorr_kernel_c, /* Media */ + oaci_xcorr_kernel_neon_fixed, /* Neon */ + oaci_xcorr_kernel_neon_fixed /* DOTPROD */ }; -#endif +# endif -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +# if defined(OAC_ARM_MAY_HAVE_NEON_INTR) # if defined(HAVE_ARM_NE10) # if defined(CUSTOM_MODES) -int (*const OPUS_FFT_ALLOC_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = { - opus_fft_alloc_arch_c, /* ARMv4 */ - opus_fft_alloc_arch_c, /* EDSP */ - opus_fft_alloc_arch_c, /* Media */ - opus_fft_alloc_arm_neon, /* Neon with NE10 library support */ - opus_fft_alloc_arm_neon /* DOTPROD with NE10 library support */ +int (*const OAC_FFT_ALLOC_ARCH_IMPL[OAC_ARCHMASK + 1])(kiss_fft_state *st) = { + oac_fft_alloc_arch_c, /* ARMv4 */ + oac_fft_alloc_arch_c, /* EDSP */ + oac_fft_alloc_arch_c, /* Media */ + oac_fft_alloc_arm_neon, /* Neon with NE10 library support */ + oac_fft_alloc_arm_neon /* DOTPROD with NE10 library support */ }; -void (*const OPUS_FFT_FREE_ARCH_IMPL[OPUS_ARCHMASK+1])(kiss_fft_state *st) = { - opus_fft_free_arch_c, /* ARMv4 */ - opus_fft_free_arch_c, /* EDSP */ - opus_fft_free_arch_c, /* Media */ - opus_fft_free_arm_neon, /* Neon with NE10 */ - opus_fft_free_arm_neon /* DOTPROD with NE10 */ +void (*const OAC_FFT_FREE_ARCH_IMPL[OAC_ARCHMASK + 1])(kiss_fft_state *st) = { + oac_fft_free_arch_c, /* ARMv4 */ + oac_fft_free_arch_c, /* EDSP */ + oac_fft_free_arch_c, /* Media */ + oac_fft_free_arm_neon, /* Neon with NE10 */ + oac_fft_free_arm_neon /* DOTPROD with NE10 */ }; # endif /* CUSTOM_MODES */ -void (*const OPUS_FFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg, +void (*const OAC_FFT[OAC_ARCHMASK + 1])(const kiss_fft_state *cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout) = { - opus_fft_c, /* ARMv4 */ - opus_fft_c, /* EDSP */ - opus_fft_c, /* Media */ - opus_fft_neon, /* Neon with NE10 */ - opus_fft_neon /* DOTPROD with NE10 */ + oac_fft_c, /* ARMv4 */ + oac_fft_c, /* EDSP */ + oac_fft_c, /* Media */ + oac_fft_neon, /* Neon with NE10 */ + oac_fft_neon /* DOTPROD with NE10 */ }; -void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg, +void (*const OAC_IFFT[OAC_ARCHMASK + 1])(const kiss_fft_state *cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout) = { - opus_ifft_c, /* ARMv4 */ - opus_ifft_c, /* EDSP */ - opus_ifft_c, /* Media */ - opus_ifft_neon, /* Neon with NE10 */ - opus_ifft_neon /* DOTPROD with NE10 */ + oac_ifft_c, /* ARMv4 */ + oac_ifft_c, /* EDSP */ + oac_ifft_c, /* Media */ + oac_ifft_neon, /* Neon with NE10 */ + oac_ifft_neon /* DOTPROD with NE10 */ }; -void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l, +void (*const CLT_MDCT_FORWARD_IMPL[OAC_ARCHMASK + 1])(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 *window, + kiss_fft_scalar * OAC_RESTRICT out, + const oac_val16 *window, int overlap, int shift, int stride, int arch) = { - clt_mdct_forward_c, /* ARMv4 */ - clt_mdct_forward_c, /* EDSP */ - clt_mdct_forward_c, /* Media */ - clt_mdct_forward_neon, /* Neon with NE10 */ - clt_mdct_forward_neon /* DOTPROD with NE10 */ + oaci_clt_mdct_forward_c, /* ARMv4 */ + oaci_clt_mdct_forward_c, /* EDSP */ + oaci_clt_mdct_forward_c, /* Media */ + oaci_clt_mdct_forward_neon, /* Neon with NE10 */ + oaci_clt_mdct_forward_neon /* DOTPROD with NE10 */ }; -void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])(const mdct_lookup *l, +void (*const CLT_MDCT_BACKWARD_IMPL[OAC_ARCHMASK + 1])(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 *window, + kiss_fft_scalar * OAC_RESTRICT out, + const oac_val16 *window, int overlap, int shift, int stride, int arch) = { - clt_mdct_backward_c, /* ARMv4 */ - clt_mdct_backward_c, /* EDSP */ - clt_mdct_backward_c, /* Media */ - clt_mdct_backward_neon, /* Neon with NE10 */ - clt_mdct_backward_neon /* DOTPROD with NE10 */ + oaci_clt_mdct_backward_c, /* ARMv4 */ + oaci_clt_mdct_backward_c, /* EDSP */ + oaci_clt_mdct_backward_c, /* Media */ + oaci_clt_mdct_backward_neon, /* Neon with NE10 */ + oaci_clt_mdct_backward_neon /* DOTPROD with NE10 */ }; # endif /* HAVE_ARM_NE10 */ -# endif /* OPUS_ARM_MAY_HAVE_NEON_INTR */ +# endif /* OAC_ARM_MAY_HAVE_NEON_INTR */ -#endif /* OPUS_HAVE_RTCD */ +#endif /* OAC_HAVE_RTCD */ diff --git a/celt/arm/armcpu.c b/celt/arm/armcpu.c index f03408c10..5c681d4f0 100644 --- a/celt/arm/armcpu.c +++ b/celt/arm/armcpu.c @@ -23,301 +23,290 @@ 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. -*/ + */ -/* Original code from libtheora modified to suit to Opus */ +/* Original code from libtheora modified to suit to Oac */ #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif -#ifdef OPUS_HAVE_RTCD +#ifdef OAC_HAVE_RTCD -#include "armcpu.h" -#include "cpu_support.h" -#include "os_support.h" -#include "opus_types.h" -#include "arch.h" +# include "armcpu.h" +# include "cpu_support.h" +# include "os_support.h" +# include "oac_types.h" +# include "arch.h" -#define OPUS_CPU_ARM_V4_FLAG (1< - -static OPUS_INLINE opus_uint32 opus_cpu_capabilities(void){ - opus_uint32 flags; - flags=0; - /* MSVC has no OPUS_INLINE __asm support for ARM, but it does let you __emit - * instructions via their assembled hex code. - * All of these instructions should be essentially nops. */ -# if defined(OPUS_ARM_MAY_HAVE_EDSP) || defined(OPUS_ARM_MAY_HAVE_MEDIA) \ - || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) - __try{ - /*PLD [r13]*/ - __emit(0xF5DDF000); - flags|=OPUS_CPU_ARM_EDSP_FLAG; - } - __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){ - /*Ignore exception.*/ - } -# if defined(OPUS_ARM_MAY_HAVE_MEDIA) \ - || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) - __try{ - /*SHADD8 r3,r3,r3*/ - __emit(0xE6333F93); - flags|=OPUS_CPU_ARM_MEDIA_FLAG; - } - __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){ - /*Ignore exception.*/ - } -# if defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) - __try{ - /*VORR q0,q0,q0*/ - __emit(0xF2200150); - flags|=OPUS_CPU_ARM_NEON_FLAG; - } - __except(GetExceptionCode()==EXCEPTION_ILLEGAL_INSTRUCTION){ - /*Ignore exception.*/ - } +# define WIN32_LEAN_AND_MEAN +# define WIN32_EXTRA_LEAN +# include + +static OAC_INLINE oac_uint32 oac_cpu_capabilities(void) { + oac_uint32 flags; + flags = 0; + /* MSVC has no OAC_INLINE __asm support for ARM, but it does let you __emit + * instructions via their assembled hex code. + * All of these instructions should be essentially nops. */ +# if defined(OAC_ARM_MAY_HAVE_EDSP) || defined(OAC_ARM_MAY_HAVE_MEDIA) \ + || defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) + __try{ + /*PLD [r13]*/ + __emit(0xF5DDF000); + flags |= OAC_CPU_ARM_EDSP_FLAG; + } + __except (GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION) { + /*Ignore exception.*/ + } +# if defined(OAC_ARM_MAY_HAVE_MEDIA) \ + || defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) + __try{ + /*SHADD8 r3,r3,r3*/ + __emit(0xE6333F93); + flags |= OAC_CPU_ARM_MEDIA_FLAG; + } + __except (GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION) { + /*Ignore exception.*/ + } +# if defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) + __try{ + /*VORR q0,q0,q0*/ + __emit(0xF2200150); + flags |= OAC_CPU_ARM_NEON_FLAG; + } + __except (GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION) { + /*Ignore exception.*/ + } +# endif # endif # endif -# endif - return flags; + return flags; } -#elif defined(__linux__) +# elif defined(__linux__) /* Linux based */ -#include - -static opus_uint32 opus_cpu_capabilities(void) -{ - opus_uint32 flags = 0; - FILE *cpuinfo; - - /* Reading /proc/self/auxv would be easier, but that doesn't work reliably on - * Android */ - cpuinfo = fopen("/proc/cpuinfo", "r"); - - if(cpuinfo != NULL) - { - /* 512 should be enough for anybody (it's even enough for all the flags that - * x86 has accumulated... so far). */ - char buf[512]; - - while(fgets(buf, 512, cpuinfo) != NULL) - { -# if defined(OPUS_ARM_MAY_HAVE_EDSP) || defined(OPUS_ARM_MAY_HAVE_MEDIA) \ - || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) - /* Search for edsp and neon flag */ - if(memcmp(buf, "Features", 8) == 0) - { - char *p; - p = strstr(buf, " edsp"); - if(p != NULL && (p[5] == ' ' || p[5] == '\n')) - flags |= OPUS_CPU_ARM_EDSP_FLAG; - -# if defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) - p = strstr(buf, " neon"); - if(p != NULL && (p[5] == ' ' || p[5] == '\n')) - flags |= OPUS_CPU_ARM_NEON_FLAG; - p = strstr(buf, " asimd"); - if(p != NULL && (p[6] == ' ' || p[6] == '\n')) - flags |= OPUS_CPU_ARM_NEON_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_EDSP_FLAG; +# include + +static oac_uint32 oac_cpu_capabilities(void) { + oac_uint32 flags = 0; + FILE *cpuinfo; + + /* Reading /proc/self/auxv would be easier, but that doesn't work reliably on + * Android */ + cpuinfo = fopen("/proc/cpuinfo", "r"); + + if (cpuinfo != NULL) { + /* 512 should be enough for anybody (it's even enough for all the flags that + * x86 has accumulated... so far). */ + char buf[512]; + + while (fgets(buf, 512, cpuinfo) != NULL) { +# if defined(OAC_ARM_MAY_HAVE_EDSP) || defined(OAC_ARM_MAY_HAVE_MEDIA) \ + || defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) + /* Search for edsp and neon flag */ + if (memcmp(buf, "Features", 8) == 0) { + char *p; + p = strstr(buf, " edsp"); + if (p != NULL && (p[5] == ' ' || p[5] == '\n')) + flags |= OAC_CPU_ARM_EDSP_FLAG; + +# if defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) + p = strstr(buf, " neon"); + if (p != NULL && (p[5] == ' ' || p[5] == '\n')) + flags |= OAC_CPU_ARM_NEON_FLAG; + p = strstr(buf, " asimd"); + if (p != NULL && (p[6] == ' ' || p[6] == '\n')) + flags |= OAC_CPU_ARM_NEON_FLAG|OAC_CPU_ARM_MEDIA_FLAG|OAC_CPU_ARM_EDSP_FLAG; +# endif +# if defined(OAC_ARM_MAY_HAVE_DOTPROD) + p = strstr(buf, " asimddp"); + if (p != NULL && (p[8] == ' ' || p[8] == '\n')) + flags |= OAC_CPU_ARM_DOTPROD_FLAG; +# endif + } # endif -# if defined(OPUS_ARM_MAY_HAVE_DOTPROD) - p = strstr(buf, " asimddp"); - if(p != NULL && (p[8] == ' ' || p[8] == '\n')) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; + +# if defined(OAC_ARM_MAY_HAVE_MEDIA) \ + || defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) + /* Search for media capabilities (>= ARMv6) */ + if (memcmp(buf, "CPU architecture:", 17) == 0) { + int version; + version = atoi(buf + 17); + + if (version >= 6) + flags |= OAC_CPU_ARM_MEDIA_FLAG; + } # endif - } -# endif + } -# if defined(OPUS_ARM_MAY_HAVE_MEDIA) \ - || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) - /* Search for media capabilities (>= ARMv6) */ - if(memcmp(buf, "CPU architecture:", 17) == 0) - { - int version; - version = atoi(buf+17); - - if(version >= 6) - flags |= OPUS_CPU_ARM_MEDIA_FLAG; - } -# endif +# if defined(OAC_ARM_PRESUME_AARCH64_NEON_INTR) + flags |= OAC_CPU_ARM_EDSP_FLAG|OAC_CPU_ARM_MEDIA_FLAG|OAC_CPU_ARM_NEON_FLAG; +# if defined(OAC_ARM_PRESUME_DOTPROD) + flags |= OAC_CPU_ARM_DOTPROD_FLAG; +# endif +# endif + + fclose(cpuinfo); } + return flags; +} -#if defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR) - flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG; -# if defined(OPUS_ARM_PRESUME_DOTPROD) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; -# endif -#endif +# elif defined(__APPLE__) +# include +# include - fclose(cpuinfo); - } - return flags; -} +static oac_uint32 oac_cpu_capabilities(void) { + oac_uint32 flags = 0; -#elif defined(__APPLE__) -#include -#include - -static opus_uint32 opus_cpu_capabilities(void) -{ - opus_uint32 flags = 0; - -#if defined(OPUS_ARM_MAY_HAVE_DOTPROD) - size_t size = sizeof(uint32_t); - uint32_t value = 0; - if (!sysctlbyname("hw.optional.arm.FEAT_DotProd", &value, &size, NULL, 0) && value) - { - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; - } -#endif +# if defined(OAC_ARM_MAY_HAVE_DOTPROD) + size_t size = sizeof(uint32_t); + uint32_t value = 0; + if (!sysctlbyname("hw.optional.arm.FEAT_DotProd", &value, &size, NULL, 0) && value) { + flags |= OAC_CPU_ARM_DOTPROD_FLAG; + } +# endif -#if defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR) - flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG; -# if defined(OPUS_ARM_PRESUME_DOTPROD) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; -# endif -#endif - return flags; +# if defined(OAC_ARM_PRESUME_AARCH64_NEON_INTR) + flags |= OAC_CPU_ARM_EDSP_FLAG|OAC_CPU_ARM_MEDIA_FLAG|OAC_CPU_ARM_NEON_FLAG; +# if defined(OAC_ARM_PRESUME_DOTPROD) + flags |= OAC_CPU_ARM_DOTPROD_FLAG; +# endif +# endif + return flags; } -#elif defined(HAVE_ELF_AUX_INFO) -#include +# elif defined(HAVE_ELF_AUX_INFO) +# include -static opus_uint32 opus_cpu_capabilities(void) -{ - long hwcap = 0; - opus_uint32 flags = 0; +static oac_uint32 oac_cpu_capabilities(void) { + long hwcap = 0; + oac_uint32 flags = 0; -# if defined(OPUS_ARM_MAY_HAVE_MEDIA) \ - || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) - /* FreeBSD requires armv6+, which always supports media instructions */ - flags |= OPUS_CPU_ARM_MEDIA_FLAG; -# endif +# if defined(OAC_ARM_MAY_HAVE_MEDIA) \ + || defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) + /* FreeBSD requires armv6+, which always supports media instructions */ + flags |= OAC_CPU_ARM_MEDIA_FLAG; +# endif - elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap); + elf_aux_info(AT_HWCAP, &hwcap, sizeof hwcap); -# if defined(OPUS_ARM_MAY_HAVE_EDSP) || defined(OPUS_ARM_MAY_HAVE_MEDIA) \ - || defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -# ifdef HWCAP_EDSP - if (hwcap & HWCAP_EDSP) - flags |= OPUS_CPU_ARM_EDSP_FLAG; -# endif +# if defined(OAC_ARM_MAY_HAVE_EDSP) || defined(OAC_ARM_MAY_HAVE_MEDIA) \ + || defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) +# ifdef HWCAP_EDSP + if (hwcap&HWCAP_EDSP) + flags |= OAC_CPU_ARM_EDSP_FLAG; +# endif -# if defined(OPUS_ARM_MAY_HAVE_NEON) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -# ifdef HWCAP_NEON - if (hwcap & HWCAP_NEON) - flags |= OPUS_CPU_ARM_NEON_FLAG; -# elif defined(HWCAP_ASIMD) - if (hwcap & HWCAP_ASIMD) - flags |= OPUS_CPU_ARM_NEON_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_EDSP_FLAG; +# if defined(OAC_ARM_MAY_HAVE_NEON) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) +# ifdef HWCAP_NEON + if (hwcap&HWCAP_NEON) + flags |= OAC_CPU_ARM_NEON_FLAG; +# elif defined(HWCAP_ASIMD) + if (hwcap&HWCAP_ASIMD) + flags |= OAC_CPU_ARM_NEON_FLAG|OAC_CPU_ARM_MEDIA_FLAG|OAC_CPU_ARM_EDSP_FLAG; +# endif +# endif +# if defined(OAC_ARM_MAY_HAVE_DOTPROD) && defined(HWCAP_ASIMDDP) + if (hwcap&HWCAP_ASIMDDP) + flags |= OAC_CPU_ARM_DOTPROD_FLAG; # endif # endif -# if defined(OPUS_ARM_MAY_HAVE_DOTPROD) && defined(HWCAP_ASIMDDP) - if (hwcap & HWCAP_ASIMDDP) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; -# endif -# endif -#if defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR) - flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG; -# if defined(OPUS_ARM_PRESUME_DOTPROD) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; -# endif -#endif +# if defined(OAC_ARM_PRESUME_AARCH64_NEON_INTR) + flags |= OAC_CPU_ARM_EDSP_FLAG|OAC_CPU_ARM_MEDIA_FLAG|OAC_CPU_ARM_NEON_FLAG; +# if defined(OAC_ARM_PRESUME_DOTPROD) + flags |= OAC_CPU_ARM_DOTPROD_FLAG; +# endif +# endif - return (flags); + return flags; } -#elif defined(__OpenBSD__) -#include -#include -#include -#include - -static opus_uint32 opus_cpu_capabilities(void) -{ - opus_uint32 flags = 0; - -#if defined(OPUS_ARM_MAY_HAVE_DOTPROD) && defined(CPU_ID_AA64ISAR0) - const int isar0_mib[] = { CTL_MACHDEP, CPU_ID_AA64ISAR0 }; - uint64_t isar0; - size_t len = sizeof(isar0); - - if (sysctl(isar0_mib, 2, &isar0, &len, NULL, 0) != -1) - { - if (ID_AA64ISAR0_DP(isar0) >= ID_AA64ISAR0_DP_IMPL) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; - } -#endif +# elif defined(__OpenBSD__) +# include +# include +# include +# include -#if defined(OPUS_ARM_PRESUME_NEON_INTR) \ - || defined(OPUS_ARM_PRESUME_AARCH64_NEON_INTR) - flags |= OPUS_CPU_ARM_EDSP_FLAG | OPUS_CPU_ARM_MEDIA_FLAG | OPUS_CPU_ARM_NEON_FLAG; -# if defined(OPUS_ARM_PRESUME_DOTPROD) - flags |= OPUS_CPU_ARM_DOTPROD_FLAG; -# endif -#endif - return flags; +static oac_uint32 oac_cpu_capabilities(void) { + oac_uint32 flags = 0; + +# if defined(OAC_ARM_MAY_HAVE_DOTPROD) && defined(CPU_ID_AA64ISAR0) + const int isar0_mib[] = { CTL_MACHDEP, CPU_ID_AA64ISAR0 }; + uint64_t isar0; + size_t len = sizeof(isar0); + + if (sysctl(isar0_mib, 2, &isar0, &len, NULL, 0) != -1) { + if (ID_AA64ISAR0_DP(isar0) >= ID_AA64ISAR0_DP_IMPL) + flags |= OAC_CPU_ARM_DOTPROD_FLAG; + } +# endif + +# if defined(OAC_ARM_PRESUME_NEON_INTR) \ + || defined(OAC_ARM_PRESUME_AARCH64_NEON_INTR) + flags |= OAC_CPU_ARM_EDSP_FLAG|OAC_CPU_ARM_MEDIA_FLAG|OAC_CPU_ARM_NEON_FLAG; +# if defined(OAC_ARM_PRESUME_DOTPROD) + flags |= OAC_CPU_ARM_DOTPROD_FLAG; +# endif +# endif + return flags; } -#else +# else /* The feature registers which can tell us what the processor supports are * accessible in privileged modes only, so we can't have a general user-space * detection method like on x86.*/ -# error "Configured to use ARM asm but no CPU detection method available for " \ - "your platform. Reconfigure with --disable-rtcd (or send patches)." -#endif +# error "Configured to use ARM asm but no CPU detection method available for " \ + "your platform. Reconfigure with --disable-rtcd (or send patches)." +# endif -static int opus_select_arch_impl(void) -{ - opus_uint32 flags = opus_cpu_capabilities(); - int arch = 0; +static int oac_select_arch_impl(void) { + oac_uint32 flags = oac_cpu_capabilities(); + int arch = 0; - if(!(flags & OPUS_CPU_ARM_EDSP_FLAG)) { - /* Asserts ensure arch values are sequential */ - celt_assert(arch == OPUS_ARCH_ARM_V4); - return arch; - } - arch++; + if (!(flags&OAC_CPU_ARM_EDSP_FLAG)) { + /* Asserts ensure arch values are sequential */ + celt_assert(arch == OAC_ARCH_ARM_V4); + return arch; + } + arch++; - if(!(flags & OPUS_CPU_ARM_MEDIA_FLAG)) { - celt_assert(arch == OPUS_ARCH_ARM_EDSP); - return arch; - } - arch++; + if (!(flags&OAC_CPU_ARM_MEDIA_FLAG)) { + celt_assert(arch == OAC_ARCH_ARM_EDSP); + return arch; + } + arch++; - if(!(flags & OPUS_CPU_ARM_NEON_FLAG)) { - celt_assert(arch == OPUS_ARCH_ARM_MEDIA); - return arch; - } - arch++; + if (!(flags&OAC_CPU_ARM_NEON_FLAG)) { + celt_assert(arch == OAC_ARCH_ARM_MEDIA); + return arch; + } + arch++; - if(!(flags & OPUS_CPU_ARM_DOTPROD_FLAG)) { - celt_assert(arch == OPUS_ARCH_ARM_NEON); - return arch; - } - arch++; + if (!(flags&OAC_CPU_ARM_DOTPROD_FLAG)) { + celt_assert(arch == OAC_ARCH_ARM_NEON); + return arch; + } + arch++; - celt_assert(arch == OPUS_ARCH_ARM_DOTPROD); - return arch; + celt_assert(arch == OAC_ARCH_ARM_DOTPROD); + return arch; } -int opus_select_arch(void) { - int arch = opus_select_arch_impl(); -#ifdef FUZZING - arch = rand()%(arch+1); -#endif - return arch; +int oac_select_arch(void) { + int arch = oac_select_arch_impl(); +# ifdef FUZZING + arch = rand()%(arch + 1); +# endif + return arch; } #endif diff --git a/celt/arm/armcpu.h b/celt/arm/armcpu.h index 6d5803d81..1565bafaf 100644 --- a/celt/arm/armcpu.h +++ b/celt/arm/armcpu.h @@ -23,68 +23,68 @@ 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. -*/ + */ #if !defined(ARMCPU_H) -# define ARMCPU_H - -# if defined(OPUS_ARM_MAY_HAVE_EDSP) -# define MAY_HAVE_EDSP(name) name ## _edsp -# else -# define MAY_HAVE_EDSP(name) name ## _c -# endif - -# if defined(OPUS_ARM_MAY_HAVE_MEDIA) -# define MAY_HAVE_MEDIA(name) name ## _media -# else -# define MAY_HAVE_MEDIA(name) MAY_HAVE_EDSP(name) -# endif - -# if defined(OPUS_ARM_MAY_HAVE_NEON) -# define MAY_HAVE_NEON(name) name ## _neon -# else -# define MAY_HAVE_NEON(name) MAY_HAVE_MEDIA(name) -# endif - -# if defined(OPUS_ARM_MAY_HAVE_DOTPROD) -# define MAY_HAVE_DOTPROD(name) name ## _dotprod -# else -# define MAY_HAVE_DOTPROD(name) MAY_HAVE_NEON(name) -# endif - -# if defined(OPUS_ARM_PRESUME_EDSP) -# define PRESUME_EDSP(name) name ## _edsp -# else -# define PRESUME_EDSP(name) name ## _c -# endif - -# if defined(OPUS_ARM_PRESUME_MEDIA) -# define PRESUME_MEDIA(name) name ## _media -# else -# define PRESUME_MEDIA(name) PRESUME_EDSP(name) -# endif - -# if defined(OPUS_ARM_PRESUME_NEON) -# define PRESUME_NEON(name) name ## _neon -# else -# define PRESUME_NEON(name) PRESUME_MEDIA(name) -# endif - -# if defined(OPUS_ARM_PRESUME_DOTPROD) -# define PRESUME_DOTPROD(name) name ## _dotprod -# else -# define PRESUME_DOTPROD(name) PRESUME_NEON(name) -# endif - -# if defined(OPUS_HAVE_RTCD) -int opus_select_arch(void); - -#define OPUS_ARCH_ARM_V4 (0) -#define OPUS_ARCH_ARM_EDSP (1) -#define OPUS_ARCH_ARM_MEDIA (2) -#define OPUS_ARCH_ARM_NEON (3) -#define OPUS_ARCH_ARM_DOTPROD (4) - -# endif +#define ARMCPU_H + +#if defined(OAC_ARM_MAY_HAVE_EDSP) +# define MAY_HAVE_EDSP(name) name ## _edsp +#else +# define MAY_HAVE_EDSP(name) name ## _c +#endif + +#if defined(OAC_ARM_MAY_HAVE_MEDIA) +# define MAY_HAVE_MEDIA(name) name ## _media +#else +# define MAY_HAVE_MEDIA(name) MAY_HAVE_EDSP(name) +#endif + +#if defined(OAC_ARM_MAY_HAVE_NEON) +# define MAY_HAVE_NEON(name) name ## _neon +#else +# define MAY_HAVE_NEON(name) MAY_HAVE_MEDIA(name) +#endif + +#if defined(OAC_ARM_MAY_HAVE_DOTPROD) +# define MAY_HAVE_DOTPROD(name) name ## _dotprod +#else +# define MAY_HAVE_DOTPROD(name) MAY_HAVE_NEON(name) +#endif + +#if defined(OAC_ARM_PRESUME_EDSP) +# define PRESUME_EDSP(name) name ## _edsp +#else +# define PRESUME_EDSP(name) name ## _c +#endif + +#if defined(OAC_ARM_PRESUME_MEDIA) +# define PRESUME_MEDIA(name) name ## _media +#else +# define PRESUME_MEDIA(name) PRESUME_EDSP(name) +#endif + +#if defined(OAC_ARM_PRESUME_NEON) +# define PRESUME_NEON(name) name ## _neon +#else +# define PRESUME_NEON(name) PRESUME_MEDIA(name) +#endif + +#if defined(OAC_ARM_PRESUME_DOTPROD) +# define PRESUME_DOTPROD(name) name ## _dotprod +#else +# define PRESUME_DOTPROD(name) PRESUME_NEON(name) +#endif + +#if defined(OAC_HAVE_RTCD) +int oac_select_arch(void); + +# define OAC_ARCH_ARM_V4 (0) +# define OAC_ARCH_ARM_EDSP (1) +# define OAC_ARCH_ARM_MEDIA (2) +# define OAC_ARCH_ARM_NEON (3) +# define OAC_ARCH_ARM_DOTPROD (4) + +#endif #endif diff --git a/celt/arm/armopts.s.in b/celt/arm/armopts.s.in index 3d8aaf275..acb744bca 100644 --- a/celt/arm/armopts.s.in +++ b/celt/arm/armopts.s.in @@ -26,12 +26,12 @@ ; Set the following to 1 if we have EDSP instructions ; (LDRD/STRD, etc., ARMv5E and later). -OPUS_ARM_MAY_HAVE_EDSP * @OPUS_ARM_MAY_HAVE_EDSP@ +OAC_ARM_MAY_HAVE_EDSP * @OAC_ARM_MAY_HAVE_EDSP@ ; Set the following to 1 if we have ARMv6 media instructions. -OPUS_ARM_MAY_HAVE_MEDIA * @OPUS_ARM_MAY_HAVE_MEDIA@ +OAC_ARM_MAY_HAVE_MEDIA * @OAC_ARM_MAY_HAVE_MEDIA@ ; Set the following to 1 if we have NEON (some ARMv7) -OPUS_ARM_MAY_HAVE_NEON * @OPUS_ARM_MAY_HAVE_NEON@ +OAC_ARM_MAY_HAVE_NEON * @OAC_ARM_MAY_HAVE_NEON@ END diff --git a/celt/arm/celt_fft_ne10.c b/celt/arm/celt_fft_ne10.c index ea5fd7808..ad7c7567e 100644 --- a/celt/arm/celt_fft_ne10.c +++ b/celt/arm/celt_fft_ne10.c @@ -28,12 +28,12 @@ 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. -*/ + */ #ifndef SKIP_CONFIG_H -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +# ifdef HAVE_CONFIG_H +# include "config.h" +# endif #endif #include @@ -63,111 +63,104 @@ /* nfft lengths in NE10 that support scaled fft */ # define NE10_FFTSCALED_SUPPORT_MAX 4 static const int ne10_fft_scaled_support[NE10_FFTSCALED_SUPPORT_MAX] = { - 480, 240, 120, 60 + 480, 240, 120, 60 }; -int opus_fft_alloc_arm_neon(kiss_fft_state *st) -{ - int i; - size_t memneeded = sizeof(struct arch_fft_state); - - st->arch_fft = (arch_fft_state *)opus_alloc(memneeded); - if (!st->arch_fft) - return -1; - - for (i = 0; i < NE10_FFTSCALED_SUPPORT_MAX; i++) { - if(st->nfft == ne10_fft_scaled_support[i]) - break; - } - if (i == NE10_FFTSCALED_SUPPORT_MAX) { - /* This nfft length (scaled fft) is not supported in NE10 */ - st->arch_fft->is_supported = 0; - st->arch_fft->priv = NULL; - } - else { - st->arch_fft->is_supported = 1; - st->arch_fft->priv = (void *)NE10_FFT_ALLOC_C2C_TYPE_NEON(st->nfft); - if (st->arch_fft->priv == NULL) { - return -1; - } - } - return 0; +int oac_fft_alloc_arm_neon(kiss_fft_state *st) { + int i; + size_t memneeded = sizeof(struct arch_fft_state); + + st->arch_fft = (arch_fft_state *)oac_alloc(memneeded); + if (!st->arch_fft) + return -1; + + for (i = 0; i < NE10_FFTSCALED_SUPPORT_MAX; i++) { + if (st->nfft == ne10_fft_scaled_support[i]) + break; + } + if (i == NE10_FFTSCALED_SUPPORT_MAX) { + /* This nfft length (scaled fft) is not supported in NE10 */ + st->arch_fft->is_supported = 0; + st->arch_fft->priv = NULL; + } else { + st->arch_fft->is_supported = 1; + st->arch_fft->priv = (void *)NE10_FFT_ALLOC_C2C_TYPE_NEON(st->nfft); + if (st->arch_fft->priv == NULL) { + return -1; + } + } + return 0; } -void opus_fft_free_arm_neon(kiss_fft_state *st) -{ - NE10_FFT_CFG_TYPE_T cfg; +void oac_fft_free_arm_neon(kiss_fft_state *st) { + NE10_FFT_CFG_TYPE_T cfg; - if (!st->arch_fft) - return; + if (!st->arch_fft) + return; - cfg = (NE10_FFT_CFG_TYPE_T)st->arch_fft->priv; - if (cfg) - NE10_FFT_DESTROY_C2C_TYPE(cfg); - opus_free(st->arch_fft); + cfg = (NE10_FFT_CFG_TYPE_T)st->arch_fft->priv; + if (cfg) + NE10_FFT_DESTROY_C2C_TYPE(cfg); + oac_free(st->arch_fft); } #endif -void opus_fft_neon(const kiss_fft_state *st, - const kiss_fft_cpx *fin, - kiss_fft_cpx *fout) -{ - NE10_FFT_STATE_TYPE_T state; - NE10_FFT_CFG_TYPE_T cfg = &state; - VARDECL(NE10_FFT_CPX_TYPE_T, buffer); - SAVE_STACK; - ALLOC(buffer, st->nfft, NE10_FFT_CPX_TYPE_T); - - if (!st->arch_fft->is_supported) { - /* This nfft length (scaled fft) not supported in NE10 */ - opus_fft_c(st, fin, fout); - } - else { - memcpy((void *)cfg, st->arch_fft->priv, sizeof(NE10_FFT_STATE_TYPE_T)); - state.buffer = (NE10_FFT_CPX_TYPE_T *)&buffer[0]; +void oac_fft_neon(const kiss_fft_state *st, + const kiss_fft_cpx *fin, + kiss_fft_cpx *fout) { + NE10_FFT_STATE_TYPE_T state; + NE10_FFT_CFG_TYPE_T cfg = &state; + VARDECL(NE10_FFT_CPX_TYPE_T, buffer); + SAVE_STACK; + ALLOC(buffer, st->nfft, NE10_FFT_CPX_TYPE_T); + + if (!st->arch_fft->is_supported) { + /* This nfft length (scaled fft) not supported in NE10 */ + oac_fft_c(st, fin, fout); + } else { + memcpy((void *)cfg, st->arch_fft->priv, sizeof(NE10_FFT_STATE_TYPE_T)); + state.buffer = (NE10_FFT_CPX_TYPE_T *)&buffer[0]; #if !defined(FIXED_POINT) - state.is_forward_scaled = 1; + state.is_forward_scaled = 1; - NE10_FFT_C2C_1D_TYPE_NEON((NE10_FFT_CPX_TYPE_T *)fout, - (NE10_FFT_CPX_TYPE_T *)fin, + NE10_FFT_C2C_1D_TYPE_NEON((NE10_FFT_CPX_TYPE_T *)fout, + (NE10_FFT_CPX_TYPE_T *)fin, cfg, 0); #else - NE10_FFT_C2C_1D_TYPE_NEON((NE10_FFT_CPX_TYPE_T *)fout, - (NE10_FFT_CPX_TYPE_T *)fin, + NE10_FFT_C2C_1D_TYPE_NEON((NE10_FFT_CPX_TYPE_T *)fout, + (NE10_FFT_CPX_TYPE_T *)fin, cfg, 0, 1); #endif - } - RESTORE_STACK; + } + RESTORE_STACK; } -void opus_ifft_neon(const kiss_fft_state *st, - const kiss_fft_cpx *fin, - kiss_fft_cpx *fout) -{ - NE10_FFT_STATE_TYPE_T state; - NE10_FFT_CFG_TYPE_T cfg = &state; - VARDECL(NE10_FFT_CPX_TYPE_T, buffer); - SAVE_STACK; - ALLOC(buffer, st->nfft, NE10_FFT_CPX_TYPE_T); - - if (!st->arch_fft->is_supported) { - /* This nfft length (scaled fft) not supported in NE10 */ - opus_ifft_c(st, fin, fout); - } - else { - memcpy((void *)cfg, st->arch_fft->priv, sizeof(NE10_FFT_STATE_TYPE_T)); - state.buffer = (NE10_FFT_CPX_TYPE_T *)&buffer[0]; +void oac_ifft_neon(const kiss_fft_state *st, + const kiss_fft_cpx *fin, + kiss_fft_cpx *fout) { + NE10_FFT_STATE_TYPE_T state; + NE10_FFT_CFG_TYPE_T cfg = &state; + VARDECL(NE10_FFT_CPX_TYPE_T, buffer); + SAVE_STACK; + ALLOC(buffer, st->nfft, NE10_FFT_CPX_TYPE_T); + + if (!st->arch_fft->is_supported) { + /* This nfft length (scaled fft) not supported in NE10 */ + oac_ifft_c(st, fin, fout); + } else { + memcpy((void *)cfg, st->arch_fft->priv, sizeof(NE10_FFT_STATE_TYPE_T)); + state.buffer = (NE10_FFT_CPX_TYPE_T *)&buffer[0]; #if !defined(FIXED_POINT) - state.is_backward_scaled = 0; + state.is_backward_scaled = 0; - NE10_FFT_C2C_1D_TYPE_NEON((NE10_FFT_CPX_TYPE_T *)fout, - (NE10_FFT_CPX_TYPE_T *)fin, + NE10_FFT_C2C_1D_TYPE_NEON((NE10_FFT_CPX_TYPE_T *)fout, + (NE10_FFT_CPX_TYPE_T *)fin, cfg, 1); #else - NE10_FFT_C2C_1D_TYPE_NEON((NE10_FFT_CPX_TYPE_T *)fout, - (NE10_FFT_CPX_TYPE_T *)fin, + NE10_FFT_C2C_1D_TYPE_NEON((NE10_FFT_CPX_TYPE_T *)fout, + (NE10_FFT_CPX_TYPE_T *)fin, cfg, 1, 0); #endif - } - RESTORE_STACK; + } + RESTORE_STACK; } diff --git a/celt/arm/celt_mdct_ne10.c b/celt/arm/celt_mdct_ne10.c index 3531d02d1..a5f6980f4 100644 --- a/celt/arm/celt_mdct_ne10.c +++ b/celt/arm/celt_mdct_ne10.c @@ -28,12 +28,12 @@ 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. -*/ + */ #ifndef SKIP_CONFIG_H -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +# ifdef HAVE_CONFIG_H +# include "config.h" +# endif #endif #include "kiss_fft.h" @@ -41,218 +41,206 @@ #include "mdct.h" #include "stack_alloc.h" -void clt_mdct_forward_neon(const mdct_lookup *l, +void oaci_clt_mdct_forward_neon(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 *window, - int overlap, int shift, int stride, int arch) -{ - int i; - int N, N2, N4; - VARDECL(kiss_fft_scalar, f); - VARDECL(kiss_fft_cpx, f2); - const kiss_fft_state *st = l->kfft[shift]; - const kiss_twiddle_scalar *trig; - - SAVE_STACK; - - N = l->n; - trig = l->trig; - for (i=0;i>= 1; - trig += N; - } - N2 = N>>1; - N4 = N>>2; - - ALLOC(f, N2, kiss_fft_scalar); - ALLOC(f2, N4, kiss_fft_cpx); - - /* Consider the input to be composed of four blocks: [a, b, c, d] */ - /* Window, shuffle, fold */ - { - /* Temp pointers to make it really clear to the compiler what we're doing */ - const kiss_fft_scalar * OPUS_RESTRICT xp1 = in+(overlap>>1); - const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+N2-1+(overlap>>1); - kiss_fft_scalar * OPUS_RESTRICT yp = f; - const opus_val16 * OPUS_RESTRICT wp1 = window+(overlap>>1); - const opus_val16 * OPUS_RESTRICT wp2 = window+(overlap>>1)-1; - for(i=0;i<((overlap+3)>>2);i++) - { - /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/ - *yp++ = MULT16_32_Q15(*wp2, xp1[N2]) + MULT16_32_Q15(*wp1,*xp2); - *yp++ = MULT16_32_Q15(*wp1, *xp1) - MULT16_32_Q15(*wp2, xp2[-N2]); - xp1+=2; - xp2-=2; - wp1+=2; - wp2-=2; - } - wp1 = window; - wp2 = window+overlap-1; - for(;i>2);i++) - { - /* Real part arranged as a-bR, Imag part arranged as -c-dR */ - *yp++ = *xp2; - *yp++ = *xp1; - xp1+=2; - xp2-=2; - } - for(;ii,t[N4+i]) - S_MUL(fp->r,t[i]); - yi = S_MUL(fp->r,t[N4+i]) + S_MUL(fp->i,t[i]); - *yp1 = yr; - *yp2 = yi; - fp++; - yp1 += 2*stride; - yp2 -= 2*stride; - } - } - RESTORE_STACK; + kiss_fft_scalar * OAC_RESTRICT out, + const oac_val16 *window, + int overlap, int shift, int stride, int arch) { + int i; + int N, N2, N4; + VARDECL(kiss_fft_scalar, f); + VARDECL(kiss_fft_cpx, f2); + const kiss_fft_state *st = l->kfft[shift]; + const kiss_twiddle_scalar *trig; + + SAVE_STACK; + + N = l->n; + trig = l->trig; + for (i = 0; i < shift; i++) { + N >>= 1; + trig += N; + } + N2 = N>>1; + N4 = N>>2; + + ALLOC(f, N2, kiss_fft_scalar); + ALLOC(f2, N4, kiss_fft_cpx); + + /* Consider the input to be composed of four blocks: [a, b, c, d] */ + /* Window, shuffle, fold */ + { + /* Temp pointers to make it really clear to the compiler what we're doing */ + const kiss_fft_scalar * OAC_RESTRICT xp1 = in + (overlap>>1); + const kiss_fft_scalar * OAC_RESTRICT xp2 = in + N2 - 1 + (overlap>>1); + kiss_fft_scalar * OAC_RESTRICT yp = f; + const oac_val16 * OAC_RESTRICT wp1 = window + (overlap>>1); + const oac_val16 * OAC_RESTRICT wp2 = window + (overlap>>1) - 1; + for (i = 0; i < ((overlap + 3)>>2); i++) { + /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/ + *yp++ = MULT16_32_Q15(*wp2, xp1[N2]) + MULT16_32_Q15(*wp1, *xp2); + *yp++ = MULT16_32_Q15(*wp1, *xp1) - MULT16_32_Q15(*wp2, xp2[-N2]); + xp1 += 2; + xp2 -= 2; + wp1 += 2; + wp2 -= 2; + } + wp1 = window; + wp2 = window + overlap - 1; + for (; i < N4 - ((overlap + 3)>>2); i++) { + /* Real part arranged as a-bR, Imag part arranged as -c-dR */ + *yp++ = *xp2; + *yp++ = *xp1; + xp1 += 2; + xp2 -= 2; + } + for (; i < N4; i++) { + /* Real part arranged as a-bR, Imag part arranged as -c-dR */ + *yp++ = -MULT16_32_Q15(*wp1, xp1[-N2]) + MULT16_32_Q15(*wp2, *xp2); + *yp++ = MULT16_32_Q15(*wp2, *xp1) + MULT16_32_Q15(*wp1, xp2[N2]); + xp1 += 2; + xp2 -= 2; + wp1 += 2; + wp2 -= 2; + } + } + /* Pre-rotation */ + { + kiss_fft_scalar * OAC_RESTRICT yp = f; + const kiss_twiddle_scalar *t = &trig[0]; + for (i = 0; i < N4; i++) { + kiss_fft_cpx yc; + kiss_twiddle_scalar t0, t1; + kiss_fft_scalar re, im, yr, yi; + t0 = t[i]; + t1 = t[N4 + i]; + re = *yp++; + im = *yp++; + yr = S_MUL(re, t0) - S_MUL(im, t1); + yi = S_MUL(im, t0) + S_MUL(re, t1); + yc.r = yr; + yc.i = yi; + f2[i] = yc; + } + } + + oac_fft(st, f2, (kiss_fft_cpx *)f, arch); + + /* Post-rotate */ + { + /* Temp pointers to make it really clear to the compiler what we're doing */ + const kiss_fft_cpx * OAC_RESTRICT fp = (kiss_fft_cpx *)f; + kiss_fft_scalar * OAC_RESTRICT yp1 = out; + kiss_fft_scalar * OAC_RESTRICT yp2 = out + stride*(N2 - 1); + const kiss_twiddle_scalar *t = &trig[0]; + /* Temp pointers to make it really clear to the compiler what we're doing */ + for (i = 0; i < N4; i++) { + kiss_fft_scalar yr, yi; + yr = S_MUL(fp->i, t[N4 + i]) - S_MUL(fp->r, t[i]); + yi = S_MUL(fp->r, t[N4 + i]) + S_MUL(fp->i, t[i]); + *yp1 = yr; + *yp2 = yi; + fp++; + yp1 += 2*stride; + yp2 -= 2*stride; + } + } + RESTORE_STACK; } -void clt_mdct_backward_neon(const mdct_lookup *l, +void oaci_clt_mdct_backward_neon(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 * OPUS_RESTRICT window, - int overlap, int shift, int stride, int arch) -{ - int i; - int N, N2, N4; - VARDECL(kiss_fft_scalar, f); - const kiss_twiddle_scalar *trig; - const kiss_fft_state *st = l->kfft[shift]; - - N = l->n; - trig = l->trig; - for (i=0;i>= 1; - trig += N; - } - N2 = N>>1; - N4 = N>>2; - - ALLOC(f, N2, kiss_fft_scalar); - - /* Pre-rotate */ - { - /* Temp pointers to make it really clear to the compiler what we're doing */ - const kiss_fft_scalar * OPUS_RESTRICT xp1 = in; - const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+stride*(N2-1); - kiss_fft_scalar * OPUS_RESTRICT yp = f; - const kiss_twiddle_scalar * OPUS_RESTRICT t = &trig[0]; - for(i=0;i>1)), arch); - - /* Post-rotate and de-shuffle from both ends of the buffer at once to make - it in-place. */ - { - kiss_fft_scalar * yp0 = out+(overlap>>1); - kiss_fft_scalar * yp1 = out+(overlap>>1)+N2-2; - const kiss_twiddle_scalar *t = &trig[0]; - /* Loop to (N4+1)>>1 to handle odd N4. When N4 is odd, the - middle pair will be computed twice. */ - for(i=0;i<(N4+1)>>1;i++) - { - kiss_fft_scalar re, im, yr, yi; - kiss_twiddle_scalar t0, t1; - re = yp0[0]; - im = yp0[1]; - t0 = t[i]; - t1 = t[N4+i]; - /* We'd scale up by 2 here, but instead it's done when mixing the windows */ - yr = S_MUL(re,t0) + S_MUL(im,t1); - yi = S_MUL(re,t1) - S_MUL(im,t0); - re = yp1[0]; - im = yp1[1]; - yp0[0] = yr; - yp1[1] = yi; - - t0 = t[(N4-i-1)]; - t1 = t[(N2-i-1)]; - /* We'd scale up by 2 here, but instead it's done when mixing the windows */ - yr = S_MUL(re,t0) + S_MUL(im,t1); - yi = S_MUL(re,t1) - S_MUL(im,t0); - yp1[0] = yr; - yp0[1] = yi; - yp0 += 2; - yp1 -= 2; - } - } - - /* Mirror on both sides for TDAC */ - { - kiss_fft_scalar * OPUS_RESTRICT xp1 = out+overlap-1; - kiss_fft_scalar * OPUS_RESTRICT yp1 = out; - const opus_val16 * OPUS_RESTRICT wp1 = window; - const opus_val16 * OPUS_RESTRICT wp2 = window+overlap-1; - - for(i = 0; i < overlap/2; i++) - { - kiss_fft_scalar x1, x2; - x1 = *xp1; - x2 = *yp1; - *yp1++ = MULT16_32_Q15(*wp2, x2) - MULT16_32_Q15(*wp1, x1); - *xp1-- = MULT16_32_Q15(*wp1, x2) + MULT16_32_Q15(*wp2, x1); - wp1++; - wp2--; - } - } - RESTORE_STACK; + kiss_fft_scalar * OAC_RESTRICT out, + const oac_val16 * OAC_RESTRICT window, + int overlap, int shift, int stride, int arch) { + int i; + int N, N2, N4; + VARDECL(kiss_fft_scalar, f); + const kiss_twiddle_scalar *trig; + const kiss_fft_state *st = l->kfft[shift]; + + N = l->n; + trig = l->trig; + for (i = 0; i < shift; i++) { + N >>= 1; + trig += N; + } + N2 = N>>1; + N4 = N>>2; + + ALLOC(f, N2, kiss_fft_scalar); + + /* Pre-rotate */ + { + /* Temp pointers to make it really clear to the compiler what we're doing */ + const kiss_fft_scalar * OAC_RESTRICT xp1 = in; + const kiss_fft_scalar * OAC_RESTRICT xp2 = in + stride*(N2 - 1); + kiss_fft_scalar * OAC_RESTRICT yp = f; + const kiss_twiddle_scalar * OAC_RESTRICT t = &trig[0]; + for (i = 0; i < N4; i++) { + kiss_fft_scalar yr, yi; + yr = S_MUL(*xp2, t[i]) + S_MUL(*xp1, t[N4 + i]); + yi = S_MUL(*xp1, t[i]) - S_MUL(*xp2, t[N4 + i]); + yp[2*i] = yr; + yp[2*i + 1] = yi; + xp1 += 2*stride; + xp2 -= 2*stride; + } + } + + oac_ifft(st, (kiss_fft_cpx *)f, (kiss_fft_cpx*)(out + (overlap>>1)), arch); + + /* Post-rotate and de-shuffle from both ends of the buffer at once to make + it in-place. */ + { + kiss_fft_scalar * yp0 = out + (overlap>>1); + kiss_fft_scalar * yp1 = out + (overlap>>1) + N2 - 2; + const kiss_twiddle_scalar *t = &trig[0]; + /* Loop to (N4+1)>>1 to handle odd N4. When N4 is odd, the + middle pair will be computed twice. */ + for (i = 0; i < (N4 + 1)>>1; i++) { + kiss_fft_scalar re, im, yr, yi; + kiss_twiddle_scalar t0, t1; + re = yp0[0]; + im = yp0[1]; + t0 = t[i]; + t1 = t[N4 + i]; + /* We'd scale up by 2 here, but instead it's done when mixing the windows */ + yr = S_MUL(re, t0) + S_MUL(im, t1); + yi = S_MUL(re, t1) - S_MUL(im, t0); + re = yp1[0]; + im = yp1[1]; + yp0[0] = yr; + yp1[1] = yi; + + t0 = t[(N4 - i - 1)]; + t1 = t[(N2 - i - 1)]; + /* We'd scale up by 2 here, but instead it's done when mixing the windows */ + yr = S_MUL(re, t0) + S_MUL(im, t1); + yi = S_MUL(re, t1) - S_MUL(im, t0); + yp1[0] = yr; + yp0[1] = yi; + yp0 += 2; + yp1 -= 2; + } + } + + /* Mirror on both sides for TDAC */ + { + kiss_fft_scalar * OAC_RESTRICT xp1 = out + overlap - 1; + kiss_fft_scalar * OAC_RESTRICT yp1 = out; + const oac_val16 * OAC_RESTRICT wp1 = window; + const oac_val16 * OAC_RESTRICT wp2 = window + overlap - 1; + + for (i = 0; i < overlap/2; i++) { + kiss_fft_scalar x1, x2; + x1 = *xp1; + x2 = *yp1; + *yp1++ = MULT16_32_Q15(*wp2, x2) - MULT16_32_Q15(*wp1, x1); + *xp1-- = MULT16_32_Q15(*wp1, x2) + MULT16_32_Q15(*wp2, x1); + wp1++; + wp2--; + } + } + RESTORE_STACK; } diff --git a/celt/arm/celt_neon_intr.c b/celt/arm/celt_neon_intr.c index 69b90d7dc..cef8e9a89 100644 --- a/celt/arm/celt_neon_intr.c +++ b/celt/arm/celt_neon_intr.c @@ -29,10 +29,10 @@ 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" +# include "config.h" #endif #include @@ -40,362 +40,351 @@ #include "../mathops.h" #include "../pitch.h" #include -#if defined(OPUS_CHECK_ASM) -#include +#if defined(OAC_CHECK_ASM) +# include #endif -#if !defined(DISABLE_FLOAT_API) && defined(OPUS_ARM_MAY_HAVE_NEON_INTR) - -void celt_float2int16_neon(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT out, int cnt) -{ - int i = 0; - -#if defined(__ARM_NEON) - const int BLOCK_SIZE = 16; - const int blockedSize = cnt / BLOCK_SIZE * BLOCK_SIZE; - - for (; i < blockedSize; i += BLOCK_SIZE) - { - float32x4_t orig_a = vld1q_f32(&in[i + 0]); - float32x4_t orig_b = vld1q_f32(&in[i + 4]); - float32x4_t orig_c = vld1q_f32(&in[i + 8]); - float32x4_t orig_d = vld1q_f32(&in[i + 12]); - - int16x4_t asShort_a = vqmovn_s32(vroundf(vmulq_n_f32(orig_a, CELT_SIG_SCALE))); - int16x4_t asShort_b = vqmovn_s32(vroundf(vmulq_n_f32(orig_b, CELT_SIG_SCALE))); - int16x4_t asShort_c = vqmovn_s32(vroundf(vmulq_n_f32(orig_c, CELT_SIG_SCALE))); - int16x4_t asShort_d = vqmovn_s32(vroundf(vmulq_n_f32(orig_d, CELT_SIG_SCALE))); - - vst1_s16(&out[i + 0], asShort_a); - vst1_s16(&out[i + 4], asShort_b); - vst1_s16(&out[i + 8], asShort_c); - vst1_s16(&out[i + 12], asShort_d); -# if defined(OPUS_CHECK_ASM) - short out_c[BLOCK_SIZE]; - int j; - for(j = 0; j < BLOCK_SIZE; j++) - { - out_c[j] = FLOAT2INT16(in[i + j]); - celt_assert(abs((out_c[j] - out[i + j])) <= 1); - } +#if !defined(DISABLE_FLOAT_API) && defined(OAC_ARM_MAY_HAVE_NEON_INTR) + +void oaci_celt_float2int16_neon(const float * OAC_RESTRICT in, short * OAC_RESTRICT out, int cnt) { + int i = 0; + +# if defined(__ARM_NEON) + const int BLOCK_SIZE = 16; + const int blockedSize = cnt/BLOCK_SIZE*BLOCK_SIZE; + + for (; i < blockedSize; i += BLOCK_SIZE) { + float32x4_t orig_a = vld1q_f32(&in[i + 0]); + float32x4_t orig_b = vld1q_f32(&in[i + 4]); + float32x4_t orig_c = vld1q_f32(&in[i + 8]); + float32x4_t orig_d = vld1q_f32(&in[i + 12]); + + int16x4_t asShort_a = vqmovn_s32(vroundf(vmulq_n_f32(orig_a, CELT_SIG_SCALE))); + int16x4_t asShort_b = vqmovn_s32(vroundf(vmulq_n_f32(orig_b, CELT_SIG_SCALE))); + int16x4_t asShort_c = vqmovn_s32(vroundf(vmulq_n_f32(orig_c, CELT_SIG_SCALE))); + int16x4_t asShort_d = vqmovn_s32(vroundf(vmulq_n_f32(orig_d, CELT_SIG_SCALE))); + + vst1_s16(&out[i + 0], asShort_a); + vst1_s16(&out[i + 4], asShort_b); + vst1_s16(&out[i + 8], asShort_c); + vst1_s16(&out[i + 12], asShort_d); +# if defined(OAC_CHECK_ASM) + short out_c[BLOCK_SIZE]; + int j; + for (j = 0; j < BLOCK_SIZE; j++) { + out_c[j] = FLOAT2INT16(in[i + j]); + celt_assert(abs((out_c[j] - out[i + j])) <= 1); + } +# endif + } # endif - } -#endif - for (; i < cnt; i++) - { - out[i] = FLOAT2INT16(in[i]); - } + for (; i < cnt; i++) { + out[i] = FLOAT2INT16(in[i]); + } } -int opus_limit2_checkwithin1_neon(float *samples, int cnt) -{ - const float hardclipMin = -2.0f; - const float hardclipMax = 2.0f; - - int i = 0; - int exceeding1 = 0; - int nextIndex = 0; - -#if defined(__ARM_NEON) - const int BLOCK_SIZE = 16; - const int blockedSize = cnt / BLOCK_SIZE * BLOCK_SIZE; - - float32x4_t min_all_0 = vdupq_n_f32(0.0f); - float32x4_t min_all_1 = vdupq_n_f32(0.0f); - float32x4_t max_all_0 = vdupq_n_f32(0.0f); - float32x4_t max_all_1 = vdupq_n_f32(0.0f); - - float max, min; - - for (i = 0; i < blockedSize; i += BLOCK_SIZE) - { - const float32x4_t orig_a = vld1q_f32(&samples[i + 0]); - const float32x4_t orig_b = vld1q_f32(&samples[i + 4]); - const float32x4_t orig_c = vld1q_f32(&samples[i + 8]); - const float32x4_t orig_d = vld1q_f32(&samples[i + 12]); - max_all_0 = vmaxq_f32(max_all_0, vmaxq_f32(orig_a, orig_b)); - max_all_1 = vmaxq_f32(max_all_1, vmaxq_f32(orig_c, orig_d)); - min_all_0 = vminq_f32(min_all_0, vminq_f32(orig_a, orig_b)); - min_all_1 = vminq_f32(min_all_1, vminq_f32(orig_c, orig_d)); - } - - max = vmaxvf(vmaxq_f32(max_all_0, max_all_1)); - min = vminvf(vminq_f32(min_all_0, min_all_1)); - - if (min < hardclipMin || max > hardclipMax) - { - const float32x4_t hardclipMinReg = vdupq_n_f32(hardclipMin); - const float32x4_t hardclipMaxReg = vdupq_n_f32(hardclipMax); - for (i = 0; i < blockedSize; i += BLOCK_SIZE) - { - const float32x4_t orig_a = vld1q_f32(&samples[i + 0]); - const float32x4_t orig_b = vld1q_f32(&samples[i + 4]); - const float32x4_t orig_c = vld1q_f32(&samples[i + 8]); - const float32x4_t orig_d = vld1q_f32(&samples[i + 12]); - const float32x4_t clipped_a = vminq_f32(hardclipMaxReg, vmaxq_f32(orig_a, hardclipMinReg)); - const float32x4_t clipped_b = vminq_f32(hardclipMaxReg, vmaxq_f32(orig_b, hardclipMinReg)); - const float32x4_t clipped_c = vminq_f32(hardclipMaxReg, vmaxq_f32(orig_c, hardclipMinReg)); - const float32x4_t clipped_d = vminq_f32(hardclipMaxReg, vmaxq_f32(orig_d, hardclipMinReg)); - vst1q_f32(&samples[i + 0], clipped_a); - vst1q_f32(&samples[i + 4], clipped_b); - vst1q_f32(&samples[i + 8], clipped_c); - vst1q_f32(&samples[i + 12], clipped_d); - } - } - - nextIndex = blockedSize; - exceeding1 |= max > 1.0f || min < -1.0f; +int oac_limit2_checkwithin1_neon(float *samples, int cnt) { + const float hardclipMin = -2.0f; + const float hardclipMax = 2.0f; + + int i = 0; + int exceeding1 = 0; + int nextIndex = 0; + +# if defined(__ARM_NEON) + const int BLOCK_SIZE = 16; + const int blockedSize = cnt/BLOCK_SIZE*BLOCK_SIZE; + + float32x4_t min_all_0 = vdupq_n_f32(0.0f); + float32x4_t min_all_1 = vdupq_n_f32(0.0f); + float32x4_t max_all_0 = vdupq_n_f32(0.0f); + float32x4_t max_all_1 = vdupq_n_f32(0.0f); + + float max, min; + + for (i = 0; i < blockedSize; i += BLOCK_SIZE) { + const float32x4_t orig_a = vld1q_f32(&samples[i + 0]); + const float32x4_t orig_b = vld1q_f32(&samples[i + 4]); + const float32x4_t orig_c = vld1q_f32(&samples[i + 8]); + const float32x4_t orig_d = vld1q_f32(&samples[i + 12]); + max_all_0 = vmaxq_f32(max_all_0, vmaxq_f32(orig_a, orig_b)); + max_all_1 = vmaxq_f32(max_all_1, vmaxq_f32(orig_c, orig_d)); + min_all_0 = vminq_f32(min_all_0, vminq_f32(orig_a, orig_b)); + min_all_1 = vminq_f32(min_all_1, vminq_f32(orig_c, orig_d)); + } + + max = vmaxvf(vmaxq_f32(max_all_0, max_all_1)); + min = vminvf(vminq_f32(min_all_0, min_all_1)); + + if (min < hardclipMin || max > hardclipMax) { + const float32x4_t hardclipMinReg = vdupq_n_f32(hardclipMin); + const float32x4_t hardclipMaxReg = vdupq_n_f32(hardclipMax); + for (i = 0; i < blockedSize; i += BLOCK_SIZE) { + const float32x4_t orig_a = vld1q_f32(&samples[i + 0]); + const float32x4_t orig_b = vld1q_f32(&samples[i + 4]); + const float32x4_t orig_c = vld1q_f32(&samples[i + 8]); + const float32x4_t orig_d = vld1q_f32(&samples[i + 12]); + const float32x4_t clipped_a = vminq_f32(hardclipMaxReg, vmaxq_f32(orig_a, hardclipMinReg)); + const float32x4_t clipped_b = vminq_f32(hardclipMaxReg, vmaxq_f32(orig_b, hardclipMinReg)); + const float32x4_t clipped_c = vminq_f32(hardclipMaxReg, vmaxq_f32(orig_c, hardclipMinReg)); + const float32x4_t clipped_d = vminq_f32(hardclipMaxReg, vmaxq_f32(orig_d, hardclipMinReg)); + vst1q_f32(&samples[i + 0], clipped_a); + vst1q_f32(&samples[i + 4], clipped_b); + vst1q_f32(&samples[i + 8], clipped_c); + vst1q_f32(&samples[i + 12], clipped_d); + } + } + + nextIndex = blockedSize; + exceeding1 |= max > 1.0f || min < -1.0f; -#endif +# endif - for (i = nextIndex; i < cnt; i++) - { - const float origVal = samples[i]; - float clippedVal = origVal; - clippedVal = MAX16(hardclipMin, clippedVal); - clippedVal = MIN16(hardclipMax, clippedVal); - samples[i] = clippedVal; + for (i = nextIndex; i < cnt; i++) { + const float origVal = samples[i]; + float clippedVal = origVal; + clippedVal = MAX16(hardclipMin, clippedVal); + clippedVal = MIN16(hardclipMax, clippedVal); + samples[i] = clippedVal; - exceeding1 |= origVal > 1.0f || origVal < -1.0f; - } + exceeding1 |= origVal > 1.0f || origVal < -1.0f; + } - return !exceeding1; + return !exceeding1; } #endif #if defined(FIXED_POINT) -#include - -void xcorr_kernel_neon_fixed(const opus_val16 * x, const opus_val16 * y, opus_val32 sum[4], int len) -{ - int j; - int32x4_t a = vld1q_s32(sum); - /* Load y[0...3] */ - /* This requires len>0 to always be valid (which we assert in the C code). */ - int16x4_t y0 = vld1_s16(y); - y += 4; - - /* This loop loads one y value more than we actually need. - Therefore we have to stop as soon as there are 8 or fewer samples left - (instead of 7), to avoid reading past the end of the array. */ - for (j = 0; j + 8 < len; j += 8) - { - /* Load x[0...7] */ - int16x8_t xx = vld1q_s16(x); - int16x4_t x0 = vget_low_s16(xx); - int16x4_t x4 = vget_high_s16(xx); - /* Load y[4...11] */ - int16x8_t yy = vld1q_s16(y); - int16x4_t y4 = vget_low_s16(yy); - int16x4_t y8 = vget_high_s16(yy); - int32x4_t a0 = vmlal_lane_s16(a, y0, x0, 0); - int32x4_t a1 = vmlal_lane_s16(a0, y4, x4, 0); - - int16x4_t y1 = vext_s16(y0, y4, 1); - int16x4_t y5 = vext_s16(y4, y8, 1); - int32x4_t a2 = vmlal_lane_s16(a1, y1, x0, 1); - int32x4_t a3 = vmlal_lane_s16(a2, y5, x4, 1); - - int16x4_t y2 = vext_s16(y0, y4, 2); - int16x4_t y6 = vext_s16(y4, y8, 2); - int32x4_t a4 = vmlal_lane_s16(a3, y2, x0, 2); - int32x4_t a5 = vmlal_lane_s16(a4, y6, x4, 2); - - int16x4_t y3 = vext_s16(y0, y4, 3); - int16x4_t y7 = vext_s16(y4, y8, 3); - int32x4_t a6 = vmlal_lane_s16(a5, y3, x0, 3); - int32x4_t a7 = vmlal_lane_s16(a6, y7, x4, 3); - - y0 = y8; - a = a7; - x += 8; - y += 8; - } - if (j + 4 < len) { - /* Load x[0...3] */ - int16x4_t x0 = vld1_s16(x); - /* Load y[4...7] */ - int16x4_t y4 = vld1_s16(y); - int32x4_t a0 = vmlal_lane_s16(a, y0, x0, 0); - int16x4_t y1 = vext_s16(y0, y4, 1); - int32x4_t a1 = vmlal_lane_s16(a0, y1, x0, 1); - int16x4_t y2 = vext_s16(y0, y4, 2); - int32x4_t a2 = vmlal_lane_s16(a1, y2, x0, 2); - int16x4_t y3 = vext_s16(y0, y4, 3); - int32x4_t a3 = vmlal_lane_s16(a2, y3, x0, 3); - y0 = y4; - a = a3; - x += 4; - y += 4; - j += 4; - } - if (j + 2 < len) { - /* Load x[0...1] */ - int16x4x2_t xx = vld2_dup_s16(x); - int16x4_t x0 = xx.val[0]; - int16x4_t x1 = xx.val[1]; - /* Load y[4...5]. - We would like to use vld1_dup_s32(), but casting the pointer would - break strict aliasing rules and potentially have alignment issues. - Fortunately the compiler seems capable of translating this memcpy() - and vdup_n_s32() into the equivalent vld1_dup_s32().*/ - int32_t yy; - memcpy(&yy, y, sizeof(yy)); - int16x4_t y4 = vreinterpret_s16_s32(vdup_n_s32(yy)); - int32x4_t a0 = vmlal_s16(a, y0, x0); - int16x4_t y1 = vext_s16(y0, y4, 1); - /* Replace bottom copy of {y[5], y[4]} in y4 with {y[3], y[2]} from y0, - using VSRI instead of VEXT, since it's a data-processing - instruction. */ - y0 = vreinterpret_s16_s64(vsri_n_s64(vreinterpret_s64_s16(y4), +# include + +void oaci_xcorr_kernel_neon_fixed(const oac_val16 * x, const oac_val16 * y, oac_val32 sum[4], int len) { + int j; + int32x4_t a = vld1q_s32(sum); + /* Load y[0...3] */ + /* This requires len>0 to always be valid (which we assert in the C code). */ + int16x4_t y0 = vld1_s16(y); + y += 4; + + /* This loop loads one y value more than we actually need. + Therefore we have to stop as soon as there are 8 or fewer samples left + (instead of 7), to avoid reading past the end of the array. */ + for (j = 0; j + 8 < len; j += 8) { + /* Load x[0...7] */ + int16x8_t xx = vld1q_s16(x); + int16x4_t x0 = vget_low_s16(xx); + int16x4_t x4 = vget_high_s16(xx); + /* Load y[4...11] */ + int16x8_t yy = vld1q_s16(y); + int16x4_t y4 = vget_low_s16(yy); + int16x4_t y8 = vget_high_s16(yy); + int32x4_t a0 = vmlal_lane_s16(a, y0, x0, 0); + int32x4_t a1 = vmlal_lane_s16(a0, y4, x4, 0); + + int16x4_t y1 = vext_s16(y0, y4, 1); + int16x4_t y5 = vext_s16(y4, y8, 1); + int32x4_t a2 = vmlal_lane_s16(a1, y1, x0, 1); + int32x4_t a3 = vmlal_lane_s16(a2, y5, x4, 1); + + int16x4_t y2 = vext_s16(y0, y4, 2); + int16x4_t y6 = vext_s16(y4, y8, 2); + int32x4_t a4 = vmlal_lane_s16(a3, y2, x0, 2); + int32x4_t a5 = vmlal_lane_s16(a4, y6, x4, 2); + + int16x4_t y3 = vext_s16(y0, y4, 3); + int16x4_t y7 = vext_s16(y4, y8, 3); + int32x4_t a6 = vmlal_lane_s16(a5, y3, x0, 3); + int32x4_t a7 = vmlal_lane_s16(a6, y7, x4, 3); + + y0 = y8; + a = a7; + x += 8; + y += 8; + } + if (j + 4 < len) { + /* Load x[0...3] */ + int16x4_t x0 = vld1_s16(x); + /* Load y[4...7] */ + int16x4_t y4 = vld1_s16(y); + int32x4_t a0 = vmlal_lane_s16(a, y0, x0, 0); + int16x4_t y1 = vext_s16(y0, y4, 1); + int32x4_t a1 = vmlal_lane_s16(a0, y1, x0, 1); + int16x4_t y2 = vext_s16(y0, y4, 2); + int32x4_t a2 = vmlal_lane_s16(a1, y2, x0, 2); + int16x4_t y3 = vext_s16(y0, y4, 3); + int32x4_t a3 = vmlal_lane_s16(a2, y3, x0, 3); + y0 = y4; + a = a3; + x += 4; + y += 4; + j += 4; + } + if (j + 2 < len) { + /* Load x[0...1] */ + int16x4x2_t xx = vld2_dup_s16(x); + int16x4_t x0 = xx.val[0]; + int16x4_t x1 = xx.val[1]; + /* Load y[4...5]. + We would like to use vld1_dup_s32(), but casting the pointer would + break strict aliasing rules and potentially have alignment issues. + Fortunately the compiler seems capable of translating this memcpy() + and vdup_n_s32() into the equivalent vld1_dup_s32().*/ + int32_t yy; + memcpy(&yy, y, sizeof(yy)); + int16x4_t y4 = vreinterpret_s16_s32(vdup_n_s32(yy)); + int32x4_t a0 = vmlal_s16(a, y0, x0); + int16x4_t y1 = vext_s16(y0, y4, 1); + /* Replace bottom copy of {y[5], y[4]} in y4 with {y[3], y[2]} from y0, + using VSRI instead of VEXT, since it's a data-processing + instruction. */ + y0 = vreinterpret_s16_s64(vsri_n_s64(vreinterpret_s64_s16(y4), vreinterpret_s64_s16(y0), 32)); - int32x4_t a1 = vmlal_s16(a0, y1, x1); - a = a1; - x += 2; - y += 2; - j += 2; - } - if (j + 1 < len) { - /* Load next x. */ - int16x4_t x0 = vld1_dup_s16(x); - int32x4_t a0 = vmlal_s16(a, y0, x0); - /* Load last y. */ - int16x4_t y4 = vld1_dup_s16(y); - y0 = vreinterpret_s16_s64(vsri_n_s64(vreinterpret_s64_s16(y4), + int32x4_t a1 = vmlal_s16(a0, y1, x1); + a = a1; + x += 2; + y += 2; + j += 2; + } + if (j + 1 < len) { + /* Load next x. */ + int16x4_t x0 = vld1_dup_s16(x); + int32x4_t a0 = vmlal_s16(a, y0, x0); + /* Load last y. */ + int16x4_t y4 = vld1_dup_s16(y); + y0 = vreinterpret_s16_s64(vsri_n_s64(vreinterpret_s64_s16(y4), vreinterpret_s64_s16(y0), 16)); - a = a0; - x++; - } - /* Load last x. */ - int16x4_t x0 = vld1_dup_s16(x); - int32x4_t a0 = vmlal_s16(a, y0, x0); - vst1q_s32(sum, a0); + a = a0; + x++; + } + /* Load last x. */ + int16x4_t x0 = vld1_dup_s16(x); + int32x4_t a0 = vmlal_s16(a, y0, x0); + vst1q_s32(sum, a0); } #else -#if defined(__ARM_FEATURE_FMA) && defined(__ARM_ARCH_ISA_A64) +# if defined(__ARM_FEATURE_FMA) && defined(__ARM_ARCH_ISA_A64) /* If we can, force the compiler to use an FMA instruction rather than break * vmlaq_f32() into fmul/fadd. */ -#ifdef vmlaq_lane_f32 -#undef vmlaq_lane_f32 -#endif -#define vmlaq_lane_f32(a,b,c,lane) vfmaq_lane_f32(a,b,c,lane) -#endif +# ifdef vmlaq_lane_f32 +# undef vmlaq_lane_f32 +# endif +# define vmlaq_lane_f32(a, b, c, lane) vfmaq_lane_f32(a, b, c, lane) +# endif /* - * Function: xcorr_kernel_neon_float + * Function: oaci_xcorr_kernel_neon_float * --------------------------------- * Computes 4 correlation values and stores them in sum[4] */ -static void xcorr_kernel_neon_float(const float32_t *x, const float32_t *y, - float32_t sum[4], int len) { - float32x4_t YY[3]; - float32x4_t YEXT[3]; - float32x4_t XX[2]; - float32x2_t XX_2; - float32x4_t SUMM; - const float32_t *xi = x; - const float32_t *yi = y; - - celt_assert(len>0); - - YY[0] = vld1q_f32(yi); - SUMM = vdupq_n_f32(0); - - /* Consume 8 elements in x vector and 12 elements in y - * vector. However, the 12'th element never really gets - * touched in this loop. So, if len == 8, then we only - * must access y[0] to y[10]. y[11] must not be accessed - * hence make sure len > 8 and not len >= 8 - */ - while (len > 8) { - yi += 4; - YY[1] = vld1q_f32(yi); - yi += 4; - YY[2] = vld1q_f32(yi); - - XX[0] = vld1q_f32(xi); - xi += 4; - XX[1] = vld1q_f32(xi); - xi += 4; - - SUMM = vmlaq_lane_f32(SUMM, YY[0], vget_low_f32(XX[0]), 0); - YEXT[0] = vextq_f32(YY[0], YY[1], 1); - SUMM = vmlaq_lane_f32(SUMM, YEXT[0], vget_low_f32(XX[0]), 1); - YEXT[1] = vextq_f32(YY[0], YY[1], 2); - SUMM = vmlaq_lane_f32(SUMM, YEXT[1], vget_high_f32(XX[0]), 0); - YEXT[2] = vextq_f32(YY[0], YY[1], 3); - SUMM = vmlaq_lane_f32(SUMM, YEXT[2], vget_high_f32(XX[0]), 1); - - SUMM = vmlaq_lane_f32(SUMM, YY[1], vget_low_f32(XX[1]), 0); - YEXT[0] = vextq_f32(YY[1], YY[2], 1); - SUMM = vmlaq_lane_f32(SUMM, YEXT[0], vget_low_f32(XX[1]), 1); - YEXT[1] = vextq_f32(YY[1], YY[2], 2); - SUMM = vmlaq_lane_f32(SUMM, YEXT[1], vget_high_f32(XX[1]), 0); - YEXT[2] = vextq_f32(YY[1], YY[2], 3); - SUMM = vmlaq_lane_f32(SUMM, YEXT[2], vget_high_f32(XX[1]), 1); - - YY[0] = YY[2]; - len -= 8; - } - - /* Consume 4 elements in x vector and 8 elements in y - * vector. However, the 8'th element in y never really gets - * touched in this loop. So, if len == 4, then we only - * must access y[0] to y[6]. y[7] must not be accessed - * hence make sure len>4 and not len>=4 - */ - if (len > 4) { - yi += 4; - YY[1] = vld1q_f32(yi); - - XX[0] = vld1q_f32(xi); - xi += 4; - - SUMM = vmlaq_lane_f32(SUMM, YY[0], vget_low_f32(XX[0]), 0); - YEXT[0] = vextq_f32(YY[0], YY[1], 1); - SUMM = vmlaq_lane_f32(SUMM, YEXT[0], vget_low_f32(XX[0]), 1); - YEXT[1] = vextq_f32(YY[0], YY[1], 2); - SUMM = vmlaq_lane_f32(SUMM, YEXT[1], vget_high_f32(XX[0]), 0); - YEXT[2] = vextq_f32(YY[0], YY[1], 3); - SUMM = vmlaq_lane_f32(SUMM, YEXT[2], vget_high_f32(XX[0]), 1); - - YY[0] = YY[1]; - len -= 4; - } - - while (--len > 0) { - XX_2 = vld1_dup_f32(xi++); - SUMM = vmlaq_lane_f32(SUMM, YY[0], XX_2, 0); - YY[0]= vld1q_f32(++yi); - } - - XX_2 = vld1_dup_f32(xi); - SUMM = vmlaq_lane_f32(SUMM, YY[0], XX_2, 0); - - vst1q_f32(sum, SUMM); +static void oaci_xcorr_kernel_neon_float(const float32_t *x, const float32_t *y, + float32_t sum[4], int len) { + float32x4_t YY[3]; + float32x4_t YEXT[3]; + float32x4_t XX[2]; + float32x2_t XX_2; + float32x4_t SUMM; + const float32_t *xi = x; + const float32_t *yi = y; + + celt_assert(len > 0); + + YY[0] = vld1q_f32(yi); + SUMM = vdupq_n_f32(0); + + /* Consume 8 elements in x vector and 12 elements in y + * vector. However, the 12'th element never really gets + * touched in this loop. So, if len == 8, then we only + * must access y[0] to y[10]. y[11] must not be accessed + * hence make sure len > 8 and not len >= 8 + */ + while (len > 8) { + yi += 4; + YY[1] = vld1q_f32(yi); + yi += 4; + YY[2] = vld1q_f32(yi); + + XX[0] = vld1q_f32(xi); + xi += 4; + XX[1] = vld1q_f32(xi); + xi += 4; + + SUMM = vmlaq_lane_f32(SUMM, YY[0], vget_low_f32(XX[0]), 0); + YEXT[0] = vextq_f32(YY[0], YY[1], 1); + SUMM = vmlaq_lane_f32(SUMM, YEXT[0], vget_low_f32(XX[0]), 1); + YEXT[1] = vextq_f32(YY[0], YY[1], 2); + SUMM = vmlaq_lane_f32(SUMM, YEXT[1], vget_high_f32(XX[0]), 0); + YEXT[2] = vextq_f32(YY[0], YY[1], 3); + SUMM = vmlaq_lane_f32(SUMM, YEXT[2], vget_high_f32(XX[0]), 1); + + SUMM = vmlaq_lane_f32(SUMM, YY[1], vget_low_f32(XX[1]), 0); + YEXT[0] = vextq_f32(YY[1], YY[2], 1); + SUMM = vmlaq_lane_f32(SUMM, YEXT[0], vget_low_f32(XX[1]), 1); + YEXT[1] = vextq_f32(YY[1], YY[2], 2); + SUMM = vmlaq_lane_f32(SUMM, YEXT[1], vget_high_f32(XX[1]), 0); + YEXT[2] = vextq_f32(YY[1], YY[2], 3); + SUMM = vmlaq_lane_f32(SUMM, YEXT[2], vget_high_f32(XX[1]), 1); + + YY[0] = YY[2]; + len -= 8; + } + + /* Consume 4 elements in x vector and 8 elements in y + * vector. However, the 8'th element in y never really gets + * touched in this loop. So, if len == 4, then we only + * must access y[0] to y[6]. y[7] must not be accessed + * hence make sure len>4 and not len>=4 + */ + if (len > 4) { + yi += 4; + YY[1] = vld1q_f32(yi); + + XX[0] = vld1q_f32(xi); + xi += 4; + + SUMM = vmlaq_lane_f32(SUMM, YY[0], vget_low_f32(XX[0]), 0); + YEXT[0] = vextq_f32(YY[0], YY[1], 1); + SUMM = vmlaq_lane_f32(SUMM, YEXT[0], vget_low_f32(XX[0]), 1); + YEXT[1] = vextq_f32(YY[0], YY[1], 2); + SUMM = vmlaq_lane_f32(SUMM, YEXT[1], vget_high_f32(XX[0]), 0); + YEXT[2] = vextq_f32(YY[0], YY[1], 3); + SUMM = vmlaq_lane_f32(SUMM, YEXT[2], vget_high_f32(XX[0]), 1); + + YY[0] = YY[1]; + len -= 4; + } + + while (--len > 0) { + XX_2 = vld1_dup_f32(xi++); + SUMM = vmlaq_lane_f32(SUMM, YY[0], XX_2, 0); + YY[0] = vld1q_f32(++yi); + } + + XX_2 = vld1_dup_f32(xi); + SUMM = vmlaq_lane_f32(SUMM, YY[0], XX_2, 0); + + vst1q_f32(sum, SUMM); } -void celt_pitch_xcorr_float_neon(const opus_val16 *_x, const opus_val16 *_y, - opus_val32 *xcorr, int len, int max_pitch, int arch) { - int i; - (void)arch; - celt_assert(max_pitch > 0); - celt_sig_assert((((size_t)_x)&3)==0); - - for (i = 0; i < (max_pitch-3); i += 4) { - xcorr_kernel_neon_float((const float32_t *)_x, (const float32_t *)_y+i, - (float32_t *)xcorr+i, len); - } - - /* In case max_pitch isn't a multiple of 4, do non-unrolled version. */ - for (; i < max_pitch; i++) { - xcorr[i] = celt_inner_prod_neon(_x, _y+i, len); - } +void oaci_celt_pitch_xcorr_float_neon(const oac_val16 *_x, const oac_val16 *_y, + oac_val32 *xcorr, int len, int max_pitch, int arch) { + int i; + (void)arch; + celt_assert(max_pitch > 0); + celt_sig_assert((((size_t)_x)&3) == 0); + + for (i = 0; i < (max_pitch - 3); i += 4) { + oaci_xcorr_kernel_neon_float((const float32_t *)_x, (const float32_t *)_y + i, + (float32_t *)xcorr + i, len); + } + + /* In case max_pitch isn't a multiple of 4, do non-unrolled version. */ + for (; i < max_pitch; i++) { + xcorr[i] = oaci_celt_inner_prod_neon(_x, _y + i, len); + } } #endif diff --git a/celt/arm/celt_pitch_xcorr_arm.s b/celt/arm/celt_pitch_xcorr_arm.s index 65a4461ff..fa5987d77 100644 --- a/celt/arm/celt_pitch_xcorr_arm.s +++ b/celt/arm/celt_pitch_xcorr_arm.s @@ -30,26 +30,26 @@ GET celt/arm/armopts.s -IF OPUS_ARM_MAY_HAVE_EDSP - EXPORT celt_pitch_xcorr_edsp +IF OAC_ARM_MAY_HAVE_EDSP + EXPORT oaci_celt_pitch_xcorr_edsp ENDIF -IF OPUS_ARM_MAY_HAVE_NEON - EXPORT celt_pitch_xcorr_neon +IF OAC_ARM_MAY_HAVE_NEON + EXPORT oaci_celt_pitch_xcorr_neon ENDIF -IF OPUS_ARM_MAY_HAVE_NEON +IF OAC_ARM_MAY_HAVE_NEON ; Compute sum[k]=sum(x[j]*y[j+k],j=0...len-1), k=0...3 -xcorr_kernel_neon PROC +oaci_xcorr_kernel_neon PROC xcorr_kernel_neon_start ; input: ; r3 = int len - ; r4 = opus_val16 *x - ; r5 = opus_val16 *y - ; q0 = opus_val32 sum[4] + ; r4 = oac_val16 *x + ; r5 = oac_val16 *y + ; q0 = oac_val32 sum[4] ; output: - ; q0 = opus_val32 sum[4] + ; q0 = oac_val32 sum[4] ; preserved: r0-r3, r6-r11, d2, q4-q7, q9-q15 ; internal usage: ; r12 = int j @@ -152,19 +152,19 @@ xcorr_kernel_neon_process1 MOV pc, lr ENDP -; opus_val32 celt_pitch_xcorr_neon(opus_val16 *_x, opus_val16 *_y, -; opus_val32 *xcorr, int len, int max_pitch, int arch) -celt_pitch_xcorr_neon PROC +; oac_val32 oaci_celt_pitch_xcorr_neon(oac_val16 *_x, oac_val16 *_y, +; oac_val32 *xcorr, int len, int max_pitch, int arch) +oaci_celt_pitch_xcorr_neon PROC ; input: - ; r0 = opus_val16 *_x - ; r1 = opus_val16 *_y - ; r2 = opus_val32 *xcorr + ; r0 = oac_val16 *_x + ; r1 = oac_val16 *_y + ; r2 = oac_val32 *xcorr ; r3 = int len ; output: ; r0 = int maxcorr ; internal usage: - ; r4 = opus_val16 *x (for xcorr_kernel_neon()) - ; r5 = opus_val16 *y (for xcorr_kernel_neon()) + ; r4 = oac_val16 *x (for xcorr_kernel_neon()) + ; r5 = oac_val16 *y (for xcorr_kernel_neon()) ; r6 = int max_pitch ; r12 = int j ; q15 = int maxcorr[4] (q15 is not used by xcorr_kernel_neon()) @@ -255,24 +255,24 @@ celt_pitch_xcorr_neon_done ENDIF -IF OPUS_ARM_MAY_HAVE_EDSP +IF OAC_ARM_MAY_HAVE_EDSP ; This will get used on ARMv7 devices without NEON, so it has been optimized ; to take advantage of dual-issuing where possible. -xcorr_kernel_edsp PROC +oaci_xcorr_kernel_edsp PROC xcorr_kernel_edsp_start ; input: ; r3 = int len - ; r4 = opus_val16 *_x (must be 32-bit aligned) - ; r5 = opus_val16 *_y (must be 32-bit aligned) - ; r6...r9 = opus_val32 sum[4] + ; r4 = oac_val16 *_x (must be 32-bit aligned) + ; r5 = oac_val16 *_y (must be 32-bit aligned) + ; r6...r9 = oac_val32 sum[4] ; output: - ; r6...r9 = opus_val32 sum[4] + ; r6...r9 = oac_val32 sum[4] ; preserved: r0-r5 ; internal usage ; r2 = int j - ; r12,r14 = opus_val16 x[4] - ; r10,r11 = opus_val16 y[4] + ; r12,r14 = oac_val16 x[4] + ; r10,r11 = oac_val16 y[4] STMFD sp!, {r2,r4,r5,lr} LDR r10, [r5], #4 ; Load y[0...1] SUBS r2, r3, #4 ; j = len-4 @@ -343,21 +343,21 @@ xcorr_kernel_edsp_done LDMFD sp!, {r2,r4,r5,pc} ENDP -celt_pitch_xcorr_edsp PROC +oaci_celt_pitch_xcorr_edsp PROC ; input: - ; r0 = opus_val16 *_x (must be 32-bit aligned) - ; r1 = opus_val16 *_y (only needs to be 16-bit aligned) - ; r2 = opus_val32 *xcorr + ; r0 = oac_val16 *_x (must be 32-bit aligned) + ; r1 = oac_val16 *_y (only needs to be 16-bit aligned) + ; r2 = oac_val32 *xcorr ; r3 = int len ; output: ; r0 = maxcorr ; internal usage - ; r4 = opus_val16 *x - ; r5 = opus_val16 *y - ; r6 = opus_val32 sum0 - ; r7 = opus_val32 sum1 - ; r8 = opus_val32 sum2 - ; r9 = opus_val32 sum3 + ; r4 = oac_val16 *x + ; r5 = oac_val16 *y + ; r6 = oac_val32 sum0 + ; r7 = oac_val32 sum1 + ; r8 = oac_val32 sum2 + ; r9 = oac_val32 sum3 ; r1 = int max_pitch ; r12 = int j ; ignored: diff --git a/celt/arm/fft_arm.h b/celt/arm/fft_arm.h index 0b78175f3..e7653c780 100644 --- a/celt/arm/fft_arm.h +++ b/celt/arm/fft_arm.h @@ -28,7 +28,7 @@ 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. -*/ + */ #if !defined(FFT_ARM_H) @@ -38,33 +38,33 @@ #if defined(HAVE_ARM_NE10) -int opus_fft_alloc_arm_neon(kiss_fft_state *st); -void opus_fft_free_arm_neon(kiss_fft_state *st); +int oac_fft_alloc_arm_neon(kiss_fft_state *st); +void oac_fft_free_arm_neon(kiss_fft_state *st); -void opus_fft_neon(const kiss_fft_state *st, - const kiss_fft_cpx *fin, - kiss_fft_cpx *fout); +void oac_fft_neon(const kiss_fft_state *st, + const kiss_fft_cpx *fin, + kiss_fft_cpx *fout); -void opus_ifft_neon(const kiss_fft_state *st, - const kiss_fft_cpx *fin, - kiss_fft_cpx *fout); +void oac_ifft_neon(const kiss_fft_state *st, + const kiss_fft_cpx *fin, + kiss_fft_cpx *fout); -#if !defined(OPUS_HAVE_RTCD) -#define OVERRIDE_OPUS_FFT (1) +# if !defined(OAC_HAVE_RTCD) +# define OVERRIDE_OAC_FFT (1) -#define opus_fft_alloc_arch(_st, arch) \ - ((void)(arch), opus_fft_alloc_arm_neon(_st)) +# define oac_fft_alloc_arch(_st, arch) \ + ((void)(arch), oac_fft_alloc_arm_neon(_st)) -#define opus_fft_free_arch(_st, arch) \ - ((void)(arch), opus_fft_free_arm_neon(_st)) +# define oac_fft_free_arch(_st, arch) \ + ((void)(arch), oac_fft_free_arm_neon(_st)) -#define opus_fft(_st, _fin, _fout, arch) \ - ((void)(arch), opus_fft_neon(_st, _fin, _fout)) +# define oac_fft(_st, _fin, _fout, arch) \ + ((void)(arch), oac_fft_neon(_st, _fin, _fout)) -#define opus_ifft(_st, _fin, _fout, arch) \ - ((void)(arch), opus_ifft_neon(_st, _fin, _fout)) +# define oac_ifft(_st, _fin, _fout, arch) \ + ((void)(arch), oac_ifft_neon(_st, _fin, _fout)) -#endif /* OPUS_HAVE_RTCD */ +# endif /* OAC_HAVE_RTCD */ #endif /* HAVE_ARM_NE10 */ diff --git a/celt/arm/fixed_arm64.h b/celt/arm/fixed_arm64.h index c6fbd3db2..d3de750ea 100644 --- a/celt/arm/fixed_arm64.h +++ b/celt/arm/fixed_arm64.h @@ -22,7 +22,7 @@ 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. -*/ + */ #ifndef FIXED_ARM64_H #define FIXED_ARM64_H diff --git a/celt/arm/fixed_armv4.h b/celt/arm/fixed_armv4.h index d84888a77..618283c0b 100644 --- a/celt/arm/fixed_armv4.h +++ b/celt/arm/fixed_armv4.h @@ -22,42 +22,40 @@ 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. -*/ + */ #ifndef FIXED_ARMv4_H #define FIXED_ARMv4_H /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ #undef MULT16_32_Q16 -static OPUS_INLINE opus_val32 MULT16_32_Q16_armv4(opus_val16 a, opus_val32 b) -{ - unsigned rd_lo; - int rd_hi; - __asm__( - "#MULT16_32_Q16\n\t" - "smull %0, %1, %2, %3\n\t" - : "=&r"(rd_lo), "=&r"(rd_hi) - : "%r"(b),"r"(SHL32(a,16)) - ); - return rd_hi; +static OAC_INLINE oac_val32 MULT16_32_Q16_armv4(oac_val16 a, oac_val32 b) { + unsigned rd_lo; + int rd_hi; + __asm__ ( + "#MULT16_32_Q16\n\t" + "smull %0, %1, %2, %3\n\t" + : "=&r" (rd_lo), "=&r" (rd_hi) + : "%r" (b), "r" (SHL32(a, 16)) + ); + return rd_hi; } #define MULT16_32_Q16(a, b) (MULT16_32_Q16_armv4(a, b)) /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ #undef MULT16_32_Q15 -static OPUS_INLINE opus_val32 MULT16_32_Q15_armv4(opus_val16 a, opus_val32 b) -{ - unsigned rd_lo; - int rd_hi; - __asm__( - "#MULT16_32_Q15\n\t" - "smull %0, %1, %2, %3\n\t" - : "=&r"(rd_lo), "=&r"(rd_hi) - : "%r"(b), "r"(SHL32(a,16)) - ); - /*We intentionally don't OR in the high bit of rd_lo for speed.*/ - return SHL32(rd_hi,1); +static OAC_INLINE oac_val32 MULT16_32_Q15_armv4(oac_val16 a, oac_val32 b) { + unsigned rd_lo; + int rd_hi; + __asm__ ( + "#MULT16_32_Q15\n\t" + "smull %0, %1, %2, %3\n\t" + : "=&r" (rd_lo), "=&r" (rd_hi) + : "%r" (b), "r" (SHL32(a, 16)) + ); + /*We intentionally don't OR in the high bit of rd_lo for speed.*/ + return SHL32(rd_hi, 1); } #define MULT16_32_Q15(a, b) (MULT16_32_Q15_armv4(a, b)) @@ -75,6 +73,6 @@ static OPUS_INLINE opus_val32 MULT16_32_Q15_armv4(opus_val16 a, opus_val32 b) /** 32x32 multiplication, followed by a 31-bit shift right. Results fits in 32 bits */ #undef MULT32_32_Q31 -#define MULT32_32_Q31(a,b) (opus_val32)((((opus_int64)(a)) * ((opus_int64)(b)))>>31) +#define MULT32_32_Q31(a, b) (oac_val32)((((oac_int64)(a))*((oac_int64)(b)))>>31) #endif diff --git a/celt/arm/fixed_armv5e.h b/celt/arm/fixed_armv5e.h index 6bf73cbac..8680f83b6 100644 --- a/celt/arm/fixed_armv5e.h +++ b/celt/arm/fixed_armv5e.h @@ -25,7 +25,7 @@ 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. -*/ + */ #ifndef FIXED_ARMv5E_H #define FIXED_ARMv5E_H @@ -34,32 +34,30 @@ /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ #undef MULT16_32_Q16 -static OPUS_INLINE opus_val32 MULT16_32_Q16_armv5e(opus_val16 a, opus_val32 b) -{ - int res; - __asm__( - "#MULT16_32_Q16\n\t" - "smulwb %0, %1, %2\n\t" - : "=r"(res) - : "r"(b),"r"(a) - ); - return res; +static OAC_INLINE oac_val32 MULT16_32_Q16_armv5e(oac_val16 a, oac_val32 b) { + int res; + __asm__ ( + "#MULT16_32_Q16\n\t" + "smulwb %0, %1, %2\n\t" + : "=r" (res) + : "r" (b), "r" (a) + ); + return res; } #define MULT16_32_Q16(a, b) (MULT16_32_Q16_armv5e(a, b)) /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ #undef MULT16_32_Q15 -static OPUS_INLINE opus_val32 MULT16_32_Q15_armv5e(opus_val16 a, opus_val32 b) -{ - int res; - __asm__( - "#MULT16_32_Q15\n\t" - "smulwb %0, %1, %2\n\t" - : "=r"(res) - : "r"(b), "r"(a) - ); - return SHL32(res,1); +static OAC_INLINE oac_val32 MULT16_32_Q15_armv5e(oac_val16 a, oac_val32 b) { + int res; + __asm__ ( + "#MULT16_32_Q15\n\t" + "smulwb %0, %1, %2\n\t" + : "=r" (res) + : "r" (b), "r" (a) + ); + return SHL32(res, 1); } #define MULT16_32_Q15(a, b) (MULT16_32_Q15_armv5e(a, b)) @@ -68,84 +66,79 @@ static OPUS_INLINE opus_val32 MULT16_32_Q15_armv5e(opus_val16 a, opus_val32 b) b must fit in 31 bits. Result fits in 32 bits. */ #undef MAC16_32_Q15 -static OPUS_INLINE opus_val32 MAC16_32_Q15_armv5e(opus_val32 c, opus_val16 a, - opus_val32 b) -{ - int res; - __asm__( - "#MAC16_32_Q15\n\t" - "smlawb %0, %1, %2, %3;\n" - : "=r"(res) - : "r"(SHL32(b,1)), "r"(a), "r"(c) - ); - return res; +static OAC_INLINE oac_val32 MAC16_32_Q15_armv5e(oac_val32 c, oac_val16 a, + oac_val32 b) { + int res; + __asm__ ( + "#MAC16_32_Q15\n\t" + "smlawb %0, %1, %2, %3;\n" + : "=r" (res) + : "r" (SHL32(b, 1)), "r" (a), "r" (c) + ); + return res; } #define MAC16_32_Q15(c, a, b) (MAC16_32_Q15_armv5e(c, a, b)) /** 16x32 multiply, followed by a 16-bit shift right and 32-bit add. Result fits in 32 bits. */ #undef MAC16_32_Q16 -static OPUS_INLINE opus_val32 MAC16_32_Q16_armv5e(opus_val32 c, opus_val16 a, - opus_val32 b) -{ - int res; - __asm__( - "#MAC16_32_Q16\n\t" - "smlawb %0, %1, %2, %3;\n" - : "=r"(res) - : "r"(b), "r"(a), "r"(c) - ); - return res; +static OAC_INLINE oac_val32 MAC16_32_Q16_armv5e(oac_val32 c, oac_val16 a, + oac_val32 b) { + int res; + __asm__ ( + "#MAC16_32_Q16\n\t" + "smlawb %0, %1, %2, %3;\n" + : "=r" (res) + : "r" (b), "r" (a), "r" (c) + ); + return res; } #define MAC16_32_Q16(c, a, b) (MAC16_32_Q16_armv5e(c, a, b)) /** 16x16 multiply-add where the result fits in 32 bits */ #undef MAC16_16 -static OPUS_INLINE opus_val32 MAC16_16_armv5e(opus_val32 c, opus_val16 a, - opus_val16 b) -{ - int res; - __asm__( - "#MAC16_16\n\t" - "smlabb %0, %1, %2, %3;\n" - : "=r"(res) - : "r"(a), "r"(b), "r"(c) - ); - return res; +static OAC_INLINE oac_val32 MAC16_16_armv5e(oac_val32 c, oac_val16 a, + oac_val16 b) { + int res; + __asm__ ( + "#MAC16_16\n\t" + "smlabb %0, %1, %2, %3;\n" + : "=r" (res) + : "r" (a), "r" (b), "r" (c) + ); + return res; } #define MAC16_16(c, a, b) (MAC16_16_armv5e(c, a, b)) /** 16x16 multiplication where the result fits in 32 bits */ #undef MULT16_16 -static OPUS_INLINE opus_val32 MULT16_16_armv5e(opus_val16 a, opus_val16 b) -{ - int res; - __asm__( - "#MULT16_16\n\t" - "smulbb %0, %1, %2;\n" - : "=r"(res) - : "r"(a), "r"(b) - ); - return res; +static OAC_INLINE oac_val32 MULT16_16_armv5e(oac_val16 a, oac_val16 b) { + int res; + __asm__ ( + "#MULT16_16\n\t" + "smulbb %0, %1, %2;\n" + : "=r" (res) + : "r" (a), "r" (b) + ); + return res; } #define MULT16_16(a, b) (MULT16_16_armv5e(a, b)) -#ifdef OPUS_ARM_INLINE_MEDIA - -#undef SIG2WORD16 -static OPUS_INLINE opus_val16 SIG2WORD16_armv6(opus_val32 x) -{ - celt_sig res; - __asm__( - "#SIG2WORD16\n\t" - "ssat %0, #16, %1, ASR #12\n\t" - : "=r"(res) - : "r"(x+2048) - ); - return EXTRACT16(res); +#ifdef OAC_ARM_INLINE_MEDIA + +# undef SIG2WORD16 +static OAC_INLINE oac_val16 SIG2WORD16_armv6(oac_val32 x) { + celt_sig res; + __asm__ ( + "#SIG2WORD16\n\t" + "ssat %0, #16, %1, ASR #12\n\t" + : "=r" (res) + : "r" (x + 2048) + ); + return EXTRACT16(res); } -#define SIG2WORD16(x) (SIG2WORD16_armv6(x)) +# define SIG2WORD16(x) (SIG2WORD16_armv6(x)) -#endif /* OPUS_ARM_INLINE_MEDIA */ +#endif /* OAC_ARM_INLINE_MEDIA */ #endif diff --git a/celt/arm/kiss_fft_armv4.h b/celt/arm/kiss_fft_armv4.h index e4faad6f2..26d9577fc 100644 --- a/celt/arm/kiss_fft_armv4.h +++ b/celt/arm/kiss_fft_armv4.h @@ -1,120 +1,120 @@ /*Copyright (c) 2013, Xiph.Org Foundation and contributors. - All rights reserved. + All rights reserved. - Redistribution and use in source and binary forms, with or without + 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, + * 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, + * 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.*/ + 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.*/ #ifndef KISS_FFT_ARMv4_H #define KISS_FFT_ARMv4_H #if !defined(KISS_FFT_GUTS_H) -#error "This file should only be included from _kiss_fft_guts.h" +# error "This file should only be included from _kiss_fft_guts.h" #endif #ifdef FIXED_POINT -#undef C_MUL -#define C_MUL(m,a,b) \ - do{ \ - int br__; \ - int bi__; \ - int tt__; \ - __asm__ __volatile__( \ - "#C_MUL\n\t" \ - "ldrsh %[br], [%[bp], #0]\n\t" \ - "ldm %[ap], {r0,r1}\n\t" \ - "ldrsh %[bi], [%[bp], #2]\n\t" \ - "smull %[tt], %[mi], r1, %[br]\n\t" \ - "smlal %[tt], %[mi], r0, %[bi]\n\t" \ - "rsb %[bi], %[bi], #0\n\t" \ - "smull %[br], %[mr], r0, %[br]\n\t" \ - "mov %[tt], %[tt], lsr #15\n\t" \ - "smlal %[br], %[mr], r1, %[bi]\n\t" \ - "orr %[mi], %[tt], %[mi], lsl #17\n\t" \ - "mov %[br], %[br], lsr #15\n\t" \ - "orr %[mr], %[br], %[mr], lsl #17\n\t" \ - : [mr]"=r"((m).r), [mi]"=r"((m).i), \ - [br]"=&r"(br__), [bi]"=r"(bi__), [tt]"=r"(tt__) \ - : [ap]"r"(&(a)), [bp]"r"(&(b)) \ - : "r0", "r1" \ - ); \ - } \ - while(0) +# undef C_MUL +# define C_MUL(m, a, b) \ + do { \ + int br__; \ + int bi__; \ + int tt__; \ + __asm__ __volatile__ ( \ + "#C_MUL\n\t" \ + "ldrsh %[br], [%[bp], #0]\n\t" \ + "ldm %[ap], {r0,r1}\n\t" \ + "ldrsh %[bi], [%[bp], #2]\n\t" \ + "smull %[tt], %[mi], r1, %[br]\n\t" \ + "smlal %[tt], %[mi], r0, %[bi]\n\t" \ + "rsb %[bi], %[bi], #0\n\t" \ + "smull %[br], %[mr], r0, %[br]\n\t" \ + "mov %[tt], %[tt], lsr #15\n\t" \ + "smlal %[br], %[mr], r1, %[bi]\n\t" \ + "orr %[mi], %[tt], %[mi], lsl #17\n\t" \ + "mov %[br], %[br], lsr #15\n\t" \ + "orr %[mr], %[br], %[mr], lsl #17\n\t" \ + : [mr] "=r" ((m).r), [mi] "=r" ((m).i), \ + [br] "=&r" (br__), [bi] "=r" (bi__), [tt] "=r" (tt__) \ + : [ap] "r" (&(a)), [bp] "r" (&(b)) \ + : "r0", "r1" \ + ); \ + } \ + while (0) -#undef C_MUL4 -#define C_MUL4(m,a,b) \ - do{ \ - int br__; \ - int bi__; \ - int tt__; \ - __asm__ __volatile__( \ - "#C_MUL4\n\t" \ - "ldrsh %[br], [%[bp], #0]\n\t" \ - "ldm %[ap], {r0,r1}\n\t" \ - "ldrsh %[bi], [%[bp], #2]\n\t" \ - "smull %[tt], %[mi], r1, %[br]\n\t" \ - "smlal %[tt], %[mi], r0, %[bi]\n\t" \ - "rsb %[bi], %[bi], #0\n\t" \ - "smull %[br], %[mr], r0, %[br]\n\t" \ - "mov %[tt], %[tt], lsr #17\n\t" \ - "smlal %[br], %[mr], r1, %[bi]\n\t" \ - "orr %[mi], %[tt], %[mi], lsl #15\n\t" \ - "mov %[br], %[br], lsr #17\n\t" \ - "orr %[mr], %[br], %[mr], lsl #15\n\t" \ - : [mr]"=r"((m).r), [mi]"=r"((m).i), \ - [br]"=&r"(br__), [bi]"=r"(bi__), [tt]"=r"(tt__) \ - : [ap]"r"(&(a)), [bp]"r"(&(b)) \ - : "r0", "r1" \ - ); \ - } \ - while(0) +# undef C_MUL4 +# define C_MUL4(m, a, b) \ + do { \ + int br__; \ + int bi__; \ + int tt__; \ + __asm__ __volatile__ ( \ + "#C_MUL4\n\t" \ + "ldrsh %[br], [%[bp], #0]\n\t" \ + "ldm %[ap], {r0,r1}\n\t" \ + "ldrsh %[bi], [%[bp], #2]\n\t" \ + "smull %[tt], %[mi], r1, %[br]\n\t" \ + "smlal %[tt], %[mi], r0, %[bi]\n\t" \ + "rsb %[bi], %[bi], #0\n\t" \ + "smull %[br], %[mr], r0, %[br]\n\t" \ + "mov %[tt], %[tt], lsr #17\n\t" \ + "smlal %[br], %[mr], r1, %[bi]\n\t" \ + "orr %[mi], %[tt], %[mi], lsl #15\n\t" \ + "mov %[br], %[br], lsr #17\n\t" \ + "orr %[mr], %[br], %[mr], lsl #15\n\t" \ + : [mr] "=r" ((m).r), [mi] "=r" ((m).i), \ + [br] "=&r" (br__), [bi] "=r" (bi__), [tt] "=r" (tt__) \ + : [ap] "r" (&(a)), [bp] "r" (&(b)) \ + : "r0", "r1" \ + ); \ + } \ + while (0) -#undef C_MULC -#define C_MULC(m,a,b) \ - do{ \ - int br__; \ - int bi__; \ - int tt__; \ - __asm__ __volatile__( \ - "#C_MULC\n\t" \ - "ldrsh %[br], [%[bp], #0]\n\t" \ - "ldm %[ap], {r0,r1}\n\t" \ - "ldrsh %[bi], [%[bp], #2]\n\t" \ - "smull %[tt], %[mr], r0, %[br]\n\t" \ - "smlal %[tt], %[mr], r1, %[bi]\n\t" \ - "rsb %[bi], %[bi], #0\n\t" \ - "smull %[br], %[mi], r1, %[br]\n\t" \ - "mov %[tt], %[tt], lsr #15\n\t" \ - "smlal %[br], %[mi], r0, %[bi]\n\t" \ - "orr %[mr], %[tt], %[mr], lsl #17\n\t" \ - "mov %[br], %[br], lsr #15\n\t" \ - "orr %[mi], %[br], %[mi], lsl #17\n\t" \ - : [mr]"=r"((m).r), [mi]"=r"((m).i), \ - [br]"=&r"(br__), [bi]"=r"(bi__), [tt]"=r"(tt__) \ - : [ap]"r"(&(a)), [bp]"r"(&(b)) \ - : "r0", "r1" \ - ); \ - } \ - while(0) +# undef C_MULC +# define C_MULC(m, a, b) \ + do { \ + int br__; \ + int bi__; \ + int tt__; \ + __asm__ __volatile__ ( \ + "#C_MULC\n\t" \ + "ldrsh %[br], [%[bp], #0]\n\t" \ + "ldm %[ap], {r0,r1}\n\t" \ + "ldrsh %[bi], [%[bp], #2]\n\t" \ + "smull %[tt], %[mr], r0, %[br]\n\t" \ + "smlal %[tt], %[mr], r1, %[bi]\n\t" \ + "rsb %[bi], %[bi], #0\n\t" \ + "smull %[br], %[mi], r1, %[br]\n\t" \ + "mov %[tt], %[tt], lsr #15\n\t" \ + "smlal %[br], %[mi], r0, %[bi]\n\t" \ + "orr %[mr], %[tt], %[mr], lsl #17\n\t" \ + "mov %[br], %[br], lsr #15\n\t" \ + "orr %[mi], %[br], %[mi], lsl #17\n\t" \ + : [mr] "=r" ((m).r), [mi] "=r" ((m).i), \ + [br] "=&r" (br__), [bi] "=r" (bi__), [tt] "=r" (tt__) \ + : [ap] "r" (&(a)), [bp] "r" (&(b)) \ + : "r0", "r1" \ + ); \ + } \ + while (0) #endif /* FIXED_POINT */ diff --git a/celt/arm/kiss_fft_armv5e.h b/celt/arm/kiss_fft_armv5e.h index 9eca183d7..d2ec2de51 100644 --- a/celt/arm/kiss_fft_armv5e.h +++ b/celt/arm/kiss_fft_armv5e.h @@ -1,117 +1,117 @@ /*Copyright (c) 2013, Xiph.Org Foundation and contributors. - All rights reserved. + All rights reserved. - Redistribution and use in source and binary forms, with or without + 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, + * 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, + * 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.*/ + 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.*/ #ifndef KISS_FFT_ARMv5E_H #define KISS_FFT_ARMv5E_H #if !defined(KISS_FFT_GUTS_H) -#error "This file should only be included from _kiss_fft_guts.h" +# error "This file should only be included from _kiss_fft_guts.h" #endif #ifdef FIXED_POINT -#if defined(__thumb__)||defined(__thumb2__) -#define LDRD_CONS "Q" -#else -#define LDRD_CONS "Uq" -#endif +# if defined(__thumb__) || defined(__thumb2__) +# define LDRD_CONS "Q" +# else +# define LDRD_CONS "Uq" +# endif -#undef C_MUL -#define C_MUL(m,a,b) \ - do{ \ - int mr1__; \ - int mr2__; \ - int mi__; \ - long long aval__; \ - int bval__; \ - __asm__( \ - "#C_MUL\n\t" \ - "ldrd %[aval], %H[aval], %[ap]\n\t" \ - "ldr %[bval], %[bp]\n\t" \ - "smulwb %[mi], %H[aval], %[bval]\n\t" \ - "smulwb %[mr1], %[aval], %[bval]\n\t" \ - "smulwt %[mr2], %H[aval], %[bval]\n\t" \ - "smlawt %[mi], %[aval], %[bval], %[mi]\n\t" \ - : [mr1]"=r"(mr1__), [mr2]"=r"(mr2__), [mi]"=r"(mi__), \ - [aval]"=&r"(aval__), [bval]"=r"(bval__) \ - : [ap]LDRD_CONS(a), [bp]"m"(b) \ - ); \ - (m).r = SHL32(SUB32(mr1__, mr2__), 1); \ - (m).i = SHL32(mi__, 1); \ - } \ - while(0) +# undef C_MUL +# define C_MUL(m, a, b) \ + do { \ + int mr1__; \ + int mr2__; \ + int mi__; \ + long long aval__; \ + int bval__; \ + __asm__ ( \ + "#C_MUL\n\t" \ + "ldrd %[aval], %H[aval], %[ap]\n\t" \ + "ldr %[bval], %[bp]\n\t" \ + "smulwb %[mi], %H[aval], %[bval]\n\t" \ + "smulwb %[mr1], %[aval], %[bval]\n\t" \ + "smulwt %[mr2], %H[aval], %[bval]\n\t" \ + "smlawt %[mi], %[aval], %[bval], %[mi]\n\t" \ + : [mr1] "=r" (mr1__), [mr2] "=r" (mr2__), [mi] "=r" (mi__), \ + [aval] "=&r" (aval__), [bval] "=r" (bval__) \ + : [ap] LDRD_CONS(a), [bp] "m" (b) \ + ); \ + (m).r = SHL32(SUB32(mr1__, mr2__), 1); \ + (m).i = SHL32(mi__, 1); \ + } \ + while (0) -#undef C_MUL4 -#define C_MUL4(m,a,b) \ - do{ \ - int mr1__; \ - int mr2__; \ - int mi__; \ - long long aval__; \ - int bval__; \ - __asm__( \ - "#C_MUL4\n\t" \ - "ldrd %[aval], %H[aval], %[ap]\n\t" \ - "ldr %[bval], %[bp]\n\t" \ - "smulwb %[mi], %H[aval], %[bval]\n\t" \ - "smulwb %[mr1], %[aval], %[bval]\n\t" \ - "smulwt %[mr2], %H[aval], %[bval]\n\t" \ - "smlawt %[mi], %[aval], %[bval], %[mi]\n\t" \ - : [mr1]"=r"(mr1__), [mr2]"=r"(mr2__), [mi]"=r"(mi__), \ - [aval]"=&r"(aval__), [bval]"=r"(bval__) \ - : [ap]LDRD_CONS(a), [bp]"m"(b) \ - ); \ - (m).r = SHR32(SUB32(mr1__, mr2__), 1); \ - (m).i = SHR32(mi__, 1); \ - } \ - while(0) +# undef C_MUL4 +# define C_MUL4(m, a, b) \ + do { \ + int mr1__; \ + int mr2__; \ + int mi__; \ + long long aval__; \ + int bval__; \ + __asm__ ( \ + "#C_MUL4\n\t" \ + "ldrd %[aval], %H[aval], %[ap]\n\t" \ + "ldr %[bval], %[bp]\n\t" \ + "smulwb %[mi], %H[aval], %[bval]\n\t" \ + "smulwb %[mr1], %[aval], %[bval]\n\t" \ + "smulwt %[mr2], %H[aval], %[bval]\n\t" \ + "smlawt %[mi], %[aval], %[bval], %[mi]\n\t" \ + : [mr1] "=r" (mr1__), [mr2] "=r" (mr2__), [mi] "=r" (mi__), \ + [aval] "=&r" (aval__), [bval] "=r" (bval__) \ + : [ap] LDRD_CONS(a), [bp] "m" (b) \ + ); \ + (m).r = SHR32(SUB32(mr1__, mr2__), 1); \ + (m).i = SHR32(mi__, 1); \ + } \ + while (0) -#undef C_MULC -#define C_MULC(m,a,b) \ - do{ \ - int mr__; \ - int mi1__; \ - int mi2__; \ - long long aval__; \ - int bval__; \ - __asm__( \ - "#C_MULC\n\t" \ - "ldrd %[aval], %H[aval], %[ap]\n\t" \ - "ldr %[bval], %[bp]\n\t" \ - "smulwb %[mr], %[aval], %[bval]\n\t" \ - "smulwb %[mi1], %H[aval], %[bval]\n\t" \ - "smulwt %[mi2], %[aval], %[bval]\n\t" \ - "smlawt %[mr], %H[aval], %[bval], %[mr]\n\t" \ - : [mr]"=r"(mr__), [mi1]"=r"(mi1__), [mi2]"=r"(mi2__), \ - [aval]"=&r"(aval__), [bval]"=r"(bval__) \ - : [ap]LDRD_CONS(a), [bp]"m"(b) \ - ); \ - (m).r = SHL32(mr__, 1); \ - (m).i = SHL32(SUB32(mi1__, mi2__), 1); \ - } \ - while(0) +# undef C_MULC +# define C_MULC(m, a, b) \ + do { \ + int mr__; \ + int mi1__; \ + int mi2__; \ + long long aval__; \ + int bval__; \ + __asm__ ( \ + "#C_MULC\n\t" \ + "ldrd %[aval], %H[aval], %[ap]\n\t" \ + "ldr %[bval], %[bp]\n\t" \ + "smulwb %[mr], %[aval], %[bval]\n\t" \ + "smulwb %[mi1], %H[aval], %[bval]\n\t" \ + "smulwt %[mi2], %[aval], %[bval]\n\t" \ + "smlawt %[mr], %H[aval], %[bval], %[mr]\n\t" \ + : [mr] "=r" (mr__), [mi1] "=r" (mi1__), [mi2] "=r" (mi2__), \ + [aval] "=&r" (aval__), [bval] "=r" (bval__) \ + : [ap] LDRD_CONS(a), [bp] "m" (b) \ + ); \ + (m).r = SHL32(mr__, 1); \ + (m).i = SHL32(SUB32(mi1__, mi2__), 1); \ + } \ + while (0) #endif /* FIXED_POINT */ diff --git a/celt/arm/mathops_arm.h b/celt/arm/mathops_arm.h index b1f916997..3139c8e29 100644 --- a/celt/arm/mathops_arm.h +++ b/celt/arm/mathops_arm.h @@ -22,82 +22,79 @@ 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. -*/ + */ #if !defined(MATHOPS_ARM_H) -# define MATHOPS_ARM_H +#define MATHOPS_ARM_H #include "armcpu.h" #include "cpu_support.h" -#include "opus_defines.h" +#include "oac_defines.h" -# if !defined(DISABLE_FLOAT_API) && defined(OPUS_ARM_MAY_HAVE_NEON_INTR) +#if !defined(DISABLE_FLOAT_API) && defined(OAC_ARM_MAY_HAVE_NEON_INTR) -#include +# include -static inline int32x4_t vroundf(float32x4_t x) -{ -# if defined(__aarch64__) || (defined(__ARM_ARCH) && __ARM_ARCH >= 8) +static inline int32x4_t vroundf(float32x4_t x) { +# if defined(__aarch64__) || (defined(__ARM_ARCH) && __ARM_ARCH >= 8) return vcvtaq_s32_f32(x); -# else +# else uint32x4_t sign = vandq_u32(vreinterpretq_u32_f32(x), vdupq_n_u32(0x80000000)); uint32x4_t bias = vdupq_n_u32(0x3F000000); return vcvtq_s32_f32(vaddq_f32(x, vreinterpretq_f32_u32(vorrq_u32(bias, sign)))); -# endif +# endif } -static inline float vminvf(float32x4_t a) -{ -#if defined(__aarch64__) - return vminvq_f32(a); -#else +static inline float vminvf(float32x4_t a) { +# if defined(__aarch64__) + return vminvq_f32(a); +# else float32x2_t xy = vmin_f32(vget_low_f32(a), vget_high_f32(a)); float x = vget_lane_f32(xy, 0); float y = vget_lane_f32(xy, 1); return x < y ? x : y; -#endif +# endif } -static inline float vmaxvf(float32x4_t a) -{ -#if defined(__aarch64__) - return vmaxvq_f32(a); -#else +static inline float vmaxvf(float32x4_t a) { +# if defined(__aarch64__) + return vmaxvq_f32(a); +# else float32x2_t xy = vmax_f32(vget_low_f32(a), vget_high_f32(a)); float x = vget_lane_f32(xy, 0); float y = vget_lane_f32(xy, 1); return x > y ? x : y; -#endif +# endif } -void celt_float2int16_neon(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT out, int cnt); -# if defined(OPUS_HAVE_RTCD) && \ - (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) +void oaci_celt_float2int16_neon(const float * OAC_RESTRICT in, short * OAC_RESTRICT out, int cnt); +# if defined(OAC_HAVE_RTCD) && \ + (defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR)) extern void -(*const CELT_FLOAT2INT16_IMPL[OPUS_ARCHMASK+1])(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT out, int cnt); - -# define OVERRIDE_FLOAT2INT16 (1) -# define celt_float2int16(in, out, cnt, arch) \ - ((*CELT_FLOAT2INT16_IMPL[(arch)&OPUS_ARCHMASK])(in, out, cnt)) - -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) -# define OVERRIDE_FLOAT2INT16 (1) -# define celt_float2int16(in, out, cnt, arch) ((void)(arch), celt_float2int16_neon(in, out, cnt)) -# endif - -int opus_limit2_checkwithin1_neon(float * samples, int cnt); -# if defined(OPUS_HAVE_RTCD) && \ - (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) -extern int (*const OPUS_LIMIT2_CHECKWITHIN1_IMPL[OPUS_ARCHMASK+1])(float * samples, int cnt); - -# define OVERRIDE_LIMIT2_CHECKWITHIN1 (1) -# define opus_limit2_checkwithin1(samples, cnt, arch) \ - ((*OPUS_LIMIT2_CHECKWITHIN1_IMPL[(arch)&OPUS_ARCHMASK])(samples, cnt)) - -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) -# define OVERRIDE_LIMIT2_CHECKWITHIN1 (1) -# define opus_limit2_checkwithin1(samples, cnt, arch) ((void)(arch), opus_limit2_checkwithin1_neon(samples, cnt)) -# endif +(*const CELT_FLOAT2INT16_IMPL[OAC_ARCHMASK + 1])(const float * OAC_RESTRICT in, short * OAC_RESTRICT out, int cnt); + +# define OVERRIDE_FLOAT2INT16 (1) +# define oaci_celt_float2int16(in, out, cnt, arch) \ + ((*CELT_FLOAT2INT16_IMPL[(arch)&OAC_ARCHMASK])(in, out, cnt)) + +# elif defined(OAC_ARM_PRESUME_NEON_INTR) +# define OVERRIDE_FLOAT2INT16 (1) +# define oaci_celt_float2int16(in, out, cnt, arch) ((void)(arch), oaci_celt_float2int16_neon(in, out, cnt)) +# endif + +int oac_limit2_checkwithin1_neon(float * samples, int cnt); +# if defined(OAC_HAVE_RTCD) && \ + (defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR)) +extern int (*const OAC_LIMIT2_CHECKWITHIN1_IMPL[OAC_ARCHMASK + 1])(float * samples, int cnt); + +# define OVERRIDE_LIMIT2_CHECKWITHIN1 (1) +# define oac_limit2_checkwithin1(samples, cnt, arch) \ + ((*OAC_LIMIT2_CHECKWITHIN1_IMPL[(arch)&OAC_ARCHMASK])(samples, cnt)) + +# elif defined(OAC_ARM_PRESUME_NEON_INTR) +# define OVERRIDE_LIMIT2_CHECKWITHIN1 (1) +# define oac_limit2_checkwithin1(samples, cnt, arch) ((void)(arch), oac_limit2_checkwithin1_neon(samples, cnt)) # endif +#endif #endif /* MATHOPS_ARM_H */ diff --git a/celt/arm/mdct_arm.h b/celt/arm/mdct_arm.h index 14200bac4..1fb2488d9 100644 --- a/celt/arm/mdct_arm.h +++ b/celt/arm/mdct_arm.h @@ -28,7 +28,7 @@ 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. -*/ + */ #if !defined(MDCT_ARM_H) #define MDCT_ARM_H @@ -37,23 +37,23 @@ #if defined(HAVE_ARM_NE10) /** Compute a forward MDCT and scale by 4/N, trashes the input array */ -void clt_mdct_forward_neon(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 *window, int overlap, - int shift, int stride, int arch); - -void clt_mdct_backward_neon(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const opus_val16 *window, int overlap, - int shift, int stride, int arch); - -#if !defined(OPUS_HAVE_RTCD) -#define OVERRIDE_OPUS_MDCT (1) -#define clt_mdct_forward(_l, _in, _out, _window, _int, _shift, _stride, _arch) \ - clt_mdct_forward_neon(_l, _in, _out, _window, _int, _shift, _stride, _arch) -#define clt_mdct_backward(_l, _in, _out, _window, _int, _shift, _stride, _arch) \ - clt_mdct_backward_neon(_l, _in, _out, _window, _int, _shift, _stride, _arch) -#endif /* OPUS_HAVE_RTCD */ +void oaci_clt_mdct_forward_neon(const mdct_lookup *l, kiss_fft_scalar *in, + kiss_fft_scalar * OAC_RESTRICT out, + const oac_val16 *window, int overlap, + int shift, int stride, int arch); + +void oaci_clt_mdct_backward_neon(const mdct_lookup *l, kiss_fft_scalar *in, + kiss_fft_scalar * OAC_RESTRICT out, + const oac_val16 *window, int overlap, + int shift, int stride, int arch); + +# if !defined(OAC_HAVE_RTCD) +# define OVERRIDE_OAC_MDCT (1) +# define oaci_clt_mdct_forward(_l, _in, _out, _window, _int, _shift, _stride, _arch) \ + oaci_clt_mdct_forward_neon(_l, _in, _out, _window, _int, _shift, _stride, _arch) +# define oaci_clt_mdct_backward(_l, _in, _out, _window, _int, _shift, _stride, _arch) \ + oaci_clt_mdct_backward_neon(_l, _in, _out, _window, _int, _shift, _stride, _arch) +# endif /* OAC_HAVE_RTCD */ #endif /* HAVE_ARM_NE10 */ #endif diff --git a/celt/arm/meson.build b/celt/arm/meson.build index b4dec564f..f77b7896f 100644 --- a/celt/arm/meson.build +++ b/celt/arm/meson.build @@ -5,7 +5,7 @@ celt_sources_arm_asm = configure_file(input: 'celt_pitch_xcorr_arm.s', capture: true) celt_arm_armopts_s_in = configure_file(input: 'armopts.s.in', output: 'armopts.s', - configuration: opus_conf) + configuration: oac_conf) celt_arm_armopts_s = configure_file(input: [celt_arm_armopts_s_in], output: '@BASENAME@-gnu.S', command: arm2gnu + ['@INPUT@'], diff --git a/celt/arm/pitch_arm.h b/celt/arm/pitch_arm.h index bed8b04ea..403e36e5e 100644 --- a/celt/arm/pitch_arm.h +++ b/celt/arm/pitch_arm.h @@ -23,137 +23,139 @@ 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. -*/ + */ #if !defined(PITCH_ARM_H) -# define PITCH_ARM_H +#define PITCH_ARM_H -# include "armcpu.h" +#include "armcpu.h" -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N); -void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, - const opus_val16 *y02, int N, opus_val32 *xy1, opus_val32 *xy2); +#if defined(OAC_ARM_MAY_HAVE_NEON_INTR) +oac_val32 oaci_celt_inner_prod_neon(const oac_val16 *x, const oac_val16 *y, int N); +void oaci_dual_inner_prod_neon(const oac_val16 *x, const oac_val16 *y01, + const oac_val16 *y02, int N, oac_val32 *xy1, oac_val32 *xy2); -# if !defined(OPUS_HAVE_RTCD) && defined(OPUS_ARM_PRESUME_NEON) -# define OVERRIDE_CELT_INNER_PROD (1) -# define OVERRIDE_DUAL_INNER_PROD (1) -# define celt_inner_prod(x, y, N, arch) ((void)(arch), PRESUME_NEON(celt_inner_prod)(x, y, N)) -# define dual_inner_prod(x, y01, y02, N, xy1, xy2, arch) ((void)(arch), PRESUME_NEON(dual_inner_prod)(x, y01, y02, N, xy1, xy2)) -# endif +# if !defined(OAC_HAVE_RTCD) && defined(OAC_ARM_PRESUME_NEON) +# define OVERRIDE_CELT_INNER_PROD (1) +# define OVERRIDE_DUAL_INNER_PROD (1) +# define oaci_celt_inner_prod(x, y, N, arch) ((void)(arch), PRESUME_NEON(oaci_celt_inner_prod)(x, y, N)) +# define oaci_dual_inner_prod(x, y01, y02, N, xy1, xy2, arch) ((void)(arch), \ + PRESUME_NEON(oaci_dual_inner_prod)(x, y01, y02, N, xy1, xy2)) # endif +#endif + +#if !defined(OVERRIDE_CELT_INNER_PROD) +# if defined(OAC_HAVE_RTCD) && (defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR)) +extern oac_val32 (*const oaci_CELT_INNER_PROD_IMPL[OAC_ARCHMASK + 1])(const oac_val16 *x, const oac_val16 *y, int N); +# define OVERRIDE_CELT_INNER_PROD (1) +# define oaci_celt_inner_prod(x, y, N, arch) ((*oaci_CELT_INNER_PROD_IMPL[(arch)&OAC_ARCHMASK])(x, y, N)) +# elif defined(OAC_ARM_PRESUME_NEON_INTR) +# define OVERRIDE_CELT_INNER_PROD (1) +# define oaci_celt_inner_prod(x, y, N, arch) ((void)(arch), oaci_celt_inner_prod_neon(x, y, N)) +# endif +#endif + +#if !defined(OVERRIDE_DUAL_INNER_PROD) +# if defined(OAC_HAVE_RTCD) && (defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR)) +extern void (*const DUAL_INNER_PROD_IMPL[OAC_ARCHMASK + 1])(const oac_val16 *x, + const oac_val16 *y01, const oac_val16 *y02, int N, oac_val32 *xy1, oac_val32 *xy2); +# define OVERRIDE_DUAL_INNER_PROD (1) +# define oaci_dual_inner_prod(x, y01, y02, N, xy1, xy2, \ + arch) ((*DUAL_INNER_PROD_IMPL[(arch)&OAC_ARCHMASK])(x, y01, y02, N, xy1, xy2)) +# elif defined(OAC_ARM_PRESUME_NEON_INTR) +# define OVERRIDE_DUAL_INNER_PROD (1) +# define oaci_dual_inner_prod(x, y01, y02, N, xy1, xy2, arch) ((void)(arch), oaci_dual_inner_prod_neon(x, y01, y02, N, xy1, xy2)) +# endif +#endif -# if !defined(OVERRIDE_CELT_INNER_PROD) -# if defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) -extern opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, const opus_val16 *y, int N); -# define OVERRIDE_CELT_INNER_PROD (1) -# define celt_inner_prod(x, y, N, arch) ((*CELT_INNER_PROD_IMPL[(arch)&OPUS_ARCHMASK])(x, y, N)) -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) -# define OVERRIDE_CELT_INNER_PROD (1) -# define celt_inner_prod(x, y, N, arch) ((void)(arch), celt_inner_prod_neon(x, y, N)) -# endif +#if defined(FIXED_POINT) + +# if defined(OAC_ARM_MAY_HAVE_NEON) +oac_val32 oaci_celt_pitch_xcorr_neon(const oac_val16 *_x, const oac_val16 *_y, + oac_val32 *xcorr, int len, int max_pitch, int arch); +# endif + +# if defined(OAC_ARM_MAY_HAVE_MEDIA) +# define oaci_celt_pitch_xcorr_media MAY_HAVE_EDSP(oaci_celt_pitch_xcorr) # endif -# if !defined(OVERRIDE_DUAL_INNER_PROD) -# if defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) -extern void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *x, - const opus_val16 *y01, const opus_val16 *y02, int N, opus_val32 *xy1, opus_val32 *xy2); -# define OVERRIDE_DUAL_INNER_PROD (1) -# define dual_inner_prod(x, y01, y02, N, xy1, xy2, arch) ((*DUAL_INNER_PROD_IMPL[(arch)&OPUS_ARCHMASK])(x, y01, y02, N, xy1, xy2)) -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) -# define OVERRIDE_DUAL_INNER_PROD (1) -# define dual_inner_prod(x, y01, y02, N, xy1, xy2, arch) ((void)(arch), dual_inner_prod_neon(x, y01, y02, N, xy1, xy2)) -# endif +# if defined(OAC_ARM_MAY_HAVE_EDSP) +oac_val32 oaci_celt_pitch_xcorr_edsp(const oac_val16 *_x, const oac_val16 *_y, + oac_val32 *xcorr, int len, int max_pitch, int arch); # endif -# if defined(FIXED_POINT) - -# if defined(OPUS_ARM_MAY_HAVE_NEON) -opus_val32 celt_pitch_xcorr_neon(const opus_val16 *_x, const opus_val16 *_y, - opus_val32 *xcorr, int len, int max_pitch, int arch); -# endif - -# if defined(OPUS_ARM_MAY_HAVE_MEDIA) -# define celt_pitch_xcorr_media MAY_HAVE_EDSP(celt_pitch_xcorr) -# endif - -# if defined(OPUS_ARM_MAY_HAVE_EDSP) -opus_val32 celt_pitch_xcorr_edsp(const opus_val16 *_x, const opus_val16 *_y, - opus_val32 *xcorr, int len, int max_pitch, int arch); -# endif - -# if defined(OPUS_HAVE_RTCD) && \ - ((defined(OPUS_ARM_MAY_HAVE_NEON) && !defined(OPUS_ARM_PRESUME_NEON)) || \ - (defined(OPUS_ARM_MAY_HAVE_MEDIA) && !defined(OPUS_ARM_PRESUME_MEDIA)) || \ - (defined(OPUS_ARM_MAY_HAVE_EDSP) && !defined(OPUS_ARM_PRESUME_EDSP))) -extern opus_val32 -(*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, - const opus_val16 *, opus_val32 *, int, int, int); -# define OVERRIDE_PITCH_XCORR (1) -# define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \ - ((*CELT_PITCH_XCORR_IMPL[(arch)&OPUS_ARCHMASK])(_x, _y, \ - xcorr, len, max_pitch, arch)) - -# elif defined(OPUS_ARM_PRESUME_EDSP) || \ - defined(OPUS_ARM_PRESUME_MEDIA) || \ - defined(OPUS_ARM_PRESUME_NEON) -# define OVERRIDE_PITCH_XCORR (1) -# define celt_pitch_xcorr (PRESUME_NEON(celt_pitch_xcorr)) - -# endif - -# if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -void xcorr_kernel_neon_fixed( - const opus_val16 *x, - const opus_val16 *y, - opus_val32 sum[4], - int len); -# endif - -# if defined(OPUS_HAVE_RTCD) && \ - (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) - -extern void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y, - opus_val32 sum[4], - int len); - -# define OVERRIDE_XCORR_KERNEL (1) -# define xcorr_kernel(x, y, sum, len, arch) \ - ((*XCORR_KERNEL_IMPL[(arch) & OPUS_ARCHMASK])(x, y, sum, len)) - -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) -# define OVERRIDE_XCORR_KERNEL (1) -# define xcorr_kernel(x, y, sum, len, arch) \ - ((void)arch, xcorr_kernel_neon_fixed(x, y, sum, len)) - -# endif +# if defined(OAC_HAVE_RTCD) && \ + ((defined(OAC_ARM_MAY_HAVE_NEON) && !defined(OAC_ARM_PRESUME_NEON)) || \ + (defined(OAC_ARM_MAY_HAVE_MEDIA) && !defined(OAC_ARM_PRESUME_MEDIA)) || \ + (defined(OAC_ARM_MAY_HAVE_EDSP) && !defined(OAC_ARM_PRESUME_EDSP))) +extern oac_val32 +(*const CELT_PITCH_XCORR_IMPL[OAC_ARCHMASK + 1])(const oac_val16 *, + const oac_val16 *, oac_val32 *, int, int, int); +# define OVERRIDE_PITCH_XCORR (1) +# define oaci_celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \ + ((*CELT_PITCH_XCORR_IMPL[(arch)&OAC_ARCHMASK])(_x, _y, \ + xcorr, len, max_pitch, arch)) + +# elif defined(OAC_ARM_PRESUME_EDSP) || \ + defined(OAC_ARM_PRESUME_MEDIA) || \ + defined(OAC_ARM_PRESUME_NEON) +# define OVERRIDE_PITCH_XCORR (1) +# define oaci_celt_pitch_xcorr (PRESUME_NEON(oaci_celt_pitch_xcorr)) + +# endif + +# if defined(OAC_ARM_MAY_HAVE_NEON_INTR) +void oaci_xcorr_kernel_neon_fixed( + const oac_val16 *x, + const oac_val16 *y, + oac_val32 sum[4], + int len); +# endif + +# if defined(OAC_HAVE_RTCD) && \ + (defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR)) + +extern void (*const oaci_XCORR_KERNEL_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y, + oac_val32 sum[4], + int len); + +# define OVERRIDE_XCORR_KERNEL (1) +# define oaci_xcorr_kernel(x, y, sum, len, arch) \ + ((*oaci_XCORR_KERNEL_IMPL[(arch)&OAC_ARCHMASK])(x, y, sum, len)) + +# elif defined(OAC_ARM_PRESUME_NEON_INTR) +# define OVERRIDE_XCORR_KERNEL (1) +# define oaci_xcorr_kernel(x, y, sum, len, arch) \ + ((void)arch, oaci_xcorr_kernel_neon_fixed(x, y, sum, len)) + +# endif #else /* Start !FIXED_POINT */ /* Float case */ -#if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -void celt_pitch_xcorr_float_neon(const opus_val16 *_x, const opus_val16 *_y, - opus_val32 *xcorr, int len, int max_pitch, int arch); -#endif +# if defined(OAC_ARM_MAY_HAVE_NEON_INTR) +void oaci_celt_pitch_xcorr_float_neon(const oac_val16 *_x, const oac_val16 *_y, + oac_val32 *xcorr, int len, int max_pitch, int arch); +# endif -# if defined(OPUS_HAVE_RTCD) && \ - (defined(OPUS_ARM_MAY_HAVE_NEON_INTR) && !defined(OPUS_ARM_PRESUME_NEON_INTR)) +# if defined(OAC_HAVE_RTCD) && \ + (defined(OAC_ARM_MAY_HAVE_NEON_INTR) && !defined(OAC_ARM_PRESUME_NEON_INTR)) extern void -(*const CELT_PITCH_XCORR_IMPL[OPUS_ARCHMASK+1])(const opus_val16 *, - const opus_val16 *, opus_val32 *, int, int, int); +(*const CELT_PITCH_XCORR_IMPL[OAC_ARCHMASK + 1])(const oac_val16 *, + const oac_val16 *, oac_val32 *, int, int, int); # define OVERRIDE_PITCH_XCORR (1) -# define celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \ - ((*CELT_PITCH_XCORR_IMPL[(arch)&OPUS_ARCHMASK])(_x, _y, \ - xcorr, len, max_pitch, arch)) +# define oaci_celt_pitch_xcorr(_x, _y, xcorr, len, max_pitch, arch) \ + ((*CELT_PITCH_XCORR_IMPL[(arch)&OAC_ARCHMASK])(_x, _y, \ + xcorr, len, max_pitch, arch)) -# elif defined(OPUS_ARM_PRESUME_NEON_INTR) +# elif defined(OAC_ARM_PRESUME_NEON_INTR) -# define OVERRIDE_PITCH_XCORR (1) -# define celt_pitch_xcorr celt_pitch_xcorr_float_neon +# define OVERRIDE_PITCH_XCORR (1) +# define oaci_celt_pitch_xcorr oaci_celt_pitch_xcorr_float_neon -# endif +# endif #endif /* end !FIXED_POINT */ diff --git a/celt/arm/pitch_neon_intr.c b/celt/arm/pitch_neon_intr.c index 43885f528..c55f32e97 100644 --- a/celt/arm/pitch_neon_intr.c +++ b/celt/arm/pitch_neon_intr.c @@ -1,32 +1,32 @@ /*********************************************************************** -Copyright (c) 2017 Google Inc. -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. -- Neither the name of Internet Society, IETF or IETF Trust, nor the -names of specific contributors, may be used to endorse or promote -products derived from this software without specific prior written -permission. -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. + Copyright (c) 2017 Google Inc. + 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. + - Neither the name of Internet Society, IETF or IETF Trust, nor the + names of specific contributors, may be used to endorse or promote + products derived from this software without specific prior written + permission. + 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" +# include "config.h" #endif #include @@ -34,10 +34,9 @@ POSSIBILITY OF SUCH DAMAGE. #ifdef FIXED_POINT -opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N) -{ +oac_val32 oaci_celt_inner_prod_neon(const oac_val16 *x, const oac_val16 *y, int N) { int i; - opus_val32 xy; + oac_val32 xy; int16x8_t x_s16x8, y_s16x8; int32x4_t xy_s32x4 = vdupq_n_s32(0); int64x2_t xy_s64x2; @@ -65,18 +64,17 @@ opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N) xy = MAC16_16(xy, x[i], y[i]); } -#ifdef OPUS_CHECK_ASM - celt_assert(celt_inner_prod_c(x, y, N) == xy); -#endif +# ifdef OAC_CHECK_ASM + celt_assert(oaci_celt_inner_prod_c(x, y, N) == xy); +# endif return xy; } -void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2) -{ +void oaci_dual_inner_prod_neon(const oac_val16 *x, const oac_val16 *y01, const oac_val16 *y02, + int N, oac_val32 *xy1, oac_val32 *xy2) { int i; - opus_val32 xy01, xy02; + oac_val32 xy01, xy02; int16x8_t x_s16x8, y01_s16x8, y02_s16x8; int32x4_t xy01_s32x4 = vdupq_n_s32(0); int32x4_t xy02_s32x4 = vdupq_n_s32(0); @@ -116,76 +114,73 @@ void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, const opus *xy1 = xy01; *xy2 = xy02; -#ifdef OPUS_CHECK_ASM +# ifdef OAC_CHECK_ASM { - opus_val32 xy1_c, xy2_c; - dual_inner_prod_c(x, y01, y02, N, &xy1_c, &xy2_c); + oac_val32 xy1_c, xy2_c; + oaci_dual_inner_prod_c(x, y01, y02, N, &xy1_c, &xy2_c); celt_assert(xy1_c == *xy1); celt_assert(xy2_c == *xy2); } -#endif +# endif } #else /* !FIXED_POINT */ /* ========================================================================== */ -#ifdef __ARM_FEATURE_FMA +# ifdef __ARM_FEATURE_FMA /* If we can, force the compiler to use an FMA instruction rather than break vmlaq_f32() into fmul/fadd. */ -#define vmlaq_f32(a,b,c) vfmaq_f32(a,b,c) -#endif +# define vmlaq_f32(a, b, c) vfmaq_f32(a, b, c) +# endif -#ifdef OPUS_CHECK_ASM +# ifdef OAC_CHECK_ASM /* This part of code simulates floating-point NEON operations. */ -/* celt_inner_prod_neon_float_c_simulation() simulates the floating-point */ -/* operations of celt_inner_prod_neon(), and both functions should have bit */ +/* oaci_celt_inner_prod_neon_float_c_simulation() simulates the floating-point */ +/* operations of oaci_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, 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; +static oac_val32 oaci_celt_inner_prod_neon_float_c_simulation(const oac_val16 *x, const oac_val16 *y, float *err, int N) { + int i; + *err = 0; + oac_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; } -/* dual_inner_prod_neon_float_c_simulation() simulates the floating-point */ -/* operations of dual_inner_prod_neon(), and both functions should have bit */ +/* oaci_dual_inner_prod_neon_float_c_simulation() simulates the floating-point */ +/* operations of oaci_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, float *err) -{ - *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); +static void oaci_dual_inner_prod_neon_float_c_simulation(const oac_val16 *x, const oac_val16 *y01, const oac_val16 *y02, + int N, oac_val32 *xy1, oac_val32 *xy2, float *err) { + *xy1 = oaci_celt_inner_prod_neon_float_c_simulation(x, y01, &err[0], N); + *xy2 = oaci_celt_inner_prod_neon_float_c_simulation(x, y02, &err[1], N); } -#endif /* OPUS_CHECK_ASM */ +# endif /* OAC_CHECK_ASM */ /* ========================================================================== */ -opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N) -{ +oac_val32 oaci_celt_inner_prod_neon(const oac_val16 *x, const oac_val16 *y, int N) { int i; - opus_val32 xy; + oac_val32 xy; float32x4_t xy_f32x4 = vdupq_n_f32(0); float32x2_t xy_f32x2; @@ -214,23 +209,22 @@ opus_val32 celt_inner_prod_neon(const opus_val16 *x, const opus_val16 *y, int N) xy = MAC16_16(xy, x[i], y[i]); } -#ifdef OPUS_CHECK_ASM +# ifdef OAC_CHECK_ASM { float err, res; - res = celt_inner_prod_neon_float_c_simulation(x, y, &err, N); + res = oaci_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 +# endif return xy; } -void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2) -{ +void oaci_dual_inner_prod_neon(const oac_val16 *x, const oac_val16 *y01, const oac_val16 *y02, + int N, oac_val32 *xy1, oac_val32 *xy2) { int i; - opus_val32 xy01, xy02; + oac_val32 xy01, xy02; float32x4_t xy01_f32x4 = vdupq_n_f32(0); float32x4_t xy02_f32x4 = vdupq_n_f32(0); float32x2_t xy01_f32x2, xy02_f32x2; @@ -272,17 +266,17 @@ void dual_inner_prod_neon(const opus_val16 *x, const opus_val16 *y01, const opus *xy1 = xy01; *xy2 = xy02; -#ifdef OPUS_CHECK_ASM +# ifdef OAC_CHECK_ASM { - opus_val32 xy1_c, xy2_c; + oac_val32 xy1_c, xy2_c; float err[2]; - dual_inner_prod_neon_float_c_simulation(x, y01, y02, N, &xy1_c, &xy2_c, err); + oaci_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]);*/ + 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 +# endif } #endif /* FIXED_POINT */ diff --git a/celt/bands.c b/celt/bands.c index afde197ef..47cc0c864 100644 --- a/celt/bands.c +++ b/celt/bands.c @@ -25,10 +25,10 @@ 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" +# include "config.h" #endif #include @@ -43,313 +43,290 @@ #include "quant_bands.h" #include "pitch.h" -int hysteresis_decision(opus_val16 val, const opus_val16 *thresholds, const opus_val16 *hysteresis, int N, int prev) -{ - int i; - for (i=0;iprev && val < thresholds[prev]+hysteresis[prev]) - i=prev; - if (i thresholds[prev-1]-hysteresis[prev-1]) - i=prev; - return i; +int oaci_hysteresis_decision(oac_val16 val, const oac_val16 *thresholds, const oac_val16 *hysteresis, int N, int prev) { + int i; + for (i = 0; i < N; i++) { + if (val < thresholds[i]) + break; + } + if (i > prev && val < thresholds[prev] + hysteresis[prev]) + i = prev; + if (i < prev && val > thresholds[prev - 1] - hysteresis[prev - 1]) + i = prev; + return i; } -opus_uint32 celt_lcg_rand(opus_uint32 seed) -{ - return 1664525 * seed + 1013904223; +oac_uint32 oaci_celt_lcg_rand(oac_uint32 seed) { + return 1664525*seed + 1013904223; } /* This is a cos() approximation designed to be bit-exact on any platform. Bit exactness with this approximation is important because it has an impact on the bit allocation */ -opus_int16 bitexact_cos(opus_int16 x) -{ - opus_int32 tmp; - opus_int16 x2; - tmp = (4096+((opus_int32)(x)*(x)))>>13; - celt_sig_assert(tmp<=32767); - x2 = tmp; - x2 = (32767-x2) + FRAC_MUL16(x2, (-7651 + FRAC_MUL16(x2, (8277 + FRAC_MUL16(-626, x2))))); - celt_sig_assert(x2<=32766); - return 1+x2; +oac_int16 oaci_bitexact_cos(oac_int16 x) { + oac_int32 tmp; + oac_int16 x2; + tmp = (4096 + ((oac_int32)(x)*(x)))>>13; + celt_sig_assert(tmp <= 32767); + x2 = tmp; + x2 = (32767 - x2) + FRAC_MUL16(x2, (-7651 + FRAC_MUL16(x2, (8277 + FRAC_MUL16(-626, x2))))); + celt_sig_assert(x2 <= 32766); + return 1 + x2; } -int bitexact_log2tan(int isin,int icos) -{ - int lc; - int ls; - lc=EC_ILOG(icos); - ls=EC_ILOG(isin); - icos<<=15-lc; - isin<<=15-ls; - return (ls-lc)*(1<<11) - +FRAC_MUL16(isin, FRAC_MUL16(isin, -2597) + 7932) - -FRAC_MUL16(icos, FRAC_MUL16(icos, -2597) + 7932); +int oaci_bitexact_log2tan(int isin, int icos) { + int lc; + int ls; + lc = EC_ILOG(icos); + ls = EC_ILOG(isin); + icos <<= 15 - lc; + isin <<= 15 - ls; + return (ls - lc)*(1<<11) + + FRAC_MUL16(isin, FRAC_MUL16(isin, -2597) + 7932) + - FRAC_MUL16(icos, FRAC_MUL16(icos, -2597) + 7932); } #ifdef FIXED_POINT /* Compute the amplitude (sqrt energy) in each of the bands */ -void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int LM, int arch) -{ - int i, c, N; - const opus_int16 *eBands = m->eBands; - (void)arch; - N = m->shortMdctSize< 0) - { - int shift = IMAX(0, 30 - celt_ilog2(maxval+(maxval>>14)+1) - ((((m->logN[i]+7)>>BITRES)+LM+1)>>1)); - j=eBands[i]<nbEBands] = MAX32(maxval, PSHR32(celt_sqrt32(SHR32(sum,1)), shift)); - } else { - bandE[i+c*m->nbEBands] = EPSILON; - } - } - } while (++ceBands; + (void)arch; + N = m->shortMdctSize< 0) { + int shift = IMAX(0, + 30 - oaci_celt_ilog2(maxval + (maxval>>14) + 1) - ((((m->logN[i] + 7)>>BITRES) + LM + 1)>>1)); + j = eBands[i]<nbEBands] = MAX32(maxval, PSHR32(oaci_celt_sqrt32(SHR32(sum, 1)), shift)); + } else { + bandE[i + c*m->nbEBands] = EPSILON; + } + } + } while (++c < C); } /* Normalise each band such that the energy is one. */ -void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, celt_norm * OPUS_RESTRICT X, const celt_ener *bandE, int end, int C, int M) -{ - int i, c, N; - const opus_int16 *eBands = m->eBands; - N = M*m->shortMdctSize; - c=0; do { - i=0; do { - int j,shift; - opus_val32 E; - opus_val32 g; - E = bandE[i+c*m->nbEBands]; - /* For very low energies, we need this to make sure not to prevent energy rounding from - blowing up the normalized signal. */ - if (E < 10) E += EPSILON; - shift = 30-celt_zlog2(E); - E = SHL32(E, shift); - g = celt_rcp_norm32(E); - j=M*eBands[i]; do { - X[j+c*N] = PSHR32(MULT32_32_Q31(g, SHL32(freq[j+c*N], shift)), 30-NORM_SHIFT); - } while (++jeBands; + N = M*m->shortMdctSize; + c = 0; do { + i = 0; do { + int j, shift; + oac_val32 E; + oac_val32 g; + E = bandE[i + c*m->nbEBands]; + /* For very low energies, we need this to make sure not to prevent energy rounding from + blowing up the normalized signal. */ + if (E < 10) E += EPSILON; + shift = 30 - oaci_celt_zlog2(E); + E = SHL32(E, shift); + g = oaci_celt_rcp_norm32(E); + j = M*eBands[i]; do { + X[j + c*N] = PSHR32(MULT32_32_Q31(g, SHL32(freq[j + c*N], shift)), 30 - NORM_SHIFT); + } while (++j < M*eBands[i + 1]); + } while (++i < end); + } while (++c < C); } #else /* FIXED_POINT */ /* Compute the amplitude (sqrt energy) in each of the bands */ -void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *bandE, int end, int C, int LM, int arch) -{ - int i, c, N; - const opus_int16 *eBands = m->eBands; - N = m->shortMdctSize<nbEBands] = celt_sqrt(sum); - /*printf ("%f ", bandE[i+c*m->nbEBands]);*/ - } - } while (++ceBands; + N = m->shortMdctSize<nbEBands] = oaci_celt_sqrt(sum); + /*printf ("%f ", bandE[i+c*m->nbEBands]);*/ + } + } while (++c < C); + /*printf ("\n");*/ } /* Normalise each band such that the energy is one. */ -void normalise_bands(const CELTMode *m, const celt_sig * OPUS_RESTRICT freq, celt_norm * OPUS_RESTRICT X, const celt_ener *bandE, int end, int C, int M) -{ - int i, c, N; - const opus_int16 *eBands = m->eBands; - N = M*m->shortMdctSize; - c=0; do { - for (i=0;inbEBands]); - for (j=M*eBands[i];jeBands; + N = M*m->shortMdctSize; + c = 0; do { + for (i = 0; i < end; i++) { + int j; + oac_val16 g = 1.f/(1e-27f + bandE[i + c*m->nbEBands]); + for (j = M*eBands[i]; j < M*eBands[i + 1]; j++) + X[j + c*N] = freq[j + c*N]*g; + } + } while (++c < C); } #endif /* FIXED_POINT */ /* De-normalise the energy to produce the synthesis from the unit-energy bands */ -void denormalise_bands(const CELTMode *m, const celt_norm * OPUS_RESTRICT X, - celt_sig * OPUS_RESTRICT freq, const celt_glog *bandLogE, int start, - int end, int M, int downsample, int silence) -{ - int i, N; - int bound; - celt_sig * OPUS_RESTRICT f; - const celt_norm * OPUS_RESTRICT x; - const opus_int16 *eBands = m->eBands; - N = M*m->shortMdctSize; - bound = M*eBands[end]; - if (downsample!=1) - bound = IMIN(bound, N/downsample); - if (silence) - { - bound = 0; - start = end = 0; - } - f = freq; - x = X+M*eBands[start]; - if (start != 0) - { - for (i=0;ieBands; + N = M*m->shortMdctSize; + bound = M*eBands[end]; + if (downsample != 1) + bound = IMIN(bound, N/downsample); + if (silence) { + bound = 0; + start = end = 0; + } + f = freq; + x = X + M*eBands[start]; + if (start != 0) { + for (i = 0; i < M*eBands[start]; i++) + *f++ = 0; + } else { + f += M*eBands[start]; + } + for (i = start; i < end; i++) { + int j, band_end; + oac_val32 g; + celt_glog lg; #ifdef FIXED_POINT - int shift; + int shift; #endif - j=M*eBands[i]; - band_end = M*eBands[i+1]; - lg = ADD32(bandLogE[i], SHL32((opus_val32)eMeans[i],DB_SHIFT-4)); + j = M*eBands[i]; + band_end = M*eBands[i + 1]; + lg = ADD32(bandLogE[i], SHL32((oac_val32)oaci_eMeans[i], DB_SHIFT - 4)); #ifndef FIXED_POINT - g = celt_exp2_db(MIN32(32.f, lg)); + g = celt_exp2_db(MIN32(32.f, lg)); #else - /* Handle the integer part of the log energy */ - shift = 17-(lg>>DB_SHIFT); - if (shift>=31) - { - shift=0; - g=0; - } else { - /* Handle the fractional part. */ - g = SHL32(celt_exp2_db_frac((lg&((1<>DB_SHIFT); + if (shift >= 31) { + shift = 0; + g = 0; + } else { + /* Handle the fractional part. */ + g = SHL32(oaci_celt_exp2_db_frac((lg&((1<eBands[i+1]-m->eBands[i]; - /* depth in 1/8 bits */ - celt_sig_assert(pulses[i]>=0); - depth = celt_udiv(1+pulses[i], (m->eBands[i+1]-m->eBands[i]))>>LM; + N0 = m->eBands[i + 1] - m->eBands[i]; + /* depth in 1/8 bits */ + celt_sig_assert(pulses[i] >= 0); + depth = oaci_celt_udiv(1 + pulses[i], (m->eBands[i + 1] - m->eBands[i]))>>LM; #ifdef FIXED_POINT - thresh32 = SHR32(celt_exp2(-SHL16(depth, 10-BITRES)),1); - thresh = MULT16_32_Q15(QCONST16(0.5f, 15), MIN32(32767,thresh32)); - { - opus_val32 t; - t = N0<>1; - t = SHL32(t, (7-shift)<<1); - sqrt_1 = celt_rsqrt_norm(t); - } + thresh32 = SHR32(oaci_celt_exp2(-SHL16(depth, 10 - BITRES)), 1); + thresh = MULT16_32_Q15(QCONST16(0.5f, 15), MIN32(32767, thresh32)); + { + oac_val32 t; + t = N0<>1; + t = SHL32(t, (7 - shift)<<1); + sqrt_1 = oaci_celt_rsqrt_norm(t); + } #else - thresh = .5f*celt_exp2(-.125f*depth); - sqrt_1 = celt_rsqrt(N0<nbEBands+i]; - prev2 = prev2logE[c*m->nbEBands+i]; - if (!encode && C==1) - { - prev1 = MAXG(prev1,prev1logE[m->nbEBands+i]); - prev2 = MAXG(prev2,prev2logE[m->nbEBands+i]); - } - Ediff = logE[c*m->nbEBands+i]-MING(prev1,prev2); - Ediff = MAX32(0, Ediff); + c = 0; do { + celt_norm *X; + celt_glog prev1; + celt_glog prev2; + oac_val32 Ediff; + celt_norm r; + int renormalize = 0; + prev1 = prev1logE[c*m->nbEBands + i]; + prev2 = prev2logE[c*m->nbEBands + i]; + if (!encode && C == 1) { + prev1 = MAXG(prev1, prev1logE[m->nbEBands + i]); + prev2 = MAXG(prev2, prev2logE[m->nbEBands + i]); + } + Ediff = logE[c*m->nbEBands + i] - MING(prev1, prev2); + Ediff = MAX32(0, Ediff); #ifdef FIXED_POINT - if (Ediff < GCONST(16.f)) - { - opus_val32 r32 = SHR32(celt_exp2_db(-Ediff),1); - r = 2*MIN16(16383,r32); - } else { - r = 0; - } - if (LM==3) - r = MULT16_16_Q14(23170, MIN32(23169, r)); - r = SHR16(MIN16(thresh, r),1); - r = VSHR32(MULT16_16_Q15(sqrt_1, r),shift+14-NORM_SHIFT); + if (Ediff < GCONST(16.f)) { + oac_val32 r32 = SHR32(celt_exp2_db(-Ediff), 1); + r = 2*MIN16(16383, r32); + } else { + r = 0; + } + if (LM == 3) + r = MULT16_16_Q14(23170, MIN32(23169, r)); + r = SHR16(MIN16(thresh, r), 1); + r = VSHR32(MULT16_16_Q15(sqrt_1, r), shift + 14 - NORM_SHIFT); #else - /* r needs to be multiplied by 2 or 2*sqrt(2) depending on LM because - short blocks don't have the same energy as long */ - r = 2.f*celt_exp2_db(-Ediff); - if (LM==3) - r *= 1.41421356f; - r = MIN16(thresh, r); - r = r*sqrt_1; + /* r needs to be multiplied by 2 or 2*sqrt(2) depending on LM because + short blocks don't have the same energy as long */ + r = 2.f*celt_exp2_db(-Ediff); + if (LM == 3) + r *= 1.41421356f; + r = MIN16(thresh, r); + r = r*sqrt_1; #endif - X = X_+c*size+(m->eBands[i]<eBands[i]<nbEBands]))-13; + int shift = oaci_celt_zlog2(MAX32(bandE[i], bandE[i + m->nbEBands])) - 13; #endif - left = VSHR32(bandE[i],shift); - right = VSHR32(bandE[i+m->nbEBands],shift); - norm = EPSILON + celt_sqrt(EPSILON+MULT16_16(left,left)+MULT16_16(right,right)); + left = VSHR32(bandE[i], shift); + right = VSHR32(bandE[i + m->nbEBands], shift); + norm = EPSILON + oaci_celt_sqrt(EPSILON + MULT16_16(left, left) + MULT16_16(right, right)); #ifdef FIXED_POINT - left = MIN32(left, norm-1); - right = MIN32(right, norm-1); + left = MIN32(left, norm - 1); + right = MIN32(right, norm - 1); #endif - a1 = DIV32_16(SHL32(EXTEND32(left),15),norm); - a2 = DIV32_16(SHL32(EXTEND32(right),15),norm); - for (j=0;j>1; - kr = celt_ilog2(Er)>>1; + kl = oaci_celt_ilog2(El)>>1; + kr = oaci_celt_ilog2(Er)>>1; #endif - t = VSHR32(El, (kl<<1)-29); - lgain = celt_rsqrt_norm32(t); - t = VSHR32(Er, (kr<<1)-29); - rgain = celt_rsqrt_norm32(t); + t = VSHR32(El, (kl<<1) - 29); + lgain = oaci_celt_rsqrt_norm32(t); + t = VSHR32(Er, (kr<<1) - 29); + rgain = oaci_celt_rsqrt_norm32(t); #ifdef FIXED_POINT - if (kl < 7) - kl = 7; - if (kr < 7) - kr = 7; + if (kl < 7) + kl = 7; + if (kr < 7) + kr = 7; #endif - for (j=0;jeBands; - int decision; - int hf_sum=0; - - celt_assert(end>0); - - N0 = M*m->shortMdctSize; - - if (M*(eBands[end]-eBands[end-1]) <= 8) - return SPREAD_NONE; - c=0; do { - for (i=0;im->nbEBands-4) - hf_sum += celt_udiv(32*(tcount[1]+tcount[0]), N); - tmp = (2*tcount[2] >= N) + (2*tcount[1] >= N) + (2*tcount[0] >= N); - sum += tmp*spread_weight[i]; - nbBands+=spread_weight[i]; - } - } while (++cnbEBands+end)); - *hf_average = (*hf_average+hf_sum)>>1; - hf_sum = *hf_average; - if (*tapset_decision==2) - hf_sum += 4; - else if (*tapset_decision==0) - hf_sum -= 4; - if (hf_sum > 22) - *tapset_decision=2; - else if (hf_sum > 18) - *tapset_decision=1; - else - *tapset_decision=0; - } - /*printf("%d %d %d\n", hf_sum, *hf_average, *tapset_decision);*/ - celt_assert(nbBands>0); /* end has to be non-zero */ - celt_assert(sum>=0); - sum = celt_udiv((opus_int32)sum<<8, nbBands); - /* Recursive averaging */ - sum = (sum+*average)>>1; - *average = sum; - /* Hysteresis */ - sum = (3*sum + (((3-last_decision)<<7) + 64) + 2)>>2; - if (sum < 80) - { - decision = SPREAD_AGGRESSIVE; - } else if (sum < 256) - { - decision = SPREAD_NORMAL; - } else if (sum < 384) - { - decision = SPREAD_LIGHT; - } else { - decision = SPREAD_NONE; - } +int oaci_spreading_decision(const CELTMode *m, const celt_norm *X, int *average, + int last_decision, int *hf_average, int *tapset_decision, int update_hf, + int end, int C, int M, const int *spread_weight) { + int i, c, N0; + int sum = 0, nbBands = 0; + const oac_int16 * OAC_RESTRICT eBands = m->eBands; + int decision; + int hf_sum = 0; + + celt_assert(end > 0); + + N0 = M*m->shortMdctSize; + + if (M*(eBands[end] - eBands[end - 1]) <= 8) + return SPREAD_NONE; + c = 0; do { + for (i = 0; i < end; i++) { + int j, N, tmp = 0; + int tcount[3] = {0, 0, 0}; + const celt_norm * OAC_RESTRICT x = X + M*eBands[i] + c*N0; + N = M*(eBands[i + 1] - eBands[i]); + if (N <= 8) + continue; + /* Compute rough CDF of |x[j]| */ + for (j = 0; j < N; j++) { + oac_val32 x2N; /* Q13 */ + + x2N = MULT16_16(MULT16_16_Q15(SHR32(x[j], NORM_SHIFT - 14), SHR32(x[j], NORM_SHIFT - 14)), N); + if (x2N < QCONST16(0.25f, 13)) + tcount[0]++; + if (x2N < QCONST16(0.0625f, 13)) + tcount[1]++; + if (x2N < QCONST16(0.015625f, 13)) + tcount[2]++; + } + + /* Only include four last bands (8 kHz and up) */ + if (i > m->nbEBands - 4) + hf_sum += oaci_celt_udiv(32*(tcount[1] + tcount[0]), N); + tmp = (2*tcount[2] >= N) + (2*tcount[1] >= N) + (2*tcount[0] >= N); + sum += tmp*spread_weight[i]; + nbBands += spread_weight[i]; + } + } while (++c < C); + + if (update_hf) { + if (hf_sum) + hf_sum = oaci_celt_udiv(hf_sum, C*(4 - m->nbEBands + end)); + *hf_average = (*hf_average + hf_sum)>>1; + hf_sum = *hf_average; + if (*tapset_decision == 2) + hf_sum += 4; + else if (*tapset_decision == 0) + hf_sum -= 4; + if (hf_sum > 22) + *tapset_decision = 2; + else if (hf_sum > 18) + *tapset_decision = 1; + else + *tapset_decision = 0; + } + /*printf("%d %d %d\n", hf_sum, *hf_average, *tapset_decision);*/ + celt_assert(nbBands > 0); /* end has to be non-zero */ + celt_assert(sum >= 0); + sum = oaci_celt_udiv((oac_int32)sum<<8, nbBands); + /* Recursive averaging */ + sum = (sum + *average)>>1; + *average = sum; + /* Hysteresis */ + sum = (3*sum + (((3 - last_decision)<<7) + 64) + 2)>>2; + if (sum < 80) { + decision = SPREAD_AGGRESSIVE; + } else if (sum < 256) { + decision = SPREAD_NORMAL; + } else if (sum < 384) { + decision = SPREAD_LIGHT; + } else { + decision = SPREAD_NONE; + } #ifdef FUZZING - decision = rand()&0x3; - *tapset_decision=rand()%3; + decision = rand()&0x3; + *tapset_decision = rand()%3; #endif - return decision; + return decision; } /* Indexing table for converting from natural Hadamard to ordery Hadamard @@ -565,1358 +528,1104 @@ int spreading_decision(const CELTMode *m, const celt_norm *X, int *average, an inversion of the order because we want the DC at the end rather than the beginning. The lines are for N=2, 4, 8, 16 */ static const int ordery_table[] = { - 1, 0, - 3, 0, 2, 1, - 7, 0, 4, 3, 6, 1, 5, 2, - 15, 0, 8, 7, 12, 3, 11, 4, 14, 1, 9, 6, 13, 2, 10, 5, + 1, 0, + 3, 0, 2, 1, + 7, 0, 4, 3, 6, 1, 5, 2, + 15, 0, 8, 7, 12, 3, 11, 4, 14, 1, 9, 6, 13, 2, 10, 5, }; -static void deinterleave_hadamard(celt_norm *X, int N0, int stride, int hadamard) -{ - int i,j; - VARDECL(celt_norm, tmp); - int N; - SAVE_STACK; - N = N0*stride; - ALLOC(tmp, N, celt_norm); - celt_assert(stride>0); - if (hadamard) - { - const int *ordery = ordery_table+stride-2; - for (i=0;i 0); + if (hadamard) { + const int *ordery = ordery_table + stride - 2; + for (i = 0; i < stride; i++) { + for (j = 0; j < N0; j++) + tmp[ordery[i]*N0 + j] = X[j*stride + i]; + } + } else { + for (i = 0; i < stride; i++) + for (j = 0; j < N0; j++) + tmp[i*N0 + j] = X[j*stride + i]; + } + OAC_COPY(X, tmp, N); + RESTORE_STACK; } -static void interleave_hadamard(celt_norm *X, int N0, int stride, int hadamard) -{ - int i,j; - VARDECL(celt_norm, tmp); - int N; - SAVE_STACK; - N = N0*stride; - ALLOC(tmp, N, celt_norm); - if (hadamard) - { - const int *ordery = ordery_table+stride-2; - for (i=0;i>= 1; - for (i=0;i>= 1; + for (i = 0; i < stride; i++) + for (j = 0; j < N0; j++) { + oac_val32 tmp1, tmp2; + tmp1 = MULT32_32_Q31(QCONST32(.70710678f, 31), X[stride*2*j + i]); + tmp2 = MULT32_32_Q31(QCONST32(.70710678f, 31), X[stride*(2*j + 1) + i]); + X[stride*2*j + i] = ADD32(tmp1, tmp2); + X[stride*(2*j + 1) + i] = SUB32(tmp1, tmp2); + } } -static int compute_qn(int N, int b, int offset, int pulse_cap, int stereo) -{ - static const opus_int16 exp2_table8[8] = - {16384, 17866, 19483, 21247, 23170, 25267, 27554, 30048}; - int qn, qb; - int N2 = 2*N-1; - if (stereo && N==2) - N2--; - /* The upper limit ensures that in a stereo split with itheta==16384, we'll - always have enough bits left over to code at least one pulse in the - side; otherwise it would collapse, since it doesn't get folded. */ - qb = celt_sudiv(b+N2*offset, N2); - qb = IMIN(b-pulse_cap-(4<>1)) { - qn = 1; - } else { - qn = exp2_table8[qb&0x7]>>(14-(qb>>BITRES)); - qn = (qn+1)>>1<<1; - } - celt_assert(qn <= 256); - return qn; +static int oaci_compute_qn(int N, int b, int offset, int pulse_cap, int stereo) { + static const oac_int16 exp2_table8[8] = + {16384, 17866, 19483, 21247, 23170, 25267, 27554, 30048}; + int qn, qb; + int N2 = 2*N - 1; + if (stereo && N == 2) + N2--; + /* The upper limit ensures that in a stereo split with itheta==16384, we'll + always have enough bits left over to code at least one pulse in the + side; otherwise it would collapse, since it doesn't get folded. */ + qb = oaci_celt_sudiv(b + N2*offset, N2); + qb = IMIN(b - pulse_cap - (4<>1)) { + qn = 1; + } else { + qn = exp2_table8[qb&0x7]>>(14 - (qb>>BITRES)); + qn = (qn + 1)>>1<<1; + } + celt_assert(qn <= 256); + return qn; } struct band_ctx { - int encode; - int resynth; - const CELTMode *m; - int i; - int intensity; - int spread; - int tf_change; - ec_ctx *ec; - opus_int32 remaining_bits; - const celt_ener *bandE; - opus_uint32 seed; - int arch; - int theta_round; - int disable_inv; - int avoid_split_noise; -#ifdef ENABLE_QEXT - ec_ctx *ext_ec; - int extra_bits; - opus_int32 ext_total_bits; - int extra_bands; -#endif + int encode; + int resynth; + const CELTMode *m; + int i; + int intensity; + int spread; + int tf_change; + ec_ctx *ec; + oac_int32 total_bits; + const celt_ener *bandE; + oac_uint32 seed; + int arch; + int theta_round; + int disable_inv; + int avoid_split_noise; }; struct split_ctx { - int inv; - int imid; - int iside; - int delta; - int itheta; -#ifdef ENABLE_QEXT - int itheta_q30; -#endif - int qalloc; + int inv; + int imid; + int iside; + int delta; + int itheta; + int itheta_q30; }; -static void compute_theta(struct band_ctx *ctx, struct split_ctx *sctx, - celt_norm *X, celt_norm *Y, int N, int *b, int B, int B0, - int LM, - int stereo, int *fill ARG_QEXT(int *ext_b)) -{ - int qn; - int itheta=0; - int itheta_q30=0; - int delta; - int imid, iside; - int qalloc; - int pulse_cap; - int offset; - opus_int32 tell; - int inv=0; - int encode; - const CELTMode *m; - int i; - int intensity; - ec_ctx *ec; - const celt_ener *bandE; - - encode = ctx->encode; - m = ctx->m; - i = ctx->i; - intensity = ctx->intensity; - ec = ctx->ec; - bandE = ctx->bandE; - - /* Decide on the resolution to give to the split parameter theta */ - pulse_cap = m->logN[i]+LM*(1<>1) - (stereo&&N==2 ? QTHETA_OFFSET_TWOPHASE : QTHETA_OFFSET); - qn = compute_qn(N, *b, offset, pulse_cap, stereo); - if (stereo && i>=intensity) - qn = 1; - if (encode) - { - /* theta is the atan() of the ratio between the (normalized) - side and mid. With just that parameter, we can re-scale both - mid and side because we know that 1) they have unit norm and - 2) they are orthogonal. */ - itheta_q30 = stereo_itheta(X, Y, stereo, N, ctx->arch); - itheta = itheta_q30>>16; - } - tell = ec_tell_frac(ec); - if (qn!=1) - { - if (encode) - { - if (!stereo || ctx->theta_round == 0) - { - itheta = (itheta*(opus_int32)qn+8192)>>14; - if (!stereo && ctx->avoid_split_noise && itheta > 0 && itheta < qn) - { - /* Check if the selected value of theta will cause the bit allocation - to inject noise on one side. If so, make sure the energy of that side - is zero. */ - int unquantized = celt_udiv((opus_int32)itheta*16384, qn); - imid = bitexact_cos((opus_int16)unquantized); - iside = bitexact_cos((opus_int16)(16384-unquantized)); - delta = FRAC_MUL16((N-1)<<7,bitexact_log2tan(iside,imid)); - if (delta > *b) - itheta = qn; - else if (delta < -*b) - itheta = 0; +static void oaci_compute_theta(struct band_ctx *ctx, struct split_ctx *sctx, + celt_norm *X, celt_norm *Y, int N, int *b, int B, int B0, + int LM, + int stereo, int *fill) { + int qn; + int itheta = 0; + int itheta_q30 = 0; + int delta; + int imid, iside; + int qalloc; + int pulse_cap; + int offset; + oac_int32 tell; + int inv = 0; + int encode; + const CELTMode *m; + int i; + int intensity; + ec_ctx *ec; + const celt_ener *bandE; + + encode = ctx->encode; + m = ctx->m; + i = ctx->i; + intensity = ctx->intensity; + ec = ctx->ec; + bandE = ctx->bandE; + + /* Decide on the resolution to give to the split parameter theta */ + pulse_cap = m->logN[i] + LM*(1<>1) - (stereo && N == 2 ? QTHETA_OFFSET_TWOPHASE : QTHETA_OFFSET); + qn = oaci_compute_qn(N, *b, offset, pulse_cap, stereo); + if (stereo && i >= intensity) + qn = 1; + if (encode) { + /* theta is the atan() of the ratio between the (normalized) + side and mid. With just that parameter, we can re-scale both + mid and side because we know that 1) they have unit norm and + 2) they are orthogonal. */ + itheta_q30 = oaci_stereo_itheta(X, Y, stereo, N, ctx->arch); + itheta = itheta_q30>>16; + } + tell = oaci_ec_tell_frac(ec); + if (qn != 1) { + if (encode) { + if (!stereo || ctx->theta_round == 0) { + itheta = (itheta*(oac_int32)qn + 8192)>>14; + if (!stereo && ctx->avoid_split_noise && itheta > 0 && itheta < qn) { + /* Check if the selected value of theta will cause the bit allocation + to inject noise on one side. If so, make sure the energy of that side + is zero. */ + int unquantized = oaci_celt_udiv((oac_int32)itheta*16384, qn); + imid = oaci_bitexact_cos((oac_int16)unquantized); + iside = oaci_bitexact_cos((oac_int16)(16384 - unquantized)); + delta = FRAC_MUL16((N - 1)<<7, oaci_bitexact_log2tan(iside, imid)); + if (delta > *b) + itheta = qn; + else if (delta < -*b) + itheta = 0; + } + } else { + int down; + /* Bias quantization towards itheta=0 and itheta=16384. */ + int bias = itheta > 8192 ? 32767/qn : -32767/qn; + down = IMIN(qn - 1, IMAX(0, (itheta*(oac_int32)qn + bias)>>14)); + if (ctx->theta_round < 0) + itheta = down; + else + itheta = down + 1; } - } else { - int down; - /* Bias quantization towards itheta=0 and itheta=16384. */ - int bias = itheta > 8192 ? 32767/qn : -32767/qn; - down = IMIN(qn-1, IMAX(0, (itheta*(opus_int32)qn + bias)>>14)); - if (ctx->theta_round < 0) - itheta = down; - else - itheta = down+1; - } - } - /* Entropy coding of the angle. We use a uniform pdf for the - time split, a step for stereo, and a triangular one for the rest. */ - if (stereo && N>2) - { - int p0 = 3; - int x = itheta; - int x0 = qn/2; - int ft = p0*(x0+1) + x0; - /* Use a probability of p0 up to itheta=8192 and then use 1 after */ - if (encode) - { - ec_encode(ec,x<=x0?p0*x:(x-1-x0)+(x0+1)*p0,x<=x0?p0*(x+1):(x-x0)+(x0+1)*p0,ft); - } else { - int fs; - fs=ec_decode(ec,ft); - if (fs<(x0+1)*p0) - x=fs/p0; + } + /* Entropy coding of the angle. We use a uniform pdf for the + time split, a step for stereo, and a triangular one for the rest. */ + if (stereo && N > 2) { + int p0 = 3; + int x = itheta; + int x0 = qn/2; + int ft = p0*(x0 + 1) + x0; + /* Use a probability of p0 up to itheta=8192 and then use 1 after */ + if (encode) { + oaci_ec_encode(ec, x <= x0?p0*x:(x - 1 - x0) + (x0 + 1)*p0, x <= x0?p0*(x + 1):(x - x0) + (x0 + 1)*p0, ft); + } else { + int fs; + fs = oaci_ec_decode(ec, ft); + if (fs < (x0 + 1)*p0) + x = fs/p0; + else + x = x0 + 1 + (fs - (x0 + 1)*p0); + oaci_ec_dec_update(ec, x <= x0?p0*x:(x - 1 - x0) + (x0 + 1)*p0, x <= x0?p0*(x + 1):(x - x0) + (x0 + 1)*p0, + ft); + itheta = x; + } + } else if (B0 > 1 || stereo) { + /* Uniform pdf */ + if (encode) + oaci_ec_enc_uint(ec, itheta, qn + 1); else - x=x0+1+(fs-(x0+1)*p0); - ec_dec_update(ec,x<=x0?p0*x:(x-1-x0)+(x0+1)*p0,x<=x0?p0*(x+1):(x-x0)+(x0+1)*p0,ft); - itheta = x; - } - } else if (B0>1 || stereo) { - /* Uniform pdf */ - if (encode) - ec_enc_uint(ec, itheta, qn+1); - else - itheta = ec_dec_uint(ec, qn+1); - } else { - int fs=1, ft; - ft = ((qn>>1)+1)*((qn>>1)+1); - if (encode) - { - int fl; - - fs = itheta <= (qn>>1) ? itheta + 1 : qn + 1 - itheta; - fl = itheta <= (qn>>1) ? itheta*(itheta + 1)>>1 : - ft - ((qn + 1 - itheta)*(qn + 2 - itheta)>>1); - - ec_encode(ec, fl, fl+fs, ft); - } else { - /* Triangular pdf */ - int fl=0; - int fm; - fm = ec_decode(ec, ft); - - if (fm < ((qn>>1)*((qn>>1) + 1)>>1)) - { - itheta = (isqrt32(8*(opus_uint32)fm + 1) - 1)>>1; - fs = itheta + 1; - fl = itheta*(itheta + 1)>>1; + itheta = oaci_ec_dec_uint(ec, qn + 1); + } else { + int fs = 1, ft; + ft = ((qn>>1) + 1)*((qn>>1) + 1); + if (encode) { + int fl; + + fs = itheta <= (qn>>1) ? itheta + 1 : qn + 1 - itheta; + fl = itheta <= (qn>>1) ? itheta*(itheta + 1)>>1 : + ft - ((qn + 1 - itheta)*(qn + 2 - itheta)>>1); + + oaci_ec_encode(ec, fl, fl + fs, ft); + } else { + /* Triangular pdf */ + int fl = 0; + int fm; + fm = oaci_ec_decode(ec, ft); + + if (fm < ((qn>>1)*((qn>>1) + 1)>>1)) { + itheta = (oaci_isqrt32(8*(oac_uint32)fm + 1) - 1)>>1; + fs = itheta + 1; + fl = itheta*(itheta + 1)>>1; + } else { + itheta = (2*(qn + 1) + - oaci_isqrt32(8*(oac_uint32)(ft - fm - 1) + 1))>>1; + fs = qn + 1 - itheta; + fl = ft - ((qn + 1 - itheta)*(qn + 2 - itheta)>>1); + } + + oaci_ec_dec_update(ec, fl, fl + fs, ft); } + } + celt_assert(itheta >= 0); + itheta = oaci_celt_udiv((oac_int32)itheta*16384, qn); + itheta_q30 = (oac_int32)itheta<<16; + if (encode && stereo) { + if (itheta == 0) + oaci_intensity_stereo(m, X, Y, bandE, i, N); else - { - itheta = (2*(qn + 1) - - isqrt32(8*(opus_uint32)(ft - fm - 1) + 1))>>1; - fs = qn + 1 - itheta; - fl = ft - ((qn + 1 - itheta)*(qn + 2 - itheta)>>1); + oaci_stereo_split(X, Y, N); + } + /* NOTE: Renormalising X and Y *may* help fixed-point a bit at very high rate. + Let's do that at higher complexity */ + } else if (stereo) { + if (encode) { + inv = itheta > 8192 && !ctx->disable_inv; + if (inv) { + int j; + for (j = 0; j < N; j++) + Y[j] = -Y[j]; } - - ec_dec_update(ec, fl, fl+fs, ft); - } - } - celt_assert(itheta>=0); - itheta = celt_udiv((opus_int32)itheta*16384, qn); -#ifdef ENABLE_QEXT - *ext_b = IMIN(*ext_b, ctx->ext_total_bits - (opus_int32)ec_tell_frac(ctx->ext_ec)); - if (*ext_b >= 2*N<ext_total_bits-ec_tell_frac(ctx->ext_ec)-1 > 2<ext_ec); - extra_bits = IMIN(12, IMAX(2, celt_sudiv(*ext_b, (2*N-1)<>30; - itheta_q30 += (1<<(extra_bits-1))-1; - itheta_q30 = IMAX(0, IMIN((1<ext_ec, itheta_q30, (1<ext_ec, (1<ext_ec) - ext_tell; - } else { - itheta_q30 = (opus_int32)itheta<<16; - } -#endif - if (encode && stereo) - { - if (itheta==0) - intensity_stereo(m, X, Y, bandE, i, N); - else - stereo_split(X, Y, N); - } - /* NOTE: Renormalising X and Y *may* help fixed-point a bit at very high rate. - Let's do that at higher complexity */ - } else if (stereo) { - if (encode) - { - inv = itheta > 8192 && !ctx->disable_inv; - if (inv) - { - int j; - for (j=0;j2<remaining_bits > 2<disable_inv) - inv = 0; - itheta = 0; - itheta_q30 = 0; - } - qalloc = ec_tell_frac(ec) - tell; - *b -= qalloc; - - if (itheta == 0) - { - imid = 32767; - iside = 0; - *fill &= (1<inv = inv; - sctx->imid = imid; - sctx->iside = iside; - sctx->delta = delta; - sctx->itheta = itheta; -#ifdef ENABLE_QEXT - sctx->itheta_q30 = itheta_q30; -#endif - sctx->qalloc = qalloc; + oaci_intensity_stereo(m, X, Y, bandE, i, N); + } + if (*b > 2<total_bits - tell > 2<disable_inv) + inv = 0; + itheta = 0; + itheta_q30 = 0; + } + qalloc = oaci_ec_tell_frac(ec) - tell; + *b -= qalloc; + + if (itheta == 0) { + imid = 32767; + iside = 0; + *fill &= (1<inv = inv; + sctx->imid = imid; + sctx->iside = iside; + sctx->delta = delta; + sctx->itheta = itheta; + sctx->itheta_q30 = itheta_q30; } -static unsigned quant_band_n1(struct band_ctx *ctx, celt_norm *X, celt_norm *Y, - celt_norm *lowband_out) -{ - int c; - int stereo; - celt_norm *x = X; - int encode; - ec_ctx *ec; - - encode = ctx->encode; - ec = ctx->ec; - - stereo = Y != NULL; - c=0; do { - int sign=0; - if (ctx->remaining_bits>=1<remaining_bits -= 1<resynth) - x[0] = sign ? -NORM_SCALING : NORM_SCALING; - x = Y; - } while (++c<1+stereo); - if (lowband_out) - lowband_out[0] = SHR32(X[0],4); - return 1; +static unsigned oaci_quant_band_n1(struct band_ctx *ctx, celt_norm *X, celt_norm *Y, + celt_norm *lowband_out) { + int c; + int stereo; + celt_norm *x = X; + int encode; + ec_ctx *ec; + + encode = ctx->encode; + ec = ctx->ec; + + stereo = Y != NULL; + c = 0; do { + int sign = 0; + if (ctx->total_bits - oaci_ec_tell_frac(ec) > 1<resynth) + x[0] = sign ? -NORM_SCALING : NORM_SCALING; + x = Y; + } while (++c < 1 + stereo); + if (lowband_out) + lowband_out[0] = SHR32(X[0], 4); + return 1; } /* This function is responsible for encoding and decoding a mono partition. It can split the band in two and transmit the energy difference with the two half-bands. It can be called recursively so bands can end up being split in 8 parts. */ -static unsigned quant_partition(struct band_ctx *ctx, celt_norm *X, - int N, int b, int B, celt_norm *lowband, - int LM, - opus_val32 gain, int fill - ARG_QEXT(int ext_b)) -{ - const unsigned char *cache; - int q; - int curr_bits; - int imid=0, iside=0; - int B0=B; - opus_val32 mid=0, side=0; - unsigned cm=0; - celt_norm *Y=NULL; - int encode; - const CELTMode *m; - int i; - int spread; - ec_ctx *ec; - - encode = ctx->encode; - m = ctx->m; - i = ctx->i; - spread = ctx->spread; - ec = ctx->ec; - - /* If we need 1.5 more bit than we can produce, split the band in two. */ - cache = m->cache.bits + m->cache.index[(LM+1)*m->nbEBands+i]; - if (LM != -1 && b > cache[cache[0]]+12 && N>2) - { - int mbits, sbits, delta; - int itheta; - int qalloc; - struct split_ctx sctx; - celt_norm *next_lowband2=NULL; - opus_int32 rebalance; - - N >>= 1; - Y = X+N; - LM -= 1; - if (B==1) - fill = (fill&1)|(fill<<1); - B = (B+1)>>1; - - compute_theta(ctx, &sctx, X, Y, N, &b, B, B0, LM, 0, &fill ARG_QEXT(&ext_b)); - imid = sctx.imid; - iside = sctx.iside; - delta = sctx.delta; - itheta = sctx.itheta; - qalloc = sctx.qalloc; +static unsigned oaci_quant_partition(struct band_ctx *ctx, celt_norm *X, + int N, int b, int B, celt_norm *lowband, + int LM, + oac_val32 gain, int fill) { + const unsigned char *cache; + int q; + int curr_bits; + int imid = 0, iside = 0; + int B0 = B; + oac_val32 mid = 0, side = 0; + unsigned cm = 0; + celt_norm *Y = NULL; + int encode; + const CELTMode *m; + int i; + int spread; + ec_ctx *ec; + oac_int32 tell; + + encode = ctx->encode; + m = ctx->m; + i = ctx->i; + spread = ctx->spread; + ec = ctx->ec; + + /* If we need 1.5 more bit than we can produce, split the band in two. */ + cache = m->cache.bits + m->cache.index[(LM + 1)*m->nbEBands + i]; + if (LM != -1 && b > cache[cache[0]] + 12 && N > 2) { + int mbits, sbits, delta; + int itheta; + struct split_ctx sctx; + celt_norm *next_lowband2 = NULL; + oac_int32 rebalance; + + N >>= 1; + Y = X + N; + LM -= 1; + if (B == 1) + fill = (fill&1)|(fill<<1); + B = (B + 1)>>1; + + oaci_compute_theta(ctx, &sctx, X, Y, N, &b, B, B0, LM, 0, &fill); + imid = sctx.imid; + iside = sctx.iside; + delta = sctx.delta; + itheta = sctx.itheta; + (void)imid; + (void)iside; #ifdef FIXED_POINT -# ifdef ENABLE_QEXT - (void)imid; - (void)iside; - mid = celt_cos_norm32(sctx.itheta_q30); - side = celt_cos_norm32((1<<30)-sctx.itheta_q30); -# else - mid = SHL32(EXTEND32(imid), 16); - side = SHL32(EXTEND32(iside), 16); -# endif + mid = oaci_celt_cos_norm32(sctx.itheta_q30); + side = oaci_celt_cos_norm32((1<<30) - sctx.itheta_q30); #else -# ifdef ENABLE_QEXT - (void)imid; - (void)iside; - mid = celt_cos_norm2(sctx.itheta_q30*(1.f/(1<<30))); - side = celt_cos_norm2(1.f-sctx.itheta_q30*(1.f/(1<<30))); -# else - mid = (1.f/32768)*imid; - side = (1.f/32768)*iside; -# endif + mid = oaci_celt_cos_norm2(sctx.itheta_q30*(1.f/(1<<30))); + side = oaci_celt_cos_norm2(1.f - sctx.itheta_q30*(1.f/(1<<30))); #endif - /* Give more bits to low-energy MDCTs than they would otherwise deserve */ - if (B0>1 && (itheta&0x3fff)) - { - if (itheta > 8192) - /* Rough approximation for pre-echo masking */ - delta -= delta>>(4-LM); - else - /* Corresponds to a forward-masking slope of 1.5 dB per 10 ms */ - delta = IMIN(0, delta + (N<>(5-LM))); - } - mbits = IMAX(0, IMIN(b, (b-delta)/2)); - sbits = b-mbits; - ctx->remaining_bits -= qalloc; - - if (lowband) - next_lowband2 = lowband+N; /* >32-bit split case */ - - rebalance = ctx->remaining_bits; - if (mbits >= sbits) - { - cm = quant_partition(ctx, X, N, mbits, B, lowband, LM, - MULT32_32_Q31(gain,mid), fill ARG_QEXT(ext_b/2)); - rebalance = mbits - (rebalance-ctx->remaining_bits); - if (rebalance > 3<>B ARG_QEXT(ext_b/2))<<(B0>>1); - } else { - cm = quant_partition(ctx, Y, N, sbits, B, next_lowband2, LM, - MULT32_32_Q31(gain,side), fill>>B ARG_QEXT(ext_b/2))<<(B0>>1); - rebalance = sbits - (rebalance-ctx->remaining_bits); - if (rebalance > 3<>BITRES; - ext_remaining_bits = ctx->ext_total_bits-(opus_int32)ec_tell_frac(ctx->ext_ec); - if (ext_remaining_bits < ((extra_bits+1)*(N-1)+N)<>BITRES; - extra_bits = IMAX(extra_bits-1, 0); - } - extra_bits = IMIN(12, extra_bits); -#endif - /* This is the basic no-split case */ - q = bits2pulses(m, i, LM, b); - curr_bits = pulses2bits(m, i, LM, q); - ctx->remaining_bits -= curr_bits; - - /* Ensures we can never bust the budget */ - while (ctx->remaining_bits < 0 && q > 0) - { - ctx->remaining_bits += curr_bits; - q--; - curr_bits = pulses2bits(m, i, LM, q); - ctx->remaining_bits -= curr_bits; - } - - if (q!=0) - { - int K = get_pulses(q); - - /* Finally do the actual quantization */ - if (encode) - { - cm = alg_quant(X, N, K, spread, B, ec, gain, ctx->resynth - ARG_QEXT(ctx->ext_ec) ARG_QEXT(extra_bits), + /* Give more bits to low-energy MDCTs than they would otherwise deserve */ + if (B0 > 1 && (itheta&0x3fff)) { + if (itheta > 8192) + /* Rough approximation for pre-echo masking */ + delta -= delta>>(4 - LM); + else + /* Corresponds to a forward-masking slope of 1.5 dB per 10 ms */ + delta = IMIN(0, delta + (N<>(5 - LM))); + } + mbits = IMAX(0, IMIN(b, (b - delta)/2)); + sbits = b - mbits; + + if (lowband) + next_lowband2 = lowband + N; /* >32-bit split case */ + + tell = oaci_ec_tell_frac(ec); + if (mbits >= sbits) { + cm = oaci_quant_partition(ctx, X, N, mbits, B, lowband, LM, + MULT32_32_Q31(gain, mid), fill); + rebalance = mbits - (oaci_ec_tell_frac(ec) - tell); + if (rebalance > 3<>B)<<(B0>>1); + } else { + cm = oaci_quant_partition(ctx, Y, N, sbits, B, next_lowband2, LM, + MULT32_32_Q31(gain, side), fill>>B)<<(B0>>1); + rebalance = sbits - (oaci_ec_tell_frac(ec) - tell); + if (rebalance > 3<total_bits - oaci_ec_tell_frac(ec) - 1; + remaining_bits -= curr_bits; + + /* Ensures we can never bust the budget */ + while (remaining_bits < 0 && q > 0) { + remaining_bits += curr_bits; + q--; + curr_bits = oaci_pulses2bits(m, i, LM, q); + remaining_bits -= curr_bits; + } + + if (q != 0) { + int K = oaci_get_pulses(q); + + /* Finally do the actual quantization */ + if (encode) { + cm = oaci_alg_quant(X, N, K, spread, B, ec, gain, ctx->resynth, ctx->arch); - } else { - cm = alg_unquant(X, N, K, spread, B, ec, gain - ARG_QEXT(ctx->ext_ec) ARG_QEXT(extra_bits)); - } -#ifdef ENABLE_QEXT - } else if (ext_b > 2*N<>BITRES; - ext_remaining_bits = ctx->ext_total_bits-ec_tell_frac(ctx->ext_ec); - if (ext_remaining_bits < ((extra_bits+1)*(N-1)+N)<>BITRES; - extra_bits = IMAX(extra_bits-1, 0); - } - extra_bits = IMIN(14, extra_bits); - if (encode) cm = cubic_quant(X, N, extra_bits, B, ctx->ext_ec, gain, ctx->resynth); - else cm = cubic_unquant(X, N, extra_bits, B, ctx->ext_ec, gain); -#endif - } else { - /* If there's no pulse, fill the band anyway */ - int j; - if (ctx->resynth) - { - unsigned cm_mask; - /* B can be as large as 16, so this shift might overflow an int on a - 16-bit platform; use a long to get defined behavior.*/ - cm_mask = (unsigned)(1UL<seed = celt_lcg_rand(ctx->seed); - X[j] = SHL32((celt_norm)((opus_int32)ctx->seed>>20), NORM_SHIFT-14); - } - cm = cm_mask; - } else { - /* Folded spectrum */ - for (j=0;jseed = celt_lcg_rand(ctx->seed); - /* About 48 dB below the "normal" folding level */ - tmp = QCONST16(1.0f/256, NORM_SHIFT-4); - tmp = (ctx->seed)&0x8000 ? tmp : -tmp; - X[j] = lowband[j]+tmp; - } - cm = fill; - } - renormalise_vector(X, N, gain, ctx->arch); + cm = oaci_alg_unquant(X, N, K, spread, B, ec, gain); + } + } else { + /* If there's no pulse, fill the band anyway */ + int j; + if (ctx->resynth) { + unsigned cm_mask; + /* B can be as large as 16, so this shift might overflow an int on a + 16-bit platform; use a long to get defined behavior.*/ + cm_mask = (unsigned)(1UL<seed = oaci_celt_lcg_rand(ctx->seed); + X[j] = SHL32((celt_norm)((oac_int32)ctx->seed>>20), NORM_SHIFT - 14); + } + cm = cm_mask; + } else { + /* Folded spectrum */ + for (j = 0; j < N; j++) { + oac_val16 tmp; + ctx->seed = oaci_celt_lcg_rand(ctx->seed); + /* About 48 dB below the "normal" folding level */ + tmp = QCONST16(1.0f/256, NORM_SHIFT - 4); + tmp = (ctx->seed)&0x8000 ? tmp : -tmp; + X[j] = lowband[j] + tmp; + } + cm = fill; + } + oaci_renormalise_vector(X, N, gain, ctx->arch); + } } - } - } - } + } + } - return cm; + return cm; } -#ifdef ENABLE_QEXT -static unsigned cubic_quant_partition(struct band_ctx *ctx, celt_norm *X, int N, int b, int B, ec_ctx *ec, int LM, opus_val32 gain, int resynth, int encode) -{ - celt_assert(LM>=0); - ctx->remaining_bits = ctx->ec->storage*8*8 - ec_tell_frac(ctx->ec); - b = IMIN(b, ctx->remaining_bits); - /* As long as we have at least two bits of depth, split all the way to LM=0 (not -1 like PVQ). */ - if (LM==0 || b<=2*N<remaining_bits); - /* Resolution left after taking into account coding the cube face. */ - res = (b-(1<m->logN[ctx->i]-(LM<>BITRES; - res = IMIN(14, IMAX(0, res)); - if (encode) ret = cubic_quant(X, N, res, B, ec, gain, resynth); - else ret = cubic_unquant(X, N, res, B, ec, gain); - ctx->remaining_bits = ctx->ec->storage*8*8 - ec_tell_frac(ctx->ec); - return ret; - } else { - celt_norm *Y; - opus_int32 itheta_q30; - opus_val32 g1, g2; - opus_int32 theta_res; - opus_int32 qtheta; - int delta; - int b1, b2; - int cm; - int N0; - N0 = N; - N >>= 1; - Y = X+N; - LM -= 1; - B = (B+1)>>1; - theta_res = IMIN(16, (b>>BITRES)/(N0-1) + 1); - if (encode) { - itheta_q30 = stereo_itheta(X, Y, 0, N, ctx->arch); - qtheta = (itheta_q30+(1<<(29-theta_res)))>>(30-theta_res); - ec_enc_uint(ec, qtheta, (1<>16)-8192) >> (17-BITRES); +unsigned oaci_cubic_quant_partition(struct band_ctx *ctx, celt_norm *X, int N, int b, int B, ec_ctx *ec, int LM, + oac_val32 gain, int resynth, int encode) { + oac_int32 remaining_bits = ctx->total_bits - oaci_ec_tell_frac(ctx->ec) - 1; + celt_assert(LM >= 0); + b = IMIN(b, remaining_bits); + /* As long as we have at least two bits of depth, split all the way to LM=0 (not -1 like PVQ). */ + if (LM == 0 || b <= 2*N<m->logN[ctx->i] - (LM<>BITRES; + res = IMIN(14, IMAX(0, res)); + if (encode) ret = oaci_cubic_quant(X, N, res, B, ec, gain, resynth); + else ret = oaci_cubic_unquant(X, N, res, B, ec, gain); + return ret; + } else { + celt_norm *Y; + oac_int32 itheta_q30; + oac_val32 g1, g2; + oac_int32 theta_res; + oac_int32 qtheta; + int delta; + int b1, b2; + int cm; + int N0; + N0 = N; + N >>= 1; + Y = X + N; + LM -= 1; + B = (B + 1)>>1; + theta_res = IMIN(16, (b>>BITRES)/(N0 - 1) + 1); + if (encode) { + itheta_q30 = oaci_stereo_itheta(X, Y, 0, N, ctx->arch); + qtheta = (itheta_q30 + (1<<(29 - theta_res)))>>(30 - theta_res); + oaci_ec_enc_uint(ec, qtheta, (1<>16) - 8192)>>(17 - BITRES); #ifdef FIXED_POINT - g1 = celt_cos_norm32(itheta_q30); - g2 = celt_cos_norm32((1<<30)-itheta_q30); + g1 = oaci_celt_cos_norm32(itheta_q30); + g2 = oaci_celt_cos_norm32((1<<30) - itheta_q30); #else - g1 = celt_cos_norm2(itheta_q30*(1.f/(1<<30))); - g2 = celt_cos_norm2(1.f-itheta_q30*(1.f/(1<<30))); + g1 = oaci_celt_cos_norm2(itheta_q30*(1.f/(1<<30))); + g2 = oaci_celt_cos_norm2(1.f - itheta_q30*(1.f/(1<<30))); #endif - if (itheta_q30 == 0) { - b1=b; - b2=0; - } else if (itheta_q30==1073741824) { - b1=0; - b2=b; - } else { - b1 = IMIN(b, IMAX(0, (b-delta)/2)); - b2 = b-b1; - } - cm = cubic_quant_partition(ctx, X, N, b1, B, ec, LM, MULT32_32_Q31(gain, g1), resynth, encode); - cm |= cubic_quant_partition(ctx, Y, N, b2, B, ec, LM, MULT32_32_Q31(gain, g2), resynth, encode); - return cm; - } + if (itheta_q30 == 0) { + b1 = b; + b2 = 0; + } else if (itheta_q30 == 1073741824) { + b1 = 0; + b2 = b; + } else { + b1 = IMIN(b, IMAX(0, (b - delta)/2)); + b2 = b - b1; + } + cm = oaci_cubic_quant_partition(ctx, X, N, b1, B, ec, LM, MULT32_32_Q31(gain, g1), resynth, encode); + cm |= oaci_cubic_quant_partition(ctx, Y, N, b2, B, ec, LM, MULT32_32_Q31(gain, g2), resynth, encode); + return cm; + } } -#endif /* This function is responsible for encoding and decoding a band for the mono case. */ -static unsigned quant_band(struct band_ctx *ctx, celt_norm *X, - int N, int b, int B, celt_norm *lowband, - int LM, celt_norm *lowband_out, - opus_val32 gain, celt_norm *lowband_scratch, int fill - ARG_QEXT(int ext_b)) -{ - int N0=N; - int N_B=N; - int N_B0; - int B0=B; - int time_divide=0; - int recombine=0; - int longBlocks; - unsigned cm=0; - int k; - int encode; - int tf_change; - - encode = ctx->encode; - tf_change = ctx->tf_change; - - longBlocks = B0==1; - - N_B = celt_udiv(N_B, B); - - /* Special case for one sample */ - if (N==1) - { - return quant_band_n1(ctx, X, NULL, lowband_out); - } - - if (tf_change>0) - recombine = tf_change; - /* Band recombining to increase frequency resolution */ - - if (lowband_scratch && lowband && (recombine || ((N_B&1) == 0 && tf_change<0) || B0>1)) - { - OPUS_COPY(lowband_scratch, lowband, N); - lowband = lowband_scratch; - } - - for (k=0;k>k, 1<>k, 1<>4]<<2; - } - B>>=recombine; - N_B<<=recombine; - - /* Increasing the time resolution */ - while ((N_B&1) == 0 && tf_change<0) - { - if (encode) - haar1(X, N_B, B); - if (lowband) - haar1(lowband, N_B, B); - fill |= fill<>= 1; - time_divide++; - tf_change++; - } - B0=B; - N_B0 = N_B; - - /* Reorganize the samples in time order instead of frequency order */ - if (B0>1) - { - if (encode) - deinterleave_hadamard(X, N_B>>recombine, B0<>recombine, B0<extra_bands && b > (3*N<m->logN[ctx->i]+8+8*LM)) { - cm = cubic_quant_partition(ctx, X, N, b, B, ctx->ec, LM, gain, ctx->resynth, encode); - } else -#endif - { - cm = quant_partition(ctx, X, N, b, B, lowband, LM, gain, fill ARG_QEXT(ext_b)); - } - - /* This code is used by the decoder and by the resynthesis-enabled encoder */ - if (ctx->resynth) - { - /* Undo the sample reorganization going from time order to frequency order */ - if (B0>1) - interleave_hadamard(X, N_B>>recombine, B0<>= 1; - N_B <<= 1; - cm |= cm>>B; - haar1(X, N_B, B); - } - - for (k=0;k>k, 1<encode; + tf_change = ctx->tf_change; + + longBlocks = B0 == 1; + + N_B = oaci_celt_udiv(N_B, B); + + /* Special case for one sample */ + if (N == 1) { + return oaci_quant_band_n1(ctx, X, NULL, lowband_out); + } + + if (tf_change > 0) + recombine = tf_change; + /* Band recombining to increase frequency resolution */ + + if (lowband_scratch && lowband && (recombine || ((N_B&1) == 0 && tf_change < 0) || B0 > 1)) { + OAC_COPY(lowband_scratch, lowband, N); + lowband = lowband_scratch; + } + + for (k = 0; k < recombine; k++) { + static const unsigned char bit_interleave_table[16] = { + 0, 1, 1, 1, 2, 3, 3, 3, 2, 3, 3, 3, 2, 3, 3, 3 + }; + if (encode) + oaci_haar1(X, N>>k, 1<>k, 1<>4]<<2; + } + B >>= recombine; + N_B <<= recombine; + + /* Increasing the time resolution */ + while ((N_B&1) == 0 && tf_change < 0) { + if (encode) + oaci_haar1(X, N_B, B); + if (lowband) + oaci_haar1(lowband, N_B, B); + fill |= fill<>= 1; + time_divide++; + tf_change++; + } + B0 = B; + N_B0 = N_B; + + /* Reorganize the samples in time order instead of frequency order */ + if (B0 > 1) { + if (encode) + oaci_deinterleave_hadamard(X, N_B>>recombine, B0<>recombine, B0<resynth) { + /* Undo the sample reorganization going from time order to frequency order */ + if (B0 > 1) + oaci_interleave_hadamard(X, N_B>>recombine, B0<>= 1; + N_B <<= 1; + cm |= cm>>B; + oaci_haar1(X, N_B, B); + } + + for (k = 0; k < recombine; k++) { + static const unsigned char bit_deinterleave_table[16] = { + 0x00, 0x03, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F, + 0xC0, 0xC3, 0xCC, 0xCF, 0xF0, 0xF3, 0xFC, 0xFF + }; + cm = bit_deinterleave_table[cm]; + oaci_haar1(X, N0>>k, 1<encode; - ec = ctx->ec; - - /* Special case for one sample */ - if (N==1) - { - return quant_band_n1(ctx, X, Y, lowband_out); - } - - orig_fill = fill; - - if (encode) { - if (ctx->bandE[ctx->i] < MIN_STEREO_ENERGY || ctx->bandE[ctx->m->nbEBands+ctx->i] < MIN_STEREO_ENERGY) { - if (ctx->bandE[ctx->i] > ctx->bandE[ctx->m->nbEBands+ctx->i]) OPUS_COPY(Y, X, N); - else OPUS_COPY(X, Y, N); - } - } - compute_theta(ctx, &sctx, X, Y, N, &b, B, B, LM, 1, &fill ARG_QEXT(&ext_b)); - inv = sctx.inv; - imid = sctx.imid; - iside = sctx.iside; - delta = sctx.delta; - itheta = sctx.itheta; - qalloc = sctx.qalloc; +static unsigned oaci_quant_band_stereo(struct band_ctx *ctx, celt_norm *X, celt_norm *Y, + int N, int b, int B, celt_norm *lowband, + int LM, celt_norm *lowband_out, + celt_norm *lowband_scratch, int fill) { + int imid = 0, iside = 0; + int inv = 0; + oac_val32 mid = 0, side = 0; + unsigned cm = 0; + int mbits, sbits, delta; + int itheta; + struct split_ctx sctx; + int orig_fill; + int encode; + ec_ctx *ec; + + encode = ctx->encode; + ec = ctx->ec; + + /* Special case for one sample */ + if (N == 1) { + return oaci_quant_band_n1(ctx, X, Y, lowband_out); + } + + orig_fill = fill; + + if (encode) { + if (ctx->bandE[ctx->i] < MIN_STEREO_ENERGY || ctx->bandE[ctx->m->nbEBands + ctx->i] < MIN_STEREO_ENERGY) { + if (ctx->bandE[ctx->i] > ctx->bandE[ctx->m->nbEBands + ctx->i]) OAC_COPY(Y, X, N); + else OAC_COPY(X, Y, N); + } + } + oaci_compute_theta(ctx, &sctx, X, Y, N, &b, B, B, LM, 1, &fill); + inv = sctx.inv; + imid = sctx.imid; + iside = sctx.iside; + delta = sctx.delta; + itheta = sctx.itheta; + (void)imid; + (void)iside; #ifdef FIXED_POINT -# ifdef ENABLE_QEXT - (void)imid; - (void)iside; - mid = celt_cos_norm32(sctx.itheta_q30); - side = celt_cos_norm32((1<<30)-sctx.itheta_q30); -# else - mid = SHL32(EXTEND32(imid), 16); - side = SHL32(EXTEND32(iside), 16); -# endif + mid = oaci_celt_cos_norm32(sctx.itheta_q30); + side = oaci_celt_cos_norm32((1<<30) - sctx.itheta_q30); #else -# ifdef ENABLE_QEXT - (void)imid; - (void)iside; - mid = celt_cos_norm2(sctx.itheta_q30*(1.f/(1<<30))); - side = celt_cos_norm2(1.f-sctx.itheta_q30*(1.f/(1<<30))); -# else - mid = (1.f/32768)*imid; - side = (1.f/32768)*iside; -# endif + mid = oaci_celt_cos_norm2(sctx.itheta_q30*(1.f/(1<<30))); + side = oaci_celt_cos_norm2(1.f - sctx.itheta_q30*(1.f/(1<<30))); #endif - /* This is a special case for N=2 that only works for stereo and takes - advantage of the fact that mid and side are orthogonal to encode - the side with just one bit. */ - if (N==2) - { - int c; - int sign=0; - celt_norm *x2, *y2; - mbits = b; - sbits = 0; - /* Only need one bit for the side. */ - if (itheta != 0 && itheta != 16384) - sbits = 1< 8192; - ctx->remaining_bits -= qalloc+sbits; - - x2 = c ? Y : X; - y2 = c ? X : Y; - if (sbits) - { - if (encode) - { - /* Here we only need to encode a sign for the side. */ - /* FIXME: Need to increase fixed-point precision? */ - sign = MULT32_32_Q31(x2[0],y2[1]) - MULT32_32_Q31(x2[1],y2[0]) < 0; - ec_enc_bits(ec, sign, 1); - } else { - sign = ec_dec_bits(ec, 1); - } - } - sign = 1-2*sign; - /* We use orig_fill here because we want to fold the side, but if - itheta==16384, we'll have cleared the low bits of fill. */ - cm = quant_band(ctx, x2, N, mbits, B, lowband, LM, lowband_out, Q31ONE, - lowband_scratch, orig_fill ARG_QEXT(ext_b)); - /* We don't split N=2 bands, so cm is either 1 or 0 (for a fold-collapse), - and there's no need to worry about mixing with the other channel. */ - y2[0] = -sign*x2[1]; - y2[1] = sign*x2[0]; - if (ctx->resynth) - { - celt_norm tmp; - X[0] = MULT32_32_Q31(mid, X[0]); - X[1] = MULT32_32_Q31(mid, X[1]); - Y[0] = MULT32_32_Q31(side, Y[0]); - Y[1] = MULT32_32_Q31(side, Y[1]); - tmp = X[0]; - X[0] = SUB32(tmp,Y[0]); - Y[0] = ADD32(tmp,Y[0]); - tmp = X[1]; - X[1] = SUB32(tmp,Y[1]); - Y[1] = ADD32(tmp,Y[1]); - } - } else { - /* "Normal" split code */ - opus_int32 rebalance; - - mbits = IMAX(0, IMIN(b, (b-delta)/2)); - sbits = b-mbits; - ctx->remaining_bits -= qalloc; - - rebalance = ctx->remaining_bits; - if (mbits >= sbits) - { -#ifdef ENABLE_QEXT - int qext_extra = 0; - /* Reallocate any mid bits that cannot be used to extra mid bits. */ - if (cap != NULL && ext_b != 0) qext_extra = IMAX(0, IMIN(ext_b/2, mbits - cap[ctx->i]/2)); -#endif - /* In stereo mode, we do not apply a scaling to the mid because we need the normalized - mid for folding later. */ - cm = quant_band(ctx, X, N, mbits, B, lowband, LM, lowband_out, Q31ONE, - lowband_scratch, fill ARG_QEXT(ext_b/2+qext_extra)); - rebalance = mbits - (rebalance-ctx->remaining_bits); - if (rebalance > 3<extra_bands) sbits = IMIN(sbits, ctx->remaining_bits); -#endif - /* For a stereo split, the high bits of fill are always zero, so no - folding will be done to the side. */ - cm |= quant_band(ctx, Y, N, sbits, B, NULL, LM, NULL, side, NULL, fill>>B ARG_QEXT(ext_b/2-qext_extra)); - } else { -#ifdef ENABLE_QEXT - int qext_extra = 0; - /* Reallocate any side bits that cannot be used to extra side bits. */ - if (cap != NULL && ext_b != 0) qext_extra = IMAX(0, IMIN(ext_b/2, sbits - cap[ctx->i]/2)); -#endif - /* For a stereo split, the high bits of fill are always zero, so no - folding will be done to the side. */ - cm = quant_band(ctx, Y, N, sbits, B, NULL, LM, NULL, side, NULL, fill>>B ARG_QEXT(ext_b/2+qext_extra)); - rebalance = sbits - (rebalance-ctx->remaining_bits); - if (rebalance > 3<extra_bands) mbits = IMIN(mbits, ctx->remaining_bits); -#endif - /* In stereo mode, we do not apply a scaling to the mid because we need the normalized - mid for folding later. */ - cm |= quant_band(ctx, X, N, mbits, B, lowband, LM, lowband_out, Q31ONE, - lowband_scratch, fill ARG_QEXT(ext_b/2-qext_extra)); - } - } - - - /* This code is used by the decoder and by the resynthesis-enabled encoder */ - if (ctx->resynth) - { - if (N!=2) - stereo_merge(X, Y, mid, N, ctx->arch); - if (inv) - { - int j; - for (j=0;j 8192; + + x2 = c ? Y : X; + y2 = c ? X : Y; + if (sbits) { + if (encode) { + /* Here we only need to encode a sign for the side. */ + /* FIXME: Need to increase fixed-point precision? */ + sign = MULT32_32_Q31(x2[0], y2[1]) - MULT32_32_Q31(x2[1], y2[0]) < 0; + oaci_ec_enc_bits(ec, sign, 1); + } else { + sign = oaci_ec_dec_bits(ec, 1); + } + } + sign = 1 - 2*sign; + /* We use orig_fill here because we want to fold the side, but if + itheta==16384, we'll have cleared the low bits of fill. */ + cm = oaci_quant_band(ctx, x2, N, mbits, B, lowband, LM, lowband_out, Q31ONE, + lowband_scratch, orig_fill); + /* We don't split N=2 bands, so cm is either 1 or 0 (for a fold-collapse), + and there's no need to worry about mixing with the other channel. */ + y2[0] = -sign*x2[1]; + y2[1] = sign*x2[0]; + if (ctx->resynth) { + celt_norm tmp; + X[0] = MULT32_32_Q31(mid, X[0]); + X[1] = MULT32_32_Q31(mid, X[1]); + Y[0] = MULT32_32_Q31(side, Y[0]); + Y[1] = MULT32_32_Q31(side, Y[1]); + tmp = X[0]; + X[0] = SUB32(tmp, Y[0]); + Y[0] = ADD32(tmp, Y[0]); + tmp = X[1]; + X[1] = SUB32(tmp, Y[1]); + Y[1] = ADD32(tmp, Y[1]); + } + } else { + /* "Normal" split code */ + oac_int32 tell; + oac_int32 rebalance; + + mbits = IMAX(0, IMIN(b, (b - delta)/2)); + sbits = b - mbits; + tell = oaci_ec_tell_frac(ec); + + if (mbits >= sbits) { + /* In stereo mode, we do not apply a scaling to the mid because we need the normalized + mid for folding later. */ + cm = oaci_quant_band(ctx, X, N, mbits, B, lowband, LM, lowband_out, Q31ONE, + lowband_scratch, fill); + rebalance = mbits - (oaci_ec_tell_frac(ec) - tell); + if (rebalance > 3<>B); + } else { + /* For a stereo split, the high bits of fill are always zero, so no + folding will be done to the side. */ + cm = oaci_quant_band(ctx, Y, N, sbits, B, NULL, LM, NULL, side, NULL, fill>>B); + rebalance = sbits - (oaci_ec_tell_frac(ec) - tell); + if (rebalance > 3<resynth) { + if (N != 2) + oaci_stereo_merge(X, Y, mid, N, ctx->arch); + if (inv) { + int j; + for (j = 0; j < N; j++) + Y[j] = -Y[j]; + } + } + 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; - const opus_int16 * OPUS_RESTRICT eBands = m->eBands; - n1 = M*(eBands[start+1]-eBands[start]); - n2 = M*(eBands[start+2]-eBands[start+1]); - /* Duplicate enough of the first band folding data to be able to fold the second band. - Copies no data for CELT-only mode. */ - OPUS_COPY(&norm[n1], &norm[2*n1 - n2], n2-n1); - if (dual_stereo) - OPUS_COPY(&norm2[n1], &norm2[2*n1 - n2], n2-n1); +static void oaci_special_hybrid_folding(const CELTMode *m, celt_norm *norm, celt_norm *norm2, int start, int M, + int dual_stereo) { + int n1, n2; + const oac_int16 * OAC_RESTRICT eBands = m->eBands; + n1 = M*(eBands[start + 1] - eBands[start]); + n2 = M*(eBands[start + 2] - eBands[start + 1]); + /* Duplicate enough of the first band folding data to be able to fold the second band. + Copies no data for CELT-only mode. */ + OAC_COPY(&norm[n1], &norm[2*n1 - n2], n2 - n1); + if (dual_stereo) + OAC_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, - const celt_ener *bandE, int *pulses, int shortBlocks, int spread, - int dual_stereo, int intensity, int *tf_res, opus_int32 total_bits, - opus_int32 balance, ec_ctx *ec, int LM, int codedBands, - opus_uint32 *seed, int complexity, int arch, int disable_inv - ARG_QEXT(ec_ctx *ext_ec) ARG_QEXT(int *extra_pulses) - ARG_QEXT(opus_int32 ext_total_bits) ARG_QEXT(const int *cap)) -{ - int i; - opus_int32 remaining_bits; - const opus_int16 * OPUS_RESTRICT eBands = m->eBands; - celt_norm * OPUS_RESTRICT norm, * OPUS_RESTRICT norm2; - VARDECL(celt_norm, _norm); - VARDECL(celt_norm, _lowband_scratch); - VARDECL(celt_norm, X_save); - VARDECL(celt_norm, Y_save); - VARDECL(celt_norm, X_save2); - VARDECL(celt_norm, Y_save2); - VARDECL(celt_norm, norm_save2); - VARDECL(unsigned char, bytes_save); - int resynth_alloc; - celt_norm *lowband_scratch; - int B; - int M; - int lowband_offset; - int update_lowband = 1; - int C = Y_ != NULL ? 2 : 1; - int norm_offset; - int theta_rdo = encode && Y_!=NULL && !dual_stereo && complexity>=8; +void oaci_quant_all_bands(int encode, const CELTMode *m, int start, int end, + celt_norm *X_, celt_norm *Y_, unsigned char *collapse_masks, + const celt_ener *bandE, int *pulses, int shortBlocks, int spread, + int dual_stereo, int intensity, int *tf_res, oac_int32 total_bits, + oac_int32 balance, ec_ctx *ec, int LM, int codedBands, + oac_uint32 *seed, int complexity, int arch, int disable_inv) { + int i; + oac_int32 remaining_bits; + const oac_int16 * OAC_RESTRICT eBands = m->eBands; + celt_norm * OAC_RESTRICT norm, * OAC_RESTRICT norm2; + VARDECL(celt_norm, _norm); + VARDECL(celt_norm, _lowband_scratch); + VARDECL(celt_norm, X_save); + VARDECL(celt_norm, Y_save); + VARDECL(celt_norm, X_save2); + VARDECL(celt_norm, Y_save2); + VARDECL(celt_norm, norm_save2); + VARDECL(unsigned char, bytes_save); + int resynth_alloc; + celt_norm *lowband_scratch; + int B; + int M; + int lowband_offset; + int update_lowband = 1; + int C = Y_ != NULL ? 2 : 1; + int norm_offset; + int theta_rdo = encode && Y_ != NULL && !dual_stereo && complexity >= 8; #ifdef RESYNTH - int resynth = 1; + int resynth = 1; #else - int resynth = !encode || theta_rdo; -#endif - struct band_ctx ctx; -#ifdef ENABLE_QEXT - int ext_b; - opus_int32 ext_balance=0; - opus_int32 ext_tell=0; - VARDECL(unsigned char, ext_bytes_save); -#endif - SAVE_STACK; - - M = 1<nbEBands-1]-norm_offset), celt_norm); - norm = _norm; - norm2 = norm + M*eBands[m->nbEBands-1]-norm_offset; - - /* For decoding, we can use the last band as scratch space because we don't need that - scratch space for the last band and we don't care about the data there until we're - decoding the last band. */ - if (encode && resynth) - resynth_alloc = M*(eBands[m->nbEBands]-eBands[m->nbEBands-1]); - else - resynth_alloc = ALLOC_NONE; - ALLOC(_lowband_scratch, resynth_alloc, celt_norm); - if (encode && resynth) - lowband_scratch = _lowband_scratch; - else - lowband_scratch = X_+M*eBands[m->effEBands-1]; - ALLOC(X_save, resynth_alloc, celt_norm); - ALLOC(Y_save, resynth_alloc, celt_norm); - ALLOC(X_save2, resynth_alloc, celt_norm); - ALLOC(Y_save2, resynth_alloc, celt_norm); - ALLOC(norm_save2, resynth_alloc, celt_norm); - - lowband_offset = 0; - ctx.bandE = bandE; - ctx.ec = ec; - ctx.encode = encode; - ctx.intensity = intensity; - ctx.m = m; - ctx.seed = *seed; - ctx.spread = spread; - ctx.arch = arch; - ctx.disable_inv = disable_inv; - ctx.resynth = resynth; - ctx.theta_round = 0; -#ifdef ENABLE_QEXT - ctx.ext_ec = ext_ec; - ctx.ext_total_bits = ext_total_bits; - ctx.extra_bands = end == NB_QEXT_BANDS || end == 2; - if (ctx.extra_bands) theta_rdo = 0; - ALLOC(ext_bytes_save, theta_rdo ? QEXT_PACKET_SIZE_CAP : ALLOC_NONE, unsigned char); -#endif - ALLOC(bytes_save, theta_rdo ? 1275 : ALLOC_NONE, unsigned char); - - /* Avoid injecting noise in the first band on transients. */ - ctx.avoid_split_noise = B > 1; - for (i=start;i 0); - tell = ec_tell_frac(ec); - - /* Compute how many bits we want to allocate to this band */ - if (i != start) - balance -= tell; - remaining_bits = total_bits-tell-1; - ctx.remaining_bits = remaining_bits; -#ifdef ENABLE_QEXT - if (i != start) { - ext_balance += extra_pulses[i-1] + ext_tell; - } - ext_tell = ec_tell_frac(ext_ec); - ctx.extra_bits = extra_pulses[i]; - if (i != start) - ext_balance -= ext_tell; - if (i <= codedBands-1) - { - opus_int32 ext_curr_balance = celt_sudiv(ext_balance, IMIN(3, codedBands-i)); - ext_b = IMAX(0, IMIN(16383, IMIN(ext_total_bits-ext_tell,extra_pulses[i]+ext_curr_balance))); - } else { - ext_b = 0; - } + int resynth = !encode || theta_rdo; #endif - if (i <= codedBands-1) - { - curr_balance = celt_sudiv(balance, IMIN(3, codedBands-i)); - b = IMAX(0, IMIN(16383, IMIN(remaining_bits+1,pulses[i]+curr_balance))); - } else { - b = 0; - } - -#ifndef DISABLE_UPDATE_DRAFT - if (resynth && (M*eBands[i]-N >= M*eBands[start] || i==start+1) && (update_lowband || lowband_offset==0)) + struct band_ctx ctx; + SAVE_STACK; + + M = 1<nbEBands - 1] - norm_offset), celt_norm); + norm = _norm; + norm2 = norm + M*eBands[m->nbEBands - 1] - norm_offset; + + /* For decoding, we can use the last band as scratch space because we don't need that + scratch space for the last band and we don't care about the data there until we're + decoding the last band. */ + if (encode && resynth) + resynth_alloc = M*(eBands[m->nbEBands] - eBands[m->nbEBands - 1]); + else + resynth_alloc = ALLOC_NONE; + ALLOC(_lowband_scratch, resynth_alloc, celt_norm); + if (encode && resynth) + lowband_scratch = _lowband_scratch; + else + lowband_scratch = X_ + M*eBands[m->effEBands - 1]; + ALLOC(X_save, resynth_alloc, celt_norm); + ALLOC(Y_save, resynth_alloc, celt_norm); + ALLOC(X_save2, resynth_alloc, celt_norm); + ALLOC(Y_save2, resynth_alloc, celt_norm); + ALLOC(norm_save2, resynth_alloc, celt_norm); + + lowband_offset = 0; + ctx.bandE = bandE; + ctx.ec = ec; + ctx.encode = encode; + ctx.intensity = intensity; + ctx.m = m; + ctx.seed = *seed; + ctx.spread = spread; + ctx.arch = arch; + ctx.disable_inv = disable_inv; + ctx.resynth = resynth; + ctx.theta_round = 0; + ALLOC(bytes_save, theta_rdo ? 1275 : ALLOC_NONE, unsigned char); + + /* Avoid injecting noise in the first band on transients. */ + ctx.avoid_split_noise = B > 1; + for (i = start; i < end; i++) { + oac_int32 tell; + int b; + int N; + oac_int32 curr_balance; + int effective_lowband = -1; + celt_norm * OAC_RESTRICT X, * OAC_RESTRICT Y; + int tf_change = 0; + unsigned x_cm; + unsigned y_cm; + int last; + + ctx.i = i; + last = (i == end - 1); + + X = X_ + M*eBands[i]; + if (Y_ != NULL) + Y = Y_ + M*eBands[i]; + else + Y = NULL; + N = M*eBands[i + 1] - M*eBands[i]; + celt_assert(N > 0); + tell = oaci_ec_tell_frac(ec); + + /* Compute how many bits we want to allocate to this band */ + if (i != start) + balance -= tell; + remaining_bits = total_bits - tell; + ctx.total_bits = total_bits; + if (i <= codedBands - 1) { + curr_balance = oaci_celt_sudiv(balance, IMIN(3, codedBands - i)); + b = IMAX(0, IMIN(16383, IMIN(remaining_bits, pulses[i] + curr_balance))); + } else { + b = 0; + } + + if (resynth && (M*eBands[i] - N >= M*eBands[start] || i == start + 1) + && (update_lowband || lowband_offset == 0)) lowband_offset = i; - if (i == start+1) - special_hybrid_folding(m, norm, norm2, start, M, dual_stereo); -#else - if (resynth && M*eBands[i]-N >= M*eBands[start] && (update_lowband || lowband_offset==0)) - lowband_offset = i; -#endif + if (i == start + 1) + oaci_special_hybrid_folding(m, norm, norm2, start, M, dual_stereo); + + tf_change = tf_res[i]; + ctx.tf_change = tf_change; + if (i >= m->effEBands) { + X = norm; + if (Y_ != NULL) + Y = norm; + lowband_scratch = NULL; + } + if (last && !theta_rdo) + lowband_scratch = NULL; + + /* Get a conservative estimate of the collapse_mask's for the bands we're + going to be folding from. */ + if (lowband_offset != 0 && (spread != SPREAD_AGGRESSIVE || B > 1 || tf_change < 0)) { + int fold_start; + int fold_end; + int fold_i; + /* This ensures we never repeat spectral content within one band */ + effective_lowband = IMAX(0, M*eBands[lowband_offset] - norm_offset - N); + fold_start = lowband_offset; + while (M*eBands[--fold_start] > effective_lowband + norm_offset) ; + fold_end = lowband_offset - 1; + while (++fold_end < i && M*eBands[fold_end] < effective_lowband + norm_offset + N) ; + x_cm = y_cm = 0; + fold_i = fold_start; do { + x_cm |= collapse_masks[fold_i*C + 0]; + y_cm |= collapse_masks[fold_i*C + C - 1]; + } while (++fold_i < fold_end); + } + /* Otherwise, we'll be using the LCG to fold, so all blocks will (almost + always) be non-zero. */ + else + x_cm = y_cm = (1<=m->effEBands) - { - X=norm; - if (Y_!=NULL) - Y = norm; - lowband_scratch = NULL; - } - if (last && !theta_rdo) - lowband_scratch = NULL; - - /* Get a conservative estimate of the collapse_mask's for the bands we're - going to be folding from. */ - if (lowband_offset != 0 && (spread!=SPREAD_AGGRESSIVE || B>1 || tf_change<0)) - { - int fold_start; - int fold_end; - int fold_i; - /* This ensures we never repeat spectral content within one band */ - effective_lowband = IMAX(0, M*eBands[lowband_offset]-norm_offset-N); - fold_start = lowband_offset; - while(M*eBands[--fold_start] > effective_lowband+norm_offset); - fold_end = lowband_offset-1; -#ifndef DISABLE_UPDATE_DRAFT - while(++fold_end < i && M*eBands[fold_end] < effective_lowband+norm_offset+N); -#else - while(M*eBands[++fold_end] < effective_lowband+norm_offset+N); -#endif - x_cm = y_cm = 0; - fold_i = fold_start; do { - x_cm |= collapse_masks[fold_i*C+0]; - y_cm |= collapse_masks[fold_i*C+C-1]; - } while (++fold_inbEBands], w); - /* Make a copy. */ - cm = x_cm|y_cm; - ec_save = *ec; -#ifdef ENABLE_QEXT - ext_ec_save = *ext_ec; -#endif - ctx_save = ctx; - OPUS_COPY(X_save, X, N); - OPUS_COPY(Y_save, Y, N); - /* Encode and round down. */ - ctx.theta_round = -1; - x_cm = quant_band_stereo(&ctx, X, Y, N, b, B, - effective_lowband != -1 ? norm+effective_lowband : NULL, LM, - last?NULL:norm+M*eBands[i]-norm_offset, lowband_scratch, cm ARG_QEXT(ext_b) ARG_QEXT(cap)); - dist0 = MULT16_32_Q15(w[0], celt_inner_prod_norm_shift(X_save, X, N, arch)) + MULT16_32_Q15(w[1], celt_inner_prod_norm_shift(Y_save, Y, N, arch)); - - /* Save first result. */ - cm2 = x_cm; - ec_save2 = *ec; -#ifdef ENABLE_QEXT - ext_ec_save2 = *ext_ec; -#endif - ctx_save2 = ctx; - OPUS_COPY(X_save2, X, N); - OPUS_COPY(Y_save2, Y, N); - if (!last) - OPUS_COPY(norm_save2, norm+M*eBands[i]-norm_offset, N); - nstart_bytes = ec_save.offs; - nend_bytes = ec_save.storage; - bytes_buf = ec_save.buf+nstart_bytes; - save_bytes = nend_bytes-nstart_bytes; - OPUS_COPY(bytes_save, bytes_buf, save_bytes); -#ifdef ENABLE_QEXT - ext_nstart_bytes = ext_ec_save.offs; - ext_nend_bytes = ext_ec_save.storage; - ext_bytes_buf = ext_ec_save.buf!=NULL ? ext_ec_save.buf+ext_nstart_bytes : NULL; - ext_save_bytes = ext_nend_bytes-ext_nstart_bytes; - if (ext_save_bytes) OPUS_COPY(ext_bytes_save, ext_bytes_buf, ext_save_bytes); -#endif - /* Restore */ - *ec = ec_save; -#ifdef ENABLE_QEXT - *ext_ec = ext_ec_save; -#endif - ctx = ctx_save; - OPUS_COPY(X, X_save, N); - OPUS_COPY(Y, Y_save, N); -#ifndef DISABLE_UPDATE_DRAFT - if (i == start+1) - special_hybrid_folding(m, norm, norm2, start, M, dual_stereo); -#endif - /* Encode and round up. */ - ctx.theta_round = 1; - x_cm = quant_band_stereo(&ctx, X, Y, N, b, B, - effective_lowband != -1 ? norm+effective_lowband : NULL, LM, - last?NULL:norm+M*eBands[i]-norm_offset, lowband_scratch, cm ARG_QEXT(ext_b) ARG_QEXT(cap)); - dist1 = MULT16_32_Q15(w[0], celt_inner_prod_norm_shift(X_save, X, N, arch)) + MULT16_32_Q15(w[1], celt_inner_prod_norm_shift(Y_save, Y, N, arch)); - if (dist0 >= dist1) { - x_cm = cm2; - *ec = ec_save2; -#ifdef ENABLE_QEXT - *ext_ec = ext_ec_save2; -#endif - ctx = ctx_save2; - OPUS_COPY(X, X_save2, N); - OPUS_COPY(Y, Y_save2, N); - if (!last) - OPUS_COPY(norm+M*eBands[i]-norm_offset, norm_save2, N); - OPUS_COPY(bytes_buf, bytes_save, save_bytes); -#ifdef ENABLE_QEXT - if (ext_save_bytes) OPUS_COPY(ext_bytes_buf, ext_bytes_save, ext_save_bytes); -#endif - } + /* Switch off dual stereo to do intensity. */ + dual_stereo = 0; + if (resynth) + for (j = 0; j < M*eBands[i] - norm_offset; j++) + norm[j] = HALF32(norm[j] + norm2[j]); + } + if (dual_stereo) { + x_cm = oaci_quant_band(&ctx, X, N, b/2, B, + effective_lowband != -1 ? norm + effective_lowband : NULL, LM, + last?NULL:norm + M*eBands[i] - norm_offset, Q31ONE, lowband_scratch, x_cm); + y_cm = oaci_quant_band(&ctx, Y, N, b/2, B, + effective_lowband != -1 ? norm2 + effective_lowband : NULL, LM, + last?NULL:norm2 + M*eBands[i] - norm_offset, Q31ONE, lowband_scratch, y_cm); + } else { + if (Y != NULL) { + if (theta_rdo && i < intensity) { + ec_ctx ec_save, ec_save2; + struct band_ctx ctx_save, ctx_save2; + oac_val32 dist0, dist1; + unsigned cm, cm2; + int nstart_bytes, nend_bytes, save_bytes; + unsigned char *bytes_buf; + oac_val16 w[2]; + oaci_compute_channel_weights(bandE[i], bandE[i + m->nbEBands], w); + /* Make a copy. */ + cm = x_cm|y_cm; + ec_save = *ec; + ctx_save = ctx; + OAC_COPY(X_save, X, N); + OAC_COPY(Y_save, Y, N); + /* Encode and round down. */ + ctx.theta_round = -1; + x_cm = oaci_quant_band_stereo(&ctx, X, Y, N, b, B, + effective_lowband != -1 ? norm + effective_lowband : NULL, LM, + last?NULL:norm + M*eBands[i] - norm_offset, lowband_scratch, cm); + dist0 = MULT16_32_Q15(w[0], oaci_celt_inner_prod_norm_shift(X_save, X, N, arch)) + MULT16_32_Q15(w[1], + oaci_celt_inner_prod_norm_shift(Y_save, Y, N, arch)); + + /* Save first result. */ + cm2 = x_cm; + ec_save2 = *ec; + ctx_save2 = ctx; + OAC_COPY(X_save2, X, N); + OAC_COPY(Y_save2, Y, N); + if (!last) + OAC_COPY(norm_save2, norm + M*eBands[i] - norm_offset, N); + nstart_bytes = ec_save.offs; + nend_bytes = ec_save.storage; + bytes_buf = ec_save.buf + nstart_bytes; + save_bytes = nend_bytes - nstart_bytes; + OAC_COPY(bytes_save, bytes_buf, save_bytes); + + /* Restore */ + *ec = ec_save; + ctx = ctx_save; + OAC_COPY(X, X_save, N); + OAC_COPY(Y, Y_save, N); + if (i == start + 1) + oaci_special_hybrid_folding(m, norm, norm2, start, M, dual_stereo); + /* Encode and round up. */ + ctx.theta_round = 1; + x_cm = oaci_quant_band_stereo(&ctx, X, Y, N, b, B, + effective_lowband != -1 ? norm + effective_lowband : NULL, LM, + last?NULL:norm + M*eBands[i] - norm_offset, lowband_scratch, cm); + dist1 = MULT16_32_Q15(w[0], oaci_celt_inner_prod_norm_shift(X_save, X, N, arch)) + MULT16_32_Q15(w[1], + oaci_celt_inner_prod_norm_shift(Y_save, Y, N, arch)); + if (dist0 >= dist1) { + x_cm = cm2; + *ec = ec_save2; + ctx = ctx_save2; + OAC_COPY(X, X_save2, N); + OAC_COPY(Y, Y_save2, N); + if (!last) + OAC_COPY(norm + M*eBands[i] - norm_offset, norm_save2, N); + OAC_COPY(bytes_buf, bytes_save, save_bytes); + } + } else { + ctx.theta_round = 0; + x_cm = oaci_quant_band_stereo(&ctx, X, Y, N, b, B, + effective_lowband != -1 ? norm + effective_lowband : NULL, LM, + last?NULL:norm + M*eBands[i] - norm_offset, lowband_scratch, x_cm|y_cm); + } } else { - ctx.theta_round = 0; - x_cm = quant_band_stereo(&ctx, X, Y, N, b, B, - effective_lowband != -1 ? norm+effective_lowband : NULL, LM, - last?NULL:norm+M*eBands[i]-norm_offset, lowband_scratch, x_cm|y_cm ARG_QEXT(ext_b) ARG_QEXT(cap)); + x_cm = oaci_quant_band(&ctx, X, N, b, B, + effective_lowband != -1 ? norm + effective_lowband : NULL, LM, + last?NULL:norm + M*eBands[i] - norm_offset, Q31ONE, lowband_scratch, x_cm|y_cm); } - } else { - x_cm = quant_band(&ctx, X, N, b, B, - effective_lowband != -1 ? norm+effective_lowband : NULL, LM, - last?NULL:norm+M*eBands[i]-norm_offset, Q31ONE, lowband_scratch, x_cm|y_cm ARG_QEXT(ext_b)); - } - y_cm = x_cm; - } - collapse_masks[i*C+0] = (unsigned char)x_cm; - collapse_masks[i*C+C-1] = (unsigned char)y_cm; - balance += pulses[i] + tell; - - /* Update the folding position only as long as we have 1 bit/sample depth. */ - update_lowband = b>(N< (N<nbEBands;i++) - { - int N; - N=(m->eBands[i+1]-m->eBands[i])<cache.caps[m->nbEBands*(2*LM+C-1)+i]+64)*C*N>>2; - } +void oaci_init_caps(const CELTMode *m, int *cap, int LM, int C) { + int i; + for (i = 0; i < m->nbEBands; i++) { + int N; + N = (m->eBands[i + 1] - m->eBands[i])<cache.caps[m->nbEBands*(2*LM + C - 1) + i] + 64)*C*N>>2; + } } -const char *opus_strerror(int error) -{ - static const char * const error_strings[8] = { - "success", - "invalid argument", - "buffer too small", - "internal error", - "corrupted stream", - "request not implemented", - "invalid state", - "memory allocation failed" - }; - if (error > 0 || error < -7) - return "unknown error"; - else - return error_strings[-error]; +const char *oac_strerror(int error) { + static const char * const error_strings[8] = { + "success", + "invalid argument", + "buffer too small", + "internal error", + "corrupted stream", + "request not implemented", + "invalid state", + "memory allocation failed" + }; + if (error > 0 || error < -7) + return "unknown error"; + else + return error_strings[-error]; } -const char *opus_get_version_string(void) -{ - return "libopus " PACKAGE_VERSION - /* Applications may rely on the presence of this substring in the version - string to determine if they have a fixed-point or floating-point build - at runtime. */ +const char *oac_get_version_string(void) { + return "liboac " PACKAGE_VERSION + /* Applications may rely on the presence of this substring in the version + string to determine if they have a fixed-point or floating-point build + at runtime. */ #ifdef FIXED_POINT - "-fixed" + "-fixed" #endif #ifdef FUZZING - "-fuzzing" + "-fuzzing" #endif - ; + ; } diff --git a/celt/celt.h b/celt/celt.h index c33e11ed0..bcfd52125 100644 --- a/celt/celt.h +++ b/celt/celt.h @@ -3,8 +3,8 @@ Copyright (c) 2008 Gregory Maxwell Written by Jean-Marc Valin and Gregory Maxwell */ /** - @file celt.h - @brief Contains all the functions for encoding and decoding audio + @file celt.h + @brief Contains all the functions for encoding and decoding audio */ /* @@ -30,57 +30,48 @@ 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. -*/ + */ #ifndef CELT_H #define CELT_H -#include "opus_types.h" -#include "opus_defines.h" -#include "opus_custom.h" +#include "oac_types.h" +#include "oac_defines.h" +#include "oac_custom.h" #include "entenc.h" #include "entdec.h" #include "arch.h" #include "kiss_fft.h" -#ifdef ENABLE_QEXT -#define ARG_QEXT(arg) , arg -#else -#define ARG_QEXT(arg) -#endif - - #ifdef ENABLE_DEEP_PLC -#include "lpcnet.h" +# include "lpcnet.h" #endif -#define CELTEncoder OpusCustomEncoder -#define CELTDecoder OpusCustomDecoder -#define CELTMode OpusCustomMode - -#define QEXT_EXTENSION_ID 124 +#define CELTEncoder OacCustomEncoder +#define CELTDecoder OacCustomDecoder +#define CELTMode OacCustomMode #define LEAK_BANDS 19 typedef struct { - int valid; - float tonality; - float tonality_slope; - float noisiness; - float activity; - float music_prob; - float music_prob_min; - float music_prob_max; - int bandwidth; - float activity_probability; - float max_pitch_ratio; - /* Store as Q6 char to save space. */ - unsigned char leak_boost[LEAK_BANDS]; + int valid; + float tonality; + float tonality_slope; + float noisiness; + float activity; + float music_prob; + float music_prob_min; + float music_prob_max; + int bandwidth; + float activity_probability; + float max_pitch_ratio; + /* Store as Q6 char to save space. */ + unsigned char leak_boost[LEAK_BANDS]; } AnalysisInfo; typedef struct { - int signalType; - int offset; + int signalType; + int offset; } SILKInfo; #define celt_check_mode_ptr_ptr(ptr) ((ptr) + ((ptr) - (const CELTMode**)(ptr))) @@ -100,175 +91,174 @@ typedef struct { 1=Short term interframe prediction allowed 2=Long term prediction allowed */ -#define CELT_SET_PREDICTION(x) CELT_SET_PREDICTION_REQUEST, opus_check_int(x) +#define CELT_SET_PREDICTION(x) CELT_SET_PREDICTION_REQUEST, oac_check_int(x) #define CELT_SET_INPUT_CLIPPING_REQUEST 10004 -#define CELT_SET_INPUT_CLIPPING(x) CELT_SET_INPUT_CLIPPING_REQUEST, opus_check_int(x) +#define CELT_SET_INPUT_CLIPPING(x) CELT_SET_INPUT_CLIPPING_REQUEST, oac_check_int(x) #define CELT_GET_AND_CLEAR_ERROR_REQUEST 10007 -#define CELT_GET_AND_CLEAR_ERROR(x) CELT_GET_AND_CLEAR_ERROR_REQUEST, opus_check_int_ptr(x) +#define CELT_GET_AND_CLEAR_ERROR(x) CELT_GET_AND_CLEAR_ERROR_REQUEST, oac_check_int_ptr(x) #define CELT_SET_CHANNELS_REQUEST 10008 -#define CELT_SET_CHANNELS(x) CELT_SET_CHANNELS_REQUEST, opus_check_int(x) +#define CELT_SET_CHANNELS(x) CELT_SET_CHANNELS_REQUEST, oac_check_int(x) /* Internal */ #define CELT_SET_START_BAND_REQUEST 10010 -#define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, opus_check_int(x) +#define CELT_SET_START_BAND(x) CELT_SET_START_BAND_REQUEST, oac_check_int(x) #define CELT_SET_END_BAND_REQUEST 10012 -#define CELT_SET_END_BAND(x) CELT_SET_END_BAND_REQUEST, opus_check_int(x) +#define CELT_SET_END_BAND(x) CELT_SET_END_BAND_REQUEST, oac_check_int(x) #define CELT_GET_MODE_REQUEST 10015 /** Get the CELTMode used by an encoder or decoder */ #define CELT_GET_MODE(x) CELT_GET_MODE_REQUEST, celt_check_mode_ptr_ptr(x) #define CELT_SET_SIGNALLING_REQUEST 10016 -#define CELT_SET_SIGNALLING(x) CELT_SET_SIGNALLING_REQUEST, opus_check_int(x) +#define CELT_SET_SIGNALLING(x) CELT_SET_SIGNALLING_REQUEST, oac_check_int(x) #define CELT_SET_TONALITY_REQUEST 10018 -#define CELT_SET_TONALITY(x) CELT_SET_TONALITY_REQUEST, opus_check_int(x) +#define CELT_SET_TONALITY(x) CELT_SET_TONALITY_REQUEST, oac_check_int(x) #define CELT_SET_TONALITY_SLOPE_REQUEST 10020 -#define CELT_SET_TONALITY_SLOPE(x) CELT_SET_TONALITY_SLOPE_REQUEST, opus_check_int(x) +#define CELT_SET_TONALITY_SLOPE(x) CELT_SET_TONALITY_SLOPE_REQUEST, oac_check_int(x) #define CELT_SET_ANALYSIS_REQUEST 10022 #define CELT_SET_ANALYSIS(x) CELT_SET_ANALYSIS_REQUEST, celt_check_analysis_ptr(x) -#define OPUS_SET_LFE_REQUEST 10024 -#define OPUS_SET_LFE(x) OPUS_SET_LFE_REQUEST, opus_check_int(x) +#define OAC_SET_LFE_REQUEST 10024 +#define OAC_SET_LFE(x) OAC_SET_LFE_REQUEST, oac_check_int(x) -#define OPUS_SET_ENERGY_MASK_REQUEST 10026 -#define OPUS_SET_ENERGY_MASK(x) OPUS_SET_ENERGY_MASK_REQUEST, celt_check_glog_ptr(x) +#define OAC_SET_ENERGY_MASK_REQUEST 10026 +#define OAC_SET_ENERGY_MASK(x) OAC_SET_ENERGY_MASK_REQUEST, celt_check_glog_ptr(x) #define CELT_SET_SILK_INFO_REQUEST 10028 #define CELT_SET_SILK_INFO(x) CELT_SET_SILK_INFO_REQUEST, celt_check_silkinfo_ptr(x) -static OPUS_INLINE opus_int32 bits_to_bitrate(opus_int32 bits, opus_int32 Fs, opus_int32 frame_size) { - return bits*(6*Fs/frame_size)/6; +static OAC_INLINE oac_int32 oaci_bits_to_bitrate(oac_int32 bits, oac_int32 Fs, oac_int32 frame_size) { + return bits*(6*Fs/frame_size)/6; } -static OPUS_INLINE opus_int32 bitrate_to_bits(opus_int32 bitrate, opus_int32 Fs, opus_int32 frame_size) { - return bitrate*6/(6*Fs/frame_size); +static OAC_INLINE oac_int32 oaci_bitrate_to_bits(oac_int32 bitrate, oac_int32 Fs, oac_int32 frame_size) { + return bitrate*6/(6*Fs/frame_size); } /* Encoder stuff */ -int celt_encoder_get_size(int channels); +int oaci_celt_encoder_get_size(int channels); -int celt_encode_with_ec(OpusCustomEncoder * OPUS_RESTRICT st, const opus_res * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc); +int oaci_celt_encode_with_ec(OacCustomEncoder * OAC_RESTRICT st, const oac_res * pcm, int frame_size, + unsigned char *compressed, int nbCompressedBytes, ec_enc *enc); -int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels, - int arch); +int oaci_celt_encoder_init(CELTEncoder *st, oac_int32 sampling_rate, int channels, + int arch); /* Decoder stuff */ -int celt_decoder_get_size(int channels); +int oaci_celt_decoder_get_size(int channels); -int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels); +int oaci_celt_decoder_init(CELTDecoder *st, oac_int32 sampling_rate, int channels); -int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, - int len, opus_res * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec, int accum +int oaci_celt_decode_with_ec_dred(CELTDecoder * OAC_RESTRICT st, const unsigned char *data, + int len, oac_res * OAC_RESTRICT pcm, int frame_size, ec_dec *dec, int accum #ifdef ENABLE_DEEP_PLC - ,LPCNetPLCState *lpcnet + , LPCNetPLCState *lpcnet #endif - ARG_QEXT(const unsigned char *qext_payload) ARG_QEXT(int qext_payload_len) - ); + ); -int celt_decode_with_ec(OpusCustomDecoder * OPUS_RESTRICT st, const unsigned char *data, - int len, opus_res * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec, int accum); +int oaci_celt_decode_with_ec(OacCustomDecoder * OAC_RESTRICT st, const unsigned char *data, + int len, oac_res * OAC_RESTRICT pcm, int frame_size, ec_dec *dec, int accum); -#define celt_encoder_ctl opus_custom_encoder_ctl -#define celt_decoder_ctl opus_custom_decoder_ctl +#define celt_encoder_ctl oac_custom_encoder_ctl +#define celt_decoder_ctl oac_custom_decoder_ctl -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -#define OPUS_CUSTOM_NOSTATIC +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) +# define OAC_CUSTOM_NOSTATIC #else -#define OPUS_CUSTOM_NOSTATIC static OPUS_INLINE +# define OAC_CUSTOM_NOSTATIC static OAC_INLINE #endif -static const unsigned char trim_icdf[11] = {126, 124, 119, 109, 87, 41, 19, 9, 4, 2, 0}; -/* Probs: NONE: 21.875%, LIGHT: 6.25%, NORMAL: 65.625%, AGGRESSIVE: 6.25% */ -static const unsigned char spread_icdf[4] = {25, 23, 2, 0}; +static const unsigned char trim_icdf[11] = {119, 109, 85, 53, 30, 14, 6, 3, 2, 1, 0}; +/* Probs: NONE: 6.25%, LIGHT: 6.25%, NORMAL: 50%, AGGRESSIVE: 37.5% */ +static const unsigned char spread_icdf[4] = {30, 28, 12, 0}; -static const unsigned char tapset_icdf[3]={2,1,0}; +static const unsigned char tapset_icdf[3] = {3, 2, 0}; -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -static const unsigned char toOpusTable[20] = { - 0xE0, 0xE8, 0xF0, 0xF8, - 0xC0, 0xC8, 0xD0, 0xD8, - 0xA0, 0xA8, 0xB0, 0xB8, - 0x00, 0x00, 0x00, 0x00, - 0x80, 0x88, 0x90, 0x98, +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) +static const unsigned char toOacTable[20] = { + 0xE0, 0xE8, 0xF0, 0xF8, + 0xC0, 0xC8, 0xD0, 0xD8, + 0xA0, 0xA8, 0xB0, 0xB8, + 0x00, 0x00, 0x00, 0x00, + 0x80, 0x88, 0x90, 0x98, }; -static const unsigned char fromOpusTable[16] = { - 0x80, 0x88, 0x90, 0x98, - 0x40, 0x48, 0x50, 0x58, - 0x20, 0x28, 0x30, 0x38, - 0x00, 0x08, 0x10, 0x18 +static const unsigned char fromOacTable[16] = { + 0x80, 0x88, 0x90, 0x98, + 0x40, 0x48, 0x50, 0x58, + 0x20, 0x28, 0x30, 0x38, + 0x00, 0x08, 0x10, 0x18 }; -static OPUS_INLINE int toOpus(unsigned char c) -{ - int ret=0; - if (c<0xA0) - ret = toOpusTable[c>>3]; - if (ret == 0) - return -1; - else - return ret|(c&0x7); +static OAC_INLINE int oaci_toOac(unsigned char c) { + int ret = 0; + if (c < 0xA0) + ret = toOacTable[c>>3]; + if (ret == 0) + return -1; + else + return ret|(c&0x7); } -static OPUS_INLINE int fromOpus(unsigned char c) -{ - if (c<0x80) - return -1; - else - return fromOpusTable[(c>>3)-16] | (c&0x7); +static OAC_INLINE int oaci_fromOac(unsigned char c) { + if (c < 0x80) + return -1; + else + return fromOacTable[(c>>3) - 16]|(c&0x7); } #endif /* CUSTOM_MODES */ #define COMBFILTER_MAXPERIOD 1024 #define COMBFILTER_MINPERIOD 15 -extern const signed char tf_select_table[4][8]; +extern const signed char oaci_tf_select_table[4][8]; #if defined(ENABLE_HARDENING) || defined(ENABLE_ASSERTIONS) -void validate_celt_decoder(CELTDecoder *st); -#define VALIDATE_CELT_DECODER(st) validate_celt_decoder(st) +void oaci_validate_celt_decoder(CELTDecoder *st); +# define VALIDATE_CELT_DECODER(st) oaci_validate_celt_decoder(st) #else -#define VALIDATE_CELT_DECODER(st) +# define VALIDATE_CELT_DECODER(st) #endif -int resampling_factor(opus_int32 rate); +int oaci_resampling_factor(oac_int32 rate); -void celt_preemphasis(const opus_res * OPUS_RESTRICT pcmp, celt_sig * OPUS_RESTRICT inp, - int N, int CC, int upsample, const opus_val16 *coef, celt_sig *mem, int clip); +void oaci_celt_preemphasis(const oac_res * OAC_RESTRICT pcmp, celt_sig * OAC_RESTRICT inp, + int N, int CC, int upsample, const oac_val16 *coef, celt_sig *mem, int clip); -void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, - opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, - const celt_coef *window, int overlap, int arch); +void oaci_comb_filter(oac_val32 *y, oac_val32 *x, int T0, int T1, int N, + oac_val16 g0, oac_val16 g1, int tapset0, int tapset1, + const celt_coef *window, int overlap, int arch); -void init_caps(const CELTMode *m,int *cap,int LM,int C); +void oaci_init_caps(const CELTMode *m, int *cap, int LM, int C); #ifdef RESYNTH -void deemphasis(celt_sig *in[], opus_res *pcm, int N, int C, int downsample, const opus_val16 *coef, celt_sig *mem, int accum); -void celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[], - celt_glog *oldBandE, int start, int effEnd, int C, int CC, int isTransient, - int LM, int downsample, int silence, int arch ARG_QEXT(const CELTMode *qext_mode) ARG_QEXT(const celt_glog *qext_bandLogE) ARG_QEXT(int qext_end)); +void oaci_deemphasis(celt_sig *in[], oac_res *pcm, int N, int C, int downsample, const oac_val16 *coef, celt_sig *mem, + int accum); +void oaci_celt_synthesis(const CELTMode *mode, celt_norm *X, celt_sig * out_syn[], + celt_glog *oldBandE, int start, int effEnd, int C, int CC, int isTransient, + int LM, int downsample, int silence, int arch); #endif #ifdef ENABLE_QEXT -#define QEXT_SCALE(x) ((qext_scale)*(x)) -#define QEXT_SCALE2(x, qext_scale) ((qext_scale)*(x)) +# define QEXT_SCALE(x) ((qext_scale)*(x)) +# define QEXT_SCALE2(x, qext_scale) ((qext_scale)*(x)) #else -#define QEXT_SCALE(x) (x) -#define QEXT_SCALE2(x, qext_scale) (x) +# define QEXT_SCALE(x) (x) +# define QEXT_SCALE2(x, qext_scale) (x) #endif #endif /* CELT_H */ diff --git a/celt/celt_decoder.c b/celt/celt_decoder.c index aba91c12a..e30f08af3 100644 --- a/celt/celt_decoder.c +++ b/celt/celt_decoder.c @@ -25,10 +25,10 @@ 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" +# include "config.h" #endif #define CELT_DECODER_C @@ -52,8 +52,8 @@ #include "vq.h" #ifdef ENABLE_DEEP_PLC -#include "lpcnet.h" -#include "lpcnet_private.h" +# include "lpcnet.h" +# include "lpcnet_private.h" #endif /* The maximum pitch lag to allow in the pitch-based PLC. It's possible to save @@ -82,551 +82,486 @@ #define PLC_UPDATE_SAMPLES (PLC_UPDATE_FRAMES*FRAME_SIZE) /** Decoder state - @brief Decoder state + @brief Decoder state */ -struct OpusCustomDecoder { - const OpusCustomMode *mode; - int overlap; - int channels; - int stream_channels; - - int downsample; - int start, end; - int signalling; - int disable_inv; - int complexity; - int arch; +struct OacCustomDecoder { + const OacCustomMode *mode; + int overlap; + int channels; + int stream_channels; + + int downsample; + int start, end; + int signalling; + int disable_inv; + int complexity; + int arch; #ifdef ENABLE_QEXT - int qext_scale; + int qext_scale; #endif - /* Everything beyond this point gets cleared on a reset */ + /* Everything beyond this point gets cleared on a reset */ #define DECODER_RESET_START rng - opus_uint32 rng; - int error; - int last_pitch_index; - int loss_duration; - int plc_duration; - int last_frame_type; - int skip_plc; - int postfilter_period; - int postfilter_period_old; - opus_val16 postfilter_gain; - opus_val16 postfilter_gain_old; - int postfilter_tapset; - int postfilter_tapset_old; - int prefilter_and_fold; - - celt_sig preemph_memD[2]; + oac_uint32 rng; + int error; + int last_pitch_index; + int loss_duration; + int plc_duration; + int last_frame_type; + int skip_plc; + int postfilter_period; + int postfilter_period_old; + oac_val16 postfilter_gain; + oac_val16 postfilter_gain_old; + int postfilter_tapset; + int postfilter_tapset_old; + int prefilter_and_fold; + + celt_sig preemph_memD[2]; #ifdef ENABLE_DEEP_PLC - opus_int16 plc_pcm[PLC_UPDATE_SAMPLES]; - int plc_fill; - float plc_preemphasis_mem; -#endif - -#ifdef ENABLE_QEXT - celt_glog qext_oldBandE[2*NB_QEXT_BANDS]; + oac_int16 plc_pcm[PLC_UPDATE_SAMPLES]; + int plc_fill; + float plc_preemphasis_mem; #endif - celt_sig _decode_mem[1]; /* Size = channels*(DECODE_BUFFER_SIZE+mode->overlap) */ - /* celt_glog oldEBands[], Size = 2*mode->nbEBands */ - /* celt_glog oldLogE[], Size = 2*mode->nbEBands */ - /* celt_glog oldLogE2[], Size = 2*mode->nbEBands */ - /* celt_glog backgroundLogE[], Size = 2*mode->nbEBands */ - /* opus_val16 lpc[], Size = channels*CELT_LPC_ORDER */ + celt_sig _decode_mem[1]; /* Size = channels*(DECODE_BUFFER_SIZE+mode->overlap) */ + /* celt_glog oldEBands[], Size = 2*mode->nbEBands */ + /* celt_glog oldLogE[], Size = 2*mode->nbEBands */ + /* celt_glog oldLogE2[], Size = 2*mode->nbEBands */ + /* celt_glog backgroundLogE[], Size = 2*mode->nbEBands */ + /* oac_val16 lpc[], Size = channels*CELT_LPC_ORDER */ }; #if defined(ENABLE_HARDENING) || defined(ENABLE_ASSERTIONS) /* Make basic checks on the CELT state to ensure we don't end up writing all over memory. */ -void validate_celt_decoder(CELTDecoder *st) -{ -#if !defined(CUSTOM_MODES) && !defined(ENABLE_OPUS_CUSTOM_API) && !defined(ENABLE_QEXT) - celt_assert(st->mode == opus_custom_mode_create(48000, 960, NULL)); - celt_assert(st->overlap == 120); - celt_assert(st->end <= 21); -#else +void oaci_validate_celt_decoder(CELTDecoder *st) { +# if !defined(CUSTOM_MODES) && !defined(ENABLE_OAC_CUSTOM_API) && !defined(ENABLE_QEXT) + celt_assert(st->mode == oac_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" + though Oac 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); -#ifdef OPUS_ARCHMASK - celt_assert(st->arch >= 0); - celt_assert(st->arch <= OPUS_ARCHMASK); -#endif -#ifndef ENABLE_QEXT - celt_assert(st->last_pitch_index <= PLC_PITCH_LAG_MAX); - celt_assert(st->last_pitch_index >= PLC_PITCH_LAG_MIN || st->last_pitch_index == 0); -#endif - celt_assert(st->postfilter_period < MAX_PERIOD); - celt_assert(st->postfilter_period >= COMBFILTER_MINPERIOD || st->postfilter_period == 0); - celt_assert(st->postfilter_period_old < MAX_PERIOD); - celt_assert(st->postfilter_period_old >= COMBFILTER_MINPERIOD || st->postfilter_period_old == 0); - celt_assert(st->postfilter_tapset <= 2); - celt_assert(st->postfilter_tapset >= 0); - celt_assert(st->postfilter_tapset_old <= 2); - celt_assert(st->postfilter_tapset_old >= 0); + 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); +# ifdef OAC_ARCHMASK + celt_assert(st->arch >= 0); + celt_assert(st->arch <= OAC_ARCHMASK); +# endif +# ifndef ENABLE_QEXT + celt_assert(st->last_pitch_index <= PLC_PITCH_LAG_MAX); + celt_assert(st->last_pitch_index >= PLC_PITCH_LAG_MIN || st->last_pitch_index == 0); +# endif + celt_assert(st->postfilter_period < MAX_PERIOD); + celt_assert(st->postfilter_period >= COMBFILTER_MINPERIOD || st->postfilter_period == 0); + celt_assert(st->postfilter_period_old < MAX_PERIOD); + celt_assert(st->postfilter_period_old >= COMBFILTER_MINPERIOD || st->postfilter_period_old == 0); + celt_assert(st->postfilter_tapset <= 2); + celt_assert(st->postfilter_tapset >= 0); + celt_assert(st->postfilter_tapset_old <= 2); + celt_assert(st->postfilter_tapset_old >= 0); } #endif -int celt_decoder_get_size(int channels) -{ +int oaci_celt_decoder_get_size(int channels) { #ifdef ENABLE_QEXT - const CELTMode *mode = opus_custom_mode_create(96000, 960, NULL); + const CELTMode *mode = oac_custom_mode_create(96000, 960, NULL); #else - const CELTMode *mode = opus_custom_mode_create(48000, 960, NULL); + const CELTMode *mode = oac_custom_mode_create(48000, 960, NULL); #endif - return opus_custom_decoder_get_size(mode, channels); + return oac_custom_decoder_get_size(mode, channels); } -OPUS_CUSTOM_NOSTATIC int opus_custom_decoder_get_size(const CELTMode *mode, int channels) -{ - int size; +OAC_CUSTOM_NOSTATIC int oac_custom_decoder_get_size(const CELTMode *mode, int channels) { + int size; #ifdef ENABLE_QEXT - int qext_scale; - if (mode->Fs == 96000 && (mode->shortMdctSize==240 || mode->shortMdctSize==180)) { - qext_scale = 2; - } else qext_scale = 1; + int qext_scale; + if (mode->Fs == 96000 && (mode->shortMdctSize == 240 || mode->shortMdctSize == 180)) { + qext_scale = 2; + } else qext_scale = 1; #endif - size = sizeof(struct CELTDecoder) - + (channels*(QEXT_SCALE(DECODE_BUFFER_SIZE)+mode->overlap)-1)*sizeof(celt_sig) - + 4*2*mode->nbEBands*sizeof(celt_glog) - + channels*CELT_LPC_ORDER*sizeof(opus_val16); - return size; + size = sizeof(struct CELTDecoder) + + (channels*(QEXT_SCALE(DECODE_BUFFER_SIZE) + mode->overlap) - 1)*sizeof(celt_sig) + + 4*2*mode->nbEBands*sizeof(celt_glog) + + channels*CELT_LPC_ORDER*sizeof(oac_val16); + return size; } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -CELTDecoder *opus_custom_decoder_create(const CELTMode *mode, int channels, int *error) -{ - int ret; - CELTDecoder *st = (CELTDecoder *)opus_alloc(opus_custom_decoder_get_size(mode, channels)); - ret = opus_custom_decoder_init(st, mode, channels); - if (ret != OPUS_OK) - { - opus_custom_decoder_destroy(st); - st = NULL; - } - if (error) - *error = ret; - return st; +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) +CELTDecoder *oac_custom_decoder_create(const CELTMode *mode, int channels, int *error) { + int ret; + CELTDecoder *st = (CELTDecoder *)oac_alloc(oac_custom_decoder_get_size(mode, channels)); + ret = oac_custom_decoder_init(st, mode, channels); + if (ret != OAC_OK) { + oac_custom_decoder_destroy(st); + st = NULL; + } + if (error) + *error = ret; + return st; } #endif /* CUSTOM_MODES */ -int celt_decoder_init(CELTDecoder *st, opus_int32 sampling_rate, int channels) -{ - int ret; +int oaci_celt_decoder_init(CELTDecoder *st, oac_int32 sampling_rate, int channels) { + int ret; #ifdef ENABLE_QEXT - if (sampling_rate == 96000) { - return opus_custom_decoder_init(st, opus_custom_mode_create(96000, 960, NULL), channels); - } + if (sampling_rate == 96000) { + return oac_custom_decoder_init(st, oac_custom_mode_create(96000, 960, NULL), channels); + } #endif - ret = opus_custom_decoder_init(st, opus_custom_mode_create(48000, 960, NULL), channels); - if (ret != OPUS_OK) - return ret; - st->downsample = resampling_factor(sampling_rate); - if (st->downsample==0) - return OPUS_BAD_ARG; - else - return OPUS_OK; + ret = oac_custom_decoder_init(st, oac_custom_mode_create(48000, 960, NULL), channels); + if (ret != OAC_OK) + return ret; + st->downsample = oaci_resampling_factor(sampling_rate); + if (st->downsample == 0) + return OAC_BAD_ARG; + else + return OAC_OK; } -OPUS_CUSTOM_NOSTATIC int opus_custom_decoder_init(CELTDecoder *st, const CELTMode *mode, int channels) -{ - if (channels < 0 || channels > 2) - return OPUS_BAD_ARG; +OAC_CUSTOM_NOSTATIC int oac_custom_decoder_init(CELTDecoder *st, const CELTMode *mode, int channels) { + if (channels < 0 || channels > 2) + return OAC_BAD_ARG; - if (st==NULL) - return OPUS_ALLOC_FAIL; + if (st == NULL) + return OAC_ALLOC_FAIL; - OPUS_CLEAR((char*)st, opus_custom_decoder_get_size(mode, channels)); + OAC_CLEAR((char*)st, oac_custom_decoder_get_size(mode, channels)); - st->mode = mode; - st->overlap = mode->overlap; - st->stream_channels = st->channels = channels; + st->mode = mode; + st->overlap = mode->overlap; + st->stream_channels = st->channels = channels; - st->downsample = 1; - st->start = 0; - st->end = st->mode->effEBands; - st->signalling = 1; -#ifndef DISABLE_UPDATE_DRAFT - st->disable_inv = channels == 1; -#else - st->disable_inv = 0; -#endif - st->arch = opus_select_arch(); + st->downsample = 1; + st->start = 0; + st->end = st->mode->effEBands; + st->signalling = 1; + st->disable_inv = channels == 1; + st->arch = oac_select_arch(); #ifdef ENABLE_QEXT - if (st->mode->Fs == 96000 && (mode->shortMdctSize==240 || mode->shortMdctSize==180)) st->qext_scale = 2; - else st->qext_scale = 1; + if (st->mode->Fs == 96000 && (mode->shortMdctSize == 240 || mode->shortMdctSize == 180)) st->qext_scale = 2; + else st->qext_scale = 1; #endif - opus_custom_decoder_ctl(st, OPUS_RESET_STATE); + oac_custom_decoder_ctl(st, OAC_RESET_STATE); - return OPUS_OK; + return OAC_OK; } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -void opus_custom_decoder_destroy(CELTDecoder *st) -{ - opus_free(st); +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) +void oac_custom_decoder_destroy(CELTDecoder *st) { + oac_free(st); } #endif /* CUSTOM_MODES */ -#if !defined(CUSTOM_MODES) && !defined(ENABLE_OPUS_CUSTOM_API) && !defined(ENABLE_QEXT) +#if !defined(CUSTOM_MODES) && !defined(ENABLE_OAC_CUSTOM_API) && !defined(ENABLE_QEXT) /* Special case for stereo with no downsampling and no accumulation. This is quite common and we can make it faster by processing both channels in the same loop, reducing overhead due to the dependency loop in the IIR filter. */ -static void deemphasis_stereo_simple(celt_sig *in[], opus_res *pcm, int N, const opus_val16 coef0, - celt_sig *mem) -{ - celt_sig * OPUS_RESTRICT x0; - celt_sig * OPUS_RESTRICT x1; - celt_sig m0, m1; - int j; - x0=in[0]; - x1=in[1]; - m0 = mem[0]; - m1 = mem[1]; - for (j=0;j1) - { - /* Shortcut for the standard (non-custom modes) case */ - for (j=0;j 1) { + /* Shortcut for the standard (non-custom modes) case */ + for (j = 0; j < N; j++) { + celt_sig tmp = SATURATE(x[j] + VERY_SMALL + m, SIG_SAT); + m = MULT16_32_Q15(coef0, tmp); + scratch[j] = tmp; } - } else - { - for (j=0;joverlap; - nbEBands = mode->nbEBands; - N = mode->shortMdctSize<Fs != 96000) qext_end=2; -#endif - - if (isTransient) - { - B = M; - NB = mode->shortMdctSize; - shift = mode->maxLM; - } else { - B = 1; - NB = mode->shortMdctSize<maxLM-LM; - } - - if (CC==2&&C==1) - { - /* Copying a mono streams to two channels */ - celt_sig *freq2; - denormalise_bands(mode, X, freq, oldBandE, start, effEnd, M, + int silence, int arch) { + int c, i; + int M; + int b; + int B; + int N, NB; + int shift; + int nbEBands; + int overlap; + VARDECL(celt_sig, freq); + SAVE_STACK; + + overlap = mode->overlap; + nbEBands = mode->nbEBands; + N = mode->shortMdctSize<shortMdctSize; + shift = mode->maxLM; + } else { + B = 1; + NB = mode->shortMdctSize<maxLM - LM; + } + + if (CC == 2 && C == 1) { + /* Copying a mono streams to two channels */ + celt_sig *freq2; + oaci_denormalise_bands(mode, X, freq, oldBandE, start, effEnd, M, downsample, silence); -#ifdef ENABLE_QEXT - if (qext_mode) - denormalise_bands(qext_mode, X, freq, qext_bandLogE, 0, qext_end, M, - downsample, silence); -#endif - /* Store a temporary copy in the output buffer because the IMDCT destroys its input. */ - freq2 = out_syn[1]+overlap/2; - OPUS_COPY(freq2, freq, N); - for (b=0;bmdct, &freq2[b], out_syn[0]+NB*b, mode->window, overlap, shift, B, arch); - for (b=0;bmdct, &freq[b], out_syn[1]+NB*b, mode->window, overlap, shift, B, arch); - } else if (CC==1&&C==2) - { - /* Downmixing a stereo stream to mono */ - celt_sig *freq2; - freq2 = out_syn[0]+overlap/2; - denormalise_bands(mode, X, freq, oldBandE, start, effEnd, M, + /* Store a temporary copy in the output buffer because the IMDCT destroys its input. */ + freq2 = out_syn[1] + overlap/2; + OAC_COPY(freq2, freq, N); + for (b = 0; b < B; b++) + oaci_clt_mdct_backward(&mode->mdct, &freq2[b], out_syn[0] + NB*b, mode->window, overlap, shift, B, arch); + for (b = 0; b < B; b++) + oaci_clt_mdct_backward(&mode->mdct, &freq[b], out_syn[1] + NB*b, mode->window, overlap, shift, B, arch); + } else if (CC == 1 && C == 2) { + /* Downmixing a stereo stream to mono */ + celt_sig *freq2; + freq2 = out_syn[0] + overlap/2; + oaci_denormalise_bands(mode, X, freq, oldBandE, start, effEnd, M, downsample, silence); - /* Use the output buffer as temp array before downmixing. */ - denormalise_bands(mode, X+N, freq2, oldBandE+nbEBands, start, effEnd, M, + /* Use the output buffer as temp array before downmixing. */ + oaci_denormalise_bands(mode, X + N, freq2, oldBandE + nbEBands, start, effEnd, M, downsample, silence); -#ifdef ENABLE_QEXT - if (qext_mode) - { - denormalise_bands(qext_mode, X, freq, qext_bandLogE, 0, qext_end, M, - downsample, silence); - denormalise_bands(qext_mode, X+N, freq2, qext_bandLogE+NB_QEXT_BANDS, 0, qext_end, M, - downsample, silence); - } -#endif - for (i=0;imdct, &freq[b], out_syn[0]+NB*b, mode->window, overlap, shift, B, arch); - } else { - /* Normal case (mono or stereo) */ - c=0; do { - denormalise_bands(mode, X+c*N, freq, oldBandE+c*nbEBands, start, effEnd, M, + for (i = 0; i < N; i++) + freq[i] = ADD32(HALF32(freq[i]), HALF32(freq2[i])); + for (b = 0; b < B; b++) + oaci_clt_mdct_backward(&mode->mdct, &freq[b], out_syn[0] + NB*b, mode->window, overlap, shift, B, arch); + } else { + /* Normal case (mono or stereo) */ + c = 0; do { + oaci_denormalise_bands(mode, X + c*N, freq, oldBandE + c*nbEBands, start, effEnd, M, downsample, silence); -#ifdef ENABLE_QEXT - if (qext_mode) - denormalise_bands(qext_mode, X+c*N, freq, qext_bandLogE+c*NB_QEXT_BANDS, 0, qext_end, M, - downsample, silence); -#endif - for (b=0;bmdct, &freq[b], out_syn[c]+NB*b, mode->window, overlap, shift, B, arch); - } while (++cmdct, &freq[b], out_syn[c] + NB*b, mode->window, overlap, shift, B, arch); + } while (++c < CC); + } + /* Saturate IMDCT output so that we can't overflow in the pitch postfilter + or in the */ + c = 0; do { + for (i = 0; i < N; i++) + out_syn[c][i] = SATURATE(out_syn[c][i], SIG_SAT); + } while (++c < CC); + RESTORE_STACK; } -static void tf_decode(int start, int end, int isTransient, int *tf_res, int LM, ec_dec *dec) -{ - int i, curr, tf_select; - int tf_select_rsv; - int tf_changed; - int logp; - opus_uint32 budget; - opus_uint32 tell; - - budget = dec->storage*8; - tell = ec_tell(dec); - logp = isTransient ? 2 : 4; - tf_select_rsv = LM>0 && tell+logp+1<=budget; - budget -= tf_select_rsv; - tf_changed = curr = 0; - for (i=start;istorage*8; + tell = oaci_ec_tell(dec); + logp = isTransient ? 2 : 4; + tf_select_rsv = LM > 0 && tell + logp + 1 <= budget; + budget -= tf_select_rsv; + tf_changed = curr = 0; + for (i = start; i < end; i++) { + if (tell + logp <= budget) { + curr ^= oaci_ec_dec_bit_logp(dec, logp); + tell = oaci_ec_tell(dec); + tf_changed |= curr; + } + tf_res[i] = curr; + logp = isTransient ? 4 : 5; + } + tf_select = 0; + if (tf_select_rsv + && oaci_tf_select_table[LM][4*isTransient + 0 + tf_changed] != + oaci_tf_select_table[LM][4*isTransient + 2 + tf_changed]) { + tf_select = oaci_ec_dec_bit_logp(dec, 1); + } + for (i = start; i < end; i++) { + tf_res[i] = oaci_tf_select_table[LM][4*isTransient + 2*tf_select + tf_res[i]]; + } } -static int celt_plc_pitch_search(CELTDecoder *st, celt_sig *decode_mem[2], int C, int arch) -{ - int pitch_index; +static int oaci_celt_plc_pitch_search(CELTDecoder *st, celt_sig *decode_mem[2], int C, int arch) { + int pitch_index; #ifdef ENABLE_QEXT - int qext_scale; + int qext_scale; #endif - VARDECL( opus_val16, lp_pitch_buf ); - SAVE_STACK; + VARDECL( oac_val16, lp_pitch_buf ); + SAVE_STACK; #ifdef ENABLE_QEXT - qext_scale = st->qext_scale; + qext_scale = st->qext_scale; #else - (void)st; + (void)st; #endif - ALLOC( lp_pitch_buf, DECODE_BUFFER_SIZE>>1, opus_val16 ); - pitch_downsample(decode_mem, lp_pitch_buf, + ALLOC( lp_pitch_buf, DECODE_BUFFER_SIZE>>1, oac_val16 ); + oaci_pitch_downsample(decode_mem, lp_pitch_buf, DECODE_BUFFER_SIZE>>1, C, QEXT_SCALE(2), arch); - pitch_search(lp_pitch_buf+(PLC_PITCH_LAG_MAX>>1), lp_pitch_buf, - DECODE_BUFFER_SIZE-PLC_PITCH_LAG_MAX, - PLC_PITCH_LAG_MAX-PLC_PITCH_LAG_MIN, &pitch_index, arch); - pitch_index = PLC_PITCH_LAG_MAX-pitch_index; - RESTORE_STACK; - return QEXT_SCALE(pitch_index); + oaci_pitch_search(lp_pitch_buf + (PLC_PITCH_LAG_MAX>>1), lp_pitch_buf, + DECODE_BUFFER_SIZE - PLC_PITCH_LAG_MAX, + PLC_PITCH_LAG_MAX - PLC_PITCH_LAG_MIN, &pitch_index, arch); + pitch_index = PLC_PITCH_LAG_MAX - pitch_index; + RESTORE_STACK; + return QEXT_SCALE(pitch_index); } -static void prefilter_and_fold(CELTDecoder * OPUS_RESTRICT st, int N) -{ - int c; - int CC; - int i; - int overlap; - celt_sig *decode_mem[2]; - const OpusCustomMode *mode; - int decode_buffer_size; +static void oaci_prefilter_and_fold(CELTDecoder * OAC_RESTRICT st, int N) { + int c; + int CC; + int i; + int overlap; + celt_sig *decode_mem[2]; + const OacCustomMode *mode; + int decode_buffer_size; #ifdef ENABLE_QEXT - int qext_scale; + int qext_scale; #endif - VARDECL(opus_val32, etmp); - SAVE_STACK + VARDECL(oac_val32, etmp); + SAVE_STACK #ifdef ENABLE_QEXT - qext_scale = st->qext_scale; + qext_scale = st->qext_scale; #endif - decode_buffer_size = QEXT_SCALE(DECODE_BUFFER_SIZE); - mode = st->mode; - overlap = st->overlap; - CC = st->channels; - ALLOC(etmp, overlap, opus_val32); - c=0; do { - decode_mem[c] = st->_decode_mem + c*(decode_buffer_size+overlap); - } while (++cmode; + overlap = st->overlap; + CC = st->channels; + ALLOC(etmp, overlap, oac_val32); + c = 0; do { + decode_mem[c] = st->_decode_mem + c*(decode_buffer_size + overlap); + } while (++c < CC); + + c = 0; do { + /* Apply the pre-filter to the MDCT overlap for the next frame because + the post-filter will be re-applied in the decoder after the MDCT + overlap. */ + oaci_comb_filter(etmp, decode_mem[c] + decode_buffer_size - N, st->postfilter_period_old, st->postfilter_period, overlap, -st->postfilter_gain_old, -st->postfilter_gain, st->postfilter_tapset_old, st->postfilter_tapset, NULL, 0, st->arch); - /* Simulate TDAC on the concealed audio so that it blends with the - MDCT of the next frame. */ - for (i=0;iwindow[i]), etmp[overlap-1-i]) - + MULT16_32_Q15 (COEF2VAL16(mode->window[overlap-i-1]), etmp[i]); - } - } while (++cwindow[i]), etmp[overlap - 1 - i]) + + MULT16_32_Q15 (COEF2VAL16(mode->window[overlap - i - 1]), etmp[i]); + } + } while (++c < CC); + RESTORE_STACK; } #ifdef ENABLE_DEEP_PLC -#define SINC_ORDER 48 +# define SINC_ORDER 48 /* h=cos(pi/2*abs(sin([-24:24]/48*pi*23./24)).^2); b=sinc([-24:24]/3*1.02).*h; b=b/sum(b); */ -static const float sinc_filter[SINC_ORDER+1] = { +static const float sinc_filter[SINC_ORDER + 1] = { 4.2931e-05f, -0.000190293f, -0.000816132f, -0.000637162f, 0.00141662f, 0.00354764f, 0.00184368f, -0.00428274f, -0.00856105f, -0.0034003f, 0.00930201f, 0.0159616f, 0.00489785f, -0.0169649f, -0.0259484f, -0.00596856f, 0.0286551f, 0.0405872f, 0.00649994f, -0.0509284f, -0.0716655f, -0.00665212f, 0.134336f, 0.278927f, @@ -636,1237 +571,1104 @@ static const float sinc_filter[SINC_ORDER+1] = { 4.2931e-05f }; -void update_plc_state(LPCNetPLCState *lpcnet, celt_sig *decode_mem[2], float *plc_preemphasis_mem, int CC) -{ - int i; - int tmp_read_post, tmp_fec_skip; - int offset; - celt_sig buf48k[DECODE_BUFFER_SIZE]; - opus_int16 buf16k[PLC_UPDATE_SAMPLES]; - if (CC == 1) OPUS_COPY(buf48k, decode_mem[0], DECODE_BUFFER_SIZE); - else { - for (i=0;ifec_read_pos; - tmp_fec_skip = lpcnet->fec_skip; - for (i=0;ifec_read_pos = tmp_read_post; - lpcnet->fec_skip = tmp_fec_skip; +void oaci_update_plc_state(LPCNetPLCState *lpcnet, celt_sig *decode_mem[2], float *plc_preemphasis_mem, int CC) { + int i; + int tmp_read_post, tmp_fec_skip; + int offset; + celt_sig buf48k[DECODE_BUFFER_SIZE]; + oac_int16 buf16k[PLC_UPDATE_SAMPLES]; + if (CC == 1) OAC_COPY(buf48k, decode_mem[0], DECODE_BUFFER_SIZE); + else { + for (i = 0; i < DECODE_BUFFER_SIZE; i++) { + buf48k[i] = .5*(decode_mem[0][i] + decode_mem[1][i]); + } + } + /* Down-sample the last 40 ms. */ + for (i = 1; i < DECODE_BUFFER_SIZE; i++) buf48k[i] += PREEMPHASIS*buf48k[i - 1]; + *plc_preemphasis_mem = buf48k[DECODE_BUFFER_SIZE - 1]; + offset = DECODE_BUFFER_SIZE - SINC_ORDER - 1 - 3*(PLC_UPDATE_SAMPLES - 1); + celt_assert(3*(PLC_UPDATE_SAMPLES - 1) + SINC_ORDER + offset == DECODE_BUFFER_SIZE - 1); + for (i = 0; i < PLC_UPDATE_SAMPLES; i++) { + int j; + float sum = 0; + for (j = 0; j < SINC_ORDER + 1; j++) { + sum += buf48k[3*i + j + offset]*sinc_filter[j]; + } + buf16k[i] = oaci_float2int(MIN32(32767.f, MAX32(-32767.f, sum))); + } + tmp_read_post = lpcnet->fec_read_pos; + tmp_fec_skip = lpcnet->fec_skip; + for (i = 0; i < PLC_UPDATE_FRAMES; i++) { + oaci_lpcnet_plc_update(lpcnet, &buf16k[FRAME_SIZE*i]); + } + lpcnet->fec_read_pos = tmp_read_post; + lpcnet->fec_skip = tmp_fec_skip; } #endif -static void celt_decode_lost(CELTDecoder * OPUS_RESTRICT st, int N, int LM +static void oaci_celt_decode_lost(CELTDecoder * OAC_RESTRICT st, int N, int LM #ifdef ENABLE_DEEP_PLC - ,LPCNetPLCState *lpcnet + , LPCNetPLCState *lpcnet #endif - ) -{ - int c; - int i; - const int C = st->channels; - celt_sig *decode_mem[2]; - celt_sig *out_syn[2]; - opus_val16 *lpc; - celt_glog *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE; - const OpusCustomMode *mode; - int nbEBands; - int overlap; - int start; - int loss_duration; - int curr_frame_type; - const opus_int16 *eBands; - int decode_buffer_size; - int max_period; + ) { + int c; + int i; + const int C = st->channels; + celt_sig *decode_mem[2]; + celt_sig *out_syn[2]; + oac_val16 *lpc; + celt_glog *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE; + const OacCustomMode *mode; + int nbEBands; + int overlap; + int start; + int loss_duration; + int curr_frame_type; + const oac_int16 *eBands; + int decode_buffer_size; + int max_period; #ifdef ENABLE_QEXT - int qext_scale; + int qext_scale; #endif - SAVE_STACK; + SAVE_STACK; #ifdef ENABLE_QEXT - qext_scale = st->qext_scale; + qext_scale = st->qext_scale; #endif - decode_buffer_size = QEXT_SCALE(DECODE_BUFFER_SIZE); - max_period = QEXT_SCALE(MAX_PERIOD); - mode = st->mode; - nbEBands = mode->nbEBands; - overlap = mode->overlap; - eBands = mode->eBands; - - c=0; do { - decode_mem[c] = st->_decode_mem + c*(decode_buffer_size+overlap); - out_syn[c] = decode_mem[c]+decode_buffer_size-N; - } while (++c_decode_mem+(decode_buffer_size+overlap)*C); - oldLogE = oldBandE + 2*nbEBands; - oldLogE2 = oldLogE + 2*nbEBands; - backgroundLogE = oldLogE2 + 2*nbEBands; - lpc = (opus_val16*)(backgroundLogE + 2*nbEBands); - - loss_duration = st->loss_duration; - start = st->start; - curr_frame_type = FRAME_PLC_PERIODIC; - if (st->plc_duration >= 40 || start != 0 || st->skip_plc) - curr_frame_type = FRAME_PLC_NOISE; + decode_buffer_size = QEXT_SCALE(DECODE_BUFFER_SIZE); + max_period = QEXT_SCALE(MAX_PERIOD); + mode = st->mode; + nbEBands = mode->nbEBands; + overlap = mode->overlap; + eBands = mode->eBands; + + c = 0; do { + decode_mem[c] = st->_decode_mem + c*(decode_buffer_size + overlap); + out_syn[c] = decode_mem[c] + decode_buffer_size - N; + } while (++c < C); + oldBandE = (celt_glog*)(st->_decode_mem + (decode_buffer_size + overlap)*C); + oldLogE = oldBandE + 2*nbEBands; + oldLogE2 = oldLogE + 2*nbEBands; + backgroundLogE = oldLogE2 + 2*nbEBands; + lpc = (oac_val16*)(backgroundLogE + 2*nbEBands); + + loss_duration = st->loss_duration; + start = st->start; + curr_frame_type = FRAME_PLC_PERIODIC; + if (st->plc_duration >= 40 || start != 0 || st->skip_plc) + curr_frame_type = FRAME_PLC_NOISE; #ifdef ENABLE_DEEP_PLC - if (start == 0 && lpcnet != NULL && st->mode->Fs != 96000 && lpcnet->loaded) - { - if (st->complexity >= 5 && st->plc_duration < 80 && !st->skip_plc) - curr_frame_type = FRAME_PLC_NEURAL; -#ifdef ENABLE_DRED - if (lpcnet->fec_fill_pos > lpcnet->fec_read_pos) - curr_frame_type = FRAME_DRED; -#endif - } + if (start == 0 && lpcnet != NULL && st->mode->Fs != 96000 && lpcnet->loaded) { + if (st->complexity >= 5 && st->plc_duration < 80 && !st->skip_plc) + curr_frame_type = FRAME_PLC_NEURAL; +# ifdef ENABLE_DRED + if (lpcnet->fec_fill_pos > lpcnet->fec_read_pos) + curr_frame_type = FRAME_DRED; +# endif + } #endif - if (curr_frame_type == FRAME_PLC_NOISE) - { - /* Noise-based PLC/CNG */ - VARDECL(celt_norm, X); - opus_uint32 seed; - int end; - int effEnd; - celt_glog decay; - end = st->end; - effEnd = IMAX(start, IMIN(end, mode->effEBands)); - - ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ - c=0; do { - OPUS_MOVE(decode_mem[c], decode_mem[c]+N, - decode_buffer_size-N+overlap); - } while (++cprefilter_and_fold) { - prefilter_and_fold(st, N); - } - - /* Energy decay */ - decay = loss_duration==0 ? GCONST(1.5f) : GCONST(.5f); - c=0; do - { - for (i=start;irng; - for (c=0;c>20), NORM_SHIFT-14); + if (curr_frame_type == FRAME_PLC_NOISE) { + /* Noise-based PLC/CNG */ + VARDECL(celt_norm, X); + oac_uint32 seed; + int end; + int effEnd; + celt_glog decay; + end = st->end; + effEnd = IMAX(start, IMIN(end, mode->effEBands)); + + ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ + c = 0; do { + OAC_MOVE(decode_mem[c], decode_mem[c] + N, + decode_buffer_size - N + overlap); + } while (++c < C); + + if (st->prefilter_and_fold) { + oaci_prefilter_and_fold(st, N); + } + + /* Energy decay */ + decay = loss_duration == 0 ? GCONST(1.5f) : GCONST(.5f); + c = 0; do { + for (i = start; i < end; i++) + oldBandE[c*nbEBands + i] = MAXG(backgroundLogE[c*nbEBands + i], oldBandE[c*nbEBands + i] - decay); + } while (++c < C); + seed = st->rng; + for (c = 0; c < C; c++) { + for (i = start; i < effEnd; i++) { + int j; + int boffs; + int blen; + boffs = N*c + (eBands[i]<>20), NORM_SHIFT - 14); + } + oaci_renormalise_vector(X + boffs, blen, Q31ONE, st->arch); } - renormalise_vector(X+boffs, blen, Q31ONE, st->arch); - } - } - st->rng = seed; - - celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, C, C, 0, LM, st->downsample, 0, st->arch ARG_QEXT(NULL) ARG_QEXT(NULL) ARG_QEXT(0)); - - /* Run the postfilter with the last parameters. */ - c=0; do { - st->postfilter_period=IMAX(st->postfilter_period, COMBFILTER_MINPERIOD); - st->postfilter_period_old=IMAX(st->postfilter_period_old, COMBFILTER_MINPERIOD); - comb_filter(out_syn[c], out_syn[c], st->postfilter_period_old, st->postfilter_period, mode->shortMdctSize, + } + st->rng = seed; + + oaci_celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, C, C, 0, LM, st->downsample, 0, st->arch); + + /* Run the postfilter with the last parameters. */ + c = 0; do { + st->postfilter_period = IMAX(st->postfilter_period, COMBFILTER_MINPERIOD); + st->postfilter_period_old = IMAX(st->postfilter_period_old, COMBFILTER_MINPERIOD); + oaci_comb_filter(out_syn[c], out_syn[c], st->postfilter_period_old, st->postfilter_period, mode->shortMdctSize, st->postfilter_gain_old, st->postfilter_gain, st->postfilter_tapset_old, st->postfilter_tapset, mode->window, overlap, st->arch); - if (LM!=0) - comb_filter(out_syn[c]+mode->shortMdctSize, out_syn[c]+mode->shortMdctSize, st->postfilter_period, st->postfilter_period, N-mode->shortMdctSize, + if (LM != 0) + oaci_comb_filter(out_syn[c] + mode->shortMdctSize, out_syn[c] + mode->shortMdctSize, st->postfilter_period, + st->postfilter_period, N - mode->shortMdctSize, st->postfilter_gain, st->postfilter_gain, st->postfilter_tapset, st->postfilter_tapset, mode->window, overlap, st->arch); - } while (++cpostfilter_period_old = st->postfilter_period; - st->postfilter_gain_old = st->postfilter_gain; - st->postfilter_tapset_old = st->postfilter_tapset; - - st->prefilter_and_fold = 0; - /* Skip regular PLC until we get two consecutive packets. */ - st->skip_plc = 1; - } else { - int exc_length; - /* Pitch-based PLC */ - const celt_coef *window; - opus_val16 *exc; - opus_val16 fade = Q15ONE; - int pitch_index; - int curr_neural; - int last_neural; - VARDECL(opus_val16, _exc); - VARDECL(opus_val16, fir_tmp); - - curr_neural = curr_frame_type == FRAME_PLC_NEURAL || curr_frame_type == FRAME_DRED; - last_neural = st->last_frame_type == FRAME_PLC_NEURAL || st->last_frame_type == FRAME_DRED; - if (st->last_frame_type != FRAME_PLC_PERIODIC && !(last_neural && curr_neural)) - { - st->last_pitch_index = pitch_index = celt_plc_pitch_search(st, decode_mem, C, st->arch); - } else { - pitch_index = st->last_pitch_index; - fade = QCONST16(.8f,15); - } + } while (++c < C); + st->postfilter_period_old = st->postfilter_period; + st->postfilter_gain_old = st->postfilter_gain; + st->postfilter_tapset_old = st->postfilter_tapset; + + st->prefilter_and_fold = 0; + /* Skip regular PLC until we get two consecutive packets. */ + st->skip_plc = 1; + } else { + int exc_length; + /* Pitch-based PLC */ + const celt_coef *window; + oac_val16 *exc; + oac_val16 fade = Q15ONE; + int pitch_index; + int curr_neural; + int last_neural; + VARDECL(oac_val16, _exc); + VARDECL(oac_val16, fir_tmp); + + curr_neural = curr_frame_type == FRAME_PLC_NEURAL || curr_frame_type == FRAME_DRED; + last_neural = st->last_frame_type == FRAME_PLC_NEURAL || st->last_frame_type == FRAME_DRED; + if (st->last_frame_type != FRAME_PLC_PERIODIC && !(last_neural && curr_neural)) { + st->last_pitch_index = pitch_index = oaci_celt_plc_pitch_search(st, decode_mem, C, st->arch); + } else { + pitch_index = st->last_pitch_index; + fade = QCONST16(.8f, 15); + } #ifdef ENABLE_DEEP_PLC - if (curr_neural && !last_neural) update_plc_state(lpcnet, decode_mem, &st->plc_preemphasis_mem, C); + if (curr_neural && !last_neural) oaci_update_plc_state(lpcnet, decode_mem, &st->plc_preemphasis_mem, C); #endif - /* We want the excitation for 2 pitch periods in order to look for a - decaying signal, but we can't get more than MAX_PERIOD. */ - exc_length = IMIN(2*pitch_index, max_period); - - ALLOC(_exc, max_period+CELT_LPC_ORDER, opus_val16); - ALLOC(fir_tmp, exc_length, opus_val16); - exc = _exc+CELT_LPC_ORDER; - window = mode->window; - c=0; do { - opus_val16 decay; - opus_val16 attenuation; - opus_val32 S1=0; - celt_sig *buf; - int extrapolation_offset; - int extrapolation_len; - int j; - - buf = decode_mem[c]; - for (i=0;ilast_frame_type != FRAME_PLC_PERIODIC && !(last_neural && curr_neural)) - { - opus_val32 ac[CELT_LPC_ORDER+1]; - /* Compute LPC coefficients for the last MAX_PERIOD samples before - the first loss so we can work in the excitation-filter domain. */ - _celt_autocorr(exc, ac, window, overlap, + /* We want the excitation for 2 pitch periods in order to look for a + decaying signal, but we can't get more than MAX_PERIOD. */ + exc_length = IMIN(2*pitch_index, max_period); + + ALLOC(_exc, max_period + CELT_LPC_ORDER, oac_val16); + ALLOC(fir_tmp, exc_length, oac_val16); + exc = _exc + CELT_LPC_ORDER; + window = mode->window; + c = 0; do { + oac_val16 decay; + oac_val16 attenuation; + oac_val32 S1 = 0; + celt_sig *buf; + int extrapolation_offset; + int extrapolation_len; + int j; + + buf = decode_mem[c]; + for (i = 0; i < max_period + CELT_LPC_ORDER; i++) + exc[i - CELT_LPC_ORDER] = SROUND16(buf[decode_buffer_size - max_period - CELT_LPC_ORDER + i], + SIG_SHIFT); + + if (st->last_frame_type != FRAME_PLC_PERIODIC && !(last_neural && curr_neural)) { + oac_val32 ac[CELT_LPC_ORDER + 1]; + /* Compute LPC coefficients for the last MAX_PERIOD samples before + the first loss so we can work in the excitation-filter domain. */ + oaci_celt_autocorr(exc, ac, window, overlap, CELT_LPC_ORDER, max_period, st->arch); - /* Add a noise floor of -40 dB. */ + /* Add a noise floor of -40 dB. */ #ifdef FIXED_POINT - ac[0] += SHR32(ac[0],13); + ac[0] += SHR32(ac[0], 13); #else - ac[0] *= 1.0001f; + ac[0] *= 1.0001f; #endif - /* Use lag windowing to stabilize the Levinson-Durbin recursion. */ - for (i=1;i<=CELT_LPC_ORDER;i++) - { - /*ac[i] *= exp(-.5*(2*M_PI*.002*i)*(2*M_PI*.002*i));*/ + /* Use lag windowing to stabilize the Levinson-Durbin recursion. */ + for (i = 1; i <= CELT_LPC_ORDER; i++) { + /*ac[i] *= exp(-.5*(2*M_PI*.002*i)*(2*M_PI*.002*i));*/ #ifdef FIXED_POINT - ac[i] -= MULT16_32_Q15(2*i*i, ac[i]); + ac[i] -= MULT16_32_Q15(2*i*i, ac[i]); #else - ac[i] -= ac[i]*(0.008f*0.008f)*i*i; + ac[i] -= ac[i]*(0.008f*0.008f)*i*i; #endif - } - _celt_lpc(lpc+c*CELT_LPC_ORDER, ac, CELT_LPC_ORDER); + } + oaci_celt_lpc(lpc + c*CELT_LPC_ORDER, ac, CELT_LPC_ORDER); #ifdef FIXED_POINT - /* For fixed-point, apply bandwidth expansion until we can guarantee that - no overflow can happen in the IIR filter. This means: - 32768*sum(abs(filter)) < 2^31 */ - while (1) { - opus_val16 tmp=Q15ONE; - opus_val32 sum=QCONST16(1., SIG_SHIFT); - for (i=0;iarch); - OPUS_COPY(exc+max_period-exc_length, fir_tmp, exc_length); - } - - /* Check if the waveform is decaying, and if so how fast. - We do this to avoid adding energy when concealing in a segment - with decaying energy. */ - { - opus_val32 E1=1, E2=1; - int decay_length; + OAC_COPY(exc + max_period - exc_length, fir_tmp, exc_length); + } + + /* Check if the waveform is decaying, and if so how fast. + We do this to avoid adding energy when concealing in a segment + with decaying energy. */ + { + oac_val32 E1 = 1, E2 = 1; + int decay_length; #ifdef FIXED_POINT - int shift = IMAX(0,2*celt_zlog2(celt_maxabs16(&exc[max_period-exc_length], exc_length))-20); -#ifdef ENABLE_QEXT - if (st->qext_scale==2) shift++; -#endif + int shift = IMAX(0, 2*oaci_celt_zlog2(oaci_celt_maxabs16(&exc[max_period - exc_length], exc_length)) - 20); +# ifdef ENABLE_QEXT + if (st->qext_scale == 2) shift++; +# endif #endif - decay_length = exc_length>>1; - for (i=0;i>1; + for (i = 0; i < decay_length; i++) { + oac_val16 e; + e = exc[max_period - decay_length + i]; + E1 += SHR32(MULT16_16(e, e), shift); + e = exc[max_period - 2*decay_length + i]; + E2 += SHR32(MULT16_16(e, e), shift); + } + E1 = MIN32(E1, E2); + decay = oaci_celt_sqrt(oaci_frac_div32(SHR32(E1, 1), E2)); } - E1 = MIN32(E1, E2); - decay = celt_sqrt(frac_div32(SHR32(E1, 1), E2)); - } - - /* Move the decoder memory one frame to the left to give us room to - add the data for the new frame. We ignore the overlap that extends - past the end of the buffer, because we aren't going to use it. */ - OPUS_MOVE(buf, buf+N, decode_buffer_size-N); - - /* Extrapolate from the end of the excitation with a period of - "pitch_index", scaling down each period by an additional factor of - "decay". */ - extrapolation_offset = max_period-pitch_index; - /* We need to extrapolate enough samples to cover a complete MDCT - window (including overlap/2 samples on both sides). */ - extrapolation_len = N+overlap; - /* We also apply fading if this is not the first loss. */ - attenuation = MULT16_16_Q15(fade, decay); - for (i=j=0;i= pitch_index) { - j -= pitch_index; - attenuation = MULT16_16_Q15(attenuation, decay); - } - buf[decode_buffer_size-N+i] = - SHL32(EXTEND32(MULT16_16_Q15(attenuation, - exc[extrapolation_offset+j])), SIG_SHIFT); - /* Compute the energy of the previously decoded signal whose - excitation we're copying. */ - tmp = SROUND16( - buf[decode_buffer_size-max_period-N+extrapolation_offset+j], + + /* Move the decoder memory one frame to the left to give us room to + add the data for the new frame. We ignore the overlap that extends + past the end of the buffer, because we aren't going to use it. */ + OAC_MOVE(buf, buf + N, decode_buffer_size - N); + + /* Extrapolate from the end of the excitation with a period of + "pitch_index", scaling down each period by an additional factor of + "decay". */ + extrapolation_offset = max_period - pitch_index; + /* We need to extrapolate enough samples to cover a complete MDCT + window (including overlap/2 samples on both sides). */ + extrapolation_len = N + overlap; + /* We also apply fading if this is not the first loss. */ + attenuation = MULT16_16_Q15(fade, decay); + for (i = j = 0; i < extrapolation_len; i++, j++) { + oac_val16 tmp; + if (j >= pitch_index) { + j -= pitch_index; + attenuation = MULT16_16_Q15(attenuation, decay); + } + buf[decode_buffer_size - N + i] = + SHL32(EXTEND32(MULT16_16_Q15(attenuation, + exc[extrapolation_offset + j])), SIG_SHIFT); + /* Compute the energy of the previously decoded signal whose + excitation we're copying. */ + tmp = SROUND16( + buf[decode_buffer_size - max_period - N + extrapolation_offset + j], SIG_SHIFT); - S1 += SHR32(MULT16_16(tmp, tmp), 11); - } - { - opus_val16 lpc_mem[CELT_LPC_ORDER]; - /* Copy the last decoded samples (prior to the overlap region) to - synthesis filter memory so we can have a continuous signal. */ - for (i=0;iarch); #ifdef FIXED_POINT - for (i=0; i < extrapolation_len; i++) - buf[decode_buffer_size-N+i] = SATURATE(buf[decode_buffer_size-N+i], SIG_SAT); + for (i = 0; i < extrapolation_len; i++) + buf[decode_buffer_size - N + i] = SATURATE(buf[decode_buffer_size - N + i], SIG_SAT); #endif - } - - /* Check if the synthesis energy is higher than expected, which can - happen with the signal changes during our window. If so, - attenuate. */ - { - opus_val32 S2=0; - for (i=0;i SHR32(S2,2))) + if (!(S1 > SHR32(S2, 2))) #else - /* The float test is written this way to catch NaNs in the output - of the IIR filter at the same time. */ - if (!(S1 > 0.2f*S2)) + /* The float test is written this way to catch NaNs in the output + of the IIR filter at the same time. */ + if (!(S1 > 0.2f*S2)) #endif - { - for (i=0;iplc_fill = 0; - } - while (st->plc_fill < samples_needed16k) { - lpcnet_plc_conceal(lpcnet, &st->plc_pcm[st->plc_fill]); - st->plc_fill += FRAME_SIZE; - } - /* Resample to 48 kHz. */ - for (i=0;i<(N+overlap)/3;i++) { - int j; - float sum; - for (sum=0, j=0;j<17;j++) sum += 3*st->plc_pcm[i+j]*sinc_filter[3*j]; - buf[decode_buffer_size-N+3*i] = sum; - for (sum=0, j=0;j<16;j++) sum += 3*st->plc_pcm[i+j+1]*sinc_filter[3*j+2]; - buf[decode_buffer_size-N+3*i+1] = sum; - for (sum=0, j=0;j<16;j++) sum += 3*st->plc_pcm[i+j+1]*sinc_filter[3*j+1]; - buf[decode_buffer_size-N+3*i+2] = sum; - } - OPUS_MOVE(st->plc_pcm, &st->plc_pcm[N/3], st->plc_fill-N/3); - st->plc_fill -= N/3; - for (i=0;iplc_preemphasis_mem; - st->plc_preemphasis_mem = tmp; - } - overlap_mem = st->plc_preemphasis_mem; - for (i=0;iplc_fill = 0; } - } while (++cplc_fill < samples_needed16k) { + oaci_lpcnet_plc_conceal(lpcnet, &st->plc_pcm[st->plc_fill]); + st->plc_fill += FRAME_SIZE; + } + /* Resample to 48 kHz. */ + for (i = 0; i < (N + overlap)/3; i++) { + int j; + float sum; + for (sum = 0, j = 0; j < 17; j++) sum += 3*st->plc_pcm[i + j]*sinc_filter[3*j]; + buf[decode_buffer_size - N + 3*i] = sum; + for (sum = 0, j = 0; j < 16; j++) sum += 3*st->plc_pcm[i + j + 1]*sinc_filter[3*j + 2]; + buf[decode_buffer_size - N + 3*i + 1] = sum; + for (sum = 0, j = 0; j < 16; j++) sum += 3*st->plc_pcm[i + j + 1]*sinc_filter[3*j + 1]; + buf[decode_buffer_size - N + 3*i + 2] = sum; + } + OAC_MOVE(st->plc_pcm, &st->plc_pcm[N/3], st->plc_fill - N/3); + st->plc_fill -= N/3; + for (i = 0; i < N; i++) { + float tmp = buf[decode_buffer_size - N + i]; + buf[decode_buffer_size - N + i] -= PREEMPHASIS*st->plc_preemphasis_mem; + st->plc_preemphasis_mem = tmp; + } + overlap_mem = st->plc_preemphasis_mem; + for (i = 0; i < overlap; i++) { + float tmp = buf[decode_buffer_size + i]; + buf[decode_buffer_size + i] -= PREEMPHASIS*overlap_mem; + overlap_mem = tmp; + } + /* For now, we just do mono PLC. */ + if (C == 2) OAC_COPY(decode_mem[1], decode_mem[0], decode_buffer_size + overlap); + c = 0; do { + /* Cross-fade with 48-kHz non-neural PLC for the first 2.5 ms to avoid a discontinuity. */ + if (!last_neural) { + for (i = 0; i < overlap; + i++) decode_mem[c][decode_buffer_size - N + i] = (1 - window[i])*buf_copy[c*overlap + i] + + (window[i]) + *decode_mem[c][decode_buffer_size - N + i]; + } + } while (++c < C); + } #endif - st->prefilter_and_fold = 1; - } + st->prefilter_and_fold = 1; + } - /* Saturate to something large to avoid wrap-around. */ - st->loss_duration = IMIN(10000, loss_duration+(1<plc_duration = IMIN(10000, st->plc_duration+(1<loss_duration = IMIN(10000, loss_duration + (1<plc_duration = IMIN(10000, st->plc_duration + (1<plc_duration = 0; - st->skip_plc = 0; - } + if (curr_frame_type == FRAME_DRED) { + st->plc_duration = 0; + st->skip_plc = 0; + } #endif - st->last_frame_type = curr_frame_type; - RESTORE_STACK; -} - -#ifdef ENABLE_QEXT -static void decode_qext_stereo_params(ec_dec *ec, int qext_end, int *qext_intensity, int *qext_dual_stereo) { - *qext_intensity = ec_dec_uint(ec, qext_end+1); - if (*qext_intensity != 0) *qext_dual_stereo = ec_dec_bit_logp(ec, 1); - else *qext_dual_stereo = 0; + st->last_frame_type = curr_frame_type; + RESTORE_STACK; } -#endif -int celt_decode_with_ec_dred(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, - int len, opus_res * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec, int accum +int oaci_celt_decode_with_ec_dred(CELTDecoder * OAC_RESTRICT st, const unsigned char *data, + int len, oac_res * OAC_RESTRICT pcm, int frame_size, ec_dec *dec, int accum #ifdef ENABLE_DEEP_PLC - ,LPCNetPLCState *lpcnet + , LPCNetPLCState *lpcnet #endif - ARG_QEXT(const unsigned char *qext_payload) ARG_QEXT(int qext_payload_len) - ) -{ - int c, i, N; - int spread_decision; - opus_int32 bits; - ec_dec _dec; - VARDECL(celt_norm, X); - VARDECL(int, fine_quant); - VARDECL(int, pulses); - VARDECL(int, cap); - VARDECL(int, offsets); - VARDECL(int, fine_priority); - VARDECL(int, tf_res); - VARDECL(unsigned char, collapse_masks); - celt_sig *decode_mem[2]; - celt_sig *out_syn[2]; - celt_glog *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE; - - int shortBlocks; - int isTransient; - int intra_ener; - const int CC = st->channels; - int LM, M; - int start; - int end; - int effEnd; - int codedBands; - int alloc_trim; - int postfilter_pitch; - opus_val16 postfilter_gain; - int intensity=0; - int dual_stereo=0; - opus_int32 total_bits; - opus_int32 balance; - opus_int32 tell; - int dynalloc_logp; - int postfilter_tapset; - int anti_collapse_rsv; - int anti_collapse_on=0; - int silence; - int C = st->stream_channels; - const OpusCustomMode *mode; - int nbEBands; - int overlap; - const opus_int16 *eBands; - celt_glog max_background_increase; - int decode_buffer_size; + ) { + int c, i, N; + int spread_decision; + oac_int32 bits; + ec_dec _dec; + VARDECL(celt_norm, X); + VARDECL(int, fine_quant); + VARDECL(int, pulses); + VARDECL(int, cap); + VARDECL(int, offsets); + VARDECL(int, fine_priority); + VARDECL(int, tf_res); + VARDECL(unsigned char, collapse_masks); + celt_sig *decode_mem[2]; + celt_sig *out_syn[2]; + celt_glog *oldBandE, *oldLogE, *oldLogE2, *backgroundLogE; + + int shortBlocks; + int isTransient; + int intra_ener; + const int CC = st->channels; + int LM, M; + int start; + int end; + int effEnd; + int codedBands; + int alloc_trim; + int postfilter_pitch; + oac_val16 postfilter_gain; + int intensity = 0; + int dual_stereo = 0; + oac_int32 total_bits; + oac_int32 balance; + oac_int32 tell; + int dynalloc_logp; + int postfilter_tapset; + int anti_collapse_rsv; + int anti_collapse_on = 0; + int silence; + int C = st->stream_channels; + const OacCustomMode *mode; + int nbEBands; + int overlap; + const oac_int16 *eBands; + celt_glog max_background_increase; + int decode_buffer_size; #ifdef ENABLE_QEXT - opus_int32 qext_bits; - ec_dec ext_dec; - int qext_bytes=0; - int qext_end=0; - int qext_intensity=0; - int qext_dual_stereo=0; - VARDECL(int, extra_quant); - VARDECL(int, extra_pulses); - const CELTMode *qext_mode = NULL; - CELTMode qext_mode_struct; - int qext_scale; -#else -# define qext_bytes 0 + int qext_scale; #endif - ALLOC_STACK; + ALLOC_STACK; #ifdef ENABLE_QEXT - qext_scale = st->qext_scale; + qext_scale = st->qext_scale; #endif - decode_buffer_size = QEXT_SCALE(DECODE_BUFFER_SIZE); - - VALIDATE_CELT_DECODER(st); - mode = st->mode; - nbEBands = mode->nbEBands; - overlap = mode->overlap; - eBands = mode->eBands; - start = st->start; - end = st->end; - frame_size *= st->downsample; - - oldBandE = (celt_glog*)(st->_decode_mem+(decode_buffer_size+overlap)*CC); - oldLogE = oldBandE + 2*nbEBands; - oldLogE2 = oldLogE + 2*nbEBands; - backgroundLogE = oldLogE2 + 2*nbEBands; - -#ifdef ENABLE_QEXT - if (qext_payload) { - ec_dec_init(&ext_dec, (unsigned char*)qext_payload, qext_payload_len); - qext_bytes = qext_payload_len; - } else { - ec_dec_init(&ext_dec, NULL, 0); - } -#endif -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) - if (st->signalling && data!=NULL) - { - int data0=data[0]; - /* Convert "standard mode" to Opus header */ + decode_buffer_size = QEXT_SCALE(DECODE_BUFFER_SIZE); + + VALIDATE_CELT_DECODER(st); + mode = st->mode; + nbEBands = mode->nbEBands; + overlap = mode->overlap; + eBands = mode->eBands; + start = st->start; + end = st->end; + frame_size *= st->downsample; + + oldBandE = (celt_glog*)(st->_decode_mem + (decode_buffer_size + overlap)*CC); + oldLogE = oldBandE + 2*nbEBands; + oldLogE2 = oldLogE + 2*nbEBands; + backgroundLogE = oldLogE2 + 2*nbEBands; + +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) + if (st->signalling && data != NULL) { + int data0 = data[0]; + /* Convert "standard mode" to Oac header */ # ifndef ENABLE_QEXT - if (mode->Fs==48000 && mode->shortMdctSize==120) + if (mode->Fs == 48000 && mode->shortMdctSize == 120) # endif - { - data0 = fromOpus(data0); - if (data0<0) - return OPUS_INVALID_PACKET; - } - st->end = end = IMAX(1, mode->effEBands-2*(data0>>5)); - LM = (data0>>3)&0x3; - C = 1 + ((data0>>2)&0x1); - if ((data[0] & 0x03) == 0x03) { - data++; - len--; - if (len<=0) - return OPUS_INVALID_PACKET; - if (data[0] & 0x40) { - int p; - int padding=0; + { + data0 = oaci_fromOac(data0); + if (data0 < 0) + return OAC_INVALID_PACKET; + } + st->end = end = IMAX(1, mode->effEBands - 2*(data0>>5)); + LM = (data0>>3)&0x3; + C = 1 + ((data0>>2)&0x1); + if ((data[0]&0x03) == 0x03) { data++; len--; - do { - int tmp; - if (len<=0) - return OPUS_INVALID_PACKET; - p = *data++; - len--; - tmp = p==255 ? 254: p; - len -= tmp; - padding += tmp; - } while (p==255); - padding--; - if (len <= 0 || padding<0) return OPUS_INVALID_PACKET; -#ifdef ENABLE_QEXT - qext_bytes = padding; - if (data[len] != QEXT_EXTENSION_ID<<1) - qext_bytes=0; - ec_dec_init(&ext_dec, (unsigned char*)data+len+1, qext_bytes); -#endif - } - } else - { - data++; - len--; - } - if (LM>mode->maxLM) - return OPUS_INVALID_PACKET; - if (frame_size < mode->shortMdctSize<shortMdctSize< mode->maxLM) + return OAC_INVALID_PACKET; + if (frame_size < mode->shortMdctSize<shortMdctSize<maxLM;LM++) - if (mode->shortMdctSize<mode->maxLM) - return OPUS_BAD_ARG; - } - M=1<1275 || pcm==NULL) - return OPUS_BAD_ARG; - - N = M*mode->shortMdctSize; - c=0; do { - decode_mem[c] = st->_decode_mem + c*(decode_buffer_size+overlap); - out_syn[c] = decode_mem[c]+decode_buffer_size-N; - } while (++c mode->effEBands) - effEnd = mode->effEBands; - - if (data == NULL || len<=1) - { - celt_decode_lost(st, N, LM + for (LM = 0; LM <= mode->maxLM; LM++) + if (mode->shortMdctSize< mode->maxLM) + return OAC_BAD_ARG; + } + M = 1< 1275 || pcm == NULL) + return OAC_BAD_ARG; + + N = M*mode->shortMdctSize; + c = 0; do { + decode_mem[c] = st->_decode_mem + c*(decode_buffer_size + overlap); + out_syn[c] = decode_mem[c] + decode_buffer_size - N; + } while (++c < CC); + + effEnd = end; + if (effEnd > mode->effEBands) + effEnd = mode->effEBands; + + if (data == NULL || len <= 1) { + oaci_celt_decode_lost(st, N, LM #ifdef ENABLE_DEEP_PLC - , lpcnet + , lpcnet #endif - ); - deemphasis(out_syn, pcm, N, CC, st->downsample, mode->preemph, st->preemph_memD, accum); - RESTORE_STACK; - return frame_size/st->downsample; - } + ); + oaci_deemphasis(out_syn, pcm, N, CC, st->downsample, mode->preemph, st->preemph_memD, accum); + RESTORE_STACK; + return frame_size/st->downsample; + } #ifdef ENABLE_DEEP_PLC - else { - /* FIXME: This is a bit of a hack just to make sure opus_decode_native() knows we're no longer in PLC. */ - if (lpcnet) lpcnet->blend = 0; - } + else { + /* FIXME: This is a bit of a hack just to make sure oac_decode_native() knows we're no longer in PLC. */ + if (lpcnet) lpcnet->blend = 0; + } #endif - /* Check if there are at least two packets received consecutively before - * turning on the pitch-based PLC */ - if (st->loss_duration == 0) st->skip_plc = 0; - - if (dec == NULL) - { - ec_dec_init(&_dec,(unsigned char*)data,len); - dec = &_dec; - } - - if (C==1) - { - for (i=0;i= total_bits) - silence = 1; - else if (tell==1) - silence = ec_dec_bit_logp(dec, 15); - else - silence = 0; - if (silence) - { - /* Pretend we've read all the remaining bits */ - tell = len*8; - dec->nbits_total+=tell-ec_tell(dec); - } - - postfilter_gain = 0; - postfilter_pitch = 0; - postfilter_tapset = 0; - if (start==0 && tell+16 <= total_bits) - { - if(ec_dec_bit_logp(dec, 1)) - { - int qg, octave; - octave = ec_dec_uint(dec, 6); - postfilter_pitch = (16< 0 && tell+3 <= total_bits) - { - isTransient = ec_dec_bit_logp(dec, 3); - tell = ec_tell(dec); - } - else - isTransient = 0; - - if (isTransient) - shortBlocks = M; - else - shortBlocks = 0; - - /* Decode the global flags (first symbols in the stream) */ - intra_ener = tell+3<=total_bits ? ec_dec_bit_logp(dec, 3) : 0; - /* If recovering from packet loss, make sure we make the energy prediction safe to reduce the - risk of getting loud artifacts. */ - if (!intra_ener && st->loss_duration != 0) { - c=0; do - { - celt_glog safety = 0; - int missing = IMIN(10, st->loss_duration>>LM); - if (LM==0) safety = GCONST(1.5f); - else if (LM==1) safety = GCONST(.5f); - for (i=start;iloss_duration == 0) st->skip_plc = 0; + + if (dec == NULL) { + oaci_ec_dec_init(&_dec, (unsigned char*)data, len); + dec = &_dec; + } + + if (C == 1) { + for (i = 0; i < nbEBands; i++) + oldBandE[i] = MAXG(oldBandE[i], oldBandE[nbEBands + i]); + } + + total_bits = len*8; + tell = oaci_ec_tell(dec); + + if (tell >= total_bits) + silence = 1; + else if (tell == 1) + silence = oaci_ec_dec_bit_logp(dec, 15); + else + silence = 0; + if (silence) { + /* Pretend we've read all the remaining bits */ + tell = len*8; + dec->nbits_total += tell - oaci_ec_tell(dec); + } + + postfilter_gain = 0; + postfilter_pitch = 0; + postfilter_tapset = 0; + if (start == 0 && tell + 18 <= total_bits) { + if (oaci_ec_dec_bit_logp(dec, 1)) { + int qg, octave; + octave = oaci_ec_dec_uint(dec, 6); + postfilter_pitch = (16< 0 && tell + 3 <= total_bits) { + isTransient = oaci_ec_dec_bit_logp(dec, 3); + tell = oaci_ec_tell(dec); + } else + isTransient = 0; + + if (isTransient) + shortBlocks = M; + else + shortBlocks = 0; + + /* Decode the global flags (first symbols in the stream) */ + intra_ener = tell + 3 <= total_bits ? oaci_ec_dec_bit_logp(dec, 3) : 0; + /* If recovering from packet loss, make sure we make the energy prediction safe to reduce the + risk of getting loud artifacts. */ + if (!intra_ener && st->loss_duration != 0) { + c = 0; do { + celt_glog safety = 0; + int missing = IMIN(10, st->loss_duration>>LM); + if (LM == 0) safety = GCONST(1.5f); + else if (LM == 1) safety = GCONST(.5f); + for (i = start; i < end; i++) { + if (oldBandE[c*nbEBands + i] < MAXG(oldLogE[c*nbEBands + i], oldLogE2[c*nbEBands + i])) { + /* If energy is going down already, continue the trend. */ + oac_val32 slope; + oac_val32 E0, E1, E2; + E0 = oldBandE[c*nbEBands + i]; + E1 = oldLogE[c*nbEBands + i]; + E2 = oldLogE2[c*nbEBands + i]; + slope = MAX32(E1 - E0, HALF32(E2 - E0)); + slope = MING(slope, GCONST(2.f)); + E0 -= MAX32(0, (1 + missing)*slope); + oldBandE[c*nbEBands + i] = MAX32(-GCONST(20.f), E0); + } else { + /* Otherwise take the min of the last frames. */ + oldBandE[c*nbEBands + i] = MING(MING(oldBandE[c*nbEBands + i], oldLogE[c*nbEBands + i]), + oldLogE2[c*nbEBands + i]); + } + /* Shorter frames have more natural fluctuations -- play it safe. */ + oldBandE[c*nbEBands + i] -= safety; } - /* Shorter frames have more natural fluctuations -- play it safe. */ - oldBandE[c*nbEBands+i] -= safety; - } - } while (++c<2); - } - /* Get band energies */ - unquant_coarse_energy(mode, start, end, oldBandE, + } while (++c < 2); + } + /* Get band energies */ + oaci_unquant_coarse_energy(mode, start, end, oldBandE, intra_ener, dec, C, LM); - ALLOC(tf_res, nbEBands, int); - tf_decode(start, end, isTransient, tf_res, LM, dec); - - tell = ec_tell(dec); - spread_decision = SPREAD_NORMAL; - if (tell+4 <= total_bits) - spread_decision = ec_dec_icdf(dec, spread_icdf, 5); - - ALLOC(cap, nbEBands, int); - - init_caps(mode,cap,LM,C); - - ALLOC(offsets, nbEBands, int); - - dynalloc_logp = 6; - total_bits<<=BITRES; - tell = ec_tell_frac(dec); - for (i=start;i0) - dynalloc_logp = IMAX(2, dynalloc_logp-1); - } - - ALLOC(fine_quant, nbEBands, int); - alloc_trim = tell+(6<=2&&bits>=((LM+2)< 0) + dynalloc_logp = IMAX(2, dynalloc_logp - 1); + } + + ALLOC(fine_quant, nbEBands, int); + alloc_trim = tell + (7<= 2 && bits >= ((LM + 2)<Fs == 48000 && (mode->shortMdctSize==120 || mode->shortMdctSize==90)) - || (mode->Fs == 96000 && (mode->shortMdctSize==240 || mode->shortMdctSize==180)))) { - int qext_intra_ener; - compute_qext_mode(&qext_mode_struct, mode); - qext_mode = &qext_mode_struct; - qext_end = ec_dec_bit_logp(&ext_dec, 1) ? NB_QEXT_BANDS : 2; - if (C==2) decode_qext_stereo_params(&ext_dec, qext_end, &qext_intensity, &qext_dual_stereo); - qext_intra_ener = ec_tell(&ext_dec)+3<=qext_bytes*8 ? ec_dec_bit_logp(&ext_dec, 3) : 0; - unquant_coarse_energy(qext_mode, 0, qext_end, st->qext_oldBandE, - qext_intra_ener, &ext_dec, C, LM); - } - ALLOC(extra_quant, nbEBands+NB_QEXT_BANDS, int); - ALLOC(extra_pulses, nbEBands+NB_QEXT_BANDS, int); - qext_bits = ((opus_int32)qext_bytes*8< 0) { - unquant_fine_energy(mode, start, end, oldBandE, fine_quant, extra_quant, &ext_dec, C); - } -#endif + c = 0; do { + OAC_MOVE(decode_mem[c], decode_mem[c] + N, decode_buffer_size - N + overlap); + } while (++c < CC); - c=0; do { - OPUS_MOVE(decode_mem[c], decode_mem[c]+N, decode_buffer_size-N+overlap); - } while (++crng, 0, - st->arch, st->disable_inv - ARG_QEXT(&ext_dec) ARG_QEXT(extra_pulses) - ARG_QEXT(qext_bytes*(8<rng, 0, + st->arch, st->disable_inv); -#ifdef ENABLE_QEXT - if (qext_mode) { - VARDECL(int, zeros); - VARDECL(unsigned char, qext_collapse_masks); - ec_dec dummy_dec; - int ext_balance; - ALLOC(zeros, nbEBands, int); - ALLOC(qext_collapse_masks, C*NB_QEXT_BANDS, unsigned char); - ec_dec_init(&dummy_dec, NULL, 0); - OPUS_CLEAR(zeros, end); - ext_balance = qext_bytes*(8<qext_oldBandE, NULL, &extra_quant[nbEBands], &ext_dec, C); - quant_all_bands(0, qext_mode, 0, qext_end, X, C==2 ? X+N : NULL, qext_collapse_masks, - NULL, &extra_pulses[nbEBands], shortBlocks, spread_decision, qext_dual_stereo, qext_intensity, zeros, - qext_bytes*(8<rng, 0, - st->arch, st->disable_inv, &dummy_dec, zeros, 0, NULL); - } -#endif + if (anti_collapse_rsv > 0) { + anti_collapse_on = oaci_ec_dec_bits(dec, 1); + } - if (anti_collapse_rsv > 0) - { - anti_collapse_on = ec_dec_bits(dec, 1); - } - unquant_energy_finalise(mode, start, end, (qext_bytes > 0) ? NULL : oldBandE, - fine_quant, fine_priority, len*8-ec_tell(dec), dec, C); - if (anti_collapse_on) - anti_collapse(mode, X, collapse_masks, LM, C, N, + oaci_unquant_energy_finalise(mode, start, end, oldBandE, + fine_quant, fine_priority, len*8 - oaci_ec_tell(dec), dec, C); + + if (anti_collapse_on) + oaci_anti_collapse(mode, X, collapse_masks, LM, C, N, start, end, oldBandE, oldLogE, oldLogE2, pulses, st->rng, 0, st->arch); - if (silence) - { - for (i=0;iprefilter_and_fold) { - prefilter_and_fold(st, N); - } - celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, - C, CC, isTransient, LM, st->downsample, silence, st->arch ARG_QEXT(qext_mode) ARG_QEXT(st->qext_oldBandE) ARG_QEXT(qext_end)); - - c=0; do { - st->postfilter_period=IMAX(st->postfilter_period, COMBFILTER_MINPERIOD); - st->postfilter_period_old=IMAX(st->postfilter_period_old, COMBFILTER_MINPERIOD); - comb_filter(out_syn[c], out_syn[c], st->postfilter_period_old, st->postfilter_period, mode->shortMdctSize, + if (silence) { + for (i = 0; i < C*nbEBands; i++) + oldBandE[i] = -GCONST(28.f); + } + if (st->prefilter_and_fold) { + oaci_prefilter_and_fold(st, N); + } + oaci_celt_synthesis(mode, X, out_syn, oldBandE, start, effEnd, + C, CC, isTransient, LM, st->downsample, silence, st->arch); + + c = 0; do { + st->postfilter_period = IMAX(st->postfilter_period, COMBFILTER_MINPERIOD); + st->postfilter_period_old = IMAX(st->postfilter_period_old, COMBFILTER_MINPERIOD); + oaci_comb_filter(out_syn[c], out_syn[c], st->postfilter_period_old, st->postfilter_period, mode->shortMdctSize, st->postfilter_gain_old, st->postfilter_gain, st->postfilter_tapset_old, st->postfilter_tapset, mode->window, overlap, st->arch); - if (LM!=0) - comb_filter(out_syn[c]+mode->shortMdctSize, out_syn[c]+mode->shortMdctSize, st->postfilter_period, postfilter_pitch, N-mode->shortMdctSize, + if (LM != 0) + oaci_comb_filter(out_syn[c] + mode->shortMdctSize, out_syn[c] + mode->shortMdctSize, st->postfilter_period, + postfilter_pitch, N - mode->shortMdctSize, st->postfilter_gain, postfilter_gain, st->postfilter_tapset, postfilter_tapset, mode->window, overlap, st->arch); - } while (++cpostfilter_period_old = st->postfilter_period; - st->postfilter_gain_old = st->postfilter_gain; - st->postfilter_tapset_old = st->postfilter_tapset; - st->postfilter_period = postfilter_pitch; - st->postfilter_gain = postfilter_gain; - st->postfilter_tapset = postfilter_tapset; - if (LM!=0) - { - st->postfilter_period_old = st->postfilter_period; - st->postfilter_gain_old = st->postfilter_gain; - st->postfilter_tapset_old = st->postfilter_tapset; - } - - if (C==1) - OPUS_COPY(&oldBandE[nbEBands], oldBandE, nbEBands); - - if (!isTransient) - { - OPUS_COPY(oldLogE2, oldLogE, 2*nbEBands); - OPUS_COPY(oldLogE, oldBandE, 2*nbEBands); - } else { - for (i=0;i<2*nbEBands;i++) - oldLogE[i] = MING(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)*GCONST(0.001f); - for (i=0;i<2*nbEBands;i++) - backgroundLogE[i] = MING(backgroundLogE[i] + max_background_increase, oldBandE[i]); - /* In case start or end were to change */ - c=0; do - { - for (i=0;irng = dec->rng; -#ifdef ENABLE_QEXT - if (qext_bytes) st->rng = st->rng ^ ext_dec.rng; -#endif - - deemphasis(out_syn, pcm, N, CC, st->downsample, mode->preemph, st->preemph_memD, accum); - st->loss_duration = 0; - st->plc_duration = 0; - st->last_frame_type = FRAME_NORMAL; - st->prefilter_and_fold = 0; - RESTORE_STACK; - if (ec_tell(dec) > 8*len) - return OPUS_INTERNAL_ERROR; -#ifdef ENABLE_QEXT - if (qext_bytes != 0 && ec_tell(&ext_dec) > 8*qext_bytes) - return OPUS_INTERNAL_ERROR; -#endif - if(ec_get_error(dec)) - st->error = 1; - return frame_size/st->downsample; + } while (++c < CC); + st->postfilter_period_old = st->postfilter_period; + st->postfilter_gain_old = st->postfilter_gain; + st->postfilter_tapset_old = st->postfilter_tapset; + st->postfilter_period = postfilter_pitch; + st->postfilter_gain = postfilter_gain; + st->postfilter_tapset = postfilter_tapset; + if (LM != 0) { + st->postfilter_period_old = st->postfilter_period; + st->postfilter_gain_old = st->postfilter_gain; + st->postfilter_tapset_old = st->postfilter_tapset; + } + + if (C == 1) + OAC_COPY(&oldBandE[nbEBands], oldBandE, nbEBands); + + if (!isTransient) { + OAC_COPY(oldLogE2, oldLogE, 2*nbEBands); + OAC_COPY(oldLogE, oldBandE, 2*nbEBands); + } else { + for (i = 0; i < 2*nbEBands; i++) + oldLogE[i] = MING(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)*GCONST(0.001f); + for (i = 0; i < 2*nbEBands; i++) + backgroundLogE[i] = MING(backgroundLogE[i] + max_background_increase, oldBandE[i]); + /* In case start or end were to change */ + c = 0; do { + for (i = 0; i < start; i++) { + oldBandE[c*nbEBands + i] = 0; + oldLogE[c*nbEBands + i] = oldLogE2[c*nbEBands + i] = -GCONST(28.f); + } + for (i = end; i < nbEBands; i++) { + oldBandE[c*nbEBands + i] = 0; + oldLogE[c*nbEBands + i] = oldLogE2[c*nbEBands + i] = -GCONST(28.f); + } + } while (++c < 2); + st->rng = dec->rng; + + oaci_deemphasis(out_syn, pcm, N, CC, st->downsample, mode->preemph, st->preemph_memD, accum); + st->loss_duration = 0; + st->plc_duration = 0; + st->last_frame_type = FRAME_NORMAL; + st->prefilter_and_fold = 0; + RESTORE_STACK; + if (oaci_ec_tell(dec) > 8*len) + return OAC_INTERNAL_ERROR; + if (oaci_ec_get_error(dec)) + st->error = 1; + return frame_size/st->downsample; } -int celt_decode_with_ec(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, - int len, opus_res * OPUS_RESTRICT pcm, int frame_size, ec_dec *dec, int accum) -{ - return celt_decode_with_ec_dred(st, data, len, pcm, frame_size, dec, accum +int oaci_celt_decode_with_ec(CELTDecoder * OAC_RESTRICT st, const unsigned char *data, + int len, oac_res * OAC_RESTRICT pcm, int frame_size, ec_dec *dec, int accum) { + return oaci_celt_decode_with_ec_dred(st, data, len, pcm, frame_size, dec, accum #ifdef ENABLE_DEEP_PLC - , NULL + , NULL #endif - ARG_QEXT(NULL) ARG_QEXT(0) - ); + ); } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) -#if defined(FIXED_POINT) && !defined(ENABLE_RES24) -int opus_custom_decode(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int16 * OPUS_RESTRICT pcm, int frame_size) -{ - return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL, 0); -} -#else -int opus_custom_decode(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int16 * OPUS_RESTRICT pcm, int frame_size) -{ - int j, ret, C, N; - VARDECL(opus_res, out); - ALLOC_STACK; - - if (pcm==NULL) - return OPUS_BAD_ARG; - - C = st->channels; - N = frame_size; - - ALLOC(out, C*N, opus_res); - ret = celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0); - if (ret>0) - for (j=0;jchannels; + N = frame_size; + + ALLOC(out, C*N, oac_res); + ret = oaci_celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0); + if (ret > 0) + for (j = 0; j < C*ret; j++) + pcm[j] = RES2INT16(out[j]); + + RESTORE_STACK; + return ret; } -#endif -#if defined(FIXED_POINT) && defined(ENABLE_RES24) -int opus_custom_decode24(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int32 * OPUS_RESTRICT pcm, int frame_size) -{ - return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL, 0); +# if defined(FIXED_POINT) +int oac_custom_decode24(CELTDecoder * OAC_RESTRICT st, const unsigned char *data, int len, oac_int32 * OAC_RESTRICT pcm, + int frame_size) { + return oaci_celt_decode_with_ec(st, data, len, pcm, frame_size, NULL, 0); } -#else -int opus_custom_decode24(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, opus_int32 * OPUS_RESTRICT pcm, int frame_size) -{ - int j, ret, C, N; - VARDECL(opus_res, out); - ALLOC_STACK; - - if (pcm==NULL) - return OPUS_BAD_ARG; - - C = st->channels; - N = frame_size; - - ALLOC(out, C*N, opus_res); - ret = celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0); - if (ret>0) - for (j=0;jchannels; + N = frame_size; + + ALLOC(out, C*N, oac_res); + ret = oaci_celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0); + if (ret > 0) + for (j = 0; j < C*ret; j++) + pcm[j] = RES2INT24(out[j]); + + RESTORE_STACK; + return ret; } -#endif +# endif -#ifndef DISABLE_FLOAT_API +# ifndef DISABLE_FLOAT_API -# if !defined(FIXED_POINT) -int opus_custom_decode_float(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, float * OPUS_RESTRICT pcm, int frame_size) -{ - return celt_decode_with_ec(st, data, len, pcm, frame_size, NULL, 0); +# if !defined(FIXED_POINT) +int oac_custom_decode_float(CELTDecoder * OAC_RESTRICT st, const unsigned char *data, int len, float * OAC_RESTRICT pcm, + int frame_size) { + return oaci_celt_decode_with_ec(st, data, len, pcm, frame_size, NULL, 0); } -# else -int opus_custom_decode_float(CELTDecoder * OPUS_RESTRICT st, const unsigned char *data, int len, float * OPUS_RESTRICT pcm, int frame_size) -{ - int j, ret, C, N; - VARDECL(opus_res, out); - ALLOC_STACK; - - if (pcm==NULL) - return OPUS_BAD_ARG; - - C = st->channels; - N = frame_size; - - ALLOC(out, C*N, opus_res); - ret=celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0); - if (ret>0) - for (j=0;jchannels; + N = frame_size; + + ALLOC(out, C*N, oac_res); + ret = oaci_celt_decode_with_ec(st, data, len, out, frame_size, NULL, 0); + if (ret > 0) + for (j = 0; j < C*ret; j++) + pcm[j] = RES2FLOAT(out[j]); + + RESTORE_STACK; + return ret; } -# endif +# endif -#endif +# endif #endif /* CUSTOM_MODES */ -int opus_custom_decoder_ctl(CELTDecoder * OPUS_RESTRICT st, int request, ...) -{ - va_list ap; - - va_start(ap, request); - switch (request) - { - case OPUS_SET_COMPLEXITY_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value<0 || value>10) - { - goto bad_arg; - } - st->complexity = value; - } - break; - case OPUS_GET_COMPLEXITY_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->complexity; - } - break; - case CELT_SET_START_BAND_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value<0 || value>=st->mode->nbEBands) - goto bad_arg; - st->start = value; - } - break; - case CELT_SET_END_BAND_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value<1 || value>st->mode->nbEBands) - goto bad_arg; - st->end = value; - } - break; - case CELT_SET_CHANNELS_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value<1 || value>2) - goto bad_arg; - st->stream_channels = value; - } - break; - case CELT_GET_AND_CLEAR_ERROR_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (value==NULL) - goto bad_arg; - *value=st->error; - st->error = 0; - } - break; - case OPUS_GET_LOOKAHEAD_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (value==NULL) - goto bad_arg; - *value = st->overlap/st->downsample; - } - break; - case OPUS_RESET_STATE: - { - int i; - celt_glog *oldBandE, *oldLogE, *oldLogE2; - int decode_buffer_size; +int oac_custom_decoder_ctl(CELTDecoder * OAC_RESTRICT st, int request, ...) { + va_list ap; + + va_start(ap, request); + switch (request) { + case OAC_SET_COMPLEXITY_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + if (value < 0 || value > 10) { + goto bad_arg; + } + st->complexity = value; + } + break; + case OAC_GET_COMPLEXITY_REQUEST: + { + oac_int32 *value = va_arg(ap, oac_int32*); + if (!value) { + goto bad_arg; + } + *value = st->complexity; + } + break; + case CELT_SET_START_BAND_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + if (value < 0 || value >= st->mode->nbEBands) + goto bad_arg; + st->start = value; + } + break; + case CELT_SET_END_BAND_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + if (value < 1 || value > st->mode->nbEBands) + goto bad_arg; + st->end = value; + } + break; + case CELT_SET_CHANNELS_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + if (value < 1 || value > 2) + goto bad_arg; + st->stream_channels = value; + } + break; + case CELT_GET_AND_CLEAR_ERROR_REQUEST: + { + oac_int32 *value = va_arg(ap, oac_int32*); + if (value == NULL) + goto bad_arg; + *value = st->error; + st->error = 0; + } + break; + case OAC_GET_LOOKAHEAD_REQUEST: + { + oac_int32 *value = va_arg(ap, oac_int32*); + if (value == NULL) + goto bad_arg; + *value = st->overlap/st->downsample; + } + break; + case OAC_RESET_STATE: + { + int i; + celt_glog *oldBandE, *oldLogE, *oldLogE2; + int decode_buffer_size; #ifdef ENABLE_QEXT - int qext_scale = st->qext_scale; + int qext_scale = st->qext_scale; #endif - decode_buffer_size = QEXT_SCALE(DECODE_BUFFER_SIZE); - oldBandE = (celt_glog*)(st->_decode_mem+(decode_buffer_size+st->overlap)*st->channels); - oldLogE = oldBandE + 2*st->mode->nbEBands; - oldLogE2 = oldLogE + 2*st->mode->nbEBands; - OPUS_CLEAR((char*)&st->DECODER_RESET_START, - opus_custom_decoder_get_size(st->mode, st->channels)- - ((char*)&st->DECODER_RESET_START - (char*)st)); - for (i=0;i<2*st->mode->nbEBands;i++) - oldLogE[i]=oldLogE2[i]=-GCONST(28.f); - st->skip_plc = 1; - st->last_frame_type = FRAME_NONE; - } - break; - case OPUS_GET_PITCH_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (value==NULL) - goto bad_arg; - *value = st->postfilter_period; - } - break; - case CELT_GET_MODE_REQUEST: - { - const CELTMode ** value = va_arg(ap, const CELTMode**); - if (value==0) - goto bad_arg; - *value=st->mode; - } - break; - case CELT_SET_SIGNALLING_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - st->signalling = value; - } - break; - case OPUS_GET_FINAL_RANGE_REQUEST: - { - opus_uint32 * value = va_arg(ap, opus_uint32 *); - if (value==0) - goto bad_arg; - *value=st->rng; - } - break; - case OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value<0 || value>1) - { - goto bad_arg; - } - st->disable_inv = value; - } - break; - case OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->disable_inv; - } - break; - default: - goto bad_request; - } - va_end(ap); - return OPUS_OK; + decode_buffer_size = QEXT_SCALE(DECODE_BUFFER_SIZE); + oldBandE = (celt_glog*)(st->_decode_mem + (decode_buffer_size + st->overlap)*st->channels); + oldLogE = oldBandE + 2*st->mode->nbEBands; + oldLogE2 = oldLogE + 2*st->mode->nbEBands; + OAC_CLEAR((char*)&st->DECODER_RESET_START, + oac_custom_decoder_get_size(st->mode, st->channels) + - ((char*)&st->DECODER_RESET_START - (char*)st)); + for (i = 0; i < 2*st->mode->nbEBands; i++) + oldLogE[i] = oldLogE2[i] = -GCONST(28.f); + st->skip_plc = 1; + st->last_frame_type = FRAME_NONE; + } + break; + case OAC_GET_PITCH_REQUEST: + { + oac_int32 *value = va_arg(ap, oac_int32*); + if (value == NULL) + goto bad_arg; + *value = st->postfilter_period; + } + break; + case CELT_GET_MODE_REQUEST: + { + const CELTMode ** value = va_arg(ap, const CELTMode**); + if (value == 0) + goto bad_arg; + *value = st->mode; + } + break; + case CELT_SET_SIGNALLING_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + st->signalling = value; + } + break; + case OAC_GET_FINAL_RANGE_REQUEST: + { + oac_uint32 * value = va_arg(ap, oac_uint32 *); + if (value == 0) + goto bad_arg; + *value = st->rng; + } + break; + case OAC_SET_PHASE_INVERSION_DISABLED_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + if (value < 0 || value > 1) { + goto bad_arg; + } + st->disable_inv = value; + } + break; + case OAC_GET_PHASE_INVERSION_DISABLED_REQUEST: + { + oac_int32 *value = va_arg(ap, oac_int32*); + if (!value) { + goto bad_arg; + } + *value = st->disable_inv; + } + break; + default: + goto bad_request; + } + va_end(ap); + return OAC_OK; bad_arg: - va_end(ap); - return OPUS_BAD_ARG; + va_end(ap); + return OAC_BAD_ARG; bad_request: - va_end(ap); - return OPUS_UNIMPLEMENTED; + va_end(ap); + return OAC_UNIMPLEMENTED; } diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c index ab97ed677..993b92641 100644 --- a/celt/celt_encoder.c +++ b/celt/celt_encoder.c @@ -25,10 +25,10 @@ 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" +# include "config.h" #endif #define CELT_ENCODER_C @@ -53,3109 +53,2770 @@ #ifndef M_PI -#define M_PI 3.141592653 +# define M_PI 3.141592653 #endif /** Encoder state - @brief Encoder state + @brief Encoder state */ -struct OpusCustomEncoder { - const OpusCustomMode *mode; /**< Mode used by the encoder */ - int channels; - int stream_channels; - - int force_intra; - int clip; - int disable_pf; - int complexity; - int upsample; - int start, end; - - opus_int32 bitrate; - int vbr; - int signalling; - int constrained_vbr; /* If zero, VBR can do whatever it likes with the rate */ - int loss_rate; - int lsb_depth; - int lfe; - int disable_inv; - int arch; +struct OacCustomEncoder { + const OacCustomMode *mode; /**< Mode used by the encoder */ + int channels; + int stream_channels; + + int force_intra; + int clip; + int disable_pf; + int complexity; + int upsample; + int start, end; + + oac_int32 bitrate; + int vbr; + int signalling; + int constrained_vbr; /* If zero, VBR can do whatever it likes with the rate */ + int loss_rate; + int lsb_depth; + int lfe; + int disable_inv; + int arch; #ifdef ENABLE_QEXT - int enable_qext; - int qext_scale; + int qext_scale; #endif - /* Everything beyond this point gets cleared on a reset */ + /* Everything beyond this point gets cleared on a reset */ #define ENCODER_RESET_START rng - opus_uint32 rng; - int spread_decision; - opus_val32 delayedIntra; - int tonal_average; - int lastCodedBands; - int hf_average; - int tapset_decision; - - int prefilter_period; - opus_val16 prefilter_gain; - int prefilter_tapset; + oac_uint32 rng; + int spread_decision; + oac_val32 delayedIntra; + int tonal_average; + int lastCodedBands; + int hf_average; + int tapset_decision; + + int prefilter_period; + oac_val16 prefilter_gain; + int prefilter_tapset; #ifdef RESYNTH - int prefilter_period_old; - opus_val16 prefilter_gain_old; - int prefilter_tapset_old; -#endif - int consec_transient; - AnalysisInfo analysis; - SILKInfo silk_info; - - opus_val32 preemph_memE[2]; - opus_val32 preemph_memD[2]; - - /* VBR-related parameters */ - opus_int32 vbr_reservoir; - opus_int32 vbr_drift; - opus_int32 vbr_offset; - opus_int32 vbr_count; - opus_val32 overlap_max; - opus_val16 stereo_saving; - int intensity; - celt_glog *energy_mask; - celt_glog spec_avg; + int prefilter_period_old; + oac_val16 prefilter_gain_old; + int prefilter_tapset_old; +#endif + int consec_transient; + AnalysisInfo analysis; + SILKInfo silk_info; + + oac_val32 preemph_memE[2]; + oac_val32 preemph_memD[2]; + + /* VBR-related parameters */ + oac_int32 vbr_reservoir; + oac_int32 vbr_drift; + oac_int32 vbr_offset; + oac_int32 vbr_count; + oac_val32 overlap_max; + oac_val16 stereo_saving; + int intensity; + celt_glog *energy_mask; + celt_glog spec_avg; #ifdef RESYNTH -#ifdef ENABLE_QEXT - /* +MAX_PERIOD/2 to make space for overlap */ - celt_sig syn_mem[2][2*DEC_PITCH_BUF_SIZE+MAX_PERIOD]; -#else - /* +MAX_PERIOD/2 to make space for overlap */ - celt_sig syn_mem[2][DEC_PITCH_BUF_SIZE+MAX_PERIOD/2]; -#endif +# ifdef ENABLE_QEXT + /* +MAX_PERIOD/2 to make space for overlap */ + celt_sig syn_mem[2][2*DEC_PITCH_BUF_SIZE + MAX_PERIOD]; +# else + /* +MAX_PERIOD/2 to make space for overlap */ + celt_sig syn_mem[2][DEC_PITCH_BUF_SIZE + MAX_PERIOD/2]; +# endif #endif - celt_sig in_mem[1]; /* Size = channels*mode->overlap */ - /* celt_sig prefilter_mem[], Size = channels*COMBFILTER_MAXPERIOD */ - /* celt_glog oldBandE[], Size = channels*mode->nbEBands */ - /* celt_glog oldLogE[], Size = channels*mode->nbEBands */ - /* celt_glog oldLogE2[], Size = channels*mode->nbEBands */ - /* celt_glog energyError[], Size = channels*mode->nbEBands */ + celt_sig in_mem[1]; /* Size = channels*mode->overlap */ + /* celt_sig prefilter_mem[], Size = channels*COMBFILTER_MAXPERIOD */ + /* celt_glog oldBandE[], Size = channels*mode->nbEBands */ + /* celt_glog oldLogE[], Size = channels*mode->nbEBands */ + /* celt_glog oldLogE2[], Size = channels*mode->nbEBands */ + /* celt_glog energyError[], Size = channels*mode->nbEBands */ }; -int celt_encoder_get_size(int channels) -{ +int oaci_celt_encoder_get_size(int channels) { #ifdef ENABLE_QEXT - CELTMode *mode = opus_custom_mode_create(96000, 1920, NULL); + CELTMode *mode = oac_custom_mode_create(96000, 1920, NULL); #else - CELTMode *mode = opus_custom_mode_create(48000, 960, NULL); + CELTMode *mode = oac_custom_mode_create(48000, 960, NULL); #endif - return opus_custom_encoder_get_size(mode, channels); + return oac_custom_encoder_get_size(mode, channels); } -OPUS_CUSTOM_NOSTATIC int opus_custom_encoder_get_size(const CELTMode *mode, int channels) -{ - int extra=0; - int size; +OAC_CUSTOM_NOSTATIC int oac_custom_encoder_get_size(const CELTMode *mode, int channels) { + int size; #ifdef ENABLE_QEXT - int qext_scale; - extra = channels*NB_QEXT_BANDS*sizeof(celt_glog); - if (mode->Fs == 96000 && (mode->shortMdctSize==240 || mode->shortMdctSize==180)) { - qext_scale = 2; - } else qext_scale = 1; -#endif - size = sizeof(struct CELTEncoder) - + (channels*mode->overlap-1)*sizeof(celt_sig) /* celt_sig in_mem[channels*mode->overlap]; */ - + channels*QEXT_SCALE(COMBFILTER_MAXPERIOD)*sizeof(celt_sig) /* celt_sig prefilter_mem[channels*COMBFILTER_MAXPERIOD]; */ - + 4*channels*mode->nbEBands*sizeof(celt_glog) /* celt_glog oldBandE[channels*mode->nbEBands]; */ + int qext_scale; + if (mode->Fs == 96000 && (mode->shortMdctSize == 240 || mode->shortMdctSize == 180)) { + qext_scale = 2; + } else qext_scale = 1; +#endif + size = sizeof(struct CELTEncoder) + + (channels*mode->overlap - 1)*sizeof(celt_sig) /* celt_sig in_mem[channels*mode->overlap]; */ + + channels*QEXT_SCALE(COMBFILTER_MAXPERIOD)*sizeof(celt_sig) /* celt_sig prefilter_mem[channels*COMBFILTER_MAXPERIOD]; */ + + 4*channels*mode->nbEBands*sizeof(celt_glog); /* celt_glog oldBandE[channels*mode->nbEBands]; */ /* celt_glog oldLogE[channels*mode->nbEBands]; */ /* celt_glog oldLogE2[channels*mode->nbEBands]; */ /* celt_glog energyError[channels*mode->nbEBands]; */ - + extra; - return size; + return size; } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -CELTEncoder *opus_custom_encoder_create(const CELTMode *mode, int channels, int *error) -{ - int ret; - CELTEncoder *st = (CELTEncoder *)opus_alloc(opus_custom_encoder_get_size(mode, channels)); - /* init will handle the NULL case */ - ret = opus_custom_encoder_init(st, mode, channels); - if (ret != OPUS_OK) - { - opus_custom_encoder_destroy(st); - st = NULL; - } - if (error) - *error = ret; - return st; +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) +CELTEncoder *oac_custom_encoder_create(const CELTMode *mode, int channels, int *error) { + int ret; + CELTEncoder *st = (CELTEncoder *)oac_alloc(oac_custom_encoder_get_size(mode, channels)); + /* init will handle the NULL case */ + ret = oac_custom_encoder_init(st, mode, channels); + if (ret != OAC_OK) { + oac_custom_encoder_destroy(st); + st = NULL; + } + if (error) + *error = ret; + return st; } #endif /* CUSTOM_MODES */ -static int opus_custom_encoder_init_arch(CELTEncoder *st, const CELTMode *mode, - int channels, int arch) -{ - if (channels < 0 || channels > 2) - return OPUS_BAD_ARG; +static int oac_custom_encoder_init_arch(CELTEncoder *st, const CELTMode *mode, + int channels, int arch) { + if (channels < 0 || channels > 2) + return OAC_BAD_ARG; - if (st==NULL || mode==NULL) - return OPUS_ALLOC_FAIL; + if (st == NULL || mode == NULL) + return OAC_ALLOC_FAIL; - OPUS_CLEAR((char*)st, opus_custom_encoder_get_size(mode, channels)); + OAC_CLEAR((char*)st, oac_custom_encoder_get_size(mode, channels)); - st->mode = mode; - st->stream_channels = st->channels = channels; + st->mode = mode; + st->stream_channels = st->channels = channels; - st->upsample = 1; - st->start = 0; - st->end = st->mode->effEBands; - st->signalling = 1; - st->arch = arch; + st->upsample = 1; + st->start = 0; + st->end = st->mode->effEBands; + st->signalling = 1; + st->arch = arch; - st->constrained_vbr = 1; - st->clip = 1; + st->constrained_vbr = 1; + st->clip = 1; - st->bitrate = OPUS_BITRATE_MAX; - st->vbr = 0; - st->force_intra = 0; - st->complexity = 5; - st->lsb_depth=24; + st->bitrate = OAC_BITRATE_MAX; + st->vbr = 0; + st->force_intra = 0; + st->complexity = 5; + st->lsb_depth = 24; #ifdef ENABLE_QEXT - if (st->mode->Fs == 96000 && (mode->shortMdctSize==240 || mode->shortMdctSize==180)) st->qext_scale = 2; - else st->qext_scale = 1; + if (st->mode->Fs == 96000 && (mode->shortMdctSize == 240 || mode->shortMdctSize == 180)) st->qext_scale = 2; + else st->qext_scale = 1; #endif - opus_custom_encoder_ctl(st, OPUS_RESET_STATE); + oac_custom_encoder_ctl(st, OAC_RESET_STATE); - return OPUS_OK; + return OAC_OK; } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -int opus_custom_encoder_init(CELTEncoder *st, const CELTMode *mode, int channels) -{ - return opus_custom_encoder_init_arch(st, mode, channels, opus_select_arch()); +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) +int oac_custom_encoder_init(CELTEncoder *st, const CELTMode *mode, int channels) { + return oac_custom_encoder_init_arch(st, mode, channels, oac_select_arch()); } #endif -int celt_encoder_init(CELTEncoder *st, opus_int32 sampling_rate, int channels, - int arch) -{ - int ret; +int oaci_celt_encoder_init(CELTEncoder *st, oac_int32 sampling_rate, int channels, + int arch) { + int ret; #ifdef ENABLE_QEXT - if (sampling_rate==96000) { - st->upsample = 1; - return opus_custom_encoder_init_arch(st, - opus_custom_mode_create(96000, 1920, NULL), channels, arch); - } -#endif - ret = opus_custom_encoder_init_arch(st, - opus_custom_mode_create(48000, 960, NULL), channels, arch); - if (ret != OPUS_OK) - return ret; - st->upsample = resampling_factor(sampling_rate); - return OPUS_OK; + if (sampling_rate == 96000) { + st->upsample = 1; + return oac_custom_encoder_init_arch(st, + oac_custom_mode_create(96000, 1920, NULL), channels, arch); + } +#endif + ret = oac_custom_encoder_init_arch(st, + oac_custom_mode_create(48000, 960, NULL), channels, arch); + if (ret != OAC_OK) + return ret; + st->upsample = oaci_resampling_factor(sampling_rate); + return OAC_OK; } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -void opus_custom_encoder_destroy(CELTEncoder *st) -{ - opus_free(st); +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) +void oac_custom_encoder_destroy(CELTEncoder *st) { + oac_free(st); } #endif /* CUSTOM_MODES */ -static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int C, - opus_val16 *tf_estimate, int *tf_chan, int allow_weak_transients, - int *weak_transient, opus_val16 tone_freq, opus_val32 toneishness) -{ - int i; - VARDECL(opus_val16, tmp); - opus_val32 mem0,mem1; - int is_transient = 0; - opus_int32 mask_metric = 0; - int c; - opus_val16 tf_max; - int len2; - /* Forward masking: 6.7 dB/ms. */ +static int oaci_transient_analysis(const oac_val32 * OAC_RESTRICT in, int len, int C, + oac_val16 *tf_estimate, int *tf_chan, int allow_weak_transients, + int *weak_transient, oac_val16 tone_freq, oac_val32 toneishness) { + int i; + VARDECL(oac_val16, tmp); + oac_val32 mem0, mem1; + int is_transient = 0; + oac_int32 mask_metric = 0; + int c; + oac_val16 tf_max; + int len2; + /* Forward masking: 6.7 dB/ms. */ #ifdef FIXED_POINT - int forward_shift = 4; + int forward_shift = 4; #else - opus_val16 forward_decay = QCONST16(.0625f,15); -#endif - /* Table of 6*64/x, trained on real data to minimize the average error */ - static const unsigned char inv_table[128] = { - 255,255,156,110, 86, 70, 59, 51, 45, 40, 37, 33, 31, 28, 26, 25, - 23, 22, 21, 20, 19, 18, 17, 16, 16, 15, 15, 14, 13, 13, 12, 12, - 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, - 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, - }; - SAVE_STACK; + oac_val16 forward_decay = QCONST16(.0625f, 15); +#endif + /* Table of 6*64/x, trained on real data to minimize the average error */ + static const unsigned char inv_table[128] = { + 255, 255, 156, 110, 86, 70, 59, 51, 45, 40, 37, 33, 31, 28, 26, 25, + 23, 22, 21, 20, 19, 18, 17, 16, 16, 15, 15, 14, 13, 13, 12, 12, + 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, + 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, + }; + SAVE_STACK; #ifdef FIXED_POINT - int in_shift = IMAX(0, celt_ilog2(1+celt_maxabs32(in, C*len))-14); + int in_shift = IMAX(0, oaci_celt_ilog2(1 + celt_maxabs32(in, C*len)) - 14); #endif - ALLOC(tmp, len, opus_val16); - - *weak_transient = 0; - /* For lower bitrates, let's be more conservative and have a forward masking - decay of 3.3 dB/ms. This avoids having to code transients at very low - bitrate (mostly for hybrid), which can result in unstable energy and/or - partial collapse. */ - if (allow_weak_transients) - { + ALLOC(tmp, len, oac_val16); + + *weak_transient = 0; + /* For lower bitrates, let's be more conservative and have a forward masking + decay of 3.3 dB/ms. This avoids having to code transients at very low + bitrate (mostly for hybrid), which can result in unstable energy and/or + partial collapse. */ + if (allow_weak_transients) { #ifdef FIXED_POINT - forward_shift = 5; + forward_shift = 5; #else - forward_decay = QCONST16(.03125f,15); -#endif - } - len2=len/2; - for (c=0;c=0;i--) - { - /* Backward masking: 13.9 dB/ms. */ + } + + mem0 = 0; + maxE = 0; + /* Backward pass to compute the pre-echo threshold */ + for (i = len2 - 1; i >= 0; i--) { + /* Backward masking: 13.9 dB/ms. */ #ifdef FIXED_POINT - /* FIXME: Use PSHR16() instead */ - mem0 = mem0 + PSHR32(SHL32(tmp[i],4)-mem0,3); - tmp[i] = PSHR32(mem0, 4); - maxE = MAX16(maxE, tmp[i]); + /* FIXME: Use PSHR16() instead */ + mem0 = mem0 + PSHR32(SHL32(tmp[i], 4) - mem0, 3); + tmp[i] = PSHR32(mem0, 4); + maxE = MAX16(maxE, tmp[i]); #else - mem0 = tmp[i] + 0.875f*mem0; - tmp[i] = 0.125f*mem0; - maxE = MAX16(maxE, 0.125f*mem0); + mem0 = tmp[i] + 0.875f*mem0; + tmp[i] = 0.125f*mem0; + maxE = MAX16(maxE, 0.125f*mem0); #endif - } - /*for (i=0;i>1))); + /* Costs two sqrt() to avoid overflows */ + mean = MULT16_16(oaci_celt_sqrt(mean), oaci_celt_sqrt(MULT16_16(maxE, len2>>1))); #else - mean = celt_sqrt(mean * maxE*.5*len2); -#endif - /* Inverse of the mean energy in Q15+6 */ - norm = SHL32(EXTEND32(len2),6+14)/ADD32(EPSILON,SHR32(mean,1)); - /* Compute harmonic mean discarding the unreliable boundaries - The data is smooth, so we only take 1/4th of the samples */ - unmask=0; - /* We should never see NaNs here. If we find any, then something really bad happened and we better abort - before it does any damage later on. If these asserts are disabled (no hardening), then the table - lookup a few lines below (id = ...) is likely to crash dur to an out-of-bounds read. DO NOT FIX - that crash on NaN since it could result in a worse issue later on. */ - celt_assert(!celt_isnan(tmp[0])); - celt_assert(!celt_isnan(norm)); - for (i=12;imask_metric) - { - *tf_chan = c; - mask_metric = unmask; - } - } - is_transient = mask_metric>200; - /* Prevent the transient detector from confusing the partial cycle of a - very low frequency tone with a transient. */ - if (toneishness > QCONST32(.98f, 29) && tone_freq < QCONST16(0.026f, 13)) - { - is_transient = 0; - mask_metric = 0; - } - /* For low bitrates, define "weak transients" that need to be - handled differently to avoid partial collapse. */ - if (allow_weak_transients && is_transient && mask_metric<600) { - is_transient = 0; - *weak_transient = 1; - } - /* Arbitrary metric for VBR boost */ - tf_max = MAX16(0,celt_sqrt(27*mask_metric)-42); - /* *tf_estimate = 1 + MIN16(1, sqrt(MAX16(0, tf_max-30))/20); */ - *tf_estimate = celt_sqrt(MAX32(0, SHL32(MULT16_16(QCONST16(0.0069,14),MIN16(163,tf_max)),14)-QCONST32(0.139,28))); - /*printf("%d %f\n", tf_max, mask_metric);*/ - RESTORE_STACK; + id = (int)MAX32(0, MIN32(127, floor(64*norm*(tmp[i] + EPSILON)))); /* Do not round to nearest */ +#endif + unmask += inv_table[id]; + } + /*printf("%d\n", unmask);*/ + /* Normalize, compensate for the 1/4th of the sample and the factor of 6 in the inverse table */ + unmask = 64*unmask*4/(6*(len2 - 17)); + if (unmask > mask_metric) { + *tf_chan = c; + mask_metric = unmask; + } + } + is_transient = mask_metric > 200; + /* Prevent the transient detector from confusing the partial cycle of a + very low frequency tone with a transient. */ + if (toneishness > QCONST32(.98f, 29) && tone_freq < QCONST16(0.026f, 13)) { + is_transient = 0; + mask_metric = 0; + } + /* For low bitrates, define "weak transients" that need to be + handled differently to avoid partial collapse. */ + if (allow_weak_transients && is_transient && mask_metric < 600) { + is_transient = 0; + *weak_transient = 1; + } + /* Arbitrary metric for VBR boost */ + tf_max = MAX16(0, oaci_celt_sqrt(27*mask_metric) - 42); + /* *tf_estimate = 1 + MIN16(1, sqrt(MAX16(0, tf_max-30))/20); */ + *tf_estimate = oaci_celt_sqrt(MAX32(0, + SHL32(MULT16_16(QCONST16(0.0069, 14), MIN16(163, tf_max)), 14) - QCONST32(0.139, 28))); + /*printf("%d %f\n", tf_max, mask_metric);*/ + RESTORE_STACK; #ifdef FUZZING - is_transient = rand()&0x1; + is_transient = rand()&0x1; #endif - /*printf("%d %f %d\n", is_transient, (float)*tf_estimate, tf_max);*/ - return is_transient; + /*printf("%d %f %d\n", is_transient, (float)*tf_estimate, tf_max);*/ + return is_transient; } /* Looks for sudden increases of energy to decide whether we need to patch the transient decision */ -static int patch_transient_decision(celt_glog *newE, celt_glog *oldE, int nbEBands, - int start, int end, int C) -{ - int i, c; - opus_val32 mean_diff=0; - celt_glog spread_old[26]; - /* Apply an aggressive (-6 dB/Bark) spreading function to the old frame to - avoid false detection caused by irrelevant bands */ - if (C==1) - { - spread_old[start] = oldE[start]; - for (i=start+1;i=start;i--) - spread_old[i] = MAXG(spread_old[i], spread_old[i+1]-GCONST(1.0f)); - /* Compute mean increase */ - c=0; do { - for (i=IMAX(2,start);i GCONST(1.f); +static int oaci_patch_transient_decision(celt_glog *newE, celt_glog *oldE, int nbEBands, + int start, int end, int C) { + int i, c; + oac_val32 mean_diff = 0; + celt_glog spread_old[26]; + /* Apply an aggressive (-6 dB/Bark) spreading function to the old frame to + avoid false detection caused by irrelevant bands */ + if (C == 1) { + spread_old[start] = oldE[start]; + for (i = start + 1; i < end; i++) + spread_old[i] = MAXG(spread_old[i - 1] - GCONST(1.0f), oldE[i]); + } else { + spread_old[start] = MAXG(oldE[start], oldE[start + nbEBands]); + for (i = start + 1; i < end; i++) + spread_old[i] = MAXG(spread_old[i - 1] - GCONST(1.0f), + MAXG(oldE[i], oldE[i + nbEBands])); + } + for (i = end - 2; i >= start; i--) + spread_old[i] = MAXG(spread_old[i], spread_old[i + 1] - GCONST(1.0f)); + /* Compute mean increase */ + c = 0; do { + for (i = IMAX(2, start); i < end - 1; i++) { + oac_val16 x1, x2; + x1 = MAXG(0, newE[i + c*nbEBands]); + x2 = MAXG(0, spread_old[i]); + mean_diff = ADD32(mean_diff, MAXG(0, SUB32(x1, x2))); + } + } while (++c < C); + mean_diff = DIV32(mean_diff, C*(end - 1 - IMAX(2, start))); + /*printf("%f %f %d\n", mean_diff, max_diff, count);*/ + return mean_diff > GCONST(1.f); } /** Apply window and compute the MDCT for all sub-frames and all channels in a frame */ -static void compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * OPUS_RESTRICT in, - celt_sig * OPUS_RESTRICT out, int C, int CC, int LM, int upsample, - int arch) -{ - const int overlap = mode->overlap; - int N; - int B; - int shift; - int i, b, c; - if (shortBlocks) - { - B = shortBlocks; - N = mode->shortMdctSize; - shift = mode->maxLM; - } else { - B = 1; - N = mode->shortMdctSize<maxLM-LM; - } - c=0; do { - for (b=0;bmdct, in+c*(B*N+overlap)+b*N, - &out[b+c*N*B], mode->window, overlap, shift, B, +static void oaci_compute_mdcts(const CELTMode *mode, int shortBlocks, celt_sig * OAC_RESTRICT in, + celt_sig * OAC_RESTRICT out, int C, int CC, int LM, int upsample, + int arch) { + const int overlap = mode->overlap; + int N; + int B; + int shift; + int i, b, c; + if (shortBlocks) { + B = shortBlocks; + N = mode->shortMdctSize; + shift = mode->maxLM; + } else { + B = 1; + N = mode->shortMdctSize<maxLM - LM; + } + c = 0; do { + for (b = 0; b < B; b++) { + /* Interleaving the sub-frames while doing the MDCTs */ + oaci_clt_mdct_forward(&mode->mdct, in + c*(B*N + overlap) + b*N, + &out[b + c*N*B], mode->window, overlap, shift, B, arch); - } - } while (++ceBands[len]-m->eBands[len-1])<eBands[len]-m->eBands[len-1])<eBands[i+1]-m->eBands[i])<eBands[i+1]-m->eBands[i])==1; - OPUS_COPY(tmp, &X[tf_chan*N0 + (m->eBands[i]<eBands[i]<>LM, 1<>k, 1<=0;i--) - { - if (tf_res[i+1] == 1) - tf_res[i] = path1[i+1]; - else - tf_res[i] = path0[i+1]; - } - /*printf("%d %f\n", *tf_sum, tf_estimate);*/ - RESTORE_STACK; +static int oaci_tf_analysis(const CELTMode *m, int len, int isTransient, + int *tf_res, int lambda, celt_norm *X, int N0, int LM, + oac_val16 tf_estimate, int tf_chan, int *importance) { + int i; + VARDECL(int, metric); + int cost0; + int cost1; + VARDECL(int, path0); + VARDECL(int, path1); + VARDECL(celt_norm, tmp); + VARDECL(celt_norm, tmp_1); + int sel; + int selcost[2]; + int tf_select = 0; + oac_val16 bias; + + SAVE_STACK; + bias = MULT16_16_Q14(QCONST16(.04f, 15), MAX16(-QCONST16(.25f, 14), QCONST16(.5f, 14) - tf_estimate)); + /*printf("%f ", bias);*/ + + ALLOC(metric, len, int); + ALLOC(tmp, (m->eBands[len] - m->eBands[len - 1])<eBands[len] - m->eBands[len - 1])<eBands[i + 1] - m->eBands[i])<eBands[i + 1] - m->eBands[i]) == 1; + OAC_COPY(tmp, &X[tf_chan*N0 + (m->eBands[i]<eBands[i]<>LM, 1<>k, 1<= 0; i--) { + if (tf_res[i + 1] == 1) + tf_res[i] = path1[i + 1]; + else + tf_res[i] = path0[i + 1]; + } + /*printf("%d %f\n", *tf_sum, tf_estimate);*/ + RESTORE_STACK; #ifdef FUZZING - tf_select = rand()&0x1; - tf_res[0] = rand()&0x1; - for (i=1;istorage*8; - tell = ec_tell(enc); - logp = isTransient ? 2 : 4; - /* Reserve space to code the tf_select decision. */ - tf_select_rsv = LM>0 && tell+logp+1 <= budget; - budget -= tf_select_rsv; - curr = tf_changed = 0; - for (i=start;istorage*8; + tell = oaci_ec_tell(enc); + logp = isTransient ? 2 : 4; + /* Reserve space to code the tf_select decision. */ + tf_select_rsv = LM > 0 && tell + logp + 1 <= budget; + budget -= tf_select_rsv; + curr = tf_changed = 0; + for (i = start; i < end; i++) { + if (tell + logp <= budget) { + oaci_ec_enc_bit_logp(enc, tf_res[i]^curr, logp); + tell = oaci_ec_tell(enc); + curr = tf_res[i]; + tf_changed |= curr; + } else + tf_res[i] = curr; + logp = isTransient ? 4 : 5; + } + /* Only code tf_select if it would actually make a difference. */ + if (tf_select_rsv + && oaci_tf_select_table[LM][4*isTransient + 0 + tf_changed] != + oaci_tf_select_table[LM][4*isTransient + 2 + tf_changed]) + oaci_ec_enc_bit_logp(enc, tf_select, 1); + else + tf_select = 0; + for (i = start; i < end; i++) + tf_res[i] = oaci_tf_select_table[LM][4*isTransient + 2*tf_select + tf_res[i]]; + /*for(i=0;i> 10; - trim = QCONST16(4.f, 8) + QCONST16(1.f/16.f, 8)*frac; - } - if (C==2) - { - opus_val16 sum = 0; /* Q10 */ - opus_val16 minXC; /* Q10 */ - /* Compute inter-channel correlation for low frequencies */ - for (i=0;i<8;i++) - { - opus_val32 partial; - partial = celt_inner_prod_norm_shift(&X[m->eBands[i]<eBands[i]<eBands[i+1]-m->eBands[i])<eBands[i]<eBands[i]<eBands[i+1]-m->eBands[i])<>10; + trim = QCONST16(4.f, 8) + QCONST16(1.f/16.f, 8)*frac; + } + if (C == 2) { + oac_val16 sum = 0; /* Q10 */ + oac_val16 minXC; /* Q10 */ + /* Compute inter-channel correlation for low frequencies */ + for (i = 0; i < 8; i++) { + oac_val32 partial; + partial = oaci_celt_inner_prod_norm_shift(&X[m->eBands[i]<eBands[i]<eBands[i + 1] - m->eBands[i])<eBands[i]<eBands[i]<eBands[i + 1] - m->eBands[i])<nbEBands], 5)*(opus_int32)(2+2*i-end); - } - } while (++cnbEBands], 5)*(oac_int32)(2 + 2*i - end); + } + } while (++c < C); + diff /= C*(end - 1); + /*printf("%f\n", diff);*/ + trim -= MAX32(-QCONST16(2.f, 8), + MIN32(QCONST16(2.f, 8), SHR32(diff + QCONST32(1.f, DB_SHIFT - 5), DB_SHIFT - 13)/6 )); + trim -= SHR16(surround_trim, DB_SHIFT - 8); + trim -= 2*SHR16(tf_estimate, 14 - 8); #ifndef DISABLE_FLOAT_API - if (analysis->valid) - { - trim -= MAX16(-QCONST16(2.f, 8), MIN16(QCONST16(2.f, 8), - (opus_val16)(QCONST16(2.f, 8)*(analysis->tonality_slope+.05f)))); - } + if (analysis->valid) { + trim -= MAX16(-QCONST16(2.f, 8), MIN16(QCONST16(2.f, 8), + (oac_val16)(QCONST16(2.f, 8)*(analysis->tonality_slope + .05f)))); + } #else - (void)analysis; + (void)analysis; #endif #ifdef FIXED_POINT - trim_index = PSHR32(trim, 8); + trim_index = PSHR32(trim, 8); #else - trim_index = (int)floor(.5f+trim); + trim_index = (int)floor(.5f + trim); #endif - trim_index = IMAX(0, IMIN(10, trim_index)); - /*printf("%d\n", trim_index);*/ + trim_index = IMAX(0, IMIN(10, trim_index)); + /*printf("%d\n", trim_index);*/ #ifdef FUZZING - trim_index = rand()%11; + trim_index = rand()%11; #endif - return trim_index; + return trim_index; } -static int stereo_analysis(const CELTMode *m, const celt_norm *X, - int LM, int N0) -{ - int i; - int thetas; - opus_val32 sumLR = EPSILON, sumMS = EPSILON; - - /* Use the L1 norm to model the entropy of the L/R signal vs the M/S signal */ - for (i=0;i<13;i++) - { - int j; - for (j=m->eBands[i]<eBands[i+1]<eBands[13]<<(LM+1))+thetas, sumMS) - > MULT16_32_Q15(m->eBands[13]<<(LM+1), sumLR); +static int oaci_stereo_analysis(const CELTMode *m, const celt_norm *X, + int LM, int N0) { + int i; + int thetas; + oac_val32 sumLR = EPSILON, sumMS = EPSILON; + + /* Use the L1 norm to model the entropy of the L/R signal vs the M/S signal */ + for (i = 0; i < 13; i++) { + int j; + for (j = m->eBands[i]<eBands[i + 1]<eBands[13]<<(LM + 1)) + thetas, sumMS) > + MULT16_32_Q15(m->eBands[13]<<(LM + 1), sumLR); } -#define MSWAP(a,b) do {celt_glog tmp = a;a=b;b=tmp;} while(0) -static celt_glog median_of_5(const celt_glog *x) -{ - celt_glog t0, t1, t2, t3, t4; - t2 = x[2]; - if (x[0] > x[1]) - { - t0 = x[1]; - t1 = x[0]; - } else { - t0 = x[0]; - t1 = x[1]; - } - if (x[3] > x[4]) - { - t3 = x[4]; - t4 = x[3]; - } else { - t3 = x[3]; - t4 = x[4]; - } - if (t0 > t3) - { - MSWAP(t0, t3); - MSWAP(t1, t4); - } - if (t2 > t1) - { - if (t1 < t3) - return MING(t2, t3); - else - return MING(t4, t1); - } else { - if (t2 < t3) - return MING(t1, t3); - else - return MING(t2, t4); - } +#define MSWAP(a, b) do {celt_glog tmp = a; a = b; b = tmp;} while (0) +static celt_glog oaci_median_of_5(const celt_glog *x) { + celt_glog t0, t1, t2, t3, t4; + t2 = x[2]; + if (x[0] > x[1]) { + t0 = x[1]; + t1 = x[0]; + } else { + t0 = x[0]; + t1 = x[1]; + } + if (x[3] > x[4]) { + t3 = x[4]; + t4 = x[3]; + } else { + t3 = x[3]; + t4 = x[4]; + } + if (t0 > t3) { + MSWAP(t0, t3); + MSWAP(t1, t4); + } + if (t2 > t1) { + if (t1 < t3) + return MING(t2, t3); + else + return MING(t4, t1); + } else { + if (t2 < t3) + return MING(t1, t3); + else + return MING(t2, t4); + } } -static celt_glog median_of_3(const celt_glog *x) -{ - celt_glog t0, t1, t2; - if (x[0] > x[1]) - { - t0 = x[1]; - t1 = x[0]; - } else { - t0 = x[0]; - t1 = x[1]; - } - t2 = x[2]; - if (t1 < t2) - return t1; - else if (t0 < t2) - return t2; - else - return t0; +static celt_glog oaci_median_of_3(const celt_glog *x) { + celt_glog t0, t1, t2; + if (x[0] > x[1]) { + t0 = x[1]; + t1 = x[0]; + } else { + t0 = x[0]; + t1 = x[1]; + } + t2 = x[2]; + if (t1 < t2) + return t1; + else if (t0 < t2) + return t2; + else + return t0; } -static celt_glog dynalloc_analysis(const celt_glog *bandLogE, const celt_glog *bandLogE2, const celt_glog *oldBandE, - int nbEBands, int start, int end, int C, int *offsets, int lsb_depth, const opus_int16 *logN, - int isTransient, int vbr, int constrained_vbr, const opus_int16 *eBands, int LM, - int effectiveBytes, opus_int32 *tot_boost_, int lfe, celt_glog *surround_dynalloc, - AnalysisInfo *analysis, int *importance, int *spread_weight, opus_val16 tone_freq, opus_val32 toneishness - ARG_QEXT(int qext_scale)) -{ - int i, c; - opus_int32 tot_boost=0; - celt_glog maxDepth; - VARDECL(celt_glog, follower); - VARDECL(celt_glog, noise_floor); - VARDECL(celt_glog, bandLogE3); - SAVE_STACK; - ALLOC(follower, C*nbEBands, celt_glog); - ALLOC(noise_floor, C*nbEBands, celt_glog); - ALLOC(bandLogE3, nbEBands, celt_glog); - OPUS_CLEAR(offsets, nbEBands); - /* Dynamic allocation code */ - maxDepth=-GCONST(31.9f); - for (i=0;i=0;i--) - mask[i] = MAXG(mask[i], mask[i+1] - GCONST(3.f)); - for (i=0;i= 0; i--) + mask[i] = MAXG(mask[i], mask[i + 1] - GCONST(3.f)); + for (i = 0; i < end; i++) { + /* Compute SMR: Mask is never more than 72 dB below the peak and never below the noise floor.*/ + celt_glog smr = sig[i] - MAXG(MAXG(0, maxDepth - GCONST(12.f)), mask[i]); + /* Clamp SMR to make sure we're not shifting by something negative or too large. */ #ifdef FIXED_POINT - /* FIXME: Use PSHR16() instead */ - int shift = -PSHR32(MAXG(-GCONST(5.f), MING(0, smr)), DB_SHIFT); + /* FIXME: Use PSHR16() instead */ + int shift = -PSHR32(MAXG(-GCONST(5.f), MING(0, smr)), DB_SHIFT); #else - int shift = IMIN(5, IMAX(0, -(int)floor(.5f + smr))); -#endif - spread_weight[i] = 32 >> shift; - } - /*for (i=0;i= (30 + 5*LM) && !lfe) - { - int last=0; - c=0;do - { - celt_glog offset; - celt_glog tmp; - celt_glog *f; - OPUS_COPY(bandLogE3, &bandLogE2[c*nbEBands], end); - if (LM==0) { - /* For 2.5 ms frames, the first 8 bands have just one bin, so the - energy is highly unreliable (high variance). For that reason, - we take the max with the previous energy so that at least 2 bins - are getting used. */ - for (i=0;i bandLogE3[i-1]+GCONST(.5f)) - last=i; - f[i] = MING(f[i-1]+GCONST(1.5f), bandLogE3[i]); - } - for (i=last-1;i>=0;i--) - f[i] = MING(f[i], MING(f[i+1]+GCONST(2.f), bandLogE3[i])); - - /* Combine with a median filter to avoid dynalloc triggering unnecessarily. - The "offset" value controls how conservative we are -- a higher offset - reduces the impact of the median filter and makes dynalloc use more bits. */ - offset = GCONST(1.f); - for (i=2;i>shift; + } + /*for (i=0;i= (30 + 5*LM) && !lfe) { + int last = 0; + c = 0; do { + celt_glog offset; + celt_glog tmp; + celt_glog *f; + OAC_COPY(bandLogE3, &bandLogE2[c*nbEBands], end); + if (LM == 0) { + /* For 2.5 ms frames, the first 8 bands have just one bin, so the + energy is highly unreliable (high variance). For that reason, + we take the max with the previous energy so that at least 2 bins + are getting used. */ + for (i = 0; i < IMIN(8, end); + i++) bandLogE3[i] = MAXG(bandLogE2[c*nbEBands + i], oldBandE[c*nbEBands + i]); + } + f = &follower[c*nbEBands]; + f[0] = bandLogE3[0]; + for (i = 1; i < end; i++) { + /* The last band to be at least 3 dB higher than the previous one + is the last we'll consider. Otherwise, we run into problems on + bandlimited signals. */ + if (bandLogE3[i] > bandLogE3[i - 1] + GCONST(.5f)) + last = i; + f[i] = MING(f[i - 1] + GCONST(1.5f), bandLogE3[i]); + } + for (i = last - 1; i >= 0; i--) + f[i] = MING(f[i], MING(f[i + 1] + GCONST(2.f), bandLogE3[i])); + + /* Combine with a median filter to avoid dynalloc triggering unnecessarily. + The "offset" value controls how conservative we are -- a higher offset + reduces the impact of the median filter and makes dynalloc use more bits. */ + offset = GCONST(1.f); + for (i = 2; i < end - 2; i++) + f[i] = MAXG(f[i], oaci_median_of_5(&bandLogE3[i - 2]) - offset); + tmp = oaci_median_of_3(&bandLogE3[0]) - offset; + f[0] = MAXG(f[0], tmp); + f[1] = MAXG(f[1], tmp); + tmp = oaci_median_of_3(&bandLogE3[end - 3]) - offset; + f[end - 2] = MAXG(f[end - 2], tmp); + f[end - 1] = MAXG(f[end - 1], tmp); + + for (i = 0; i < end; i++) + f[i] = MAXG(f[i], noise_floor[i]); + } while (++c < C); + if (C == 2) { + for (i = start; i < end; i++) { + /* Consider 24 dB "cross-talk" */ + follower[nbEBands + i] = MAXG(follower[nbEBands + i], follower[ i] - GCONST(4.f)); + follower[ i] = MAXG(follower[ i], follower[nbEBands + i] - GCONST(4.f)); + follower[i] = HALF32(MAXG(0, bandLogE[i] - follower[i]) + MAXG(0, + bandLogE[nbEBands + i] - follower[nbEBands + i])); + } + } else { + for (i = start; i < end; i++) { + follower[i] = MAXG(0, bandLogE[i] - follower[i]); + } + } + for (i = start; i < end; i++) + follower[i] = MAXG(follower[i], surround_dynalloc[i]); + for (i = start; i < end; i++) { #ifdef FIXED_POINT - importance[i] = PSHR32(13*celt_exp2_db(MING(follower[i], GCONST(4.f))), 16); + importance[i] = PSHR32(13*celt_exp2_db(MING(follower[i], GCONST(4.f))), 16); #else - importance[i] = (int)floor(.5f+13*celt_exp2_db(MING(follower[i], GCONST(4.f)))); -#endif - } - /* For non-transient CBR/CVBR frames, halve the dynalloc contribution */ - if ((!vbr || constrained_vbr)&&!isTransient) - { - for (i=start;i=12) - follower[i] = HALF32(follower[i]); - } - /* Compensate for Opus' under-allocation on tones. */ - if (toneishness > QCONST32(.98f, 29)) { + importance[i] = (int)floor(.5f + 13*celt_exp2_db(MING(follower[i], GCONST(4.f)))); +#endif + } + /* For non-transient CBR/CVBR frames, halve the dynalloc contribution */ + if ((!vbr || constrained_vbr) && !isTransient) { + for (i = start; i < end; i++) + follower[i] = HALF32(follower[i]); + } + for (i = start; i < end; i++) { + if (i < 8) + follower[i] *= 2; + if (i >= 12) + follower[i] = HALF32(follower[i]); + } + /* Compensate for Oac' under-allocation on tones. */ + if (toneishness > QCONST32(.98f, 29)) { #ifdef FIXED_POINT - int freq_bin = PSHR32(QEXT_SCALE((opus_val32)tone_freq)*QCONST16(120/M_PI, 9), 13+9); + int freq_bin = PSHR32(QEXT_SCALE((oac_val32)tone_freq)*QCONST16(120/M_PI, 9), 13 + 9); #else - int freq_bin = (int)floor(.5 + QEXT_SCALE(tone_freq)*120/M_PI); -#endif - for (i=start;i= eBands[i] && freq_bin <= eBands[i+1]) follower[i] += GCONST(2.f); - if (freq_bin >= eBands[i]-1 && freq_bin <= eBands[i+1]+1) follower[i] += GCONST(1.f); - if (freq_bin >= eBands[i]-2 && freq_bin <= eBands[i+1]+2) follower[i] += GCONST(1.f); - if (freq_bin >= eBands[i]-3 && freq_bin <= eBands[i+1]+3) follower[i] += GCONST(.5f); - } - if (freq_bin >= eBands[end]) { - follower[end-1] += GCONST(2.f); - follower[end-2] += GCONST(1.f); - } - } + int freq_bin = (int)floor(.5 + QEXT_SCALE(tone_freq)*120/M_PI); +#endif + for (i = start; i < end; i++) { + if (freq_bin >= eBands[i] && freq_bin <= eBands[i + 1]) follower[i] += GCONST(2.f); + if (freq_bin >= eBands[i] - 1 && freq_bin <= eBands[i + 1] + 1) follower[i] += GCONST(1.f); + if (freq_bin >= eBands[i] - 2 && freq_bin <= eBands[i + 1] + 2) follower[i] += GCONST(1.f); + if (freq_bin >= eBands[i] - 3 && freq_bin <= eBands[i + 1] + 3) follower[i] += GCONST(.5f); + } + if (freq_bin >= eBands[end]) { + follower[end - 1] += GCONST(2.f); + follower[end - 2] += GCONST(1.f); + } + } #ifdef DISABLE_FLOAT_API - (void)analysis; + (void)analysis; #else - if (analysis->valid) - { - for (i=start;ileak_boost[i]; - } -#endif - for (i=start;i 48) { - boost = (int)SHR32(follower[i]*8,DB_SHIFT-8); - boost_bits = (boost*width<>BITRES>>3 > 2*effectiveBytes/3) - { - opus_int32 cap = ((2*effectiveBytes/3)<valid) { + for (i = start; i < IMIN(LEAK_BANDS, end); i++) + follower[i] = follower[i] + GCONST(1.f/64.f)*analysis->leak_boost[i]; + } +#endif + for (i = start; i < end; i++) { + int width; + int boost; + int boost_bits; + + follower[i] = MING(follower[i], GCONST(4)); + + follower[i] = SHR32(follower[i], 8); + width = C*(eBands[i + 1] - eBands[i])< 48) { + boost = (int)SHR32(follower[i]*8, DB_SHIFT - 8); + boost_bits = (boost*width<>BITRES>>3 > 2*effectiveBytes/3) { + oac_int32 cap = ((2*effectiveBytes/3)< 0) { - for (i=0;i 0) { + for (i = 0; i < len; i++) { + x[i] = PSHR32(x[i], shift); + } + } } -int acos_approx(opus_val32 x) { - opus_val16 x14; - opus_val32 tmp; - int flip = x<0; - x = abs(x); - x14 = x>>15; - tmp = (762*x14>>14)-3308; - tmp = (tmp*x14>>14)+25726; - tmp = tmp*celt_sqrt(IMAX(0, (1<<30) - (x<<1)))>>16; - if (flip) tmp = 25736 - tmp; - return tmp; +int oaci_acos_approx(oac_val32 x) { + oac_val16 x14; + oac_val32 tmp; + int flip = x < 0; + x = abs(x); + x14 = x>>15; + tmp = (762*x14>>14) - 3308; + tmp = (tmp*x14>>14) + 25726; + tmp = tmp*oaci_celt_sqrt(IMAX(0, (1<<30) - (x<<1)))>>16; + if (flip) tmp = 25736 - tmp; + return tmp; } #endif /* Compute the LPC coefficients using a least-squares fit for both forward and backward prediction. */ -static int tone_lpc(const opus_val16 *x, int len, int delay, opus_val32 *lpc) { - int i; - opus_val32 r00=0, r01=0, r11=0, r02=0, r12=0, r22=0; - opus_val32 edges; - opus_val32 num0, num1, den; - celt_assert(len > 2*delay); - /* Compute correlations as if using the forward prediction covariance method. */ - for (i=0;i 2*delay); + /* Compute correlations as if using the forward prediction covariance method. */ + for (i = 0; i < len - 2*delay; i++) { + r00 += MULT16_16(x[i], x[i]); + r01 += MULT16_16(x[i], x[i + delay]); + r02 += MULT16_16(x[i], x[i + 2*delay]); + } + edges = 0; + for (i = 0; i < delay; i++) edges += MULT16_16(x[len + i - 2*delay], x[len + i - 2*delay]) - MULT16_16(x[i], x[i]); + r11 = r00 + edges; + edges = 0; + for (i = 0; i < delay; + i++) edges += MULT16_16(x[len + i - delay], x[len + i - delay]) - MULT16_16(x[i + delay], x[i + delay]); + r22 = r11 + edges; + edges = 0; + for (i = 0; i < delay; + i++) edges += MULT16_16(x[len + i - 2*delay], x[len + i - delay]) - MULT16_16(x[i], x[i + delay]); + r12 = r01 + edges; + /* Reverse and sum to get the backward contribution. */ + { + oac_val32 R00, R01, R11, R02, R12, R22; + R00 = r00 + r22; + R01 = r01 + r12; + R11 = 2*r11; + R02 = 2*r02; + R12 = r12 + r01; + R22 = r00 + r22; + r00 = R00; + r01 = R01; + r11 = R11; + r02 = R02; + r12 = R12; + r22 = R22; + } + /* Solve A*x=b, where A=[r00, r01; r01, r11] and b=[r02; r12]. */ + den = MULT32_32_Q31(r00, r11) - MULT32_32_Q31(r01, r01); #ifdef FIXED_POINT - if (den <= SHR32(MULT32_32_Q31(r00,r11), 10)) return 1; + if (den <= SHR32(MULT32_32_Q31(r00, r11), 10)) return 1; #else - if (den < .001f*MULT32_32_Q31(r00,r11)) return 1; -#endif - num1 = MULT32_32_Q31(r02,r11) - MULT32_32_Q31(r01,r12); - if (num1 >= den) lpc[1] = QCONST32(1.f, 29); - else if (num1 <= -den) lpc[1] = -QCONST32(1.f, 29); - else lpc[1] = frac_div32_q29(num1, den); - num0 = MULT32_32_Q31(r00,r12) - MULT32_32_Q31(r02,r01); - if (HALF32(num0) >= den) lpc[0] = QCONST32(1.999999f, 29); - else if (HALF32(num0) <= -den) lpc[0] = -QCONST32(1.999999f, 29); - else lpc[0] = frac_div32_q29(num0, den); - /*printf("%f %f\n", lpc[0], lpc[1]);*/ - return 0; + if (den < .001f*MULT32_32_Q31(r00, r11)) return 1; +#endif + num1 = MULT32_32_Q31(r02, r11) - MULT32_32_Q31(r01, r12); + if (num1 >= den) lpc[1] = QCONST32(1.f, 29); + else if (num1 <= -den) lpc[1] = -QCONST32(1.f, 29); + else lpc[1] = oaci_frac_div32_q29(num1, den); + num0 = MULT32_32_Q31(r00, r12) - MULT32_32_Q31(r02, r01); + if (HALF32(num0) >= den) lpc[0] = QCONST32(1.999999f, 29); + else if (HALF32(num0) <= -den) lpc[0] = -QCONST32(1.999999f, 29); + else lpc[0] = oaci_frac_div32_q29(num0, den); + /*printf("%f %f\n", lpc[0], lpc[1]);*/ + return 0; } /* Detects pure of nearly pure tones so we can prevent them from causing problems with the encoder. */ -static opus_val16 tone_detect(const celt_sig *in, int CC, int N, opus_val32 *toneishness, opus_int32 Fs) { - int i; - int delay = 1; - int fail; - opus_val32 lpc[2]; - opus_val16 freq; - VARDECL(opus_val16, x); - SAVE_STACK; - ALLOC(x, N, opus_val16); - /* Shift by SIG_SHIFT+2 (+3 for stereo) to account for HF gain of the preemphasis filter. */ - if (CC==2) { - for (i=0;i QCONST32(1.f, 29) && lpc[1] < 0))) { - delay *= 2; - fail = tone_lpc(x, N, delay, lpc); - } - /* Check that our filter has complex roots. */ - if (!fail && MULT32_32_Q31(lpc[0],lpc[0]) + MULT32_32_Q31(QCONST32(3.999999, 29), lpc[1]) < 0) { - /* Squared radius of the poles. */ - *toneishness = -lpc[1]; + oaci_normalize_tone_input(x, N); +#endif + fail = oaci_tone_lpc(x, N, delay, lpc); + /* If our LPC filter resonates too close to DC, retry the analysis with down-sampling. */ + while (delay <= Fs/3000 && (fail || (lpc[0] > QCONST32(1.f, 29) && lpc[1] < 0))) { + delay *= 2; + fail = oaci_tone_lpc(x, N, delay, lpc); + } + /* Check that our filter has complex roots. */ + if (!fail && MULT32_32_Q31(lpc[0], lpc[0]) + MULT32_32_Q31(QCONST32(3.999999, 29), lpc[1]) < 0) { + /* Squared radius of the poles. */ + *toneishness = -lpc[1]; #ifdef FIXED_POINT - freq = (acos_approx(lpc[0]>>1)+delay/2)/delay; + freq = (oaci_acos_approx(lpc[0]>>1) + delay/2)/delay; #else - freq = acos(.5f*lpc[0])/delay; -#endif - } else { - freq = -1; - *toneishness=0; - } - /*printf("%f %f %f %f\n", freq, lpc[0], lpc[1], *toneishness);*/ - RESTORE_STACK; - return freq; + freq = acos(.5f*lpc[0])/delay; +#endif + } else { + freq = -1; + *toneishness = 0; + } + /*printf("%f %f %f %f\n", freq, lpc[0], lpc[1], *toneishness);*/ + RESTORE_STACK; + return freq; } -static int run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, int CC, int N, - int prefilter_tapset, int *pitch, opus_val16 *gain, int *qgain, int enabled, int complexity, opus_val16 tf_estimate, - int nbAvailableBytes, AnalysisInfo *analysis, opus_val16 tone_freq, opus_val32 toneishness ARG_QEXT(int qext_scale)) -{ - int c; - VARDECL(celt_sig, _pre); - celt_sig *pre[2]; - const CELTMode *mode; - int pitch_index; - opus_val16 gain1; - opus_val16 pf_threshold; - int pf_on; - int qg; - int overlap; - int min_period, max_period; - opus_val32 before[2]={0}, after[2]={0}; - int cancel_pitch=0; - SAVE_STACK; - - max_period = QEXT_SCALE(COMBFILTER_MAXPERIOD); - min_period = QEXT_SCALE(COMBFILTER_MINPERIOD); - mode = st->mode; - overlap = mode->overlap; - ALLOC(_pre, CC*(N+max_period), celt_sig); - - pre[0] = _pre; - pre[1] = _pre + (N+max_period); - - - c=0; do { - OPUS_COPY(pre[c], prefilter_mem+c*max_period, max_period); - OPUS_COPY(pre[c]+max_period, in+c*(N+overlap)+overlap, N); - } while (++c QCONST32(.99f, 29)) { - int multiple=1; - /* Using aliased version of the postfilter above 24 kHz. - First value is purposely slightly above pi to avoid triggering for Fs=48kHz. */ - if (QEXT_SCALE(tone_freq) >= QCONST16(3.1416f, 13)) tone_freq = QCONST16(3.141593f, 13) - tone_freq; - /* If the pitch is too high for our post-filter, apply pitch doubling until - we can get something that fits (not ideal, but better than nothing). */ - while (QEXT_SCALE(tone_freq) >= multiple*QCONST16(0.39f, 13)) multiple++; - if (QEXT_SCALE(tone_freq) > QCONST16(0.006148f, 13)) { +static int oaci_run_prefilter(CELTEncoder *st, celt_sig *in, celt_sig *prefilter_mem, int CC, int N, + int prefilter_tapset, int *pitch, oac_val16 *gain, int *qgain, int enabled, int complexity, + oac_val16 tf_estimate, + int nbAvailableBytes, AnalysisInfo *analysis, oac_val16 tone_freq, oac_val32 toneishness, + int qext_scale) { + int c; + VARDECL(celt_sig, _pre); + celt_sig *pre[2]; + const CELTMode *mode; + int pitch_index; + oac_val16 gain1; + oac_val16 pf_threshold; + int pf_on; + int qg; + int overlap; + int min_period, max_period; + oac_val32 before[2] = {0}, after[2] = {0}; + int cancel_pitch = 0; + SAVE_STACK; + +#ifndef ENABLE_QEXT + (void)qext_scale; +#endif + + max_period = QEXT_SCALE(COMBFILTER_MAXPERIOD); + min_period = QEXT_SCALE(COMBFILTER_MINPERIOD); + mode = st->mode; + overlap = mode->overlap; + ALLOC(_pre, CC*(N + max_period), celt_sig); + + pre[0] = _pre; + pre[1] = _pre + (N + max_period); + + + c = 0; do { + OAC_COPY(pre[c], prefilter_mem + c*max_period, max_period); + OAC_COPY(pre[c] + max_period, in + c*(N + overlap) + overlap, N); + } while (++c < CC); + + /* If we detect that the signal is dominated by a single tone, don't rely on the standard pitch + estimator, as it can become unreliable. */ + if (enabled && toneishness > QCONST32(.99f, 29)) { + int multiple = 1; + /* Using aliased version of the postfilter above 24 kHz. + First value is purposely slightly above pi to avoid triggering for Fs=48kHz. */ + if (QEXT_SCALE(tone_freq) >= QCONST16(3.1416f, 13)) tone_freq = QCONST16(3.141593f, 13) - tone_freq; + /* If the pitch is too high for our post-filter, apply pitch doubling until + we can get something that fits (not ideal, but better than nothing). */ + while (QEXT_SCALE(tone_freq) >= multiple*QCONST16(0.39f, 13)) multiple++; + if (QEXT_SCALE(tone_freq) > QCONST16(0.006148f, 13)) { #ifdef FIXED_POINT - pitch_index = IMIN((51472*multiple+QEXT_SCALE(tone_freq)/2)/QEXT_SCALE(tone_freq), COMBFILTER_MAXPERIOD-2); + pitch_index = IMIN((51472*multiple + QEXT_SCALE(tone_freq)/2)/QEXT_SCALE(tone_freq), + COMBFILTER_MAXPERIOD - 2); #else - pitch_index = IMIN((int)floor(.5+2.f*M_PI*multiple/QEXT_SCALE(tone_freq)), COMBFILTER_MAXPERIOD-2); -#endif - } else { - /* If the pitch is too low, using a very high pitch will actually give us an improvement - due to the DC component of the filter that will be close to our tone. Again, not ideal, - but if we only have a single tone, it's better than nothing. */ - pitch_index = COMBFILTER_MINPERIOD; - } - gain1 = QCONST16(.75f, 15); - } else if (enabled && complexity >= 5) { - VARDECL(opus_val16, pitch_buf); - ALLOC(pitch_buf, (max_period+N)>>1, opus_val16); - - pitch_downsample(pre, pitch_buf, (max_period+N)>>1, CC, 2, st->arch); - /* Don't search for the fir last 1.5 octave of the range because - there's too many false-positives due to short-term correlation */ - pitch_search(pitch_buf+(max_period>>1), pitch_buf, N, - max_period-3*min_period, &pitch_index, + pitch_index = IMIN((int)floor(.5 + 2.f*M_PI*multiple/QEXT_SCALE(tone_freq)), COMBFILTER_MAXPERIOD - 2); +#endif + } else { + /* If the pitch is too low, using a very high pitch will actually give us an improvement + due to the DC component of the filter that will be close to our tone. Again, not ideal, + but if we only have a single tone, it's better than nothing. */ + pitch_index = COMBFILTER_MINPERIOD; + } + gain1 = QCONST16(.75f, 15); + } else if (enabled && complexity >= 5) { + VARDECL(oac_val16, pitch_buf); + ALLOC(pitch_buf, (max_period + N)>>1, oac_val16); + + oaci_pitch_downsample(pre, pitch_buf, (max_period + N)>>1, CC, 2, st->arch); + /* Don't search for the fir last 1.5 octave of the range because + there's too many false-positives due to short-term correlation */ + oaci_pitch_search(pitch_buf + (max_period>>1), pitch_buf, N, + max_period - 3*min_period, &pitch_index, st->arch); - pitch_index = max_period-pitch_index; + pitch_index = max_period - pitch_index; - gain1 = remove_doubling(pitch_buf, max_period, min_period, + gain1 = oaci_remove_doubling(pitch_buf, max_period, min_period, N, &pitch_index, st->prefilter_period, st->prefilter_gain, st->arch); - if (pitch_index > max_period-QEXT_SCALE(2)) - pitch_index = max_period-QEXT_SCALE(2); + if (pitch_index > max_period - QEXT_SCALE(2)) + pitch_index = max_period - QEXT_SCALE(2); #ifdef ENABLE_QEXT - pitch_index /= qext_scale; -#endif - gain1 = MULT16_16_Q15(QCONST16(.7f,15),gain1); - /*printf("%d %d %f %f\n", pitch_change, pitch_index, gain1, st->analysis.tonality);*/ - if (st->loss_rate>2) - gain1 = HALF32(gain1); - if (st->loss_rate>4) - gain1 = HALF32(gain1); - if (st->loss_rate>8) - gain1 = 0; - } else { - gain1 = 0; - pitch_index = COMBFILTER_MINPERIOD; - } + pitch_index /= qext_scale; +#endif + gain1 = MULT16_16_Q15(QCONST16(.7f, 15), gain1); + /*printf("%d %d %f %f\n", pitch_change, pitch_index, gain1, st->analysis.tonality);*/ + if (st->loss_rate > 2) + gain1 = HALF32(gain1); + if (st->loss_rate > 4) + gain1 = HALF32(gain1); + if (st->loss_rate > 8) + gain1 = 0; + } else { + gain1 = 0; + pitch_index = COMBFILTER_MINPERIOD; + } #ifndef DISABLE_FLOAT_API - if (analysis->valid) - gain1 = (opus_val16)(gain1 * analysis->max_pitch_ratio); + if (analysis->valid) + gain1 = (oac_val16)(gain1*analysis->max_pitch_ratio); #else - (void)analysis; -#endif - /* Gain threshold for enabling the prefilter/postfilter */ - pf_threshold = QCONST16(.2f,15); - - /* Adjusting the threshold based on rate and continuity */ - if (abs(pitch_index-st->prefilter_period)*10>pitch_index) - { - pf_threshold += QCONST16(.2f,15); - /* Completely disable the prefilter on strong transients without continuity. */ - if (tf_estimate > QCONST16(.98f, 14)) - gain1 = 0; - } - if (nbAvailableBytes<25) - pf_threshold += QCONST16(.1f,15); - if (nbAvailableBytes<35) - pf_threshold += QCONST16(.1f,15); - if (st->prefilter_gain > QCONST16(.4f,15)) - pf_threshold -= QCONST16(.1f,15); - if (st->prefilter_gain > QCONST16(.55f,15)) - pf_threshold -= QCONST16(.1f,15); - - /* Hard threshold at 0.2 */ - pf_threshold = MAX16(pf_threshold, QCONST16(.2f,15)); - if (gain1prefilter_gain)prefilter_gain; + (void)analysis; +#endif + /* Gain threshold for enabling the prefilter/postfilter */ + pf_threshold = QCONST16(.2f, 15); + + /* Adjusting the threshold based on rate and continuity */ + if (abs(pitch_index - st->prefilter_period)*10 > pitch_index) { + pf_threshold += QCONST16(.2f, 15); + /* Completely disable the prefilter on strong transients without continuity. */ + if (tf_estimate > QCONST16(.98f, 14)) + gain1 = 0; + } + if (nbAvailableBytes < 25) + pf_threshold += QCONST16(.1f, 15); + if (nbAvailableBytes < 35) + pf_threshold += QCONST16(.1f, 15); + if (st->prefilter_gain > QCONST16(.4f, 15)) + pf_threshold -= QCONST16(.1f, 15); + if (st->prefilter_gain > QCONST16(.55f, 15)) + pf_threshold -= QCONST16(.1f, 15); + + /* Hard threshold at 0.2 */ + pf_threshold = MAX16(pf_threshold, QCONST16(.2f, 15)); + if (gain1 < pf_threshold) { + gain1 = 0; + pf_on = 0; + qg = 0; + } else { + /*This block is not gated by a total bits check only because + of the nbAvailableBytes check above.*/ + if (ABS16(gain1 - st->prefilter_gain) < QCONST16(.1f, 15)) + gain1 = st->prefilter_gain; #ifdef FIXED_POINT - qg = ((gain1+1536)>>10)/3-1; + qg = ((gain1 + 1536)>>10)/3 - 1; #else - qg = (int)floor(.5f+gain1*32/3)-1; -#endif - qg = IMAX(0, IMIN(7, qg)); - gain1 = QCONST16(0.09375f,15)*(qg+1); - pf_on = 1; - } - /*printf("%d %f\n", pitch_index, gain1);*/ - - c=0; do { - int i; - int offset = mode->shortMdctSize-overlap; - st->prefilter_period=IMAX(st->prefilter_period, COMBFILTER_MINPERIOD); - OPUS_COPY(in+c*(N+overlap), st->in_mem+c*(overlap), overlap); - for (i=0;ishortMdctSize - overlap; + st->prefilter_period = IMAX(st->prefilter_period, COMBFILTER_MINPERIOD); + OAC_COPY(in + c*(N + overlap), st->in_mem + c*(overlap), overlap); + for (i = 0; i < N; i++) before[c] += ABS32(SHR32(in[c*(N + overlap) + overlap + i], 12)); + if (offset) + oaci_comb_filter(in + c*(N + overlap) + overlap, pre[c] + max_period, st->prefilter_period, st->prefilter_period, offset, -st->prefilter_gain, -st->prefilter_gain, st->prefilter_tapset, st->prefilter_tapset, NULL, 0, st->arch); - comb_filter(in+c*(N+overlap)+overlap+offset, pre[c]+max_period+offset, - st->prefilter_period, pitch_index, N-offset, -st->prefilter_gain, -gain1, + oaci_comb_filter(in + c*(N + overlap) + overlap + offset, pre[c] + max_period + offset, + st->prefilter_period, pitch_index, N - offset, -st->prefilter_gain, -gain1, st->prefilter_tapset, prefilter_tapset, mode->window, overlap, st->arch); - for (i=0;i thresh[0] || after[1]-before[1] > thresh[1]) cancel_pitch = 1; - /* Use the filter only if at least one channel gets significantly better. */ - if (before[0]-after[0] < thresh[0] && before[1]-after[1] < thresh[1]) cancel_pitch = 1; - } else { - /* Check that the mono channel actually got better. */ - if (after[0] > before[0]) cancel_pitch = 1; - } - /* If needed, revert to a gain of zero. */ - if (cancel_pitch) { - c=0; do { - int offset = mode->shortMdctSize-overlap; - OPUS_COPY(in+c*(N+overlap)+overlap, pre[c]+max_period, N); - comb_filter(in+c*(N+overlap)+overlap+offset, pre[c]+max_period+offset, + for (i = 0; i < N; i++) after[c] += ABS32(SHR32(in[c*(N + overlap) + overlap + i], 12)); + } while (++c < CC); + + if (CC == 2) { + oac_val16 thresh[2]; + thresh[0] = MULT16_32_Q15(MULT16_16_Q15(QCONST16(.25f, 15), gain1), + before[0]) + MULT16_32_Q15(QCONST16(.01f, 15), before[1]); + thresh[1] = MULT16_32_Q15(MULT16_16_Q15(QCONST16(.25f, 15), gain1), + before[1]) + MULT16_32_Q15(QCONST16(.01f, 15), before[0]); + /* Don't use the filter if one channel gets significantly worse. */ + if (after[0] - before[0] > thresh[0] || after[1] - before[1] > thresh[1]) cancel_pitch = 1; + /* Use the filter only if at least one channel gets significantly better. */ + if (before[0] - after[0] < thresh[0] && before[1] - after[1] < thresh[1])cancel_pitch = 1; + } else { + /* Check that the mono channel actually got better. */ + if (after[0] > before[0]) cancel_pitch = 1; + } + /* If needed, revert to a gain of zero. */ + if (cancel_pitch) { + c = 0; do { + int offset = mode->shortMdctSize - overlap; + OAC_COPY(in + c*(N + overlap) + overlap, pre[c] + max_period, N); + oaci_comb_filter(in + c*(N + overlap) + overlap + offset, pre[c] + max_period + offset, st->prefilter_period, pitch_index, overlap, -st->prefilter_gain, -0, st->prefilter_tapset, prefilter_tapset, mode->window, overlap, st->arch); - } while (++cin_mem+c*(overlap), in+c*(N+overlap)+N, overlap); - - if (N>max_period) - { - OPUS_COPY(prefilter_mem+c*max_period, pre[c]+N, max_period); - } else { - OPUS_MOVE(prefilter_mem+c*max_period, prefilter_mem+c*max_period+N, max_period-N); - OPUS_COPY(prefilter_mem+c*max_period+max_period-N, pre[c]+max_period, N); - } - } while (++cin_mem + c*(overlap), in + c*(N + overlap) + N, overlap); + + if (N > max_period) { + OAC_COPY(prefilter_mem + c*max_period, pre[c] + N, max_period); + } else { + OAC_MOVE(prefilter_mem + c*max_period, prefilter_mem + c*max_period + N, max_period - N); + OAC_COPY(prefilter_mem + c*max_period + max_period - N, pre[c] + max_period, N); + } + } while (++c < CC); + + RESTORE_STACK; + *gain = gain1; + *pitch = pitch_index; + *qgain = qg; + return pf_on; } -static int compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, opus_int32 base_target, - int LM, opus_int32 bitrate, int lastCodedBands, int C, int intensity, - int constrained_vbr, opus_val16 stereo_saving, int tot_boost, - opus_val16 tf_estimate, int pitch_change, celt_glog maxDepth, - int lfe, int has_surround_mask, celt_glog surround_masking, - celt_glog temporal_vbr ARG_QEXT(int enable_qext)) -{ - /* The target rate in 8th bits per frame */ - opus_int32 target; - int coded_bins; - int coded_bands; - opus_val16 tf_calibration; - int nbEBands; - const opus_int16 *eBands; - - nbEBands = mode->nbEBands; - eBands = mode->eBands; - - coded_bands = lastCodedBands ? lastCodedBands : nbEBands; - coded_bins = eBands[coded_bands]<analysis.activity, st->analysis.tonality, tf_estimate, st->stereo_saving, tot_boost, coded_bands);*/ +static int oaci_compute_vbr(const CELTMode *mode, AnalysisInfo *analysis, oac_int32 base_target, + int LM, oac_int32 bitrate, int lastCodedBands, int C, int intensity, + int constrained_vbr, oac_val16 stereo_saving, int tot_boost, + oac_val16 tf_estimate, int pitch_change, celt_glog maxDepth, + int lfe, int has_surround_mask, celt_glog surround_masking, + celt_glog temporal_vbr) { + /* The target rate in 8th bits per frame */ + oac_int32 target; + int coded_bins; + int coded_bands; + oac_val16 tf_calibration; + int nbEBands; + const oac_int16 *eBands; + + nbEBands = mode->nbEBands; + eBands = mode->eBands; + + coded_bands = lastCodedBands ? lastCodedBands : nbEBands; + coded_bins = eBands[coded_bands]<analysis.activity, st->analysis.tonality, tf_estimate, st->stereo_saving, tot_boost, coded_bands);*/ #ifndef DISABLE_FLOAT_API - if (analysis->valid && analysis->activity<.4) - target -= (opus_int32)((coded_bins<activity)); -#endif - /* Stereo savings */ - if (C==2) - { - int coded_stereo_bands; - int coded_stereo_dof; - opus_val16 max_frac; - coded_stereo_bands = IMIN(intensity, coded_bands); - coded_stereo_dof = (eBands[coded_stereo_bands]<valid && analysis->activity < .4) + target -= (oac_int32)((coded_bins<activity)); +#endif + /* Stereo savings */ + if (C == 2) { + int coded_stereo_bands; + int coded_stereo_dof; + oac_val16 max_frac; + coded_stereo_bands = IMIN(intensity, coded_bands); + coded_stereo_dof = (eBands[coded_stereo_bands]<valid && !lfe) - { - opus_int32 tonal_target; - float tonal; - - /* Tonality boost (compensating for the average). */ - tonal = MAX16(0.f,analysis->tonality-.15f)-0.12f; - tonal_target = target + (opus_int32)((coded_bins<tonality, tonal);*/ - target = tonal_target; - } + /* Apply tonality boost */ + if (analysis->valid && !lfe) { + oac_int32 tonal_target; + float tonal; + + /* Tonality boost (compensating for the average). */ + tonal = MAX16(0.f, analysis->tonality - .15f) - 0.12f; + tonal_target = target + (oac_int32)((coded_bins<tonality, tonal);*/ + target = tonal_target; + } #else - (void)analysis; - (void)pitch_change; -#endif - - if (has_surround_mask&&!lfe) - { - opus_int32 surround_target = target + (opus_int32)SHR32(MULT16_16(SHR32(surround_masking,DB_SHIFT-10),coded_bins<end, st->intensity, surround_target, target, st->bitrate);*/ - target = IMAX(target/4, surround_target); - } - - { - opus_int32 floor_depth; - int bins; - bins = eBands[nbEBands-2]<shortMdctSize<>2); - target = IMIN(target, floor_depth); - /*printf("%f %d\n", maxDepth, floor_depth);*/ - } - - /* Make VBR less aggressive for constrained VBR because we can't keep a higher bitrate - for long. Needs tuning. */ - if ((!has_surround_mask||lfe) && constrained_vbr) - { - target = base_target + (opus_int32)MULT16_32_Q15(QCONST16(0.67f, 15), target-base_target); - } - - if (!has_surround_mask && tf_estimate < QCONST16(.2f, 14)) - { - opus_val16 amount; - opus_val16 tvbr_factor; - amount = MULT16_16_Q15(QCONST16(.0000031f, 30), IMAX(0, IMIN(32000, 96000-bitrate))); - tvbr_factor = SHR32(MULT16_16(SHR32(temporal_vbr, DB_SHIFT-10), amount), 10); - target += (opus_int32)MULT16_32_Q15(tvbr_factor, target); - } - - /* Don't allow more than doubling the rate */ - target = IMIN(2*base_target, target); - - return target; -} - -#ifdef ENABLE_QEXT -static void encode_qext_stereo_params(ec_enc *ec, int qext_end, int qext_intensity, int qext_dual_stereo) { - ec_enc_uint(ec, qext_intensity, qext_end+1); - if (qext_intensity != 0) ec_enc_bit_logp(ec, qext_dual_stereo, 1); + (void)analysis; + (void)pitch_change; +#endif + + if (has_surround_mask && !lfe) { + oac_int32 surround_target = target + (oac_int32)SHR32(MULT16_16(SHR32(surround_masking, DB_SHIFT - 10), + coded_bins<end, st->intensity, surround_target, target, st->bitrate);*/ + target = IMAX(target/4, surround_target); + } + + { + oac_int32 floor_depth; + int bins; + bins = eBands[nbEBands - 2]<>2); + target = IMIN(target, floor_depth); + /*printf("%f %d\n", maxDepth, floor_depth);*/ + } + + /* Make VBR less aggressive for constrained VBR because we can't keep a higher bitrate + for long. Needs tuning. */ + if ((!has_surround_mask || lfe) && constrained_vbr) { + target = base_target + (oac_int32)MULT16_32_Q15(QCONST16(0.67f, 15), target - base_target); + } + + if (!has_surround_mask && tf_estimate < QCONST16(.2f, 14)) { + oac_val16 amount; + oac_val16 tvbr_factor; + amount = MULT16_16_Q15(QCONST16(.0000031f, 30), IMAX(0, IMIN(32000, 96000 - bitrate))); + tvbr_factor = SHR32(MULT16_16(SHR32(temporal_vbr, DB_SHIFT - 10), amount), 10); + target += (oac_int32)MULT16_32_Q15(tvbr_factor, target); + } + + /* Don't allow more than doubling the rate */ + target = IMIN(2*base_target, target); + + return target; } -#endif -int celt_encode_with_ec(CELTEncoder * OPUS_RESTRICT st, const opus_res * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes, ec_enc *enc) -{ - int i, c, N; - opus_int32 bits; - ec_enc _enc; - VARDECL(celt_sig, in); - VARDECL(celt_sig, freq); - VARDECL(celt_norm, X); - VARDECL(celt_ener, bandE); - VARDECL(celt_glog, bandLogE); - VARDECL(celt_glog, bandLogE2); - VARDECL(int, fine_quant); - VARDECL(celt_glog, error); - VARDECL(int, pulses); - VARDECL(int, cap); - VARDECL(int, offsets); - VARDECL(int, importance); - VARDECL(int, spread_weight); - VARDECL(int, fine_priority); - VARDECL(int, tf_res); - VARDECL(unsigned char, collapse_masks); - celt_sig *prefilter_mem; - celt_glog *oldBandE, *oldLogE, *oldLogE2, *energyError; - int shortBlocks=0; - int isTransient=0; - const int CC = st->channels; - const int C = st->stream_channels; - int LM, M; - int tf_select; - int nbFilledBytes, nbAvailableBytes; - opus_int32 min_allowed; - int start; - int end; - int effEnd; - int codedBands; - int alloc_trim; - int pitch_index=COMBFILTER_MINPERIOD; - opus_val16 gain1 = 0; - int dual_stereo=0; - int effectiveBytes; - int dynalloc_logp; - opus_int32 vbr_rate; - opus_int32 total_bits; - opus_int32 total_boost; - opus_int32 balance; - opus_int32 tell; - opus_int32 tell0_frac; - int prefilter_tapset=0; - int pf_on; - int anti_collapse_rsv; - int anti_collapse_on=0; - int silence=0; - int tf_chan = 0; - opus_val16 tf_estimate; - int pitch_change=0; - opus_int32 tot_boost; - opus_val32 sample_max; - celt_glog maxDepth; - const OpusCustomMode *mode; - int nbEBands; - int overlap; - const opus_int16 *eBands; - int secondMdct; - int signalBandwidth; - int transient_got_disabled=0; - celt_glog surround_masking=0; - celt_glog temporal_vbr=0; - celt_glog surround_trim = 0; - opus_int32 equiv_rate; - int hybrid; - int weak_transient = 0; - int enable_tf_analysis; - opus_val16 tone_freq=-1; - opus_val32 toneishness=0; - VARDECL(celt_glog, surround_dynalloc); - int qext_bytes=0; - int packet_size_cap = 1275; -#ifdef ENABLE_QEXT - int qext_scale; - int qext_end=0; - int qext_intensity=0; - int qext_dual_stereo=0; - int padding_len_bytes=0; - unsigned char *ext_payload; - opus_int32 qext_bits; - ec_enc ext_enc; - VARDECL(int, extra_quant); - VARDECL(int, extra_pulses); - VARDECL(celt_glog, error_bak); - const CELTMode *qext_mode = NULL; - CELTMode qext_mode_struct; - celt_ener qext_bandE[2*NB_QEXT_BANDS]; - celt_glog qext_bandLogE[2*NB_QEXT_BANDS]; - celt_glog *qext_oldBandE=NULL; - celt_glog qext_error[2*NB_QEXT_BANDS]; -#endif - ALLOC_STACK; - - mode = st->mode; - nbEBands = mode->nbEBands; - overlap = mode->overlap; - eBands = mode->eBands; - start = st->start; - end = st->end; - hybrid = start != 0; - tf_estimate = 0; - if (nbCompressedBytes<2 || pcm==NULL) - { - RESTORE_STACK; - return OPUS_BAD_ARG; - } - - frame_size *= st->upsample; - for (LM=0;LM<=mode->maxLM;LM++) - if (mode->shortMdctSize<mode->maxLM) - { - RESTORE_STACK; - return OPUS_BAD_ARG; - } - M=1<shortMdctSize; +int oaci_celt_encode_with_ec(CELTEncoder * OAC_RESTRICT st, const oac_res * pcm, int frame_size, unsigned char *compressed, + int nbCompressedBytes, ec_enc *enc) { + int i, c, N; + oac_int32 bits; + ec_enc _enc; + VARDECL(celt_sig, in); + VARDECL(celt_sig, freq); + VARDECL(celt_norm, X); + VARDECL(celt_ener, bandE); + VARDECL(celt_glog, bandLogE); + VARDECL(celt_glog, bandLogE2); + VARDECL(int, fine_quant); + VARDECL(celt_glog, error); + VARDECL(int, pulses); + VARDECL(int, cap); + VARDECL(int, offsets); + VARDECL(int, importance); + VARDECL(int, spread_weight); + VARDECL(int, fine_priority); + VARDECL(int, tf_res); + VARDECL(unsigned char, collapse_masks); + celt_sig *prefilter_mem; + celt_glog *oldBandE, *oldLogE, *oldLogE2, *energyError; + int shortBlocks = 0; + int isTransient = 0; + const int CC = st->channels; + const int C = st->stream_channels; + int LM, M; + int tf_select; + int nbFilledBytes, nbAvailableBytes; + oac_int32 min_allowed; + int start; + int end; + int effEnd; + int codedBands; + int alloc_trim; + int pitch_index = COMBFILTER_MINPERIOD; + oac_val16 gain1 = 0; + int dual_stereo = 0; + int effectiveBytes; + int dynalloc_logp; + oac_int32 vbr_rate; + oac_int32 total_bits; + oac_int32 total_boost; + oac_int32 balance; + oac_int32 tell; + oac_int32 tell0_frac; + int prefilter_tapset = 0; + int pf_on; + int anti_collapse_rsv; + int anti_collapse_on = 0; + int silence = 0; + int tf_chan = 0; + oac_val16 tf_estimate; + int pitch_change = 0; + oac_int32 tot_boost; + oac_val32 sample_max; + celt_glog maxDepth; + const OacCustomMode *mode; + int nbEBands; + int overlap; + const oac_int16 *eBands; + int secondMdct; + int signalBandwidth; + int transient_got_disabled = 0; + celt_glog surround_masking = 0; + celt_glog temporal_vbr = 0; + celt_glog surround_trim = 0; + oac_int32 equiv_rate; + int hybrid; + int weak_transient = 0; + int enable_tf_analysis; + oac_val16 tone_freq = -1; + oac_val32 toneishness = 0; + VARDECL(celt_glog, surround_dynalloc); + int packet_size_cap = 1275; + int qext_scale = 1; + ALLOC_STACK; + + mode = st->mode; + nbEBands = mode->nbEBands; + overlap = mode->overlap; + eBands = mode->eBands; + start = st->start; + end = st->end; + hybrid = start != 0; + tf_estimate = 0; + if (nbCompressedBytes < 2 || pcm == NULL) { + RESTORE_STACK; + return OAC_BAD_ARG; + } + + frame_size *= st->upsample; + for (LM = 0; LM <= mode->maxLM; LM++) + if (mode->shortMdctSize< mode->maxLM) { + RESTORE_STACK; + return OAC_BAD_ARG; + } + M = 1<shortMdctSize; #ifdef ENABLE_QEXT - qext_scale = st->qext_scale; - if (st->enable_qext) packet_size_cap = QEXT_PACKET_SIZE_CAP; -#endif - - prefilter_mem = st->in_mem+CC*(overlap); - oldBandE = (celt_glog*)(st->in_mem+CC*(overlap+QEXT_SCALE(COMBFILTER_MAXPERIOD))); - oldLogE = oldBandE + CC*nbEBands; - oldLogE2 = oldLogE + CC*nbEBands; - energyError = oldLogE2 + CC*nbEBands; - - if (enc==NULL) - { - tell0_frac=tell=1; - nbFilledBytes=0; - } else { - tell0_frac=ec_tell_frac(enc); - tell=ec_tell(enc); - nbFilledBytes=(tell+4)>>3; - } - -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) - if (st->signalling && enc==NULL) - { - int tmp = (mode->effEBands-end)>>1; - end = st->end = IMAX(1, mode->effEBands-tmp); - compressed[0] = tmp<<5; - compressed[0] |= LM<<3; - compressed[0] |= (C==2)<<2; - /* Convert "standard mode" to Opus header */ + qext_scale = st->qext_scale; +#endif + + prefilter_mem = st->in_mem + CC*(overlap); + oldBandE = (celt_glog*)(st->in_mem + CC*(overlap + QEXT_SCALE(COMBFILTER_MAXPERIOD))); + oldLogE = oldBandE + CC*nbEBands; + oldLogE2 = oldLogE + CC*nbEBands; + energyError = oldLogE2 + CC*nbEBands; + + if (enc == NULL) { + tell0_frac = tell = 1; + nbFilledBytes = 0; + } else { + tell0_frac = oaci_ec_tell_frac(enc); + tell = oaci_ec_tell(enc); + nbFilledBytes = (tell + 4)>>3; + } + +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) + if (st->signalling && enc == NULL) { + int tmp = (mode->effEBands - end)>>1; + end = st->end = IMAX(1, mode->effEBands - tmp); + compressed[0] = tmp<<5; + compressed[0] |= LM<<3; + compressed[0] |= (C == 2)<<2; + /* Convert "standard mode" to Oac header */ # ifndef ENABLE_QEXT - if (mode->Fs==48000 && mode->shortMdctSize==120) + if (mode->Fs == 48000 && mode->shortMdctSize == 120) # endif - { - int c0 = toOpus(compressed[0]); - if (c0<0) - { - RESTORE_STACK; - return OPUS_BAD_ARG; - } - compressed[0] = c0; - } - compressed++; - nbCompressedBytes--; - } + { + int c0 = oaci_toOac(compressed[0]); + if (c0 < 0) { + RESTORE_STACK; + return OAC_BAD_ARG; + } + compressed[0] = c0; + } + compressed++; + nbCompressedBytes--; + } #else - celt_assert(st->signalling==0); -#endif - - /* Can't produce more than 1275 output bytes for the main payload, plus any QEXT extra data. */ - nbCompressedBytes = IMIN(nbCompressedBytes,packet_size_cap); - - if (st->vbr && st->bitrate!=OPUS_BITRATE_MAX) - { - vbr_rate = bitrate_to_bits(st->bitrate, mode->Fs, frame_size)<signalling) - vbr_rate -= 8<>(3+BITRES); - } else { - opus_int32 tmp; - vbr_rate = 0; - tmp = st->bitrate*frame_size; - if (tell>1) - tmp += tell*mode->Fs; - if (st->bitrate!=OPUS_BITRATE_MAX) - { - nbCompressedBytes = IMAX(2, IMIN(nbCompressedBytes, - (tmp+4*mode->Fs)/(8*mode->Fs)-!!st->signalling)); - if (enc != NULL) - ec_enc_shrink(enc, nbCompressedBytes); - } - effectiveBytes = nbCompressedBytes - nbFilledBytes; - } - nbAvailableBytes = nbCompressedBytes - nbFilledBytes; - 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)); - - if (enc==NULL) - { - ec_enc_init(&_enc, compressed, nbCompressedBytes); - enc = &_enc; - } - - if (vbr_rate>0) - { - /* Computes the max bit-rate allowed in VBR mode to avoid violating the - target rate and buffering. - We must do this up front so that bust-prevention logic triggers - correctly if we don't have enough bits. */ - if (st->constrained_vbr) - { - opus_int32 vbr_bound; - opus_int32 max_allowed; - /* We could use any multiple of vbr_rate as bound (depending on the - delay). - This is clamped to ensure we use at least two bytes if the encoder - was entirely empty, but to allow 0 in hybrid mode. */ - vbr_bound = vbr_rate; - max_allowed = IMIN(IMAX(tell==1?2:0, - (vbr_rate+vbr_bound-st->vbr_reservoir)>>(BITRES+3)), + celt_assert(st->signalling == 0); +#endif + + /* Can't produce more than 1275 output bytes for the main payload. */ + nbCompressedBytes = IMIN(nbCompressedBytes, packet_size_cap); + + if (st->vbr && st->bitrate != OAC_BITRATE_MAX) { + vbr_rate = oaci_bitrate_to_bits(st->bitrate, mode->Fs, frame_size)<signalling) + vbr_rate -= 8<>(3 + BITRES); + } else { + oac_int32 tmp; + vbr_rate = 0; + tmp = st->bitrate*frame_size; + if (tell > 1) + tmp += tell*mode->Fs; + if (st->bitrate != OAC_BITRATE_MAX) { + nbCompressedBytes = IMAX(2, IMIN(nbCompressedBytes, + (tmp + 4*mode->Fs)/(8*mode->Fs) - !!st->signalling)); + if (enc != NULL) + oaci_ec_enc_shrink(enc, nbCompressedBytes); + } + effectiveBytes = nbCompressedBytes - nbFilledBytes; + } + nbAvailableBytes = nbCompressedBytes - nbFilledBytes; + equiv_rate = ((oac_int32)nbCompressedBytes*8*50<<(3 - LM)) - (40*C + 20)*((400>>LM) - 50); + if (st->bitrate != OAC_BITRATE_MAX) + equiv_rate = IMIN(equiv_rate, st->bitrate - (40*C + 20)*((400>>LM) - 50)); + + if (enc == NULL) { + oaci_ec_enc_init(&_enc, compressed, nbCompressedBytes); + enc = &_enc; + } + + if (vbr_rate > 0) { + /* Computes the max bit-rate allowed in VBR mode to avoid violating the + target rate and buffering. + We must do this up front so that bust-prevention logic triggers + correctly if we don't have enough bits. */ + if (st->constrained_vbr) { + oac_int32 vbr_bound; + oac_int32 max_allowed; + /* We could use any multiple of vbr_rate as bound (depending on the + delay). + This is clamped to ensure we use at least two bytes if the encoder + was entirely empty, but to allow 0 in hybrid mode. */ + vbr_bound = vbr_rate; + max_allowed = IMIN(IMAX(tell == 1?2:0, + (vbr_rate + vbr_bound - st->vbr_reservoir)>>(BITRES + 3)), nbAvailableBytes); - if(max_allowed < nbAvailableBytes) - { - nbCompressedBytes = nbFilledBytes+max_allowed; - nbAvailableBytes = max_allowed; - ec_enc_shrink(enc, nbCompressedBytes); - } - } - } - total_bits = nbCompressedBytes*8; - - effEnd = end; - if (effEnd > mode->effEBands) - effEnd = mode->effEBands; - - ALLOC(in, CC*(N+overlap), celt_sig); - - sample_max=MAX32(st->overlap_max, celt_maxabs_res(pcm, C*(N-overlap)/st->upsample)); - st->overlap_max=celt_maxabs_res(pcm+C*(N-overlap)/st->upsample, C*overlap/st->upsample); - sample_max=MAX32(sample_max, st->overlap_max); + if (max_allowed < nbAvailableBytes) { + nbCompressedBytes = nbFilledBytes + max_allowed; + nbAvailableBytes = max_allowed; + oaci_ec_enc_shrink(enc, nbCompressedBytes); + } + } + } + total_bits = nbCompressedBytes*8; + + effEnd = end; + if (effEnd > mode->effEBands) + effEnd = mode->effEBands; + + ALLOC(in, CC*(N + overlap), celt_sig); + + sample_max = MAX32(st->overlap_max, celt_maxabs_res(pcm, CC*(N - overlap)/st->upsample)); + st->overlap_max = celt_maxabs_res(pcm + CC*(N - overlap)/st->upsample, CC*overlap/st->upsample); + sample_max = MAX32(sample_max, st->overlap_max); #ifdef FIXED_POINT - silence = (sample_max==0); + silence = (sample_max == 0); #else - silence = (sample_max <= (opus_val16)1/(1<lsb_depth)); + silence = (sample_max <= (oac_val16)1/(1<lsb_depth)); #endif #ifdef FUZZING - if ((rand()&0x3F)==0) - silence = 1; -#endif - if (tell==1) - ec_enc_bit_logp(enc, silence, 15); - else - silence=0; - if (silence) - { - /*In VBR mode there is no need to send more than the minimum. */ - if (vbr_rate>0) - { - effectiveBytes=nbCompressedBytes=IMIN(nbCompressedBytes, nbFilledBytes+2); - total_bits=nbCompressedBytes*8; - nbAvailableBytes=2; - ec_enc_shrink(enc, nbCompressedBytes); - } -#ifdef ENABLE_QEXT - else if (st->enable_qext) { - nbCompressedBytes = IMIN(nbCompressedBytes, 1275); - nbAvailableBytes = nbCompressedBytes - nbFilledBytes; - total_bits = nbCompressedBytes*8; - ec_enc_shrink(enc, nbCompressedBytes); - } -#endif - /* Pretend we've filled all the remaining bits with zeros - (that's what the initialiser did anyway) */ - tell = nbCompressedBytes*8; - enc->nbits_total+=tell-ec_tell(enc); - } - c=0; do { - int need_clip=0; + if ((rand()&0x3F) == 0) + silence = 1; +#endif + if (tell == 1) + oaci_ec_enc_bit_logp(enc, silence, 15); + else + silence = 0; + if (silence) { + /*In VBR mode there is no need to send more than the minimum. */ + if (vbr_rate > 0) { + effectiveBytes = nbCompressedBytes = IMIN(nbCompressedBytes, nbFilledBytes + 2); + total_bits = nbCompressedBytes*8; + nbAvailableBytes = 2; + oaci_ec_enc_shrink(enc, nbCompressedBytes); + } + /* Pretend we've filled all the remaining bits with zeros + (that's what the initialiser did anyway) */ + tell = nbCompressedBytes*8; + enc->nbits_total += tell - oaci_ec_tell(enc); + } + c = 0; do { + int need_clip = 0; #ifdef FIXED_POINT - need_clip = st->clip && sample_max>65536<clip && sample_max > 65536<clip && sample_max>65536.f; -#endif - celt_preemphasis(pcm+c, in+c*(N+overlap)+overlap, N, CC, st->upsample, - mode->preemph, st->preemph_memE+c, need_clip); - OPUS_COPY(in+c*(N+overlap), &prefilter_mem[(1+c)*QEXT_SCALE(COMBFILTER_MAXPERIOD)-overlap], overlap); - } while (++cFs); - isTransient = 0; - shortBlocks = 0; - if (st->complexity >= 1 && !st->lfe) - { - /* Reduces the likelihood of energy instability on fricatives at low bitrate - in hybrid mode. It seems like we still want to have real transients on vowels - though (small SILK quantization offset value). */ - int allow_weak_transients = hybrid && effectiveBytes<15 && st->silk_info.signalType != 2; - isTransient = transient_analysis(in, N+overlap, CC, + need_clip = st->clip && sample_max > 65536.f; +#endif + oaci_celt_preemphasis(pcm + c, in + c*(N + overlap) + overlap, N, CC, st->upsample, + mode->preemph, st->preemph_memE + c, need_clip); + OAC_COPY(in + c*(N + overlap), &prefilter_mem[(1 + c)*QEXT_SCALE(COMBFILTER_MAXPERIOD) - overlap], overlap); + } while (++c < CC); + + + tone_freq = oaci_tone_detect(in, CC, N + overlap, &toneishness, mode->Fs); + isTransient = 0; + shortBlocks = 0; + if (st->complexity >= 1 && !st->lfe) { + /* Reduces the likelihood of energy instability on fricatives at low bitrate + in hybrid mode. It seems like we still want to have real transients on vowels + though (small SILK quantization offset value). */ + int allow_weak_transients = hybrid && effectiveBytes < 15 && st->silk_info.signalType != 2; + isTransient = oaci_transient_analysis(in, N + overlap, CC, &tf_estimate, &tf_chan, allow_weak_transients, &weak_transient, tone_freq, toneishness); - } - toneishness = MIN32(toneishness, QCONST32(1.f, 29)-SHL32(tf_estimate, 15)); - /* Find pitch period and gain */ - { - int enabled; - int qg; - enabled = ((st->lfe&&nbAvailableBytes>3) || nbAvailableBytes>12*C) && !hybrid && !silence && tell+16<=total_bits && !st->disable_pf; - - prefilter_tapset = st->tapset_decision; - pf_on = run_prefilter(st, in, prefilter_mem, CC, N, prefilter_tapset, &pitch_index, &gain1, &qg, enabled, st->complexity, tf_estimate, nbAvailableBytes, &st->analysis, tone_freq, toneishness ARG_QEXT(qext_scale)); - if ((gain1 > QCONST16(.4f,15) || st->prefilter_gain > QCONST16(.4f,15)) && (!st->analysis.valid || st->analysis.tonality > .3) + } + toneishness = MIN32(toneishness, QCONST32(1.f, 29) - SHL32(tf_estimate, 15)); + /* Find pitch period and gain */ + { + int enabled; + int qg; + enabled = ((st->lfe && nbAvailableBytes > 3) || nbAvailableBytes > 12*C) && !hybrid && !silence + && tell + 16 <= total_bits && !st->disable_pf; + + prefilter_tapset = st->tapset_decision; + pf_on = oaci_run_prefilter(st, in, prefilter_mem, CC, N, prefilter_tapset, &pitch_index, &gain1, &qg, enabled, + st->complexity, tf_estimate, nbAvailableBytes, &st->analysis, tone_freq, toneishness, qext_scale); + if ((gain1 > QCONST16(.4f, 15) || st->prefilter_gain > QCONST16(.4f, + 15)) && (!st->analysis.valid || st->analysis.tonality > .3) && (pitch_index > 1.26*st->prefilter_period || pitch_index < .79*st->prefilter_period)) - pitch_change = 1; - if (pf_on==0) - { - if(!hybrid && tell+16<=total_bits) - ec_enc_bit_logp(enc, 0, 1); - } else { - /*This block is not gated by a total bits check only because - of the nbAvailableBytes check above.*/ - int octave; - ec_enc_bit_logp(enc, 1, 1); - pitch_index += 1; - octave = EC_ILOG(pitch_index)-5; - ec_enc_uint(enc, octave, 6); - ec_enc_bits(enc, pitch_index-(16<0 && ec_tell(enc)+3<=total_bits) - { - if (isTransient) - shortBlocks = M; - } else { - isTransient = 0; - transient_got_disabled=1; - } - - ALLOC(freq, CC*N, celt_sig); /**< Interleaved signal MDCTs */ - ALLOC(bandE,nbEBands*CC, celt_ener); - ALLOC(bandLogE,nbEBands*CC, celt_glog); - - secondMdct = shortBlocks && st->complexity>=8; - ALLOC(bandLogE2, C*nbEBands, celt_glog); - if (secondMdct) - { - 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 (c=0;cupsample, st->arch); - /* This should catch any NaN in the CELT input. Since we're not supposed to see any (they're filtered - at the Opus layer), just abort. */ - celt_assert(!celt_isnan(freq[0]) && (C==1 || !celt_isnan(freq[N]))); - if (CC==2&&C==1) - tf_chan = 0; - compute_band_energies(mode, freq, bandE, effEnd, C, LM, st->arch); - - if (st->lfe) - { - for (i=2;ienergy_mask&&!st->lfe) - { - int mask_end; - int midband; - int count_dynalloc; - opus_val32 mask_avg=0; - opus_val32 diff=0; - int count=0; - mask_end = IMAX(2,st->lastCodedBands); - for (c=0;cenergy_mask[nbEBands*c+i], + pitch_change = 1; + if (pf_on == 0) { + if (!hybrid && tell + 18 <= total_bits) + oaci_ec_enc_bit_logp(enc, 0, 1); + } else { + /*This block is not gated by a total bits check only because + of the nbAvailableBytes check above.*/ + int octave; + oaci_ec_enc_bit_logp(enc, 1, 1); + pitch_index += 1; + octave = EC_ILOG(pitch_index) - 5; + oaci_ec_enc_uint(enc, octave, 6); + oaci_ec_enc_bits(enc, pitch_index - (16< 0 && oaci_ec_tell(enc) + 3 <= total_bits) { + if (isTransient) + shortBlocks = M; + } else { + isTransient = 0; + transient_got_disabled = 1; + } + + ALLOC(freq, CC*N, celt_sig); /**< Interleaved signal MDCTs */ + ALLOC(bandE, nbEBands*CC, celt_ener); + ALLOC(bandLogE, nbEBands*CC, celt_glog); + + secondMdct = shortBlocks && st->complexity >= 8; + ALLOC(bandLogE2, C*nbEBands, celt_glog); + if (secondMdct) { + oaci_compute_mdcts(mode, 0, in, freq, C, CC, LM, st->upsample, st->arch); + oaci_compute_band_energies(mode, freq, bandE, effEnd, C, LM, st->arch); + oaci_amp2Log2(mode, effEnd, end, bandE, bandLogE2, C); + for (c = 0; c < C; c++) { + for (i = 0; i < end; i++) + bandLogE2[nbEBands*c + i] += HALF32(SHL32(LM, DB_SHIFT)); + } + } + + oaci_compute_mdcts(mode, shortBlocks, in, freq, C, CC, LM, st->upsample, st->arch); + /* This should catch any NaN in the CELT input. Since we're not supposed to see any (they're filtered + at the Oac layer), just abort. */ + celt_assert(!oaci_celt_isnan(freq[0]) && (C == 1 || !oaci_celt_isnan(freq[N]))); + if (CC == 2 && C == 1) + tf_chan = 0; + oaci_compute_band_energies(mode, freq, bandE, effEnd, C, LM, st->arch); + + if (st->lfe) { + for (i = 2; i < end; i++) { + bandE[i] = IMIN(bandE[i], MULT16_32_Q15(QCONST16(1e-4f, 15), bandE[0])); + bandE[i] = MAX32(bandE[i], EPSILON); + } + } + oaci_amp2Log2(mode, effEnd, end, bandE, bandLogE, C); + + ALLOC(surround_dynalloc, C*nbEBands, celt_glog); + OAC_CLEAR(surround_dynalloc, end); + /* This computes how much masking takes place between surround channels */ + if (!hybrid && st->energy_mask && !st->lfe) { + int mask_end; + int midband; + int count_dynalloc; + oac_val32 mask_avg = 0; + oac_val32 diff = 0; + int count = 0; + mask_end = IMAX(2, st->lastCodedBands); + for (c = 0; c < C; c++) { + for (i = 0; i < mask_end; i++) { + celt_glog mask; + oac_val16 mask16; + mask = MAXG(MING(st->energy_mask[nbEBands*c + i], GCONST(.25f)), -GCONST(2.0f)); - if (mask > 0) - mask = HALF32(mask); - mask16 = SHR32(mask, DB_SHIFT-10); - mask_avg += MULT16_16(mask16, eBands[i+1]-eBands[i]); - count += eBands[i+1]-eBands[i]; - diff += MULT16_16(mask16, 1+2*i-mask_end); - } - } - celt_assert(count>0); - mask_avg = SHL32(DIV32_16(mask_avg,count), DB_SHIFT-10); - mask_avg += GCONST(.2f); - diff = SHL32(diff*6/(C*(mask_end-1)*(mask_end+1)*mask_end), DB_SHIFT-10); - /* Again, being conservative */ - diff = HALF32(diff); - diff = MAX32(MIN32(diff, GCONST(.031f)), -GCONST(.031f)); - /* Find the band that's in the middle of the coded spectrum */ - for (midband=0;eBands[midband+1] < eBands[mask_end]/2;midband++); - count_dynalloc=0; - for(i=0;ienergy_mask[i], st->energy_mask[nbEBands+i]); - else - unmask = st->energy_mask[i]; - unmask = MING(unmask, GCONST(.0f)); - unmask -= lin; - if (unmask > GCONST(.25f)) - { - surround_dynalloc[i] = unmask - GCONST(.25f); - count_dynalloc++; - } - } - if (count_dynalloc>=3) - { - /* If we need dynalloc in many bands, it's probably because our - initial masking rate was too low. */ - mask_avg += GCONST(.25f); - if (mask_avg>0) - { - /* Something went really wrong in the original calculations, - disabling masking. */ - mask_avg = 0; - diff = 0; - OPUS_CLEAR(surround_dynalloc, mask_end); - } else { - for(i=0;ilfe) - { - celt_glog follow=-QCONST32(10.0f, DB_SHIFT-5); - opus_val32 frame_avg=0; - celt_glog offset = shortBlocks?HALF32(SHL32(LM, DB_SHIFT-5)):0; - for(i=start;ispec_avg); - temporal_vbr = MING(GCONST(3.f), MAXG(-GCONST(1.5f), temporal_vbr)); - st->spec_avg += MULT16_32_Q15(QCONST16(.02f, 15), temporal_vbr); - } - /*for (i=0;i<21;i++) - printf("%f ", bandLogE[i]); - printf("\n");*/ - - if (!secondMdct) - { - OPUS_COPY(bandLogE2, bandLogE, C*nbEBands); - } - - /* Last chance to catch any transient we might have missed in the - time-domain analysis */ - if (LM>0 && ec_tell(enc)+3<=total_bits && !isTransient && st->complexity>=5 && !st->lfe && !hybrid) - { - if (patch_transient_decision(bandLogE, oldBandE, nbEBands, start, end, C)) - { - isTransient = 1; - shortBlocks = M; - compute_mdcts(mode, shortBlocks, 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, bandLogE, C); - /* Compensate for the scaling of short vs long mdcts */ - for (c=0;c0 && ec_tell(enc)+3<=total_bits) - ec_enc_bit_logp(enc, isTransient, 3); - - ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ - - /* Band normalisation */ - normalise_bands(mode, freq, X, bandE, effEnd, C, M); - - enable_tf_analysis = effectiveBytes>=15*C && !hybrid && st->complexity>=2 && !st->lfe && toneishness < QCONST32(.98f, 29); - - ALLOC(offsets, nbEBands, int); - ALLOC(importance, nbEBands, int); - ALLOC(spread_weight, nbEBands, int); - - maxDepth = dynalloc_analysis(bandLogE, bandLogE2, oldBandE, nbEBands, start, end, C, offsets, + if (mask > 0) + mask = HALF32(mask); + mask16 = SHR32(mask, DB_SHIFT - 10); + mask_avg += MULT16_16(mask16, eBands[i + 1] - eBands[i]); + count += eBands[i + 1] - eBands[i]; + diff += MULT16_16(mask16, 1 + 2*i - mask_end); + } + } + celt_assert(count > 0); + mask_avg = SHL32(DIV32_16(mask_avg, count), DB_SHIFT - 10); + mask_avg += GCONST(.2f); + diff = SHL32(diff*6/(C*(mask_end - 1)*(mask_end + 1)*mask_end), DB_SHIFT - 10); + /* Again, being conservative */ + diff = HALF32(diff); + diff = MAX32(MIN32(diff, GCONST(.031f)), -GCONST(.031f)); + /* Find the band that's in the middle of the coded spectrum */ + for (midband = 0; eBands[midband + 1] < eBands[mask_end]/2; midband++) ; + count_dynalloc = 0; + for (i = 0; i < mask_end; i++) { + oac_val32 lin; + celt_glog unmask; + lin = mask_avg + diff*(i - midband); + if (C == 2) + unmask = MAXG(st->energy_mask[i], st->energy_mask[nbEBands + i]); + else + unmask = st->energy_mask[i]; + unmask = MING(unmask, GCONST(.0f)); + unmask -= lin; + if (unmask > GCONST(.25f)) { + surround_dynalloc[i] = unmask - GCONST(.25f); + count_dynalloc++; + } + } + if (count_dynalloc >= 3) { + /* If we need dynalloc in many bands, it's probably because our + initial masking rate was too low. */ + mask_avg += GCONST(.25f); + if (mask_avg > 0) { + /* Something went really wrong in the original calculations, + disabling masking. */ + mask_avg = 0; + diff = 0; + OAC_CLEAR(surround_dynalloc, mask_end); + } else { + for (i = 0; i < mask_end; i++) + surround_dynalloc[i] = MAXG(0, surround_dynalloc[i] - GCONST(.25f)); + } + } + mask_avg += GCONST(.2f); + /* Convert to 1/64th units used for the trim */ + surround_trim = 64*diff; + /*printf("%d %d ", mask_avg, surround_trim);*/ + surround_masking = mask_avg; + } + /* Temporal VBR (but not for LFE) */ + if (!st->lfe) { + celt_glog follow = -QCONST32(10.0f, DB_SHIFT - 5); + oac_val32 frame_avg = 0; + celt_glog offset = shortBlocks?HALF32(SHL32(LM, DB_SHIFT - 5)):0; + for (i = start; i < end; i++) { + follow = MAXG(follow - QCONST32(1.0f, DB_SHIFT - 5), SHR32(bandLogE[i], 5) - offset); + if (C == 2) + follow = MAXG(follow, SHR32(bandLogE[i + nbEBands], 5) - offset); + frame_avg += follow; + } + frame_avg /= (end - start); + temporal_vbr = SUB32(SHL32(frame_avg, 5), st->spec_avg); + temporal_vbr = MING(GCONST(3.f), MAXG(-GCONST(1.5f), temporal_vbr)); + st->spec_avg += MULT16_32_Q15(QCONST16(.02f, 15), temporal_vbr); + } + /*for (i=0;i<21;i++) + printf("%f ", bandLogE[i]); + printf("\n");*/ + + if (!secondMdct) { + OAC_COPY(bandLogE2, bandLogE, C*nbEBands); + } + + /* Last chance to catch any transient we might have missed in the + time-domain analysis */ + if (LM > 0 && oaci_ec_tell(enc) + 3 <= total_bits && !isTransient && st->complexity >= 5 && !st->lfe && !hybrid) { + if (oaci_patch_transient_decision(bandLogE, oldBandE, nbEBands, start, end, C)) { + isTransient = 1; + shortBlocks = M; + oaci_compute_mdcts(mode, shortBlocks, in, freq, C, CC, LM, st->upsample, st->arch); + oaci_compute_band_energies(mode, freq, bandE, effEnd, C, LM, st->arch); + oaci_amp2Log2(mode, effEnd, end, bandE, bandLogE, C); + /* Compensate for the scaling of short vs long mdcts */ + for (c = 0; c < C; c++) { + for (i = 0; i < end; i++) + bandLogE2[nbEBands*c + i] += HALF32(SHL32(LM, DB_SHIFT)); + } + tf_estimate = QCONST16(.2f, 14); + } + } + + if (LM > 0 && oaci_ec_tell(enc) + 3 <= total_bits) + oaci_ec_enc_bit_logp(enc, isTransient, 3); + + ALLOC(X, C*N, celt_norm); /**< Interleaved normalised MDCTs */ + + /* Band normalisation */ + oaci_normalise_bands(mode, freq, X, bandE, effEnd, C, M); + + enable_tf_analysis = effectiveBytes >= 15*C && !hybrid && st->complexity >= 2 && !st->lfe + && toneishness < QCONST32(.98f, 29); + + ALLOC(offsets, nbEBands, int); + ALLOC(importance, nbEBands, int); + ALLOC(spread_weight, nbEBands, int); + + maxDepth = oaci_dynalloc_analysis(bandLogE, bandLogE2, oldBandE, nbEBands, start, end, C, offsets, st->lsb_depth, mode->logN, isTransient, st->vbr, st->constrained_vbr, - eBands, LM, effectiveBytes, &tot_boost, st->lfe, surround_dynalloc, &st->analysis, importance, spread_weight, tone_freq, toneishness ARG_QEXT(qext_scale)); - - ALLOC(tf_res, nbEBands, int); - /* Disable variable tf resolution for hybrid and at very low bitrate */ - if (enable_tf_analysis) - { - int lambda; - lambda = IMAX(80, 20480/effectiveBytes + 2); - tf_select = tf_analysis(mode, effEnd, isTransient, tf_res, lambda, X, N, LM, tf_estimate, tf_chan, importance); - for (i=effEnd;isilk_info.signalType != 2) - { - /* For low bitrate hybrid, we force temporal resolution to 5 ms rather than 2.5 ms. */ - for (i=0;ilfe, surround_dynalloc, &st->analysis, importance, spread_weight, + tone_freq, toneishness, qext_scale); + + ALLOC(tf_res, nbEBands, int); + /* Disable variable tf resolution for hybrid and at very low bitrate */ + if (enable_tf_analysis) { + int lambda; + lambda = IMAX(80, 20480/effectiveBytes + 2); + tf_select = oaci_tf_analysis(mode, effEnd, isTransient, tf_res, lambda, X, N, LM, tf_estimate, tf_chan, importance); + for (i = effEnd; i < end; i++) + tf_res[i] = tf_res[effEnd - 1]; + } else if (hybrid && weak_transient) { + /* For weak transients, we rely on the fact that improving time resolution using + TF on a long window is imperfect and will not result in an energy collapse at + low bitrate. */ + for (i = 0; i < end; i++) + tf_res[i] = 1; + tf_select = 0; + } else if (hybrid && effectiveBytes < 15 && st->silk_info.signalType != 2) { + /* For low bitrate hybrid, we force temporal resolution to 5 ms rather than 2.5 ms. */ + for (i = 0; i < end; i++) + tf_res[i] = 0; + tf_select = isTransient; + } else { + for (i = 0; i < end; i++) + tf_res[i] = isTransient; + tf_select = 0; + } + + ALLOC(error, C*nbEBands, celt_glog); + c = 0; + do { + for (i = start; i < end; i++) { + /* When the energy is stable, slightly bias energy quantization towards + the previous error to make the gain more stable (a constant offset is + better than fluctuations). */ + if (ABS32(SUB32(bandLogE[i + c*nbEBands], oldBandE[i + c*nbEBands])) < GCONST(2.f)) { + bandLogE[i + c*nbEBands] -= MULT16_32_Q15(QCONST16(0.25f, 15), energyError[i + c*nbEBands]); + } + } + } while (++c < C); + oaci_quant_coarse_energy(mode, start, end, effEnd, bandLogE, oldBandE, total_bits, error, enc, C, LM, nbAvailableBytes, st->force_intra, &st->delayedIntra, st->complexity >= 4, st->loss_rate, st->lfe); - tf_encode(start, end, isTransient, tf_res, LM, tf_select, enc); - - if (ec_tell(enc)+4<=total_bits) - { - if (st->lfe) - { - st->tapset_decision = 0; - st->spread_decision = SPREAD_NORMAL; - } else if (hybrid) - { - if (st->complexity == 0) - st->spread_decision = SPREAD_NONE; - else if (isTransient) - st->spread_decision = SPREAD_NORMAL; - else - st->spread_decision = SPREAD_AGGRESSIVE; - } else if (shortBlocks || st->complexity < 3 || nbAvailableBytes < 10*C) - { - if (st->complexity == 0) - st->spread_decision = SPREAD_NONE; - else + oaci_tf_encode(start, end, isTransient, tf_res, LM, tf_select, enc); + + if (oaci_ec_tell(enc) + 4 <= total_bits) { + if (st->lfe) { + st->tapset_decision = 0; st->spread_decision = SPREAD_NORMAL; - } else { - /* Disable new spreading+tapset estimator until we can show it works - better than the old one. So far it seems like spreading_decision() - works best. */ + } else if (hybrid) { + if (st->complexity == 0) + st->spread_decision = SPREAD_NONE; + else if (isTransient) + st->spread_decision = SPREAD_NORMAL; + else + st->spread_decision = SPREAD_AGGRESSIVE; + } else if (shortBlocks || st->complexity < 3 || nbAvailableBytes < 10*C) { + if (st->complexity == 0) + st->spread_decision = SPREAD_NONE; + else + st->spread_decision = SPREAD_NORMAL; + } else { + /* Disable new spreading+tapset estimator until we can show it works + better than the old one. So far it seems like oaci_spreading_decision() + works best. */ #if 0 - if (st->analysis.valid) - { - static const opus_val16 spread_thresholds[3] = {-QCONST16(.6f, 15), -QCONST16(.2f, 15), -QCONST16(.07f, 15)}; - static const opus_val16 spread_histeresis[3] = {QCONST16(.15f, 15), QCONST16(.07f, 15), QCONST16(.02f, 15)}; - static const opus_val16 tapset_thresholds[2] = {QCONST16(.0f, 15), QCONST16(.15f, 15)}; - static const opus_val16 tapset_histeresis[2] = {QCONST16(.1f, 15), QCONST16(.05f, 15)}; - st->spread_decision = hysteresis_decision(-st->analysis.tonality, spread_thresholds, spread_histeresis, 3, st->spread_decision); - st->tapset_decision = hysteresis_decision(st->analysis.tonality_slope, tapset_thresholds, tapset_histeresis, 2, st->tapset_decision); - } else -#endif - { - st->spread_decision = spreading_decision(mode, X, + if (st->analysis.valid) { + static const oac_val16 spread_thresholds[3] = {-QCONST16(.6f, 15), -QCONST16(.2f, 15), + -QCONST16(.07f, 15)}; + static const oac_val16 spread_histeresis[3] = {QCONST16(.15f, 15), QCONST16(.07f, 15), + QCONST16(.02f, 15)}; + static const oac_val16 tapset_thresholds[2] = {QCONST16(.0f, 15), QCONST16(.15f, 15)}; + static const oac_val16 tapset_histeresis[2] = {QCONST16(.1f, 15), QCONST16(.05f, 15)}; + st->spread_decision = oaci_hysteresis_decision(-st->analysis.tonality, spread_thresholds, spread_histeresis, + 3, st->spread_decision); + st->tapset_decision = oaci_hysteresis_decision(st->analysis.tonality_slope, tapset_thresholds, + tapset_histeresis, 2, st->tapset_decision); + } else +#endif + { + st->spread_decision = oaci_spreading_decision(mode, X, &st->tonal_average, st->spread_decision, &st->hf_average, - &st->tapset_decision, pf_on&&!shortBlocks, effEnd, C, M, spread_weight); - } - /*printf("%d %d\n", st->tapset_decision, st->spread_decision);*/ - /*printf("%f %d %f %d\n\n", st->analysis.tonality, st->spread_decision, st->analysis.tonality_slope, st->tapset_decision);*/ - } - ec_enc_icdf(enc, st->spread_decision, spread_icdf, 5); - } else { - st->spread_decision = SPREAD_NORMAL; - } - - /* For LFE, everything interesting is in the first band */ - if (st->lfe) - offsets[0] = IMIN(8, effectiveBytes/3); - ALLOC(cap, nbEBands, int); - init_caps(mode,cap,LM,C); - - dynalloc_logp = 6; - total_bits<<=BITRES; - total_boost = 0; - tell = ec_tell_frac(enc); - for (i=start;itapset_decision, pf_on && !shortBlocks, effEnd, C, M, spread_weight); + } + /*printf("%d %d\n", st->tapset_decision, st->spread_decision);*/ + /*printf("%f %d %f %d\n\n", st->analysis.tonality, st->spread_decision, st->analysis.tonality_slope, st->tapset_decision);*/ + } + oaci_ec_enc_icdf(enc, st->spread_decision, spread_icdf, 5); + } else { + st->spread_decision = SPREAD_NORMAL; + } + + /* For LFE, everything interesting is in the first band */ + if (st->lfe) + offsets[0] = IMIN(8, effectiveBytes/3); + ALLOC(cap, nbEBands, int); + oaci_init_caps(mode, cap, LM, C); + + dynalloc_logp = 6; + total_bits <<= BITRES; + total_boost = 0; + tell = oaci_ec_tell_frac(enc); + for (i = start; i < end; i++) { + int width, quanta; + int dynalloc_loop_logp; + int boost; + int j; + width = C*(eBands[i + 1] - eBands[i])<intensity = hysteresis_decision((opus_val16)(equiv_rate/1000), + st->intensity = oaci_hysteresis_decision((oac_val16)(equiv_rate/1000), intensity_thresholds, intensity_histeresis, 21, st->intensity); - st->intensity = IMIN(end,IMAX(start, st->intensity)); - } - - alloc_trim = 5; - if (tell+(6< 0 || st->lfe) - { - st->stereo_saving = 0; - alloc_trim = 5; - } else { - alloc_trim = alloc_trim_analysis(mode, X, bandLogE, + st->intensity = IMIN(end, IMAX(start, st->intensity)); + } + + alloc_trim = 5; + if (tell + (7< 0 || st->lfe) { + st->stereo_saving = 0; + alloc_trim = 5; + } else { + alloc_trim = oaci_alloc_trim_analysis(mode, X, bandLogE, end, LM, C, N, &st->analysis, &st->stereo_saving, tf_estimate, st->intensity, surround_trim, equiv_rate, st->arch); - } - ec_enc_icdf(enc, alloc_trim, trim_icdf, 7); - tell = ec_tell_frac(enc); - } - - /* In VBR mode the frame size must not be reduced so much that it would - result in the encoder running out of bits. - The margin of 2 bytes ensures that none of the bust-prevention logic - in the decoder will have triggered so far. */ - min_allowed = ((tell+total_boost+(1<<(BITRES+3))-1)>>(BITRES+3)) + 2; - /* Take into account the 37 bits we need to have left in the packet to - signal a redundant frame in hybrid mode. Creating a shorter packet would - create an entropy coder desync. */ - if (hybrid) - min_allowed = IMAX(min_allowed, (tell0_frac+(37<>(BITRES+3)); - /* Variable bitrate */ - if (vbr_rate>0) - { - opus_val16 alpha; - opus_int32 delta; - /* The target rate in 8th bits per frame */ - opus_int32 target, base_target; - int lm_diff = mode->maxLM - LM; - - /* Don't attempt to use more than 510 kb/s, even for frames smaller than 20 ms. - The CELT allocator will just not be able to use more than that anyway. */ - nbCompressedBytes = IMIN(nbCompressedBytes,packet_size_cap>>(3-LM)); - if (!hybrid) - { - base_target = vbr_rate - ((40*C+20)<constrained_vbr) - base_target += (st->vbr_offset>>lm_diff); - - if (!hybrid) - { - target = compute_vbr(mode, &st->analysis, base_target, LM, equiv_rate, + } + oaci_ec_enc_icdf(enc, alloc_trim, trim_icdf, 7); + tell = oaci_ec_tell_frac(enc); + } + + /* In VBR mode the frame size must not be reduced so much that it would + result in the encoder running out of bits. + The margin of 2 bytes ensures that none of the bust-prevention logic + in the decoder will have triggered so far. */ + min_allowed = ((tell + total_boost + (1<<(BITRES + 3)) - 1)>>(BITRES + 3)) + 2; + /* Take into account the 37 bits we need to have left in the packet to + signal a redundant frame in hybrid mode. Creating a shorter packet would + create an entropy coder desync. */ + if (hybrid) + min_allowed = IMAX(min_allowed, + (tell0_frac + (37<>(BITRES + 3)); + /* Variable bitrate */ + if (vbr_rate > 0) { + oac_val16 alpha; + oac_int32 delta; + /* The target rate in 8th bits per frame */ + oac_int32 target, base_target; + int lm_diff = mode->maxLM - LM; + + /* Don't attempt to use more than 510 kb/s, even for frames smaller than 20 ms. + The CELT allocator will just not be able to use more than that anyway. */ + nbCompressedBytes = IMIN(nbCompressedBytes, packet_size_cap>>(3 - LM)); + if (!hybrid) { + base_target = vbr_rate - ((40*C + 20)<constrained_vbr) + base_target += (st->vbr_offset>>lm_diff); + + if (!hybrid) { + target = oaci_compute_vbr(mode, &st->analysis, base_target, LM, equiv_rate, st->lastCodedBands, C, st->intensity, st->constrained_vbr, st->stereo_saving, tot_boost, tf_estimate, pitch_change, maxDepth, - st->lfe, st->energy_mask!=NULL, surround_masking, - temporal_vbr ARG_QEXT(st->enable_qext)); - } else { - target = base_target; - /* Tonal frames (offset<100) need more bits than noisy (offset>100) ones. */ - if (st->silk_info.offset < 100) target += 12 << BITRES >> (3-LM); - if (st->silk_info.offset > 100) target -= 18 << BITRES >> (3-LM); - /* Boosting bitrate on transients and vowels with significant temporal - spikes. */ - target += (opus_int32)MULT16_16_Q14(tf_estimate-QCONST16(.25f,14), (50< QCONST16(.7f,14)) - target = IMAX(target, 50<>(BITRES+3); - nbAvailableBytes = IMAX(min_allowed,nbAvailableBytes); - nbAvailableBytes = IMIN(nbCompressedBytes,nbAvailableBytes); - - /* By how much did we "miss" the target on that frame */ - delta = target - vbr_rate; - - target=nbAvailableBytes<<(BITRES+3); - - /*If the frame is silent we don't adjust our drift, otherwise - the encoder will shoot to very high rates after hitting a - span of silence, but we do allow the bitres to refill. - This means that we'll undershoot our target in CVBR/VBR modes - on files with lots of silence. */ - if(silence) - { - nbAvailableBytes = 2; - target = 2*8<vbr_count < 970) - { - st->vbr_count++; - alpha = celt_rcp(SHL32(EXTEND32(st->vbr_count+20),16)); - } else - alpha = QCONST16(.001f,15); - /* How many bits have we used in excess of what we're allowed */ - if (st->constrained_vbr) - st->vbr_reservoir += target - vbr_rate; - /*printf ("%d\n", st->vbr_reservoir);*/ - - /* Compute the offset we need to apply in order to reach the target */ - if (st->constrained_vbr) - { - st->vbr_drift += (opus_int32)MULT16_32_Q15(alpha,(delta*(1<vbr_offset-st->vbr_drift); - st->vbr_offset = -st->vbr_drift; - } - /*printf ("%d\n", st->vbr_drift);*/ - - if (st->constrained_vbr && st->vbr_reservoir < 0) - { - /* We're under the min value -- increase rate */ - int adjust = (-st->vbr_reservoir)/(8<vbr_reservoir = 0; - /*printf ("+%d\n", adjust);*/ - } - nbCompressedBytes = IMIN(nbCompressedBytes,nbAvailableBytes); - /*printf("%d\n", nbCompressedBytes*50*8);*/ - /* This moves the raw bits to take into account the new compressed size */ - ec_enc_shrink(enc, nbCompressedBytes); - } -#ifdef ENABLE_QEXT - if (st->enable_qext) { - int new_compressedBytes; - /* Don't give any bits for the first 80 kb/s per channel. Then 80% of the excess. */ - opus_int32 offset = bitrate_to_bits(C*80000, mode->Fs, frame_size)/8; - qext_bytes = IMAX(nbCompressedBytes-1275, IMAX(0, (nbCompressedBytes-offset)*4/5)); - if (qext_bytes > 20) { - opus_int32 target; - opus_val16 scale; - target = ((nbCompressedBytes-qext_bytes/3)*8<analysis, target, LM, equiv_rate, - st->lastCodedBands, C, st->intensity, st->constrained_vbr, - st->stereo_saving, tot_boost, tf_estimate2, pitch_change, maxDepth, - st->lfe, st->energy_mask!=NULL, surround_masking, - temporal_vbr ARG_QEXT(st->enable_qext)); - target += tell; - } - scale = PSHR32(toneishness,14); - scale = Q15ONE - MULT16_16_Q15(scale, scale); - qext_bytes += MULT16_32_Q15(scale, (nbCompressedBytes-(target/(8< 20) { - new_compressedBytes = nbCompressedBytes-qext_bytes-padding_len_bytes-1; - ec_enc_shrink(enc, new_compressedBytes); - if (compressed == NULL) { - compressed = enc->buf; - } - compressed[-1] |= 0x03; /* Code 3 packet */ - enc->buf += 1+padding_len_bytes; - OPUS_MOVE(compressed+1+padding_len_bytes, compressed, new_compressedBytes); - compressed[0] = 0x41; /* Set padding */ - for (i=0;iFs == 48000 || mode->Fs == 96000) && (mode->shortMdctSize==120*qext_scale || mode->shortMdctSize==90*qext_scale)) { - compute_qext_mode(&qext_mode_struct, mode); - qext_mode = &qext_mode_struct; - qext_end = (qext_scale == 2) ? NB_QEXT_BANDS : 2; - ec_enc_bit_logp(&ext_enc, qext_end == NB_QEXT_BANDS, 1); - } - } else { - ec_enc_init(&ext_enc, NULL, 0); - qext_bytes = 0; - } - } else { - ec_enc_init(&ext_enc, NULL, 0); - } -#endif - - /* Bit allocation */ - ALLOC(fine_quant, nbEBands, int); - ALLOC(pulses, nbEBands, int); - ALLOC(fine_priority, nbEBands, int); - - /* bits = packet size - where we are - safety*/ - bits = (((opus_int32)nbCompressedBytes*8)<=2&&bits>=((LM+2)<lfe, st->energy_mask != NULL, surround_masking, + temporal_vbr); + } else { + target = base_target; + /* Tonal frames (offset<100) need more bits than noisy (offset>100) ones. */ + if (st->silk_info.offset < 100) target += 12<>(3 - LM); + if (st->silk_info.offset > 100) target -= 18<>(3 - LM); + /* Boosting bitrate on transients and vowels with significant temporal + spikes. */ + target += (oac_int32)MULT16_16_Q14(tf_estimate - QCONST16(.25f, 14), (50< QCONST16(.7f, 14)) + target = IMAX(target, 50<>(BITRES + 3); + nbAvailableBytes = IMAX(min_allowed, nbAvailableBytes); + nbAvailableBytes = IMIN(nbCompressedBytes, nbAvailableBytes); + + /* By how much did we "miss" the target on that frame */ + delta = target - vbr_rate; + + target = nbAvailableBytes<<(BITRES + 3); + + /*If the frame is silent we don't adjust our drift, otherwise + the encoder will shoot to very high rates after hitting a + span of silence, but we do allow the bitres to refill. + This means that we'll undershoot our target in CVBR/VBR modes + on files with lots of silence. */ + if (silence) { + nbAvailableBytes = 2; + target = 2*8<vbr_count < 970) { + st->vbr_count++; + alpha = oaci_celt_rcp(SHL32(EXTEND32(st->vbr_count + 20), 16)); + } else + alpha = QCONST16(.001f, 15); + /* How many bits have we used in excess of what we're allowed */ + if (st->constrained_vbr) + st->vbr_reservoir += target - vbr_rate; + /*printf ("%d\n", st->vbr_reservoir);*/ + + /* Compute the offset we need to apply in order to reach the target */ + if (st->constrained_vbr) { + st->vbr_drift += (oac_int32)MULT16_32_Q15(alpha, (delta*(1<vbr_offset - st->vbr_drift); + st->vbr_offset = -st->vbr_drift; + } + /*printf ("%d\n", st->vbr_drift);*/ + + if (st->constrained_vbr && st->vbr_reservoir < 0) { + /* We're under the min value -- increase rate */ + int adjust = (-st->vbr_reservoir)/(8<vbr_reservoir = 0; + /*printf ("+%d\n", adjust);*/ + } + nbCompressedBytes = IMIN(nbCompressedBytes, nbAvailableBytes); + /*printf("%d\n", nbCompressedBytes*50*8);*/ + /* This moves the raw bits to take into account the new compressed size */ + oaci_ec_enc_shrink(enc, nbCompressedBytes); + } + + /* Bit allocation */ + ALLOC(fine_quant, nbEBands, int); + ALLOC(pulses, nbEBands, int); + ALLOC(fine_priority, nbEBands, int); + + /* bits = packet size - where we are - safety*/ + bits = (((oac_int32)nbCompressedBytes*8)<= 2 && bits >= ((LM + 2)<analysis.valid) - { - int min_bandwidth; - if (equiv_rate < (opus_int32)32000*C) - min_bandwidth = 13; - else if (equiv_rate < (opus_int32)48000*C) - min_bandwidth = 16; - else if (equiv_rate < (opus_int32)60000*C) - min_bandwidth = 18; - else if (equiv_rate < (opus_int32)80000*C) - min_bandwidth = 19; - else - min_bandwidth = 20; - signalBandwidth = IMAX(st->analysis.bandwidth, min_bandwidth); - } -#endif - if (st->lfe) - signalBandwidth = 1; - codedBands = clt_compute_allocation(mode, start, end, offsets, cap, + if (st->analysis.valid) { + int min_bandwidth; + if (equiv_rate < (oac_int32)32000*C) + min_bandwidth = 13; + else if (equiv_rate < (oac_int32)48000*C) + min_bandwidth = 16; + else if (equiv_rate < (oac_int32)60000*C) + min_bandwidth = 18; + else if (equiv_rate < (oac_int32)80000*C) + min_bandwidth = 19; + else + min_bandwidth = 20; + signalBandwidth = IMAX(st->analysis.bandwidth, min_bandwidth); + } +#endif + if (st->lfe) + signalBandwidth = 1; + codedBands = oaci_clt_compute_allocation(mode, start, end, offsets, cap, alloc_trim, &st->intensity, &dual_stereo, bits, &balance, pulses, fine_quant, fine_priority, C, LM, enc, 1, st->lastCodedBands, signalBandwidth); - if (st->lastCodedBands) - st->lastCodedBands = IMIN(st->lastCodedBands+1,IMAX(st->lastCodedBands-1,codedBands)); - else - st->lastCodedBands = codedBands; + if (st->lastCodedBands) + st->lastCodedBands = IMIN(st->lastCodedBands + 1, IMAX(st->lastCodedBands - 1, codedBands)); + else + st->lastCodedBands = codedBands; - quant_fine_energy(mode, start, end, oldBandE, error, NULL, fine_quant, enc, C); - OPUS_CLEAR(energyError, nbEBands*CC); -#ifdef ENABLE_QEXT - if (qext_mode) - { - /* Don't bias for intra. */ - opus_val32 qext_delayedIntra=0; - qext_oldBandE = energyError + CC*nbEBands; - compute_band_energies(qext_mode, freq, qext_bandE, qext_end, C, LM, st->arch); - normalise_bands(qext_mode, freq, X, qext_bandE, qext_end, C, M); - amp2Log2(qext_mode, qext_end, qext_end, qext_bandE, qext_bandLogE, C); - if (C==2) { - qext_intensity = qext_end; - qext_dual_stereo = dual_stereo; - encode_qext_stereo_params(&ext_enc, qext_end, qext_intensity, qext_dual_stereo); - } - quant_coarse_energy(qext_mode, 0, qext_end, qext_end, qext_bandLogE, - qext_oldBandE, qext_bytes*8, qext_error, &ext_enc, - C, LM, qext_bytes, st->force_intra, - &qext_delayedIntra, st->complexity >= 4, st->loss_rate, st->lfe); - } - ALLOC(extra_quant, nbEBands+NB_QEXT_BANDS, int); - ALLOC(extra_pulses, nbEBands+NB_QEXT_BANDS, int); - ALLOC(error_bak, C*nbEBands, celt_glog); - - qext_bits = ((opus_int32)qext_bytes*8< 0) { - quant_fine_energy(mode, start, end, oldBandE, error, fine_quant, extra_quant, &ext_enc, C); - } -#endif + oaci_quant_fine_energy(mode, start, end, oldBandE, error, NULL, fine_quant, enc, C); + OAC_CLEAR(energyError, nbEBands*CC); - /* Residual quantisation */ - ALLOC(collapse_masks, C*nbEBands, unsigned char); - quant_all_bands(1, mode, start, end, X, C==2 ? X+N : NULL, collapse_masks, + /* Residual quantisation */ + ALLOC(collapse_masks, C*nbEBands, unsigned char); + oaci_quant_all_bands(1, mode, start, end, X, C == 2 ? X + N : NULL, collapse_masks, bandE, pulses, shortBlocks, st->spread_decision, - dual_stereo, st->intensity, tf_res, nbCompressedBytes*(8<rng, st->complexity, st->arch, st->disable_inv - ARG_QEXT(&ext_enc) ARG_QEXT(extra_pulses) - ARG_QEXT(qext_bytes*(8<spread_decision, - qext_dual_stereo, qext_intensity, zeros, qext_bytes*(8<rng, st->complexity, st->arch, st->disable_inv, &dummy_enc, zeros, 0, NULL); - } -#endif + dual_stereo, st->intensity, tf_res, nbCompressedBytes*(8<rng, st->complexity, st->arch, st->disable_inv); - if (anti_collapse_rsv > 0) - { - anti_collapse_on = st->consec_transient<2; + if (anti_collapse_rsv > 0) { + anti_collapse_on = st->consec_transient < 2; #ifdef FUZZING - anti_collapse_on = rand()&0x1; -#endif - ec_enc_bits(enc, anti_collapse_on, 1); - } - if (qext_bytes == 0) - quant_energy_finalise(mode, start, end, oldBandE, error, fine_quant, fine_priority, nbCompressedBytes*8-ec_tell(enc), enc, C); - c=0; - do { - for (i=start;i 0) - quant_energy_finalise(mode, start, end, NULL, error_bak, fine_quant, fine_priority, nbCompressedBytes*8-ec_tell(enc), enc, C); -#endif - if (silence) - { - for (i=0;irng, 1, st->arch); - } + } - c=0; do { - OPUS_MOVE(st->syn_mem[c], st->syn_mem[c]+N, QEXT_SCALE(DEC_PITCH_BUF_SIZE)-N+overlap/2); - } while (++csyn_mem[c], st->syn_mem[c] + N, QEXT_SCALE(DEC_PITCH_BUF_SIZE) - N + overlap/2); + } while (++c < CC); - c=0; do { - out_mem[c] = st->syn_mem[c]+QEXT_SCALE(DEC_PITCH_BUF_SIZE)-N; - } while (++csyn_mem[c] + QEXT_SCALE(DEC_PITCH_BUF_SIZE) - N; + } while (++c < CC); - celt_synthesis(mode, X, out_mem, oldBandE, start, effEnd, - C, CC, isTransient, LM, st->upsample, silence, st->arch ARG_QEXT(qext_mode) ARG_QEXT(qext_oldBandE) ARG_QEXT(qext_end)); + oaci_celt_synthesis(mode, X, out_mem, oldBandE, start, effEnd, + C, CC, isTransient, LM, st->upsample, silence, st->arch); - c=0; do { - st->prefilter_period=IMAX(st->prefilter_period, COMBFILTER_MINPERIOD); - st->prefilter_period_old=IMAX(st->prefilter_period_old, COMBFILTER_MINPERIOD); - comb_filter(out_mem[c], out_mem[c], st->prefilter_period_old, st->prefilter_period, mode->shortMdctSize, + c = 0; do { + st->prefilter_period = IMAX(st->prefilter_period, COMBFILTER_MINPERIOD); + st->prefilter_period_old = IMAX(st->prefilter_period_old, COMBFILTER_MINPERIOD); + oaci_comb_filter(out_mem[c], out_mem[c], st->prefilter_period_old, st->prefilter_period, mode->shortMdctSize, st->prefilter_gain_old, st->prefilter_gain, st->prefilter_tapset_old, st->prefilter_tapset, mode->window, overlap, st->arch); - if (LM!=0) - comb_filter(out_mem[c]+mode->shortMdctSize, out_mem[c]+mode->shortMdctSize, st->prefilter_period, pitch_index, N-mode->shortMdctSize, + if (LM != 0) + oaci_comb_filter(out_mem[c] + mode->shortMdctSize, out_mem[c] + mode->shortMdctSize, st->prefilter_period, + pitch_index, N - mode->shortMdctSize, st->prefilter_gain, gain1, st->prefilter_tapset, prefilter_tapset, mode->window, overlap, st->arch); - } while (++cupsample, mode->preemph, st->preemph_memD, 0); - st->prefilter_period_old = st->prefilter_period; - st->prefilter_gain_old = st->prefilter_gain; - st->prefilter_tapset_old = st->prefilter_tapset; - } -#endif + } while (++c < CC); - st->prefilter_period = pitch_index; - st->prefilter_gain = gain1; - st->prefilter_tapset = prefilter_tapset; -#ifdef RESYNTH - if (LM!=0) - { - st->prefilter_period_old = st->prefilter_period; - st->prefilter_gain_old = st->prefilter_gain; - st->prefilter_tapset_old = st->prefilter_tapset; - } + /* We reuse freq[] as scratch space for the de-emphasis */ + oaci_deemphasis(out_mem, (oac_res*)pcm, N, CC, st->upsample, mode->preemph, st->preemph_memD, 0); + st->prefilter_period_old = st->prefilter_period; + st->prefilter_gain_old = st->prefilter_gain; + st->prefilter_tapset_old = st->prefilter_tapset; + } #endif - if (CC==2&&C==1) { - OPUS_COPY(&oldBandE[nbEBands], oldBandE, nbEBands); - } - - if (!isTransient) - { - OPUS_COPY(oldLogE2, oldLogE, CC*nbEBands); - OPUS_COPY(oldLogE, oldBandE, CC*nbEBands); - } else { - for (i=0;iconsec_transient++; - else - st->consec_transient=0; - st->rng = enc->rng; - - /* If there's any room left (can only happen for very high rates), - it's already filled with zeros */ - ec_enc_done(enc); -#ifdef ENABLE_QEXT - ec_enc_done(&ext_enc); - if (qext_bytes > 0) - nbCompressedBytes += padding_len_bytes+2+qext_bytes; - if (qext_bytes) st->rng = st->rng ^ ext_enc.rng; - if (ec_get_error(&ext_enc)) - return OPUS_INTERNAL_ERROR; -#endif -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) - if (st->signalling) - nbCompressedBytes++; -#endif - - RESTORE_STACK; - if (ec_get_error(enc)) - return OPUS_INTERNAL_ERROR; - else - return nbCompressedBytes; + st->prefilter_period = pitch_index; + st->prefilter_gain = gain1; + st->prefilter_tapset = prefilter_tapset; +#ifdef RESYNTH + if (LM != 0) { + st->prefilter_period_old = st->prefilter_period; + st->prefilter_gain_old = st->prefilter_gain; + st->prefilter_tapset_old = st->prefilter_tapset; + } +#endif + + if (CC == 2 && C == 1) { + OAC_COPY(&oldBandE[nbEBands], oldBandE, nbEBands); + } + + if (!isTransient) { + OAC_COPY(oldLogE2, oldLogE, CC*nbEBands); + OAC_COPY(oldLogE, oldBandE, CC*nbEBands); + } else { + for (i = 0; i < CC*nbEBands; i++) + oldLogE[i] = MING(oldLogE[i], oldBandE[i]); + } + /* In case start or end were to change */ + c = 0; do { + for (i = 0; i < start; i++) { + oldBandE[c*nbEBands + i] = 0; + oldLogE[c*nbEBands + i] = oldLogE2[c*nbEBands + i] = -GCONST(28.f); + } + for (i = end; i < nbEBands; i++) { + oldBandE[c*nbEBands + i] = 0; + oldLogE[c*nbEBands + i] = oldLogE2[c*nbEBands + i] = -GCONST(28.f); + } + } while (++c < CC); + + if (isTransient || transient_got_disabled) + st->consec_transient++; + else + st->consec_transient = 0; + st->rng = enc->rng; + + /* If there's any room left (can only happen for very high rates), + it's already filled with zeros */ + oaci_ec_enc_done(enc); +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) + if (st->signalling) + nbCompressedBytes++; +#endif + + RESTORE_STACK; + if (oaci_ec_get_error(enc)) + return OAC_INTERNAL_ERROR; + else + return nbCompressedBytes; } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) -#if defined(FIXED_POINT) && !defined(ENABLE_RES24) -int opus_custom_encode(CELTEncoder * OPUS_RESTRICT st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) -{ - return celt_encode_with_ec(st, pcm, frame_size, compressed, nbCompressedBytes, NULL); -} -#else -int opus_custom_encode(CELTEncoder * OPUS_RESTRICT st, const opus_int16 * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) -{ - int j, ret, C, N; - VARDECL(opus_res, in); - ALLOC_STACK; +int oac_custom_encode(CELTEncoder * OAC_RESTRICT st, const oac_int16 * pcm, int frame_size, unsigned char *compressed, + int nbCompressedBytes) { + int j, ret, C, N; + VARDECL(oac_res, in); + ALLOC_STACK; - if (pcm==NULL) - return OPUS_BAD_ARG; + if (pcm == NULL) + return OAC_BAD_ARG; - C = st->channels; - N = frame_size; - ALLOC(in, C*N, opus_res); + C = st->channels; + N = frame_size; + ALLOC(in, C*N, oac_res); - for (j=0;jchannels; - N = frame_size; - ALLOC(in, C*N, opus_res); - - for (j=0;jchannels; + N = frame_size; + ALLOC(in, C*N, oac_res); + + for (j = 0; j < C*N; j++) + in[j] = INT24TORES(pcm[j]); + + ret = oaci_celt_encode_with_ec(st, in, frame_size, compressed, nbCompressedBytes, NULL); +# ifdef RESYNTH + for (j = 0; j < C*N; j++) + ((oac_int32*)pcm)[j] = RES2INT24(in[j]); +# endif + RESTORE_STACK; + return ret; } -#endif +# endif -#ifndef DISABLE_FLOAT_API +# ifndef DISABLE_FLOAT_API -# if !defined(FIXED_POINT) -int opus_custom_encode_float(CELTEncoder * OPUS_RESTRICT st, const float * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) -{ - return celt_encode_with_ec(st, pcm, frame_size, compressed, nbCompressedBytes, NULL); +# if !defined(FIXED_POINT) +int oac_custom_encode_float(CELTEncoder * OAC_RESTRICT st, const float * pcm, int frame_size, unsigned char *compressed, + int nbCompressedBytes) { + return oaci_celt_encode_with_ec(st, pcm, frame_size, compressed, nbCompressedBytes, NULL); } -# else -int opus_custom_encode_float(CELTEncoder * OPUS_RESTRICT st, const float * pcm, int frame_size, unsigned char *compressed, int nbCompressedBytes) -{ - int j, ret, C, N; - VARDECL(opus_res, in); - ALLOC_STACK; - - if (pcm==NULL) - return OPUS_BAD_ARG; - - C = st->channels; - N = frame_size; - ALLOC(in, C*N, opus_res); - - for (j=0;jchannels; + N = frame_size; + ALLOC(in, C*N, oac_res); + + for (j = 0; j < C*N; j++) + in[j] = FLOAT2RES(pcm[j]); + + ret = oaci_celt_encode_with_ec(st, in, frame_size, compressed, nbCompressedBytes, NULL); +# ifdef RESYNTH + for (j = 0; j < C*N; j++) + ((float*)pcm)[j] = RES2FLOAT(in[j]); +# endif + RESTORE_STACK; + return ret; } -# endif +# endif -#endif +# endif #endif /* CUSTOM_MODES */ -int opus_custom_encoder_ctl(CELTEncoder * OPUS_RESTRICT st, int request, ...) -{ - va_list ap; - - va_start(ap, request); - switch (request) - { - case OPUS_SET_COMPLEXITY_REQUEST: - { - int value = va_arg(ap, opus_int32); - if (value<0 || value>10) - goto bad_arg; - st->complexity = value; - } - break; - case CELT_SET_START_BAND_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value<0 || value>=st->mode->nbEBands) - goto bad_arg; - st->start = value; - } - break; - case CELT_SET_END_BAND_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value<1 || value>st->mode->nbEBands) - goto bad_arg; - st->end = value; - } - break; - case CELT_SET_PREDICTION_REQUEST: - { - int value = va_arg(ap, opus_int32); - if (value<0 || value>2) - goto bad_arg; - st->disable_pf = value<=1; - st->force_intra = value==0; - } - break; - case OPUS_SET_PACKET_LOSS_PERC_REQUEST: - { - int value = va_arg(ap, opus_int32); - if (value<0 || value>100) - goto bad_arg; - st->loss_rate = value; - } - break; - case OPUS_SET_VBR_CONSTRAINT_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - st->constrained_vbr = value; - } - break; - case OPUS_SET_VBR_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - st->vbr = value; - } - break; - case OPUS_SET_BITRATE_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value<=500 && value!=OPUS_BITRATE_MAX) - goto bad_arg; - value = IMIN(value, 750000*st->channels); - st->bitrate = value; - } - break; - case CELT_SET_CHANNELS_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value<1 || value>2) - goto bad_arg; - st->stream_channels = value; - } - break; - case OPUS_SET_LSB_DEPTH_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if (value<8 || value>24) - goto bad_arg; - st->lsb_depth=value; - } - break; - case OPUS_GET_LSB_DEPTH_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - *value=st->lsb_depth; - } - break; - case OPUS_SET_PHASE_INVERSION_DISABLED_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value<0 || value>1) - { - goto bad_arg; - } - st->disable_inv = value; - } - break; - case OPUS_GET_PHASE_INVERSION_DISABLED_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->disable_inv; - } - break; -#ifdef ENABLE_QEXT - case OPUS_SET_QEXT_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - if(value<0 || value>1) - { - goto bad_arg; - } - st->enable_qext = value; - } - break; - case OPUS_GET_QEXT_REQUEST: - { - opus_int32 *value = va_arg(ap, opus_int32*); - if (!value) - { - goto bad_arg; - } - *value = st->enable_qext; - } - break; -#endif - case OPUS_RESET_STATE: - { - int i; - celt_glog *oldBandE, *oldLogE, *oldLogE2; - oldBandE = (celt_glog*)(st->in_mem+st->channels*(st->mode->overlap+QEXT_SCALE2(COMBFILTER_MAXPERIOD, st->qext_scale))); - oldLogE = oldBandE + st->channels*st->mode->nbEBands; - oldLogE2 = oldLogE + st->channels*st->mode->nbEBands; - OPUS_CLEAR((char*)&st->ENCODER_RESET_START, - opus_custom_encoder_get_size(st->mode, st->channels)- - ((char*)&st->ENCODER_RESET_START - (char*)st)); - for (i=0;ichannels*st->mode->nbEBands;i++) - oldLogE[i]=oldLogE2[i]=-GCONST(28.f); - st->vbr_offset = 0; - st->delayedIntra = 1; - st->spread_decision = SPREAD_NORMAL; - st->tonal_average = 256; - st->hf_average = 0; - st->tapset_decision = 0; - } - break; -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) - case CELT_SET_INPUT_CLIPPING_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - st->clip = value; - } - break; -#endif - case CELT_SET_SIGNALLING_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - st->signalling = value; - } - break; - case CELT_SET_ANALYSIS_REQUEST: - { - AnalysisInfo *info = va_arg(ap, AnalysisInfo *); - if (info) - OPUS_COPY(&st->analysis, info, 1); - } - break; - case CELT_SET_SILK_INFO_REQUEST: - { - SILKInfo *info = va_arg(ap, SILKInfo *); - if (info) - OPUS_COPY(&st->silk_info, info, 1); - } - break; - case CELT_GET_MODE_REQUEST: - { - const CELTMode ** value = va_arg(ap, const CELTMode**); - if (value==0) - goto bad_arg; - *value=st->mode; - } - break; - case OPUS_GET_FINAL_RANGE_REQUEST: - { - opus_uint32 * value = va_arg(ap, opus_uint32 *); - if (value==0) - goto bad_arg; - *value=st->rng; - } - break; - case OPUS_SET_LFE_REQUEST: - { - opus_int32 value = va_arg(ap, opus_int32); - st->lfe = value; - } - break; - case OPUS_SET_ENERGY_MASK_REQUEST: - { - celt_glog *value = va_arg(ap, celt_glog*); - st->energy_mask = value; - } - break; - default: - goto bad_request; - } - va_end(ap); - return OPUS_OK; +int oac_custom_encoder_ctl(CELTEncoder * OAC_RESTRICT st, int request, ...) { + va_list ap; + + va_start(ap, request); + switch (request) { + case OAC_SET_COMPLEXITY_REQUEST: + { + int value = va_arg(ap, oac_int32); + if (value < 0 || value > 10) + goto bad_arg; + st->complexity = value; + } + break; + case CELT_SET_START_BAND_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + if (value < 0 || value >= st->mode->nbEBands) + goto bad_arg; + st->start = value; + } + break; + case CELT_SET_END_BAND_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + if (value < 1 || value > st->mode->nbEBands) + goto bad_arg; + st->end = value; + } + break; + case CELT_SET_PREDICTION_REQUEST: + { + int value = va_arg(ap, oac_int32); + if (value < 0 || value > 2) + goto bad_arg; + st->disable_pf = value <= 1; + st->force_intra = value == 0; + } + break; + case OAC_SET_PACKET_LOSS_PERC_REQUEST: + { + int value = va_arg(ap, oac_int32); + if (value < 0 || value > 100) + goto bad_arg; + st->loss_rate = value; + } + break; + case OAC_SET_VBR_CONSTRAINT_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + st->constrained_vbr = value; + } + break; + case OAC_SET_VBR_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + st->vbr = value; + } + break; + case OAC_SET_BITRATE_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + if (value <= 500 && value != OAC_BITRATE_MAX) + goto bad_arg; + value = IMIN(value, 750000*st->channels); + st->bitrate = value; + } + break; + case CELT_SET_CHANNELS_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + if (value < 1 || value > 2) + goto bad_arg; + st->stream_channels = value; + } + break; + case OAC_SET_LSB_DEPTH_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + if (value < 8 || value > 24) + goto bad_arg; + st->lsb_depth = value; + } + break; + case OAC_GET_LSB_DEPTH_REQUEST: + { + oac_int32 *value = va_arg(ap, oac_int32*); + *value = st->lsb_depth; + } + break; + case OAC_SET_PHASE_INVERSION_DISABLED_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + if (value < 0 || value > 1) { + goto bad_arg; + } + st->disable_inv = value; + } + break; + case OAC_GET_PHASE_INVERSION_DISABLED_REQUEST: + { + oac_int32 *value = va_arg(ap, oac_int32*); + if (!value) { + goto bad_arg; + } + *value = st->disable_inv; + } + break; + case OAC_RESET_STATE: + { + int i; + celt_glog *oldBandE, *oldLogE, *oldLogE2; + oldBandE = (celt_glog*)(st->in_mem + st->channels*(st->mode->overlap + QEXT_SCALE2(COMBFILTER_MAXPERIOD, + st->qext_scale))); + oldLogE = oldBandE + st->channels*st->mode->nbEBands; + oldLogE2 = oldLogE + st->channels*st->mode->nbEBands; + OAC_CLEAR((char*)&st->ENCODER_RESET_START, + oac_custom_encoder_get_size(st->mode, st->channels) + - ((char*)&st->ENCODER_RESET_START - (char*)st)); + for (i = 0; i < st->channels*st->mode->nbEBands; i++) + oldLogE[i] = oldLogE2[i] = -GCONST(28.f); + st->vbr_offset = 0; + st->delayedIntra = 1; + st->spread_decision = SPREAD_NORMAL; + st->tonal_average = 256; + st->hf_average = 0; + st->tapset_decision = 0; + } + break; +#if defined(CUSTOM_MODES) || defined(ENABLE_OAC_CUSTOM_API) + case CELT_SET_INPUT_CLIPPING_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + st->clip = value; + } + break; +#endif + case CELT_SET_SIGNALLING_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + st->signalling = value; + } + break; + case CELT_SET_ANALYSIS_REQUEST: + { + AnalysisInfo *info = va_arg(ap, AnalysisInfo *); + if (info) + OAC_COPY(&st->analysis, info, 1); + } + break; + case CELT_SET_SILK_INFO_REQUEST: + { + SILKInfo *info = va_arg(ap, SILKInfo *); + if (info) + OAC_COPY(&st->silk_info, info, 1); + } + break; + case CELT_GET_MODE_REQUEST: + { + const CELTMode ** value = va_arg(ap, const CELTMode**); + if (value == 0) + goto bad_arg; + *value = st->mode; + } + break; + case OAC_GET_FINAL_RANGE_REQUEST: + { + oac_uint32 * value = va_arg(ap, oac_uint32 *); + if (value == 0) + goto bad_arg; + *value = st->rng; + } + break; + case OAC_SET_LFE_REQUEST: + { + oac_int32 value = va_arg(ap, oac_int32); + st->lfe = value; + } + break; + case OAC_SET_ENERGY_MASK_REQUEST: + { + celt_glog *value = va_arg(ap, celt_glog*); + st->energy_mask = value; + } + break; + default: + goto bad_request; + } + va_end(ap); + return OAC_OK; bad_arg: - va_end(ap); - return OPUS_BAD_ARG; + va_end(ap); + return OAC_BAD_ARG; bad_request: - va_end(ap); - return OPUS_UNIMPLEMENTED; + va_end(ap); + return OAC_UNIMPLEMENTED; } diff --git a/celt/celt_lpc.c b/celt/celt_lpc.c index e5a1c4852..291138bcc 100644 --- a/celt/celt_lpc.c +++ b/celt/celt_lpc.c @@ -23,10 +23,10 @@ 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" +# include "config.h" #endif #include "celt_lpc.h" @@ -34,341 +34,320 @@ #include "mathops.h" #include "pitch.h" -void _celt_lpc( - opus_val16 *_lpc, /* out: [0...p-1] LPC coefficients */ -const opus_val32 *ac, /* in: [0...p] autocorrelation values */ -int p -) -{ - int i, j; - opus_val32 r; - opus_val32 error = ac[0]; +void oaci_celt_lpc( + oac_val16 *_lpc, /* out: [0...p-1] LPC coefficients */ + const oac_val32 *ac, /* in: [0...p] autocorrelation values */ + int p) { + int i, j; + oac_val32 r; + oac_val32 error = ac[0]; #ifdef FIXED_POINT - opus_val32 lpc[CELT_LPC_ORDER]; + oac_val32 lpc[CELT_LPC_ORDER]; #else - float *lpc = _lpc; + float *lpc = _lpc; #endif - OPUS_CLEAR(lpc, p); + OAC_CLEAR(lpc, p); #ifdef FIXED_POINT - if (ac[0] != 0) + if (ac[0] != 0) #else - if (ac[0] > 1e-10f) + if (ac[0] > 1e-10f) #endif - { - for (i = 0; i < p; i++) { - /* Sum up this iteration's reflection coefficient */ - opus_val32 rr = 0; -#if defined (FIXED_POINT) && OPUS_FAST_INT64 - opus_int64 acc = 0; - for (j = 0; j < i; j++) - acc += (opus_int64)(lpc[j]) * (opus_int64)(ac[i - j]); - rr = (opus_val32)SHR64(acc, 31); + { + for (i = 0; i < p; i++) { + /* Sum up this iteration's reflection coefficient */ + oac_val32 rr = 0; +#if defined (FIXED_POINT) && OAC_FAST_INT64 + oac_int64 acc = 0; + for (j = 0; j < i; j++) + acc += (oac_int64)(lpc[j])*(oac_int64)(ac[i - j]); + rr = (oac_val32)SHR64(acc, 31); #else - for (j = 0; j < i; j++) - rr += MULT32_32_Q31(lpc[j],ac[i - j]); + for (j = 0; j < i; j++) + rr += MULT32_32_Q31(lpc[j], ac[i - j]); #endif - rr += SHR32(ac[i + 1],6); - r = -frac_div32(SHL32(rr,6), error); - /* Update LPC coefficients and total error */ - lpc[i] = SHR32(r,6); - for (j = 0; j < (i+1)>>1; j++) - { - opus_val32 tmp1, tmp2; - tmp1 = lpc[j]; - tmp2 = lpc[i-1-j]; - lpc[j] = tmp1 + MULT32_32_Q31(r,tmp2); - lpc[i-1-j] = tmp2 + MULT32_32_Q31(r,tmp1); - } + rr += SHR32(ac[i + 1], 6); + r = -oaci_frac_div32(SHL32(rr, 6), error); + /* Update LPC coefficients and total error */ + lpc[i] = SHR32(r, 6); + for (j = 0; j < (i + 1)>>1; j++) { + oac_val32 tmp1, tmp2; + tmp1 = lpc[j]; + tmp2 = lpc[i - 1 - j]; + lpc[j] = tmp1 + MULT32_32_Q31(r, tmp2); + lpc[i - 1 - j] = tmp2 + MULT32_32_Q31(r, tmp1); + } - error = error - MULT32_32_Q31(MULT32_32_Q31(r,r),error); - /* Bail out once we get 30 dB gain */ + 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)) - break; + if (error <= SHR32(ac[0], 10)) + break; #else - if (error<=.001f*ac[0]) - break; + if (error <= .001f*ac[0]) + break; #endif - } - } + } + } #ifdef FIXED_POINT - { - /* 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; + { + /* Convert the int32 lpcs to int16 and ensure there are no wrap-arounds. + This reuses the logic in oaci_silk_LPC_fit() and oaci_silk_bwexpander_32(). Any bug + fixes should also be applied there. */ + int iter, idx = 0; + oac_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; + 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 */ + maxabs = PSHR32(maxabs, 13); /* Q25->Q12 */ - if (maxabs > 32767) { - maxabs = MIN32(maxabs, 163838); - chirp_Q16 = QCONST32(0.999, 16) - DIV32(SHL32(maxabs - 32767, 14), + 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; + 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); + /* 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; } - 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 */ - } - } - } + 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. */ + OAC_CLEAR(lpc, p); + _lpc[0] = 4096; /* Q12 */ + } else { + for (i = 0; i < p; i++) { + _lpc[i] = EXTRACT16(PSHR32(lpc[i], 13)); /* Q25->Q12 */ + } + } + } #endif } -void celt_fir_c( - const opus_val16 *x, - const opus_val16 *num, - opus_val16 *y, - int N, - int ord, - int arch) -{ - int i,j; - VARDECL(opus_val16, rnum); - SAVE_STACK; - celt_assert(x != y); - ALLOC(rnum, ord, opus_val16); - for(i=0;i=1;j--) - { - mem[j]=mem[j-1]; - } - mem[0] = SROUND16(sum, SIG_SHIFT); - _y[i] = sum; - } + int i, j; + (void)arch; + for (i = 0; i < N; i++) { + oac_val32 sum = _x[i]; + for (j = 0; j < ord; j++) { + sum -= MULT16_16(den[j], mem[j]); + } + for (j = ord - 1; j >= 1; j--) { + mem[j] = mem[j - 1]; + } + mem[0] = SROUND16(sum, SIG_SHIFT); + _y[i] = sum; + } #else - int i,j; - VARDECL(opus_val16, rden); - VARDECL(opus_val16, y); - SAVE_STACK; + int i, j; + VARDECL(oac_val16, rden); + VARDECL(oac_val16, y); + SAVE_STACK; - celt_assert((ord&3)==0); - ALLOC(rden, ord, opus_val16); - ALLOC(y, N+ord, opus_val16); - for(i=0;i0); - celt_assert(overlap>=0); - if (overlap == 0) - { - xptr = x; - } else { - for (i=0;i 0); + celt_assert(overlap >= 0); + if (overlap == 0) { + xptr = x; + } else { + for (i = 0; i < n; i++) + xx[i] = x[i]; + for (i = 0; i < overlap; i++) { + oac_val16 w = COEF2VAL16(window[i]); + xx[i] = MULT16_16_Q15(x[i], w); + xx[n - i - 1] = MULT16_16_Q15(x[n - i - 1], w); + } + xptr = xx; + } + shift = 0; #ifdef FIXED_POINT - { - opus_val32 ac0; - int ac0_shift = celt_ilog2(n + (n>>4)); - ac0 = 1+(n<<7); - if (n&1) ac0 += SHR32(MULT16_16(xptr[0],xptr[0]),ac0_shift); - for(i=(n&1);i>4)); + ac0 = 1 + (n<<7); + if (n&1) ac0 += SHR32(MULT16_16(xptr[0], xptr[0]), ac0_shift); + for (i = (n&1); i < n; i += 2) { + ac0 += SHR32(MULT16_16(xptr[i], xptr[i]), ac0_shift); + ac0 += SHR32(MULT16_16(xptr[i + 1], xptr[i + 1]), ac0_shift); + } + /* Consider the effect of rounding-to-nearest when scaling the signal. */ + ac0 += SHR32(ac0, 7); - shift = celt_ilog2(ac0)-30+ac0_shift+1; - shift = (shift)/2; - if (shift>0) - { - for(i=0;i 0) { + for (i = 0; i < n; i++) + xx[i] = PSHR32(xptr[i], shift); + xptr = xx; + } else + shift = 0; + } #endif - celt_pitch_xcorr(xptr, xptr, ac, fastN, lag+1, arch); - for (k=0;k<=lag;k++) - { - for (i = k+fastN, d = 0; i < n; i++) - d = MAC16_16(d, xptr[i], xptr[i-k]); - ac[k] += d; - } + oaci_celt_pitch_xcorr(xptr, xptr, ac, fastN, lag + 1, arch); + for (k = 0; k <= lag; k++) { + for (i = k + fastN, d = 0; i < n; i++) + d = MAC16_16(d, xptr[i], xptr[i - k]); + ac[k] += d; + } #ifdef FIXED_POINT - shift = 2*shift; - if (shift<=0) - ac[0] += SHL32((opus_int32)1, -shift); - if (ac[0] < 268435456) - { - int shift2 = 29 - EC_ILOG(ac[0]); - for (i=0;i<=lag;i++) - ac[i] = SHL32(ac[i], shift2); - shift -= shift2; - } else if (ac[0] >= 536870912) - { - int shift2=1; - if (ac[0] >= 1073741824) - shift2++; - for (i=0;i<=lag;i++) - ac[i] = SHR32(ac[i], shift2); - shift += shift2; - } + shift = 2*shift; + if (shift <= 0) + ac[0] += SHL32((oac_int32)1, -shift); + if (ac[0] < 268435456) { + int shift2 = 29 - EC_ILOG(ac[0]); + for (i = 0; i <= lag; i++) + ac[i] = SHL32(ac[i], shift2); + shift -= shift2; + } else if (ac[0] >= 536870912) { + int shift2 = 1; + if (ac[0] >= 1073741824) + shift2++; + for (i = 0; i <= lag; i++) + ac[i] = SHR32(ac[i], shift2); + shift += shift2; + } #endif - RESTORE_STACK; - return shift; + RESTORE_STACK; + return shift; } diff --git a/celt/celt_lpc.h b/celt/celt_lpc.h index e7109465f..4bef47f5b 100644 --- a/celt/celt_lpc.h +++ b/celt/celt_lpc.h @@ -23,7 +23,7 @@ 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. -*/ + */ #ifndef CELT_LPC_H #define CELT_LPC_H @@ -31,36 +31,36 @@ #include "arch.h" #include "cpu_support.h" -#if defined(OPUS_X86_MAY_HAVE_SSE4_1) -#include "x86/celt_lpc_sse.h" +#if defined(OAC_X86_MAY_HAVE_SSE4_1) +# include "x86/celt_lpc_sse.h" #endif #define CELT_LPC_ORDER 24 -void _celt_lpc(opus_val16 *_lpc, const opus_val32 *ac, int p); +void oaci_celt_lpc(oac_val16 *_lpc, const oac_val32 *ac, int p); -void celt_fir_c( - const opus_val16 *x, - const opus_val16 *num, - opus_val16 *y, - int N, - int ord, - int arch); +void oaci_celt_fir_c( + const oac_val16 *x, + const oac_val16 *num, + oac_val16 *y, + int N, + int ord, + int arch); #if !defined(OVERRIDE_CELT_FIR) -#define celt_fir(x, num, y, N, ord, arch) \ - (celt_fir_c(x, num, y, N, ord, arch)) +# define oaci_celt_fir(x, num, y, N, ord, arch) \ + (oaci_celt_fir_c(x, num, y, N, ord, arch)) #endif -void celt_iir(const opus_val32 *x, - const opus_val16 *den, - opus_val32 *y, - int N, - int ord, - opus_val16 *mem, - int arch); +void oaci_celt_iir(const oac_val32 *x, + const oac_val16 *den, + oac_val32 *y, + int N, + int ord, + oac_val16 *mem, + int arch); -int _celt_autocorr(const opus_val16 *x, opus_val32 *ac, - const celt_coef *window, int overlap, int lag, int n, int arch); +int oaci_celt_autocorr(const oac_val16 *x, oac_val32 *ac, + const celt_coef *window, int overlap, int lag, int n, int arch); #endif /* CELT_LPC_H */ diff --git a/celt/cpu_support.h b/celt/cpu_support.h index 9f13d8aec..edc11add9 100644 --- a/celt/cpu_support.h +++ b/celt/cpu_support.h @@ -23,17 +23,17 @@ 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. -*/ + */ #ifndef CPU_SUPPORT_H #define CPU_SUPPORT_H -#include "opus_types.h" -#include "opus_defines.h" +#include "oac_types.h" +#include "oac_defines.h" -#if defined(OPUS_HAVE_RTCD) && \ - (defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) -#include "arm/armcpu.h" +#if defined(OAC_HAVE_RTCD) && \ + (defined(OAC_ARM_ASM) || defined(OAC_ARM_MAY_HAVE_NEON_INTR)) +# include "arm/armcpu.h" /* We currently support 5 ARM variants: * arch[0] -> ARMv4 @@ -42,15 +42,15 @@ * arch[3] -> NEON * arch[4] -> NEON+DOTPROD */ -#define OPUS_ARCHMASK 7 +# define OAC_ARCHMASK 7 -#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_AVX2) && !defined(OPUS_X86_PRESUME_AVX2))) +#elif defined(OAC_HAVE_RTCD) && \ + ((defined(OAC_X86_MAY_HAVE_SSE) && !defined(OAC_X86_PRESUME_SSE)) || \ + (defined(OAC_X86_MAY_HAVE_SSE2) && !defined(OAC_X86_PRESUME_SSE2)) || \ + (defined(OAC_X86_MAY_HAVE_SSE4_1) && !defined(OAC_X86_PRESUME_SSE4_1)) || \ + (defined(OAC_X86_MAY_HAVE_AVX2) && !defined(OAC_X86_PRESUME_AVX2))) -#include "x86/x86cpu.h" +# include "x86/x86cpu.h" /* We currently support 5 x86 variants: * arch[0] -> non-sse * arch[1] -> sse @@ -58,15 +58,14 @@ * arch[3] -> sse4.1 * arch[4] -> avx */ -#define OPUS_ARCHMASK 7 -int opus_select_arch(void); +# define OAC_ARCHMASK 7 +int oac_select_arch(void); #else -#define OPUS_ARCHMASK 0 +# define OAC_ARCHMASK 0 -static OPUS_INLINE int opus_select_arch(void) -{ - return 0; +static OAC_INLINE int oac_select_arch(void) { + return 0; } #endif #endif diff --git a/celt/cwrs.c b/celt/cwrs.c index 8a280ce36..545ecdf9f 100644 --- a/celt/cwrs.c +++ b/celt/cwrs.c @@ -25,10 +25,10 @@ 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" +# include "config.h" #endif #include "os_support.h" @@ -36,62 +36,60 @@ #include "mathops.h" #include "arch.h" -#if defined(CUSTOM_MODES) || defined(ENABLE_QEXT) -#define CWRS_EXTRA_ROWS +#if defined(CUSTOM_MODES) +# define CWRS_EXTRA_ROWS #endif #if defined(CUSTOM_MODES) /*Guaranteed to return a conservatively large estimate of the binary logarithm with frac bits of fractional precision. - Tested for all possible 32-bit inputs with frac=4, where the maximum + Tested for all possible 32-bit inputs with frac=4, where the maximum overestimation is 0.06254243 bits.*/ -int log2_frac(opus_uint32 val, int frac) -{ - int l; - l=EC_ILOG(val); - if(val&(val-1)){ - /*This is (val>>l-16), but guaranteed to round up, even if adding a bias - before the shift would cause overflow (e.g., for 0xFFFFxxxx). - Doesn't work for val=0, but that case fails the test above.*/ - if(l>16)val=((val-1)>>(l-16))+1; - else val<<=16-l; - l=(l-1)<>16); - l+=b<>b; - val=(val*val+0x7FFF)>>15; +int oaci_log2_frac(oac_uint32 val, int frac) { + int l; + l = EC_ILOG(val); + if (val&(val - 1)) { + /*This is (val>>l-16), but guaranteed to round up, even if adding a bias + before the shift would cause overflow (e.g., for 0xFFFFxxxx). + Doesn't work for val=0, but that case fails the test above.*/ + if (l > 16) val = ((val - 1)>>(l - 16)) + 1; + else val <<= 16 - l; + l = (l - 1)<>16); + l += b<>b; + val = (val*val + 0x7FFF)>>15; + } while (frac-- > 0); + /*If val is not exactly 0x8000, then we have to round up the remainder.*/ + return l + (val > 0x8000); } - while(frac-->0); - /*If val is not exactly 0x8000, then we have to round up the remainder.*/ - return l+(val>0x8000); - } - /*Exact powers of two require no rounding.*/ - else return (l-1)<0 ? sum(k=1...K,2**k*choose(N,k)*choose(K-1,k-1)) : 1, where choose() is the binomial function. - A table of values for N<10 and K<10 looks like: - V[10][10] = { + A table of values for N<10 and K<10 looks like: + V[10][10] = { {1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 2, 2, 2, 2, 2, 2, 2, 2, 2}, {1, 4, 8, 12, 16, 20, 24, 28, 32, 36}, @@ -102,22 +100,22 @@ int log2_frac(opus_uint32 val, int frac) {1, 14, 98, 462, 1666, 4942, 12642, 28814, 59906, 115598}, {1, 16, 128, 688, 2816, 9424, 27008, 68464, 157184, 332688}, {1, 18, 162, 978, 4482, 16722, 53154, 148626, 374274, 864146} - }; + }; - U(N,K) = the number of such combinations wherein N-1 objects are taken at + U(N,K) = the number of such combinations wherein N-1 objects are taken at most K-1 at a time. - This is given by + This is given by U(N,K) = sum(k=0...K-1,V(N-1,k)) = K>0 ? (V(N-1,K-1) + V(N,K-1))/2 : 0. - The latter expression also makes clear that U(N,K) is half the number of such + The latter expression also makes clear that U(N,K) is half the number of such combinations wherein the first object is taken at least once. - Although it may not be clear from either of these definitions, U(N,K) is the + Although it may not be clear from either of these definitions, U(N,K) is the natural function to work with when enumerating the pulse vector codebooks, not V(N,K). - U(N,K) is not well-defined for N=0, but with the extension + U(N,K) is not well-defined for N=0, but with the extension U(0,K) = K>0 ? 0 : 1, the function becomes symmetric: U(N,K) = U(K,N), with a similar table: - U[10][10] = { + U[10][10] = { {1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 1, 3, 5, 7, 9, 11, 13, 15, 17}, @@ -128,46 +126,46 @@ int log2_frac(opus_uint32 val, int frac) {0, 1, 13, 85, 377, 1289, 3653, 8989, 19825, 40081}, {0, 1, 15, 113, 575, 2241, 7183, 19825, 48639, 108545}, {0, 1, 17, 145, 833, 3649, 13073, 40081, 108545, 265729} - }; + }; - With this extension, V(N,K) may be written in terms of U(N,K): + With this extension, V(N,K) may be written in terms of U(N,K): V(N,K) = U(N,K) + U(N,K+1) for all N>=0, K>=0. - Thus U(N,K+1) represents the number of combinations where the first element + Thus U(N,K+1) represents the number of combinations where the first element is positive or zero, and U(N,K) represents the number of combinations where it is negative. - With a large enough table of U(N,K) values, we could write O(N) encoding + With a large enough table of U(N,K) values, we could write O(N) encoding and O(min(N*log(K),N+K)) decoding routines, but such a table would be prohibitively large for small embedded devices (K may be as large as 32767 for small N, and N may be as large as 200). - Both functions obey the same recurrence relation: + Both functions obey the same recurrence relation: V(N,K) = V(N-1,K) + V(N,K-1) + V(N-1,K-1), U(N,K) = U(N-1,K) + U(N,K-1) + U(N-1,K-1), for all N>0, K>0, with different initial conditions at N=0 or K=0. - This allows us to construct a row of one of the tables above given the + This allows us to construct a row of one of the tables above given the previous row or the next row. - Thus we can derive O(NK) encoding and decoding routines with O(K) memory + Thus we can derive O(NK) encoding and decoding routines with O(K) memory using only addition and subtraction. - When encoding, we build up from the U(2,K) row and work our way forwards. - When decoding, we need to start at the U(N,K) row and work our way backwards, + When encoding, we build up from the U(2,K) row and work our way forwards. + When decoding, we need to start at the U(N,K) row and work our way backwards, which requires a means of computing U(N,K). - U(N,K) may be computed from two previous values with the same N: + U(N,K) may be computed from two previous values with the same N: U(N,K) = ((2*N-1)*U(N,K-1) - U(N,K-2))/(K-1) + U(N,K-2) for all N>1, and since U(N,K) is symmetric, a similar relation holds for two previous values with the same K: U(N,K>1) = ((2*K-1)*U(N-1,K) - U(N-2,K))/(N-1) + U(N-2,K) for all K>1. - This allows us to construct an arbitrary row of the U(N,K) table by starting + This allows us to construct an arbitrary row of the U(N,K) table by starting with the first two values, which are constants. - This saves roughly 2/3 the work in our O(NK) decoding routine, but costs O(K) + This saves roughly 2/3 the work in our O(NK) decoding routine, but costs O(K) multiplications. - Similar relations can be derived for V(N,K), but are not used here. + Similar relations can be derived for V(N,K), but are not used here. - For N>0 and K>0, U(N,K) and V(N,K) take on the form of an (N-1)-degree + For N>0 and K>0, U(N,K) and V(N,K) take on the form of an (N-1)-degree polynomial for fixed N. - The first few are + The first few are U(1,K) = 1, U(2,K) = 2*K-1, U(3,K) = (2*K-2)*K+1, @@ -180,10 +178,10 @@ int log2_frac(opus_uint32 val, int frac) V(4,K) = 8*(K*K+2)*K/3, V(5,K) = ((4*K*K+20)*K*K+6)/3, for all K>0. - This allows us to derive O(N) encoding and O(N*log(K)) decoding routines for + This allows us to derive O(N) encoding and O(N*log(K)) decoding routines for small N (and indeed decoding is also O(N) for N<3). - @ARTICLE{Fis86, + @ARTICLE{Fis86, author="Thomas R. Fischer", title="A Pyramid Vector Quantizer", journal="IEEE Transactions on Information Theory", @@ -192,528 +190,522 @@ int log2_frac(opus_uint32 val, int frac) pages="568--583", month=Jul, year=1986 - }*/ + }*/ #if !defined(SMALL_FOOTPRINT) /*U(N,K) = U(K,N) := N>0?K>0?U(N-1,K)+U(N,K-1)+U(N-1,K-1):0:K>0?1:0*/ -# define CELT_PVQ_U(_n,_k) (CELT_PVQ_U_ROW[IMIN(_n,_k)][IMAX(_n,_k)]) +# define CELT_PVQ_U(_n, _k) (CELT_PVQ_U_ROW[IMIN(_n, _k)][IMAX(_n, _k)]) /*V(N,K) := U(N,K)+U(N,K+1) = the number of PVQ codewords for a band of size N with K pulses allocated to it.*/ -# define CELT_PVQ_V(_n,_k) (CELT_PVQ_U(_n,_k)+CELT_PVQ_U(_n,(_k)+1)) +# define CELT_PVQ_V(_n, _k) (CELT_PVQ_U(_n, _k) + CELT_PVQ_U(_n, (_k) + 1)) /*For each V(N,K) supported, we will access element U(min(N,K+1),max(N,K+1)). - Thus, the number of entries in row I is the larger of the maximum number of + Thus, the number of entries in row I is the larger of the maximum number of pulses we will ever allocate for a given N=I (K=128, or however many fit in 32 bits, whichever is smaller), plus one, and the maximum N for which K=I-1 pulses fit in 32 bits. - The largest band size in an Opus Custom mode is 208. - Otherwise, we can limit things to the set of N which can be achieved by - splitting a band from a standard Opus mode: 176, 144, 96, 88, 72, 64, 48, + The largest band size in an Oac Custom mode is 208. + Otherwise, we can limit things to the set of N which can be achieved by + splitting a band from a standard Oac mode: 176, 144, 96, 88, 72, 64, 48, 44, 36, 32, 24, 22, 18, 16, 8, 4, 2).*/ -#if defined(CWRS_EXTRA_ROWS) -static const opus_uint32 CELT_PVQ_U_DATA[1488]={ -#else -static const opus_uint32 CELT_PVQ_U_DATA[1272]={ -#endif - /*N=0, K=0...176:*/ - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -#if defined(CWRS_EXTRA_ROWS) - /*...208:*/ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, -#endif - /*N=1, K=1...176:*/ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -#if defined(CWRS_EXTRA_ROWS) - /*...208:*/ - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, -#endif - /*N=2, K=2...176:*/ - 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, - 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, - 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, - 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, - 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, - 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, - 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, - 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, 261, 263, - 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, 289, 291, 293, - 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, - 325, 327, 329, 331, 333, 335, 337, 339, 341, 343, 345, 347, 349, 351, -#if defined(CWRS_EXTRA_ROWS) - /*...208:*/ - 353, 355, 357, 359, 361, 363, 365, 367, 369, 371, 373, 375, 377, 379, 381, - 383, 385, 387, 389, 391, 393, 395, 397, 399, 401, 403, 405, 407, 409, 411, - 413, 415, -#endif - /*N=3, K=3...176:*/ - 13, 25, 41, 61, 85, 113, 145, 181, 221, 265, 313, 365, 421, 481, 545, 613, - 685, 761, 841, 925, 1013, 1105, 1201, 1301, 1405, 1513, 1625, 1741, 1861, - 1985, 2113, 2245, 2381, 2521, 2665, 2813, 2965, 3121, 3281, 3445, 3613, 3785, - 3961, 4141, 4325, 4513, 4705, 4901, 5101, 5305, 5513, 5725, 5941, 6161, 6385, - 6613, 6845, 7081, 7321, 7565, 7813, 8065, 8321, 8581, 8845, 9113, 9385, 9661, - 9941, 10225, 10513, 10805, 11101, 11401, 11705, 12013, 12325, 12641, 12961, - 13285, 13613, 13945, 14281, 14621, 14965, 15313, 15665, 16021, 16381, 16745, - 17113, 17485, 17861, 18241, 18625, 19013, 19405, 19801, 20201, 20605, 21013, - 21425, 21841, 22261, 22685, 23113, 23545, 23981, 24421, 24865, 25313, 25765, - 26221, 26681, 27145, 27613, 28085, 28561, 29041, 29525, 30013, 30505, 31001, - 31501, 32005, 32513, 33025, 33541, 34061, 34585, 35113, 35645, 36181, 36721, - 37265, 37813, 38365, 38921, 39481, 40045, 40613, 41185, 41761, 42341, 42925, - 43513, 44105, 44701, 45301, 45905, 46513, 47125, 47741, 48361, 48985, 49613, - 50245, 50881, 51521, 52165, 52813, 53465, 54121, 54781, 55445, 56113, 56785, - 57461, 58141, 58825, 59513, 60205, 60901, 61601, -#if defined(CWRS_EXTRA_ROWS) - /*...208:*/ - 62305, 63013, 63725, 64441, 65161, 65885, 66613, 67345, 68081, 68821, 69565, - 70313, 71065, 71821, 72581, 73345, 74113, 74885, 75661, 76441, 77225, 78013, - 78805, 79601, 80401, 81205, 82013, 82825, 83641, 84461, 85285, 86113, -#endif - /*N=4, K=4...176:*/ - 63, 129, 231, 377, 575, 833, 1159, 1561, 2047, 2625, 3303, 4089, 4991, 6017, - 7175, 8473, 9919, 11521, 13287, 15225, 17343, 19649, 22151, 24857, 27775, - 30913, 34279, 37881, 41727, 45825, 50183, 54809, 59711, 64897, 70375, 76153, - 82239, 88641, 95367, 102425, 109823, 117569, 125671, 134137, 142975, 152193, - 161799, 171801, 182207, 193025, 204263, 215929, 228031, 240577, 253575, - 267033, 280959, 295361, 310247, 325625, 341503, 357889, 374791, 392217, - 410175, 428673, 447719, 467321, 487487, 508225, 529543, 551449, 573951, - 597057, 620775, 645113, 670079, 695681, 721927, 748825, 776383, 804609, - 833511, 863097, 893375, 924353, 956039, 988441, 1021567, 1055425, 1090023, - 1125369, 1161471, 1198337, 1235975, 1274393, 1313599, 1353601, 1394407, - 1436025, 1478463, 1521729, 1565831, 1610777, 1656575, 1703233, 1750759, - 1799161, 1848447, 1898625, 1949703, 2001689, 2054591, 2108417, 2163175, - 2218873, 2275519, 2333121, 2391687, 2451225, 2511743, 2573249, 2635751, - 2699257, 2763775, 2829313, 2895879, 2963481, 3032127, 3101825, 3172583, - 3244409, 3317311, 3391297, 3466375, 3542553, 3619839, 3698241, 3777767, - 3858425, 3940223, 4023169, 4107271, 4192537, 4278975, 4366593, 4455399, - 4545401, 4636607, 4729025, 4822663, 4917529, 5013631, 5110977, 5209575, - 5309433, 5410559, 5512961, 5616647, 5721625, 5827903, 5935489, 6044391, - 6154617, 6266175, 6379073, 6493319, 6608921, 6725887, 6844225, 6963943, - 7085049, 7207551, -#if defined(CWRS_EXTRA_ROWS) - /*...208:*/ - 7331457, 7456775, 7583513, 7711679, 7841281, 7972327, 8104825, 8238783, - 8374209, 8511111, 8649497, 8789375, 8930753, 9073639, 9218041, 9363967, - 9511425, 9660423, 9810969, 9963071, 10116737, 10271975, 10428793, 10587199, - 10747201, 10908807, 11072025, 11236863, 11403329, 11571431, 11741177, - 11912575, -#endif - /*N=5, K=5...176:*/ - 321, 681, 1289, 2241, 3649, 5641, 8361, 11969, 16641, 22569, 29961, 39041, - 50049, 63241, 78889, 97281, 118721, 143529, 172041, 204609, 241601, 283401, - 330409, 383041, 441729, 506921, 579081, 658689, 746241, 842249, 947241, - 1061761, 1186369, 1321641, 1468169, 1626561, 1797441, 1981449, 2179241, - 2391489, 2618881, 2862121, 3121929, 3399041, 3694209, 4008201, 4341801, - 4695809, 5071041, 5468329, 5888521, 6332481, 6801089, 7295241, 7815849, - 8363841, 8940161, 9545769, 10181641, 10848769, 11548161, 12280841, 13047849, - 13850241, 14689089, 15565481, 16480521, 17435329, 18431041, 19468809, - 20549801, 21675201, 22846209, 24064041, 25329929, 26645121, 28010881, - 29428489, 30899241, 32424449, 34005441, 35643561, 37340169, 39096641, - 40914369, 42794761, 44739241, 46749249, 48826241, 50971689, 53187081, - 55473921, 57833729, 60268041, 62778409, 65366401, 68033601, 70781609, - 73612041, 76526529, 79526721, 82614281, 85790889, 89058241, 92418049, - 95872041, 99421961, 103069569, 106816641, 110664969, 114616361, 118672641, - 122835649, 127107241, 131489289, 135983681, 140592321, 145317129, 150160041, - 155123009, 160208001, 165417001, 170752009, 176215041, 181808129, 187533321, - 193392681, 199388289, 205522241, 211796649, 218213641, 224775361, 231483969, - 238341641, 245350569, 252512961, 259831041, 267307049, 274943241, 282741889, - 290705281, 298835721, 307135529, 315607041, 324252609, 333074601, 342075401, - 351257409, 360623041, 370174729, 379914921, 389846081, 399970689, 410291241, - 420810249, 431530241, 442453761, 453583369, 464921641, 476471169, 488234561, - 500214441, 512413449, 524834241, 537479489, 550351881, 563454121, 576788929, - 590359041, 604167209, 618216201, 632508801, -#if defined(CWRS_EXTRA_ROWS) - /*...208:*/ - 647047809, 661836041, 676876329, 692171521, 707724481, 723538089, 739615241, - 755958849, 772571841, 789457161, 806617769, 824056641, 841776769, 859781161, - 878072841, 896654849, 915530241, 934702089, 954173481, 973947521, 994027329, - 1014416041, 1035116809, 1056132801, 1077467201, 1099123209, 1121104041, - 1143412929, 1166053121, 1189027881, 1212340489, 1235994241, -#endif - /*N=6, K=6...96:*/ - 1683, 3653, 7183, 13073, 22363, 36365, 56695, 85305, 124515, 177045, 246047, - 335137, 448427, 590557, 766727, 982729, 1244979, 1560549, 1937199, 2383409, - 2908411, 3522221, 4235671, 5060441, 6009091, 7095093, 8332863, 9737793, - 11326283, 13115773, 15124775, 17372905, 19880915, 22670725, 25765455, - 29189457, 32968347, 37129037, 41699767, 46710137, 52191139, 58175189, - 64696159, 71789409, 79491819, 87841821, 96879431, 106646281, 117185651, - 128542501, 140763503, 153897073, 167993403, 183104493, 199284183, 216588185, - 235074115, 254801525, 275831935, 298228865, 322057867, 347386557, 374284647, - 402823977, 433078547, 465124549, 499040399, 534906769, 572806619, 612825229, - 655050231, 699571641, 746481891, 795875861, 847850911, 902506913, 959946283, - 1020274013, 1083597703, 1150027593, 1219676595, 1292660325, 1369097135, - 1449108145, 1532817275, 1620351277, 1711839767, 1807415257, 1907213187, - 2011371957, 2120032959, -#if defined(CWRS_EXTRA_ROWS) - /*...109:*/ - 2233340609U, 2351442379U, 2474488829U, 2602633639U, 2736033641U, 2874848851U, - 3019242501U, 3169381071U, 3325434321U, 3487575323U, 3655980493U, 3830829623U, - 4012305913U, -#endif - /*N=7, K=7...54*/ - 8989, 19825, 40081, 75517, 134245, 227305, 369305, 579125, 880685, 1303777, - 1884961, 2668525, 3707509, 5064793, 6814249, 9041957, 11847485, 15345233, - 19665841, 24957661, 31388293, 39146185, 48442297, 59511829, 72616013, - 88043969, 106114625, 127178701, 151620757, 179861305, 212358985, 249612805, - 292164445, 340600625, 395555537, 457713341, 527810725, 606639529, 695049433, - 793950709, 904317037, 1027188385, 1163673953, 1314955181, 1482288821, - 1667010073, 1870535785, 2094367717, -#if defined(CWRS_EXTRA_ROWS) - /*...60:*/ - 2340095869U, 2609401873U, 2904062449U, 3225952925U, 3577050821U, 3959439497U, -#endif - /*N=8, K=8...37*/ - 48639, 108545, 224143, 433905, 795455, 1392065, 2340495, 3800305, 5984767, - 9173505, 13726991, 20103025, 28875327, 40754369, 56610575, 77500017, - 104692735, 139703809, 184327311, 240673265, 311207743, 398796225, 506750351, - 638878193, 799538175, 993696769, 1226990095, 1505789553, 1837271615, - 2229491905U, -#if defined(CWRS_EXTRA_ROWS) - /*...40:*/ - 2691463695U, 3233240945U, 3866006015U, -#endif - /*N=9, K=9...28:*/ - 265729, 598417, 1256465, 2485825, 4673345, 8405905, 14546705, 24331777, - 39490049, 62390545, 96220561, 145198913, 214828609, 312193553, 446304145, - 628496897, 872893441, 1196924561, 1621925137, 2173806145U, -#if defined(CWRS_EXTRA_ROWS) - /*...29:*/ - 2883810113U, -#endif - /*N=10, K=10...24:*/ - 1462563, 3317445, 7059735, 14218905, 27298155, 50250765, 89129247, 152951073, - 254831667, 413442773, 654862247, 1014889769, 1541911931, 2300409629U, - 3375210671U, - /*N=11, K=11...19:*/ - 8097453, 18474633, 39753273, 81270333, 158819253, 298199265, 540279585, - 948062325, 1616336765, -#if defined(CWRS_EXTRA_ROWS) - /*...20:*/ - 2684641785U, -#endif - /*N=12, K=12...18:*/ - 45046719, 103274625, 224298231, 464387817, 921406335, 1759885185, - 3248227095U, - /*N=13, K=13...16:*/ - 251595969, 579168825, 1267854873, 2653649025U, - /*N=14, K=14:*/ - 1409933619 +# if defined(CWRS_EXTRA_ROWS) +static const oac_uint32 CELT_PVQ_U_DATA[1488] = { +# else +static const oac_uint32 CELT_PVQ_U_DATA[1272] = { +# endif + /*N=0, K=0...176:*/ + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +# if defined(CWRS_EXTRA_ROWS) + /*...208:*/ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, +# endif + /*N=1, K=1...176:*/ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +# if defined(CWRS_EXTRA_ROWS) + /*...208:*/ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, +# endif + /*N=2, K=2...176:*/ + 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, + 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, + 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, + 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, + 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, + 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, + 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, + 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, 261, 263, + 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, 289, 291, 293, + 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, + 325, 327, 329, 331, 333, 335, 337, 339, 341, 343, 345, 347, 349, 351, +# if defined(CWRS_EXTRA_ROWS) + /*...208:*/ + 353, 355, 357, 359, 361, 363, 365, 367, 369, 371, 373, 375, 377, 379, 381, + 383, 385, 387, 389, 391, 393, 395, 397, 399, 401, 403, 405, 407, 409, 411, + 413, 415, +# endif + /*N=3, K=3...176:*/ + 13, 25, 41, 61, 85, 113, 145, 181, 221, 265, 313, 365, 421, 481, 545, 613, + 685, 761, 841, 925, 1013, 1105, 1201, 1301, 1405, 1513, 1625, 1741, 1861, + 1985, 2113, 2245, 2381, 2521, 2665, 2813, 2965, 3121, 3281, 3445, 3613, 3785, + 3961, 4141, 4325, 4513, 4705, 4901, 5101, 5305, 5513, 5725, 5941, 6161, 6385, + 6613, 6845, 7081, 7321, 7565, 7813, 8065, 8321, 8581, 8845, 9113, 9385, 9661, + 9941, 10225, 10513, 10805, 11101, 11401, 11705, 12013, 12325, 12641, 12961, + 13285, 13613, 13945, 14281, 14621, 14965, 15313, 15665, 16021, 16381, 16745, + 17113, 17485, 17861, 18241, 18625, 19013, 19405, 19801, 20201, 20605, 21013, + 21425, 21841, 22261, 22685, 23113, 23545, 23981, 24421, 24865, 25313, 25765, + 26221, 26681, 27145, 27613, 28085, 28561, 29041, 29525, 30013, 30505, 31001, + 31501, 32005, 32513, 33025, 33541, 34061, 34585, 35113, 35645, 36181, 36721, + 37265, 37813, 38365, 38921, 39481, 40045, 40613, 41185, 41761, 42341, 42925, + 43513, 44105, 44701, 45301, 45905, 46513, 47125, 47741, 48361, 48985, 49613, + 50245, 50881, 51521, 52165, 52813, 53465, 54121, 54781, 55445, 56113, 56785, + 57461, 58141, 58825, 59513, 60205, 60901, 61601, +# if defined(CWRS_EXTRA_ROWS) + /*...208:*/ + 62305, 63013, 63725, 64441, 65161, 65885, 66613, 67345, 68081, 68821, 69565, + 70313, 71065, 71821, 72581, 73345, 74113, 74885, 75661, 76441, 77225, 78013, + 78805, 79601, 80401, 81205, 82013, 82825, 83641, 84461, 85285, 86113, +# endif + /*N=4, K=4...176:*/ + 63, 129, 231, 377, 575, 833, 1159, 1561, 2047, 2625, 3303, 4089, 4991, 6017, + 7175, 8473, 9919, 11521, 13287, 15225, 17343, 19649, 22151, 24857, 27775, + 30913, 34279, 37881, 41727, 45825, 50183, 54809, 59711, 64897, 70375, 76153, + 82239, 88641, 95367, 102425, 109823, 117569, 125671, 134137, 142975, 152193, + 161799, 171801, 182207, 193025, 204263, 215929, 228031, 240577, 253575, + 267033, 280959, 295361, 310247, 325625, 341503, 357889, 374791, 392217, + 410175, 428673, 447719, 467321, 487487, 508225, 529543, 551449, 573951, + 597057, 620775, 645113, 670079, 695681, 721927, 748825, 776383, 804609, + 833511, 863097, 893375, 924353, 956039, 988441, 1021567, 1055425, 1090023, + 1125369, 1161471, 1198337, 1235975, 1274393, 1313599, 1353601, 1394407, + 1436025, 1478463, 1521729, 1565831, 1610777, 1656575, 1703233, 1750759, + 1799161, 1848447, 1898625, 1949703, 2001689, 2054591, 2108417, 2163175, + 2218873, 2275519, 2333121, 2391687, 2451225, 2511743, 2573249, 2635751, + 2699257, 2763775, 2829313, 2895879, 2963481, 3032127, 3101825, 3172583, + 3244409, 3317311, 3391297, 3466375, 3542553, 3619839, 3698241, 3777767, + 3858425, 3940223, 4023169, 4107271, 4192537, 4278975, 4366593, 4455399, + 4545401, 4636607, 4729025, 4822663, 4917529, 5013631, 5110977, 5209575, + 5309433, 5410559, 5512961, 5616647, 5721625, 5827903, 5935489, 6044391, + 6154617, 6266175, 6379073, 6493319, 6608921, 6725887, 6844225, 6963943, + 7085049, 7207551, +# if defined(CWRS_EXTRA_ROWS) + /*...208:*/ + 7331457, 7456775, 7583513, 7711679, 7841281, 7972327, 8104825, 8238783, + 8374209, 8511111, 8649497, 8789375, 8930753, 9073639, 9218041, 9363967, + 9511425, 9660423, 9810969, 9963071, 10116737, 10271975, 10428793, 10587199, + 10747201, 10908807, 11072025, 11236863, 11403329, 11571431, 11741177, + 11912575, +# endif + /*N=5, K=5...176:*/ + 321, 681, 1289, 2241, 3649, 5641, 8361, 11969, 16641, 22569, 29961, 39041, + 50049, 63241, 78889, 97281, 118721, 143529, 172041, 204609, 241601, 283401, + 330409, 383041, 441729, 506921, 579081, 658689, 746241, 842249, 947241, + 1061761, 1186369, 1321641, 1468169, 1626561, 1797441, 1981449, 2179241, + 2391489, 2618881, 2862121, 3121929, 3399041, 3694209, 4008201, 4341801, + 4695809, 5071041, 5468329, 5888521, 6332481, 6801089, 7295241, 7815849, + 8363841, 8940161, 9545769, 10181641, 10848769, 11548161, 12280841, 13047849, + 13850241, 14689089, 15565481, 16480521, 17435329, 18431041, 19468809, + 20549801, 21675201, 22846209, 24064041, 25329929, 26645121, 28010881, + 29428489, 30899241, 32424449, 34005441, 35643561, 37340169, 39096641, + 40914369, 42794761, 44739241, 46749249, 48826241, 50971689, 53187081, + 55473921, 57833729, 60268041, 62778409, 65366401, 68033601, 70781609, + 73612041, 76526529, 79526721, 82614281, 85790889, 89058241, 92418049, + 95872041, 99421961, 103069569, 106816641, 110664969, 114616361, 118672641, + 122835649, 127107241, 131489289, 135983681, 140592321, 145317129, 150160041, + 155123009, 160208001, 165417001, 170752009, 176215041, 181808129, 187533321, + 193392681, 199388289, 205522241, 211796649, 218213641, 224775361, 231483969, + 238341641, 245350569, 252512961, 259831041, 267307049, 274943241, 282741889, + 290705281, 298835721, 307135529, 315607041, 324252609, 333074601, 342075401, + 351257409, 360623041, 370174729, 379914921, 389846081, 399970689, 410291241, + 420810249, 431530241, 442453761, 453583369, 464921641, 476471169, 488234561, + 500214441, 512413449, 524834241, 537479489, 550351881, 563454121, 576788929, + 590359041, 604167209, 618216201, 632508801, +# if defined(CWRS_EXTRA_ROWS) + /*...208:*/ + 647047809, 661836041, 676876329, 692171521, 707724481, 723538089, 739615241, + 755958849, 772571841, 789457161, 806617769, 824056641, 841776769, 859781161, + 878072841, 896654849, 915530241, 934702089, 954173481, 973947521, 994027329, + 1014416041, 1035116809, 1056132801, 1077467201, 1099123209, 1121104041, + 1143412929, 1166053121, 1189027881, 1212340489, 1235994241, +# endif + /*N=6, K=6...96:*/ + 1683, 3653, 7183, 13073, 22363, 36365, 56695, 85305, 124515, 177045, 246047, + 335137, 448427, 590557, 766727, 982729, 1244979, 1560549, 1937199, 2383409, + 2908411, 3522221, 4235671, 5060441, 6009091, 7095093, 8332863, 9737793, + 11326283, 13115773, 15124775, 17372905, 19880915, 22670725, 25765455, + 29189457, 32968347, 37129037, 41699767, 46710137, 52191139, 58175189, + 64696159, 71789409, 79491819, 87841821, 96879431, 106646281, 117185651, + 128542501, 140763503, 153897073, 167993403, 183104493, 199284183, 216588185, + 235074115, 254801525, 275831935, 298228865, 322057867, 347386557, 374284647, + 402823977, 433078547, 465124549, 499040399, 534906769, 572806619, 612825229, + 655050231, 699571641, 746481891, 795875861, 847850911, 902506913, 959946283, + 1020274013, 1083597703, 1150027593, 1219676595, 1292660325, 1369097135, + 1449108145, 1532817275, 1620351277, 1711839767, 1807415257, 1907213187, + 2011371957, 2120032959, +# if defined(CWRS_EXTRA_ROWS) + /*...109:*/ + 2233340609U, 2351442379U, 2474488829U, 2602633639U, 2736033641U, 2874848851U, + 3019242501U, 3169381071U, 3325434321U, 3487575323U, 3655980493U, 3830829623U, + 4012305913U, +# endif + /*N=7, K=7...54*/ + 8989, 19825, 40081, 75517, 134245, 227305, 369305, 579125, 880685, 1303777, + 1884961, 2668525, 3707509, 5064793, 6814249, 9041957, 11847485, 15345233, + 19665841, 24957661, 31388293, 39146185, 48442297, 59511829, 72616013, + 88043969, 106114625, 127178701, 151620757, 179861305, 212358985, 249612805, + 292164445, 340600625, 395555537, 457713341, 527810725, 606639529, 695049433, + 793950709, 904317037, 1027188385, 1163673953, 1314955181, 1482288821, + 1667010073, 1870535785, 2094367717, +# if defined(CWRS_EXTRA_ROWS) + /*...60:*/ + 2340095869U, 2609401873U, 2904062449U, 3225952925U, 3577050821U, 3959439497U, +# endif + /*N=8, K=8...37*/ + 48639, 108545, 224143, 433905, 795455, 1392065, 2340495, 3800305, 5984767, + 9173505, 13726991, 20103025, 28875327, 40754369, 56610575, 77500017, + 104692735, 139703809, 184327311, 240673265, 311207743, 398796225, 506750351, + 638878193, 799538175, 993696769, 1226990095, 1505789553, 1837271615, + 2229491905U, +# if defined(CWRS_EXTRA_ROWS) + /*...40:*/ + 2691463695U, 3233240945U, 3866006015U, +# endif + /*N=9, K=9...28:*/ + 265729, 598417, 1256465, 2485825, 4673345, 8405905, 14546705, 24331777, + 39490049, 62390545, 96220561, 145198913, 214828609, 312193553, 446304145, + 628496897, 872893441, 1196924561, 1621925137, 2173806145U, +# if defined(CWRS_EXTRA_ROWS) + /*...29:*/ + 2883810113U, +# endif + /*N=10, K=10...24:*/ + 1462563, 3317445, 7059735, 14218905, 27298155, 50250765, 89129247, 152951073, + 254831667, 413442773, 654862247, 1014889769, 1541911931, 2300409629U, + 3375210671U, + /*N=11, K=11...19:*/ + 8097453, 18474633, 39753273, 81270333, 158819253, 298199265, 540279585, + 948062325, 1616336765, +# if defined(CWRS_EXTRA_ROWS) + /*...20:*/ + 2684641785U, +# endif + /*N=12, K=12...18:*/ + 45046719, 103274625, 224298231, 464387817, 921406335, 1759885185, + 3248227095U, + /*N=13, K=13...16:*/ + 251595969, 579168825, 1267854873, 2653649025U, + /*N=14, K=14:*/ + 1409933619 }; -#if defined(CWRS_EXTRA_ROWS) -static const opus_uint32 *const CELT_PVQ_U_ROW[15]={ - CELT_PVQ_U_DATA+ 0,CELT_PVQ_U_DATA+ 208,CELT_PVQ_U_DATA+ 415, - CELT_PVQ_U_DATA+ 621,CELT_PVQ_U_DATA+ 826,CELT_PVQ_U_DATA+1030, - CELT_PVQ_U_DATA+1233,CELT_PVQ_U_DATA+1336,CELT_PVQ_U_DATA+1389, - CELT_PVQ_U_DATA+1421,CELT_PVQ_U_DATA+1441,CELT_PVQ_U_DATA+1455, - CELT_PVQ_U_DATA+1464,CELT_PVQ_U_DATA+1470,CELT_PVQ_U_DATA+1473 +# if defined(CWRS_EXTRA_ROWS) +static const oac_uint32 *const CELT_PVQ_U_ROW[15] = { + CELT_PVQ_U_DATA + 0, CELT_PVQ_U_DATA + 208, CELT_PVQ_U_DATA + 415, + CELT_PVQ_U_DATA + 621, CELT_PVQ_U_DATA + 826, CELT_PVQ_U_DATA + 1030, + CELT_PVQ_U_DATA + 1233, CELT_PVQ_U_DATA + 1336, CELT_PVQ_U_DATA + 1389, + CELT_PVQ_U_DATA + 1421, CELT_PVQ_U_DATA + 1441, CELT_PVQ_U_DATA + 1455, + CELT_PVQ_U_DATA + 1464, CELT_PVQ_U_DATA + 1470, CELT_PVQ_U_DATA + 1473 }; -#else -static const opus_uint32 *const CELT_PVQ_U_ROW[15]={ - CELT_PVQ_U_DATA+ 0,CELT_PVQ_U_DATA+ 176,CELT_PVQ_U_DATA+ 351, - CELT_PVQ_U_DATA+ 525,CELT_PVQ_U_DATA+ 698,CELT_PVQ_U_DATA+ 870, - CELT_PVQ_U_DATA+1041,CELT_PVQ_U_DATA+1131,CELT_PVQ_U_DATA+1178, - CELT_PVQ_U_DATA+1207,CELT_PVQ_U_DATA+1226,CELT_PVQ_U_DATA+1240, - CELT_PVQ_U_DATA+1248,CELT_PVQ_U_DATA+1254,CELT_PVQ_U_DATA+1257 +# else +static const oac_uint32 *const CELT_PVQ_U_ROW[15] = { + CELT_PVQ_U_DATA + 0, CELT_PVQ_U_DATA + 176, CELT_PVQ_U_DATA + 351, + CELT_PVQ_U_DATA + 525, CELT_PVQ_U_DATA + 698, CELT_PVQ_U_DATA + 870, + CELT_PVQ_U_DATA + 1041, CELT_PVQ_U_DATA + 1131, CELT_PVQ_U_DATA + 1178, + CELT_PVQ_U_DATA + 1207, CELT_PVQ_U_DATA + 1226, CELT_PVQ_U_DATA + 1240, + CELT_PVQ_U_DATA + 1248, CELT_PVQ_U_DATA + 1254, CELT_PVQ_U_DATA + 1257 }; -#endif - -#if defined(CUSTOM_MODES) -void get_required_bits(opus_int16 *_bits,int _n,int _maxk,int _frac){ - int k; - /*_maxk==0 => there's nothing to do.*/ - celt_assert(_maxk>0); - _bits[0]=0; - for(k=1;k<=_maxk;k++)_bits[k]=log2_frac(CELT_PVQ_V(_n,k),_frac); +# endif + +# if defined(CUSTOM_MODES) +void oaci_get_required_bits(oac_int16 *_bits, int _n, int _maxk, int _frac) { + int k; + /*_maxk==0 => there's nothing to do.*/ + celt_assert(_maxk > 0); + _bits[0] = 0; + for (k = 1; k <= _maxk; k++) _bits[k] = oaci_log2_frac(CELT_PVQ_V(_n, k), _frac); } -#endif - -static opus_uint32 icwrs(int _n,const int *_y){ - opus_uint32 i; - int j; - int k; - celt_assert(_n>=2); - j=_n-1; - i=_y[j]<0; - k=abs(_y[j]); - do{ - j--; - i+=CELT_PVQ_U(_n-j,k); - k+=abs(_y[j]); - if(_y[j]<0)i+=CELT_PVQ_U(_n-j,k+1); - } - while(j>0); - return i; +# endif + +static oac_uint32 oaci_icwrs(int _n, const int *_y) { + oac_uint32 i; + int j; + int k; + celt_assert(_n >= 2); + j = _n - 1; + i = _y[j] < 0; + k = abs(_y[j]); + do { + j--; + i += CELT_PVQ_U(_n - j, k); + k += abs(_y[j]); + if (_y[j] < 0) i += CELT_PVQ_U(_n - j, k + 1); + } while (j > 0); + return i; } -void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){ - celt_assert(_k>0); - ec_enc_uint(_enc,icwrs(_n,_y),CELT_PVQ_V(_n,_k)); +void oaci_encode_pulses(const int *_y, int _n, int _k, ec_enc *_enc) { + celt_assert(_k > 0); + oaci_ec_enc_uint(_enc, oaci_icwrs(_n, _y), CELT_PVQ_V(_n, _k)); } -static opus_val32 cwrsi(int _n,int _k,opus_uint32 _i,int *_y){ - opus_uint32 p; - int s; - int k0; - opus_int16 val; - opus_val32 yy=0; - celt_assert(_k>0); - celt_assert(_n>1); - while(_n>2){ - opus_uint32 q; - /*Lots of pulses case:*/ - if(_k>=_n){ - const opus_uint32 *row; - row=CELT_PVQ_U_ROW[_n]; - /*Are the pulses in this dimension negative?*/ - p=row[_k+1]; - s=-(_i>=p); - _i-=p&s; - /*Count how many pulses were placed in this dimension.*/ - k0=_k; - q=row[_n]; - if(q>_i){ - celt_sig_assert(p>q); - _k=_n; - do p=CELT_PVQ_U_ROW[--_k][_n]; - while(p>_i); - } - else for(p=row[_k];p>_i;p=row[_k])_k--; - _i-=p; - val=(k0-_k+s)^s; - *_y++=val; - yy=MAC16_16(yy,val,val); +static oac_val32 oaci_cwrsi(int _n, int _k, oac_uint32 _i, int *_y) { + oac_uint32 p; + int s; + int k0; + oac_int16 val; + oac_val32 yy = 0; + celt_assert(_k > 0); + celt_assert(_n > 1); + while (_n > 2) { + oac_uint32 q; + /*Lots of pulses case:*/ + if (_k >= _n) { + const oac_uint32 *row; + row = CELT_PVQ_U_ROW[_n]; + /*Are the pulses in this dimension negative?*/ + p = row[_k + 1]; + s = -(_i >= p); + _i -= p&s; + /*Count how many pulses were placed in this dimension.*/ + k0 = _k; + q = row[_n]; + if (q > _i) { + celt_sig_assert(p > q); + _k = _n; + do p = CELT_PVQ_U_ROW[--_k][_n]; + while (p > _i); + } else for (p = row[_k]; p > _i; p = row[_k]) _k--; + _i -= p; + val = (k0 - _k + s)^s; + *_y++ = val; + yy = MAC16_16(yy, val, val); + } + /*Lots of dimensions case:*/ + else { + /*Are there any pulses in this dimension at all?*/ + p = CELT_PVQ_U_ROW[_k][_n]; + q = CELT_PVQ_U_ROW[_k + 1][_n]; + if (p <= _i && _i < q) { + _i -= p; + *_y++ = 0; + } else { + /*Are the pulses in this dimension negative?*/ + s = -(_i >= q); + _i -= q&s; + /*Count how many pulses were placed in this dimension.*/ + k0 = _k; + do p = CELT_PVQ_U_ROW[--_k][_n]; + while (p > _i); + _i -= p; + val = (k0 - _k + s)^s; + *_y++ = val; + yy = MAC16_16(yy, val, val); + } + } + _n--; } - /*Lots of dimensions case:*/ - else{ - /*Are there any pulses in this dimension at all?*/ - p=CELT_PVQ_U_ROW[_k][_n]; - q=CELT_PVQ_U_ROW[_k+1][_n]; - if(p<=_i&&_i=q); - _i-=q&s; - /*Count how many pulses were placed in this dimension.*/ - k0=_k; - do p=CELT_PVQ_U_ROW[--_k][_n]; - while(p>_i); - _i-=p; - val=(k0-_k+s)^s; - *_y++=val; - yy=MAC16_16(yy,val,val); - } - } - _n--; - } - /*_n==2*/ - p=2*_k+1; - s=-(_i>=p); - _i-=p&s; - k0=_k; - _k=(_i+1)>>1; - if(_k)_i-=2*_k-1; - val=(k0-_k+s)^s; - *_y++=val; - yy=MAC16_16(yy,val,val); - /*_n==1*/ - s=-(int)_i; - val=(_k+s)^s; - *_y=val; - yy=MAC16_16(yy,val,val); - return yy; + /*_n==2*/ + p = 2*_k + 1; + s = -(_i >= p); + _i -= p&s; + k0 = _k; + _k = (_i + 1)>>1; + if (_k) _i -= 2*_k - 1; + val = (k0 - _k + s)^s; + *_y++ = val; + yy = MAC16_16(yy, val, val); + /*_n==1*/ + s = -(int)_i; + val = (_k + s)^s; + *_y = val; + yy = MAC16_16(yy, val, val); + return yy; } -opus_val32 decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ - return cwrsi(_n,_k,ec_dec_uint(_dec,CELT_PVQ_V(_n,_k)),_y); +oac_val32 oaci_decode_pulses(int *_y, int _n, int _k, ec_dec *_dec) { + return oaci_cwrsi(_n, _k, oaci_ec_dec_uint(_dec, CELT_PVQ_V(_n, _k)), _y); } #else /* SMALL_FOOTPRINT */ /*Computes the next row/column of any recurrence that obeys the relation u[i][j]=u[i-1][j]+u[i][j-1]+u[i-1][j-1]. - _ui0 is the base case for the new row/column.*/ -static OPUS_INLINE void unext(opus_uint32 *_ui,unsigned _len,opus_uint32 _ui0){ - opus_uint32 ui1; - unsigned j; - /*This do-while will overrun the array if we don't have storage for at least - 2 values.*/ - j=1; do { - ui1=UADD32(UADD32(_ui[j],_ui[j-1]),_ui0); - _ui[j-1]=_ui0; - _ui0=ui1; - } while (++j<_len); - _ui[j-1]=_ui0; + _ui0 is the base case for the new row/column.*/ +static OAC_INLINE void oaci_unext(oac_uint32 *_ui, unsigned _len, oac_uint32 _ui0) { + oac_uint32 ui1; + unsigned j; + /*This do-while will overrun the array if we don't have storage for at least + 2 values.*/ + j = 1; do { + ui1 = UADD32(UADD32(_ui[j], _ui[j - 1]), _ui0); + _ui[j - 1] = _ui0; + _ui0 = ui1; + } while (++j < _len); + _ui[j - 1] = _ui0; } /*Computes the previous row/column of any recurrence that obeys the relation u[i-1][j]=u[i][j]-u[i][j-1]-u[i-1][j-1]. - _ui0 is the base case for the new row/column.*/ -static OPUS_INLINE void uprev(opus_uint32 *_ui,unsigned _n,opus_uint32 _ui0){ - opus_uint32 ui1; - unsigned j; - /*This do-while will overrun the array if we don't have storage for at least - 2 values.*/ - j=1; do { - ui1=USUB32(USUB32(_ui[j],_ui[j-1]),_ui0); - _ui[j-1]=_ui0; - _ui0=ui1; - } while (++j<_n); - _ui[j-1]=_ui0; + _ui0 is the base case for the new row/column.*/ +static OAC_INLINE void uprev(oac_uint32 *_ui, unsigned _n, oac_uint32 _ui0) { + oac_uint32 ui1; + unsigned j; + /*This do-while will overrun the array if we don't have storage for at least + 2 values.*/ + j = 1; do { + ui1 = USUB32(USUB32(_ui[j], _ui[j - 1]), _ui0); + _ui[j - 1] = _ui0; + _ui0 = ui1; + } while (++j < _n); + _ui[j - 1] = _ui0; } /*Compute V(_n,_k), as well as U(_n,0..._k+1). - _u: On exit, _u[i] contains U(_n,i) for i in [0..._k+1].*/ -static opus_uint32 ncwrs_urow(unsigned _n,unsigned _k,opus_uint32 *_u){ - opus_uint32 um2; - unsigned len; - unsigned k; - len=_k+2; - /*We require storage at least 3 values (e.g., _k>0).*/ - celt_assert(len>=3); - _u[0]=0; - _u[1]=um2=1; - /*If _n==0, _u[0] should be 1 and the rest should be 0.*/ - /*If _n==1, _u[i] should be 1 for i>1.*/ - celt_assert(_n>=2); - /*If _k==0, the following do-while loop will overflow the buffer.*/ - celt_assert(_k>0); - k=2; - do _u[k]=(k<<1)-1; - while(++k0).*/ + celt_assert(len >= 3); + _u[0] = 0; + _u[1] = um2 = 1; + /*If _n==0, _u[0] should be 1 and the rest should be 0.*/ + /*If _n==1, _u[i] should be 1 for i>1.*/ + celt_assert(_n >= 2); + /*If _k==0, the following do-while loop will overflow the buffer.*/ + celt_assert(_k > 0); + k = 2; + do _u[k] = (k<<1) - 1; + while (++k < len); + for (k = 2; k < _n; k++) oaci_unext(_u + 1, _k + 1, 1); + return _u[_k] + _u[_k + 1]; } /*Returns the _i'th combination of _k elements chosen from a set of size _n with associated sign bits. - _y: Returns the vector of pulses. - _u: Must contain entries [0..._k+1] of row _n of U() on input. + _y: Returns the vector of pulses. + _u: Must contain entries [0..._k+1] of row _n of U() on input. Its contents will be destructively modified.*/ -static opus_val32 cwrsi(int _n,int _k,opus_uint32 _i,int *_y,opus_uint32 *_u){ - int j; - opus_int16 val; - opus_val32 yy=0; - celt_assert(_n>0); - j=0; - do{ - opus_uint32 p; - int s; - int yj; - p=_u[_k+1]; - s=-(_i>=p); - _i-=p&s; - yj=_k; - p=_u[_k]; - while(p>_i)p=_u[--_k]; - _i-=p; - yj-=_k; - val=(yj+s)^s; - _y[j]=val; - yy=MAC16_16(yy,val,val); - uprev(_u,_k+2,0); - } - while(++j<_n); - return yy; +static oac_val32 oaci_cwrsi(int _n, int _k, oac_uint32 _i, int *_y, oac_uint32 *_u) { + int j; + oac_int16 val; + oac_val32 yy = 0; + celt_assert(_n > 0); + j = 0; + do { + oac_uint32 p; + int s; + int yj; + p = _u[_k + 1]; + s = -(_i >= p); + _i -= p&s; + yj = _k; + p = _u[_k]; + while (p > _i) p = _u[--_k]; + _i -= p; + yj -= _k; + val = (yj + s)^s; + _y[j] = val; + yy = MAC16_16(yy, val, val); + uprev(_u, _k + 2, 0); + } while (++j < _n); + return yy; } /*Returns the index of the given combination of K elements chosen from a set of size 1 with associated sign bits. - _y: The vector of pulses, whose sum of absolute values is K. - _k: Returns K.*/ -static OPUS_INLINE opus_uint32 icwrs1(const int *_y,int *_k){ - *_k=abs(_y[0]); - return _y[0]<0; + _y: The vector of pulses, whose sum of absolute values is K. + _k: Returns K.*/ +static OAC_INLINE oac_uint32 icwrs1(const int *_y, int *_k) { + *_k = abs(_y[0]); + return _y[0] < 0; } /*Returns the index of the given combination of K elements chosen from a set of size _n with associated sign bits. - _y: The vector of pulses, whose sum of absolute values must be _k. - _nc: Returns V(_n,_k).*/ -static OPUS_INLINE opus_uint32 icwrs(int _n,int _k,opus_uint32 *_nc,const int *_y, - opus_uint32 *_u){ - opus_uint32 i; - int j; - int k; - /*We can't unroll the first two iterations of the loop unless _n>=2.*/ - celt_assert(_n>=2); - _u[0]=0; - for(k=1;k<=_k+1;k++)_u[k]=(k<<1)-1; - i=icwrs1(_y+_n-1,&k); - j=_n-2; - i+=_u[k]; - k+=abs(_y[j]); - if(_y[j]<0)i+=_u[k+1]; - while(j-->0){ - unext(_u,_k+2,0); - i+=_u[k]; - k+=abs(_y[j]); - if(_y[j]<0)i+=_u[k+1]; - } - *_nc=_u[k]+_u[k+1]; - return i; + _y: The vector of pulses, whose sum of absolute values must be _k. + _nc: Returns V(_n,_k).*/ +static OAC_INLINE oac_uint32 oaci_icwrs(int _n, int _k, oac_uint32 *_nc, const int *_y, + oac_uint32 *_u) { + oac_uint32 i; + int j; + int k; + /*We can't unroll the first two iterations of the loop unless _n>=2.*/ + celt_assert(_n >= 2); + _u[0] = 0; + for (k = 1; k <= _k + 1; k++) _u[k] = (k<<1) - 1; + i = icwrs1(_y + _n - 1, &k); + j = _n - 2; + i += _u[k]; + k += abs(_y[j]); + if (_y[j] < 0) i += _u[k + 1]; + while (j-- > 0) { + oaci_unext(_u, _k + 2, 0); + i += _u[k]; + k += abs(_y[j]); + if (_y[j] < 0) i += _u[k + 1]; + } + *_nc = _u[k] + _u[k + 1]; + return i; } -#if defined(CUSTOM_MODES) -void get_required_bits(opus_int16 *_bits,int _n,int _maxk,int _frac){ - int k; - /*_maxk==0 => there's nothing to do.*/ - celt_assert(_maxk>0); - _bits[0]=0; - if (_n==1) - { - for (k=1;k<=_maxk;k++) - _bits[k] = 1<<_frac; - } - else { - VARDECL(opus_uint32,u); +# if defined(CUSTOM_MODES) +void oaci_get_required_bits(oac_int16 *_bits, int _n, int _maxk, int _frac) { + int k; + /*_maxk==0 => there's nothing to do.*/ + celt_assert(_maxk > 0); + _bits[0] = 0; + if (_n == 1) { + for (k = 1; k <= _maxk; k++) + _bits[k] = 1<<_frac; + } else { + VARDECL(oac_uint32, u); + SAVE_STACK; + ALLOC(u, _maxk + 2U, oac_uint32); + oaci_ncwrs_urow(_n, _maxk, u); + for (k = 1; k <= _maxk; k++) + _bits[k] = oaci_log2_frac(u[k] + u[k + 1], _frac); + RESTORE_STACK; + } +} +# endif /* CUSTOM_MODES */ + +void oaci_encode_pulses(const int *_y, int _n, int _k, ec_enc *_enc) { + oac_uint32 i; + VARDECL(oac_uint32, u); + oac_uint32 nc; SAVE_STACK; - ALLOC(u,_maxk+2U,opus_uint32); - ncwrs_urow(_n,_maxk,u); - for(k=1;k<=_maxk;k++) - _bits[k]=log2_frac(u[k]+u[k+1],_frac); + celt_assert(_k > 0); + ALLOC(u, _k + 2U, oac_uint32); + i = oaci_icwrs(_n, _k, &nc, _y, u); + oaci_ec_enc_uint(_enc, i, nc); RESTORE_STACK; - } -} -#endif /* CUSTOM_MODES */ - -void encode_pulses(const int *_y,int _n,int _k,ec_enc *_enc){ - opus_uint32 i; - VARDECL(opus_uint32,u); - opus_uint32 nc; - SAVE_STACK; - celt_assert(_k>0); - ALLOC(u,_k+2U,opus_uint32); - i=icwrs(_n,_k,&nc,_y,u); - ec_enc_uint(_enc,i,nc); - RESTORE_STACK; } -opus_val32 decode_pulses(int *_y,int _n,int _k,ec_dec *_dec){ - VARDECL(opus_uint32,u); - int ret; - SAVE_STACK; - celt_assert(_k>0); - ALLOC(u,_k+2U,opus_uint32); - ret = cwrsi(_n,_k,ec_dec_uint(_dec,ncwrs_urow(_n,_k,u)),_y,u); - RESTORE_STACK; - return ret; +oac_val32 oaci_decode_pulses(int *_y, int _n, int _k, ec_dec *_dec) { + VARDECL(oac_uint32, u); + int ret; + SAVE_STACK; + celt_assert(_k > 0); + ALLOC(u, _k + 2U, oac_uint32); + ret = oaci_cwrsi(_n, _k, oaci_ec_dec_uint(_dec, oaci_ncwrs_urow(_n, _k, u)), _y, u); + RESTORE_STACK; + return ret; } #endif /* SMALL_FOOTPRINT */ diff --git a/celt/cwrs.h b/celt/cwrs.h index 7cd471745..143ec5f64 100644 --- a/celt/cwrs.h +++ b/celt/cwrs.h @@ -25,7 +25,7 @@ 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. -*/ + */ #ifndef CWRS_H #define CWRS_H @@ -36,13 +36,13 @@ #include "entdec.h" #ifdef CUSTOM_MODES -int log2_frac(opus_uint32 val, int frac); +int oaci_log2_frac(oac_uint32 val, int frac); #endif -void get_required_bits(opus_int16 *bits, int N, int K, int frac); +void oaci_get_required_bits(oac_int16 *bits, int N, int K, int frac); -void encode_pulses(const int *_y, int N, int K, ec_enc *enc); +void oaci_encode_pulses(const int *_y, int N, int K, ec_enc *enc); -opus_val32 decode_pulses(int *_y, int N, int K, ec_dec *dec); +oac_val32 oaci_decode_pulses(int *_y, int N, int K, ec_dec *dec); #endif /* CWRS_H */ diff --git a/celt/dump_modes/Makefile b/celt/dump_modes/Makefile index c3e7e7ce7..2d67b6352 100644 --- a/celt/dump_modes/Makefile +++ b/celt/dump_modes/Makefile @@ -12,14 +12,12 @@ SOURCES = dump_modes.c \ ../mathops.c \ ../mdct.c \ ../celt.c \ - ../kiss_fft.c \ - ../quant_bands.c \ - ../laplace.c + ../kiss_fft.c ifdef HAVE_ARM_NE10 CC = gcc CFLAGS += -mfpu=neon -INCLUDES += -I$(NE10_INCDIR) -DHAVE_ARM_NE10 -DOPUS_ARM_PRESUME_NEON_INTR +INCLUDES += -I$(NE10_INCDIR) -DHAVE_ARM_NE10 -DOAC_ARM_PRESUME_NEON_INTR LIBS = -L$(NE10_LIBDIR) -lNE10 SOURCES += ../arm/celt_ne10_fft.c \ dump_modes_arm_ne10.c \ diff --git a/celt/dump_modes/dump_modes.c b/celt/dump_modes/dump_modes.c index 849938fdd..772188a60 100644 --- a/celt/dump_modes/dump_modes.c +++ b/celt/dump_modes/dump_modes.c @@ -24,10 +24,10 @@ 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" +# include "config.h" #endif #include @@ -42,390 +42,307 @@ #define FLOAT "%#0.8gf" #ifdef FIXED_POINT -#define WORD16 INT16 -#define WORD32 INT32 +# define WORD16 INT16 +# define WORD32 INT32 #else -#define WORD16 FLOAT -#define WORD32 FLOAT +# define WORD16 FLOAT +# define WORD32 FLOAT #endif -#define COEF16(x, a) ((opus_int16)SATURATE(((opus_int64)(x)+(1<<(a)>>1))>>(a), 32767)) -int opus_select_arch(void) { - return 0; +#define COEF16(x, a) ((oac_int16)SATURATE(((oac_int64)(x) + (1<<(a)>>1))>>(a), 32767)) +int oac_select_arch(void) { + return 0; } -void dump_modes(FILE *file, CELTMode **modes, int nb_modes) -{ - int i, j, k; - int mdct_twiddles_size; - fprintf(file, "/* The contents of this file was automatically generated by dump_modes.c\n"); - fprintf(file, " with arguments:"); - for (i=0;iFs,mode->shortMdctSize*mode->nbShortMdcts); - } - fprintf(file, "\n It contains static definitions for some pre-defined modes. */\n"); - fprintf(file, "#include \"modes.h\"\n"); - fprintf(file, "#include \"rate.h\"\n"); - fprintf(file, "\n#ifdef HAVE_ARM_NE10\n"); - fprintf(file, "#define OVERRIDE_FFT 1\n"); - fprintf(file, "#include \"%s\"\n", ARM_NE10_ARCH_FILE_NAME); - fprintf(file, "#endif\n"); - - fprintf(file, "\n"); - - for (i=0;ishortMdctSize*mode->nbShortMdcts; - standard = (mode->Fs == 400*(opus_int32)mode->shortMdctSize); - framerate = mode->Fs/mode->shortMdctSize; - - if (!standard) - { - fprintf(file, "#ifndef DEF_EBANDS%d_%d\n", mode->Fs, mdctSize); - fprintf(file, "#define DEF_EBANDS%d_%d\n", mode->Fs, mdctSize); - fprintf (file, "static const opus_int16 eBands%d_%d[%d] = {\n", mode->Fs, mdctSize, mode->nbEBands+2); - for (j=0;jnbEBands+2;j++) - fprintf (file, "%d, ", mode->eBands[j]); - fprintf (file, "};\n"); - fprintf(file, "#endif\n"); - fprintf(file, "\n"); - } - - fprintf(file, "#ifndef DEF_WINDOW%d\n", mode->overlap); - fprintf(file, "#define DEF_WINDOW%d\n", mode->overlap); - fprintf (file, "static const celt_coef window%d[%d] = {\n", mode->overlap, mode->overlap); -#if defined(FIXED_POINT) && defined(ENABLE_QEXT) - fprintf(file, "#ifdef ENABLE_QEXT\n"); - for (j=0;joverlap;j++) - fprintf (file, WORD32 ",%c", mode->window[j],(j+6)%5==0?'\n':' '); - fprintf(file, "#else\n"); - for (j=0;joverlap;j++) - fprintf (file, WORD16 ",%c", COEF16(mode->window[j], 16),(j+6)%5==0?'\n':' '); - fprintf(file, "#endif\n"); -#else - for (j=0;joverlap;j++) - fprintf (file, WORD16 ",%c", mode->window[j],(j+6)%5==0?'\n':' '); -#endif - fprintf (file, "};\n"); - fprintf(file, "#endif\n"); - fprintf(file, "\n"); - - if (!standard) - { - fprintf(file, "#ifndef DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mdctSize); - fprintf(file, "#define DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mdctSize); - fprintf (file, "static const unsigned char allocVectors%d_%d[%d] = {\n", mode->Fs, mdctSize, mode->nbEBands*mode->nbAllocVectors); - for (j=0;jnbAllocVectors;j++) - { - for (k=0;knbEBands;k++) - fprintf (file, "%2d, ", mode->allocVectors[j*mode->nbEBands+k]); - fprintf (file, "\n"); - } - fprintf (file, "};\n"); - fprintf(file, "#endif\n"); - fprintf(file, "\n"); - } - - fprintf(file, "#ifndef DEF_LOGN%d\n", framerate); - fprintf(file, "#define DEF_LOGN%d\n", framerate); - fprintf (file, "static const opus_int16 logN%d[%d] = {\n", framerate, mode->nbEBands); - for (j=0;jnbEBands;j++) - fprintf (file, "%d, ", mode->logN[j]); - fprintf (file, "};\n"); - fprintf(file, "#endif\n"); - fprintf(file, "\n"); - - /* Pulse cache */ - fprintf(file, "#ifndef DEF_PULSE_CACHE%d\n", mode->Fs/mdctSize); - fprintf(file, "#define DEF_PULSE_CACHE%d\n", mode->Fs/mdctSize); - fprintf (file, "static const opus_int16 cache_index%d[%d] = {\n", mode->Fs/mdctSize, (mode->maxLM+2)*mode->nbEBands); - for (j=0;jnbEBands*(mode->maxLM+2);j++) - fprintf (file, "%d,%c", mode->cache.index[j],(j+16)%15==0?'\n':' '); - fprintf (file, "};\n"); - fprintf (file, "static const unsigned char cache_bits%d[%d] = {\n", mode->Fs/mdctSize, mode->cache.size); - for (j=0;jcache.size;j++) - fprintf (file, "%d,%c", mode->cache.bits[j],(j+16)%15==0?'\n':' '); - fprintf (file, "};\n"); - fprintf (file, "static const unsigned char cache_caps%d[%d] = {\n", mode->Fs/mdctSize, (mode->maxLM+1)*2*mode->nbEBands); - for (j=0;j<(mode->maxLM+1)*2*mode->nbEBands;j++) - fprintf (file, "%d,%c", mode->cache.caps[j],(j+16)%15==0?'\n':' '); - fprintf (file, "};\n"); - - fprintf(file, "#endif\n"); - fprintf(file, "\n"); - - /* QEXT Pulse cache */ - if (mode->qext_cache.index != NULL) { - fprintf(file, "#ifdef ENABLE_QEXT\n"); - fprintf(file, "# ifndef DEF_QEXT_PULSE_CACHE%d\n", mode->Fs/mdctSize); - fprintf(file, "# define DEF_QEXT_PULSE_CACHE%d\n", mode->Fs/mdctSize); - fprintf (file, "static const opus_int16 qext_cache_index%d[%d] = {\n", mode->Fs/mdctSize, (mode->maxLM+2)*NB_QEXT_BANDS); - for (j=0;jmaxLM+2);j++) - fprintf (file, "%d,%c", mode->qext_cache.index[j],(j+16)%15==0?'\n':' '); - fprintf (file, "};\n"); - fprintf (file, "static const unsigned char qext_cache_bits%d[%d] = {\n", mode->Fs/mdctSize, mode->qext_cache.size); - for (j=0;jqext_cache.size;j++) - fprintf (file, "%d,%c", mode->qext_cache.bits[j],(j+16)%15==0?'\n':' '); - fprintf (file, "};\n"); - fprintf (file, "static const unsigned char qext_cache_caps%d[%d] = {\n", mode->Fs/mdctSize, (mode->maxLM+1)*2*NB_QEXT_BANDS); - for (j=0;j<(mode->maxLM+1)*2*NB_QEXT_BANDS;j++) - fprintf (file, "%d,%c", mode->qext_cache.caps[j],(j+16)%15==0?'\n':' '); - fprintf (file, "};\n"); - fprintf(file, "# endif\n"); - fprintf(file, "#endif\n"); - fprintf(file, "\n"); - } - - /* FFT twiddles */ - fprintf(file, "#ifndef FFT_TWIDDLES%d_%d\n", mode->Fs, mdctSize); - fprintf(file, "#define FFT_TWIDDLES%d_%d\n", mode->Fs, mdctSize); - - fprintf (file, "static const kiss_twiddle_cpx fft_twiddles%d_%d[%d] = {\n", +void dump_modes(FILE *file, CELTMode **modes, int nb_modes) { + int i, j, k; + int mdct_twiddles_size; + fprintf(file, "/* The contents of this file was automatically generated by dump_modes.c\n"); + fprintf(file, " with arguments:"); + for (i = 0; i < nb_modes; i++) { + CELTMode *mode = modes[i]; + fprintf(file, " %d %d", mode->Fs, mode->shortMdctSize*mode->nbShortMdcts); + } + fprintf(file, "\n It contains static definitions for some pre-defined modes. */\n"); + fprintf(file, "#include \"modes.h\"\n"); + fprintf(file, "#include \"rate.h\"\n"); + fprintf(file, "\n#ifdef HAVE_ARM_NE10\n"); + fprintf(file, "#define OVERRIDE_FFT 1\n"); + fprintf(file, "#include \"%s\"\n", ARM_NE10_ARCH_FILE_NAME); + fprintf(file, "#endif\n"); + + fprintf(file, "\n"); + + for (i = 0; i < nb_modes; i++) { + CELTMode *mode = modes[i]; + int mdctSize; + int standard, framerate; + + mdctSize = mode->shortMdctSize*mode->nbShortMdcts; + standard = (mode->Fs == 400*(oac_int32)mode->shortMdctSize); + framerate = mode->Fs/mode->shortMdctSize; + + if (!standard) { + fprintf(file, "#ifndef DEF_EBANDS%d_%d\n", mode->Fs, mdctSize); + fprintf(file, "#define DEF_EBANDS%d_%d\n", mode->Fs, mdctSize); + fprintf (file, "static const oac_int16 eBands%d_%d[%d] = {\n", mode->Fs, mdctSize, mode->nbEBands + 2); + for (j = 0; j < mode->nbEBands + 2; j++) + fprintf (file, "%d, ", mode->eBands[j]); + fprintf (file, "};\n"); + fprintf(file, "#endif\n"); + fprintf(file, "\n"); + } + + fprintf(file, "#ifndef DEF_WINDOW%d\n", mode->overlap); + fprintf(file, "#define DEF_WINDOW%d\n", mode->overlap); + fprintf (file, "static const celt_coef window%d[%d] = {\n", mode->overlap, mode->overlap); + for (j = 0; j < mode->overlap; j++) + fprintf (file, WORD32 ",%c", mode->window[j], (j + 6)%5 == 0?'\n':' '); + fprintf (file, "};\n"); + fprintf(file, "#endif\n"); + fprintf(file, "\n"); + + if (!standard) { + fprintf(file, "#ifndef DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mdctSize); + fprintf(file, "#define DEF_ALLOC_VECTORS%d_%d\n", mode->Fs, mdctSize); + fprintf (file, "static const unsigned char allocVectors%d_%d[%d] = {\n", mode->Fs, mdctSize, + mode->nbEBands*mode->nbAllocVectors); + for (j = 0; j < mode->nbAllocVectors; j++) { + for (k = 0; k < mode->nbEBands; k++) + fprintf (file, "%2d, ", mode->allocVectors[j*mode->nbEBands + k]); + fprintf (file, "\n"); + } + fprintf (file, "};\n"); + fprintf(file, "#endif\n"); + fprintf(file, "\n"); + } + + fprintf(file, "#ifndef DEF_LOGN%d\n", framerate); + fprintf(file, "#define DEF_LOGN%d\n", framerate); + fprintf (file, "static const oac_int16 logN%d[%d] = {\n", framerate, mode->nbEBands); + for (j = 0; j < mode->nbEBands; j++) + fprintf (file, "%d, ", mode->logN[j]); + fprintf (file, "};\n"); + fprintf(file, "#endif\n"); + fprintf(file, "\n"); + + /* Pulse cache */ + fprintf(file, "#ifndef DEF_PULSE_CACHE%d\n", mode->Fs/mdctSize); + fprintf(file, "#define DEF_PULSE_CACHE%d\n", mode->Fs/mdctSize); + fprintf (file, "static const oac_int16 cache_index%d[%d] = {\n", mode->Fs/mdctSize, + (mode->maxLM + 2)*mode->nbEBands); + for (j = 0; j < mode->nbEBands*(mode->maxLM + 2); j++) + fprintf (file, "%d,%c", mode->cache.index[j], (j + 16)%15 == 0?'\n':' '); + fprintf (file, "};\n"); + fprintf (file, "static const unsigned char cache_bits%d[%d] = {\n", mode->Fs/mdctSize, mode->cache.size); + for (j = 0; j < mode->cache.size; j++) + fprintf (file, "%d,%c", mode->cache.bits[j], (j + 16)%15 == 0?'\n':' '); + fprintf (file, "};\n"); + fprintf (file, "static const unsigned char cache_caps%d[%d] = {\n", mode->Fs/mdctSize, + (mode->maxLM + 1)*2*mode->nbEBands); + for (j = 0; j < (mode->maxLM + 1)*2*mode->nbEBands; j++) + fprintf (file, "%d,%c", mode->cache.caps[j], (j + 16)%15 == 0?'\n':' '); + fprintf (file, "};\n"); + + fprintf(file, "#endif\n"); + fprintf(file, "\n"); + + /* FFT twiddles */ + fprintf(file, "#ifndef FFT_TWIDDLES%d_%d\n", mode->Fs, mdctSize); + fprintf(file, "#define FFT_TWIDDLES%d_%d\n", mode->Fs, mdctSize); + + fprintf (file, "static const kiss_twiddle_cpx fft_twiddles%d_%d[%d] = {\n", mode->Fs, mdctSize, mode->mdct.kfft[0]->nfft); -#if defined(FIXED_POINT) && defined(ENABLE_QEXT) - fprintf(file, "#ifdef ENABLE_QEXT\n"); - for (j=0;jmdct.kfft[0]->nfft;j++) - fprintf (file, "{" WORD32 ", " WORD32 "},%c", mode->mdct.kfft[0]->twiddles[j].r, mode->mdct.kfft[0]->twiddles[j].i,(j+3)%2==0?'\n':' '); - fprintf(file, "#else\n"); - for (j=0;jmdct.kfft[0]->nfft;j++) - fprintf (file, "{" WORD16 ", " WORD16 "},%c", COEF16(mode->mdct.kfft[0]->twiddles[j].r,16), COEF16(mode->mdct.kfft[0]->twiddles[j].i,16),(j+3)%2==0?'\n':' '); - fprintf(file, "#endif\n"); -#else - for (j=0;jmdct.kfft[0]->nfft;j++) - fprintf (file, "{" WORD16 ", " WORD16 "},%c", mode->mdct.kfft[0]->twiddles[j].r, mode->mdct.kfft[0]->twiddles[j].i,(j+3)%2==0?'\n':' '); -#endif - fprintf (file, "};\n"); + for (j = 0; j < mode->mdct.kfft[0]->nfft; j++) + fprintf (file, "{" WORD32 ", " WORD32 "},%c", mode->mdct.kfft[0]->twiddles[j].r, + mode->mdct.kfft[0]->twiddles[j].i, (j + 3)%2 == 0?'\n':' '); + fprintf (file, "};\n"); #ifdef OVERRIDE_FFT - dump_mode_arch(mode); + dump_mode_arch(mode); #endif - /* FFT Bitrev tables */ - for (k=0;k<=mode->mdct.maxshift;k++) - { - fprintf(file, "#ifndef FFT_BITREV%d\n", mode->mdct.kfft[k]->nfft); - fprintf(file, "#define FFT_BITREV%d\n", mode->mdct.kfft[k]->nfft); - fprintf (file, "static const opus_int16 fft_bitrev%d[%d] = {\n", + /* FFT Bitrev tables */ + for (k = 0; k <= mode->mdct.maxshift; k++) { + fprintf(file, "#ifndef FFT_BITREV%d\n", mode->mdct.kfft[k]->nfft); + fprintf(file, "#define FFT_BITREV%d\n", mode->mdct.kfft[k]->nfft); + fprintf (file, "static const oac_int16 fft_bitrev%d[%d] = {\n", mode->mdct.kfft[k]->nfft, mode->mdct.kfft[k]->nfft); - for (j=0;jmdct.kfft[k]->nfft;j++) - fprintf (file, "%d,%c", mode->mdct.kfft[k]->bitrev[j],(j+16)%15==0?'\n':' '); - fprintf (file, "};\n"); - - fprintf(file, "#endif\n"); - fprintf(file, "\n"); - } - - /* FFT States */ - for (k=0;k<=mode->mdct.maxshift;k++) - { - fprintf(file, "#ifndef FFT_STATE%d_%d_%d\n", mode->Fs, mdctSize, k); - fprintf(file, "#define FFT_STATE%d_%d_%d\n", mode->Fs, mdctSize, k); - fprintf (file, "static const kiss_fft_state fft_state%d_%d_%d = {\n", + for (j = 0; j < mode->mdct.kfft[k]->nfft; j++) + fprintf (file, "%d,%c", mode->mdct.kfft[k]->bitrev[j], (j + 16)%15 == 0?'\n':' '); + fprintf (file, "};\n"); + + fprintf(file, "#endif\n"); + fprintf(file, "\n"); + } + + /* FFT States */ + for (k = 0; k <= mode->mdct.maxshift; k++) { + fprintf(file, "#ifndef FFT_STATE%d_%d_%d\n", mode->Fs, mdctSize, k); + fprintf(file, "#define FFT_STATE%d_%d_%d\n", mode->Fs, mdctSize, k); + fprintf (file, "static const kiss_fft_state fft_state%d_%d_%d = {\n", mode->Fs, mdctSize, k); - fprintf (file, "%d, /* nfft */\n", mode->mdct.kfft[k]->nfft); - -#if defined(FIXED_POINT) && defined(ENABLE_QEXT) - fprintf(file, "#ifdef ENABLE_QEXT\n"); - fprintf (file, WORD32 ", /* scale */\n", mode->mdct.kfft[k]->scale); - fprintf(file, "#else\n"); - fprintf (file, WORD16 ", /* scale */\n", COEF16(mode->mdct.kfft[k]->scale, 15)); - fprintf(file, "#endif\n"); -#else - fprintf (file, WORD16 ", /* scale */\n", mode->mdct.kfft[k]->scale); -#endif + fprintf (file, "%d, /* nfft */\n", mode->mdct.kfft[k]->nfft); + + fprintf (file, WORD32 ", /* scale */\n", mode->mdct.kfft[k]->scale); #ifdef FIXED_POINT - fprintf (file, "%d, /* scale_shift */\n", mode->mdct.kfft[k]->scale_shift); + fprintf (file, "%d, /* scale_shift */\n", mode->mdct.kfft[k]->scale_shift); #endif - fprintf (file, "%d, /* shift */\n", mode->mdct.kfft[k]->shift); - fprintf (file, "{"); - for (j=0;j<2*MAXFACTORS;j++) - fprintf (file, "%d, ", mode->mdct.kfft[k]->factors[j]); - fprintf (file, "}, /* factors */\n"); - fprintf (file, "fft_bitrev%d, /* bitrev */\n", mode->mdct.kfft[k]->nfft); - fprintf (file, "fft_twiddles%d_%d, /* bitrev */\n", mode->Fs, mdctSize); - - fprintf (file, "#ifdef OVERRIDE_FFT\n"); - fprintf (file, "(arch_fft_state *)&cfg_arch_%d,\n", mode->mdct.kfft[k]->nfft); - fprintf (file, "#else\n"); - fprintf (file, "NULL,\n"); - fprintf(file, "#endif\n"); - - fprintf (file, "};\n"); - - fprintf(file, "#endif\n"); - fprintf(file, "\n"); - } - - fprintf(file, "#endif\n"); - fprintf(file, "\n"); - - /* MDCT twiddles */ - mdct_twiddles_size = mode->mdct.n-(mode->mdct.n/2>>mode->mdct.maxshift); - fprintf(file, "#ifndef MDCT_TWIDDLES%d\n", mdctSize); - fprintf(file, "#define MDCT_TWIDDLES%d\n", mdctSize); - fprintf (file, "static const celt_coef mdct_twiddles%d[%d] = {\n", + fprintf (file, "%d, /* shift */\n", mode->mdct.kfft[k]->shift); + fprintf (file, "{"); + for (j = 0; j < 2*MAXFACTORS; j++) + fprintf (file, "%d, ", mode->mdct.kfft[k]->factors[j]); + fprintf (file, "}, /* factors */\n"); + fprintf (file, "fft_bitrev%d, /* bitrev */\n", mode->mdct.kfft[k]->nfft); + fprintf (file, "fft_twiddles%d_%d, /* bitrev */\n", mode->Fs, mdctSize); + + fprintf (file, "#ifdef OVERRIDE_FFT\n"); + fprintf (file, "(arch_fft_state *)&cfg_arch_%d,\n", mode->mdct.kfft[k]->nfft); + fprintf (file, "#else\n"); + fprintf (file, "NULL,\n"); + fprintf(file, "#endif\n"); + + fprintf (file, "};\n"); + + fprintf(file, "#endif\n"); + fprintf(file, "\n"); + } + + fprintf(file, "#endif\n"); + fprintf(file, "\n"); + + /* MDCT twiddles */ + mdct_twiddles_size = mode->mdct.n - (mode->mdct.n/2>>mode->mdct.maxshift); + fprintf(file, "#ifndef MDCT_TWIDDLES%d\n", mdctSize); + fprintf(file, "#define MDCT_TWIDDLES%d\n", mdctSize); + fprintf (file, "static const celt_coef mdct_twiddles%d[%d] = {\n", mdctSize, mdct_twiddles_size); -#if defined(FIXED_POINT) && defined(ENABLE_QEXT) - fprintf(file, "#ifdef ENABLE_QEXT\n"); - for (j=0;jmdct.trig[j],(j+6)%5==0?'\n':' '); - fprintf(file, "#else\n"); - for (j=0;jmdct.trig[j], 16),(j+6)%5==0?'\n':' '); - fprintf(file, "#endif\n"); -#else - for (j=0;jmdct.trig[j],(j+6)%5==0?'\n':' '); -#endif - - fprintf (file, "};\n"); - - fprintf(file, "#endif\n"); - fprintf(file, "\n"); - - - /* Print the actual mode data */ - fprintf(file, "static const CELTMode mode%d_%d_%d = {\n", mode->Fs, mdctSize, mode->overlap); - fprintf(file, INT32 ", /* Fs */\n", mode->Fs); - fprintf(file, "%d, /* overlap */\n", mode->overlap); - fprintf(file, "%d, /* nbEBands */\n", mode->nbEBands); - fprintf(file, "%d, /* effEBands */\n", mode->effEBands); - fprintf(file, "{"); - for (j=0;j<4;j++) - fprintf(file, WORD16 ", ", mode->preemph[j]); - fprintf(file, "}, /* preemph */\n"); - if (standard) - fprintf(file, "eband5ms, /* eBands */\n"); - else - fprintf(file, "eBands%d_%d, /* eBands */\n", mode->Fs, mdctSize); - - fprintf(file, "%d, /* maxLM */\n", mode->maxLM); - fprintf(file, "%d, /* nbShortMdcts */\n", mode->nbShortMdcts); - fprintf(file, "%d, /* shortMdctSize */\n", mode->shortMdctSize); - - fprintf(file, "%d, /* nbAllocVectors */\n", mode->nbAllocVectors); - if (standard) - fprintf(file, "band_allocation, /* allocVectors */\n"); - else - fprintf(file, "allocVectors%d_%d, /* allocVectors */\n", mode->Fs, mdctSize); - - fprintf(file, "logN%d, /* logN */\n", framerate); - fprintf(file, "window%d, /* window */\n", mode->overlap); - fprintf(file, "{%d, %d, {", mode->mdct.n, mode->mdct.maxshift); - for (k=0;k<=mode->mdct.maxshift;k++) - fprintf(file, "&fft_state%d_%d_%d, ", mode->Fs, mdctSize, k); - fprintf (file, "}, mdct_twiddles%d}, /* mdct */\n", mdctSize); - - fprintf(file, "{%d, cache_index%d, cache_bits%d, cache_caps%d}, /* cache */\n", + for (j = 0; j < mdct_twiddles_size; j++) + fprintf (file, WORD32 ",%c", mode->mdct.trig[j], (j + 6)%5 == 0?'\n':' '); + + fprintf (file, "};\n"); + + fprintf(file, "#endif\n"); + fprintf(file, "\n"); + + + /* Print the actual mode data */ + fprintf(file, "static const CELTMode mode%d_%d_%d = {\n", mode->Fs, mdctSize, mode->overlap); + fprintf(file, INT32 ", /* Fs */\n", mode->Fs); + fprintf(file, "%d, /* overlap */\n", mode->overlap); + fprintf(file, "%d, /* nbEBands */\n", mode->nbEBands); + fprintf(file, "%d, /* effEBands */\n", mode->effEBands); + fprintf(file, "{"); + for (j = 0; j < 4; j++) + fprintf(file, WORD16 ", ", mode->preemph[j]); + fprintf(file, "}, /* preemph */\n"); + if (standard) + fprintf(file, "eband5ms, /* eBands */\n"); + else + fprintf(file, "eBands%d_%d, /* eBands */\n", mode->Fs, mdctSize); + + fprintf(file, "%d, /* maxLM */\n", mode->maxLM); + fprintf(file, "%d, /* nbShortMdcts */\n", mode->nbShortMdcts); + fprintf(file, "%d, /* shortMdctSize */\n", mode->shortMdctSize); + + fprintf(file, "%d, /* nbAllocVectors */\n", mode->nbAllocVectors); + if (standard) + fprintf(file, "band_allocation, /* allocVectors */\n"); + else + fprintf(file, "allocVectors%d_%d, /* allocVectors */\n", mode->Fs, mdctSize); + + fprintf(file, "logN%d, /* logN */\n", framerate); + fprintf(file, "window%d, /* window */\n", mode->overlap); + fprintf(file, "{%d, %d, {", mode->mdct.n, mode->mdct.maxshift); + for (k = 0; k <= mode->mdct.maxshift; k++) + fprintf(file, "&fft_state%d_%d_%d, ", mode->Fs, mdctSize, k); + fprintf (file, "}, mdct_twiddles%d}, /* mdct */\n", mdctSize); + + fprintf(file, "{%d, cache_index%d, cache_bits%d, cache_caps%d}, /* cache */\n", mode->cache.size, mode->Fs/mdctSize, mode->Fs/mdctSize, mode->Fs/mdctSize); - - fprintf(file, "#ifdef ENABLE_QEXT\n"); - if (mode->qext_cache.index != NULL) { - fprintf(file, "{%d, qext_cache_index%d, qext_cache_bits%d, qext_cache_caps%d}, /* qext_cache */\n", - mode->qext_cache.size, mode->Fs/mdctSize, mode->Fs/mdctSize, mode->Fs/mdctSize); - } else { - fprintf(file, "{0, NULL, NULL, NULL}, /* qext_cache */\n"); - } - fprintf(file, "#endif\n"); - fprintf(file, "};\n"); - } - fprintf(file, "\n"); - fprintf(file, "/* List of all the available modes */\n"); - fprintf(file, "#define TOTAL_MODES %d\n", nb_modes); - fprintf(file, "static const CELTMode * const static_mode_list[TOTAL_MODES] = {\n"); - for (i=0;ishortMdctSize*mode->nbShortMdcts; - fprintf(file, "&mode%d_%d_%d,\n", mode->Fs, mdctSize, mode->overlap); - } - fprintf(file, "};\n"); + fprintf(file, "};\n"); + } + fprintf(file, "\n"); + fprintf(file, "/* List of all the available modes */\n"); + fprintf(file, "#define TOTAL_MODES %d\n", nb_modes); + fprintf(file, "static const CELTMode * const static_mode_list[TOTAL_MODES] = {\n"); + for (i = 0; i < nb_modes; i++) { + CELTMode *mode = modes[i]; + int mdctSize; + mdctSize = mode->shortMdctSize*mode->nbShortMdcts; + fprintf(file, "&mode%d_%d_%d,\n", mode->Fs, mdctSize, mode->overlap); + } + fprintf(file, "};\n"); } -void dump_header(FILE *file, CELTMode **modes, int nb_modes) -{ - int i; - int channels = 0; - int frame_size = 0; - int overlap = 0; - fprintf (file, "/* This header file is generated automatically*/\n"); - for (i=0;ishortMdctSize*mode->nbShortMdcts; - else if (frame_size != mode->shortMdctSize*mode->nbShortMdcts) - frame_size = -1; - if (overlap==0) - overlap = mode->overlap; - else if (overlap != mode->overlap) - overlap = -1; - } - if (channels>0) - { - fprintf (file, "#define CHANNELS(mode) %d\n", channels); - if (channels==1) - fprintf (file, "#define DISABLE_STEREO\n"); - } - if (frame_size>0) - { - fprintf (file, "#define FRAMESIZE(mode) %d\n", frame_size); - } - if (overlap>0) - { - fprintf (file, "#define OVERLAP(mode) %d\n", overlap); - } +void dump_header(FILE *file, CELTMode **modes, int nb_modes) { + int i; + int channels = 0; + int frame_size = 0; + int overlap = 0; + fprintf (file, "/* This header file is generated automatically*/\n"); + for (i = 0; i < nb_modes; i++) { + CELTMode *mode = modes[i]; + if (frame_size == 0) + frame_size = mode->shortMdctSize*mode->nbShortMdcts; + else if (frame_size != mode->shortMdctSize*mode->nbShortMdcts) + frame_size = -1; + if (overlap == 0) + overlap = mode->overlap; + else if (overlap != mode->overlap) + overlap = -1; + } + if (channels > 0) { + fprintf (file, "#define CHANNELS(mode) %d\n", channels); + if (channels == 1) + fprintf (file, "#define DISABLE_STEREO\n"); + } + if (frame_size > 0) { + fprintf (file, "#define FRAMESIZE(mode) %d\n", frame_size); + } + if (overlap > 0) { + fprintf (file, "#define OVERLAP(mode) %d\n", overlap); + } } #ifdef FIXED_POINT -#define BASENAME "static_modes_fixed" +# define BASENAME "static_modes_fixed" #else -#define BASENAME "static_modes_float" +# define BASENAME "static_modes_float" #endif -int main(int argc, char **argv) -{ - int i, nb; - FILE *file; - CELTMode **m; - if (argc%2 != 1 || argc<3) - { - fprintf (stderr, "Usage: %s rate frame_size [rate frame_size] [rate frame_size]...\n",argv[0]); - return 1; - } - nb = (argc-1)/2; - m = malloc(nb*sizeof(CELTMode*)); - for (i=0;iFs,mode->shortMdctSize*mode->nbShortMdcts); - } - fprintf(file, "\n * It contains static definitions for some pre-defined modes. */\n"); - fprintf(file, "#include \n\n"); +void dump_modes_arch_init(CELTMode **modes, int nb_modes) { + int i; + + file = fopen(ARM_NE10_ARCH_FILE_NAME, "w"); + fprintf(file, "/* The contents of this file was automatically generated by\n"); + fprintf(file, " * dump_mode_arm_ne10.c with arguments:"); + for (i = 0; i < nb_modes; i++) { + CELTMode *mode = modes[i]; + fprintf(file, " %d %d", mode->Fs, mode->shortMdctSize*mode->nbShortMdcts); + } + fprintf(file, "\n * It contains static definitions for some pre-defined modes. */\n"); + fprintf(file, "#include \n\n"); } -void dump_modes_arch_finalize() -{ - fclose(file); +void dump_modes_arch_finalize() { + fclose(file); } -void dump_mode_arch(CELTMode *mode) -{ - int k, j; - int mdctSize; - - mdctSize = mode->shortMdctSize*mode->nbShortMdcts; - - fprintf(file, "#ifndef NE10_FFT_PARAMS%d_%d\n", mode->Fs, mdctSize); - fprintf(file, "#define NE10_FFT_PARAMS%d_%d\n", mode->Fs, mdctSize); - /* cfg->factors */ - for(k=0;k<=mode->mdct.maxshift;k++) { - NE10_FFT_CFG_TYPE_T cfg; - cfg = (NE10_FFT_CFG_TYPE_T)mode->mdct.kfft[k]->arch_fft->priv; - if (!cfg) - continue; - fprintf(file, "static const ne10_int32_t ne10_factors_%d[%d] = {\n", - mode->mdct.kfft[k]->nfft, (NE10_MAXFACTORS * 2)); - for(j=0;j<(NE10_MAXFACTORS * 2);j++) { - fprintf(file, "%d,%c", cfg->factors[j],(j+16)%15==0?'\n':' '); - } - fprintf (file, "};\n"); - } - - /* cfg->twiddles */ - for(k=0;k<=mode->mdct.maxshift;k++) { - NE10_FFT_CFG_TYPE_T cfg; - cfg = (NE10_FFT_CFG_TYPE_T)mode->mdct.kfft[k]->arch_fft->priv; - if (!cfg) - continue; - fprintf(file, "static const %s ne10_twiddles_%d[%d] = {\n", +void dump_mode_arch(CELTMode *mode) { + int k, j; + int mdctSize; + + mdctSize = mode->shortMdctSize*mode->nbShortMdcts; + + fprintf(file, "#ifndef NE10_FFT_PARAMS%d_%d\n", mode->Fs, mdctSize); + fprintf(file, "#define NE10_FFT_PARAMS%d_%d\n", mode->Fs, mdctSize); + /* cfg->factors */ + for (k = 0; k <= mode->mdct.maxshift; k++) { + NE10_FFT_CFG_TYPE_T cfg; + cfg = (NE10_FFT_CFG_TYPE_T)mode->mdct.kfft[k]->arch_fft->priv; + if (!cfg) + continue; + fprintf(file, "static const ne10_int32_t ne10_factors_%d[%d] = {\n", + mode->mdct.kfft[k]->nfft, (NE10_MAXFACTORS*2)); + for (j = 0; j < (NE10_MAXFACTORS*2); j++) { + fprintf(file, "%d,%c", cfg->factors[j], (j + 16)%15 == 0?'\n':' '); + } + fprintf (file, "};\n"); + } + + /* cfg->twiddles */ + for (k = 0; k <= mode->mdct.maxshift; k++) { + NE10_FFT_CFG_TYPE_T cfg; + cfg = (NE10_FFT_CFG_TYPE_T)mode->mdct.kfft[k]->arch_fft->priv; + if (!cfg) + continue; + fprintf(file, "static const %s ne10_twiddles_%d[%d] = {\n", NE10_FFT_CPX_TYPE_T_STR, mode->mdct.kfft[k]->nfft, mode->mdct.kfft[k]->nfft); - for(j=0;jmdct.kfft[k]->nfft;j++) { + for (j = 0; j < mode->mdct.kfft[k]->nfft; j++) { #if !defined(FIXED_POINT) - fprintf(file, "{%#0.8gf,%#0.8gf},%c", - cfg->twiddles[j].r, cfg->twiddles[j].i,(j+4)%3==0?'\n':' '); + fprintf(file, "{%#0.8gf,%#0.8gf},%c", + cfg->twiddles[j].r, cfg->twiddles[j].i, (j + 4)%3 == 0?'\n':' '); #else - fprintf(file, "{%d,%d},%c", - cfg->twiddles[j].r, cfg->twiddles[j].i,(j+4)%3==0?'\n':' '); + fprintf(file, "{%d,%d},%c", + cfg->twiddles[j].r, cfg->twiddles[j].i, (j + 4)%3 == 0?'\n':' '); #endif - } - fprintf (file, "};\n"); - } - - for(k=0;k<=mode->mdct.maxshift;k++) { - NE10_FFT_CFG_TYPE_T cfg; - cfg = (NE10_FFT_CFG_TYPE_T)mode->mdct.kfft[k]->arch_fft->priv; - if (!cfg) { - fprintf(file, "/* Ne10 does not support scaled FFT for length = %d */\n", + } + fprintf (file, "};\n"); + } + + for (k = 0; k <= mode->mdct.maxshift; k++) { + NE10_FFT_CFG_TYPE_T cfg; + cfg = (NE10_FFT_CFG_TYPE_T)mode->mdct.kfft[k]->arch_fft->priv; + if (!cfg) { + fprintf(file, "/* Ne10 does not support scaled FFT for length = %d */\n", mode->mdct.kfft[k]->nfft); - fprintf(file, "static const arch_fft_state cfg_arch_%d = {\n", mode->mdct.kfft[k]->nfft); - fprintf(file, "0,\n"); - fprintf(file, "NULL\n"); - fprintf(file, "};\n"); - continue; - } - fprintf(file, "static const %s %s_%d = {\n", NE10_FFT_STATE_TYPE_T_STR, + fprintf(file, "static const arch_fft_state cfg_arch_%d = {\n", mode->mdct.kfft[k]->nfft); + fprintf(file, "0,\n"); + fprintf(file, "NULL\n"); + fprintf(file, "};\n"); + continue; + } + fprintf(file, "static const %s %s_%d = {\n", NE10_FFT_STATE_TYPE_T_STR, NE10_FFT_STATE_TYPE_T_STR, mode->mdct.kfft[k]->nfft); - fprintf(file, "%d,\n", cfg->nfft); - fprintf(file, "(ne10_int32_t *)ne10_factors_%d,\n", mode->mdct.kfft[k]->nfft); - fprintf(file, "(%s *)ne10_twiddles_%d,\n", + fprintf(file, "%d,\n", cfg->nfft); + fprintf(file, "(ne10_int32_t *)ne10_factors_%d,\n", mode->mdct.kfft[k]->nfft); + fprintf(file, "(%s *)ne10_twiddles_%d,\n", NE10_FFT_CPX_TYPE_T_STR, mode->mdct.kfft[k]->nfft); - fprintf(file, "NULL,\n"); /* buffer */ - fprintf(file, "(%s *)&ne10_twiddles_%d[%d],\n", + fprintf(file, "NULL,\n"); /* buffer */ + fprintf(file, "(%s *)&ne10_twiddles_%d[%d],\n", NE10_FFT_CPX_TYPE_T_STR, mode->mdct.kfft[k]->nfft, cfg->nfft); #if !defined(FIXED_POINT) - fprintf(file, "/* is_forward_scaled = true */\n"); - fprintf(file, "(ne10_int32_t) 1,\n"); - fprintf(file, "/* is_backward_scaled = false */\n"); - fprintf(file, "(ne10_int32_t) 0,\n"); + fprintf(file, "/* is_forward_scaled = true */\n"); + fprintf(file, "(ne10_int32_t) 1,\n"); + fprintf(file, "/* is_backward_scaled = false */\n"); + fprintf(file, "(ne10_int32_t) 0,\n"); #endif - fprintf(file, "};\n"); + fprintf(file, "};\n"); - fprintf(file, "static const arch_fft_state cfg_arch_%d = {\n", + fprintf(file, "static const arch_fft_state cfg_arch_%d = {\n", mode->mdct.kfft[k]->nfft); - fprintf(file, "1,\n"); - fprintf(file, "(void *)&%s_%d,\n", + fprintf(file, "1,\n"); + fprintf(file, "(void *)&%s_%d,\n", NE10_FFT_STATE_TYPE_T_STR, mode->mdct.kfft[k]->nfft); - fprintf(file, "};\n\n"); - } - fprintf(file, "#endif /* end NE10_FFT_PARAMS%d_%d */\n", mode->Fs, mdctSize); + fprintf(file, "};\n\n"); + } + fprintf(file, "#endif /* end NE10_FFT_PARAMS%d_%d */\n", mode->Fs, mdctSize); } diff --git a/celt/ecintrin.h b/celt/ecintrin.h index 66a4c36ea..649d9e3f5 100644 --- a/celt/ecintrin.h +++ b/celt/ecintrin.h @@ -23,69 +23,69 @@ 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. -*/ + */ /*Some common macros for potential platform-specific optimization.*/ -#include "opus_types.h" +#include "oac_types.h" #include #include #include "arch.h" #if !defined(_ecintrin_H) # define _ecintrin_H (1) -/*Some specific platforms may have optimized intrinsic or OPUS_INLINE assembly +/*Some specific platforms may have optimized intrinsic or OAC_INLINE assembly versions of these functions which can substantially improve performance. - We define macros for them to allow easy incorporation of these non-ANSI + We define macros for them to allow easy incorporation of these non-ANSI features.*/ /*Modern gcc (4.x) can compile the naive versions of min and max with cmov if given an appropriate architecture, but the branchless bit-twiddling versions are just as fast, and do not require any special target architecture. - Earlier gcc versions (3.x) compiled both code to the same assembly + Earlier gcc versions (3.x) compiled both code to the same assembly instructions, because of the way they represented ((_b)>(_a)) internally.*/ -# define EC_MINI(_a,_b) ((_a)+(((_b)-(_a))&-((_b)<(_a)))) +# define EC_MINI(_a, _b) ((_a) + (((_b) - (_a))& -((_b) < (_a)))) /*Count leading zeros. - 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 /* Improve compiler throughput. */ -#else -# include -#endif + 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 /* Improve compiler throughput. */ +# else +# include +# endif /*In _DEBUG mode this is not an intrinsic by default.*/ -# pragma intrinsic(_BitScanReverse) +# pragma intrinsic(_BitScanReverse) -static __inline int ec_bsr(unsigned long _x){ - unsigned long ret; - _BitScanReverse(&ret,_x); - return (int)ret; +static __inline int ec_bsr(unsigned long _x) { + unsigned long ret; + _BitScanReverse(&ret, _x); + return (int)ret; } -# define EC_CLZ0 (1) -# define EC_CLZ(_x) (-ec_bsr(_x)) -#elif defined(ENABLE_TI_DSPLIB) -# include "dsplib.h" -# define EC_CLZ0 (31) -# define EC_CLZ(_x) (_lnorm(_x)) -#elif __GNUC_PREREQ(3,4) -# if INT_MAX>=2147483647 -# define EC_CLZ0 ((int)sizeof(unsigned)*CHAR_BIT) -# define EC_CLZ(_x) (__builtin_clz(_x)) -# elif LONG_MAX>=2147483647L -# define EC_CLZ0 ((int)sizeof(unsigned long)*CHAR_BIT) -# define EC_CLZ(_x) (__builtin_clzl(_x)) +# define EC_CLZ0 (1) +# define EC_CLZ(_x) (-ec_bsr(_x)) +# elif defined(ENABLE_TI_DSPLIB) +# include "dsplib.h" +# define EC_CLZ0 (31) +# define EC_CLZ(_x) (_lnorm(_x)) +# elif __GNUC_PREREQ(3, 4) +# if INT_MAX >= 2147483647 +# define EC_CLZ0 ((int)sizeof(unsigned)*CHAR_BIT) +# define EC_CLZ(_x) (__builtin_clz(_x)) +# elif LONG_MAX >= 2147483647L +# define EC_CLZ0 ((int)sizeof(unsigned long)*CHAR_BIT) +# define EC_CLZ(_x) (__builtin_clzl(_x)) +# endif # endif -#endif -#if defined(EC_CLZ) +# if defined(EC_CLZ) /*Note that __builtin_clz is not defined when _x==0, according to the gcc documentation (and that of the BSR instruction that implements it on x86). - The majority of the time we can never pass it zero. - When we need to, it can be special cased.*/ -# define EC_ILOG(_x) (EC_CLZ0-EC_CLZ(_x)) -#else -int ec_ilog(opus_uint32 _v); -# define EC_ILOG(_x) (ec_ilog(_x)) -#endif + The majority of the time we can never pass it zero. + When we need to, it can be special cased.*/ +# define EC_ILOG(_x) (EC_CLZ0 - EC_CLZ(_x)) +# else +int ec_ilog(oac_uint32 _v); +# define EC_ILOG(_x) (ec_ilog(_x)) +# endif #endif diff --git a/celt/entcode.c b/celt/entcode.c index 70f32016e..a65f15ad5 100644 --- a/celt/entcode.c +++ b/celt/entcode.c @@ -1,5 +1,5 @@ /* Copyright (c) 2001-2011 Timothy B. Terriberry -*/ + */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -23,10 +23,10 @@ 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" +# include "config.h" #endif #include "entcode.h" @@ -35,119 +35,119 @@ #if !defined(EC_CLZ) /*This is a fallback for systems where we don't know how to access a BSR or CLZ instruction (see ecintrin.h). - If you are optimizing Opus on a new platform and it has a native CLZ or - BZR (e.g. cell, MIPS, x86, etc) then making it available to Opus will be + If you are optimizing Oac on a new platform and it has a native CLZ or + BZR (e.g. cell, MIPS, x86, etc) then making it available to Oac will be an easy performance win.*/ -int ec_ilog(opus_uint32 _v){ - /*On a Pentium M, this branchless version tested as the fastest on - 1,000,000,000 random 32-bit integers, edging out a similar version with - branches, and a 256-entry LUT version.*/ - int ret; - int m; - ret=!!_v; - m=!!(_v&0xFFFF0000)<<4; - _v>>=m; - ret|=m; - m=!!(_v&0xFF00)<<3; - _v>>=m; - ret|=m; - m=!!(_v&0xF0)<<2; - _v>>=m; - ret|=m; - m=!!(_v&0xC)<<1; - _v>>=m; - ret|=m; - ret+=!!(_v&0x2); - return ret; +int ec_ilog(oac_uint32 _v) { + /*On a Pentium M, this branchless version tested as the fastest on + 1,000,000,000 random 32-bit integers, edging out a similar version with + branches, and a 256-entry LUT version.*/ + int ret; + int m; + ret = !!_v; + m = !!(_v&0xFFFF0000)<<4; + _v >>= m; + ret |= m; + m = !!(_v&0xFF00)<<3; + _v >>= m; + ret |= m; + m = !!(_v&0xF0)<<2; + _v >>= m; + ret |= m; + m = !!(_v&0xC)<<1; + _v >>= m; + ret |= m; + ret += !!(_v&0x2); + return ret; } #endif #if 1 -/* This is a faster version of ec_tell_frac() that takes advantage +/* This is a faster version of oaci_ec_tell_frac() that takes advantage of the low (1/8 bit) resolution to use just a linear function followed by a lookup to determine the exact transition thresholds. */ -opus_uint32 ec_tell_frac(ec_ctx *_this){ - static const unsigned correction[8] = +oac_uint32 oaci_ec_tell_frac(ec_ctx *_this) { + static const unsigned correction[8] = {35733, 38967, 42495, 46340, 50535, 55109, 60097, 65535}; - opus_uint32 nbits; - opus_uint32 r; - int l; - unsigned b; - nbits=_this->nbits_total<rng); - r=_this->rng>>(l-16); - b = (r>>12)-8; - b += r>correction[b]; - l = (l<<3)+b; - return nbits-l; + oac_uint32 nbits; + oac_uint32 r; + int l; + unsigned b; + nbits = _this->nbits_total<rng); + r = _this->rng>>(l - 16); + b = (r>>12) - 8; + b += r > correction[b]; + l = (l<<3) + b; + return nbits - l; } #else -opus_uint32 ec_tell_frac(ec_ctx *_this){ - opus_uint32 nbits; - opus_uint32 r; - int l; - int i; - /*To handle the non-integral number of bits still left in the encoder/decoder - state, we compute the worst-case number of bits of val that must be - encoded to ensure that the value is inside the range for any possible - subsequent bits. - The computation here is independent of val itself (the decoder does not - even track that value), even though the real number of bits used after - ec_enc_done() may be 1 smaller if rng is a power of two and the - corresponding trailing bits of val are all zeros. - If we did try to track that special case, then coding a value with a - probability of 1/(1<nbits_total<rng); - r=_this->rng>>(l-16); - for(i=BITRES;i-->0;){ - int b; - r=r*r>>15; - b=(int)(r>>16); - l=l<<1|b; - r>>=b; - } - return nbits-l; +oac_uint32 oaci_ec_tell_frac(ec_ctx *_this) { + oac_uint32 nbits; + oac_uint32 r; + int l; + int i; + /*To handle the non-integral number of bits still left in the encoder/decoder + state, we compute the worst-case number of bits of val that must be + encoded to ensure that the value is inside the range for any possible + subsequent bits. + The computation here is independent of val itself (the decoder does not + even track that value), even though the real number of bits used after + oaci_ec_enc_done() may be 1 smaller if rng is a power of two and the + corresponding trailing bits of val are all zeros. + If we did try to track that special case, then coding a value with a + probability of 1/(1<nbits_total<rng); + r = _this->rng>>(l - 16); + for (i = BITRES; i-- > 0;) { + int b; + r = r*r>>15; + b = (int)(r>>16); + l = l<<1|b; + r >>= b; + } + return nbits - l; } #endif #ifdef USE_SMALL_DIV_TABLE /* Result of 2^32/(2*i+1), except for i=0. */ -const opus_uint32 SMALL_DIV_TABLE[129] = { - 0xFFFFFFFF, 0x55555555, 0x33333333, 0x24924924, - 0x1C71C71C, 0x1745D174, 0x13B13B13, 0x11111111, - 0x0F0F0F0F, 0x0D79435E, 0x0C30C30C, 0x0B21642C, - 0x0A3D70A3, 0x097B425E, 0x08D3DCB0, 0x08421084, - 0x07C1F07C, 0x07507507, 0x06EB3E45, 0x06906906, - 0x063E7063, 0x05F417D0, 0x05B05B05, 0x0572620A, - 0x05397829, 0x05050505, 0x04D4873E, 0x04A7904A, - 0x047DC11F, 0x0456C797, 0x04325C53, 0x04104104, - 0x03F03F03, 0x03D22635, 0x03B5CC0E, 0x039B0AD1, - 0x0381C0E0, 0x0369D036, 0x03531DEC, 0x033D91D2, - 0x0329161F, 0x03159721, 0x03030303, 0x02F14990, - 0x02E05C0B, 0x02D02D02, 0x02C0B02C, 0x02B1DA46, - 0x02A3A0FD, 0x0295FAD4, 0x0288DF0C, 0x027C4597, - 0x02702702, 0x02647C69, 0x02593F69, 0x024E6A17, - 0x0243F6F0, 0x0239E0D5, 0x02302302, 0x0226B902, - 0x021D9EAD, 0x0214D021, 0x020C49BA, 0x02040810, - 0x01FC07F0, 0x01F44659, 0x01ECC07B, 0x01E573AC, - 0x01DE5D6E, 0x01D77B65, 0x01D0CB58, 0x01CA4B30, - 0x01C3F8F0, 0x01BDD2B8, 0x01B7D6C3, 0x01B20364, - 0x01AC5701, 0x01A6D01A, 0x01A16D3F, 0x019C2D14, - 0x01970E4F, 0x01920FB4, 0x018D3018, 0x01886E5F, - 0x0183C977, 0x017F405F, 0x017AD220, 0x01767DCE, - 0x01724287, 0x016E1F76, 0x016A13CD, 0x01661EC6, - 0x01623FA7, 0x015E75BB, 0x015AC056, 0x01571ED3, - 0x01539094, 0x01501501, 0x014CAB88, 0x0149539E, - 0x01460CBC, 0x0142D662, 0x013FB013, 0x013C995A, - 0x013991C2, 0x013698DF, 0x0133AE45, 0x0130D190, - 0x012E025C, 0x012B404A, 0x01288B01, 0x0125E227, - 0x01234567, 0x0120B470, 0x011E2EF3, 0x011BB4A4, - 0x01194538, 0x0116E068, 0x011485F0, 0x0112358E, - 0x010FEF01, 0x010DB20A, 0x010B7E6E, 0x010953F3, - 0x01073260, 0x0105197F, 0x0103091B, 0x01010101 +const oac_uint32 OACI_SMALL_DIV_TABLE[129] = { + 0xFFFFFFFF, 0x55555555, 0x33333333, 0x24924924, + 0x1C71C71C, 0x1745D174, 0x13B13B13, 0x11111111, + 0x0F0F0F0F, 0x0D79435E, 0x0C30C30C, 0x0B21642C, + 0x0A3D70A3, 0x097B425E, 0x08D3DCB0, 0x08421084, + 0x07C1F07C, 0x07507507, 0x06EB3E45, 0x06906906, + 0x063E7063, 0x05F417D0, 0x05B05B05, 0x0572620A, + 0x05397829, 0x05050505, 0x04D4873E, 0x04A7904A, + 0x047DC11F, 0x0456C797, 0x04325C53, 0x04104104, + 0x03F03F03, 0x03D22635, 0x03B5CC0E, 0x039B0AD1, + 0x0381C0E0, 0x0369D036, 0x03531DEC, 0x033D91D2, + 0x0329161F, 0x03159721, 0x03030303, 0x02F14990, + 0x02E05C0B, 0x02D02D02, 0x02C0B02C, 0x02B1DA46, + 0x02A3A0FD, 0x0295FAD4, 0x0288DF0C, 0x027C4597, + 0x02702702, 0x02647C69, 0x02593F69, 0x024E6A17, + 0x0243F6F0, 0x0239E0D5, 0x02302302, 0x0226B902, + 0x021D9EAD, 0x0214D021, 0x020C49BA, 0x02040810, + 0x01FC07F0, 0x01F44659, 0x01ECC07B, 0x01E573AC, + 0x01DE5D6E, 0x01D77B65, 0x01D0CB58, 0x01CA4B30, + 0x01C3F8F0, 0x01BDD2B8, 0x01B7D6C3, 0x01B20364, + 0x01AC5701, 0x01A6D01A, 0x01A16D3F, 0x019C2D14, + 0x01970E4F, 0x01920FB4, 0x018D3018, 0x01886E5F, + 0x0183C977, 0x017F405F, 0x017AD220, 0x01767DCE, + 0x01724287, 0x016E1F76, 0x016A13CD, 0x01661EC6, + 0x01623FA7, 0x015E75BB, 0x015AC056, 0x01571ED3, + 0x01539094, 0x01501501, 0x014CAB88, 0x0149539E, + 0x01460CBC, 0x0142D662, 0x013FB013, 0x013C995A, + 0x013991C2, 0x013698DF, 0x0133AE45, 0x0130D190, + 0x012E025C, 0x012B404A, 0x01288B01, 0x0125E227, + 0x01234567, 0x0120B470, 0x011E2EF3, 0x011BB4A4, + 0x01194538, 0x0116E068, 0x011485F0, 0x0112358E, + 0x010FEF01, 0x010DB20A, 0x010B7E6E, 0x010953F3, + 0x01073260, 0x0105197F, 0x0103091B, 0x01010101 }; #endif diff --git a/celt/entcode.h b/celt/entcode.h index de145c719..8a9d5141d 100644 --- a/celt/entcode.h +++ b/celt/entcode.h @@ -23,10 +23,10 @@ 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. -*/ + */ -#include "opus_types.h" -#include "opus_defines.h" +#include "oac_types.h" +#include "oac_defines.h" #if !defined(_entcode_H) # define _entcode_H (1) @@ -34,18 +34,18 @@ # include # include "ecintrin.h" -extern const opus_uint32 SMALL_DIV_TABLE[129]; +extern const oac_uint32 OACI_SMALL_DIV_TABLE[129]; -#ifdef OPUS_ARM_ASM -#define USE_SMALL_DIV_TABLE -#endif +# ifdef OAC_ARM_ASM +# define USE_SMALL_DIV_TABLE +# endif /*OPT: ec_window must be at least 32 bits, but if you have fast arithmetic on a larger type, you can speed up the decoder by using it here.*/ -typedef opus_uint32 ec_window; -typedef struct ec_ctx ec_ctx; -typedef struct ec_ctx ec_enc; -typedef struct ec_ctx ec_dec; +typedef oac_uint32 ec_window; +typedef struct ec_ctx ec_ctx; +typedef struct ec_ctx ec_enc; +typedef struct ec_ctx ec_dec; # define EC_WINDOW_SIZE ((int)sizeof(ec_window)*CHAR_BIT) @@ -57,96 +57,96 @@ typedef struct ec_ctx ec_dec; # define BITRES 3 /*The entropy encoder/decoder context. - We use the same structure for both, so that common functions like ec_tell() + We use the same structure for both, so that common functions like oaci_ec_tell() can be used on either one.*/ -struct ec_ctx{ - /*Buffered input/output.*/ - unsigned char *buf; - /*The size of the buffer.*/ - opus_uint32 storage; - /*The offset at which the last byte containing raw bits was read/written.*/ - opus_uint32 end_offs; - /*Bits that will be read from/written at the end.*/ - ec_window end_window; - /*Number of valid bits in end_window.*/ - int nend_bits; - /*The total number of whole bits read/written. - This does not include partial bits currently in the range coder.*/ - int nbits_total; - /*The offset at which the next range coder byte will be read/written.*/ - opus_uint32 offs; - /*The number of values in the current range.*/ - opus_uint32 rng; - /*In the decoder: the difference between the top of the current range and - the input value, minus one. - In the encoder: the low end of the current range.*/ - opus_uint32 val; - /*In the decoder: the saved normalization factor from ec_decode(). - In the encoder: the number of outstanding carry propagating symbols.*/ - opus_uint32 ext; - /*A buffered input/output symbol, awaiting carry propagation.*/ - int rem; - /*Nonzero if an error occurred.*/ - int error; +struct ec_ctx { + /*Buffered input/output.*/ + unsigned char *buf; + /*The size of the buffer.*/ + oac_uint32 storage; + /*The offset at which the last byte containing raw bits was read/written.*/ + oac_uint32 end_offs; + /*Bits that will be read from/written at the end.*/ + ec_window end_window; + /*Number of valid bits in end_window.*/ + int nend_bits; + /*The total number of whole bits read/written. + This does not include partial bits currently in the range coder.*/ + int nbits_total; + /*The offset at which the next range coder byte will be read/written.*/ + oac_uint32 offs; + /*The number of values in the current range.*/ + oac_uint32 rng; + /*In the decoder: the difference between the top of the current range and + the input value, minus one. + In the encoder: the low end of the current range.*/ + oac_uint32 val; + /*In the decoder: the saved normalization factor from oaci_ec_decode(). + In the encoder: the number of outstanding carry propagating symbols.*/ + oac_uint32 ext; + /*A buffered input/output symbol, awaiting carry propagation.*/ + int rem; + /*Nonzero if an error occurred.*/ + int error; }; -static OPUS_INLINE opus_uint32 ec_range_bytes(ec_ctx *_this){ - return _this->offs; +static OAC_INLINE oac_uint32 oaci_ec_range_bytes(ec_ctx *_this) { + return _this->offs; } -static OPUS_INLINE unsigned char *ec_get_buffer(ec_ctx *_this){ - return _this->buf; +static OAC_INLINE unsigned char *oaci_ec_get_buffer(ec_ctx *_this) { + return _this->buf; } -static OPUS_INLINE int ec_get_error(ec_ctx *_this){ - return _this->error; +static OAC_INLINE int oaci_ec_get_error(ec_ctx *_this) { + return _this->error; } /*Returns the number of bits "used" by the encoded or decoded symbols so far. - This same number can be computed in either the encoder or the decoder, and is + This same number can be computed in either the encoder or the decoder, and is suitable for making coding decisions. - Return: The number of bits. + Return: The number of bits. This will always be slightly larger than the exact value (e.g., all rounding error is in the positive direction).*/ -static OPUS_INLINE int ec_tell(ec_ctx *_this){ - return _this->nbits_total-EC_ILOG(_this->rng); +static OAC_INLINE int oaci_ec_tell(ec_ctx *_this) { + return _this->nbits_total - EC_ILOG(_this->rng); } /*Returns the number of bits "used" by the encoded or decoded symbols so far. - This same number can be computed in either the encoder or the decoder, and is + This same number can be computed in either the encoder or the decoder, and is suitable for making coding decisions. - Return: The number of bits scaled by 2**BITRES. + Return: The number of bits scaled by 2**BITRES. This will always be slightly larger than the exact value (e.g., all rounding error is in the positive direction).*/ -opus_uint32 ec_tell_frac(ec_ctx *_this); +oac_uint32 oaci_ec_tell_frac(ec_ctx *_this); /* Tested exhaustively for all n and for 1<=d<=256 */ -static OPUS_INLINE opus_uint32 celt_udiv(opus_uint32 n, opus_uint32 d) { - celt_sig_assert(d>0); -#ifdef USE_SMALL_DIV_TABLE - if (d>256) - return n/d; - else { - opus_uint32 t, q; - t = EC_ILOG(d&-d); - q = (opus_uint64)SMALL_DIV_TABLE[d>>t]*(n>>(t-1))>>32; - return q+(n-q*d >= d); - } -#else - return n/d; -#endif +static OAC_INLINE oac_uint32 oaci_celt_udiv(oac_uint32 n, oac_uint32 d) { + celt_sig_assert(d > 0); +# ifdef USE_SMALL_DIV_TABLE + if (d > 256) + return n/d; + else { + oac_uint32 t, q; + t = EC_ILOG(d& -d); + q = (oac_uint64)OACI_SMALL_DIV_TABLE[d>>t]*(n>>(t - 1))>>32; + return q + (n - q*d >= d); + } +# else + return n/d; +# endif } -static OPUS_INLINE opus_int32 celt_sudiv(opus_int32 n, opus_int32 d) { - celt_sig_assert(d>0); -#ifdef USE_SMALL_DIV_TABLE - if (n<0) - return -(opus_int32)celt_udiv(-n, d); - else - return celt_udiv(n, d); -#else - return n/d; -#endif +static OAC_INLINE oac_int32 oaci_celt_sudiv(oac_int32 n, oac_int32 d) { + celt_sig_assert(d > 0); +# ifdef USE_SMALL_DIV_TABLE + if (n < 0) + return -(oac_int32)oaci_celt_udiv(-n, d); + else + return oaci_celt_udiv(n, d); +# else + return n/d; +# endif } #endif diff --git a/celt/entdec.c b/celt/entdec.c index 027aa24bc..06a347956 100644 --- a/celt/entdec.c +++ b/celt/entdec.c @@ -23,10 +23,10 @@ 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" +# include "config.h" #endif #include @@ -36,38 +36,38 @@ #include "mfrngcod.h" /*A range decoder. - This is an entropy decoder based upon \cite{Mar79}, which is itself a + This is an entropy decoder based upon \cite{Mar79}, which is itself a rediscovery of the FIFO arithmetic code introduced by \cite{Pas76}. - It is very similar to arithmetic encoding, except that encoding is done with + It is very similar to arithmetic encoding, except that encoding is done with digits in any base, instead of with bits, and so it is faster when using larger bases (i.e.: a byte). - The author claims an average waste of $\frac{1}{2}\log_b(2b)$ bits, where $b$ + The author claims an average waste of $\frac{1}{2}\log_b(2b)$ bits, where $b$ is the base, longer than the theoretical optimum, but to my knowledge there is no published justification for this claim. - This only seems true when using near-infinite precision arithmetic so that + This only seems true when using near-infinite precision arithmetic so that the process is carried out with no rounding errors. - An excellent description of implementation details is available at + An excellent description of implementation details is available at http://www.arturocampos.com/ac_range.html - A recent work \cite{MNW98} which proposes several changes to arithmetic + A recent work \cite{MNW98} which proposes several changes to arithmetic encoding for efficiency actually re-discovers many of the principles behind range encoding, and presents a good theoretical analysis of them. - End of stream is handled by writing out the smallest number of bits that + End of stream is handled by writing out the smallest number of bits that ensures that the stream will be correctly decoded regardless of the value of any subsequent bits. - ec_tell() can be used to determine how many bits were needed to decode + ec_tell() can be used to determine how many bits were needed to decode all the symbols thus far; other data can be packed in the remaining bits of the input buffer. - @PHDTHESIS{Pas76, + @PHDTHESIS{Pas76, author="Richard Clark Pasco", title="Source coding algorithms for fast data compression", school="Dept. of Electrical Engineering, Stanford University", address="Stanford, CA", month=May, year=1976 - } - @INPROCEEDINGS{Mar79, + } + @INPROCEEDINGS{Mar79, author="Martin, G.N.N.", title="Range encoding: an algorithm for removing redundancy from a digitised message", @@ -75,8 +75,8 @@ year=1979, address="Southampton", month=Jul - } - @ARTICLE{MNW98, + } + @ARTICLE{MNW98, author="Alistair Moffat and Radford Neal and Ian H. Witten", title="Arithmetic Coding Revisited", journal="{ACM} Transactions on Information Systems", @@ -86,181 +86,177 @@ pages="256--294", month=Jul, URL="http://www.stanford.edu/class/ee398a/handouts/papers/Moffat98ArithmCoding.pdf" - }*/ + }*/ -static int ec_read_byte(ec_dec *_this){ - return _this->offs<_this->storage?_this->buf[_this->offs++]:0; +static int oaci_ec_read_byte(ec_dec *_this) { + return _this->offs < _this->storage?_this->buf[_this->offs++]:0; } -static int ec_read_byte_from_end(ec_dec *_this){ - return _this->end_offs<_this->storage? - _this->buf[_this->storage-++(_this->end_offs)]:0; +static int oaci_ec_read_byte_from_end(ec_dec *_this) { + return _this->end_offs < _this->storage? + _this->buf[_this->storage - ++(_this->end_offs)]:0; } /*Normalizes the contents of val and rng so that rng lies entirely in the high-order symbol.*/ -static void ec_dec_normalize(ec_dec *_this){ - /*If the range is too small, rescale it and input some bits.*/ - while(_this->rng<=EC_CODE_BOT){ - int sym; - _this->nbits_total+=EC_SYM_BITS; - _this->rng<<=EC_SYM_BITS; - /*Use up the remaining bits from our last symbol.*/ - sym=_this->rem; - /*Read the next value from the input.*/ - _this->rem=ec_read_byte(_this); - /*Take the rest of the bits we need from this new symbol.*/ - sym=(sym<rem)>>(EC_SYM_BITS-EC_CODE_EXTRA); - /*And subtract them from val, capped to be less than EC_CODE_TOP.*/ - _this->val=((_this->val<rng <= EC_CODE_BOT) { + int sym; + _this->nbits_total += EC_SYM_BITS; + _this->rng <<= EC_SYM_BITS; + /*Use up the remaining bits from our last symbol.*/ + sym = _this->rem; + /*Read the next value from the input.*/ + _this->rem = oaci_ec_read_byte(_this); + /*Take the rest of the bits we need from this new symbol.*/ + sym = (sym<rem)>>(EC_SYM_BITS - EC_CODE_EXTRA); + /*And subtract them from val, capped to be less than EC_CODE_TOP.*/ + _this->val = ((_this->val<buf=_buf; - _this->storage=_storage; - _this->end_offs=0; - _this->end_window=0; - _this->nend_bits=0; - /*This is the offset from which ec_tell() will subtract partial bits. - The final value after the ec_dec_normalize() call will be the same as in - the encoder, but we have to compensate for the bits that are added there.*/ - _this->nbits_total=EC_CODE_BITS+1 - -((EC_CODE_BITS-EC_CODE_EXTRA)/EC_SYM_BITS)*EC_SYM_BITS; - _this->offs=0; - _this->rng=1U<rem=ec_read_byte(_this); - _this->val=_this->rng-1-(_this->rem>>(EC_SYM_BITS-EC_CODE_EXTRA)); - _this->error=0; - /*Normalize the interval.*/ - ec_dec_normalize(_this); +void oaci_ec_dec_init(ec_dec *_this, unsigned char *_buf, oac_uint32 _storage) { + _this->buf = _buf; + _this->storage = _storage; + _this->end_offs = 0; + _this->end_window = 0; + _this->nend_bits = 0; + /*This is the offset from which oaci_ec_tell() will subtract partial bits. + The final value after the oaci_ec_dec_normalize() call will be the same as in + the encoder, but we have to compensate for the bits that are added there.*/ + _this->nbits_total = EC_CODE_BITS + 1 + - ((EC_CODE_BITS - EC_CODE_EXTRA)/EC_SYM_BITS)*EC_SYM_BITS; + _this->offs = 0; + _this->rng = 1U<rem = oaci_ec_read_byte(_this); + _this->val = _this->rng - 1 - (_this->rem>>(EC_SYM_BITS - EC_CODE_EXTRA)); + _this->error = 0; + /*Normalize the interval.*/ + oaci_ec_dec_normalize(_this); } -unsigned ec_decode(ec_dec *_this,unsigned _ft){ - unsigned s; - _this->ext=celt_udiv(_this->rng,_ft); - s=(unsigned)(_this->val/_this->ext); - return _ft-EC_MINI(s+1,_ft); +unsigned oaci_ec_decode(ec_dec *_this, unsigned _ft) { + unsigned s; + _this->ext = oaci_celt_udiv(_this->rng, _ft); + s = (unsigned)(_this->val/_this->ext); + return _ft - EC_MINI(s + 1, _ft); } -unsigned ec_decode_bin(ec_dec *_this,unsigned _bits){ - unsigned s; - _this->ext=_this->rng>>_bits; - s=(unsigned)(_this->val/_this->ext); - return (1U<<_bits)-EC_MINI(s+1U,1U<<_bits); +unsigned oaci_ec_decode_bin(ec_dec *_this, unsigned _bits) { + unsigned s; + _this->ext = _this->rng>>_bits; + s = (unsigned)(_this->val/_this->ext); + return (1U<<_bits) - EC_MINI(s + 1U, 1U<<_bits); } -void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh,unsigned _ft){ - opus_uint32 s; - s=IMUL32(_this->ext,_ft-_fh); - _this->val-=s; - _this->rng=_fl>0?IMUL32(_this->ext,_fh-_fl):_this->rng-s; - ec_dec_normalize(_this); +void oaci_ec_dec_update(ec_dec *_this, unsigned _fl, unsigned _fh, unsigned _ft) { + oac_uint32 s; + s = IMUL32(_this->ext, _ft - _fh); + _this->val -= s; + _this->rng = _fl > 0?IMUL32(_this->ext, _fh - _fl):_this->rng - s; + oaci_ec_dec_normalize(_this); } /*The probability of having a "one" is 1/(1<<_logp).*/ -int ec_dec_bit_logp(ec_dec *_this,unsigned _logp){ - opus_uint32 r; - opus_uint32 d; - opus_uint32 s; - int ret; - r=_this->rng; - d=_this->val; - s=r>>_logp; - ret=dval=d-s; - _this->rng=ret?s:r-s; - ec_dec_normalize(_this); - return ret; +int oaci_ec_dec_bit_logp(ec_dec *_this, unsigned _logp) { + oac_uint32 r; + oac_uint32 d; + oac_uint32 s; + int ret; + r = _this->rng; + d = _this->val; + s = r>>_logp; + ret = d < s; + if (!ret) _this->val = d - s; + _this->rng = ret?s:r - s; + oaci_ec_dec_normalize(_this); + return ret; } -int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb){ - opus_uint32 r; - opus_uint32 d; - opus_uint32 s; - opus_uint32 t; - int ret; - s=_this->rng; - d=_this->val; - r=s>>_ftb; - ret=-1; - do{ - t=s; - s=IMUL32(r,_icdf[++ret]); - } - while(dval=d-s; - _this->rng=t-s; - ec_dec_normalize(_this); - return ret; +int oaci_ec_dec_icdf(ec_dec *_this, const unsigned char *_icdf, unsigned _ftb) { + oac_uint32 r; + oac_uint32 d; + oac_uint32 s; + oac_uint32 t; + int ret; + s = _this->rng; + d = _this->val; + r = s>>_ftb; + ret = -1; + do { + t = s; + s = IMUL32(r, _icdf[++ret]); + } while (d < s); + _this->val = d - s; + _this->rng = t - s; + oaci_ec_dec_normalize(_this); + return ret; } -int ec_dec_icdf16(ec_dec *_this,const opus_uint16 *_icdf,unsigned _ftb){ - opus_uint32 r; - opus_uint32 d; - opus_uint32 s; - opus_uint32 t; - int ret; - s=_this->rng; - d=_this->val; - r=s>>_ftb; - ret=-1; - do{ - t=s; - s=IMUL32(r,_icdf[++ret]); - } - while(dval=d-s; - _this->rng=t-s; - ec_dec_normalize(_this); - return ret; +int oaci_ec_dec_icdf16(ec_dec *_this, const oac_uint16 *_icdf, unsigned _ftb) { + oac_uint32 r; + oac_uint32 d; + oac_uint32 s; + oac_uint32 t; + int ret; + s = _this->rng; + d = _this->val; + r = s>>_ftb; + ret = -1; + do { + t = s; + s = IMUL32(r, _icdf[++ret]); + } while (d < s); + _this->val = d - s; + _this->rng = t - s; + oaci_ec_dec_normalize(_this); + return ret; } -opus_uint32 ec_dec_uint(ec_dec *_this,opus_uint32 _ft){ - unsigned ft; - unsigned s; - int ftb; - /*In order to optimize EC_ILOG(), it is undefined for the value 0.*/ - celt_assert(_ft>1); - _ft--; - ftb=EC_ILOG(_ft); - if(ftb>EC_UINT_BITS){ - opus_uint32 t; - ftb-=EC_UINT_BITS; - ft=(unsigned)(_ft>>ftb)+1; - s=ec_decode(_this,ft); - ec_dec_update(_this,s,s+1,ft); - t=(opus_uint32)s<error=1; - return _ft; - } - else{ - _ft++; - s=ec_decode(_this,(unsigned)_ft); - ec_dec_update(_this,s,s+1,(unsigned)_ft); - return s; - } +oac_uint32 oaci_ec_dec_uint(ec_dec *_this, oac_uint32 _ft) { + unsigned ft; + unsigned s; + int ftb; + /*In order to optimize EC_ILOG(), it is undefined for the value 0.*/ + celt_assert(_ft > 1); + _ft--; + ftb = EC_ILOG(_ft); + if (ftb > EC_UINT_BITS) { + oac_uint32 t; + ftb -= EC_UINT_BITS; + ft = (unsigned)(_ft>>ftb) + 1; + s = oaci_ec_decode(_this, ft); + oaci_ec_dec_update(_this, s, s + 1, ft); + t = (oac_uint32)s<error = 1; + return _ft; + } else { + _ft++; + s = oaci_ec_decode(_this, (unsigned)_ft); + oaci_ec_dec_update(_this, s, s + 1, (unsigned)_ft); + return s; + } } -opus_uint32 ec_dec_bits(ec_dec *_this,unsigned _bits){ - ec_window window; - int available; - opus_uint32 ret; - window=_this->end_window; - available=_this->nend_bits; - if((unsigned)available<_bits){ - do{ - window|=(ec_window)ec_read_byte_from_end(_this)<end_window; + available = _this->nend_bits; + if ((unsigned)available < _bits) { + do { + window |= (ec_window)oaci_ec_read_byte_from_end(_this)<>=_bits; - available-=_bits; - _this->end_window=window; - _this->nend_bits=available; - _this->nbits_total+=_bits; - return ret; + ret = (oac_uint32)window&(((oac_uint32)1<<_bits) - 1U); + window >>= _bits; + available -= _bits; + _this->end_window = window; + _this->nend_bits = available; + _this->nbits_total += _bits; + return ret; } diff --git a/celt/entdec.h b/celt/entdec.h index c81f26fdb..1e51b927f 100644 --- a/celt/entdec.h +++ b/celt/entdec.h @@ -23,88 +23,88 @@ 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. -*/ + */ #if !defined(_entdec_H) -# define _entdec_H (1) -# include -# include "entcode.h" +#define _entdec_H (1) +#include +#include "entcode.h" /*Initializes the decoder. - _buf: The input buffer to use. - Return: 0 on success, or a negative value on error.*/ -void ec_dec_init(ec_dec *_this,unsigned char *_buf,opus_uint32 _storage); + _buf: The input buffer to use. + Return: 0 on success, or a negative value on error.*/ +void oaci_ec_dec_init(ec_dec *_this, unsigned char *_buf, oac_uint32 _storage); /*Calculates the cumulative frequency for the next symbol. - This can then be fed into the probability model to determine what that + This can then be fed into the probability model to determine what that symbol is, and the additional frequency information required to advance to the next symbol. - This function cannot be called more than once without a corresponding call to - ec_dec_update(), or decoding will not proceed correctly. - _ft: The total frequency of the symbols in the alphabet the next symbol was + This function cannot be called more than once without a corresponding call to + oaci_ec_dec_update(), or decoding will not proceed correctly. + _ft: The total frequency of the symbols in the alphabet the next symbol was encoded with. - Return: A cumulative frequency representing the encoded symbol. + Return: A cumulative frequency representing the encoded symbol. If the cumulative frequency of all the symbols before the one that was encoded was fl, and the cumulative frequency of all the symbols up to and including the one encoded is fh, then the returned value will fall in the range [fl,fh).*/ -unsigned ec_decode(ec_dec *_this,unsigned _ft); +unsigned oaci_ec_decode(ec_dec *_this, unsigned _ft); -/*Equivalent to ec_decode() with _ft==1<<_bits.*/ -unsigned ec_decode_bin(ec_dec *_this,unsigned _bits); +/*Equivalent to oaci_ec_decode() with _ft==1<<_bits.*/ +unsigned oaci_ec_decode_bin(ec_dec *_this, unsigned _bits); /*Advance the decoder past the next symbol using the frequency information the symbol was encoded with. - Exactly one call to ec_decode() must have been made so that all necessary + Exactly one call to oaci_ec_decode() must have been made so that all necessary intermediate calculations are performed. - _fl: The cumulative frequency of all symbols that come before the symbol + _fl: The cumulative frequency of all symbols that come before the symbol decoded. - _fh: The cumulative frequency of all symbols up to and including the symbol + _fh: The cumulative frequency of all symbols up to and including the symbol decoded. Together with _fl, this defines the range [_fl,_fh) in which the value returned above must fall. - _ft: The total frequency of the symbols in the alphabet the symbol decoded + _ft: The total frequency of the symbols in the alphabet the symbol decoded was encoded in. - This must be the same as passed to the preceding call to ec_decode().*/ -void ec_dec_update(ec_dec *_this,unsigned _fl,unsigned _fh,unsigned _ft); + This must be the same as passed to the preceding call to oaci_ec_decode().*/ +void oaci_ec_dec_update(ec_dec *_this, unsigned _fl, unsigned _fh, unsigned _ft); /* Decode a bit that has a 1/(1<<_logp) probability of being a one */ -int ec_dec_bit_logp(ec_dec *_this,unsigned _logp); +int oaci_ec_dec_bit_logp(ec_dec *_this, unsigned _logp); /*Decodes a symbol given an "inverse" CDF table. - No call to ec_dec_update() is necessary after this call. - _icdf: The "inverse" CDF, such that symbol s falls in the range + No call to oaci_ec_dec_update() is necessary after this call. + _icdf: The "inverse" CDF, such that symbol s falls in the range [s>0?ft-_icdf[s-1]:0,ft-_icdf[s]), where ft=1<<_ftb. The values must be monotonically non-increasing, and the last value must be 0. - _ftb: The number of bits of precision in the cumulative distribution. - Return: The decoded symbol s.*/ -int ec_dec_icdf(ec_dec *_this,const unsigned char *_icdf,unsigned _ftb); + _ftb: The number of bits of precision in the cumulative distribution. + Return: The decoded symbol s.*/ +int oaci_ec_dec_icdf(ec_dec *_this, const unsigned char *_icdf, unsigned _ftb); /*Decodes a symbol given an "inverse" CDF table. - No call to ec_dec_update() is necessary after this call. - _icdf: The "inverse" CDF, such that symbol s falls in the range + No call to oaci_ec_dec_update() is necessary after this call. + _icdf: The "inverse" CDF, such that symbol s falls in the range [s>0?ft-_icdf[s-1]:0,ft-_icdf[s]), where ft=1<<_ftb. The values must be monotonically non-increasing, and the last value must be 0. - _ftb: The number of bits of precision in the cumulative distribution. - Return: The decoded symbol s.*/ -int ec_dec_icdf16(ec_dec *_this,const opus_uint16 *_icdf,unsigned _ftb); + _ftb: The number of bits of precision in the cumulative distribution. + Return: The decoded symbol s.*/ +int oaci_ec_dec_icdf16(ec_dec *_this, const oac_uint16 *_icdf, unsigned _ftb); /*Extracts a raw unsigned integer with a non-power-of-2 range from the stream. - The bits must have been encoded with ec_enc_uint(). - No call to ec_dec_update() is necessary after this call. - _ft: The number of integers that can be decoded (one more than the max). + The bits must have been encoded with oaci_ec_enc_uint(). + No call to oaci_ec_dec_update() is necessary after this call. + _ft: The number of integers that can be decoded (one more than the max). This must be at least 2, and no more than 2**32-1. - Return: The decoded bits.*/ -opus_uint32 ec_dec_uint(ec_dec *_this,opus_uint32 _ft); + Return: The decoded bits.*/ +oac_uint32 oaci_ec_dec_uint(ec_dec *_this, oac_uint32 _ft); /*Extracts a sequence of raw bits from the stream. - The bits must have been encoded with ec_enc_bits(). - No call to ec_dec_update() is necessary after this call. - _ftb: The number of bits to extract. + The bits must have been encoded with oaci_ec_enc_bits(). + No call to oaci_ec_dec_update() is necessary after this call. + _ftb: The number of bits to extract. This must be between 0 and 25, inclusive. - Return: The decoded bits.*/ -opus_uint32 ec_dec_bits(ec_dec *_this,unsigned _ftb); + Return: The decoded bits.*/ +oac_uint32 oaci_ec_dec_bits(ec_dec *_this, unsigned _ftb); #endif diff --git a/celt/entenc.c b/celt/entenc.c index ede00c848..d796dcca3 100644 --- a/celt/entenc.c +++ b/celt/entenc.c @@ -23,7 +23,7 @@ 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. -*/ + */ #if defined(HAVE_CONFIG_H) # include "config.h" @@ -34,9 +34,9 @@ #include "mfrngcod.h" /*A range encoder. - See entdec.c and the references for implementation details \cite{Mar79,MNW98}. + See entdec.c and the references for implementation details \cite{Mar79,MNW98}. - @INPROCEEDINGS{Mar79, + @INPROCEEDINGS{Mar79, author="Martin, G.N.N.", title="Range encoding: an algorithm for removing redundancy from a digitised message", @@ -44,8 +44,8 @@ year=1979, address="Southampton", month=Jul - } - @ARTICLE{MNW98, + } + @ARTICLE{MNW98, author="Alistair Moffat and Radford Neal and Ian H. Witten", title="Arithmetic Coding Revisited", journal="{ACM} Transactions on Information Systems", @@ -55,251 +55,242 @@ pages="256--294", month=Jul, URL="http://www.stanford.edu/class/ee398/handouts/papers/Moffat98ArithmCoding.pdf" - }*/ + }*/ -static int ec_write_byte(ec_enc *_this,unsigned _value){ - if(_this->offs+_this->end_offs>=_this->storage)return -1; - _this->buf[_this->offs++]=(unsigned char)_value; - return 0; +static int oaci_ec_write_byte(ec_enc *_this, unsigned _value) { + if (_this->offs + _this->end_offs >= _this->storage) return -1; + _this->buf[_this->offs++] = (unsigned char)_value; + return 0; } -static int ec_write_byte_at_end(ec_enc *_this,unsigned _value){ - if(_this->offs+_this->end_offs>=_this->storage)return -1; - _this->buf[_this->storage-++(_this->end_offs)]=(unsigned char)_value; - return 0; +static int oaci_ec_write_byte_at_end(ec_enc *_this, unsigned _value) { + if (_this->offs + _this->end_offs >= _this->storage) return -1; + _this->buf[_this->storage - ++(_this->end_offs)] = (unsigned char)_value; + return 0; } /*Outputs a symbol, with a carry bit. - If there is a potential to propagate a carry over several symbols, they are + If there is a potential to propagate a carry over several symbols, they are buffered until it can be determined whether or not an actual carry will occur. - If the counter for the buffered symbols overflows, then the stream becomes + If the counter for the buffered symbols overflows, then the stream becomes undecodable. - This gives a theoretical limit of a few billion symbols in a single packet on + This gives a theoretical limit of a few billion symbols in a single packet on 32-bit systems. - The alternative is to truncate the range in order to force a carry, but + The alternative is to truncate the range in order to force a carry, but requires similar carry tracking in the decoder, needlessly slowing it down.*/ -static void ec_enc_carry_out(ec_enc *_this,int _c){ - if(_c!=EC_SYM_MAX){ - /*No further carry propagation possible, flush buffer.*/ - int carry; - carry=_c>>EC_SYM_BITS; - /*Don't output a byte on the first write. - This compare should be taken care of by branch-prediction thereafter.*/ - if(_this->rem>=0)_this->error|=ec_write_byte(_this,_this->rem+carry); - if(_this->ext>0){ - unsigned sym; - sym=(EC_SYM_MAX+carry)&EC_SYM_MAX; - do _this->error|=ec_write_byte(_this,sym); - while(--(_this->ext)>0); - } - _this->rem=_c&EC_SYM_MAX; - } - else _this->ext++; +static void oaci_ec_enc_carry_out(ec_enc *_this, int _c) { + if (_c != EC_SYM_MAX) { + /*No further carry propagation possible, flush buffer.*/ + int carry; + carry = _c>>EC_SYM_BITS; + /*Don't output a byte on the first write. + This compare should be taken care of by branch-prediction thereafter.*/ + if (_this->rem >= 0) _this->error |= oaci_ec_write_byte(_this, _this->rem + carry); + if (_this->ext > 0) { + unsigned sym; + sym = (EC_SYM_MAX + carry)&EC_SYM_MAX; + do _this->error |= oaci_ec_write_byte(_this, sym); + while (--(_this->ext) > 0); + } + _this->rem = _c&EC_SYM_MAX; + } else _this->ext++; } -static OPUS_INLINE void ec_enc_normalize(ec_enc *_this){ - /*If the range is too small, output some bits and rescale it.*/ - while(_this->rng<=EC_CODE_BOT){ - ec_enc_carry_out(_this,(int)(_this->val>>EC_CODE_SHIFT)); - /*Move the next-to-high-order symbol into the high-order position.*/ - _this->val=(_this->val<rng<<=EC_SYM_BITS; - _this->nbits_total+=EC_SYM_BITS; - } +static OAC_INLINE void oaci_ec_enc_normalize(ec_enc *_this) { + /*If the range is too small, output some bits and rescale it.*/ + while (_this->rng <= EC_CODE_BOT) { + oaci_ec_enc_carry_out(_this, (int)(_this->val>>EC_CODE_SHIFT)); + /*Move the next-to-high-order symbol into the high-order position.*/ + _this->val = (_this->val<rng <<= EC_SYM_BITS; + _this->nbits_total += EC_SYM_BITS; + } } -void ec_enc_init(ec_enc *_this,unsigned char *_buf,opus_uint32 _size){ - _this->buf=_buf; - _this->end_offs=0; - _this->end_window=0; - _this->nend_bits=0; - /*This is the offset from which ec_tell() will subtract partial bits.*/ - _this->nbits_total=EC_CODE_BITS+1; - _this->offs=0; - _this->rng=EC_CODE_TOP; - _this->rem=-1; - _this->val=0; - _this->ext=0; - _this->storage=_size; - _this->error=0; +void oaci_ec_enc_init(ec_enc *_this, unsigned char *_buf, oac_uint32 _size) { + _this->buf = _buf; + _this->end_offs = 0; + _this->end_window = 0; + _this->nend_bits = 0; + /*This is the offset from which oaci_ec_tell() will subtract partial bits.*/ + _this->nbits_total = EC_CODE_BITS + 1; + _this->offs = 0; + _this->rng = EC_CODE_TOP; + _this->rem = -1; + _this->val = 0; + _this->ext = 0; + _this->storage = _size; + _this->error = 0; } -void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft){ - opus_uint32 r; - r=celt_udiv(_this->rng,_ft); - if(_fl>0){ - _this->val+=_this->rng-IMUL32(r,(_ft-_fl)); - _this->rng=IMUL32(r,(_fh-_fl)); - } - else _this->rng-=IMUL32(r,(_ft-_fh)); - ec_enc_normalize(_this); +void oaci_ec_encode(ec_enc *_this, unsigned _fl, unsigned _fh, unsigned _ft) { + oac_uint32 r; + r = oaci_celt_udiv(_this->rng, _ft); + if (_fl > 0) { + _this->val += _this->rng - IMUL32(r, (_ft - _fl)); + _this->rng = IMUL32(r, (_fh - _fl)); + } else _this->rng -= IMUL32(r, (_ft - _fh)); + oaci_ec_enc_normalize(_this); } -void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _bits){ - opus_uint32 r; - r=_this->rng>>_bits; - if(_fl>0){ - _this->val+=_this->rng-IMUL32(r,((1U<<_bits)-_fl)); - _this->rng=IMUL32(r,(_fh-_fl)); - } - else _this->rng-=IMUL32(r,((1U<<_bits)-_fh)); - ec_enc_normalize(_this); +void oaci_ec_encode_bin(ec_enc *_this, unsigned _fl, unsigned _fh, unsigned _bits) { + oac_uint32 r; + r = _this->rng>>_bits; + if (_fl > 0) { + _this->val += _this->rng - IMUL32(r, ((1U<<_bits) - _fl)); + _this->rng = IMUL32(r, (_fh - _fl)); + } else _this->rng -= IMUL32(r, ((1U<<_bits) - _fh)); + oaci_ec_enc_normalize(_this); } /*The probability of having a "one" is 1/(1<<_logp).*/ -void ec_enc_bit_logp(ec_enc *_this,int _val,unsigned _logp){ - opus_uint32 r; - opus_uint32 s; - opus_uint32 l; - r=_this->rng; - l=_this->val; - s=r>>_logp; - r-=s; - if(_val)_this->val=l+r; - _this->rng=_val?s:r; - ec_enc_normalize(_this); +void oaci_ec_enc_bit_logp(ec_enc *_this, int _val, unsigned _logp) { + oac_uint32 r; + oac_uint32 s; + oac_uint32 l; + r = _this->rng; + l = _this->val; + s = r>>_logp; + r -= s; + if (_val) _this->val = l + r; + _this->rng = _val?s:r; + oaci_ec_enc_normalize(_this); } -void ec_enc_icdf(ec_enc *_this,int _s,const unsigned char *_icdf,unsigned _ftb){ - opus_uint32 r; - r=_this->rng>>_ftb; - if(_s>0){ - _this->val+=_this->rng-IMUL32(r,_icdf[_s-1]); - _this->rng=IMUL32(r,_icdf[_s-1]-_icdf[_s]); - } - else _this->rng-=IMUL32(r,_icdf[_s]); - ec_enc_normalize(_this); +void oaci_ec_enc_icdf(ec_enc *_this, int _s, const unsigned char *_icdf, unsigned _ftb) { + oac_uint32 r; + r = _this->rng>>_ftb; + if (_s > 0) { + _this->val += _this->rng - IMUL32(r, _icdf[_s - 1]); + _this->rng = IMUL32(r, _icdf[_s - 1] - _icdf[_s]); + } else _this->rng -= IMUL32(r, _icdf[_s]); + oaci_ec_enc_normalize(_this); } -void ec_enc_icdf16(ec_enc *_this,int _s,const opus_uint16 *_icdf,unsigned _ftb){ - opus_uint32 r; - r=_this->rng>>_ftb; - if(_s>0){ - _this->val+=_this->rng-IMUL32(r,_icdf[_s-1]); - _this->rng=IMUL32(r,_icdf[_s-1]-_icdf[_s]); - } - else _this->rng-=IMUL32(r,_icdf[_s]); - ec_enc_normalize(_this); +void oaci_ec_enc_icdf16(ec_enc *_this, int _s, const oac_uint16 *_icdf, unsigned _ftb) { + oac_uint32 r; + r = _this->rng>>_ftb; + if (_s > 0) { + _this->val += _this->rng - IMUL32(r, _icdf[_s - 1]); + _this->rng = IMUL32(r, _icdf[_s - 1] - _icdf[_s]); + } else _this->rng -= IMUL32(r, _icdf[_s]); + oaci_ec_enc_normalize(_this); } -void ec_enc_uint(ec_enc *_this,opus_uint32 _fl,opus_uint32 _ft){ - unsigned ft; - unsigned fl; - int ftb; - /*In order to optimize EC_ILOG(), it is undefined for the value 0.*/ - celt_assert(_ft>1); - _ft--; - ftb=EC_ILOG(_ft); - if(ftb>EC_UINT_BITS){ - ftb-=EC_UINT_BITS; - ft=(_ft>>ftb)+1; - fl=(unsigned)(_fl>>ftb); - ec_encode(_this,fl,fl+1,ft); - ec_enc_bits(_this,_fl&(((opus_uint32)1< 1); + _ft--; + ftb = EC_ILOG(_ft); + if (ftb > EC_UINT_BITS) { + ftb -= EC_UINT_BITS; + ft = (_ft>>ftb) + 1; + fl = (unsigned)(_fl>>ftb); + oaci_ec_encode(_this, fl, fl + 1, ft); + oaci_ec_enc_bits(_this, _fl&(((oac_uint32)1<end_window; - used=_this->nend_bits; - celt_assert(_bits>0); - if(used+_bits>EC_WINDOW_SIZE){ - do{ - _this->error|=ec_write_byte_at_end(_this,(unsigned)window&EC_SYM_MAX); - window>>=EC_SYM_BITS; - used-=EC_SYM_BITS; +void oaci_ec_enc_bits(ec_enc *_this, oac_uint32 _fl, unsigned _bits) { + ec_window window; + int used; + window = _this->end_window; + used = _this->nend_bits; + celt_assert(_bits > 0); + if (used + _bits > EC_WINDOW_SIZE) { + do { + _this->error |= oaci_ec_write_byte_at_end(_this, (unsigned)window&EC_SYM_MAX); + window >>= EC_SYM_BITS; + used -= EC_SYM_BITS; + } while (used >= EC_SYM_BITS); } - while(used>=EC_SYM_BITS); - } - window|=(ec_window)_fl<end_window=window; - _this->nend_bits=used; - _this->nbits_total+=_bits; + window |= (ec_window)_fl<end_window = window; + _this->nend_bits = used; + _this->nbits_total += _bits; } -void ec_enc_patch_initial_bits(ec_enc *_this,unsigned _val,unsigned _nbits){ - int shift; - unsigned mask; - celt_assert(_nbits<=EC_SYM_BITS); - shift=EC_SYM_BITS-_nbits; - mask=((1<<_nbits)-1)<offs>0){ - /*The first byte has been finalized.*/ - _this->buf[0]=(unsigned char)((_this->buf[0]&~mask)|_val<rem>=0){ - /*The first byte is still awaiting carry propagation.*/ - _this->rem=(_this->rem&~mask)|_val<rng<=(EC_CODE_TOP>>_nbits)){ - /*The renormalization loop has never been run.*/ - _this->val=(_this->val&~((opus_uint32)mask<error=-1; +void oaci_ec_enc_patch_initial_bits(ec_enc *_this, unsigned _val, unsigned _nbits) { + int shift; + unsigned mask; + celt_assert(_nbits <= EC_SYM_BITS); + shift = EC_SYM_BITS - _nbits; + mask = ((1<<_nbits) - 1)<offs > 0) { + /*The first byte has been finalized.*/ + _this->buf[0] = (unsigned char)((_this->buf[0]&~mask)|_val<rem >= 0) { + /*The first byte is still awaiting carry propagation.*/ + _this->rem = (_this->rem&~mask)|_val<rng <= (EC_CODE_TOP>>_nbits)) { + /*The renormalization loop has never been run.*/ + _this->val = (_this->val&~((oac_uint32)mask<error = -1; } -void ec_enc_shrink(ec_enc *_this,opus_uint32 _size){ - celt_assert(_this->offs+_this->end_offs<=_size); - OPUS_MOVE(_this->buf+_size-_this->end_offs, - _this->buf+_this->storage-_this->end_offs,_this->end_offs); - _this->storage=_size; +void oaci_ec_enc_shrink(ec_enc *_this, oac_uint32 _size) { + celt_assert(_this->offs + _this->end_offs <= _size); + OAC_MOVE(_this->buf + _size - _this->end_offs, + _this->buf + _this->storage - _this->end_offs, _this->end_offs); + _this->storage = _size; } -void ec_enc_done(ec_enc *_this){ - ec_window window; - int used; - opus_uint32 msk; - opus_uint32 end; - int l; - /*We output the minimum number of bits that ensures that the symbols encoded - thus far will be decoded correctly regardless of the bits that follow.*/ - l=EC_CODE_BITS-EC_ILOG(_this->rng); - msk=(EC_CODE_TOP-1)>>l; - end=(_this->val+msk)&~msk; - if((end|msk)>=_this->val+_this->rng){ - l++; - msk>>=1; - end=(_this->val+msk)&~msk; - } - while(l>0){ - ec_enc_carry_out(_this,(int)(end>>EC_CODE_SHIFT)); - end=(end<rem>=0||_this->ext>0)ec_enc_carry_out(_this,0); - /*If we have buffered extra bits, flush them as well.*/ - window=_this->end_window; - used=_this->nend_bits; - while(used>=EC_SYM_BITS){ - _this->error|=ec_write_byte_at_end(_this,(unsigned)window&EC_SYM_MAX); - window>>=EC_SYM_BITS; - used-=EC_SYM_BITS; - } - /*Clear any excess space and add any remaining extra bits to the last byte.*/ - if(!_this->error){ - if (_this->buf) OPUS_CLEAR(_this->buf+_this->offs, - _this->storage-_this->offs-_this->end_offs); - if(used>0){ - /*If there's no range coder data at all, give up.*/ - if(_this->end_offs>=_this->storage)_this->error=-1; - else{ - l=-l; - /*If we've busted, don't add too many extra bits to the last byte; it - would corrupt the range coder data, and that's more important.*/ - if(_this->offs+_this->end_offs>=_this->storage&&lerror=-1; +void oaci_ec_enc_done(ec_enc *_this) { + ec_window window; + int used; + oac_uint32 msk; + oac_uint32 end; + int l; + /*We output the minimum number of bits that ensures that the symbols encoded + thus far will be decoded correctly regardless of the bits that follow.*/ + l = EC_CODE_BITS - EC_ILOG(_this->rng); + msk = (EC_CODE_TOP - 1)>>l; + end = (_this->val + msk)&~msk; + if ((end|msk) >= _this->val + _this->rng) { + l++; + msk >>= 1; + end = (_this->val + msk)&~msk; + } + while (l > 0) { + oaci_ec_enc_carry_out(_this, (int)(end>>EC_CODE_SHIFT)); + end = (end<rem >= 0 || _this->ext > 0) oaci_ec_enc_carry_out(_this, 0); + /*If we have buffered extra bits, flush them as well.*/ + window = _this->end_window; + used = _this->nend_bits; + while (used >= EC_SYM_BITS) { + _this->error |= oaci_ec_write_byte_at_end(_this, (unsigned)window&EC_SYM_MAX); + window >>= EC_SYM_BITS; + used -= EC_SYM_BITS; + } + /*Clear any excess space and add any remaining extra bits to the last byte.*/ + if (!_this->error) { + if (_this->buf) OAC_CLEAR(_this->buf + _this->offs, + _this->storage - _this->offs - _this->end_offs); + if (used > 0) { + /*If there's no range coder data at all, give up.*/ + if (_this->end_offs >= _this->storage) _this->error = -1; + else { + l = -l; + /*If we've busted, don't add too many extra bits to the last byte; it + would corrupt the range coder data, and that's more important.*/ + if (_this->offs + _this->end_offs >= _this->storage && l < used) { + window &= (1<error = -1; + } + _this->buf[_this->storage - _this->end_offs - 1] |= (unsigned char)window; + } } - _this->buf[_this->storage-_this->end_offs-1]|=(unsigned char)window; - } } - } } diff --git a/celt/entenc.h b/celt/entenc.h index c7bcf006c..c4b519987 100644 --- a/celt/entenc.h +++ b/celt/entenc.h @@ -23,97 +23,97 @@ 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. -*/ + */ #if !defined(_entenc_H) -# define _entenc_H (1) -# include -# include "entcode.h" +#define _entenc_H (1) +#include +#include "entcode.h" /*Initializes the encoder. - _buf: The buffer to store output bytes in. - _size: The size of the buffer, in chars.*/ -void ec_enc_init(ec_enc *_this,unsigned char *_buf,opus_uint32 _size); + _buf: The buffer to store output bytes in. + _size: The size of the buffer, in chars.*/ +void oaci_ec_enc_init(ec_enc *_this, unsigned char *_buf, oac_uint32 _size); /*Encodes a symbol given its frequency information. - The frequency information must be discernible by the decoder, assuming it + The frequency information must be discernible by the decoder, assuming it has read only the previous symbols from the stream. - It is allowable to change the frequency information, or even the entire + It is allowable to change the frequency information, or even the entire source alphabet, so long as the decoder can tell from the context of the previously encoded information that it is supposed to do so as well. - _fl: The cumulative frequency of all symbols that come before the one to be + _fl: The cumulative frequency of all symbols that come before the one to be encoded. - _fh: The cumulative frequency of all symbols up to and including the one to + _fh: The cumulative frequency of all symbols up to and including the one to be encoded. Together with _fl, this defines the range [_fl,_fh) in which the decoded value will fall. - _ft: The sum of the frequencies of all the symbols*/ -void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft); + _ft: The sum of the frequencies of all the symbols*/ +void oaci_ec_encode(ec_enc *_this, unsigned _fl, unsigned _fh, unsigned _ft); -/*Equivalent to ec_encode() with _ft==1<<_bits.*/ -void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _bits); +/*Equivalent to oaci_ec_encode() with _ft==1<<_bits.*/ +void oaci_ec_encode_bin(ec_enc *_this, unsigned _fl, unsigned _fh, unsigned _bits); /* Encode a bit that has a 1/(1<<_logp) probability of being a one */ -void ec_enc_bit_logp(ec_enc *_this,int _val,unsigned _logp); +void oaci_ec_enc_bit_logp(ec_enc *_this, int _val, unsigned _logp); /*Encodes a symbol given an "inverse" CDF table. - _s: The index of the symbol to encode. - _icdf: The "inverse" CDF, such that symbol _s falls in the range + _s: The index of the symbol to encode. + _icdf: The "inverse" CDF, such that symbol _s falls in the range [_s>0?ft-_icdf[_s-1]:0,ft-_icdf[_s]), where ft=1<<_ftb. The values must be monotonically non-increasing, and the last value must be 0. - _ftb: The number of bits of precision in the cumulative distribution.*/ -void ec_enc_icdf(ec_enc *_this,int _s,const unsigned char *_icdf,unsigned _ftb); + _ftb: The number of bits of precision in the cumulative distribution.*/ +void oaci_ec_enc_icdf(ec_enc *_this, int _s, const unsigned char *_icdf, unsigned _ftb); /*Encodes a symbol given an "inverse" CDF table. - _s: The index of the symbol to encode. - _icdf: The "inverse" CDF, such that symbol _s falls in the range + _s: The index of the symbol to encode. + _icdf: The "inverse" CDF, such that symbol _s falls in the range [_s>0?ft-_icdf[_s-1]:0,ft-_icdf[_s]), where ft=1<<_ftb. The values must be monotonically non-increasing, and the last value must be 0. - _ftb: The number of bits of precision in the cumulative distribution.*/ -void ec_enc_icdf16(ec_enc *_this,int _s,const opus_uint16 *_icdf,unsigned _ftb); + _ftb: The number of bits of precision in the cumulative distribution.*/ +void oaci_ec_enc_icdf16(ec_enc *_this, int _s, const oac_uint16 *_icdf, unsigned _ftb); /*Encodes a raw unsigned integer in the stream. - _fl: The integer to encode. - _ft: The number of integers that can be encoded (one more than the max). + _fl: The integer to encode. + _ft: The number of integers that can be encoded (one more than the max). This must be at least 2, and no more than 2**32-1.*/ -void ec_enc_uint(ec_enc *_this,opus_uint32 _fl,opus_uint32 _ft); +void oaci_ec_enc_uint(ec_enc *_this, oac_uint32 _fl, oac_uint32 _ft); /*Encodes a sequence of raw bits in the stream. - _fl: The bits to encode. - _ftb: The number of bits to encode. + _fl: The bits to encode. + _ftb: The number of bits to encode. This must be between 1 and 25, inclusive.*/ -void ec_enc_bits(ec_enc *_this,opus_uint32 _fl,unsigned _ftb); +void oaci_ec_enc_bits(ec_enc *_this, oac_uint32 _fl, unsigned _ftb); /*Overwrites a few bits at the very start of an existing stream, after they have already been encoded. - This makes it possible to have a few flags up front, where it is easy for + This makes it possible to have a few flags up front, where it is easy for decoders to access them without parsing the whole stream, even if their values are not determined until late in the encoding process, without having to buffer all the intermediate symbols in the encoder. - In order for this to work, at least _nbits bits must have already been + In order for this to work, at least _nbits bits must have already been encoded using probabilities that are an exact power of two. - The encoder can verify the number of encoded bits is sufficient, but cannot + The encoder can verify the number of encoded bits is sufficient, but cannot check this latter condition. - _val: The bits to encode (in the least _nbits significant bits). + _val: The bits to encode (in the least _nbits significant bits). They will be decoded in order from most-significant to least. - _nbits: The number of bits to overwrite. + _nbits: The number of bits to overwrite. This must be no more than 8.*/ -void ec_enc_patch_initial_bits(ec_enc *_this,unsigned _val,unsigned _nbits); +void oaci_ec_enc_patch_initial_bits(ec_enc *_this, unsigned _val, unsigned _nbits); /*Compacts the data to fit in the target size. - This moves up the raw bits at the end of the current buffer so they are at + This moves up the raw bits at the end of the current buffer so they are at the end of the new buffer size. - The caller must ensure that the amount of data that's already been written + The caller must ensure that the amount of data that's already been written will fit in the new size. - _size: The number of bytes in the new buffer. + _size: The number of bytes in the new buffer. This must be large enough to contain the bits already written, and must be no larger than the existing size.*/ -void ec_enc_shrink(ec_enc *_this,opus_uint32 _size); +void oaci_ec_enc_shrink(ec_enc *_this, oac_uint32 _size); /*Indicates that there are no more symbols to encode. - All remaining output bytes are flushed to the output buffer. - ec_enc_init() must be called before the encoder can be used again.*/ -void ec_enc_done(ec_enc *_this); + All remaining output bytes are flushed to the output buffer. + ec_enc_init() must be called before the encoder can be used again.*/ +void oaci_ec_enc_done(ec_enc *_this); #endif diff --git a/celt/fixed_c5x.h b/celt/fixed_c5x.h index ea95a998c..d128e5d0b 100644 --- a/celt/fixed_c5x.h +++ b/celt/fixed_c5x.h @@ -2,7 +2,7 @@ /** @file fixed_c5x.h @brief Fixed-point operations for the TI C5x DSP family -*/ + */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -26,7 +26,7 @@ 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. -*/ + */ #ifndef FIXED_C5X_H #define FIXED_C5X_H @@ -34,46 +34,45 @@ #include "dsplib.h" #undef IMUL32 -static OPUS_INLINE long IMUL32(long i, long j) -{ - long ac0, ac1; - ac0 = _lmpy(i>>16,j); - ac1 = ac0 + _lmpy(i,j>>16); - return _lmpyu(i,j) + (ac1<<16); +static OAC_INLINE long IMUL32(long i, long j) { + long ac0, ac1; + ac0 = _lmpy(i>>16, j); + ac1 = ac0 + _lmpy(i, j>>16); + return _lmpyu(i, j) + (ac1<<16); } #undef MAX16 -#define MAX16(a,b) _max(a,b) +#define MAX16(a, b) _max(a, b) #undef MIN16 -#define MIN16(a,b) _min(a,b) +#define MIN16(a, b) _min(a, b) #undef MAX32 -#define MAX32(a,b) _lmax(a,b) +#define MAX32(a, b) _lmax(a, b) #undef MIN32 -#define MIN32(a,b) _lmin(a,b) +#define MIN32(a, b) _lmin(a, b) #undef VSHR32 -#define VSHR32(a, shift) _lshl(a,-(shift)) +#define VSHR32(a, shift) _lshl(a, -(shift)) #undef MULT16_16_Q15 -#define MULT16_16_Q15(a,b) (_smpy(a,b)) +#define MULT16_16_Q15(a, b) (_smpy(a, b)) #undef MULT16_16SU -#define MULT16_16SU(a,b) _lmpysu(a,b) +#define MULT16_16SU(a, b) _lmpysu(a, b) #undef MULT_16_16 -#define MULT_16_16(a,b) _lmpy(a,b) +#define MULT_16_16(a, b) _lmpy(a, b) /* FIXME: This is technically incorrect and is bound to cause problems. Is there any cleaner solution? */ #undef MULT16_32_Q15 -#define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),(b)),15)) +#define MULT16_32_Q15(a, b) ADD32(SHL(MULT16_16((a), SHR((b), 16)), 1), SHR(MULT16_16SU((a), (b)), 15)) -#define celt_ilog2(x) (30 - _lnorm(x)) +#define oaci_celt_ilog2(x) (30 - _lnorm(x)) #define OVERRIDE_CELT_ILOG2 -#define celt_maxabs16(x, len) MAX32(EXTEND32(maxval((DATA *)x, len)),-EXTEND32(minval((DATA *)x, len))) +#define oaci_celt_maxabs16(x, len) MAX32(EXTEND32(maxval((DATA *)x, len)), -EXTEND32(minval((DATA *)x, len))) #define OVERRIDE_CELT_MAXABS16 #endif /* FIXED_C5X_H */ diff --git a/celt/fixed_c6x.h b/celt/fixed_c6x.h index bb6ad9278..90b5879f9 100644 --- a/celt/fixed_c6x.h +++ b/celt/fixed_c6x.h @@ -2,7 +2,7 @@ /** @file fixed_c6x.h @brief Fixed-point operations for the TI C6x DSP family -*/ + */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -26,45 +26,45 @@ 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. -*/ + */ #ifndef FIXED_C6X_H -#define FIXED_C6X_H +# define FIXED_C6X_H -#undef MULT16_16SU -#define MULT16_16SU(a,b) _mpysu(a,b) +# undef MULT16_16SU +# define MULT16_16SU(a, b) _mpysu(a, b) -#undef MULT_16_16 -#define MULT_16_16(a,b) _mpy(a,b) +# undef MULT_16_16 +# define MULT_16_16(a, b) _mpy(a, b) -#define celt_ilog2(x) (30 - _norm(x)) -#define OVERRIDE_CELT_ILOG2 +# define oaci_celt_ilog2(x) (30 - _norm(x)) +# define OVERRIDE_CELT_ILOG2 -#undef MULT16_32_Q15 -#define MULT16_32_Q15(a,b) (_mpylill(a, b) >> 15) +# undef MULT16_32_Q15 +# define MULT16_32_Q15(a, b) (_mpylill(a, b)>>15) -#if 0 -#include "dsplib.h" +# if 0 +# include "dsplib.h" -#undef MAX16 -#define MAX16(a,b) _max(a,b) +# undef MAX16 +# define MAX16(a, b) _max(a, b) -#undef MIN16 -#define MIN16(a,b) _min(a,b) +# undef MIN16 +# define MIN16(a, b) _min(a, b) -#undef MAX32 -#define MAX32(a,b) _lmax(a,b) +# undef MAX32 +# define MAX32(a, b) _lmax(a, b) -#undef MIN32 -#define MIN32(a,b) _lmin(a,b) +# undef MIN32 +# define MIN32(a, b) _lmin(a, b) -#undef VSHR32 -#define VSHR32(a, shift) _lshl(a,-(shift)) +# undef VSHR32 +# define VSHR32(a, shift) _lshl(a, -(shift)) -#undef MULT16_16_Q15 -#define MULT16_16_Q15(a,b) (_smpy(a,b)) +# undef MULT16_16_Q15 +# define MULT16_16_Q15(a, b) (_smpy(a, b)) -#define celt_maxabs16(x, len) MAX32(EXTEND32(maxval((DATA *)x, len)),-EXTEND32(minval((DATA *)x, len))) -#define OVERRIDE_CELT_MAXABS16 +# define oaci_celt_maxabs16(x, len) MAX32(EXTEND32(maxval((DATA *)x, len)), -EXTEND32(minval((DATA *)x, len))) +# define OVERRIDE_CELT_MAXABS16 -#endif /* FIXED_C6X_H */ +# endif /* FIXED_C6X_H */ diff --git a/celt/fixed_debug.h b/celt/fixed_debug.h index 34c3646d6..491fd3176 100644 --- a/celt/fixed_debug.h +++ b/celt/fixed_debug.h @@ -3,7 +3,7 @@ /** @file fixed_debug.h @brief Fixed-point operations with debugging -*/ + */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -27,822 +27,748 @@ 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. -*/ + */ #ifndef FIXED_DEBUG_H #define FIXED_DEBUG_H #include -#include "opus_defines.h" +#include "oac_defines.h" #ifdef CELT_C -OPUS_EXPORT opus_int64 celt_mips=0; +OAC_EXPORT oac_int64 celt_mips = 0; #else -extern opus_int64 celt_mips; -#endif - -#define MULT16_16U(a,b) ((opus_uint32)(a)*(opus_uint32)(b)) -#define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(opus_uint16)(b)) -#define MULT32_32_Q31(a,b) ADD32(ADD32(SHL32(MULT16_16(SHR32((a),16),SHR((b),16)),1), SHR32(MULT16_16SU(SHR32((a),16),((b)&0x0000ffff)),15)), SHR32(MULT16_16SU(SHR32((b),16),((a)&0x0000ffff)),15)) -#define MULT32_32_P31(a,b) ADD32(SHL32(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(opus_int32)(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff))>>(16+7)) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) ) -#define MULT32_32_P31_ovflw(a,b) ADD32_ovflw(SHL32(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(opus_int32)(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff))>>(16+7)) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) ) -#define MULT32_32_Q32(a,b) ADD32(ADD32(MULT16_16(SHR((a),16),SHR((b),16)), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),16)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),16)) +extern oac_int64 celt_mips; +#endif + +#define MULT16_16U(a, b) ((oac_uint32)(a)*(oac_uint32)(b)) +#define MULT16_16SU(a, b) ((oac_val32)(oac_val16)(a)*(oac_val32)(oac_uint16)(b)) +#define MULT32_32_Q31(a, \ + b) ADD32(ADD32(SHL32(MULT16_16(SHR32((a), 16), SHR((b), 16)), 1), \ + SHR32(MULT16_16SU(SHR32((a), 16), ((b)&0x0000ffff)), 15)), SHR32(MULT16_16SU(SHR32((b), 16), ((a)&0x0000ffff)), 15)) +#define MULT32_32_P31(a, b) ADD32(SHL32(MULT16_16(SHR((a), 16), SHR((b), 16)), 1), \ + SHR32(128 + (oac_int32)(MULT16_16U(((a)&0x0000ffff), ((b)&0x0000ffff))>>(16 + 7)) + SHR32(MULT16_16SU(SHR((a), 16), \ + ((b)&0x0000ffff)), 7) + SHR32(MULT16_16SU(SHR((b), 16), ((a)&0x0000ffff)), 7), 8)) +#define MULT32_32_P31_ovflw(a, b) ADD32_ovflw(SHL32(MULT16_16(SHR((a), 16), SHR((b), 16)), 1), \ + SHR32(128 + (oac_int32)(MULT16_16U(((a)&0x0000ffff), ((b)&0x0000ffff))>>(16 + 7)) + SHR32(MULT16_16SU(SHR((a), 16), \ + ((b)&0x0000ffff)), 7) + SHR32(MULT16_16SU(SHR((b), 16), ((a)&0x0000ffff)), 7), 8)) +#define MULT32_32_Q32(a, \ + b) ADD32(ADD32(MULT16_16(SHR((a), 16), SHR((b), 16)), \ + SHR(MULT16_16SU(SHR((a), 16), ((b)&0x0000ffff)), 16)), SHR(MULT16_16SU(SHR((b), 16), ((a)&0x0000ffff)), 16)) /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ -#define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR32((b),16)), SHR32(MULT16_16SU((a),((b)&0x0000ffff)),16)) +#define MULT16_32_Q16(a, b) ADD32(MULT16_16((a), SHR32((b), 16)), SHR32(MULT16_16SU((a), ((b)&0x0000ffff)), 16)) -#define MULT16_32_P16(a,b) MULT16_32_PX(a,b,16) +#define MULT16_32_P16(a, b) MULT16_32_PX(a, b, 16) -#define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits)))) -#define QCONST32(x,bits) ((opus_val32)(.5+(x)*(((opus_val64)1)<<(bits)))) -#define GCONST2(x,bits) ((celt_glog)(.5+(x)*(((celt_glog)1)<<(bits)))) -#define GCONST(x) GCONST2((x),DB_SHIFT) +#define QCONST16(x, bits) ((oac_val16)(.5 + (x)*(((oac_val32)1)<<(bits)))) +#define QCONST32(x, bits) ((oac_val32)(.5 + (x)*(((oac_val64)1)<<(bits)))) +#define GCONST2(x, bits) ((celt_glog)(.5 + (x)*(((celt_glog)1)<<(bits)))) +#define GCONST(x) GCONST2((x), DB_SHIFT) -#define VERIFY_SHORT(x) ((x)<=32767&&(x)>=-32768) -#define VERIFY_INT(x) ((x)<=2147483647LL&&(x)>=-2147483648LL) -#define VERIFY_UINT(x) ((x)<=(2147483647LLU<<1)) +#define VERIFY_SHORT(x) ((x) <= 32767 && (x) >= -32768) +#define VERIFY_INT(x) ((x) <= 2147483647LL && (x) >= -2147483648LL) +#define VERIFY_UINT(x) ((x) <= (2147483647LLU<<1)) -#define SHR(a,b) SHR32(a,b) -#define PSHR(a,b) PSHR32(a,b) +#define SHR(a, b) SHR32(a, b) +#define PSHR(a, b) PSHR32(a, b) /** Add two 32-bit values, ignore any overflows */ -#define ADD32_ovflw(a,b) (celt_mips+=2,(opus_val32)((opus_uint32)(a)+(opus_uint32)(b))) +#define ADD32_ovflw(a, b) (celt_mips += 2, (oac_val32)((oac_uint32)(a) + (oac_uint32)(b))) /** Subtract two 32-bit values, ignore any overflows */ -#define SUB32_ovflw(a,b) (celt_mips+=2,(opus_val32)((opus_uint32)(a)-(opus_uint32)(b))) +#define SUB32_ovflw(a, b) (celt_mips += 2, (oac_val32)((oac_uint32)(a) - (oac_uint32)(b))) /* Avoid MSVC warning C4146: unary minus operator applied to unsigned type */ /** Negate 32-bit value, ignore any overflows */ -#define NEG32_ovflw(a) (celt_mips+=2,(opus_val32)(0-(opus_uint32)(a))) +#define NEG32_ovflw(a) (celt_mips += 2, (oac_val32)(0 - (oac_uint32)(a))) /** 32-bit shift left, ignoring overflows */ -#define SHL32_ovflw(a,shift) ((opus_int32)((opus_uint32)(a)<<(shift))) +#define SHL32_ovflw(a, shift) ((oac_int32)((oac_uint32)(a)<<(shift))) /** 32-bit arithmetic shift right with rounding-to-nearest, ignoring overflows */ -#define PSHR32_ovflw(a,shift) (SHR32(ADD32_ovflw(a, (EXTEND32(1)<<(shift)>>1)),shift)) +#define PSHR32_ovflw(a, shift) (SHR32(ADD32_ovflw(a, (EXTEND32(1)<<(shift)>>1)), shift)) -static OPUS_INLINE short NEG16(int x) -{ - int res; - if (!VERIFY_SHORT(x)) - { - fprintf (stderr, "NEG16: input is not short: %d\n", (int)x); +static OAC_INLINE short NEG16(int x) { + int res; + if (!VERIFY_SHORT(x)) { + fprintf (stderr, "NEG16: input is not short: %d\n", (int)x); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = -x; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "NEG16: output is not short: %d\n", (int)res); + } + res = -x; + if (!VERIFY_SHORT(res)) { + fprintf (stderr, "NEG16: output is not short: %d\n", (int)res); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips++; - return res; + } + celt_mips++; + return res; } -static OPUS_INLINE int NEG32(opus_int64 x) -{ - opus_int64 res; - if (!VERIFY_INT(x)) - { - fprintf (stderr, "NEG16: input is not int: %d\n", (int)x); +static OAC_INLINE int NEG32(oac_int64 x) { + oac_int64 res; + if (!VERIFY_INT(x)) { + fprintf (stderr, "NEG16: input is not int: %d\n", (int)x); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = -x; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "NEG16: output is not int: %d\n", (int)res); + } + res = -x; + if (!VERIFY_INT(res)) { + fprintf (stderr, "NEG16: output is not int: %d\n", (int)res); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips+=2; - return res; + } + celt_mips += 2; + return res; } #define EXTRACT16(x) EXTRACT16_(x, __FILE__, __LINE__) -static OPUS_INLINE short EXTRACT16_(int x, char *file, int line) -{ - int res; - if (!VERIFY_SHORT(x)) - { - fprintf (stderr, "EXTRACT16: input is not short: %d in %s: line %d\n", x, file, line); +static OAC_INLINE short EXTRACT16_(int x, char *file, int line) { + int res; + if (!VERIFY_SHORT(x)) { + fprintf (stderr, "EXTRACT16: input is not short: %d in %s: line %d\n", x, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = x; - celt_mips++; - return res; + } + res = x; + celt_mips++; + return res; } #define EXTEND32(x) EXTEND32_(x, __FILE__, __LINE__) -static OPUS_INLINE int EXTEND32_(int x, char *file, int line) -{ - int res; - if (!VERIFY_SHORT(x)) - { - fprintf (stderr, "EXTEND32: input is not short: %d in %s: line %d\n", x, file, line); +static OAC_INLINE int EXTEND32_(int x, char *file, int line) { + int res; + if (!VERIFY_SHORT(x)) { + fprintf (stderr, "EXTEND32: input is not short: %d in %s: line %d\n", x, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = x; - celt_mips++; - return res; + } + res = x; + celt_mips++; + return res; } #define SHR16(a, shift) SHR16_(a, shift, __FILE__, __LINE__) -static OPUS_INLINE short SHR16_(int a, int shift, char *file, int line) -{ - int res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift)) - { - fprintf (stderr, "SHR16: inputs are not short: %d >> %d in %s: line %d\n", a, shift, file, line); +static OAC_INLINE short SHR16_(int a, int shift, char *file, int line) { + int res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift)) { + fprintf (stderr, "SHR16: inputs are not short: %d >> %d in %s: line %d\n", a, shift, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = a>>shift; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "SHR16: output is not short: %d in %s: line %d\n", res, file, line); + } + res = a>>shift; + if (!VERIFY_SHORT(res)) { + fprintf (stderr, "SHR16: output is not short: %d in %s: line %d\n", res, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips++; - return res; + } + celt_mips++; + return res; } #define SHL16(a, shift) SHL16_(a, shift, __FILE__, __LINE__) -static OPUS_INLINE short SHL16_(int a, int shift, char *file, int line) -{ - 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); +static OAC_INLINE short SHL16_(int a, int shift, char *file, int line) { + oac_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); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = (opus_int32)((opus_uint32)a<>shift; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "SHR32: output is not int: %d\n", (int)res); + } + res = a>>shift; + if (!VERIFY_INT(res)) { + fprintf (stderr, "SHR32: output is not int: %d\n", (int)res); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips+=2; - return res; + } + celt_mips += 2; + return res; } #define SHL32(a, shift) SHL32_(a, shift, __FILE__, __LINE__) -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", (long long)a, shift, file, line); +static OAC_INLINE int SHL32_(oac_int64 a, int shift, char *file, int line) { + oac_int64 res; + if (!VERIFY_INT(a) || !VERIFY_SHORT(shift)) { + 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); + celt_assert(0); #endif - } - res = (opus_int64)((opus_uint64)a<>1))),shift)) -#define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) +#define PSHR32(a, shift) (celt_mips--, SHR32(ADD32((a), (((oac_val32)(1)<<((shift))>>1))), shift)) +#define VSHR32(a, shift) (((shift) > 0) ? SHR32(a, shift) : SHL32(a, -(shift))) -#define SHR64(a,shift) (celt_mips++,(a) >> (shift)) +#define SHR64(a, shift) (celt_mips++, (a)>>(shift)) -#define ROUND16(x,a) (celt_mips--,EXTRACT16(PSHR32((x),(a)))) -#define SROUND16(x,a) (celt_mips--,EXTRACT16(SATURATE(PSHR32(x,a), 32767))); +#define ROUND16(x, a) (celt_mips--, EXTRACT16(PSHR32((x), (a)))) +#define SROUND16(x, a) (celt_mips--, EXTRACT16(SATURATE(PSHR32(x, a), 32767))); -#define HALF16(x) (SHR16(x,1)) -#define HALF32(x) (SHR32(x,1)) +#define HALF16(x) (SHR16(x, 1)) +#define HALF32(x) (SHR32(x, 1)) #define ADD16(a, b) ADD16_(a, b, __FILE__, __LINE__) -static OPUS_INLINE short ADD16_(int a, int b, char *file, int line) -{ - int res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "ADD16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); +static OAC_INLINE short ADD16_(int a, int b, char *file, int line) { + int res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { + fprintf (stderr, "ADD16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = a+b; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "ADD16: output is not short: %d+%d=%d in %s: line %d\n", a,b,res, file, line); + } + res = a + b; + if (!VERIFY_SHORT(res)) { + fprintf (stderr, "ADD16: output is not short: %d+%d=%d in %s: line %d\n", a, b, res, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips++; - return res; + } + celt_mips++; + return res; } #define SUB16(a, b) SUB16_(a, b, __FILE__, __LINE__) -static OPUS_INLINE short SUB16_(int a, int b, char *file, int line) -{ - int res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "SUB16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); +static OAC_INLINE short SUB16_(int a, int b, char *file, int line) { + int res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { + fprintf (stderr, "SUB16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = a-b; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "SUB16: output is not short: %d in %s: line %d\n", res, file, line); + } + res = a - b; + if (!VERIFY_SHORT(res)) { + fprintf (stderr, "SUB16: output is not short: %d in %s: line %d\n", res, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips++; - return res; + } + celt_mips++; + return res; } #define ADD32(a, b) ADD32_(a, b, __FILE__, __LINE__) -static OPUS_INLINE int ADD32_(opus_int64 a, opus_int64 b, char *file, int line) -{ - opus_int64 res; - if (!VERIFY_INT(a) || !VERIFY_INT(b)) - { - fprintf (stderr, "ADD32: inputs are not int: %d %d in %s: line %d\n", (int)a, (int)b, file, line); +static OAC_INLINE int ADD32_(oac_int64 a, oac_int64 b, char *file, int line) { + oac_int64 res; + if (!VERIFY_INT(a) || !VERIFY_INT(b)) { + fprintf (stderr, "ADD32: inputs are not int: %d %d in %s: line %d\n", (int)a, (int)b, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = a+b; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "ADD32: output is not int: %d in %s: line %d\n", (int)res, file, line); + } + res = a + b; + if (!VERIFY_INT(res)) { + fprintf (stderr, "ADD32: output is not int: %d in %s: line %d\n", (int)res, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips+=2; - return res; + } + celt_mips += 2; + return res; } #define SUB32(a, b) SUB32_(a, b, __FILE__, __LINE__) -static OPUS_INLINE int SUB32_(opus_int64 a, opus_int64 b, char *file, int line) -{ - opus_int64 res; - if (!VERIFY_INT(a) || !VERIFY_INT(b)) - { - fprintf (stderr, "SUB32: inputs are not int: %d %d in %s: line %d\n", (int)a, (int)b, file, line); +static OAC_INLINE int SUB32_(oac_int64 a, oac_int64 b, char *file, int line) { + oac_int64 res; + if (!VERIFY_INT(a) || !VERIFY_INT(b)) { + fprintf (stderr, "SUB32: inputs are not int: %d %d in %s: line %d\n", (int)a, (int)b, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = a-b; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "SUB32: output is not int: %d in %s: line %d\n", (int)res, file, line); + } + res = a - b; + if (!VERIFY_INT(res)) { + fprintf (stderr, "SUB32: output is not int: %d in %s: line %d\n", (int)res, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips+=2; - return res; + } + celt_mips += 2; + return res; } #undef UADD32 #define UADD32(a, b) UADD32_(a, b, __FILE__, __LINE__) -static OPUS_INLINE unsigned int UADD32_(opus_uint64 a, opus_uint64 b, char *file, int line) -{ - opus_uint64 res; - if (!VERIFY_UINT(a) || !VERIFY_UINT(b)) - { - fprintf (stderr, "UADD32: inputs are not uint32: %llu %llu in %s: line %d\n", (unsigned long long)a, (unsigned long long)b, file, line); +static OAC_INLINE unsigned int UADD32_(oac_uint64 a, oac_uint64 b, char *file, int line) { + oac_uint64 res; + if (!VERIFY_UINT(a) || !VERIFY_UINT(b)) { + 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); + celt_assert(0); #endif - } - res = a+b; - if (!VERIFY_UINT(res)) - { - fprintf (stderr, "UADD32: output is not uint32: %llu in %s: line %d\n", (unsigned long long)res, file, line); + } + res = a + b; + if (!VERIFY_UINT(res)) { + 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); + celt_assert(0); #endif - } - celt_mips+=2; - return res; + } + celt_mips += 2; + return res; } #undef USUB32 #define USUB32(a, b) USUB32_(a, b, __FILE__, __LINE__) -static OPUS_INLINE unsigned int USUB32_(opus_uint64 a, opus_uint64 b, char *file, int line) -{ - opus_uint64 res; - if (!VERIFY_UINT(a) || !VERIFY_UINT(b)) - { - fprintf (stderr, "USUB32: inputs are not uint32: %llu %llu in %s: line %d\n", (unsigned long long)a, (unsigned long long)b, file, line); +static OAC_INLINE unsigned int USUB32_(oac_uint64 a, oac_uint64 b, char *file, int line) { + oac_uint64 res; + if (!VERIFY_UINT(a) || !VERIFY_UINT(b)) { + 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); + celt_assert(0); #endif - } - if (a> 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); + } + res = ((oac_int64)(a)*(oac_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); + celt_assert(0); #endif - } - celt_mips+=5; - return res; + } + 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) -{ - opus_int64 res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); +static OAC_INLINE int MULT16_16_(int a, int b, char *file, int line) { + oac_int64 res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { + fprintf (stderr, "MULT16_16: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = ((opus_int64)a)*b; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "MULT16_16: output is not int: %d in %s: line %d\n", (int)res, file, line); + } + res = ((oac_int64)a)*b; + if (!VERIFY_INT(res)) { + fprintf (stderr, "MULT16_16: output is not int: %d in %s: line %d\n", (int)res, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips++; - return res; + } + celt_mips++; + return res; } -#define MAC16_16(c,a,b) (celt_mips-=2,ADD32((c),MULT16_16((a),(b)))) +#define MAC16_16(c, a, b) (celt_mips -= 2, ADD32((c), MULT16_16((a), (b)))) #define MULT16_32_QX(a, b, Q) MULT16_32_QX_(a, b, Q, __FILE__, __LINE__) -static OPUS_INLINE int MULT16_32_QX_(int a, opus_int64 b, int Q, char *file, int line) -{ - opus_int64 res; - if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) - { - fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, line); +static OAC_INLINE int MULT16_32_QX_(int a, oac_int64 b, int Q, char *file, int line) { + oac_int64 res; + if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) { + fprintf (stderr, "MULT16_32_Q%d: inputs are not short+int: %d %d in %s: line %d\n", Q, (int)a, (int)b, file, + line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - 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); + } + if (ABS32(b) >= ((oac_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 - celt_assert(0); + celt_assert(0); #endif - } - res = (((opus_int64)a)*(opus_int64)b) >> Q; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "MULT16_32_Q%d: output is not int: %d*%d=%d in %s: line %d\n", Q, (int)a, (int)b,(int)res, file, line); + } + res = (((oac_int64)a)*(oac_int64)b)>>Q; + if (!VERIFY_INT(res)) { + fprintf (stderr, "MULT16_32_Q%d: output is not int: %d*%d=%d in %s: line %d\n", Q, (int)a, (int)b, (int)res, + file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - if (Q==15) - celt_mips+=3; - else - celt_mips+=4; - return res; + } + if (Q == 15) + celt_mips += 3; + else + celt_mips += 4; + return res; } #define MULT16_32_PX(a, b, Q) MULT16_32_PX_(a, b, Q, __FILE__, __LINE__) -static OPUS_INLINE int MULT16_32_PX_(int a, opus_int64 b, int Q, char *file, int line) -{ - opus_int64 res; - if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) - { - fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d in %s: line %d\n\n", Q, (int)a, (int)b, file, line); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - 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 - celt_assert(0); -#endif - } - res = ((((opus_int64)a)*(opus_int64)b) + (((opus_val32)(1)<>1))>> Q; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d in %s: line %d\n\n", Q, (int)a, (int)b,(int)res, file, line); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - if (Q==15) - celt_mips+=4; - else - celt_mips+=5; - return res; -} - -#define MULT16_32_Q15(a,b) MULT16_32_QX(a,b,15) -#define MAC16_32_Q15(c,a,b) (celt_mips-=2,ADD32((c),MULT16_32_Q15((a),(b)))) -#define MAC16_32_Q16(c,a,b) (celt_mips-=2,ADD32((c),MULT16_32_Q16((a),(b)))) - -static OPUS_INLINE int SATURATE(int a, int b) -{ - if (a>b) - a=b; - if (a<-b) - a = -b; - celt_mips+=3; - return a; -} - -static OPUS_INLINE opus_int16 SATURATE16(opus_int32 a) -{ - celt_mips+=3; - if (a>32767) - return 32767; - else if (a<-32768) - return -32768; - else return a; -} - -static OPUS_INLINE int MULT16_16_Q11_32(int a, int b) -{ - opus_int64 res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_Q11: inputs are not short: %d %d\n", a, b); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - res = ((opus_int64)a)*b; - res >>= 11; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "MULT16_16_Q11: output is not short: %d*%d=%d\n", (int)a, (int)b, (int)res); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - celt_mips+=3; - return res; -} -static OPUS_INLINE short MULT16_16_Q13(int a, int b) -{ - opus_int64 res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_Q13: inputs are not short: %d %d\n", a, b); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - res = ((opus_int64)a)*b; - res >>= 13; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "MULT16_16_Q13: output is not short: %d*%d=%d\n", a, b, (int)res); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - celt_mips+=3; - return res; -} -static OPUS_INLINE short MULT16_16_Q14(int a, int b) -{ - opus_int64 res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_Q14: inputs are not short: %d %d\n", a, b); +static OAC_INLINE int MULT16_32_PX_(int a, oac_int64 b, int Q, char *file, int line) { + oac_int64 res; + if (!VERIFY_SHORT(a) || !VERIFY_INT(b)) { + fprintf (stderr, "MULT16_32_P%d: inputs are not short+int: %d %d in %s: line %d\n\n", Q, (int)a, (int)b, file, + line); +#ifdef FIXED_DEBUG_ASSERT + celt_assert(0); +#endif + } + if (ABS32(b) >= ((oac_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 - celt_assert(0); + celt_assert(0); #endif - } - res = ((opus_int64)a)*b; - res >>= 14; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "MULT16_16_Q14: output is not short: %d\n", (int)res); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - celt_mips+=3; - return res; + } + res = ((((oac_int64)a)*(oac_int64)b) + (((oac_val32)(1)<>1))>>Q; + if (!VERIFY_INT(res)) { + fprintf (stderr, "MULT16_32_P%d: output is not int: %d*%d=%d in %s: line %d\n\n", Q, (int)a, (int)b, (int)res, + file, line); +#ifdef FIXED_DEBUG_ASSERT + celt_assert(0); +#endif + } + if (Q == 15) + celt_mips += 4; + else + celt_mips += 5; + return res; +} + +#define MULT16_32_Q15(a, b) MULT16_32_QX(a, b, 15) +#define MAC16_32_Q15(c, a, b) (celt_mips -= 2, ADD32((c), MULT16_32_Q15((a), (b)))) +#define MAC16_32_Q16(c, a, b) (celt_mips -= 2, ADD32((c), MULT16_32_Q16((a), (b)))) + +static OAC_INLINE int SATURATE(int a, int b) { + if (a > b) + a = b; + if (a < -b) + a = -b; + celt_mips += 3; + return a; +} + +static OAC_INLINE oac_int16 SATURATE16(oac_int32 a) { + celt_mips += 3; + if (a > 32767) + return 32767; + else if (a < -32768) + return -32768; + else return a; +} + +static OAC_INLINE int MULT16_16_Q11_32(int a, int b) { + oac_int64 res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { + fprintf (stderr, "MULT16_16_Q11: inputs are not short: %d %d\n", a, b); +#ifdef FIXED_DEBUG_ASSERT + celt_assert(0); +#endif + } + res = ((oac_int64)a)*b; + res >>= 11; + if (!VERIFY_INT(res)) { + fprintf (stderr, "MULT16_16_Q11: output is not short: %d*%d=%d\n", (int)a, (int)b, (int)res); +#ifdef FIXED_DEBUG_ASSERT + celt_assert(0); +#endif + } + celt_mips += 3; + return res; +} +static OAC_INLINE short MULT16_16_Q13(int a, int b) { + oac_int64 res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { + fprintf (stderr, "MULT16_16_Q13: inputs are not short: %d %d\n", a, b); +#ifdef FIXED_DEBUG_ASSERT + celt_assert(0); +#endif + } + res = ((oac_int64)a)*b; + res >>= 13; + if (!VERIFY_SHORT(res)) { + fprintf (stderr, "MULT16_16_Q13: output is not short: %d*%d=%d\n", a, b, (int)res); +#ifdef FIXED_DEBUG_ASSERT + celt_assert(0); +#endif + } + celt_mips += 3; + return res; +} +static OAC_INLINE short MULT16_16_Q14(int a, int b) { + oac_int64 res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { + fprintf (stderr, "MULT16_16_Q14: inputs are not short: %d %d\n", a, b); +#ifdef FIXED_DEBUG_ASSERT + celt_assert(0); +#endif + } + res = ((oac_int64)a)*b; + res >>= 14; + if (!VERIFY_SHORT(res)) { + fprintf (stderr, "MULT16_16_Q14: output is not short: %d\n", (int)res); +#ifdef FIXED_DEBUG_ASSERT + celt_assert(0); +#endif + } + celt_mips += 3; + return res; } #define MULT16_16_Q15(a, b) MULT16_16_Q15_(a, b, __FILE__, __LINE__) -static OPUS_INLINE short MULT16_16_Q15_(int a, int b, char *file, int line) -{ - opus_int64 res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_Q15: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); -#ifdef FIXED_DEBUG_ASSERT - celt_assert(0); -#endif - } - res = ((opus_int64)a)*b; - res >>= 15; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "MULT16_16_Q15: output is not short: %d in %s: line %d\n", (int)res, file, line); +static OAC_INLINE short MULT16_16_Q15_(int a, int b, char *file, int line) { + oac_int64 res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { + fprintf (stderr, "MULT16_16_Q15: inputs are not short: %d %d in %s: line %d\n", a, b, file, line); +#ifdef FIXED_DEBUG_ASSERT + celt_assert(0); +#endif + } + res = ((oac_int64)a)*b; + res >>= 15; + if (!VERIFY_SHORT(res)) { + fprintf (stderr, "MULT16_16_Q15: output is not short: %d in %s: line %d\n", (int)res, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips+=1; - return res; + } + celt_mips += 1; + return res; } -static OPUS_INLINE short MULT16_16_P13(int a, int b) -{ - opus_int64 res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_P13: inputs are not short: %d %d\n", a, b); +static OAC_INLINE short MULT16_16_P13(int a, int b) { + oac_int64 res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { + fprintf (stderr, "MULT16_16_P13: inputs are not short: %d %d\n", a, b); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = ((opus_int64)a)*b; - res += 4096; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "MULT16_16_P13: overflow: %d*%d=%d\n", a, b, (int)res); + } + res = ((oac_int64)a)*b; + res += 4096; + if (!VERIFY_INT(res)) { + fprintf (stderr, "MULT16_16_P13: overflow: %d*%d=%d\n", a, b, (int)res); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res >>= 13; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "MULT16_16_P13: output is not short: %d*%d=%d\n", a, b, (int)res); + } + res >>= 13; + if (!VERIFY_SHORT(res)) { + fprintf (stderr, "MULT16_16_P13: output is not short: %d*%d=%d\n", a, b, (int)res); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips+=4; - return res; + } + celt_mips += 4; + return res; } -static OPUS_INLINE short MULT16_16_P14(int a, int b) -{ - opus_int64 res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_P14: inputs are not short: %d %d\n", a, b); +static OAC_INLINE short MULT16_16_P14(int a, int b) { + oac_int64 res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { + fprintf (stderr, "MULT16_16_P14: inputs are not short: %d %d\n", a, b); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = ((opus_int64)a)*b; - res += 8192; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "MULT16_16_P14: overflow: %d*%d=%d\n", a, b, (int)res); + } + res = ((oac_int64)a)*b; + res += 8192; + if (!VERIFY_INT(res)) { + fprintf (stderr, "MULT16_16_P14: overflow: %d*%d=%d\n", a, b, (int)res); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res >>= 14; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "MULT16_16_P14: output is not short: %d*%d=%d\n", a, b, (int)res); + } + res >>= 14; + if (!VERIFY_SHORT(res)) { + fprintf (stderr, "MULT16_16_P14: output is not short: %d*%d=%d\n", a, b, (int)res); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips+=4; - return res; + } + celt_mips += 4; + return res; } -static OPUS_INLINE short MULT16_16_P15(int a, int b) -{ - opus_int64 res; - if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "MULT16_16_P15: inputs are not short: %d %d\n", a, b); +static OAC_INLINE short MULT16_16_P15(int a, int b) { + oac_int64 res; + if (!VERIFY_SHORT(a) || !VERIFY_SHORT(b)) { + fprintf (stderr, "MULT16_16_P15: inputs are not short: %d %d\n", a, b); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = ((opus_int64)a)*b; - res += 16384; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "MULT16_16_P15: overflow: %d*%d=%d\n", a, b, (int)res); + } + res = ((oac_int64)a)*b; + res += 16384; + if (!VERIFY_INT(res)) { + fprintf (stderr, "MULT16_16_P15: overflow: %d*%d=%d\n", a, b, (int)res); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res >>= 15; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "MULT16_16_P15: output is not short: %d*%d=%d\n", a, b, (int)res); + } + res >>= 15; + if (!VERIFY_SHORT(res)) { + fprintf (stderr, "MULT16_16_P15: output is not short: %d*%d=%d\n", a, b, (int)res); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips+=2; - return res; + } + celt_mips += 2; + return res; } #define DIV32_16(a, b) DIV32_16_(a, b, __FILE__, __LINE__) -static OPUS_INLINE int DIV32_16_(opus_int64 a, opus_int64 b, char *file, int line) -{ - opus_int64 res; - if (b==0) - { - fprintf(stderr, "DIV32_16: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line); +static OAC_INLINE int DIV32_16_(oac_int64 a, oac_int64 b, char *file, int line) { + oac_int64 res; + if (b == 0) { + fprintf(stderr, "DIV32_16: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - return 0; - } - if (!VERIFY_INT(a) || !VERIFY_SHORT(b)) - { - fprintf (stderr, "DIV32_16: inputs are not int/short: %d %d in %s: line %d\n", (int)a, (int)b, file, line); + return 0; + } + if (!VERIFY_INT(a) || !VERIFY_SHORT(b)) { + fprintf (stderr, "DIV32_16: inputs are not int/short: %d %d in %s: line %d\n", (int)a, (int)b, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = a/b; - if (!VERIFY_SHORT(res)) - { - fprintf (stderr, "DIV32_16: output is not short: %d / %d = %d in %s: line %d\n", (int)a,(int)b,(int)res, file, line); - if (res>32767) - res = 32767; - if (res<-32768) - res = -32768; + } + res = a/b; + if (!VERIFY_SHORT(res)) { + fprintf (stderr, "DIV32_16: output is not short: %d / %d = %d in %s: line %d\n", (int)a, (int)b, (int)res, file, + line); + if (res > 32767) + res = 32767; + if (res < -32768) + res = -32768; #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips+=35; - return res; + } + celt_mips += 35; + return res; } #define DIV32(a, b) DIV32_(a, b, __FILE__, __LINE__) -static OPUS_INLINE int DIV32_(opus_int64 a, opus_int64 b, char *file, int line) -{ - opus_int64 res; - if (b==0) - { - fprintf(stderr, "DIV32: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line); +static OAC_INLINE int DIV32_(oac_int64 a, oac_int64 b, char *file, int line) { + oac_int64 res; + if (b == 0) { + fprintf(stderr, "DIV32: divide by zero: %d/%d in %s: line %d\n", (int)a, (int)b, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - return 0; - } + return 0; + } - if (!VERIFY_INT(a) || !VERIFY_INT(b)) - { - fprintf (stderr, "DIV32: inputs are not int/short: %d %d in %s: line %d\n", (int)a, (int)b, file, line); + if (!VERIFY_INT(a) || !VERIFY_INT(b)) { + fprintf (stderr, "DIV32: inputs are not int/short: %d %d in %s: line %d\n", (int)a, (int)b, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - res = a/b; - if (!VERIFY_INT(res)) - { - fprintf (stderr, "DIV32: output is not int: %d in %s: line %d\n", (int)res, file, line); + } + res = a/b; + if (!VERIFY_INT(res)) { + fprintf (stderr, "DIV32: output is not int: %d in %s: line %d\n", (int)res, file, line); #ifdef FIXED_DEBUG_ASSERT - celt_assert(0); + celt_assert(0); #endif - } - celt_mips+=70; - return res; + } + celt_mips += 70; + return res; } -static OPUS_INLINE opus_val16 SIG2WORD16_generic(celt_sig x) -{ - x = PSHR32(x, SIG_SHIFT); - x = MAX32(x, -32768); - x = MIN32(x, 32767); - return EXTRACT16(x); +static OAC_INLINE oac_val16 SIG2WORD16_generic(celt_sig x) { + x = PSHR32(x, SIG_SHIFT); + x = MAX32(x, -32768); + x = MIN32(x, 32767); + return EXTRACT16(x); } #define SIG2WORD16(x) (SIG2WORD16_generic(x)) #undef PRINT_MIPS -#define PRINT_MIPS(file) do {fprintf (file, "total complexity = %llu MIPS\n", (unsigned long long)celt_mips);} while (0); +#define PRINT_MIPS(file) do {fprintf (file, "total complexity = %llu MIPS\n", (unsigned long long)celt_mips); \ +} while (0); #endif diff --git a/celt/fixed_generic.h b/celt/fixed_generic.h index ee9ea1844..3167f53c8 100644 --- a/celt/fixed_generic.h +++ b/celt/fixed_generic.h @@ -4,7 +4,7 @@ /** @file fixed_generic.h @brief Generic fixed-point operations -*/ + */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -28,77 +28,91 @@ 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. -*/ + */ #ifndef FIXED_GENERIC_H #define FIXED_GENERIC_H /** Multiply a 16-bit signed value by a 16-bit unsigned value. The result is a 32-bit signed value */ -#define MULT16_16SU(a,b) ((opus_val32)(opus_val16)(a)*(opus_val32)(opus_uint16)(b)) +#define MULT16_16SU(a, b) ((oac_val32)(oac_val16)(a)*(oac_val32)(oac_uint16)(b)) /** 16x32 multiplication, followed by a 16-bit shift right. Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT16_32_Q16(a,b) ((opus_val32)SHR((opus_int64)((opus_val16)(a))*(b),16)) +#if OAC_FAST_INT64 +# define MULT16_32_Q16(a, b) ((oac_val32)SHR((oac_int64)((oac_val16)(a))*(b), 16)) #else -#define MULT16_32_Q16(a,b) ADD32(MULT16_16((a),SHR((b),16)), SHR(MULT16_16SU((a),((b)&0x0000ffff)),16)) +# define MULT16_32_Q16(a, b) ADD32(MULT16_16((a), SHR((b), 16)), SHR(MULT16_16SU((a), ((b)&0x0000ffff)), 16)) #endif /** 16x32 multiplication, followed by a 16-bit shift right (round-to-nearest). Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT16_32_P16(a,b) ((opus_val32)PSHR((opus_int64)((opus_val16)(a))*(b),16)) +#if OAC_FAST_INT64 +# define MULT16_32_P16(a, b) ((oac_val32)PSHR((oac_int64)((oac_val16)(a))*(b), 16)) #else -#define MULT16_32_P16(a,b) ADD32(MULT16_16((a),SHR((b),16)), PSHR(MULT16_16SU((a),((b)&0x0000ffff)),16)) +# define MULT16_32_P16(a, b) ADD32(MULT16_16((a), SHR((b), 16)), PSHR(MULT16_16SU((a), ((b)&0x0000ffff)), 16)) #endif /** 16x32 multiplication, followed by a 15-bit shift right. Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT16_32_Q15(a,b) ((opus_val32)SHR((opus_int64)((opus_val16)(a))*(b),15)) +#if OAC_FAST_INT64 +# define MULT16_32_Q15(a, b) ((oac_val32)SHR((oac_int64)((oac_val16)(a))*(b), 15)) #else -#define MULT16_32_Q15(a,b) ADD32(SHL(MULT16_16((a),SHR((b),16)),1), SHR(MULT16_16SU((a),((b)&0x0000ffff)),15)) +# 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)) +#if OAC_FAST_INT64 +# define MULT32_32_Q16(a, b) ((oac_val32)SHR((oac_int64)(a)*(oac_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))) +# define MULT32_32_Q16(a, \ + b) (ADD32(ADD32(ADD32((oac_val32)(SHR32(((oac_uint32)((a)&0x0000ffff) \ + *(oac_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)) +#if OAC_FAST_INT64 +# define MULT32_32_Q31(a, b) ((oac_val32)SHR((oac_int64)(a)*(oac_int64)(b), 31)) #else -#define MULT32_32_Q31(a,b) ADD32(ADD32(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),15)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),15)) +# define MULT32_32_Q31(a, \ + b) ADD32(ADD32(SHL(MULT16_16(SHR((a), 16), SHR((b), 16)), 1), \ + SHR(MULT16_16SU(SHR((a), 16), ((b)&0x0000ffff)), 15)), SHR(MULT16_16SU(SHR((b), 16), ((a)&0x0000ffff)), 15)) #endif /** 32x32 multiplication, followed by a 31-bit shift right (with rounding). Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT32_32_P31(a,b) ((opus_val32)SHR(1073741824+(opus_int64)(a)*(opus_int64)(b),31)) -#define MULT32_32_P31_ovflw(a,b) MULT32_32_P31(a,b) +#if OAC_FAST_INT64 +# define MULT32_32_P31(a, b) ((oac_val32)SHR(1073741824 + (oac_int64)(a)*(oac_int64)(b), 31)) +# define MULT32_32_P31_ovflw(a, b) MULT32_32_P31(a, b) #else -#define MULT16_16U(a,b) ((opus_uint32)(a)*(opus_uint32)(b)) -#define MULT32_32_P31(a,b) ADD32(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(opus_int32)SHR(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff)),16+7) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) ) -#define MULT32_32_P31_ovflw(a,b) ADD32_ovflw(SHL(MULT16_16(SHR((a),16),SHR((b),16)),1), SHR32(128+(opus_int32)SHR(MULT16_16U(((a)&0x0000ffff),((b)&0x0000ffff)),16+7) + SHR32(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),7) + SHR32(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),7), 8) ) +# define MULT16_16U(a, b) ((oac_uint32)(a)*(oac_uint32)(b)) +# define MULT32_32_P31(a, b) ADD32(SHL(MULT16_16(SHR((a), 16), SHR((b), 16)), 1), \ + SHR32(128 + (oac_int32)SHR(MULT16_16U(((a)&0x0000ffff), ((b)&0x0000ffff)), \ + 16 + 7) + SHR32(MULT16_16SU(SHR((a), 16), ((b)&0x0000ffff)), 7) + SHR32(MULT16_16SU(SHR((b), 16), ((a)&0x0000ffff)), \ + 7), 8)) +# define MULT32_32_P31_ovflw(a, b) ADD32_ovflw(SHL(MULT16_16(SHR((a), 16), SHR((b), 16)), 1), \ + SHR32(128 + (oac_int32)SHR(MULT16_16U(((a)&0x0000ffff), ((b)&0x0000ffff)), \ + 16 + 7) + SHR32(MULT16_16SU(SHR((a), 16), ((b)&0x0000ffff)), 7) + SHR32(MULT16_16SU(SHR((b), 16), ((a)&0x0000ffff)), \ + 7), 8)) #endif /** 32x32 multiplication, followed by a 32-bit shift right. Results fits in 32 bits */ -#if OPUS_FAST_INT64 -#define MULT32_32_Q32(a,b) ((opus_val32)SHR((opus_int64)(a)*(opus_int64)(b),32)) +#if OAC_FAST_INT64 +# define MULT32_32_Q32(a, b) ((oac_val32)SHR((oac_int64)(a)*(oac_int64)(b), 32)) #else -#define MULT32_32_Q32(a,b) ADD32(ADD32(MULT16_16(SHR((a),16),SHR((b),16)), SHR(MULT16_16SU(SHR((a),16),((b)&0x0000ffff)),16)), SHR(MULT16_16SU(SHR((b),16),((a)&0x0000ffff)),16)) +# define MULT32_32_Q32(a, \ + b) ADD32(ADD32(MULT16_16(SHR((a), 16), SHR((b), 16)), \ + SHR(MULT16_16SU(SHR((a), 16), ((b)&0x0000ffff)), 16)), SHR(MULT16_16SU(SHR((b), 16), ((a)&0x0000ffff)), 16)) #endif /** Compile-time conversion of float constant to 16-bit value */ -#define QCONST16(x,bits) ((opus_val16)(.5+(x)*(((opus_val32)1)<<(bits)))) +#define QCONST16(x, bits) ((oac_val16)(.5 + (x)*(((oac_val32)1)<<(bits)))) /** Compile-time conversion of float constant to 32-bit value */ -#define QCONST32(x,bits) ((opus_val32)(.5+(x)*(((opus_int64)1)<<(bits)))) +#define QCONST32(x, bits) ((oac_val32)(.5 + (x)*(((oac_int64)1)<<(bits)))) /** Compile-time conversion of float constant to log gain value */ -#define GCONST2(x,bits) ((celt_glog)(.5+(x)*(((celt_glog)1)<<(bits)))) +#define GCONST2(x, bits) ((celt_glog)(.5 + (x)*(((celt_glog)1)<<(bits)))) /** Compile-time conversion of float constant to DB_SHIFT log gain value */ -#define GCONST(x) GCONST2((x),DB_SHIFT) +#define GCONST(x) GCONST2((x), DB_SHIFT) /** Negate a 16-bit value */ #define NEG16(x) (-(x)) @@ -106,112 +120,112 @@ #define NEG32(x) (-(x)) /** Change a 32-bit value into a 16-bit value. The value is assumed to fit in 16-bit, otherwise the result is undefined */ -#define EXTRACT16(x) ((opus_val16)(x)) +#define EXTRACT16(x) ((oac_val16)(x)) /** Change a 16-bit value into a 32-bit value */ -#define EXTEND32(x) ((opus_val32)(x)) +#define EXTEND32(x) ((oac_val32)(x)) /** Arithmetic shift-right of a 16-bit value */ -#define SHR16(a,shift) ((a) >> (shift)) +#define SHR16(a, shift) ((a)>>(shift)) /** Arithmetic shift-left of a 16-bit value */ -#define SHL16(a,shift) ((opus_int16)((opus_uint16)(a)<<(shift))) +#define SHL16(a, shift) ((oac_int16)((oac_uint16)(a)<<(shift))) /** Arithmetic shift-right of a 32-bit value */ -#define SHR32(a,shift) ((a) >> (shift)) +#define SHR32(a, shift) ((a)>>(shift)) /** Arithmetic shift-left of a 32-bit value */ -#define SHL32(a,shift) ((opus_int32)((opus_uint32)(a)<<(shift))) +#define SHL32(a, shift) ((oac_int32)((oac_uint32)(a)<<(shift))) /** 32-bit arithmetic shift right with rounding-to-nearest instead of rounding down */ -#define PSHR32(a,shift) (SHR32((a)+((EXTEND32(1)<<((shift))>>1)),shift)) +#define PSHR32(a, shift) (SHR32((a) + ((EXTEND32(1)<<((shift))>>1)), shift)) /** 32-bit arithmetic shift right where the argument can be negative */ -#define VSHR32(a, shift) (((shift)>0) ? SHR32(a, shift) : SHL32(a, -(shift))) +#define VSHR32(a, shift) (((shift) > 0) ? SHR32(a, shift) : SHL32(a, -(shift))) /** Arithmetic shift-right of a 64-bit value */ -#define SHR64(a,shift) ((a) >> (shift)) +#define SHR64(a, shift) ((a)>>(shift)) /** "RAW" macros, should not be used outside of this header file */ -#define SHR(a,shift) ((a) >> (shift)) -#define SHL(a,shift) SHL32(a,shift) -#define PSHR(a,shift) (SHR((a)+((EXTEND32(1)<<((shift))>>1)),shift)) -#define SATURATE(x,a) (((x)>(a) ? (a) : (x)<-(a) ? -(a) : (x))) +#define SHR(a, shift) ((a)>>(shift)) +#define SHL(a, shift) SHL32(a, shift) +#define PSHR(a, shift) (SHR((a) + ((EXTEND32(1)<<((shift))>>1)), shift)) +#define SATURATE(x, a) (((x) > (a) ? (a) : (x) < -(a) ? -(a) : (x))) -#define SATURATE16(x) (EXTRACT16((x)>32767 ? 32767 : (x)<-32768 ? -32768 : (x))) +#define SATURATE16(x) (EXTRACT16((x) > 32767 ? 32767 : (x) < -32768 ? -32768 : (x))) /** Shift by a and round-to-nearest 32-bit value. Result is a 16-bit value */ -#define ROUND16(x,a) (EXTRACT16(PSHR32((x),(a)))) +#define ROUND16(x, a) (EXTRACT16(PSHR32((x), (a)))) /** 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)); +#define SROUND16(x, a) EXTRACT16(SATURATE(PSHR32(x, a), 32767)); /** Divide by two */ -#define HALF16(x) (SHR16(x,1)) -#define HALF32(x) (SHR32(x,1)) +#define HALF16(x) (SHR16(x, 1)) +#define HALF32(x) (SHR32(x, 1)) /** Add two 16-bit values */ -#define ADD16(a,b) ((opus_val16)((opus_val16)(a)+(opus_val16)(b))) +#define ADD16(a, b) ((oac_val16)((oac_val16)(a) + (oac_val16)(b))) /** Subtract two 16-bit values */ -#define SUB16(a,b) ((opus_val16)(a)-(opus_val16)(b)) +#define SUB16(a, b) ((oac_val16)(a) - (oac_val16)(b)) /** Add two 32-bit values */ -#define ADD32(a,b) ((opus_val32)(a)+(opus_val32)(b)) +#define ADD32(a, b) ((oac_val32)(a) + (oac_val32)(b)) /** Subtract two 32-bit values */ -#define SUB32(a,b) ((opus_val32)(a)-(opus_val32)(b)) +#define SUB32(a, b) ((oac_val32)(a) - (oac_val32)(b)) /** Add two 32-bit values, ignore any overflows */ -#define ADD32_ovflw(a,b) ((opus_val32)((opus_uint32)(a)+(opus_uint32)(b))) +#define ADD32_ovflw(a, b) ((oac_val32)((oac_uint32)(a) + (oac_uint32)(b))) /** Subtract two 32-bit values, ignore any overflows */ -#define SUB32_ovflw(a,b) ((opus_val32)((opus_uint32)(a)-(opus_uint32)(b))) +#define SUB32_ovflw(a, b) ((oac_val32)((oac_uint32)(a) - (oac_uint32)(b))) /* Avoid MSVC warning C4146: unary minus operator applied to unsigned type */ /** Negate 32-bit value, ignore any overflows */ -#define NEG32_ovflw(a) ((opus_val32)(0-(opus_uint32)(a))) +#define NEG32_ovflw(a) ((oac_val32)(0 - (oac_uint32)(a))) /** 32-bit shift left, ignoring overflows */ -#define SHL32_ovflw(a,shift) SHL32(a,shift) +#define SHL32_ovflw(a, shift) SHL32(a, shift) /** 32-bit arithmetic shift right with rounding-to-nearest, ignoring overflows */ -#define PSHR32_ovflw(a,shift) (SHR32(ADD32_ovflw(a, (EXTEND32(1)<<(shift)>>1)),shift)) +#define PSHR32_ovflw(a, shift) (SHR32(ADD32_ovflw(a, (EXTEND32(1)<<(shift)>>1)), shift)) /** 16x16 multiplication where the result fits in 16 bits */ -#define MULT16_16_16(a,b) ((((opus_val16)(a))*((opus_val16)(b)))) +#define MULT16_16_16(a, b) ((((oac_val16)(a))*((oac_val16)(b)))) /** 32x32 multiplication where the result fits in 32 bits */ -#define MULT32_32_32(a,b) ((((opus_val32)(a))*((opus_val32)(b)))) +#define MULT32_32_32(a, b) ((((oac_val32)(a))*((oac_val32)(b)))) -/* (opus_val32)(opus_val16) gives TI compiler a hint that it's 16x16->32 multiply */ +/* (oac_val32)(oac_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))) +#define MULT16_16(a, b) (((oac_val32)(oac_val16)(a))*((oac_val32)(oac_val16)(b))) /** 16x16 multiply-add where the result fits in 32 bits */ -#define MAC16_16(c,a,b) (ADD32((c),MULT16_16((a),(b)))) +#define MAC16_16(c, a, b) (ADD32((c), MULT16_16((a), (b)))) /** 16x32 multiply, followed by a 15-bit shift right and 32-bit add. b must fit in 31 bits. Result fits in 32 bits. */ -#define MAC16_32_Q15(c,a,b) ADD32((c),ADD32(MULT16_16((a),SHR((b),15)), SHR(MULT16_16((a),((b)&0x00007fff)),15))) +#define MAC16_32_Q15(c, a, b) ADD32((c), ADD32(MULT16_16((a), SHR((b), 15)), SHR(MULT16_16((a), ((b)&0x00007fff)), 15))) /** 16x32 multiplication, followed by a 16-bit shift right and 32-bit add. Results fits in 32 bits */ -#define MAC16_32_Q16(c,a,b) ADD32((c),ADD32(MULT16_16((a),SHR((b),16)), SHR(MULT16_16SU((a),((b)&0x0000ffff)),16))) +#define MAC16_32_Q16(c, a, b) ADD32((c), \ + ADD32(MULT16_16((a), SHR((b), 16)), SHR(MULT16_16SU((a), ((b)&0x0000ffff)), 16))) -#define MULT16_16_Q11_32(a,b) (SHR(MULT16_16((a),(b)),11)) -#define MULT16_16_Q11(a,b) (SHR(MULT16_16((a),(b)),11)) -#define MULT16_16_Q13(a,b) (SHR(MULT16_16((a),(b)),13)) -#define MULT16_16_Q14(a,b) (SHR(MULT16_16((a),(b)),14)) -#define MULT16_16_Q15(a,b) (SHR(MULT16_16((a),(b)),15)) +#define MULT16_16_Q11_32(a, b) (SHR(MULT16_16((a), (b)), 11)) +#define MULT16_16_Q11(a, b) (SHR(MULT16_16((a), (b)), 11)) +#define MULT16_16_Q13(a, b) (SHR(MULT16_16((a), (b)), 13)) +#define MULT16_16_Q14(a, b) (SHR(MULT16_16((a), (b)), 14)) +#define MULT16_16_Q15(a, b) (SHR(MULT16_16((a), (b)), 15)) -#define MULT16_16_P13(a,b) (SHR(ADD32(4096,MULT16_16((a),(b))),13)) -#define MULT16_16_P14(a,b) (SHR(ADD32(8192,MULT16_16((a),(b))),14)) -#define MULT16_16_P15(a,b) (SHR(ADD32(16384,MULT16_16((a),(b))),15)) +#define MULT16_16_P13(a, b) (SHR(ADD32(4096, MULT16_16((a), (b))), 13)) +#define MULT16_16_P14(a, b) (SHR(ADD32(8192, MULT16_16((a), (b))), 14)) +#define MULT16_16_P15(a, b) (SHR(ADD32(16384, MULT16_16((a), (b))), 15)) /** Divide a 32-bit value by a 16-bit value. Result fits in 16 bits */ -#define DIV32_16(a,b) ((opus_val16)(((opus_val32)(a))/((opus_val16)(b)))) +#define DIV32_16(a, b) ((oac_val16)(((oac_val32)(a))/((oac_val16)(b)))) /** Divide a 32-bit value by a 32-bit value. Result fits in 32 bits */ -#define DIV32(a,b) (((opus_val32)(a))/((opus_val32)(b))) +#define DIV32(a, b) (((oac_val32)(a))/((oac_val32)(b))) #if defined(__mips) -#include "mips/fixed_generic_mipsr1.h" +# include "mips/fixed_generic_mipsr1.h" #endif -static OPUS_INLINE opus_val16 SIG2WORD16_generic(celt_sig x) -{ - x = PSHR32(x, SIG_SHIFT); - x = MAX32(x, -32768); - x = MIN32(x, 32767); - return EXTRACT16(x); +static OAC_INLINE oac_val16 SIG2WORD16_generic(celt_sig x) { + x = PSHR32(x, SIG_SHIFT); + x = MAX32(x, -32768); + x = MIN32(x, 32767); + return EXTRACT16(x); } #define SIG2WORD16(x) (SIG2WORD16_generic(x)) diff --git a/celt/float_cast.h b/celt/float_cast.h index 120a53695..b1101bc9c 100644 --- a/celt/float_cast.h +++ b/celt/float_cast.h @@ -22,7 +22,7 @@ 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. -*/ + */ /* Version 1.1 */ @@ -64,47 +64,46 @@ /* With GCC, when SSE is available, the fastest conversion is cvtss2si. */ #if defined(__GNUC__) && defined(__SSE__) -#include -static OPUS_INLINE opus_int32 float2int(float x) {return _mm_cvt_ss2si(_mm_set_ss(x));} +# include +static OAC_INLINE oac_int32 oaci_float2int(float x) { + return _mm_cvt_ss2si(_mm_set_ss(x)); +} #elif (defined(_MSC_VER) && _MSC_VER >= 1400) && (defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 1)) - #include - 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)); - } +# include +static OAC_INLINE oac_int32 oaci_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 +# include - /* Win32 doesn't seem to have these functions. - ** Therefore implement OPUS_INLINE versions of these functions here. - */ +/* Win32 doesn't seem to have these functions. +** Therefore implement OAC_INLINE versions of these functions here. +*/ - static OPUS_INLINE opus_int32 - float2int (float flt) - { int intgr; +static OAC_INLINE oac_int32 oaci_float2int (float flt) { + int intgr; - _asm - { fld flt - fistp intgr - } ; + _asm + { fld flt + fistp intgr + }; - return intgr ; - } + return intgr; +} #elif defined(__aarch64__) - #include - static OPUS_INLINE opus_int32 float2int(float flt) - { - return vcvtns_s32_f32(flt); - } +# include +static OAC_INLINE oac_int32 oaci_float2int(float flt) { + return vcvtns_s32_f32(flt); +} #elif defined(HAVE_LRINTF) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L @@ -115,62 +114,59 @@ static OPUS_INLINE opus_int32 float2int(float x) {return _mm_cvt_ss2si(_mm_set_s ** maths library using -lm. */ -#define _ISOC9X_SOURCE 1 -#define _ISOC99_SOURCE 1 +# define _ISOC9X_SOURCE 1 +# define _ISOC99_SOURCE 1 -#define __USE_ISOC9X 1 -#define __USE_ISOC99 1 +# define __USE_ISOC9X 1 +# define __USE_ISOC99 1 -#include -#define float2int(x) lrintf(x) +# include +# define oaci_float2int(x) lrintf(x) #elif defined(HAVE_LRINT) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define _ISOC9X_SOURCE 1 -#define _ISOC99_SOURCE 1 +# define _ISOC9X_SOURCE 1 +# define _ISOC99_SOURCE 1 -#define __USE_ISOC9X 1 -#define __USE_ISOC99 1 +# define __USE_ISOC9X 1 +# define __USE_ISOC99 1 -#include -#define float2int(x) lrint(x) +# include +# define oaci_float2int(x) lrint(x) #else -#if (defined(__GNUC__) && defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) - /* supported by gcc in C99 mode, but not by all other compilers */ - #warning "Don't have the functions lrint() and lrintf ()." - #warning "Replacing these functions with a standard C cast." -#endif /* __STDC_VERSION__ >= 199901L */ - #include - #define float2int(flt) ((int)(floor(.5+flt))) +# if (defined(__GNUC__) && defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) +/* supported by gcc in C99 mode, but not by all other compilers */ +# warning "Don't have the functions lrint() and lrintf ()." +# warning "Replacing these functions with a standard C cast." +# endif /* __STDC_VERSION__ >= 199901L */ +# include +# define oaci_float2int(flt) ((int)(floor(.5 + flt))) #endif #ifndef DISABLE_FLOAT_API -static OPUS_INLINE opus_int16 FLOAT2INT16(float x) -{ - x = x*CELT_SIG_SCALE; - x = MAX32(x, -32768); - x = MIN32(x, 32767); - return (opus_int16)float2int(x); +static OAC_INLINE oac_int16 FLOAT2INT16(float x) { + x = x*CELT_SIG_SCALE; + x = MAX32(x, -32768); + x = MIN32(x, 32767); + return (oac_int16)oaci_float2int(x); } -static OPUS_INLINE opus_int32 FLOAT2INT24(float x) -{ - x = x*(CELT_SIG_SCALE*256.f); - x = MAX32(x, -16777216); - x = MIN32(x, 16777216); - return float2int(x); +static OAC_INLINE oac_int32 FLOAT2INT24(float x) { + x = x*(CELT_SIG_SCALE*256.f); + x = MAX32(x, -16777216); + x = MIN32(x, 16777216); + return oaci_float2int(x); } -#ifdef FIXED_POINT -static OPUS_INLINE opus_int32 FLOAT2SIG(float x) -{ - x = x*((opus_int32)32768<twiddles; - /* m is guaranteed to be a multiple of 4. */ - for (j=0;jtwiddles; + /* m is guaranteed to be a multiple of 4. */ + for (j = 0; j < m; j++) { + C_MUL(scratch[0], Fout[m], *tw1 ); + C_MUL(scratch[1], Fout[m2], *tw2 ); + C_MUL(scratch[2], Fout[m3], *tw3 ); + + C_SUB( scratch[5], *Fout, scratch[1] ); + C_ADDTO(*Fout, scratch[1]); + C_ADD( scratch[3], scratch[0], scratch[2] ); + C_SUB( scratch[4], scratch[0], scratch[2] ); + C_SUB( Fout[m2], *Fout, scratch[3] ); + tw1 += fstride; + tw2 += fstride*2; + tw3 += fstride*3; + C_ADDTO( *Fout, scratch[3] ); + + Fout[m].r = ADD32_ovflw(scratch[5].r, scratch[4].i); + Fout[m].i = SUB32_ovflw(scratch[5].i, scratch[4].r); + Fout[m3].r = SUB32_ovflw(scratch[5].r, scratch[4].i); + Fout[m3].i = ADD32_ovflw(scratch[5].i, scratch[4].r); + ++Fout; + } + } + } +} + + +#ifndef RADIX_TWO_ONLY + +static void oaci_kf_bfly3( + kiss_fft_cpx * Fout, + const size_t fstride, + const kiss_fft_state *st, + int m, + int N, + int mm) { + int i; + size_t k; + const size_t m2 = 2*m; + const kiss_twiddle_cpx *tw1, *tw2; + kiss_fft_cpx scratch[5]; + kiss_twiddle_cpx epi3; + + kiss_fft_cpx * Fout_beg = Fout; +# ifdef FIXED_POINT + /*epi3.r = -16384;*/ /* Unused */ + epi3.i = -QCONST32(0.86602540f, COEF_SHIFT - 1); +# else + epi3 = st->twiddles[fstride*m]; +# endif + for (i = 0; i < N; i++) { + Fout = Fout_beg + i*mm; + tw1 = tw2 = st->twiddles; + /* For non-custom modes, m is guaranteed to be a multiple of 4. */ + k = m; + do { + + C_MUL(scratch[1], Fout[m], *tw1); + C_MUL(scratch[2], Fout[m2], *tw2); + + C_ADD(scratch[3], scratch[1], scratch[2]); + C_SUB(scratch[0], scratch[1], scratch[2]); tw1 += fstride; tw2 += fstride*2; - tw3 += fstride*3; - C_ADDTO( *Fout , scratch[3] ); - Fout[m].r = ADD32_ovflw(scratch[5].r, scratch[4].i); - Fout[m].i = SUB32_ovflw(scratch[5].i, scratch[4].r); - Fout[m3].r = SUB32_ovflw(scratch[5].r, scratch[4].i); - Fout[m3].i = ADD32_ovflw(scratch[5].i, scratch[4].r); + Fout[m].r = SUB32_ovflw(Fout->r, HALF_OF(scratch[3].r)); + Fout[m].i = SUB32_ovflw(Fout->i, HALF_OF(scratch[3].i)); + + C_MULBYSCALAR( scratch[0], epi3.i ); + + C_ADDTO(*Fout, scratch[3]); + + Fout[m2].r = ADD32_ovflw(Fout[m].r, scratch[0].i); + Fout[m2].i = SUB32_ovflw(Fout[m].i, scratch[0].r); + + Fout[m].r = SUB32_ovflw(Fout[m].r, scratch[0].i); + Fout[m].i = ADD32_ovflw(Fout[m].i, scratch[0].r); + ++Fout; - } - } - } + } while (--k); + } } -#ifndef RADIX_TWO_ONLY - -static void kf_bfly3( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_state *st, - int m, - int N, - int mm - ) -{ - int i; - size_t k; - const size_t m2 = 2*m; - const kiss_twiddle_cpx *tw1,*tw2; - kiss_fft_cpx scratch[5]; - kiss_twiddle_cpx epi3; - - kiss_fft_cpx * Fout_beg = Fout; -#ifdef FIXED_POINT - /*epi3.r = -16384;*/ /* Unused */ - epi3.i = -QCONST32(0.86602540f, COEF_SHIFT-1); -#else - epi3 = st->twiddles[fstride*m]; -#endif - for (i=0;itwiddles; - /* For non-custom modes, m is guaranteed to be a multiple of 4. */ - k=m; - do { +# ifndef OVERRIDE_oaci_kf_bfly5 +static void oaci_kf_bfly5( + kiss_fft_cpx * Fout, + const size_t fstride, + const kiss_fft_state *st, + int m, + int N, + int mm) { + kiss_fft_cpx *Fout0, *Fout1, *Fout2, *Fout3, *Fout4; + int i, u; + kiss_fft_cpx scratch[13]; + const kiss_twiddle_cpx *tw; + kiss_twiddle_cpx ya, yb; + kiss_fft_cpx * Fout_beg = Fout; + +# ifdef FIXED_POINT + ya.r = QCONST32(0.30901699f, COEF_SHIFT - 1); + ya.i = -QCONST32(0.95105652f, COEF_SHIFT - 1); + yb.r = -QCONST32(0.80901699f, COEF_SHIFT - 1); + yb.i = -QCONST32(0.58778525f, COEF_SHIFT - 1); +# else + ya = st->twiddles[fstride*m]; + yb = st->twiddles[fstride*2*m]; +# endif + tw = st->twiddles; - C_MUL(scratch[1],Fout[m] , *tw1); - C_MUL(scratch[2],Fout[m2] , *tw2); + for (i = 0; i < N; i++) { + Fout = Fout_beg + i*mm; + Fout0 = Fout; + Fout1 = Fout0 + m; + Fout2 = Fout0 + 2*m; + Fout3 = Fout0 + 3*m; + Fout4 = Fout0 + 4*m; - C_ADD(scratch[3],scratch[1],scratch[2]); - C_SUB(scratch[0],scratch[1],scratch[2]); - tw1 += fstride; - tw2 += fstride*2; + /* For non-custom modes, m is guaranteed to be a multiple of 4. */ + for (u = 0; u < m; ++u) { + scratch[0] = *Fout0; - Fout[m].r = SUB32_ovflw(Fout->r, HALF_OF(scratch[3].r)); - Fout[m].i = SUB32_ovflw(Fout->i, HALF_OF(scratch[3].i)); + C_MUL(scratch[1], *Fout1, tw[u*fstride]); + C_MUL(scratch[2], *Fout2, tw[2*u*fstride]); + C_MUL(scratch[3], *Fout3, tw[3*u*fstride]); + C_MUL(scratch[4], *Fout4, tw[4*u*fstride]); - C_MULBYSCALAR( scratch[0] , epi3.i ); + C_ADD( scratch[7], scratch[1], scratch[4]); + C_SUB( scratch[10], scratch[1], scratch[4]); + C_ADD( scratch[8], scratch[2], scratch[3]); + C_SUB( scratch[9], scratch[2], scratch[3]); - C_ADDTO(*Fout,scratch[3]); + Fout0->r = ADD32_ovflw(Fout0->r, ADD32_ovflw(scratch[7].r, scratch[8].r)); + Fout0->i = ADD32_ovflw(Fout0->i, ADD32_ovflw(scratch[7].i, scratch[8].i)); - Fout[m2].r = ADD32_ovflw(Fout[m].r, scratch[0].i); - Fout[m2].i = SUB32_ovflw(Fout[m].i, scratch[0].r); + scratch[5].r = ADD32_ovflw(scratch[0].r, ADD32_ovflw(S_MUL(scratch[7].r, ya.r), S_MUL(scratch[8].r, yb.r))); + scratch[5].i = ADD32_ovflw(scratch[0].i, ADD32_ovflw(S_MUL(scratch[7].i, ya.r), S_MUL(scratch[8].i, yb.r))); - Fout[m].r = SUB32_ovflw(Fout[m].r, scratch[0].i); - Fout[m].i = ADD32_ovflw(Fout[m].i, scratch[0].r); + scratch[6].r = ADD32_ovflw(S_MUL(scratch[10].i, ya.i), S_MUL(scratch[9].i, yb.i)); + scratch[6].i = NEG32_ovflw(ADD32_ovflw(S_MUL(scratch[10].r, ya.i), S_MUL(scratch[9].r, yb.i))); - ++Fout; - } while(--k); - } -} + C_SUB(*Fout1, scratch[5], scratch[6]); + C_ADD(*Fout4, scratch[5], scratch[6]); + scratch[11].r = ADD32_ovflw(scratch[0].r, + ADD32_ovflw(S_MUL(scratch[7].r, yb.r), S_MUL(scratch[8].r, ya.r))); + scratch[11].i = ADD32_ovflw(scratch[0].i, + ADD32_ovflw(S_MUL(scratch[7].i, yb.r), S_MUL(scratch[8].i, ya.r))); + scratch[12].r = SUB32_ovflw(S_MUL(scratch[9].i, ya.i), S_MUL(scratch[10].i, yb.i)); + scratch[12].i = SUB32_ovflw(S_MUL(scratch[10].r, yb.i), S_MUL(scratch[9].r, ya.i)); -#ifndef OVERRIDE_kf_bfly5 -static void kf_bfly5( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_state *st, - int m, - int N, - int mm - ) -{ - kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; - int i, u; - kiss_fft_cpx scratch[13]; - const kiss_twiddle_cpx *tw; - kiss_twiddle_cpx ya,yb; - kiss_fft_cpx * Fout_beg = Fout; + C_ADD(*Fout2, scratch[11], scratch[12]); + C_SUB(*Fout3, scratch[11], scratch[12]); -#ifdef FIXED_POINT - ya.r = QCONST32(0.30901699f, COEF_SHIFT-1); - ya.i = -QCONST32(0.95105652f, COEF_SHIFT-1); - yb.r = -QCONST32(0.80901699f, COEF_SHIFT-1); - yb.i = -QCONST32(0.58778525f, COEF_SHIFT-1); -#else - ya = st->twiddles[fstride*m]; - yb = st->twiddles[fstride*2*m]; -#endif - tw=st->twiddles; - - for (i=0;ir = ADD32_ovflw(Fout0->r, ADD32_ovflw(scratch[7].r, scratch[8].r)); - Fout0->i = ADD32_ovflw(Fout0->i, ADD32_ovflw(scratch[7].i, scratch[8].i)); - - scratch[5].r = ADD32_ovflw(scratch[0].r, ADD32_ovflw(S_MUL(scratch[7].r,ya.r), S_MUL(scratch[8].r,yb.r))); - scratch[5].i = ADD32_ovflw(scratch[0].i, ADD32_ovflw(S_MUL(scratch[7].i,ya.r), S_MUL(scratch[8].i,yb.r))); - - scratch[6].r = ADD32_ovflw(S_MUL(scratch[10].i,ya.i), S_MUL(scratch[9].i,yb.i)); - scratch[6].i = NEG32_ovflw(ADD32_ovflw(S_MUL(scratch[10].r,ya.i), S_MUL(scratch[9].r,yb.i))); - - C_SUB(*Fout1,scratch[5],scratch[6]); - C_ADD(*Fout4,scratch[5],scratch[6]); - - scratch[11].r = ADD32_ovflw(scratch[0].r, ADD32_ovflw(S_MUL(scratch[7].r,yb.r), S_MUL(scratch[8].r,ya.r))); - scratch[11].i = ADD32_ovflw(scratch[0].i, ADD32_ovflw(S_MUL(scratch[7].i,yb.r), S_MUL(scratch[8].i,ya.r))); - scratch[12].r = SUB32_ovflw(S_MUL(scratch[9].i,ya.i), S_MUL(scratch[10].i,yb.i)); - scratch[12].i = SUB32_ovflw(S_MUL(scratch[10].r,yb.i), S_MUL(scratch[9].r,ya.i)); - - C_ADD(*Fout2,scratch[11],scratch[12]); - C_SUB(*Fout3,scratch[11],scratch[12]); - - ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4; - } - } + ++Fout0; ++Fout1; ++Fout2; ++Fout3; ++Fout4; + } + } } -#endif /* OVERRIDE_kf_bfly5 */ +# endif /* OVERRIDE_oaci_kf_bfly5 */ #endif @@ -319,36 +304,31 @@ static void kf_bfly5( #ifdef CUSTOM_MODES static -void compute_bitrev_table( - int Fout, - opus_int16 *f, - const size_t fstride, - int in_stride, - opus_int16 * factors, - const kiss_fft_state *st - ) -{ - const int p=*factors++; /* the radix */ - const int m=*factors++; /* stage's fft length/p */ +void oaci_compute_bitrev_table( + int Fout, + oac_int16 *f, + const size_t fstride, + int in_stride, + oac_int16 * factors, + const kiss_fft_state *st) { + const int p = *factors++; /* the radix */ + const int m = *factors++; /* stage's fft length/p */ /*printf ("fft %d %d %d %d %d %d\n", p*m, m, p, s2, fstride*in_stride, N);*/ - if (m==1) - { - int j; - for (j=0;j32000 || (opus_int32)p*(opus_int32)p > n) + if (p > 32000 || (oac_int32)p*(oac_int32)p > n) p = n; /* no more factors, skip to end */ } n /= p; -#ifdef RADIX_TWO_ONLY - if (p!=2 && p != 4) -#else - if (p>5) -#endif +# ifdef RADIX_TWO_ONLY + if (p != 2 && p != 4) +# else + if (p > 5) +# endif { - return 0; + return 0; } facbuf[2*stages] = p; - if (p==2 && stages > 1) - { - facbuf[2*stages] = 4; - facbuf[2] = 2; + if (p == 2 && stages > 1) { + facbuf[2*stages] = 4; + facbuf[2] = 2; } stages++; } while (n > 1); @@ -395,46 +373,39 @@ int kf_factor(int n,opus_int16 * facbuf) /* Reverse the order to get the radix 4 at the end, so we can use the fast degenerate case. It turns out that reversing the order also improves the noise behaviour. */ - for (i=0;i= memneeded) st = (kiss_fft_state*)mem; *lenmem = memneeded; } if (st) { - opus_int16 *bitrev; + oac_int16 *bitrev; kiss_twiddle_cpx *twiddles; - st->nfft=nfft; -#ifdef FIXED_POINT - st->scale_shift = celt_ilog2(st->nfft); -# ifdef ENABLE_QEXT + st->nfft = nfft; +# ifdef FIXED_POINT + st->scale_shift = oaci_celt_ilog2(st->nfft); if (st->nfft == 1<scale_shift) - st->scale = QCONST32(1.0f, 30); + st->scale = QCONST32(1.0f, 30); else - st->scale = (((opus_int64)1073741824<scale_shift)+st->nfft/2)/st->nfft; + st->scale = (((oac_int64)1073741824<scale_shift) + st->nfft/2)/st->nfft; # else - if (st->nfft == 1<scale_shift) - st->scale = Q15ONE; - else - st->scale = (1073741824+st->nfft/2)/st->nfft>>(15-st->scale_shift); -# endif -#else st->scale = 1.f/nfft; -#endif - if (base != NULL) - { - st->twiddles = base->twiddles; - st->shift = 0; - while (st->shift < 32 && nfft<shift != base->nfft) - st->shift++; - if (st->shift>=32) - goto fail; +# endif + if (base != NULL) { + st->twiddles = base->twiddles; + st->shift = 0; + while (st->shift < 32 && nfft<shift != base->nfft) + st->shift++; + if (st->shift >= 32) + goto fail; } else { - st->twiddles = twiddles = (kiss_twiddle_cpx*)KISS_FFT_MALLOC(sizeof(kiss_twiddle_cpx)*nfft); - compute_twiddles(twiddles, nfft); - st->shift = -1; + st->twiddles = twiddles = (kiss_twiddle_cpx*)KISS_FFT_MALLOC(sizeof(kiss_twiddle_cpx)*nfft); + oaci_compute_twiddles(twiddles, nfft); + st->shift = -1; } - if (!kf_factor(nfft,st->factors)) - { - goto fail; + if (!oaci_kf_factor(nfft, st->factors)) { + goto fail; } /* bitrev */ - st->bitrev = bitrev = (opus_int16*)KISS_FFT_MALLOC(sizeof(opus_int16)*nfft); - if (st->bitrev==NULL) + st->bitrev = bitrev = (oac_int16*)KISS_FFT_MALLOC(sizeof(oac_int16)*nfft); + if (st->bitrev == NULL) goto fail; - compute_bitrev_table(0, bitrev, 1,1, st->factors,st); + oaci_compute_bitrev_table(0, bitrev, 1, 1, st->factors, st); /* Initialize architecture specific fft parameters */ - if (opus_fft_alloc_arch(st, arch)) + if (oac_fft_alloc_arch(st, arch)) goto fail; } return st; fail: - opus_fft_free(st, arch); + oac_fft_free(st, arch); return NULL; } -kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch) -{ - return opus_fft_alloc_twiddles(nfft, mem, lenmem, NULL, arch); +kiss_fft_state *oac_fft_alloc(int nfft, void * mem, size_t * lenmem, int arch) { + return oac_fft_alloc_twiddles(nfft, mem, lenmem, NULL, arch); } -void opus_fft_free_arch_c(kiss_fft_state *st) { - (void)st; +void oac_fft_free_arch_c(kiss_fft_state *st) { + (void)st; } -void opus_fft_free(const kiss_fft_state *cfg, int arch) -{ - if (cfg) - { - opus_fft_free_arch((kiss_fft_state *)cfg, arch); - opus_free((opus_int16*)cfg->bitrev); - if (cfg->shift < 0) - opus_free((kiss_twiddle_cpx*)cfg->twiddles); - opus_free((kiss_fft_state*)cfg); - } +void oac_fft_free(const kiss_fft_state *cfg, int arch) { + if (cfg) { + oac_fft_free_arch((kiss_fft_state *)cfg, arch); + oac_free((oac_int16*)cfg->bitrev); + if (cfg->shift < 0) + oac_free((kiss_twiddle_cpx*)cfg->twiddles); + oac_free((kiss_fft_state*)cfg); + } } #endif /* CUSTOM_MODES */ #ifdef FIXED_POINT -#ifndef OVERRIDE_fft_downshift -static void fft_downshift(kiss_fft_cpx *x, int N, int *total, int step) { - int shift; - shift = IMIN(step, *total); - *total -= shift; - if (shift == 1) { - int i; - for (i=0;i0) { - int i; - for (i=0;i 0) { + int i; + for (i = 0; i < N; i++) { + x[i].r = PSHR32(x[i].r, shift); + x[i].i = PSHR32(x[i].i, shift); + } + } } -#endif /* OVERRIDE_fft_downshift */ +# endif /* OVERRIDE_oaci_fft_downshift */ #else -#define fft_downshift(x, N, total, step) +# define oaci_fft_downshift(x, N, total, step) #endif -void opus_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout ARG_FIXED(int downshift)) -{ +void oac_fft_impl(const kiss_fft_state *st, kiss_fft_cpx *fout ARG_FIXED(int downshift)) { int m2, m; int p; int L; @@ -569,82 +526,77 @@ void opus_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout ARG_FIXED(int dow int shift; /* st->shift can be -1 */ - shift = st->shift>0 ? st->shift : 0; + shift = st->shift > 0 ? st->shift : 0; fstride[0] = 1; - L=0; + L = 0; do { - p = st->factors[2*L]; - m = st->factors[2*L+1]; - fstride[L+1] = fstride[L]*p; - L++; - } while(m!=1); - m = st->factors[2*L-1]; - for (i=L-1;i>=0;i--) - { - if (i!=0) - m2 = st->factors[2*i-1]; - else - m2 = 1; - switch (st->factors[2*i]) - { - case 2: - fft_downshift(fout, st->nfft, &downshift, 1); - kf_bfly2(fout, m, fstride[i]); - break; - case 4: - fft_downshift(fout, st->nfft, &downshift, 2); - kf_bfly4(fout,fstride[i]<nfft, &downshift, 2); - kf_bfly3(fout,fstride[i]<nfft, &downshift, 3); - kf_bfly5(fout,fstride[i]<factors[2*L]; + m = st->factors[2*L + 1]; + fstride[L + 1] = fstride[L]*p; + L++; + } while (m != 1); + m = st->factors[2*L - 1]; + for (i = L - 1; i >= 0; i--) { + if (i != 0) + m2 = st->factors[2*i - 1]; + else + m2 = 1; + switch (st->factors[2*i]) { + case 2: + oaci_fft_downshift(fout, st->nfft, &downshift, 1); + oaci_kf_bfly2(fout, m, fstride[i]); + break; + case 4: + oaci_fft_downshift(fout, st->nfft, &downshift, 2); + oaci_kf_bfly4(fout, fstride[i]<nfft, &downshift, 2); + oaci_kf_bfly3(fout, fstride[i]<nfft, &downshift, 3); + oaci_kf_bfly5(fout, fstride[i]<nfft, &downshift, downshift); + oaci_fft_downshift(fout, st->nfft, &downshift, downshift); } -void opus_fft_c(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) -{ - int i; - celt_coef scale; +void oac_fft_c(const kiss_fft_state *st, const kiss_fft_cpx *fin, kiss_fft_cpx *fout) { + int i; + celt_coef scale; #ifdef FIXED_POINT - /* Allows us to scale with MULT16_32_Q16(), which is faster than - MULT16_32_Q15() on ARM. */ - int scale_shift = st->scale_shift-1; + /* Allows us to scale with MULT16_32_Q16(), which is faster than + MULT16_32_Q15() on ARM. */ + int scale_shift = st->scale_shift - 1; #endif - scale = st->scale; - - celt_assert2 (fin != fout, "In-place FFT not supported"); - /* Bit-reverse the input */ - for (i=0;infft;i++) - { - kiss_fft_cpx x = fin[i]; - fout[st->bitrev[i]].r = S_MUL2(x.r, scale); - fout[st->bitrev[i]].i = S_MUL2(x.i, scale); - } - opus_fft_impl(st, fout ARG_FIXED(scale_shift)); + scale = st->scale; + + celt_assert2 (fin != fout, "In-place FFT not supported"); + /* Bit-reverse the input */ + for (i = 0; i < st->nfft; i++) { + kiss_fft_cpx x = fin[i]; + fout[st->bitrev[i]].r = S_MUL2(x.r, scale); + fout[st->bitrev[i]].i = S_MUL2(x.i, scale); + } + oac_fft_impl(st, fout ARG_FIXED(scale_shift)); } -void opus_ifft_c(const kiss_fft_state *st,const kiss_fft_cpx *fin,kiss_fft_cpx *fout) -{ - int i; - celt_assert2 (fin != fout, "In-place FFT not supported"); - /* Bit-reverse the input */ - for (i=0;infft;i++) - fout[st->bitrev[i]] = fin[i]; - for (i=0;infft;i++) - fout[i].i = -fout[i].i; - opus_fft_impl(st, fout ARG_FIXED(0)); - for (i=0;infft;i++) - fout[i].i = -fout[i].i; +void oac_ifft_c(const kiss_fft_state *st, const kiss_fft_cpx *fin, kiss_fft_cpx *fout) { + int i; + celt_assert2 (fin != fout, "In-place FFT not supported"); + /* Bit-reverse the input */ + for (i = 0; i < st->nfft; i++) + fout[st->bitrev[i]] = fin[i]; + for (i = 0; i < st->nfft; i++) + fout[i].i = -fout[i].i; + oac_fft_impl(st, fout ARG_FIXED(0)); + for (i = 0; i < st->nfft; i++) + fout[i].i = -fout[i].i; } diff --git a/celt/kiss_fft.h b/celt/kiss_fft.h index 20eb0b21c..307ad5dbe 100644 --- a/celt/kiss_fft.h +++ b/celt/kiss_fft.h @@ -1,30 +1,30 @@ /*Copyright (c) 2003-2004, Mark Borgerding - Lots of modifications by Jean-Marc Valin - Copyright (c) 2005-2007, Xiph.Org Foundation - Copyright (c) 2008, Xiph.Org Foundation, CSIRO + Lots of modifications by Jean-Marc Valin + Copyright (c) 2005-2007, Xiph.Org Foundation + Copyright (c) 2008, Xiph.Org Foundation, CSIRO - All rights reserved. + All rights reserved. - Redistribution and use in source and binary forms, with or without + 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, + * 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, + * 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.*/ + 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.*/ #ifndef KISS_FFT_H #define KISS_FFT_H @@ -37,42 +37,38 @@ #ifdef USE_SIMD # include # define kiss_fft_scalar __m128 -#define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes) +# define KISS_FFT_MALLOC(nbytes) memalign(16, nbytes) #else -#define KISS_FFT_MALLOC opus_alloc +# define KISS_FFT_MALLOC oac_alloc #endif #ifdef FIXED_POINT -#include "arch.h" +# include "arch.h" -# define kiss_fft_scalar opus_int32 -# ifdef ENABLE_QEXT -# define COEF_SHIFT 32 -# else -# define COEF_SHIFT 16 -# endif +# define kiss_fft_scalar oac_int32 +# define COEF_SHIFT 32 -# define kiss_twiddle_scalar celt_coef +# define kiss_twiddle_scalar celt_coef /* 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)) +# define KISS_TWIDDLE_CPX_ALIGNMENT (sizeof(oac_int32)) #else # ifndef kiss_fft_scalar /* default is float */ -# define kiss_fft_scalar float -# define kiss_twiddle_scalar float -# define KF_SUFFIX _celt_single +# define kiss_fft_scalar float +# define kiss_twiddle_scalar float +# define KF_SUFFIX _celt_single # endif #endif #if defined(__GNUC__) && defined(KISS_TWIDDLE_CPX_ALIGNMENT) -#define KISS_TWIDDLE_CPX_ALIGNED __attribute__((aligned(KISS_TWIDDLE_CPX_ALIGNMENT))) +# define KISS_TWIDDLE_CPX_ALIGNED __attribute__((aligned(KISS_TWIDDLE_CPX_ALIGNMENT))) #else -#define KISS_TWIDDLE_CPX_ALIGNED +# define KISS_TWIDDLE_CPX_ALIGNED #endif typedef struct { @@ -81,51 +77,51 @@ typedef struct { }kiss_fft_cpx; typedef struct { - kiss_twiddle_scalar r; - kiss_twiddle_scalar i; + kiss_twiddle_scalar r; + kiss_twiddle_scalar i; } KISS_TWIDDLE_CPX_ALIGNED kiss_twiddle_cpx; #define MAXFACTORS 8 /* e.g. an fft of length 128 has 4 factors - as far as kissfft is concerned - 4*4*4*2 + as far as kissfft is concerned + 4*4*4*2 */ -typedef struct arch_fft_state{ - int is_supported; - void *priv; +typedef struct arch_fft_state { + int is_supported; + void *priv; } arch_fft_state; -typedef struct kiss_fft_state{ +typedef struct kiss_fft_state { int nfft; celt_coef scale; #ifdef FIXED_POINT int scale_shift; #endif int shift; - opus_int16 factors[2*MAXFACTORS]; - const opus_int16 *bitrev; + oac_int16 factors[2*MAXFACTORS]; + const oac_int16 *bitrev; const kiss_twiddle_cpx *twiddles; arch_fft_state *arch_fft; } kiss_fft_state; #if defined(HAVE_ARM_NE10) -#include "arm/fft_arm.h" +# include "arm/fft_arm.h" #endif /*typedef struct kiss_fft_state* kiss_fft_cfg;*/ /** - * opus_fft_alloc + * oac_fft_alloc * * Initialize a FFT (or IFFT) algorithm's cfg/state buffer. * - * typical usage: kiss_fft_cfg mycfg=opus_fft_alloc(1024,0,NULL,NULL); + * typical usage: kiss_fft_cfg mycfg=oac_fft_alloc(1024,0,NULL,NULL); * * The return value from fft_alloc is a cfg buffer used internally * by the fft routine or NULL. * - * If lenmem is NULL, then opus_fft_alloc will allocate a cfg buffer using malloc. + * If lenmem is NULL, then oac_fft_alloc will allocate a cfg buffer using malloc. * The returned value should be free()d when done to avoid memory leaks. * * The state can be placed in a user supplied buffer 'mem': @@ -138,12 +134,12 @@ typedef struct kiss_fft_state{ * buffer size in *lenmem. * */ -kiss_fft_state *opus_fft_alloc_twiddles(int nfft,void * mem,size_t * lenmem, const kiss_fft_state *base, int arch); +kiss_fft_state *oac_fft_alloc_twiddles(int nfft, void * mem, size_t * lenmem, const kiss_fft_state *base, int arch); -kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch); +kiss_fft_state *oac_fft_alloc(int nfft, void * mem, size_t * lenmem, int arch); /** - * opus_fft(cfg,in_out_buf) + * oac_fft(cfg,in_out_buf) * * Perform an FFT on a complex input buffer. * for a forward FFT, @@ -152,58 +148,58 @@ kiss_fft_state *opus_fft_alloc(int nfft,void * mem,size_t * lenmem, int arch); * Note that each element is complex and can be accessed like f[k].r and f[k].i * */ -void opus_fft_c(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); -void opus_ifft_c(const kiss_fft_state *cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout); +void oac_fft_c(const kiss_fft_state *cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout); +void oac_ifft_c(const kiss_fft_state *cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout); -void opus_fft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout ARG_FIXED(int downshift)); -void opus_ifft_impl(const kiss_fft_state *st,kiss_fft_cpx *fout); +void oac_fft_impl(const kiss_fft_state*st, kiss_fft_cpx*fout ARG_FIXED(int downshift)); +void oac_ifft_impl(const kiss_fft_state *st, kiss_fft_cpx *fout); -void opus_fft_free(const kiss_fft_state *cfg, int arch); +void oac_fft_free(const kiss_fft_state *cfg, int arch); -void opus_fft_free_arch_c(kiss_fft_state *st); -int opus_fft_alloc_arch_c(kiss_fft_state *st); +void oac_fft_free_arch_c(kiss_fft_state *st); +int oac_fft_alloc_arch_c(kiss_fft_state *st); -#if !defined(OVERRIDE_OPUS_FFT) +#if !defined(OVERRIDE_OAC_FFT) /* Is run-time CPU detection enabled on this platform? */ -#if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) +# if defined(OAC_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) -extern int (*const OPUS_FFT_ALLOC_ARCH_IMPL[OPUS_ARCHMASK+1])( +extern int (*const OAC_FFT_ALLOC_ARCH_IMPL[OAC_ARCHMASK + 1])( kiss_fft_state *st); -#define opus_fft_alloc_arch(_st, arch) \ - ((*OPUS_FFT_ALLOC_ARCH_IMPL[(arch)&OPUS_ARCHMASK])(_st)) +# define oac_fft_alloc_arch(_st, arch) \ + ((*OAC_FFT_ALLOC_ARCH_IMPL[(arch)&OAC_ARCHMASK])(_st)) -extern void (*const OPUS_FFT_FREE_ARCH_IMPL[OPUS_ARCHMASK+1])( +extern void (*const OAC_FFT_FREE_ARCH_IMPL[OAC_ARCHMASK + 1])( kiss_fft_state *st); -#define opus_fft_free_arch(_st, arch) \ - ((*OPUS_FFT_FREE_ARCH_IMPL[(arch)&OPUS_ARCHMASK])(_st)) +# define oac_fft_free_arch(_st, arch) \ + ((*OAC_FFT_FREE_ARCH_IMPL[(arch)&OAC_ARCHMASK])(_st)) -extern void (*const OPUS_FFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg, +extern void (*const OAC_FFT[OAC_ARCHMASK + 1])(const kiss_fft_state *cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout); -#define opus_fft(_cfg, _fin, _fout, arch) \ - ((*OPUS_FFT[(arch)&OPUS_ARCHMASK])(_cfg, _fin, _fout)) +# define oac_fft(_cfg, _fin, _fout, arch) \ + ((*OAC_FFT[(arch)&OAC_ARCHMASK])(_cfg, _fin, _fout)) -extern void (*const OPUS_IFFT[OPUS_ARCHMASK+1])(const kiss_fft_state *cfg, +extern void (*const OAC_IFFT[OAC_ARCHMASK + 1])(const kiss_fft_state *cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout); -#define opus_ifft(_cfg, _fin, _fout, arch) \ - ((*OPUS_IFFT[(arch)&OPUS_ARCHMASK])(_cfg, _fin, _fout)) +# define oac_ifft(_cfg, _fin, _fout, arch) \ + ((*OAC_IFFT[(arch)&OAC_ARCHMASK])(_cfg, _fin, _fout)) -#else /* else for if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */ +# else /* else for if defined(OAC_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */ -#define opus_fft_alloc_arch(_st, arch) \ - ((void)(arch), opus_fft_alloc_arch_c(_st)) +# define oac_fft_alloc_arch(_st, arch) \ + ((void)(arch), oac_fft_alloc_arch_c(_st)) -#define opus_fft_free_arch(_st, arch) \ - ((void)(arch), opus_fft_free_arch_c(_st)) +# define oac_fft_free_arch(_st, arch) \ + ((void)(arch), oac_fft_free_arch_c(_st)) -#define opus_fft(_cfg, _fin, _fout, arch) \ - ((void)(arch), opus_fft_c(_cfg, _fin, _fout)) +# define oac_fft(_cfg, _fin, _fout, arch) \ + ((void)(arch), oac_fft_c(_cfg, _fin, _fout)) -#define opus_ifft(_cfg, _fin, _fout, arch) \ - ((void)(arch), opus_ifft_c(_cfg, _fin, _fout)) +# define oac_ifft(_cfg, _fin, _fout, arch) \ + ((void)(arch), oac_ifft_c(_cfg, _fin, _fout)) -#endif /* end if defined(OPUS_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */ -#endif /* end if !defined(OVERRIDE_OPUS_FFT) */ +# endif /* end if defined(OAC_HAVE_RTCD) && (defined(HAVE_ARM_NE10)) */ +#endif /* end if !defined(OVERRIDE_OAC_FFT) */ #endif diff --git a/celt/laplace.c b/celt/laplace.c index 218096666..53ed89afb 100644 --- a/celt/laplace.c +++ b/celt/laplace.c @@ -24,10 +24,10 @@ 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" +# include "config.h" #endif #include "laplace.h" @@ -41,195 +41,178 @@ #define LAPLACE_NMIN (16) /* When called, decay is positive and at most 11456. */ -static unsigned ec_laplace_get_freq1(unsigned fs0, int decay) -{ - unsigned ft; - ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN) - fs0; - return ft*(opus_int32)(16384-decay)>>15; +static unsigned oaci_ec_laplace_get_freq1(unsigned fs0, int decay) { + unsigned ft; + ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN) - fs0; + return ft*(oac_int32)(16384 - decay)>>15; } -void ec_laplace_encode(ec_enc *enc, int *value, unsigned fs, int decay) -{ - unsigned fl; - int val = *value; - fl = 0; - if (val) - { - int s; - int i; - s = -(val<0); - val = (val+s)^s; - fl = fs; - fs = ec_laplace_get_freq1(fs, decay); - /* Search the decaying part of the PDF.*/ - for (i=1; fs > 0 && i < val; i++) - { - fs *= 2; - fl += fs+2*LAPLACE_MINP; - fs = (fs*(opus_int32)decay)>>15; - } - /* Everything beyond that has probability LAPLACE_MINP. */ - if (!fs) - { - int di; - int ndi_max; - ndi_max = (32768-fl+LAPLACE_MINP-1)>>LAPLACE_LOG_MINP; - ndi_max = (ndi_max-s)>>1; - di = IMIN(val - i, ndi_max - 1); - fl += (2*di+1+s)*LAPLACE_MINP; - fs = IMIN(LAPLACE_MINP, 32768-fl); - *value = (i+di+s)^s; - } - else - { - fs += LAPLACE_MINP; - fl += fs&~s; - } - celt_assert(fl+fs<=32768); - celt_assert(fs>0); - } - ec_encode_bin(enc, fl, fl+fs, 15); +void oaci_ec_laplace_encode(ec_enc *enc, int *value, unsigned fs, int decay) { + unsigned fl; + int val = *value; + fl = 0; + if (val) { + int s; + int i; + s = -(val < 0); + val = (val + s)^s; + fl = fs; + fs = oaci_ec_laplace_get_freq1(fs, decay); + /* Search the decaying part of the PDF.*/ + for (i = 1; fs > 0 && i < val; i++) { + fs *= 2; + fl += fs + 2*LAPLACE_MINP; + fs = (fs*(oac_int32)decay)>>15; + } + /* Everything beyond that has probability LAPLACE_MINP. */ + if (!fs) { + int di; + int ndi_max; + ndi_max = (32768 - fl + LAPLACE_MINP - 1)>>LAPLACE_LOG_MINP; + ndi_max = (ndi_max - s)>>1; + di = IMIN(val - i, ndi_max - 1); + fl += (2*di + 1 + s)*LAPLACE_MINP; + fs = IMIN(LAPLACE_MINP, 32768 - fl); + *value = (i + di + s)^s; + } else { + fs += LAPLACE_MINP; + fl += fs&~s; + } + celt_assert(fl + fs <= 32768); + celt_assert(fs > 0); + } + oaci_ec_encode_bin(enc, fl, fl + fs, 15); } -int ec_laplace_decode(ec_dec *dec, unsigned fs, int decay) -{ - int val=0; - unsigned fl; - unsigned fm; - fm = ec_decode_bin(dec, 15); - fl = 0; - if (fm >= fs) - { - val++; - fl = fs; - fs = ec_laplace_get_freq1(fs, decay)+LAPLACE_MINP; - /* Search the decaying part of the PDF.*/ - while(fs > LAPLACE_MINP && fm >= fl+2*fs) - { - fs *= 2; - fl += fs; - fs = ((fs-2*LAPLACE_MINP)*(opus_int32)decay)>>15; - fs += LAPLACE_MINP; - val++; - } - /* Everything beyond that has probability LAPLACE_MINP. */ - if (fs <= LAPLACE_MINP) - { - int di; - di = (fm-fl)>>(LAPLACE_LOG_MINP+1); - val += di; - fl += 2*di*LAPLACE_MINP; - } - if (fm < fl+fs) - val = -val; - else - fl += fs; - } - celt_assert(fl<32768); - celt_assert(fs>0); - celt_assert(fl<=fm); - celt_assert(fm= fs) { + val++; + fl = fs; + fs = oaci_ec_laplace_get_freq1(fs, decay) + LAPLACE_MINP; + /* Search the decaying part of the PDF.*/ + while (fs > LAPLACE_MINP && fm >= fl + 2*fs) { + fs *= 2; + fl += fs; + fs = ((fs - 2*LAPLACE_MINP)*(oac_int32)decay)>>15; + fs += LAPLACE_MINP; + val++; + } + /* Everything beyond that has probability LAPLACE_MINP. */ + if (fs <= LAPLACE_MINP) { + int di; + di = (fm - fl)>>(LAPLACE_LOG_MINP + 1); + val += di; + fl += 2*di*LAPLACE_MINP; + } + if (fm < fl + fs) + val = -val; + else + fl += fs; + } + celt_assert(fl < 32768); + celt_assert(fs > 0); + celt_assert(fl <= fm); + celt_assert(fm < IMIN(fl + fs, 32768)); + oaci_ec_dec_update(dec, fl, IMIN(fl + fs, 32768), 32768); + return val; } -void ec_laplace_encode_p0(ec_enc *enc, int value, opus_uint16 p0, opus_uint16 decay) -{ - int s; - opus_uint16 sign_icdf[3]; - sign_icdf[0] = 32768-p0; - sign_icdf[1] = sign_icdf[0]/2; - sign_icdf[2] = 0; - s = value == 0 ? 0 : (value > 0 ? 1 : 2); - ec_enc_icdf16(enc, s, sign_icdf, 15); - value = abs(value); - if (value) - { - int i; - opus_uint16 icdf[8]; - icdf[0] = IMAX(7, decay); - for (i=1;i<7;i++) - { - icdf[i] = IMAX(7-i, (icdf[i-1] * (opus_int32)decay) >> 15); - } - icdf[7] = 0; - value--; - do { - ec_enc_icdf16(enc, IMIN(value, 7), icdf, 15); - value -= 7; - } while (value >= 0); - } +void oaci_ec_laplace_encode_p0(ec_enc *enc, int value, oac_uint16 p0, oac_uint16 decay) { + int s; + oac_uint16 sign_icdf[3]; + sign_icdf[0] = 32768 - p0; + sign_icdf[1] = sign_icdf[0]/2; + sign_icdf[2] = 0; + s = value == 0 ? 0 : (value > 0 ? 1 : 2); + oaci_ec_enc_icdf16(enc, s, sign_icdf, 15); + value = abs(value); + if (value) { + int i; + oac_uint16 icdf[8]; + icdf[0] = IMAX(7, decay); + for (i = 1; i < 7; i++) { + icdf[i] = IMAX(7 - i, (icdf[i - 1]*(oac_int32)decay)>>15); + } + icdf[7] = 0; + value--; + do { + oaci_ec_enc_icdf16(enc, IMIN(value, 7), icdf, 15); + value -= 7; + } while (value >= 0); + } } -int ec_laplace_decode_p0(ec_dec *dec, opus_uint16 p0, opus_uint16 decay) -{ - int s; - int value; - opus_uint16 sign_icdf[3]; - sign_icdf[0] = 32768-p0; - sign_icdf[1] = sign_icdf[0]/2; - sign_icdf[2] = 0; - s = ec_dec_icdf16(dec, sign_icdf, 15); - if (s==2) s = -1; - if (s != 0) - { - int i; - int v; - opus_uint16 icdf[8]; - icdf[0] = IMAX(7, decay); - for (i=1;i<7;i++) - { - icdf[i] = IMAX(7-i, (icdf[i-1] * (opus_int32)decay) >> 15); - } - icdf[7] = 0; - value = 1; - do { - v = ec_dec_icdf16(dec, icdf, 15); - value += v; - } while (v == 7); - return s*value; - } else return 0; +int oaci_ec_laplace_decode_p0(ec_dec *dec, oac_uint16 p0, oac_uint16 decay) { + int s; + int value; + oac_uint16 sign_icdf[3]; + sign_icdf[0] = 32768 - p0; + sign_icdf[1] = sign_icdf[0]/2; + sign_icdf[2] = 0; + s = oaci_ec_dec_icdf16(dec, sign_icdf, 15); + if (s == 2) s = -1; + if (s != 0) { + int i; + int v; + oac_uint16 icdf[8]; + icdf[0] = IMAX(7, decay); + for (i = 1; i < 7; i++) { + icdf[i] = IMAX(7 - i, (icdf[i - 1]*(oac_int32)decay)>>15); + } + icdf[7] = 0; + value = 1; + do { + v = oaci_ec_dec_icdf16(dec, icdf, 15); + value += v; + } while (v == 7); + return s*value; + } else return 0; } #if 0 -#include -#define NB_VALS 10 -#define DATA_SIZE 10000 +# include +# define NB_VALS 10 +# define DATA_SIZE 10000 int main() { - ec_enc enc; - ec_dec dec; - unsigned char *ptr; - int i; - int decay, p0; - int val[NB_VALS] = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; - /*for (i=0;i>1; - b=1U<>=1; - bshift--; - } - while(bshift>=0); - return g; + _val must be greater than 0. + This has been tested on all possible 32-bit inputs greater than 0.*/ +unsigned oaci_isqrt32(oac_uint32 _val) { + unsigned b; + unsigned g; + int bshift; + /*Uses the second method from + http://www.azillionmonkeys.com/qed/sqroot.html + The main idea is to search for the largest binary digit b such that + (g+b)*(g+b) <= _val, and add it to the solution g.*/ + g = 0; + bshift = (EC_ILOG(_val) - 1)>>1; + b = 1U<>= 1; + bshift--; + } while (bshift >= 0); + return g; } #ifdef FIXED_POINT -opus_val32 frac_div32_q29(opus_val32 a, opus_val32 b) -{ - opus_val16 rcp; - opus_val32 result, rem; - int shift = celt_ilog2(b)-29; - a = VSHR32(a,shift); - b = VSHR32(b,shift); - /* 16-bit reciprocal */ - rcp = ROUND16(celt_rcp(ROUND16(b,16)),3); - result = MULT16_32_Q15(rcp, a); - rem = PSHR32(a,2)-MULT32_32_Q31(result, b); - result = ADD32(result, SHL32(MULT16_32_Q15(rcp, rem),2)); - return result; +oac_val32 oaci_frac_div32_q29(oac_val32 a, oac_val32 b) { + oac_val16 rcp; + oac_val32 result, rem; + int shift = oaci_celt_ilog2(b) - 29; + a = VSHR32(a, shift); + b = VSHR32(b, shift); + /* 16-bit reciprocal */ + rcp = ROUND16(oaci_celt_rcp(ROUND16(b, 16)), 3); + result = MULT16_32_Q15(rcp, a); + rem = PSHR32(a, 2) - MULT32_32_Q31(result, b); + result = ADD32(result, SHL32(MULT16_32_Q15(rcp, rem), 2)); + return result; } -opus_val32 frac_div32(opus_val32 a, opus_val32 b) { - opus_val32 result = frac_div32_q29(a,b); - if (result >= 536870912) /* 2^29 */ - return 2147483647; /* 2^31 - 1 */ - else if (result <= -536870912) /* -2^29 */ - return -2147483647; /* -2^31 */ - else - return SHL32(result, 2); +oac_val32 oaci_frac_div32(oac_val32 a, oac_val32 b) { + oac_val32 result = oaci_frac_div32_q29(a, b); + if (result >= 536870912) /* 2^29 */ + return 2147483647; /* 2^31 - 1 */ + else if (result <= -536870912) /* -2^29 */ + return -2147483647; /* -2^31 */ + else + return SHL32(result, 2); } /** Reciprocal sqrt approximation in the range [0.25,1) (Q16 in, Q14 out) */ -opus_val16 celt_rsqrt_norm(opus_val32 x) -{ - opus_val16 n; - opus_val16 r; - opus_val16 r2; - opus_val16 y; - /* Range of n is [-16384,32767] ([-0.5,1) in Q15). */ - n = x-32768; - /* Get a rough initial guess for the root. - The optimal minimax quadratic approximation (using relative error) is - r = 1.437799046117536+n*(-0.823394375837328+n*0.4096419668459485). - Coefficients here, and the final result r, are Q14.*/ - r = ADD16(23557, MULT16_16_Q15(n, ADD16(-13490, MULT16_16_Q15(n, 6713)))); - /* We want y = x*r*r-1 in Q15, but x is 32-bit Q16 and r is Q14. - We can compute the result from n and r using Q15 multiplies with some - adjustment, carefully done to avoid overflow. - Range of y is [-1564,1594]. */ - r2 = MULT16_16_Q15(r, r); - y = SHL16(SUB16(ADD16(MULT16_16_Q15(r2, n), r2), 16384), 1); - /* Apply a 2nd-order Householder iteration: r += r*y*(y*0.375-0.5). - This yields the Q14 reciprocal square root of the Q16 x, with a maximum - relative error of 1.04956E-4, a (relative) RMSE of 2.80979E-5, and a - peak absolute error of 2.26591/16384. */ - return ADD16(r, MULT16_16_Q15(r, MULT16_16_Q15(y, +oac_val16 oaci_celt_rsqrt_norm(oac_val32 x) { + oac_val16 n; + oac_val16 r; + oac_val16 r2; + oac_val16 y; + /* Range of n is [-16384,32767] ([-0.5,1) in Q15). */ + n = x - 32768; + /* Get a rough initial guess for the root. + The optimal minimax quadratic approximation (using relative error) is + r = 1.437799046117536+n*(-0.823394375837328+n*0.4096419668459485). + Coefficients here, and the final result r, are Q14.*/ + r = ADD16(23557, MULT16_16_Q15(n, ADD16(-13490, MULT16_16_Q15(n, 6713)))); + /* We want y = x*r*r-1 in Q15, but x is 32-bit Q16 and r is Q14. + We can compute the result from n and r using Q15 multiplies with some + adjustment, carefully done to avoid overflow. + Range of y is [-1564,1594]. */ + r2 = MULT16_16_Q15(r, r); + y = SHL16(SUB16(ADD16(MULT16_16_Q15(r2, n), r2), 16384), 1); + /* Apply a 2nd-order Householder iteration: r += r*y*(y*0.375-0.5). + This yields the Q14 reciprocal square root of the Q16 x, with a maximum + relative error of 1.04956E-4, a (relative) RMSE of 2.80979E-5, and a + peak absolute error of 2.26591/16384. */ + return ADD16(r, MULT16_16_Q15(r, MULT16_16_Q15(y, SUB16(MULT16_16_Q15(y, 12288), 16384)))); } /** Reciprocal sqrt approximation in the range [0.25,1) (Q31 in, Q29 out) */ -opus_val32 celt_rsqrt_norm32(opus_val32 x) -{ - opus_int32 tmp; - /* Use the first-order Newton-Raphson method to refine the root estimate. - * r = r * (1.5 - 0.5*x*r*r) */ - opus_int32 r_q29 = SHL32(celt_rsqrt_norm(SHR32(x, 31-16)), 15); - /* Split evaluation in steps to avoid exploding macro expansion. */ - tmp = MULT32_32_Q31(r_q29, r_q29); - tmp = MULT32_32_Q31(1073741824 /* Q31 */, tmp); - tmp = MULT32_32_Q31(x, tmp); - return SHL32(MULT32_32_Q31(r_q29, SUB32(201326592 /* Q27 */, tmp)), 4); +oac_val32 oaci_celt_rsqrt_norm32(oac_val32 x) { + oac_int32 tmp; + /* Use the first-order Newton-Raphson method to refine the root estimate. + * r = r * (1.5 - 0.5*x*r*r) */ + oac_int32 r_q29 = SHL32(oaci_celt_rsqrt_norm(SHR32(x, 31 - 16)), 15); + /* Split evaluation in steps to avoid exploding macro expansion. */ + tmp = MULT32_32_Q31(r_q29, r_q29); + tmp = MULT32_32_Q31(1073741824 /* Q31 */, tmp); + tmp = MULT32_32_Q31(x, tmp); + return SHL32(MULT32_32_Q31(r_q29, SUB32(201326592 /* Q27 */, tmp)), 4); } /** Sqrt approximation (QX input, QX/2 output) */ -opus_val32 celt_sqrt(opus_val32 x) -{ - int k; - opus_val16 n; - opus_val32 rt; - /* These coeffs are optimized in fixed-point to minimize both RMS and max error - of sqrt(x) over .25=1073741824) - return 32767; - k = (celt_ilog2(x)>>1)-7; - x = VSHR32(x, 2*k); - n = x-32768; - rt = ADD32(C[0], MULT16_16_Q15(n, ADD16(C[1], MULT16_16_Q15(n, ADD16(C[2], +oac_val32 oaci_celt_sqrt(oac_val32 x) { + int k; + oac_val16 n; + oac_val32 rt; + /* These coeffs are optimized in fixed-point to minimize both RMS and max error + of sqrt(x) over .25= 1073741824) + return 32767; + k = (oaci_celt_ilog2(x)>>1) - 7; + x = VSHR32(x, 2*k); + n = x - 32768; + rt = ADD32(C[0], MULT16_16_Q15(n, ADD16(C[1], MULT16_16_Q15(n, ADD16(C[2], MULT16_16_Q15(n, ADD16(C[3], MULT16_16_Q15(n, ADD16(C[4], MULT16_16_Q15(n, (C[5]))))))))))); - rt = VSHR32(rt,7-k); - return rt; + rt = VSHR32(rt, 7 - k); + return rt; } /* Perform fixed-point arithmetic to approximate the square root. When the input * is in Qx format, the output will be in Q(x/2 + 16) format. */ -opus_val32 celt_sqrt32(opus_val32 x) -{ - int k; - opus_int32 x_frac; - if (x==0) - return 0; - else if (x>=1073741824) - return 2147483647; /* 2^31 -1 */ - k = (celt_ilog2(x)>>1); - x_frac = VSHR32(x, 2*(k-14)-1); - x_frac = MULT32_32_Q31(celt_rsqrt_norm32(x_frac), x_frac); - if (k < 12) return PSHR32(x_frac, 12-k); - else return SHL32(x_frac, k-12); +oac_val32 oaci_celt_sqrt32(oac_val32 x) { + int k; + oac_int32 x_frac; + if (x == 0) + return 0; + else if (x >= 1073741824) + return 2147483647; /* 2^31 -1 */ + k = (oaci_celt_ilog2(x)>>1); + x_frac = VSHR32(x, 2*(k - 14) - 1); + x_frac = MULT32_32_Q31(oaci_celt_rsqrt_norm32(x_frac), x_frac); + if (k < 12) return PSHR32(x_frac, 12 - k); + else return SHL32(x_frac, k - 12); } -#define L1 32767 -#define L2 -7651 -#define L3 8277 -#define L4 -626 +# define L1 32767 +# define L2 -7651 +# define L3 8277 +# define L4 -626 -static OPUS_INLINE opus_val16 _celt_cos_pi_2(opus_val16 x) -{ - opus_val16 x2; +static OAC_INLINE oac_val16 oaci_celt_cos_pi_2(oac_val16 x) { + oac_val16 x2; - x2 = MULT16_16_P15(x,x); - return ADD16(1,MIN16(32766,ADD32(SUB16(L1,x2), MULT16_16_P15(x2, ADD32(L2, MULT16_16_P15(x2, ADD32(L3, MULT16_16_P15(L4, x2 - )))))))); + x2 = MULT16_16_P15(x, x); + return ADD16(1, + MIN16(32766, ADD32(SUB16(L1, x2), MULT16_16_P15(x2, ADD32(L2, MULT16_16_P15(x2, ADD32(L3, MULT16_16_P15(L4, x2 + )))))))); } -#undef L1 -#undef L2 -#undef L3 -#undef L4 +# undef L1 +# undef L2 +# undef L3 +# undef L4 -opus_val16 celt_cos_norm(opus_val32 x) -{ - x = x&0x0001ffff; - if (x>SHL32(EXTEND32(1), 16)) - x = SUB32(SHL32(EXTEND32(1), 17),x); - if (x&0x00007fff) - { - if (x SHL32(EXTEND32(1), 16)) + x = SUB32(SHL32(EXTEND32(1), 17), x); + if (x&0x00007fff) { + if (x < SHL32(EXTEND32(1), 15)) { + return oaci_celt_cos_pi_2(EXTRACT16(x)); + } else { + return NEG16(oaci_celt_cos_pi_2(EXTRACT16(65536 - x))); + } + } else { + if (x&0x0000ffff) + return 0; + else if (x&0x0001ffff) + return -32767; + else + return 32767; + } } /* Calculates the cosine of (PI*0.5*x) where the input x ranges from -1 to 1 and * is in Q30 format. The output will also be in Q31 format. */ -opus_val32 celt_cos_norm32(opus_val32 x) -{ - static const opus_val32 COS_NORM_COEFF_A0 = 134217720; /* Q27 */ - static const opus_val32 COS_NORM_COEFF_A1 = -662336704; /* Q29 */ - static const opus_val32 COS_NORM_COEFF_A2 = 544710848; /* Q31 */ - static const opus_val32 COS_NORM_COEFF_A3 = -178761936; /* Q33 */ - static const opus_val32 COS_NORM_COEFF_A4 = 29487206; /* Q35 */ - opus_int32 x_sq_q29, tmp; - /* The expected x is in the range of [-1.0f, 1.0f] */ - celt_sig_assert((x >= -1073741824) && (x <= 1073741824)); - /* Make cos(+/- pi/2) exactly zero. */ - if (ABS32(x) == 1<<30) return 0; - x_sq_q29 = MULT32_32_Q31(x, x); - /* Split evaluation in steps to avoid exploding macro expansion. */ - tmp = ADD32(COS_NORM_COEFF_A3, MULT32_32_Q31(x_sq_q29, COS_NORM_COEFF_A4)); - tmp = ADD32(COS_NORM_COEFF_A2, MULT32_32_Q31(x_sq_q29, tmp)); - tmp = ADD32(COS_NORM_COEFF_A1, MULT32_32_Q31(x_sq_q29, tmp)); - return SHL32(ADD32(COS_NORM_COEFF_A0, MULT32_32_Q31(x_sq_q29, tmp)), 4); +oac_val32 oaci_celt_cos_norm32(oac_val32 x) { + static const oac_val32 COS_NORM_COEFF_A0 = 134217720; /* Q27 */ + static const oac_val32 COS_NORM_COEFF_A1 = -662336704; /* Q29 */ + static const oac_val32 COS_NORM_COEFF_A2 = 544710848; /* Q31 */ + static const oac_val32 COS_NORM_COEFF_A3 = -178761936; /* Q33 */ + static const oac_val32 COS_NORM_COEFF_A4 = 29487206; /* Q35 */ + oac_int32 x_sq_q29, tmp; + /* The expected x is in the range of [-1.0f, 1.0f] */ + celt_sig_assert((x >= -1073741824) && (x <= 1073741824)); + /* Make cos(+/- pi/2) exactly zero. */ + if (ABS32(x) == 1<<30) return 0; + x_sq_q29 = MULT32_32_Q31(x, x); + /* Split evaluation in steps to avoid exploding macro expansion. */ + tmp = ADD32(COS_NORM_COEFF_A3, MULT32_32_Q31(x_sq_q29, COS_NORM_COEFF_A4)); + tmp = ADD32(COS_NORM_COEFF_A2, MULT32_32_Q31(x_sq_q29, tmp)); + tmp = ADD32(COS_NORM_COEFF_A1, MULT32_32_Q31(x_sq_q29, tmp)); + return SHL32(ADD32(COS_NORM_COEFF_A0, MULT32_32_Q31(x_sq_q29, tmp)), 4); } /* Computes a 16 bit approximate reciprocal (1/x) for a normalized Q15 input, * resulting in a Q15 output. */ -opus_val16 celt_rcp_norm16(opus_val16 x) -{ - opus_val16 r; - /* Start with a linear approximation: - r = 1.8823529411764706-0.9411764705882353*n. - The coefficients and the result are Q14 in the range [15420,30840].*/ - r = ADD16(30840, MULT16_16_Q15(-15420, x)); - /* Perform two Newton iterations: - r -= r*((r*n)+(r-1.Q15)) - = r*((r*n)+(r-1.Q15)). */ - r = SUB16(r, MULT16_16_Q15(r, +oac_val16 oaci_celt_rcp_norm16(oac_val16 x) { + oac_val16 r; + /* Start with a linear approximation: + r = 1.8823529411764706-0.9411764705882353*n. + The coefficients and the result are Q14 in the range [15420,30840].*/ + r = ADD16(30840, MULT16_16_Q15(-15420, x)); + /* Perform two Newton iterations: + r -= r*((r*n)+(r-1.Q15)) + = r*((r*n)+(r-1.Q15)). */ + r = SUB16(r, MULT16_16_Q15(r, ADD16(MULT16_16_Q15(r, x), ADD16(r, -32768)))); - /* We subtract an extra 1 in the second iteration to avoid overflow; it also - neatly compensates for truncation error in the rest of the process. */ - return SUB16(r, ADD16(1, MULT16_16_Q15(r, + /* We subtract an extra 1 in the second iteration to avoid overflow; it also + neatly compensates for truncation error in the rest of the process. */ + return SUB16(r, ADD16(1, MULT16_16_Q15(r, ADD16(MULT16_16_Q15(r, x), ADD16(r, -32768))))); } /* Computes a 32 bit approximated reciprocal (1/x) for a normalized Q31 input, * resulting in a Q30 output. The expected input range is [0.5f, 1.0f) in Q31 * and the expected output range is [1.0f, 2.0f) in Q30. */ -opus_val32 celt_rcp_norm32(opus_val32 x) -{ - opus_val32 r_q30; - celt_sig_assert(x >= 1073741824); - r_q30 = SHL32(EXTEND32(celt_rcp_norm16(SHR32(x, 15)-32768)), 16); - /* Solving f(y) = a - 1/y using the Newton Method - * Note: f(y)' = 1/y^2 - * r = r - f(r)/f(r)' = r - (x * r*r - r) - * = r - r*(r*x - 1) - * where - * - r means 1/y's approximation. - * - x means a, the input of function. - * Please note that: - * - It adds 1 to avoid overflow - * - -1.0f in Q30 is -1073741824. */ - return SUB32(r_q30, ADD32(SHL32( +oac_val32 oaci_celt_rcp_norm32(oac_val32 x) { + oac_val32 r_q30; + celt_sig_assert(x >= 1073741824); + r_q30 = SHL32(EXTEND32(oaci_celt_rcp_norm16(SHR32(x, 15) - 32768)), 16); + /* Solving f(y) = a - 1/y using the Newton Method + * Note: f(y)' = 1/y^2 + * r = r - f(r)/f(r)' = r - (x * r*r - r) + * = r - r*(r*x - 1) + * where + * - r means 1/y's approximation. + * - x means a, the input of function. + * Please note that: + * - It adds 1 to avoid overflow + * - -1.0f in Q30 is -1073741824. */ + return SUB32(r_q30, ADD32(SHL32( MULT32_32_Q31(ADD32(MULT32_32_Q31(r_q30, x), -1073741824), r_q30), 1), 1)); } /** Reciprocal approximation (Q15 input, Q16 output) */ -opus_val32 celt_rcp(opus_val32 x) -{ - int i; - opus_val16 r; - celt_sig_assert(x>0); - i = celt_ilog2(x); +oac_val32 oaci_celt_rcp(oac_val32 x) { + int i; + oac_val16 r; + celt_sig_assert(x > 0); + i = oaci_celt_ilog2(x); - /* Compute the reciprocal of a Q15 number in the range [0, 1). */ - r = celt_rcp_norm16(VSHR32(x,i-15)-32768); + /* Compute the reciprocal of a Q15 number in the range [0, 1). */ + r = oaci_celt_rcp_norm16(VSHR32(x, i - 15) - 32768); - /* r is now the Q15 solution to 2/(n+1), with a maximum relative error - of 7.05346E-5, a (relative) RMSE of 2.14418E-5, and a peak absolute - error of 1.24665/32768. */ - return VSHR32(EXTEND32(r),i-16); + /* r is now the Q15 solution to 2/(n+1), with a maximum relative error + of 7.05346E-5, a (relative) RMSE of 2.14418E-5, and a peak absolute + error of 1.24665/32768. */ + return VSHR32(EXTEND32(r), i - 16); } #endif #ifndef DISABLE_FLOAT_API -void celt_float2int16_c(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT out, int cnt) -{ - int i; - for (i = 0; i < cnt; i++) - { - out[i] = FLOAT2INT16(in[i]); - } +void oaci_celt_float2int16_c(const float * OAC_RESTRICT in, short * OAC_RESTRICT out, int cnt) { + int i; + for (i = 0; i < cnt; i++) { + out[i] = FLOAT2INT16(in[i]); + } } -int opus_limit2_checkwithin1_c(float * samples, int cnt) -{ - int i; - if (cnt <= 0) - { - return 1; - } +int oac_limit2_checkwithin1_c(float * samples, int cnt) { + int i; + if (cnt <= 0) { + return 1; + } - for (i = 0; i < cnt; i++) - { - float clippedVal = samples[i]; - clippedVal = FMAX(-2.0f, clippedVal); - clippedVal = FMIN(2.0f, clippedVal); - samples[i] = clippedVal; - } + for (i = 0; i < cnt; i++) { + float clippedVal = samples[i]; + clippedVal = FMAX(-2.0f, clippedVal); + clippedVal = FMIN(2.0f, clippedVal); + samples[i] = clippedVal; + } - /* C implementation can't provide quick hint. Assume it might exceed -1/+1. */ - return 0; + /* C implementation can't provide quick hint. Assume it might exceed -1/+1. */ + return 0; } #endif /* DISABLE_FLOAT_API */ diff --git a/celt/mathops.h b/celt/mathops.h index 4b6fa15cc..5a030fdf9 100644 --- a/celt/mathops.h +++ b/celt/mathops.h @@ -6,7 +6,7 @@ /** @file mathops.h @brief Various math functions -*/ + */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -30,7 +30,7 @@ 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. -*/ + */ #ifndef MATHOPS_H #define MATHOPS_H @@ -40,200 +40,188 @@ #include "os_support.h" -#if defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -#include "arm/mathops_arm.h" +#if defined(OAC_ARM_MAY_HAVE_NEON_INTR) +# include "arm/mathops_arm.h" #endif #define PI 3.1415926535897931 /* Multiplies two 16-bit fractional values. Bit-exactness of this macro is important */ -#define FRAC_MUL16(a,b) ((16384+((opus_int32)(opus_int16)(a)*(opus_int16)(b)))>>15) +#define FRAC_MUL16(a, b) ((16384 + ((oac_int32)(oac_int16)(a)*(oac_int16)(b)))>>15) -unsigned isqrt32(opus_uint32 _val); +unsigned oaci_isqrt32(oac_uint32 _val); /* CELT doesn't need it for fixed-point, by analysis.c does. */ #if !defined(FIXED_POINT) || defined(ANALYSIS_C) -#define cA 0.43157974f -#define cB 0.67848403f -#define cC 0.08595542f -#define cE ((float)PI/2) -static OPUS_INLINE float fast_atan2f(float y, float x) { - float x2, y2; - x2 = x*x; - y2 = y*y; - /* For very small values, we don't care about the answer, so - we can just return 0. */ - if (x2 + y2 < 1e-18f) - { - return 0; - } - if(x2=0 && y>=0); - - /* For very small values, we don't care about the answer. */ - if ((x*x + y*y) < 1e-18f) - { - return 0; - } - - if (y < x) - { - return celt_atan_norm(y / x); - } else { - return 1.f - celt_atan_norm(x / y); - } +static OAC_INLINE float oaci_celt_atan2p_norm(float y, float x) { + celt_sig_assert(x >= 0 && y >= 0); + + /* For very small values, we don't care about the answer. */ + if ((x*x + y*y) < 1e-18f) { + return 0; + } + + if (y < x) { + return oaci_celt_atan_norm(y/x); + } else { + return 1.f - oaci_celt_atan_norm(x/y); + } } #endif -#if !defined(FIXED_POINT) || defined(ENABLE_QEXT) +#if !defined(FIXED_POINT) /* Computes estimated cosine values for (PI/2 * x) using only terms with even * exponents. */ -static OPUS_INLINE float celt_cos_norm2(float x) -{ - float x_norm_sq; - int output_sign; - /* Restrict x to [-1, 3]. */ - x -= 4*floor(.25*(x+1)); - /* Negative sign for [1, 3]. */ - output_sign = 1 - 2*(x>1); - /* Restrict to [-1, 1]. */ - x -= 2*(x>1); - - /* The cosine function, cos(x), has a Taylor series representation consisting - * exclusively of even-powered polynomial terms. */ - x_norm_sq = x * x; - - /* Polynomial coefficients approximated in the [0, 1] range using only terms +static OAC_INLINE float oaci_celt_cos_norm2(float x) { + float x_norm_sq; + int output_sign; + /* Restrict x to [-1, 3]. */ + x -= 4*floor(.25*(x + 1)); + /* Negative sign for [1, 3]. */ + output_sign = 1 - 2*(x > 1); + /* Restrict to [-1, 1]. */ + x -= 2*(x > 1); + + /* The cosine function, cos(x), has a Taylor series representation consisting + * exclusively of even-powered polynomial terms. */ + x_norm_sq = x*x; + + /* Polynomial coefficients approximated in the [0, 1] range using only terms * with even exponents. * Lolremez command: lolremez --degree 4 --range 0:1 "cos(sqrt(x)*pi*0.5)" */ - #define COS_COEFF_A0 9.999999403953552246093750000000e-01f - #define COS_COEFF_A2 -1.233698248863220214843750000000000f - #define COS_COEFF_A4 2.536507546901702880859375000000e-01f - #define COS_COEFF_A6 -2.08106283098459243774414062500e-02f - #define COS_COEFF_A8 8.581906440667808055877685546875e-04f - return output_sign * (COS_COEFF_A0 + x_norm_sq * (COS_COEFF_A2 + - x_norm_sq * (COS_COEFF_A4 + - x_norm_sq * (COS_COEFF_A6 + - x_norm_sq * (COS_COEFF_A8))))); +# define COS_COEFF_A0 9.999999403953552246093750000000e-01f +# define COS_COEFF_A2 -1.233698248863220214843750000000000f +# define COS_COEFF_A4 2.536507546901702880859375000000e-01f +# define COS_COEFF_A6 -2.08106283098459243774414062500e-02f +# define COS_COEFF_A8 8.581906440667808055877685546875e-04f + return output_sign*(COS_COEFF_A0 + x_norm_sq*(COS_COEFF_A2 + + x_norm_sq*(COS_COEFF_A4 + + x_norm_sq*(COS_COEFF_A6 + + x_norm_sq*(COS_COEFF_A8))))); } #endif #ifndef FIXED_POINT -#define celt_sqrt(x) ((float)sqrt(x)) -#define celt_sqrt32(x) ((float)sqrt(x)) -#define celt_rsqrt(x) (1.f/celt_sqrt(x)) -#define celt_rsqrt_norm(x) (celt_rsqrt(x)) -#define celt_rsqrt_norm32(x) (celt_rsqrt(x)) -#define celt_cos_norm(x) ((float)cos((.5f*PI)*(x))) -#define celt_rcp(x) (1.f/(x)) -#define celt_div(a,b) ((a)/(b)) -#define frac_div32(a,b) ((float)(a)/(b)) -#define frac_div32_q29(a,b) frac_div32(a,b) - -#ifdef FLOAT_APPROX +# define oaci_celt_sqrt(x) ((float)sqrt(x)) +# define oaci_celt_sqrt32(x) ((float)sqrt(x)) +# define oaci_celt_rsqrt(x) (1.f/oaci_celt_sqrt(x)) +# define oaci_celt_rsqrt_norm(x) (oaci_celt_rsqrt(x)) +# define oaci_celt_rsqrt_norm32(x) (oaci_celt_rsqrt(x)) +# define oaci_celt_cos_norm(x) ((float)cos((.5f*PI)*(x))) +# define oaci_celt_rcp(x) (1.f/(x)) +# define oaci_celt_div(a, b) ((a)/(b)) +# define oaci_frac_div32(a, b) ((float)(a)/(b)) +# define oaci_frac_div32_q29(a, b) oaci_frac_div32(a, b) + +# ifdef FLOAT_APPROX /* Calculates the base-2 logarithm (log2(x)) of a number. It is designed for * systems using radix-2 floating-point representation, with the exponent * located at bits 23 to 30 and an offset of 127. Note that special cases like @@ -250,10 +238,10 @@ static OPUS_INLINE float celt_cos_norm2(float x) * 6.666666666666666e-01, 6.153846153846154e-01, * 5.714285714285714e-01, 5.333333333333333e-01} */ static const float log2_x_norm_coeff[8] = { - 1.000000000000000000000000000f, 8.88888895511627197265625e-01f, - 8.00000000000000000000000e-01f, 7.27272748947143554687500e-01f, - 6.66666686534881591796875e-01f, 6.15384638309478759765625e-01f, - 5.71428596973419189453125e-01f, 5.33333361148834228515625e-01f}; + 1.000000000000000000000000000f, 8.88888895511627197265625e-01f, + 8.00000000000000000000000e-01f, 7.27272748947143554687500e-01f, + 6.66666686534881591796875e-01f, 6.15384638309478759765625e-01f, + 5.71428596973419189453125e-01f, 5.33333361148834228515625e-01f}; /* Log2 y normalization single precision coefficients calculated by * log2(1 + 0.125 * index). @@ -264,45 +252,44 @@ static const float log2_x_norm_coeff[8] = { * 5.849625007211562e-01, 7.004397181410922e-01, * 8.073549220576041e-01, 9.068905956085185e-01}; */ static const float log2_y_norm_coeff[8] = { - 0.0000000000000000000000000000f, 1.699250042438507080078125e-01f, - 3.219280838966369628906250e-01f, 4.594316184520721435546875e-01f, - 5.849624872207641601562500e-01f, 7.004396915435791015625000e-01f, - 8.073549270629882812500000e-01f, 9.068905711174011230468750e-01f}; - -static OPUS_INLINE float celt_log2(float x) -{ - opus_int32 integer; - opus_int32 range_idx; - union { - float f; - opus_uint32 i; - } in; - in.f = x; - integer = (opus_int32)(in.i>>23)-127; - in.i = (opus_int32)in.i - (opus_int32)((opus_uint32)integer<<23); - - /* Normalize the mantissa range from [1, 2] to [1,1.125], and then shift x - * by 1.0625 to [-0.0625, 0.0625]. */ - range_idx = (in.i >> 20) & 0x7; - in.f = in.f * log2_x_norm_coeff[range_idx] - 1.0625f; - - /* Polynomial coefficients approximated in the [1, 1.125] range. - * Lolremez command: lolremez --degree 4 --range -0.0625:0.0625 - * "log(x+1.0625)/log(2)" - * Coefficients in Double Precision - * A0: 8.7462840624502679e-2 A1: 1.3578296070972002 - * A2: -6.3897703690210047e-1 A3: 4.0197125617419959e-1 - * A4: -2.8415445877832832e-1 */ - #define LOG2_COEFF_A0 8.74628424644470214843750000e-02f - #define LOG2_COEFF_A1 1.357829570770263671875000000000f - #define LOG2_COEFF_A2 -6.3897705078125000000000000e-01f - #define LOG2_COEFF_A3 4.01971250772476196289062500e-01f - #define LOG2_COEFF_A4 -2.8415444493293762207031250e-01f - in.f = LOG2_COEFF_A0 + in.f * (LOG2_COEFF_A1 - + in.f * (LOG2_COEFF_A2 - + in.f * (LOG2_COEFF_A3 - + in.f * (LOG2_COEFF_A4)))); - return integer + in.f + log2_y_norm_coeff[range_idx]; + 0.0000000000000000000000000000f, 1.699250042438507080078125e-01f, + 3.219280838966369628906250e-01f, 4.594316184520721435546875e-01f, + 5.849624872207641601562500e-01f, 7.004396915435791015625000e-01f, + 8.073549270629882812500000e-01f, 9.068905711174011230468750e-01f}; + +static OAC_INLINE float oaci_celt_log2(float x) { + oac_int32 integer; + oac_int32 range_idx; + union { + float f; + oac_uint32 i; + } in; + in.f = x; + integer = (oac_int32)(in.i>>23) - 127; + in.i = (oac_int32)in.i - (oac_int32)((oac_uint32)integer<<23); + + /* Normalize the mantissa range from [1, 2] to [1,1.125], and then shift x + * by 1.0625 to [-0.0625, 0.0625]. */ + range_idx = (in.i>>20)&0x7; + in.f = in.f*log2_x_norm_coeff[range_idx] - 1.0625f; + + /* Polynomial coefficients approximated in the [1, 1.125] range. + * Lolremez command: lolremez --degree 4 --range -0.0625:0.0625 + * "log(x+1.0625)/log(2)" + * Coefficients in Double Precision + * A0: 8.7462840624502679e-2 A1: 1.3578296070972002 + * A2: -6.3897703690210047e-1 A3: 4.0197125617419959e-1 + * A4: -2.8415445877832832e-1 */ +# define LOG2_COEFF_A0 8.74628424644470214843750000e-02f +# define LOG2_COEFF_A1 1.357829570770263671875000000000f +# define LOG2_COEFF_A2 -6.3897705078125000000000000e-01f +# define LOG2_COEFF_A3 4.01971250772476196289062500e-01f +# define LOG2_COEFF_A4 -2.8415444493293762207031250e-01f + in.f = LOG2_COEFF_A0 + in.f*(LOG2_COEFF_A1 + + in.f*(LOG2_COEFF_A2 + + in.f*(LOG2_COEFF_A3 + + in.f*(LOG2_COEFF_A4)))); + return integer + in.f + log2_y_norm_coeff[range_idx]; } /* Calculates an approximation of 2^x. The approximation was achieved by @@ -310,352 +297,331 @@ static OPUS_INLINE float celt_log2(float x) * of order 5, ensuring a controlled relative error. * exp2(x) = exp2(integer + fraction) * = exp2(integer) * exp2(fraction) */ -static OPUS_INLINE float celt_exp2(float x) -{ - opus_int32 integer; - float frac; - union { - float f; - opus_uint32 i; - } res; - integer = (int)floor(x); - if (integer < -50) - return 0; - frac = x-integer; - - /* Polynomial coefficients approximated in the [0, 1] range. - * Lolremez command: lolremez --degree 5 --range 0:1 - * "exp(x*0.693147180559945)" "exp(x*0.693147180559945)" - * NOTE: log(2) ~ 0.693147180559945 */ - #define EXP2_COEFF_A0 9.999999403953552246093750000000e-01f - #define EXP2_COEFF_A1 6.931530833244323730468750000000e-01f - #define EXP2_COEFF_A2 2.401536107063293457031250000000e-01f - #define EXP2_COEFF_A3 5.582631751894950866699218750000e-02f - #define EXP2_COEFF_A4 8.989339694380760192871093750000e-03f - #define EXP2_COEFF_A5 1.877576694823801517486572265625e-03f - res.f = EXP2_COEFF_A0 + frac * (EXP2_COEFF_A1 - + frac * (EXP2_COEFF_A2 - + frac * (EXP2_COEFF_A3 - + frac * (EXP2_COEFF_A4 - + frac * (EXP2_COEFF_A5))))); - res.i = (opus_uint32)((opus_int32)res.i + (opus_int32)((opus_uint32)integer<<23)) & 0x7fffffff; - return res.f; +static OAC_INLINE float oaci_celt_exp2(float x) { + oac_int32 integer; + float frac; + union { + float f; + oac_uint32 i; + } res; + integer = (int)floor(x); + if (integer < -50) + return 0; + frac = x - integer; + + /* Polynomial coefficients approximated in the [0, 1] range. + * Lolremez command: lolremez --degree 5 --range 0:1 + * "exp(x*0.693147180559945)" "exp(x*0.693147180559945)" + * NOTE: log(2) ~ 0.693147180559945 */ +# define EXP2_COEFF_A0 9.999999403953552246093750000000e-01f +# define EXP2_COEFF_A1 6.931530833244323730468750000000e-01f +# define EXP2_COEFF_A2 2.401536107063293457031250000000e-01f +# define EXP2_COEFF_A3 5.582631751894950866699218750000e-02f +# define EXP2_COEFF_A4 8.989339694380760192871093750000e-03f +# define EXP2_COEFF_A5 1.877576694823801517486572265625e-03f + res.f = EXP2_COEFF_A0 + frac*(EXP2_COEFF_A1 + + frac*(EXP2_COEFF_A2 + + frac*(EXP2_COEFF_A3 + + frac*(EXP2_COEFF_A4 + + frac*(EXP2_COEFF_A5))))); + res.i = (oac_uint32)((oac_int32)res.i + (oac_int32)((oac_uint32)integer<<23))&0x7fffffff; + return res.f; } -#else -#define celt_log2(x) ((float)(1.442695040888963387*log(x))) -#define celt_exp2(x) ((float)exp(0.6931471805599453094*(x))) -#endif +# else +# define oaci_celt_log2(x) ((float)(1.442695040888963387*log(x))) +# define oaci_celt_exp2(x) ((float)exp(0.6931471805599453094*(x))) +# endif -#define celt_exp2_db celt_exp2 -#define celt_log2_db celt_log2 +# define celt_exp2_db oaci_celt_exp2 +# define oaci_celt_log2_db oaci_celt_log2 -#define celt_sin(x) celt_cos_norm2((0.5f*PI) * (x) - 1.0f) -#define celt_log(x) (celt_log2(x) * 0.6931471805599453f) -#define celt_exp(x) (celt_exp2((x) * 1.4426950408889634f)) +# define oaci_celt_sin(x) oaci_celt_cos_norm2((0.5f*PI)*(x) - 1.0f) +# define celt_log(x) (oaci_celt_log2(x)*0.6931471805599453f) +# define celt_exp(x) (oaci_celt_exp2((x)*1.4426950408889634f)) #endif #ifdef FIXED_POINT -#include "os_support.h" +# include "os_support.h" -#ifndef OVERRIDE_CELT_ILOG2 +# ifndef OVERRIDE_CELT_ILOG2 /** Integer log in base2. Undefined for zero and negative numbers */ -static OPUS_INLINE opus_int16 celt_ilog2(opus_int32 x) -{ - celt_sig_assert(x>0); - return EC_ILOG(x)-1; +static OAC_INLINE oac_int16 oaci_celt_ilog2(oac_int32 x) { + celt_sig_assert(x > 0); + return EC_ILOG(x) - 1; } -#endif +# endif /** Integer log in base2. Defined for zero, but not for negative numbers */ -static OPUS_INLINE opus_int16 celt_zlog2(opus_val32 x) -{ - return x <= 0 ? 0 : celt_ilog2(x); +static OAC_INLINE oac_int16 oaci_celt_zlog2(oac_val32 x) { + return x <= 0 ? 0 : oaci_celt_ilog2(x); } -opus_val16 celt_rsqrt_norm(opus_val32 x); +oac_val16 oaci_celt_rsqrt_norm(oac_val32 x); -opus_val32 celt_rsqrt_norm32(opus_val32 x); +oac_val32 oaci_celt_rsqrt_norm32(oac_val32 x); -opus_val32 celt_sqrt(opus_val32 x); +oac_val32 oaci_celt_sqrt(oac_val32 x); -opus_val32 celt_sqrt32(opus_val32 x); +oac_val32 oaci_celt_sqrt32(oac_val32 x); -opus_val16 celt_cos_norm(opus_val32 x); +oac_val16 oaci_celt_cos_norm(oac_val32 x); -opus_val32 celt_cos_norm32(opus_val32 x); +oac_val32 oaci_celt_cos_norm32(oac_val32 x); /** Base-2 logarithm approximation (log2(x)). (Q14 input, Q10 output) */ -static OPUS_INLINE opus_val16 celt_log2(opus_val32 x) -{ - int i; - opus_val16 n, frac; - /* -0.41509302963303146, 0.9609890551383969, -0.31836011537636605, - 0.15530808010959576, -0.08556153059057618 */ - static const opus_val16 C[5] = {-6801+(1<<(13-10)), 15746, -5217, 2545, -1401}; - if (x==0) - return -32767; - i = celt_ilog2(x); - n = VSHR32(x,i-15)-32768-16384; - frac = ADD16(C[0], MULT16_16_Q15(n, ADD16(C[1], MULT16_16_Q15(n, ADD16(C[2], MULT16_16_Q15(n, ADD16(C[3], MULT16_16_Q15(n, C[4])))))))); - return SHL32(i-13,10)+SHR32(frac,14-10); +static OAC_INLINE oac_val16 oaci_celt_log2(oac_val32 x) { + int i; + oac_val16 n, frac; + /* -0.41509302963303146, 0.9609890551383969, -0.31836011537636605, + 0.15530808010959576, -0.08556153059057618 */ + static const oac_val16 C[5] = {-6801 + (1<<(13 - 10)), 15746, -5217, 2545, -1401}; + if (x == 0) + return -32767; + i = oaci_celt_ilog2(x); + n = VSHR32(x, i - 15) - 32768 - 16384; + frac = ADD16(C[0], + MULT16_16_Q15(n, + ADD16(C[1], MULT16_16_Q15(n, ADD16(C[2], MULT16_16_Q15(n, ADD16(C[3], MULT16_16_Q15(n, C[4])))))))); + return SHL32(i - 13, 10) + SHR32(frac, 14 - 10); } /* - K0 = 1 - K1 = log(2) - K2 = 3-4*log(2) - K3 = 3*log(2) - 2 -*/ -#define D0 16383 -#define D1 22804 -#define D2 14819 -#define D3 10204 - -static OPUS_INLINE opus_val32 celt_exp2_frac(opus_val16 x) -{ - opus_val16 frac; - frac = SHL16(x, 4); - return ADD16(D0, MULT16_16_Q15(frac, ADD16(D1, MULT16_16_Q15(frac, ADD16(D2 , MULT16_16_Q15(D3,frac)))))); + K0 = 1 + K1 = log(2) + K2 = 3-4*log(2) + K3 = 3*log(2) - 2 + */ +# define D0 16383 +# define D1 22804 +# define D2 14819 +# define D3 10204 + +static OAC_INLINE oac_val32 oaci_celt_exp2_frac(oac_val16 x) { + oac_val16 frac; + frac = SHL16(x, 4); + return ADD16(D0, MULT16_16_Q15(frac, ADD16(D1, MULT16_16_Q15(frac, ADD16(D2, MULT16_16_Q15(D3, frac)))))); } -#undef D0 -#undef D1 -#undef D2 -#undef D3 +# undef D0 +# undef D1 +# undef D2 +# undef D3 /** Base-2 exponential approximation (2^x). (Q10 input, Q16 output) */ -static OPUS_INLINE opus_val32 celt_exp2(opus_val16 x) -{ - int integer; - opus_val16 frac; - integer = SHR16(x,10); - if (integer>14) - return 0x7f000000; - else if (integer < -15) - return 0; - frac = celt_exp2_frac(x-SHL16(integer,10)); - return VSHR32(EXTEND32(frac), -integer-2); +static OAC_INLINE oac_val32 oaci_celt_exp2(oac_val16 x) { + int integer; + oac_val16 frac; + integer = SHR16(x, 10); + if (integer > 14) + return 0x7f000000; + else if (integer < -15) + return 0; + frac = oaci_celt_exp2_frac(x - SHL16(integer, 10)); + return VSHR32(EXTEND32(frac), -integer - 2); } -#ifdef ENABLE_QEXT - /* Calculates the base-2 logarithm of a Q14 input value. The result is returned * in Q(DB_SHIFT). If the input value is 0, the function will output -32.0f. */ -static OPUS_INLINE opus_val32 celt_log2_db(opus_val32 x) { - /* Q30 */ - static const opus_val32 log2_x_norm_coeff[8] = { - 1073741824, 954437184, 858993472, 780903168, - 715827904, 660764224, 613566784, 572662336}; - /* Q24 */ - static const opus_val32 log2_y_norm_coeff[8] = { - 0, 2850868, 5401057, 7707983, - 9814042, 11751428, 13545168, 15215099}; - static const opus_val32 LOG2_COEFF_A0 = 1467383; /* Q24 */ - static const opus_val32 LOG2_COEFF_A1 = 182244800; /* Q27 */ - static const opus_val32 LOG2_COEFF_A2 = -21440512; /* Q25 */ - static const opus_val32 LOG2_COEFF_A3 = 107903336; /* Q28 */ - static const opus_val32 LOG2_COEFF_A4 = -610217024; /* Q31 */ - - opus_int32 integer, norm_coeff_idx, tmp; - opus_val32 mantissa; - if (x==0) { - return -536870912; /* -32.0f */ - } - integer = SUB32(celt_ilog2(x), 14); /* Q0 */ - mantissa = VSHR32(x, integer + 14 - 29); /* Q29 */ - norm_coeff_idx = SHR32(mantissa, 29 - 3) & 0x7; - /* mantissa is in Q28 (29 + Q_NORM_CONST - 31 where Q_NORM_CONST is Q30) - * 285212672 (Q28) is 1.0625f. */ - mantissa = SUB32(MULT32_32_Q31(mantissa, log2_x_norm_coeff[norm_coeff_idx]), +static OAC_INLINE oac_val32 oaci_celt_log2_db(oac_val32 x) { + /* Q30 */ + static const oac_val32 log2_x_norm_coeff[8] = { + 1073741824, 954437184, 858993472, 780903168, + 715827904, 660764224, 613566784, 572662336}; + /* Q24 */ + static const oac_val32 log2_y_norm_coeff[8] = { + 0, 2850868, 5401057, 7707983, + 9814042, 11751428, 13545168, 15215099}; + static const oac_val32 LOG2_COEFF_A0 = 1467383; /* Q24 */ + static const oac_val32 LOG2_COEFF_A1 = 182244800; /* Q27 */ + static const oac_val32 LOG2_COEFF_A2 = -21440512; /* Q25 */ + static const oac_val32 LOG2_COEFF_A3 = 107903336; /* Q28 */ + static const oac_val32 LOG2_COEFF_A4 = -610217024; /* Q31 */ + + oac_int32 integer, norm_coeff_idx, tmp; + oac_val32 mantissa; + if (x == 0) { + return -536870912; /* -32.0f */ + } + integer = SUB32(oaci_celt_ilog2(x), 14); /* Q0 */ + mantissa = VSHR32(x, integer + 14 - 29); /* Q29 */ + norm_coeff_idx = SHR32(mantissa, 29 - 3)&0x7; + /* mantissa is in Q28 (29 + Q_NORM_CONST - 31 where Q_NORM_CONST is Q30) + * 285212672 (Q28) is 1.0625f. */ + mantissa = SUB32(MULT32_32_Q31(mantissa, log2_x_norm_coeff[norm_coeff_idx]), 285212672); - /* q_a3(Q28): q_mantissa + q_a4 - 31 - * q_a2(Q25): q_mantissa + q_a3 - 31 - * q_a1(Q27): q_mantissa + q_a2 - 31 + 5 - * q_a0(Q24): q_mantissa + q_a1 - 31 - * where q_mantissa is Q28 */ - /* Split evaluation in steps to avoid exploding macro expansion. */ - tmp = MULT32_32_Q31(mantissa, LOG2_COEFF_A4); - tmp = MULT32_32_Q31(mantissa, ADD32(LOG2_COEFF_A3, tmp)); - tmp = SHL32(MULT32_32_Q31(mantissa, ADD32(LOG2_COEFF_A2, tmp)), 5 /* SHL32 for LOG2_COEFF_A1 */); - tmp = MULT32_32_Q31(mantissa, ADD32(LOG2_COEFF_A1, tmp)); - return ADD32(log2_y_norm_coeff[norm_coeff_idx], + /* q_a3(Q28): q_mantissa + q_a4 - 31 + * q_a2(Q25): q_mantissa + q_a3 - 31 + * q_a1(Q27): q_mantissa + q_a2 - 31 + 5 + * q_a0(Q24): q_mantissa + q_a1 - 31 + * where q_mantissa is Q28 */ + /* Split evaluation in steps to avoid exploding macro expansion. */ + tmp = MULT32_32_Q31(mantissa, LOG2_COEFF_A4); + tmp = MULT32_32_Q31(mantissa, ADD32(LOG2_COEFF_A3, tmp)); + tmp = SHL32(MULT32_32_Q31(mantissa, ADD32(LOG2_COEFF_A2, tmp)), 5 /* SHL32 for LOG2_COEFF_A1 */); + tmp = MULT32_32_Q31(mantissa, ADD32(LOG2_COEFF_A1, tmp)); + return ADD32(log2_y_norm_coeff[norm_coeff_idx], ADD32(SHL32(integer, DB_SHIFT), ADD32(LOG2_COEFF_A0, tmp))); } /* Calculates exp2 for Q28 within a specific range (0 to 1.0) using fixed-point * arithmetic. The input number must be adjusted for Q DB_SHIFT. */ -static OPUS_INLINE opus_val32 celt_exp2_db_frac(opus_val32 x) -{ - /* Approximation constants. */ - static const opus_int32 EXP2_COEFF_A0 = 268435440; /* Q28 */ - static const opus_int32 EXP2_COEFF_A1 = 744267456; /* Q30 */ - static const opus_int32 EXP2_COEFF_A2 = 1031451904; /* Q32 */ - static const opus_int32 EXP2_COEFF_A3 = 959088832; /* Q34 */ - static const opus_int32 EXP2_COEFF_A4 = 617742720; /* Q36 */ - static const opus_int32 EXP2_COEFF_A5 = 516104352; /* Q38 */ - opus_int32 tmp; - /* Converts input value from Q24 to Q29. */ - opus_val32 x_q29 = SHL32(x, 29 - 24); - /* Split evaluation in steps to avoid exploding macro expansion. */ - tmp = ADD32(EXP2_COEFF_A4, MULT32_32_Q31(x_q29, EXP2_COEFF_A5)); - tmp = ADD32(EXP2_COEFF_A3, MULT32_32_Q31(x_q29, tmp)); - tmp = ADD32(EXP2_COEFF_A2, MULT32_32_Q31(x_q29, tmp)); - tmp = ADD32(EXP2_COEFF_A1, MULT32_32_Q31(x_q29, tmp)); - return ADD32(EXP2_COEFF_A0, MULT32_32_Q31(x_q29, tmp)); +static OAC_INLINE oac_val32 oaci_celt_exp2_db_frac(oac_val32 x) { + /* Approximation constants. */ + static const oac_int32 EXP2_COEFF_A0 = 268435440; /* Q28 */ + static const oac_int32 EXP2_COEFF_A1 = 744267456; /* Q30 */ + static const oac_int32 EXP2_COEFF_A2 = 1031451904; /* Q32 */ + static const oac_int32 EXP2_COEFF_A3 = 959088832; /* Q34 */ + static const oac_int32 EXP2_COEFF_A4 = 617742720; /* Q36 */ + static const oac_int32 EXP2_COEFF_A5 = 516104352; /* Q38 */ + oac_int32 tmp; + /* Converts input value from Q24 to Q29. */ + oac_val32 x_q29 = SHL32(x, 29 - 24); + /* Split evaluation in steps to avoid exploding macro expansion. */ + tmp = ADD32(EXP2_COEFF_A4, MULT32_32_Q31(x_q29, EXP2_COEFF_A5)); + tmp = ADD32(EXP2_COEFF_A3, MULT32_32_Q31(x_q29, tmp)); + tmp = ADD32(EXP2_COEFF_A2, MULT32_32_Q31(x_q29, tmp)); + tmp = ADD32(EXP2_COEFF_A1, MULT32_32_Q31(x_q29, tmp)); + return ADD32(EXP2_COEFF_A0, MULT32_32_Q31(x_q29, tmp)); } /* Calculates exp2 for Q16 using fixed-point arithmetic. The input number must * be adjusted for Q DB_SHIFT. */ -static OPUS_INLINE opus_val32 celt_exp2_db(opus_val32 x) -{ - int integer; - opus_val32 frac; - integer = SHR32(x,DB_SHIFT); - if (integer>14) - return 0x7f000000; - else if (integer <= -17) - return 0; - frac = celt_exp2_db_frac(x-SHL32(integer, DB_SHIFT)); /* Q28 */ - return VSHR32(frac, -integer + 28 - 16); /* Q16 */ +static OAC_INLINE oac_val32 celt_exp2_db(oac_val32 x) { + int integer; + oac_val32 frac; + integer = SHR32(x, DB_SHIFT); + if (integer > 14) + return 0x7f000000; + else if (integer <= -17) + return 0; + frac = oaci_celt_exp2_db_frac(x - SHL32(integer, DB_SHIFT)); /* Q28 */ + return VSHR32(frac, -integer + 28 - 16); /* Q16 */ } -#else - -#define celt_log2_db(x) SHL32(EXTEND32(celt_log2(x)), DB_SHIFT-10) -#define celt_exp2_db_frac(x) SHL32(celt_exp2_frac(PSHR32(x, DB_SHIFT-10)), 14) -#define celt_exp2_db(x) celt_exp2(PSHR32(x, DB_SHIFT-10)) -#endif -opus_val32 celt_rcp(opus_val32 x); -opus_val32 celt_rcp_norm32(opus_val32 x); +oac_val32 oaci_celt_rcp(oac_val32 x); +oac_val32 oaci_celt_rcp_norm32(oac_val32 x); -#define celt_div(a,b) MULT32_32_Q31((opus_val32)(a),celt_rcp(b)) +# define oaci_celt_div(a, b) MULT32_32_Q31((oac_val32)(a), oaci_celt_rcp(b)) -opus_val32 frac_div32_q29(opus_val32 a, opus_val32 b); -opus_val32 frac_div32(opus_val32 a, opus_val32 b); +oac_val32 oaci_frac_div32_q29(oac_val32 a, oac_val32 b); +oac_val32 oaci_frac_div32(oac_val32 a, oac_val32 b); /* Computes atan(x) multiplied by 2/PI. The input value (x) should be within the * range of -1 to 1 and represented in Q30 format. The function will return the * result in Q30 format. */ -static OPUS_INLINE opus_val32 celt_atan_norm(opus_val32 x) -{ - /* Approximation constants. */ - static const opus_int32 ATAN_2_OVER_PI = 1367130551; /* Q31 */ - static const opus_int32 ATAN_COEFF_A03 = -715791936; /* Q31 */ - static const opus_int32 ATAN_COEFF_A05 = 857391616; /* Q32 */ - static const opus_int32 ATAN_COEFF_A07 = -1200579328; /* Q33 */ - static const opus_int32 ATAN_COEFF_A09 = 1682636672; /* Q34 */ - static const opus_int32 ATAN_COEFF_A11 = -1985085440; /* Q35 */ - static const opus_int32 ATAN_COEFF_A13 = 1583306112; /* Q36 */ - static const opus_int32 ATAN_COEFF_A15 = -598602432; /* Q37 */ - opus_int32 x_sq_q30; - opus_int32 x_q31; - opus_int32 tmp; - /* The expected x is in the range of [-1.0f, 1.0f] */ - celt_sig_assert((x <= 1073741824) && (x >= -1073741824)); - - /* If x = 1.0f, returns 0.5f */ - if (x == 1073741824) - { - return 536870912; /* 0.5f (Q30) */ - } - /* If x = 1.0f, returns 0.5f */ - if (x == -1073741824) - { - return -536870912; /* -0.5f (Q30) */ - } - x_q31 = SHL32(x, 1); - x_sq_q30 = MULT32_32_Q31(x_q31, x); - /* Split evaluation in steps to avoid exploding macro expansion. */ - tmp = MULT32_32_Q31(x_sq_q30, ATAN_COEFF_A15); - tmp = MULT32_32_Q31(x_sq_q30, ADD32(ATAN_COEFF_A13, tmp)); - tmp = MULT32_32_Q31(x_sq_q30, ADD32(ATAN_COEFF_A11, tmp)); - tmp = MULT32_32_Q31(x_sq_q30, ADD32(ATAN_COEFF_A09, tmp)); - tmp = MULT32_32_Q31(x_sq_q30, ADD32(ATAN_COEFF_A07, tmp)); - tmp = MULT32_32_Q31(x_sq_q30, ADD32(ATAN_COEFF_A05, tmp)); - tmp = MULT32_32_Q31(x_sq_q30, ADD32(ATAN_COEFF_A03, tmp)); - tmp = ADD32(x, MULT32_32_Q31(x_q31, tmp)); - return MULT32_32_Q31(ATAN_2_OVER_PI, tmp); +static OAC_INLINE oac_val32 oaci_celt_atan_norm(oac_val32 x) { + /* Approximation constants. */ + static const oac_int32 ATAN_2_OVER_PI = 1367130551; /* Q31 */ + static const oac_int32 ATAN_COEFF_A03 = -715791936; /* Q31 */ + static const oac_int32 ATAN_COEFF_A05 = 857391616; /* Q32 */ + static const oac_int32 ATAN_COEFF_A07 = -1200579328; /* Q33 */ + static const oac_int32 ATAN_COEFF_A09 = 1682636672; /* Q34 */ + static const oac_int32 ATAN_COEFF_A11 = -1985085440; /* Q35 */ + static const oac_int32 ATAN_COEFF_A13 = 1583306112; /* Q36 */ + static const oac_int32 ATAN_COEFF_A15 = -598602432; /* Q37 */ + oac_int32 x_sq_q30; + oac_int32 x_q31; + oac_int32 tmp; + /* The expected x is in the range of [-1.0f, 1.0f] */ + celt_sig_assert((x <= 1073741824) && (x >= -1073741824)); + + /* If x = 1.0f, returns 0.5f */ + if (x == 1073741824) { + return 536870912; /* 0.5f (Q30) */ + } + /* If x = 1.0f, returns 0.5f */ + if (x == -1073741824) { + return -536870912; /* -0.5f (Q30) */ + } + x_q31 = SHL32(x, 1); + x_sq_q30 = MULT32_32_Q31(x_q31, x); + /* Split evaluation in steps to avoid exploding macro expansion. */ + tmp = MULT32_32_Q31(x_sq_q30, ATAN_COEFF_A15); + tmp = MULT32_32_Q31(x_sq_q30, ADD32(ATAN_COEFF_A13, tmp)); + tmp = MULT32_32_Q31(x_sq_q30, ADD32(ATAN_COEFF_A11, tmp)); + tmp = MULT32_32_Q31(x_sq_q30, ADD32(ATAN_COEFF_A09, tmp)); + tmp = MULT32_32_Q31(x_sq_q30, ADD32(ATAN_COEFF_A07, tmp)); + tmp = MULT32_32_Q31(x_sq_q30, ADD32(ATAN_COEFF_A05, tmp)); + tmp = MULT32_32_Q31(x_sq_q30, ADD32(ATAN_COEFF_A03, tmp)); + tmp = ADD32(x, MULT32_32_Q31(x_q31, tmp)); + return MULT32_32_Q31(ATAN_2_OVER_PI, tmp); } /* Calculates the arctangent of y/x, multiplies the result by 2/pi, and returns * the value in Q30 format. Both input values (x and y) must be within the range * of 0 to 1 and represented in Q30 format. Inputs must be zero or greater, and * at least one input must be non-zero. */ -static OPUS_INLINE opus_val32 celt_atan2p_norm(opus_val32 y, opus_val32 x) -{ - celt_sig_assert(x>=0 && y>=0); - if (y==0 && x==0) { - return 0; - } else if (y < x) { - return celt_atan_norm(SHR32(frac_div32(y, x), 1)); - } else { - celt_sig_assert(y > 0); - return 1073741824 /* 1.0f Q30 */ - - celt_atan_norm(SHR32(frac_div32(x, y), 1)); - } +static OAC_INLINE oac_val32 oaci_celt_atan2p_norm(oac_val32 y, oac_val32 x) { + celt_sig_assert(x >= 0 && y >= 0); + if (y == 0 && x == 0) { + return 0; + } else if (y < x) { + return oaci_celt_atan_norm(SHR32(oaci_frac_div32(y, x), 1)); + } else { + celt_sig_assert(y > 0); + return 1073741824 /* 1.0f Q30 */ + - oaci_celt_atan_norm(SHR32(oaci_frac_div32(x, y), 1)); + } } -#define M1 32767 -#define M2 -21 -#define M3 -11943 -#define M4 4936 +# define M1 32767 +# define M2 -21 +# define M3 -11943 +# define M4 4936 /* Atan approximation using a 4th order polynomial. Input is in Q15 format and normalized by pi/4. Output is in Q15 format */ -static OPUS_INLINE opus_val16 celt_atan01(opus_val16 x) -{ - return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x))))))); +static OAC_INLINE oac_val16 oaci_celt_atan01(oac_val16 x) { + return MULT16_16_P15(x, ADD32(M1, MULT16_16_P15(x, ADD32(M2, MULT16_16_P15(x, ADD32(M3, MULT16_16_P15(M4, x))))))); } -#undef M1 -#undef M2 -#undef M3 -#undef M4 +# undef M1 +# undef M2 +# undef M3 +# undef M4 /* atan2() approximation valid for positive input values */ -static OPUS_INLINE opus_val16 celt_atan2p(opus_val16 y, opus_val16 x) -{ - if (x==0 && y==0) { - return 0; - } else if (y < x) - { - opus_val32 arg; - arg = celt_div(SHL32(EXTEND32(y),15),x); - if (arg >= 32767) - arg = 32767; - return SHR16(celt_atan01(EXTRACT16(arg)),1); - } else { - opus_val32 arg; - arg = celt_div(SHL32(EXTEND32(x),15),y); - if (arg >= 32767) - arg = 32767; - return 25736-SHR16(celt_atan01(EXTRACT16(arg)),1); - } +static OAC_INLINE oac_val16 oaci_celt_atan2p(oac_val16 y, oac_val16 x) { + if (x == 0 && y == 0) { + return 0; + } else if (y < x) { + oac_val32 arg; + arg = oaci_celt_div(SHL32(EXTEND32(y), 15), x); + if (arg >= 32767) + arg = 32767; + return SHR16(oaci_celt_atan01(EXTRACT16(arg)), 1); + } else { + oac_val32 arg; + arg = oaci_celt_div(SHL32(EXTEND32(x), 15), y); + if (arg >= 32767) + arg = 32767; + return 25736 - SHR16(oaci_celt_atan01(EXTRACT16(arg)), 1); + } } #endif /* FIXED_POINT */ #ifndef DISABLE_FLOAT_API -void celt_float2int16_c(const float * OPUS_RESTRICT in, short * OPUS_RESTRICT out, int cnt); +void oaci_celt_float2int16_c(const float * OAC_RESTRICT in, short * OAC_RESTRICT out, int cnt); -#ifndef OVERRIDE_FLOAT2INT16 -#define celt_float2int16(in, out, cnt, arch) ((void)(arch), celt_float2int16_c(in, out, cnt)) -#endif +# ifndef OVERRIDE_FLOAT2INT16 +# define oaci_celt_float2int16(in, out, cnt, arch) ((void)(arch), oaci_celt_float2int16_c(in, out, cnt)) +# endif -int opus_limit2_checkwithin1_c(float *samples, int cnt); +int oac_limit2_checkwithin1_c(float *samples, int cnt); -#ifndef OVERRIDE_LIMIT2_CHECKWITHIN1 -#define opus_limit2_checkwithin1(samples, cnt, arch) ((void)(arch), opus_limit2_checkwithin1_c(samples, cnt)) -#endif +# ifndef OVERRIDE_LIMIT2_CHECKWITHIN1 +# define oac_limit2_checkwithin1(samples, cnt, arch) ((void)(arch), oac_limit2_checkwithin1_c(samples, cnt)) +# endif #endif /* DISABLE_FLOAT_API */ diff --git a/celt/mdct.c b/celt/mdct.c index 2b8a0bce9..c474b21f2 100644 --- a/celt/mdct.c +++ b/celt/mdct.c @@ -24,7 +24,7 @@ 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. -*/ + */ /* This is a simple MDCT implementation that uses a N/4 complex FFT to do most of the work. It should be relatively straightforward to @@ -37,12 +37,12 @@ The algorithm is similar to (and inspired from) Fabrice Bellard's MDCT implementation in FFMPEG, but has differences in signs, ordering and scaling in many places. -*/ + */ #ifndef SKIP_CONFIG_H -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +# ifdef HAVE_CONFIG_H +# include "config.h" +# endif #endif #include "mdct.h" @@ -53,338 +53,302 @@ #include "mathops.h" #include "stack_alloc.h" -#if defined(FIXED_POINT) && defined(__mips) && __mips == 32 -#include "mips/mdct_mipsr1.h" -#endif - #ifndef M_PI -#define M_PI 3.141592653 +# define M_PI 3.141592653 #endif #ifdef CUSTOM_MODES -int clt_mdct_init(mdct_lookup *l,int N, int maxshift, int arch) -{ - int i; - kiss_twiddle_scalar *trig; - int shift; - int N2=N>>1; - l->n = N; - l->maxshift = maxshift; - for (i=0;i<=maxshift;i++) - { - if (i==0) - l->kfft[i] = opus_fft_alloc(N>>2>>i, 0, 0, arch); - else - l->kfft[i] = opus_fft_alloc_twiddles(N>>2>>i, 0, 0, l->kfft[0], arch); -#ifndef ENABLE_TI_DSPLIB55 - if (l->kfft[i]==NULL) - return 0; -#endif - } - l->trig = trig = (kiss_twiddle_scalar*)opus_alloc((N-(N2>>maxshift))*sizeof(kiss_twiddle_scalar)); - if (l->trig==NULL) - return 0; - for (shift=0;shift<=maxshift;shift++) - { - /* We have enough points that sine isn't necessary */ -#if defined(FIXED_POINT) -#ifndef ENABLE_QEXT - for (i=0;i>= 1; - N >>= 1; - } - return 1; +int oaci_clt_mdct_init(mdct_lookup *l, int N, int maxshift, int arch) { + int i; + kiss_twiddle_scalar *trig; + int shift; + int N2 = N>>1; + l->n = N; + l->maxshift = maxshift; + for (i = 0; i <= maxshift; i++) { + if (i == 0) + l->kfft[i] = oac_fft_alloc(N>>2>>i, 0, 0, arch); + else + l->kfft[i] = oac_fft_alloc_twiddles(N>>2>>i, 0, 0, l->kfft[0], arch); +# ifndef ENABLE_TI_DSPLIB55 + if (l->kfft[i] == NULL) + return 0; +# endif + } + l->trig = trig = (kiss_twiddle_scalar*)oac_alloc((N - (N2>>maxshift))*sizeof(kiss_twiddle_scalar)); + if (l->trig == NULL) + return 0; + for (shift = 0; shift <= maxshift; shift++) { + /* We have enough points that sine isn't necessary */ +# if defined(FIXED_POINT) + for (i = 0; i < N2; i++) + trig[i] = (kiss_twiddle_scalar)MAX32(-2147483647, + MIN32(2147483647, floor(.5 + 2147483648*cos(2*M_PI*(i + .125)/N)))); +# else + for (i = 0; i < N2; i++) + trig[i] = (kiss_twiddle_scalar)cos(2*PI*(i + .125)/N); +# endif + trig += N2; + N2 >>= 1; + N >>= 1; + } + return 1; } -void clt_mdct_clear(mdct_lookup *l, int arch) -{ - int i; - for (i=0;i<=l->maxshift;i++) - opus_fft_free(l->kfft[i], arch); - opus_free((kiss_twiddle_scalar*)l->trig); +void oaci_clt_mdct_clear(mdct_lookup *l, int arch) { + int i; + for (i = 0; i <= l->maxshift; i++) + oac_fft_free(l->kfft[i], arch); + oac_free((kiss_twiddle_scalar*)l->trig); } #endif /* CUSTOM_MODES */ /* Forward MDCT trashes the input array */ -#ifndef OVERRIDE_clt_mdct_forward -void clt_mdct_forward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out, - const celt_coef *window, int overlap, int shift, int stride, int arch) -{ - int i; - int N, N2, N4; - VARDECL(kiss_fft_scalar, f); - VARDECL(kiss_fft_cpx, f2); - const kiss_fft_state *st = l->kfft[shift]; - const kiss_twiddle_scalar *trig; - celt_coef scale; -#ifdef FIXED_POINT - /* Allows us to scale with MULT16_32_Q16(), which is faster than - MULT16_32_Q15() on ARM. */ - int scale_shift = st->scale_shift-1; - int headroom; -#endif - SAVE_STACK; - (void)arch; - scale = st->scale; +#ifndef OVERRIDE_oaci_clt_mdct_forward +void oaci_clt_mdct_forward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OAC_RESTRICT out, + const celt_coef *window, int overlap, int shift, int stride, int arch) { + int i; + int N, N2, N4; + VARDECL(kiss_fft_scalar, f); + VARDECL(kiss_fft_cpx, f2); + const kiss_fft_state *st = l->kfft[shift]; + const kiss_twiddle_scalar *trig; + celt_coef scale; +# ifdef FIXED_POINT + /* Allows us to scale with MULT16_32_Q16(), which is faster than + MULT16_32_Q15() on ARM. */ + int scale_shift = st->scale_shift - 1; + int headroom; +# endif + SAVE_STACK; + (void)arch; + scale = st->scale; - N = l->n; - trig = l->trig; - for (i=0;i>= 1; - trig += N; - } - N2 = N>>1; - N4 = N>>2; + N = l->n; + trig = l->trig; + for (i = 0; i < shift; i++) { + N >>= 1; + trig += N; + } + N2 = N>>1; + N4 = N>>2; - ALLOC(f, N2, kiss_fft_scalar); - ALLOC(f2, N4, kiss_fft_cpx); + ALLOC(f, N2, kiss_fft_scalar); + ALLOC(f2, N4, kiss_fft_cpx); - /* Consider the input to be composed of four blocks: [a, b, c, d] */ - /* Window, shuffle, fold */ - { - /* Temp pointers to make it really clear to the compiler what we're doing */ - const kiss_fft_scalar * OPUS_RESTRICT xp1 = in+(overlap>>1); - const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+N2-1+(overlap>>1); - kiss_fft_scalar * OPUS_RESTRICT yp = f; - const celt_coef * OPUS_RESTRICT wp1 = window+(overlap>>1); - const celt_coef * OPUS_RESTRICT wp2 = window+(overlap>>1)-1; - for(i=0;i<((overlap+3)>>2);i++) - { - /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/ - *yp++ = S_MUL(xp1[N2], *wp2) + S_MUL(*xp2, *wp1); - *yp++ = S_MUL(*xp1, *wp1) - S_MUL(xp2[-N2], *wp2); - xp1+=2; - xp2-=2; - wp1+=2; - wp2-=2; - } - wp1 = window; - wp2 = window+overlap-1; - for(;i>2);i++) - { - /* Real part arranged as a-bR, Imag part arranged as -c-dR */ - *yp++ = *xp2; - *yp++ = *xp1; - xp1+=2; - xp2-=2; - } - for(;ibitrev[i]] = yc; - } -#ifdef FIXED_POINT - headroom = IMAX(0, IMIN(scale_shift, 28-celt_ilog2(maxval))); -#endif - } + /* Consider the input to be composed of four blocks: [a, b, c, d] */ + /* Window, shuffle, fold */ + { + /* Temp pointers to make it really clear to the compiler what we're doing */ + const kiss_fft_scalar * OAC_RESTRICT xp1 = in + (overlap>>1); + const kiss_fft_scalar * OAC_RESTRICT xp2 = in + N2 - 1 + (overlap>>1); + kiss_fft_scalar * OAC_RESTRICT yp = f; + const celt_coef * OAC_RESTRICT wp1 = window + (overlap>>1); + const celt_coef * OAC_RESTRICT wp2 = window + (overlap>>1) - 1; + for (i = 0; i < ((overlap + 3)>>2); i++) { + /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/ + *yp++ = S_MUL(xp1[N2], *wp2) + S_MUL(*xp2, *wp1); + *yp++ = S_MUL(*xp1, *wp1) - S_MUL(xp2[-N2], *wp2); + xp1 += 2; + xp2 -= 2; + wp1 += 2; + wp2 -= 2; + } + wp1 = window; + wp2 = window + overlap - 1; + for (; i < N4 - ((overlap + 3)>>2); i++) { + /* Real part arranged as a-bR, Imag part arranged as -c-dR */ + *yp++ = *xp2; + *yp++ = *xp1; + xp1 += 2; + xp2 -= 2; + } + for (; i < N4; i++) { + /* Real part arranged as a-bR, Imag part arranged as -c-dR */ + *yp++ = -S_MUL(xp1[-N2], *wp1) + S_MUL(*xp2, *wp2); + *yp++ = S_MUL(*xp1, *wp2) + S_MUL(xp2[N2], *wp1); + xp1 += 2; + xp2 -= 2; + wp1 += 2; + wp2 -= 2; + } + } + /* Pre-rotation */ + { + kiss_fft_scalar * OAC_RESTRICT yp = f; + const kiss_twiddle_scalar *t = &trig[0]; +# ifdef FIXED_POINT + oac_val32 maxval = 1; +# endif + for (i = 0; i < N4; i++) { + kiss_fft_cpx yc; + kiss_twiddle_scalar t0, t1; + kiss_fft_scalar re, im, yr, yi; + t0 = t[i]; + t1 = t[N4 + i]; + re = *yp++; + im = *yp++; + yr = S_MUL(re, t0) - S_MUL(im, t1); + yi = S_MUL(im, t0) + S_MUL(re, t1); + yc.r = yr; + yc.i = yi; +# ifdef FIXED_POINT + maxval = MAX32(maxval, MAX32(ABS32(yc.r), ABS32(yc.i))); +# endif + f2[st->bitrev[i]] = yc; + } +# ifdef FIXED_POINT + headroom = IMAX(0, IMIN(scale_shift, 28 - oaci_celt_ilog2(maxval))); +# endif + } - /* N/4 complex FFT, does not downscale anymore */ - opus_fft_impl(st, f2 ARG_FIXED(scale_shift-headroom)); + /* N/4 complex FFT, does not downscale anymore */ + oac_fft_impl(st, f2 ARG_FIXED(scale_shift - headroom)); - /* Post-rotate */ - { - /* Temp pointers to make it really clear to the compiler what we're doing */ - const kiss_fft_cpx * OPUS_RESTRICT fp = f2; - kiss_fft_scalar * OPUS_RESTRICT yp1 = out; - kiss_fft_scalar * OPUS_RESTRICT yp2 = out+stride*(N2-1); - const kiss_twiddle_scalar *t = &trig[0]; - /* Temp pointers to make it really clear to the compiler what we're doing */ - for(i=0;ii,t1) - S_MUL(fp->r,t0), headroom); - yi = PSHR32(S_MUL(fp->r,t1) + S_MUL(fp->i,t0), headroom); - *yp1 = yr; - *yp2 = yi; - fp++; - yp1 += 2*stride; - yp2 -= 2*stride; - } - } - RESTORE_STACK; + /* Post-rotate */ + { + /* Temp pointers to make it really clear to the compiler what we're doing */ + const kiss_fft_cpx * OAC_RESTRICT fp = f2; + kiss_fft_scalar * OAC_RESTRICT yp1 = out; + kiss_fft_scalar * OAC_RESTRICT yp2 = out + stride*(N2 - 1); + const kiss_twiddle_scalar *t = &trig[0]; + /* Temp pointers to make it really clear to the compiler what we're doing */ + for (i = 0; i < N4; i++) { + kiss_fft_scalar yr, yi; + kiss_fft_scalar t0, t1; + t0 = S_MUL2(t[i], scale); + t1 = S_MUL2(t[N4 + i], scale); + yr = PSHR32(S_MUL(fp->i, t1) - S_MUL(fp->r, t0), headroom); + yi = PSHR32(S_MUL(fp->r, t1) + S_MUL(fp->i, t0), headroom); + *yp1 = yr; + *yp2 = yi; + fp++; + yp1 += 2*stride; + yp2 -= 2*stride; + } + } + RESTORE_STACK; } -#endif /* OVERRIDE_clt_mdct_forward */ +#endif /* OVERRIDE_oaci_clt_mdct_forward */ -#ifndef OVERRIDE_clt_mdct_backward -void clt_mdct_backward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out, - const celt_coef * OPUS_RESTRICT window, int overlap, int shift, int stride, int arch) -{ - int i; - int N, N2, N4; - const kiss_twiddle_scalar *trig; -#ifdef FIXED_POINT - int pre_shift, post_shift, fft_shift; -#endif - (void) arch; +#ifndef OVERRIDE_oaci_clt_mdct_backward +void oaci_clt_mdct_backward_c(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OAC_RESTRICT out, + const celt_coef * OAC_RESTRICT window, int overlap, int shift, int stride, int arch) { + int i; + int N, N2, N4; + const kiss_twiddle_scalar *trig; +# ifdef FIXED_POINT + int pre_shift, post_shift, fft_shift; +# endif + (void) arch; - N = l->n; - trig = l->trig; - for (i=0;i>= 1; - trig += N; - } - N2 = N>>1; - N4 = N>>2; + N = l->n; + trig = l->trig; + for (i = 0; i < shift; i++) { + N >>= 1; + trig += N; + } + N2 = N>>1; + N4 = N>>2; -#ifdef FIXED_POINT - { - opus_val32 sumval=N2; - opus_val32 maxval=0; - for (i=0;i>1); - const kiss_twiddle_scalar * OPUS_RESTRICT t = &trig[0]; - const opus_int16 * OPUS_RESTRICT bitrev = l->kfft[shift]->bitrev; - for(i=0;i>1); + const kiss_twiddle_scalar * OAC_RESTRICT t = &trig[0]; + const oac_int16 * OAC_RESTRICT bitrev = l->kfft[shift]->bitrev; + for (i = 0; i < N4; i++) { + int rev; + kiss_fft_scalar yr, yi; + oac_val32 x1, x2; + rev = *bitrev++; + x1 = SHL32_ovflw(*xp1, pre_shift); + x2 = SHL32_ovflw(*xp2, pre_shift); + yr = ADD32_ovflw(S_MUL(x2, t[i]), S_MUL(x1, t[N4 + i])); + yi = SUB32_ovflw(S_MUL(x1, t[i]), S_MUL(x2, t[N4 + i])); + /* We swap real and imag because we use an FFT instead of an IFFT. */ + yp[2*rev + 1] = yr; + yp[2*rev] = yi; + /* Storing the pre-rotation directly in the bitrev order. */ + xp1 += 2*stride; + xp2 -= 2*stride; + } + } - opus_fft_impl(l->kfft[shift], (kiss_fft_cpx*)(out+(overlap>>1)) ARG_FIXED(fft_shift)); + oac_fft_impl(l->kfft[shift], (kiss_fft_cpx*)(out + (overlap>>1))ARG_FIXED(fft_shift)); - /* Post-rotate and de-shuffle from both ends of the buffer at once to make - it in-place. */ - { - kiss_fft_scalar * yp0 = out+(overlap>>1); - kiss_fft_scalar * yp1 = out+(overlap>>1)+N2-2; - const kiss_twiddle_scalar *t = &trig[0]; - /* Loop to (N4+1)>>1 to handle odd N4. When N4 is odd, the - middle pair will be computed twice. */ - for(i=0;i<(N4+1)>>1;i++) - { - kiss_fft_scalar re, im, yr, yi; - kiss_twiddle_scalar t0, t1; - /* We swap real and imag because we're using an FFT instead of an IFFT. */ - re = yp0[1]; - im = yp0[0]; - t0 = t[i]; - t1 = t[N4+i]; - /* We'd scale up by 2 here, but instead it's done when mixing the windows */ - yr = PSHR32_ovflw(ADD32_ovflw(S_MUL(re,t0), S_MUL(im,t1)), post_shift); - yi = PSHR32_ovflw(SUB32_ovflw(S_MUL(re,t1), S_MUL(im,t0)), post_shift); - /* We swap real and imag because we're using an FFT instead of an IFFT. */ - re = yp1[1]; - im = yp1[0]; - yp0[0] = yr; - yp1[1] = yi; + /* Post-rotate and de-shuffle from both ends of the buffer at once to make + it in-place. */ + { + kiss_fft_scalar * yp0 = out + (overlap>>1); + kiss_fft_scalar * yp1 = out + (overlap>>1) + N2 - 2; + const kiss_twiddle_scalar *t = &trig[0]; + /* Loop to (N4+1)>>1 to handle odd N4. When N4 is odd, the + middle pair will be computed twice. */ + for (i = 0; i < (N4 + 1)>>1; i++) { + kiss_fft_scalar re, im, yr, yi; + kiss_twiddle_scalar t0, t1; + /* We swap real and imag because we're using an FFT instead of an IFFT. */ + re = yp0[1]; + im = yp0[0]; + t0 = t[i]; + t1 = t[N4 + i]; + /* We'd scale up by 2 here, but instead it's done when mixing the windows */ + yr = PSHR32_ovflw(ADD32_ovflw(S_MUL(re, t0), S_MUL(im, t1)), post_shift); + yi = PSHR32_ovflw(SUB32_ovflw(S_MUL(re, t1), S_MUL(im, t0)), post_shift); + /* We swap real and imag because we're using an FFT instead of an IFFT. */ + re = yp1[1]; + im = yp1[0]; + yp0[0] = yr; + yp1[1] = yi; - t0 = t[(N4-i-1)]; - t1 = t[(N2-i-1)]; - /* We'd scale up by 2 here, but instead it's done when mixing the windows */ - yr = PSHR32_ovflw(ADD32_ovflw(S_MUL(re,t0), S_MUL(im,t1)), post_shift); - yi = PSHR32_ovflw(SUB32_ovflw(S_MUL(re,t1), S_MUL(im,t0)), post_shift); - yp1[0] = yr; - yp0[1] = yi; - yp0 += 2; - yp1 -= 2; - } - } + t0 = t[(N4 - i - 1)]; + t1 = t[(N2 - i - 1)]; + /* We'd scale up by 2 here, but instead it's done when mixing the windows */ + yr = PSHR32_ovflw(ADD32_ovflw(S_MUL(re, t0), S_MUL(im, t1)), post_shift); + yi = PSHR32_ovflw(SUB32_ovflw(S_MUL(re, t1), S_MUL(im, t0)), post_shift); + yp1[0] = yr; + yp0[1] = yi; + yp0 += 2; + yp1 -= 2; + } + } - /* Mirror on both sides for TDAC */ - { - kiss_fft_scalar * OPUS_RESTRICT xp1 = out+overlap-1; - kiss_fft_scalar * OPUS_RESTRICT yp1 = out; - const celt_coef * OPUS_RESTRICT wp1 = window; - const celt_coef * OPUS_RESTRICT wp2 = window+overlap-1; + /* Mirror on both sides for TDAC */ + { + kiss_fft_scalar * OAC_RESTRICT xp1 = out + overlap - 1; + kiss_fft_scalar * OAC_RESTRICT yp1 = out; + const celt_coef * OAC_RESTRICT wp1 = window; + const celt_coef * OAC_RESTRICT wp2 = window + overlap - 1; - for(i = 0; i < overlap/2; i++) - { - kiss_fft_scalar x1, x2; - x1 = *xp1; - x2 = *yp1; - *yp1++ = SUB32_ovflw(S_MUL(x2, *wp2), S_MUL(x1, *wp1)); - *xp1-- = ADD32_ovflw(S_MUL(x2, *wp1), S_MUL(x1, *wp2)); - wp1++; - wp2--; - } - } + for (i = 0; i < overlap/2; i++) { + kiss_fft_scalar x1, x2; + x1 = *xp1; + x2 = *yp1; + *yp1++ = SUB32_ovflw(S_MUL(x2, *wp2), S_MUL(x1, *wp1)); + *xp1-- = ADD32_ovflw(S_MUL(x2, *wp1), S_MUL(x1, *wp2)); + wp1++; + wp2--; + } + } } -#endif /* OVERRIDE_clt_mdct_backward */ +#endif /* OVERRIDE_oaci_clt_mdct_backward */ diff --git a/celt/mdct.h b/celt/mdct.h index 529b706d9..73bf3b8eb 100644 --- a/celt/mdct.h +++ b/celt/mdct.h @@ -24,7 +24,7 @@ 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. -*/ + */ /* This is a simple MDCT implementation that uses a N/4 complex FFT to do most of the work. It should be relatively straightforward to @@ -37,75 +37,75 @@ The algorithm is similar to (and inspired from) Fabrice Bellard's MDCT implementation in FFMPEG, but has differences in signs, ordering and scaling in many places. -*/ + */ #ifndef MDCT_H #define MDCT_H -#include "opus_defines.h" +#include "oac_defines.h" #include "kiss_fft.h" #include "arch.h" typedef struct { - int n; - int maxshift; - const kiss_fft_state *kfft[4]; - const kiss_twiddle_scalar * OPUS_RESTRICT trig; + int n; + int maxshift; + const kiss_fft_state *kfft[4]; + const kiss_twiddle_scalar * OAC_RESTRICT trig; } mdct_lookup; #if defined(HAVE_ARM_NE10) -#include "arm/mdct_arm.h" +# include "arm/mdct_arm.h" #endif -int clt_mdct_init(mdct_lookup *l,int N, int maxshift, int arch); -void clt_mdct_clear(mdct_lookup *l, int arch); +int oaci_clt_mdct_init(mdct_lookup *l, int N, int maxshift, int arch); +void oaci_clt_mdct_clear(mdct_lookup *l, int arch); /** Compute a forward MDCT and scale by 4/N, trashes the input array */ -void clt_mdct_forward_c(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const celt_coef *window, int overlap, - int shift, int stride, int arch); +void oaci_clt_mdct_forward_c(const mdct_lookup *l, kiss_fft_scalar *in, + kiss_fft_scalar * OAC_RESTRICT out, + const celt_coef *window, int overlap, + int shift, int stride, int arch); /** Compute a backward MDCT (no scaling) and performs weighted overlap-add (scales implicitly by 1/2) */ -void clt_mdct_backward_c(const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, - const celt_coef * OPUS_RESTRICT window, - int overlap, int shift, int stride, int arch); +void oaci_clt_mdct_backward_c(const mdct_lookup *l, kiss_fft_scalar *in, + kiss_fft_scalar * OAC_RESTRICT out, + const celt_coef * OAC_RESTRICT window, + int overlap, int shift, int stride, int arch); -#if !defined(OVERRIDE_OPUS_MDCT) +#if !defined(OVERRIDE_OAC_MDCT) /* Is run-time CPU detection enabled on this platform? */ -#if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) +# if defined(OAC_HAVE_RTCD) && defined(HAVE_ARM_NE10) -extern void (*const CLT_MDCT_FORWARD_IMPL[OPUS_ARCHMASK+1])( +extern void (*const CLT_MDCT_FORWARD_IMPL[OAC_ARCHMASK + 1])( const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, const celt_coef *window, + kiss_fft_scalar * OAC_RESTRICT out, const celt_coef *window, int overlap, int shift, int stride, int arch); -#define clt_mdct_forward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ - ((*CLT_MDCT_FORWARD_IMPL[(arch)&OPUS_ARCHMASK])(_l, _in, _out, \ - _window, _overlap, _shift, \ - _stride, _arch)) +# define oaci_clt_mdct_forward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ + ((*CLT_MDCT_FORWARD_IMPL[(arch)&OAC_ARCHMASK])(_l, _in, _out, \ + _window, _overlap, _shift, \ + _stride, _arch)) -extern void (*const CLT_MDCT_BACKWARD_IMPL[OPUS_ARCHMASK+1])( +extern void (*const CLT_MDCT_BACKWARD_IMPL[OAC_ARCHMASK + 1])( const mdct_lookup *l, kiss_fft_scalar *in, - kiss_fft_scalar * OPUS_RESTRICT out, const celt_coef *window, + kiss_fft_scalar * OAC_RESTRICT out, const celt_coef *window, int overlap, int shift, int stride, int arch); -#define clt_mdct_backward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ - (*CLT_MDCT_BACKWARD_IMPL[(arch)&OPUS_ARCHMASK])(_l, _in, _out, \ - _window, _overlap, _shift, \ - _stride, _arch) +# define oaci_clt_mdct_backward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ + (*CLT_MDCT_BACKWARD_IMPL[(arch)&OAC_ARCHMASK])(_l, _in, _out, \ + _window, _overlap, _shift, \ + _stride, _arch) -#else /* if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) */ +# else /* if defined(OAC_HAVE_RTCD) && defined(HAVE_ARM_NE10) */ -#define clt_mdct_forward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ - clt_mdct_forward_c(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) +# define oaci_clt_mdct_forward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ + oaci_clt_mdct_forward_c(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) -#define clt_mdct_backward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ - clt_mdct_backward_c(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) +# define oaci_clt_mdct_backward(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) \ + oaci_clt_mdct_backward_c(_l, _in, _out, _window, _overlap, _shift, _stride, _arch) -#endif /* end if defined(OPUS_HAVE_RTCD) && defined(HAVE_ARM_NE10) && !defined(FIXED_POINT) */ -#endif /* end if !defined(OVERRIDE_OPUS_MDCT) */ +# endif /* end if defined(OAC_HAVE_RTCD) && defined(HAVE_ARM_NE10) && !defined(FIXED_POINT) */ +#endif /* end if !defined(OVERRIDE_OAC_MDCT) */ #endif diff --git a/celt/meson.build b/celt/meson.build index 46601ca13..a28bf2628 100644 --- a/celt/meson.build +++ b/celt/meson.build @@ -12,7 +12,7 @@ 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') +if host_cpu_family in ['x86', 'x86_64'] and oac_conf.has('OAC_HAVE_RTCD') celt_sources += sources['CELT_SOURCES_X86_RTCD'] endif @@ -23,10 +23,10 @@ foreach intr_name : ['sse', 'sse2', 'sse4_1', 'avx2', 'neon_intr'] endif intr_sources = get_variable('celt_@0@_sources'.format(intr_name)) - intr_args = get_variable('opus_@0@_args'.format(intr_name), []) + intr_args = get_variable('oac_@0@_args'.format(intr_name), []) celt_static_libs += static_library('celt_' + intr_name, intr_sources, c_args: intr_args, - include_directories: opus_includes, + include_directories: oac_includes, install: false) endforeach @@ -36,13 +36,13 @@ if (intrinsics_support.length() + asm_optimization.length() + inline_optimizatio endif if host_cpu_family in ['arm', 'aarch64'] and have_arm_intrinsics_or_asm - if opus_conf.has('OPUS_HAVE_RTCD') + if oac_conf.has('OAC_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 + if oac_arm_external_asm subdir('arm') celt_static_libs += static_library('celt-armasm', celt_arm_armopts_s, celt_sources_arm_asm, @@ -55,10 +55,10 @@ if host_system == 'windows' celt_c_args += ['-DDLL_EXPORT'] endif -celt_lib = static_library('opus-celt', +celt_lib = static_library('oac-celt', celt_sources, c_args: celt_c_args, - include_directories: opus_includes, + include_directories: oac_includes, link_whole: celt_static_libs, dependencies: libm, install: false) diff --git a/celt/mfrngcod.h b/celt/mfrngcod.h index 809152a59..51770d88c 100644 --- a/celt/mfrngcod.h +++ b/celt/mfrngcod.h @@ -23,26 +23,26 @@ 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. -*/ + */ #if !defined(_mfrngcode_H) -# define _mfrngcode_H (1) -# include "entcode.h" +#define _mfrngcode_H (1) +#include "entcode.h" /*Constants used by the entropy encoder/decoder.*/ /*The number of bits to output at a time.*/ -# define EC_SYM_BITS (8) +#define EC_SYM_BITS (8) /*The total number of bits in each of the state registers.*/ -# define EC_CODE_BITS (32) +#define EC_CODE_BITS (32) /*The maximum symbol value.*/ -# define EC_SYM_MAX ((1U<>EC_SYM_BITS) +#define EC_CODE_BOT (EC_CODE_TOP>>EC_SYM_BITS) /*The number of bits available for the last, partial symbol in the code field.*/ -# define EC_CODE_EXTRA ((EC_CODE_BITS-2)%EC_SYM_BITS+1) +#define EC_CODE_EXTRA ((EC_CODE_BITS - 2)%EC_SYM_BITS + 1) #endif diff --git a/celt/mini_kfft.c b/celt/mini_kfft.c index b2b92504b..212a3bdd9 100644 --- a/celt/mini_kfft.c +++ b/celt/mini_kfft.c @@ -25,11 +25,11 @@ typedef struct mini_kiss_fft_state* mini_kiss_fft_cfg; #define MINI_MAXFACTORS 32 /* e.g. an fft of length 128 has 4 factors - as far as kissfft is concerned - 4*4*4*2 + as far as kissfft is concerned + 4*4*4*2 */ -typedef struct mini_kiss_fft_state{ +typedef struct mini_kiss_fft_state { int nfft; int inverse; int factors[2*MINI_MAXFACTORS]; @@ -37,7 +37,7 @@ typedef struct mini_kiss_fft_state{ } mini_kiss_fft_state; /* - Explanation of macros dealing with complex math: + Explanation of macros dealing with complex math: C_MUL(m,a,b) : m = a*b C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise @@ -46,274 +46,264 @@ typedef struct mini_kiss_fft_state{ C_ADDTO( res , a) : res += a * */ -# define S_MUL(a,b) ( (a)*(b) ) -#define C_MUL(m,a,b) \ - do{ (m).r = (a).r*(b).r - (a).i*(b).i;\ - (m).i = (a).r*(b).i + (a).i*(b).r; }while(0) -# define C_FIXDIV(c,div) /* NOOP */ -# define C_MULBYSCALAR( c, s ) \ - do{ (c).r *= (s);\ - (c).i *= (s); }while(0) - - -#define CHECK_OVERFLOW_OP(a,op,b) /* noop */ - -#define C_ADD( res, a,b)\ - do { \ - CHECK_OVERFLOW_OP((a).r,+,(b).r)\ - CHECK_OVERFLOW_OP((a).i,+,(b).i)\ - (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \ - }while(0) -#define C_SUB( res, a,b)\ - do { \ - CHECK_OVERFLOW_OP((a).r,-,(b).r)\ - CHECK_OVERFLOW_OP((a).i,-,(b).i)\ - (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \ - }while(0) -#define C_ADDTO( res , a)\ - do { \ - CHECK_OVERFLOW_OP((res).r,+,(a).r)\ - CHECK_OVERFLOW_OP((res).i,+,(a).i)\ - (res).r += (a).r; (res).i += (a).i;\ - }while(0) - -#define C_SUBFROM( res , a)\ - do {\ - CHECK_OVERFLOW_OP((res).r,-,(a).r)\ - CHECK_OVERFLOW_OP((res).i,-,(a).i)\ - (res).r -= (a).r; (res).i -= (a).i; \ - }while(0) - - -# define MINI_KISS_FFT_COS(phase) (mini_kiss_fft_scalar) cos(phase) -# define MINI_KISS_FFT_SIN(phase) (mini_kiss_fft_scalar) sin(phase) -# define MINI_HALF_OF(x) ((x)*((mini_kiss_fft_scalar).5)) - -#define mini_kf_cexp(x,phase) \ - do{ \ - (x)->r = MINI_KISS_FFT_COS(phase);\ - (x)->i = MINI_KISS_FFT_SIN(phase);\ - }while(0) - - - - -static void kf_bfly2( - mini_kiss_fft_cpx * Fout, - const size_t fstride, - const mini_kiss_fft_cfg st, - int m - ) -{ +#define S_MUL(a, b) ((a)*(b)) +#define C_MUL(m, a, b) \ + do { (m).r = (a).r*(b).r - (a).i*(b).i; \ + (m).i = (a).r*(b).i + (a).i*(b).r; } while (0) +#define C_FIXDIV(c, div) /* NOOP */ +#define C_MULBYSCALAR( c, s ) \ + do { (c).r *= (s); \ + (c).i *= (s); } while (0) + + +#define CHECK_OVERFLOW_OP(a, op, b) /* noop */ + +#define C_ADD( res, a, b) \ + do { \ + CHECK_OVERFLOW_OP((a).r, +, (b).r) \ + CHECK_OVERFLOW_OP((a).i, +, (b).i) \ + (res).r = (a).r + (b).r; (res).i = (a).i + (b).i; \ + } while (0) +#define C_SUB( res, a, b) \ + do { \ + CHECK_OVERFLOW_OP((a).r, -, (b).r) \ + CHECK_OVERFLOW_OP((a).i, -, (b).i) \ + (res).r = (a).r - (b).r; (res).i = (a).i - (b).i; \ + } while (0) +#define C_ADDTO( res, a) \ + do { \ + CHECK_OVERFLOW_OP((res).r, +, (a).r) \ + CHECK_OVERFLOW_OP((res).i, +, (a).i) \ + (res).r += (a).r; (res).i += (a).i; \ + } while (0) + +#define C_SUBFROM( res, a) \ + do { \ + CHECK_OVERFLOW_OP((res).r, -, (a).r) \ + CHECK_OVERFLOW_OP((res).i, -, (a).i) \ + (res).r -= (a).r; (res).i -= (a).i; \ + } while (0) + + +#define MINI_KISS_FFT_COS(phase) (mini_kiss_fft_scalar) cos(phase) +#define MINI_KISS_FFT_SIN(phase) (mini_kiss_fft_scalar) sin(phase) +#define MINI_HALF_OF(x) ((x)*((mini_kiss_fft_scalar).5)) + +#define mini_kf_cexp(x, phase) \ + do { \ + (x)->r = MINI_KISS_FFT_COS(phase); \ + (x)->i = MINI_KISS_FFT_SIN(phase); \ + } while (0) + + + + +static void oaci_kf_bfly2( + mini_kiss_fft_cpx * Fout, + const size_t fstride, + const mini_kiss_fft_cfg st, + int m) { mini_kiss_fft_cpx * Fout2; mini_kiss_fft_cpx * tw1 = st->twiddles; mini_kiss_fft_cpx t; Fout2 = Fout + m; - do{ - C_FIXDIV(*Fout,2); C_FIXDIV(*Fout2,2); + do { + C_FIXDIV(*Fout, 2); C_FIXDIV(*Fout2, 2); - C_MUL (t, *Fout2 , *tw1); + C_MUL (t, *Fout2, *tw1); tw1 += fstride; - C_SUB( *Fout2 , *Fout , t ); - C_ADDTO( *Fout , t ); + C_SUB( *Fout2, *Fout, t ); + C_ADDTO( *Fout, t ); ++Fout2; ++Fout; - }while (--m); + } while (--m); } -static void kf_bfly4( - mini_kiss_fft_cpx * Fout, - const size_t fstride, - const mini_kiss_fft_cfg st, - const size_t m - ) -{ - mini_kiss_fft_cpx *tw1,*tw2,*tw3; +static void oaci_kf_bfly4( + mini_kiss_fft_cpx * Fout, + const size_t fstride, + const mini_kiss_fft_cfg st, + const size_t m) { + mini_kiss_fft_cpx *tw1, *tw2, *tw3; mini_kiss_fft_cpx scratch[6]; - size_t k=m; - const size_t m2=2*m; - const size_t m3=3*m; + size_t k = m; + const size_t m2 = 2*m; + const size_t m3 = 3*m; tw3 = tw2 = tw1 = st->twiddles; do { - C_FIXDIV(*Fout,4); C_FIXDIV(Fout[m],4); C_FIXDIV(Fout[m2],4); C_FIXDIV(Fout[m3],4); + C_FIXDIV(*Fout, 4); C_FIXDIV(Fout[m], 4); C_FIXDIV(Fout[m2], 4); C_FIXDIV(Fout[m3], 4); - C_MUL(scratch[0],Fout[m] , *tw1 ); - C_MUL(scratch[1],Fout[m2] , *tw2 ); - C_MUL(scratch[2],Fout[m3] , *tw3 ); + C_MUL(scratch[0], Fout[m], *tw1 ); + C_MUL(scratch[1], Fout[m2], *tw2 ); + C_MUL(scratch[2], Fout[m3], *tw3 ); - C_SUB( scratch[5] , *Fout, scratch[1] ); + C_SUB( scratch[5], *Fout, scratch[1] ); C_ADDTO(*Fout, scratch[1]); - C_ADD( scratch[3] , scratch[0] , scratch[2] ); - C_SUB( scratch[4] , scratch[0] , scratch[2] ); + C_ADD( scratch[3], scratch[0], scratch[2] ); + C_SUB( scratch[4], scratch[0], scratch[2] ); C_SUB( Fout[m2], *Fout, scratch[3] ); tw1 += fstride; tw2 += fstride*2; tw3 += fstride*3; - C_ADDTO( *Fout , scratch[3] ); + C_ADDTO( *Fout, scratch[3] ); - if(st->inverse) { + if (st->inverse) { Fout[m].r = scratch[5].r - scratch[4].i; Fout[m].i = scratch[5].i + scratch[4].r; Fout[m3].r = scratch[5].r + scratch[4].i; Fout[m3].i = scratch[5].i - scratch[4].r; - }else{ + } else { Fout[m].r = scratch[5].r + scratch[4].i; Fout[m].i = scratch[5].i - scratch[4].r; Fout[m3].r = scratch[5].r - scratch[4].i; Fout[m3].i = scratch[5].i + scratch[4].r; } ++Fout; - }while(--k); + } while (--k); } -static void kf_bfly3( - mini_kiss_fft_cpx * Fout, - const size_t fstride, - const mini_kiss_fft_cfg st, - size_t m - ) -{ - size_t k=m; - const size_t m2 = 2*m; - mini_kiss_fft_cpx *tw1,*tw2; - mini_kiss_fft_cpx scratch[5]; - mini_kiss_fft_cpx epi3; - epi3 = st->twiddles[fstride*m]; +static void oaci_kf_bfly3( + mini_kiss_fft_cpx * Fout, + const size_t fstride, + const mini_kiss_fft_cfg st, + size_t m) { + size_t k = m; + const size_t m2 = 2*m; + mini_kiss_fft_cpx *tw1, *tw2; + mini_kiss_fft_cpx scratch[5]; + mini_kiss_fft_cpx epi3; + epi3 = st->twiddles[fstride*m]; - tw1=tw2=st->twiddles; + tw1 = tw2 = st->twiddles; - do{ - C_FIXDIV(*Fout,3); C_FIXDIV(Fout[m],3); C_FIXDIV(Fout[m2],3); + do { + C_FIXDIV(*Fout, 3); C_FIXDIV(Fout[m], 3); C_FIXDIV(Fout[m2], 3); - C_MUL(scratch[1],Fout[m] , *tw1); - C_MUL(scratch[2],Fout[m2] , *tw2); + C_MUL(scratch[1], Fout[m], *tw1); + C_MUL(scratch[2], Fout[m2], *tw2); - C_ADD(scratch[3],scratch[1],scratch[2]); - C_SUB(scratch[0],scratch[1],scratch[2]); - tw1 += fstride; - tw2 += fstride*2; + C_ADD(scratch[3], scratch[1], scratch[2]); + C_SUB(scratch[0], scratch[1], scratch[2]); + tw1 += fstride; + tw2 += fstride*2; - Fout[m].r = Fout->r - MINI_HALF_OF(scratch[3].r); - Fout[m].i = Fout->i - MINI_HALF_OF(scratch[3].i); + Fout[m].r = Fout->r - MINI_HALF_OF(scratch[3].r); + Fout[m].i = Fout->i - MINI_HALF_OF(scratch[3].i); - C_MULBYSCALAR( scratch[0] , epi3.i ); + C_MULBYSCALAR( scratch[0], epi3.i ); - C_ADDTO(*Fout,scratch[3]); + C_ADDTO(*Fout, scratch[3]); - Fout[m2].r = Fout[m].r + scratch[0].i; - Fout[m2].i = Fout[m].i - scratch[0].r; + Fout[m2].r = Fout[m].r + scratch[0].i; + Fout[m2].i = Fout[m].i - scratch[0].r; - Fout[m].r -= scratch[0].i; - Fout[m].i += scratch[0].r; + Fout[m].r -= scratch[0].i; + Fout[m].i += scratch[0].r; - ++Fout; - }while(--k); + ++Fout; + } while (--k); } -static void kf_bfly5( - mini_kiss_fft_cpx * Fout, - const size_t fstride, - const mini_kiss_fft_cfg st, - int m - ) -{ - mini_kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; +static void oaci_kf_bfly5( + mini_kiss_fft_cpx * Fout, + const size_t fstride, + const mini_kiss_fft_cfg st, + int m) { + mini_kiss_fft_cpx *Fout0, *Fout1, *Fout2, *Fout3, *Fout4; int u; mini_kiss_fft_cpx scratch[13]; mini_kiss_fft_cpx * twiddles = st->twiddles; mini_kiss_fft_cpx *tw; - mini_kiss_fft_cpx ya,yb; + mini_kiss_fft_cpx ya, yb; ya = twiddles[fstride*m]; yb = twiddles[fstride*2*m]; - Fout0=Fout; - Fout1=Fout0+m; - Fout2=Fout0+2*m; - Fout3=Fout0+3*m; - Fout4=Fout0+4*m; + Fout0 = Fout; + Fout1 = Fout0 + m; + Fout2 = Fout0 + 2*m; + Fout3 = Fout0 + 3*m; + Fout4 = Fout0 + 4*m; - tw=st->twiddles; - for ( u=0; utwiddles; + for (u = 0; u < m; ++u) { + C_FIXDIV( *Fout0, 5); C_FIXDIV( *Fout1, 5); C_FIXDIV( *Fout2, 5); C_FIXDIV( *Fout3, 5); C_FIXDIV( *Fout4, 5); scratch[0] = *Fout0; - C_MUL(scratch[1] ,*Fout1, tw[u*fstride]); - C_MUL(scratch[2] ,*Fout2, tw[2*u*fstride]); - C_MUL(scratch[3] ,*Fout3, tw[3*u*fstride]); - C_MUL(scratch[4] ,*Fout4, tw[4*u*fstride]); + C_MUL(scratch[1], *Fout1, tw[u*fstride]); + C_MUL(scratch[2], *Fout2, tw[2*u*fstride]); + C_MUL(scratch[3], *Fout3, tw[3*u*fstride]); + C_MUL(scratch[4], *Fout4, tw[4*u*fstride]); - C_ADD( scratch[7],scratch[1],scratch[4]); - C_SUB( scratch[10],scratch[1],scratch[4]); - C_ADD( scratch[8],scratch[2],scratch[3]); - C_SUB( scratch[9],scratch[2],scratch[3]); + C_ADD( scratch[7], scratch[1], scratch[4]); + C_SUB( scratch[10], scratch[1], scratch[4]); + C_ADD( scratch[8], scratch[2], scratch[3]); + C_SUB( scratch[9], scratch[2], scratch[3]); Fout0->r += scratch[7].r + scratch[8].r; Fout0->i += scratch[7].i + scratch[8].i; - scratch[5].r = scratch[0].r + S_MUL(scratch[7].r,ya.r) + S_MUL(scratch[8].r,yb.r); - scratch[5].i = scratch[0].i + S_MUL(scratch[7].i,ya.r) + S_MUL(scratch[8].i,yb.r); + scratch[5].r = scratch[0].r + S_MUL(scratch[7].r, ya.r) + S_MUL(scratch[8].r, yb.r); + scratch[5].i = scratch[0].i + S_MUL(scratch[7].i, ya.r) + S_MUL(scratch[8].i, yb.r); - scratch[6].r = S_MUL(scratch[10].i,ya.i) + S_MUL(scratch[9].i,yb.i); - scratch[6].i = -S_MUL(scratch[10].r,ya.i) - S_MUL(scratch[9].r,yb.i); + scratch[6].r = S_MUL(scratch[10].i, ya.i) + S_MUL(scratch[9].i, yb.i); + scratch[6].i = -S_MUL(scratch[10].r, ya.i) - S_MUL(scratch[9].r, yb.i); - C_SUB(*Fout1,scratch[5],scratch[6]); - C_ADD(*Fout4,scratch[5],scratch[6]); + C_SUB(*Fout1, scratch[5], scratch[6]); + C_ADD(*Fout4, scratch[5], scratch[6]); - scratch[11].r = scratch[0].r + S_MUL(scratch[7].r,yb.r) + S_MUL(scratch[8].r,ya.r); - scratch[11].i = scratch[0].i + S_MUL(scratch[7].i,yb.r) + S_MUL(scratch[8].i,ya.r); - scratch[12].r = - S_MUL(scratch[10].i,yb.i) + S_MUL(scratch[9].i,ya.i); - scratch[12].i = S_MUL(scratch[10].r,yb.i) - S_MUL(scratch[9].r,ya.i); + scratch[11].r = scratch[0].r + S_MUL(scratch[7].r, yb.r) + S_MUL(scratch[8].r, ya.r); + scratch[11].i = scratch[0].i + S_MUL(scratch[7].i, yb.r) + S_MUL(scratch[8].i, ya.r); + scratch[12].r = -S_MUL(scratch[10].i, yb.i) + S_MUL(scratch[9].i, ya.i); + scratch[12].i = S_MUL(scratch[10].r, yb.i) - S_MUL(scratch[9].r, ya.i); - C_ADD(*Fout2,scratch[11],scratch[12]); - C_SUB(*Fout3,scratch[11],scratch[12]); + C_ADD(*Fout2, scratch[11], scratch[12]); + C_SUB(*Fout3, scratch[11], scratch[12]); - ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4; + ++Fout0; ++Fout1; ++Fout2; ++Fout3; ++Fout4; } } static void kf_work( - mini_kiss_fft_cpx * Fout, - const mini_kiss_fft_cpx * f, - const size_t fstride, - int in_stride, - int * factors, - const mini_kiss_fft_cfg st - ) -{ - mini_kiss_fft_cpx * Fout_beg=Fout; - const int p=*factors++; /* the radix */ - const int m=*factors++; /* stage's fft length/p */ + mini_kiss_fft_cpx * Fout, + const mini_kiss_fft_cpx * f, + const size_t fstride, + int in_stride, + int * factors, + const mini_kiss_fft_cfg st) { + mini_kiss_fft_cpx * Fout_beg = Fout; + const int p = *factors++; /* the radix */ + const int m = *factors++; /* stage's fft length/p */ const mini_kiss_fft_cpx * Fout_end = Fout + p*m; - if (m==1) { - do{ + if (m == 1) { + do { *Fout = *f; f += fstride*in_stride; - }while(++Fout != Fout_end ); - }else{ - do{ + } while (++Fout != Fout_end); + } else { + do { /* recursive call: DFT of size m*p performed by doing p instances of smaller DFTs of size m, each one takes a decimated version of the input */ - kf_work( Fout , f, fstride*p, in_stride, factors,st); + kf_work( Fout, f, fstride*p, in_stride, factors, st); f += fstride*in_stride; - }while( (Fout += m) != Fout_end ); + } while ((Fout += m) != Fout_end); } - Fout=Fout_beg; + Fout = Fout_beg; /* recombine the p smaller DFTs*/ switch (p) { - case 2: kf_bfly2(Fout,fstride,st,m); break; - case 3: kf_bfly3(Fout,fstride,st,m); break; - case 4: kf_bfly4(Fout,fstride,st,m); break; - case 5: kf_bfly5(Fout,fstride,st,m); break; + case 2: oaci_kf_bfly2(Fout, fstride, st, m); break; + case 3: oaci_kf_bfly3(Fout, fstride, st, m); break; + case 4: oaci_kf_bfly4(Fout, fstride, st, m); break; + case 5: oaci_kf_bfly5(Fout, fstride, st, m); break; default: assert(0); } } @@ -323,15 +313,14 @@ void kf_work( p[i] * m[i] = m[i-1] m0 = n */ static -void kf_factor(int n,int * facbuf) -{ - int p=4; +void oaci_kf_factor(int n, int * facbuf) { + int p = 4; double floor_sqrt; - floor_sqrt = floor( sqrt((double)n) ); + floor_sqrt = floor( sqrt((double)n)); /*factor out powers of 4, powers of 2, then any remaining primes */ do { - while (n % p) { + while (n%p) { switch (p) { case 4: p = 2; break; case 2: p = 3; break; @@ -353,71 +342,67 @@ void kf_factor(int n,int * facbuf) * The return value is a contiguous block of memory, allocated with malloc. As such, * It can be freed with free(), rather than a kiss_fft-specific function. * */ -mini_kiss_fft_cfg mini_kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem ) -{ +mini_kiss_fft_cfg mini_kiss_fft_alloc(int nfft, int inverse_fft, void * mem, size_t * lenmem ) { - mini_kiss_fft_cfg st=NULL; + mini_kiss_fft_cfg st = NULL; size_t memneeded = (sizeof(struct mini_kiss_fft_state) - + sizeof(mini_kiss_fft_cpx)*(nfft-1)); /* twiddle factors*/ + + sizeof(mini_kiss_fft_cpx)*(nfft - 1)); /* twiddle factors*/ - if ( lenmem==NULL ) { + if (lenmem == NULL) { st = ( mini_kiss_fft_cfg)malloc( memneeded ); - }else{ + } else { if (mem != NULL && *lenmem >= memneeded) st = (mini_kiss_fft_cfg)mem; *lenmem = memneeded; } if (st) { int i; - st->nfft=nfft; + st->nfft = nfft; st->inverse = inverse_fft; - for (i=0;iinverse) phase *= -1; - mini_kf_cexp(st->twiddles+i, phase ); + mini_kf_cexp(st->twiddles + i, phase ); } - kf_factor(nfft,st->factors); + oaci_kf_factor(nfft, st->factors); } return st; } -void mini_kiss_fft_stride(mini_kiss_fft_cfg st,const mini_kiss_fft_cpx *fin,mini_kiss_fft_cpx *fout,int in_stride) -{ +void mini_kiss_fft_stride(mini_kiss_fft_cfg st, const mini_kiss_fft_cpx *fin, mini_kiss_fft_cpx *fout, int in_stride) { assert(fin != fout); - kf_work( fout, fin, 1,in_stride, st->factors,st ); + kf_work( fout, fin, 1, in_stride, st->factors, st ); } -void mini_kiss_fft(mini_kiss_fft_cfg cfg,const mini_kiss_fft_cpx *fin,mini_kiss_fft_cpx *fout) -{ - mini_kiss_fft_stride(cfg,fin,fout,1); +void mini_kiss_fft(mini_kiss_fft_cfg cfg, const mini_kiss_fft_cpx *fin, mini_kiss_fft_cpx *fout) { + mini_kiss_fft_stride(cfg, fin, fout, 1); } typedef struct mini_kiss_fftr_state *mini_kiss_fftr_cfg; -typedef struct mini_kiss_fftr_state{ +typedef struct mini_kiss_fftr_state { mini_kiss_fft_cfg substate; mini_kiss_fft_cpx * tmpbuf; mini_kiss_fft_cpx * super_twiddles; } mini_kiss_fftr_state; -mini_kiss_fftr_cfg mini_kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem) -{ +mini_kiss_fftr_cfg mini_kiss_fftr_alloc(int nfft, int inverse_fft, void * mem, size_t * lenmem) { int i; mini_kiss_fftr_cfg st = NULL; size_t subsize = 0, memneeded; - assert ((nfft & 1) == 0); + assert ((nfft&1) == 0); nfft >>= 1; mini_kiss_fft_alloc (nfft, inverse_fft, NULL, &subsize); - memneeded = sizeof(struct mini_kiss_fftr_state) + subsize + sizeof(mini_kiss_fft_cpx) * ( nfft * 3 / 2); + memneeded = sizeof(struct mini_kiss_fftr_state) + subsize + sizeof(mini_kiss_fft_cpx)*(nfft*3/2); if (lenmem == NULL) { st = (mini_kiss_fftr_cfg) malloc(memneeded); @@ -436,26 +421,25 @@ mini_kiss_fftr_cfg mini_kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size for (i = 0; i < nfft/2; ++i) { double phase = - -3.14159265358979323846264338327 * ((double) (i+1) / nfft + .5); + -3.14159265358979323846264338327*((double) (i + 1)/nfft + .5); if (inverse_fft) phase *= -1; - mini_kf_cexp (st->super_twiddles+i,phase); + mini_kf_cexp (st->super_twiddles + i, phase); } return st; } -void mini_kiss_fftr(mini_kiss_fftr_cfg st,const mini_kiss_fft_scalar *timedata,mini_kiss_fft_cpx *freqdata) -{ +void mini_kiss_fftr(mini_kiss_fftr_cfg st, const mini_kiss_fft_scalar *timedata, mini_kiss_fft_cpx *freqdata) { /* input buffer timedata is stored row-wise */ - int k,ncfft; - mini_kiss_fft_cpx fpnk,fpk,f1k,f2k,tw,tdc; + int k, ncfft; + mini_kiss_fft_cpx fpnk, fpk, f1k, f2k, tw, tdc; assert ( !st->substate->inverse); ncfft = st->substate->nfft; /*perform the parallel fft of two real signals packed in real,imag*/ - mini_kiss_fft( st->substate , (const mini_kiss_fft_cpx*)timedata, st->tmpbuf ); + mini_kiss_fft( st->substate, (const mini_kiss_fft_cpx*)timedata, st->tmpbuf ); /* The real part of the DC element of the frequency spectrum in st->tmpbuf * contains the sum of the even-numbered elements of the input time sequence * The imag part is the sum of the odd-numbered elements @@ -468,27 +452,27 @@ void mini_kiss_fftr(mini_kiss_fftr_cfg st,const mini_kiss_fft_scalar *timedata,m tdc.r = st->tmpbuf[0].r; tdc.i = st->tmpbuf[0].i; - C_FIXDIV(tdc,2); - CHECK_OVERFLOW_OP(tdc.r ,+, tdc.i); - CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i); + C_FIXDIV(tdc, 2); + CHECK_OVERFLOW_OP(tdc.r, +, tdc.i); + CHECK_OVERFLOW_OP(tdc.r, -, tdc.i); freqdata[0].r = tdc.r + tdc.i; freqdata[ncfft].r = tdc.r - tdc.i; freqdata[ncfft].i = freqdata[0].i = 0; - for ( k=1;k <= ncfft/2 ; ++k ) { + for (k = 1; k <= ncfft/2 ; ++k) { fpk = st->tmpbuf[k]; - fpnk.r = st->tmpbuf[ncfft-k].r; - fpnk.i = - st->tmpbuf[ncfft-k].i; - C_FIXDIV(fpk,2); - C_FIXDIV(fpnk,2); + fpnk.r = st->tmpbuf[ncfft - k].r; + fpnk.i = -st->tmpbuf[ncfft - k].i; + C_FIXDIV(fpk, 2); + C_FIXDIV(fpnk, 2); - C_ADD( f1k, fpk , fpnk ); - C_SUB( f2k, fpk , fpnk ); - C_MUL( tw , f2k , st->super_twiddles[k-1]); + C_ADD( f1k, fpk, fpnk ); + C_SUB( f2k, fpk, fpnk ); + C_MUL( tw, f2k, st->super_twiddles[k - 1]); freqdata[k].r = MINI_HALF_OF(f1k.r + tw.r); freqdata[k].i = MINI_HALF_OF(f1k.i + tw.i); - freqdata[ncfft-k].r = MINI_HALF_OF(f1k.r - tw.r); - freqdata[ncfft-k].i = MINI_HALF_OF(tw.i - f1k.i); + freqdata[ncfft - k].r = MINI_HALF_OF(f1k.r - tw.r); + freqdata[ncfft - k].i = MINI_HALF_OF(tw.i - f1k.i); } } diff --git a/celt/mips/celt_mipsr1.h b/celt/mips/celt_mipsr1.h deleted file mode 100644 index 8a5d0c90a..000000000 --- a/celt/mips/celt_mipsr1.h +++ /dev/null @@ -1,198 +0,0 @@ -/* Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2010 Xiph.Org Foundation - Copyright (c) 2008 Gregory Maxwell - Written by Jean-Marc Valin and Gregory Maxwell */ -/* - 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. -*/ - -#ifndef CELT_MIPSR1_H__ -#define CELT_MIPSR1_H__ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define CELT_C - -#if defined (__mips_dsp) && __mips == 32 - -#define OVERRIDE_COMB_FILTER_CONST -#define OVERRIDE_comb_filter -#elif defined(__mips_isa_rev) && __mips_isa_rev < 6 - -#define OVERRIDE_COMB_FILTER_CONST -#define OVERRIDE_comb_filter -#endif - -#include "os_support.h" -#include "mdct.h" -#include -#include "celt.h" -#include "pitch.h" -#include "bands.h" -#include "modes.h" -#include "entcode.h" -#include "quant_bands.h" -#include "rate.h" -#include "stack_alloc.h" -#include "mathops.h" -#include "float_cast.h" -#include -#include "celt_lpc.h" -#include "vq.h" - -#if defined (__mips_dsp) && __mips == 32 - -#define MIPS_MULT __builtin_mips_mult -#define MIPS_MADD __builtin_mips_madd -#define MIPS_EXTR __builtin_mips_extr_w - -#elif defined(__mips_isa_rev) && __mips_isa_rev < 6 - -static inline long long MIPS_MULT(int a, int b) { - long long acc; - - asm volatile ( - "mult %[a], %[b] \n" - : [acc] "=x"(acc) - : [a] "r"(a), [b] "r"(b) - : - ); - return acc; -} - -static inline long long MIPS_MADD(long long acc, int a, int b) { - asm volatile ( - "madd %[a], %[b] \n" - : [acc] "+x"(acc) - : [a] "r"(a), [b] "r"(b) - : - ); - return acc; -} - -static inline opus_val32 MIPS_EXTR(long long acc, int shift) { - return (opus_val32)(acc >> shift); -} - -#endif - -#if defined (OVERRIDE_comb_filter) -void comb_filter(opus_val32 *y, opus_val32 *x, int T0, int T1, int N, - opus_val16 g0, opus_val16 g1, int tapset0, int tapset1, - const opus_val16 *window, int overlap, int arch) -{ - int i; - opus_val32 x0, x1, x2, x3, x4; - - (void)arch; - - /* printf ("%d %d %f %f\n", T0, T1, g0, g1); */ - opus_val16 g00, g01, g02, g10, g11, g12; - static const opus_val16 gains[3][3] = { - {QCONST16(0.3066406250f, 15), QCONST16(0.2170410156f, 15), QCONST16(0.1296386719f, 15)}, - {QCONST16(0.4638671875f, 15), QCONST16(0.2680664062f, 15), QCONST16(0.f, 15)}, - {QCONST16(0.7998046875f, 15), QCONST16(0.1000976562f, 15), QCONST16(0.f, 15)}}; - - if (g0==0 && g1==0) - { - /* OPT: Happens to work without the OPUS_MOVE(), but only because the current encoder already copies x to y */ - if (x!=y) - OPUS_MOVE(y, x, N); - return; - } - - g00 = MULT16_16_P15(g0, gains[tapset0][0]); - g01 = MULT16_16_P15(g0, gains[tapset0][1]); - g02 = MULT16_16_P15(g0, gains[tapset0][2]); - g10 = MULT16_16_P15(g1, gains[tapset1][0]); - g11 = MULT16_16_P15(g1, gains[tapset1][1]); - g12 = MULT16_16_P15(g1, gains[tapset1][2]); - x1 = x[-T1+1]; - x2 = x[-T1 ]; - x3 = x[-T1-1]; - x4 = x[-T1-2]; - /* If the filter didn't change, we don't need the overlap */ - if (g0==g1 && T0==T1 && tapset0==tapset1) - overlap=0; - - for (i=0;i 0) { - v2max = (v2i16){ 0, ABS16(*x) }; - x++; - len--; - } - x2 = __builtin_assume_aligned(x, 4); - loops = len / 4; - - for (i = 0; i < loops; i++) - { - x01 = *x2++; - x23 = *x2++; - x01 = __builtin_mips_absq_s_ph(x01); - x23 = __builtin_mips_absq_s_ph(x23); - __builtin_mips_cmp_lt_ph(v2max, x01); - v2max = __builtin_mips_pick_ph(x01, v2max); - __builtin_mips_cmp_lt_ph(v2max, x23); - v2max = __builtin_mips_pick_ph(x23, v2max); - } - - switch (len & 3) { - case 3: - x01 = __builtin_mips_absq_s_ph(*x2); - __builtin_mips_cmp_lt_ph(v2max, x01); - v2max = __builtin_mips_pick_ph(x01, v2max); - maxlo = EXTRACT16((opus_val32)v2max); - maxhi = EXTRACT16((opus_val32)v2max >> 16); - maxlo = MAX16(MAX16(maxlo, maxhi), ABS16(x[len - 1])); - break; - case 2: - x01 = __builtin_mips_absq_s_ph(*x2); - __builtin_mips_cmp_lt_ph(v2max, x01); - v2max = __builtin_mips_pick_ph(x01, v2max); - maxlo = EXTRACT16((opus_val32)v2max); - maxhi = EXTRACT16((opus_val32)v2max >> 16); - maxlo = MAX16(maxlo, maxhi); - break; - case 1: - maxlo = EXTRACT16((opus_val32)v2max); - maxhi = EXTRACT16((opus_val32)v2max >> 16); - return MAX16(MAX16(maxlo, maxhi), ABS16(x[len - 1])); - break; - case 0: - maxlo = EXTRACT16((opus_val32)v2max); - maxhi = EXTRACT16((opus_val32)v2max >> 16); - maxlo = MAX16(maxlo, maxhi); - break; - default: - __builtin_unreachable(); - } - /* C version might return 0x8000, this one can't - * because abs is saturated here. Since result - * used only for determine dynamic range - * in ilog2-like context it's worth to add 1 - * for proper magnitude whether saturated - */ - return (opus_val32)maxlo + 1; +# define OVERRIDE_CELT_MAXABS16 +static OAC_INLINE oac_val32 oaci_celt_maxabs16(const oac_val16 *x, int len) { + int i; + v2i16 v2max = (v2i16) { 0, 0 }; + v2i16 x01, x23; + const v2i16 *x2; + oac_val16 maxlo, maxhi; + int loops; + + if ((long)x&2 && len > 0) { + v2max = (v2i16) { 0, ABS16(*x) }; + x++; + len--; + } + x2 = __builtin_assume_aligned(x, 4); + loops = len/4; + + for (i = 0; i < loops; i++) { + x01 = *x2++; + x23 = *x2++; + x01 = __builtin_mips_absq_s_ph(x01); + x23 = __builtin_mips_absq_s_ph(x23); + __builtin_mips_cmp_lt_ph(v2max, x01); + v2max = __builtin_mips_pick_ph(x01, v2max); + __builtin_mips_cmp_lt_ph(v2max, x23); + v2max = __builtin_mips_pick_ph(x23, v2max); + } + + switch (len&3) { + case 3: + x01 = __builtin_mips_absq_s_ph(*x2); + __builtin_mips_cmp_lt_ph(v2max, x01); + v2max = __builtin_mips_pick_ph(x01, v2max); + maxlo = EXTRACT16((oac_val32)v2max); + maxhi = EXTRACT16((oac_val32)v2max>>16); + maxlo = MAX16(MAX16(maxlo, maxhi), ABS16(x[len - 1])); + break; + case 2: + x01 = __builtin_mips_absq_s_ph(*x2); + __builtin_mips_cmp_lt_ph(v2max, x01); + v2max = __builtin_mips_pick_ph(x01, v2max); + maxlo = EXTRACT16((oac_val32)v2max); + maxhi = EXTRACT16((oac_val32)v2max>>16); + maxlo = MAX16(maxlo, maxhi); + break; + case 1: + maxlo = EXTRACT16((oac_val32)v2max); + maxhi = EXTRACT16((oac_val32)v2max>>16); + return MAX16(MAX16(maxlo, maxhi), ABS16(x[len - 1])); + break; + case 0: + maxlo = EXTRACT16((oac_val32)v2max); + maxhi = EXTRACT16((oac_val32)v2max>>16); + maxlo = MAX16(maxlo, maxhi); + break; + default: + __builtin_unreachable(); + } + /* C version might return 0x8000, this one can't + * because abs is saturated here. Since result + * used only for determine dynamic range + * in ilog2-like context it's worth to add 1 + * for proper magnitude whether saturated + */ + return (oac_val32)maxlo + 1; } #elif __mips == 32 -#undef MULT16_32_Q16 -#define MULT16_32_Q16(a,b) ((opus_val32)SHR((opus_int64)(SHL32((a), 16))*(b),32)) +# undef MULT16_32_Q16 +# define MULT16_32_Q16(a, b) ((oac_val32)SHR((oac_int64)(SHL32((a), 16))*(b), 32)) #endif diff --git a/celt/mips/kiss_fft_mipsr1.h b/celt/mips/kiss_fft_mipsr1.h deleted file mode 100644 index 215dd0d3c..000000000 --- a/celt/mips/kiss_fft_mipsr1.h +++ /dev/null @@ -1,271 +0,0 @@ -/*Copyright (c) 2013, Xiph.Org Foundation and contributors. - - All rights reserved. - - 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.*/ - -#ifndef KISS_FFT_MIPSR1_H -#define KISS_FFT_MIPSR1_H - -#if !defined(KISS_FFT_GUTS_H) -#error "This file should only be included from _kiss_fft_guts.h" -#endif - -#ifdef FIXED_POINT - -#if __mips == 32 && defined (__mips_dsp) - -static inline int S_MUL_ADD(int a, int b, int c, int d) { - long long acc = __builtin_mips_mult(a, b); - acc = __builtin_mips_madd(acc, c, d); - return __builtin_mips_extr_w(acc, 15); -} - -static inline int S_MUL_SUB(int a, int b, int c, int d) { - long long acc = __builtin_mips_mult(a, b); - acc = __builtin_mips_msub(acc, c, d); - return __builtin_mips_extr_w(acc, 15); -} - -#undef C_MUL -# define C_MUL(m,a,b) (m=C_MUL_fun(a,b)) -static inline kiss_fft_cpx C_MUL_fun(kiss_fft_cpx a, kiss_twiddle_cpx b) { - kiss_fft_cpx m; - - long long acc1 = __builtin_mips_mult((int)a.r, (int)b.r); - long long acc2 = __builtin_mips_mult((int)a.r, (int)b.i); - acc1 = __builtin_mips_msub(acc1, (int)a.i, (int)b.i); - acc2 = __builtin_mips_madd(acc2, (int)a.i, (int)b.r); - m.r = __builtin_mips_extr_w(acc1, 15); - m.i = __builtin_mips_extr_w(acc2, 15); - return m; -} -#undef C_MULC -# define C_MULC(m,a,b) (m=C_MULC_fun(a,b)) -static inline kiss_fft_cpx C_MULC_fun(kiss_fft_cpx a, kiss_twiddle_cpx b) { - kiss_fft_cpx m; - - long long acc1 = __builtin_mips_mult((int)a.r, (int)b.r); - long long acc2 = __builtin_mips_mult((int)a.i, (int)b.r); - acc1 = __builtin_mips_madd(acc1, (int)a.i, (int)b.i); - acc2 = __builtin_mips_msub(acc2, (int)a.r, (int)b.i); - m.r = __builtin_mips_extr_w(acc1, 15); - m.i = __builtin_mips_extr_w(acc2, 15); - return m; -} - -#define OVERRIDE_kf_bfly5 - -#elif __mips == 32 && defined(__mips_isa_rev) && __mips_isa_rev < 6 - -static inline int S_MUL_ADD(int a, int b, int c, int d) { - long long acc; - - asm volatile ( - "mult %[a], %[b] \n" - "madd %[c], %[d] \n" - : [acc] "=x"(acc) - : [a] "r"(a), [b] "r"(b), [c] "r"(c), [d] "r"(d) - : - ); - return (int)(acc >> 15); -} - -static inline int S_MUL_SUB(int a, int b, int c, int d) { - long long acc; - - asm volatile ( - "mult %[a], %[b] \n" - "msub %[c], %[d] \n" - : [acc] "=x"(acc) - : [a] "r"(a), [b] "r"(b), [c] "r"(c), [d] "r"(d) - : - ); - return (int)(acc >> 15); -} - -#undef C_MUL -# define C_MUL(m,a,b) (m=C_MUL_fun(a,b)) -static inline kiss_fft_cpx C_MUL_fun(kiss_fft_cpx a, kiss_twiddle_cpx b) { - kiss_fft_cpx m; - - m.r = S_MUL_SUB(a.r, b.r, a.i, b.i); - m.i = S_MUL_ADD(a.r, b.i, a.i, b.r); - - return m; -} - -#undef C_MULC -# define C_MULC(m,a,b) (m=C_MULC_fun(a,b)) -static inline kiss_fft_cpx C_MULC_fun(kiss_fft_cpx a, kiss_twiddle_cpx b) { - kiss_fft_cpx m; - - m.r = S_MUL_ADD(a.r, b.r, a.i, b.i); - m.i = S_MUL_SUB(a.i, b.r, a.r, b.i); - - return m; -} - -#define OVERRIDE_kf_bfly5 - -#endif - -#endif /* FIXED_POINT */ - -#if defined(OVERRIDE_kf_bfly5) - -static void kf_bfly5( - kiss_fft_cpx * Fout, - const size_t fstride, - const kiss_fft_state *st, - int m, - int N, - int mm - ) -{ - kiss_fft_cpx *Fout0,*Fout1,*Fout2,*Fout3,*Fout4; - int i, u; - kiss_fft_cpx scratch[13]; - - const kiss_twiddle_cpx *tw; - kiss_twiddle_cpx ya,yb; - kiss_fft_cpx * Fout_beg = Fout; - -#ifdef FIXED_POINT - ya.r = 10126; - ya.i = -31164; - yb.r = -26510; - yb.i = -19261; -#else - ya = st->twiddles[fstride*m]; - yb = st->twiddles[fstride*2*m]; -#endif - - tw=st->twiddles; - - for (i=0;ir += scratch[7].r + scratch[8].r; - Fout0->i += scratch[7].i + scratch[8].i; - scratch[5].r = scratch[0].r + S_MUL_ADD(scratch[7].r,ya.r,scratch[8].r,yb.r); - scratch[5].i = scratch[0].i + S_MUL_ADD(scratch[7].i,ya.r,scratch[8].i,yb.r); - - scratch[6].r = S_MUL_ADD(scratch[10].i,ya.i,scratch[9].i,yb.i); - scratch[6].i = -S_MUL_ADD(scratch[10].r,ya.i,scratch[9].r,yb.i); - - C_SUB(*Fout1,scratch[5],scratch[6]); - C_ADD(*Fout4,scratch[5],scratch[6]); - - scratch[11].r = scratch[0].r + S_MUL_ADD(scratch[7].r,yb.r,scratch[8].r,ya.r); - scratch[11].i = scratch[0].i + S_MUL_ADD(scratch[7].i,yb.r,scratch[8].i,ya.r); - - scratch[12].r = S_MUL_SUB(scratch[9].i,ya.i,scratch[10].i,yb.i); - scratch[12].i = S_MUL_SUB(scratch[10].r,yb.i,scratch[9].r,ya.i); - - C_ADD(*Fout2,scratch[11],scratch[12]); - C_SUB(*Fout3,scratch[11],scratch[12]); - - ++Fout0;++Fout1;++Fout2;++Fout3;++Fout4; - } - } -} - -#endif /* defined(OVERRIDE_kf_bfly5) */ - -#define OVERRIDE_fft_downshift -/* Just unroll tight loop, should be ok for any mips */ -static void fft_downshift(kiss_fft_cpx *x, int N, int *total, int step) { - int shift; - shift = IMIN(step, *total); - *total -= shift; - if (shift == 1) { - int i; - for (i = 0; i < N - 1; i += 2) { - x[i].r = SHR32(x[i].r, 1); - x[i].i = SHR32(x[i].i, 1); - x[i+1].r = SHR32(x[i+1].r, 1); - x[i+1].i = SHR32(x[i+1].i, 1); - } - if (N & 1) { - x[i].r = SHR32(x[i].r, 1); - x[i].i = SHR32(x[i].i, 1); - } - } else if (shift > 0) { - int i; - for (i = 0; i < N - 3; i += 4) { - x[i].r = PSHR32(x[i].r, shift); - x[i].i = PSHR32(x[i].i, shift); - x[i+1].r = PSHR32(x[i+1].r, shift); - x[i+1].i = PSHR32(x[i+1].i, shift); - x[i+2].r = PSHR32(x[i+2].r, shift); - x[i+2].i = PSHR32(x[i+2].i, shift); - x[i+3].r = PSHR32(x[i+3].r, shift); - x[i+3].i = PSHR32(x[i+3].i, shift); - } - switch (N & 3) { - case 3: - x[i].r = PSHR32(x[i].r, shift); - x[i].i = PSHR32(x[i].i, shift); - x[i+1].r = PSHR32(x[i+1].r, shift); - x[i+1].i = PSHR32(x[i+1].i, shift); - x[i+2].r = PSHR32(x[i+2].r, shift); - x[i+2].i = PSHR32(x[i+2].i, shift); - break; - case 2: - x[i].r = PSHR32(x[i].r, shift); - x[i].i = PSHR32(x[i].i, shift); - x[i+1].r = PSHR32(x[i+1].r, shift); - x[i+1].i = PSHR32(x[i+1].i, shift); - break; - case 1: - x[i].r = PSHR32(x[i].r, shift); - x[i].i = PSHR32(x[i].i, shift); - break; - case 0: - break; - } - } -} - -#endif /* KISS_FFT_MIPSR1_H */ diff --git a/celt/mips/mdct_mipsr1.h b/celt/mips/mdct_mipsr1.h deleted file mode 100644 index bc349cc25..000000000 --- a/celt/mips/mdct_mipsr1.h +++ /dev/null @@ -1,383 +0,0 @@ -/* Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2008 Xiph.Org Foundation - Written by Jean-Marc Valin */ -/* - 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. -*/ - -/* This is a simple MDCT implementation that uses a N/4 complex FFT - to do most of the work. It should be relatively straightforward to - plug in pretty much and FFT here. - - This replaces the Vorbis FFT (and uses the exact same API), which - was a bit too messy and that was ending up duplicating code - (might as well use the same FFT everywhere). - - The algorithm is similar to (and inspired from) Fabrice Bellard's - MDCT implementation in FFMPEG, but has differences in signs, ordering - and scaling in many places. -*/ -#ifndef MDCT_MIPSR1_H__ -#define MDCT_MIPSR1_H__ - -#ifndef SKIP_CONFIG_H -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#endif - -#include "mdct.h" -#include "kiss_fft.h" -#include "_kiss_fft_guts.h" -#include -#include "os_support.h" -#include "mathops.h" -#include "stack_alloc.h" - -#if defined (__mips_dsp) -static inline int S_MUL_ADD_PSR(int a, int b, int c, int d, int shift) { - long long acc = __builtin_mips_mult(a, b); - acc = __builtin_mips_madd(acc, c, d); - return __builtin_mips_extr_w(acc, 15+shift); -} - -static inline int S_MUL_SUB_PSR(int a, int b, int c, int d, int shift) { - long long acc = __builtin_mips_mult(a, b); - acc = __builtin_mips_msub(acc, c, d); - return __builtin_mips_extr_w(acc, 15+shift); -} - -#define OVERRIDE_clt_mdct_forward -#define OVERRIDE_clt_mdct_backward - -#elif defined(__mips_isa_rev) && __mips_isa_rev < 6 - -static inline int S_MUL_ADD_PSR(int a, int b, int c, int d, int shift) { - long long acc; - - asm volatile ( - "mult %[a], %[b] \n" - "madd %[c], %[d] \n" - : [acc] "=x"(acc) - : [a] "r"(a), [b] "r"(b), [c] "r"(c), [d] "r"(d) - : - ); - return (int)(acc >> (15 + shift)); -} - -static inline int S_MUL_SUB_PSR(int a, int b, int c, int d, int shift) { - long long acc; - - asm volatile ( - "mult %[a], %[b] \n" - "msub %[c], %[d] \n" - : [acc] "=x"(acc) - : [a] "r"(a), [b] "r"(b), [c] "r"(c), [d] "r"(d) - : - ); - return (int)(acc >> (15 + shift)); -} - -#define OVERRIDE_clt_mdct_forward -#define OVERRIDE_clt_mdct_backward - -#endif - -#if defined (OVERRIDE_clt_mdct_forward) - -/* Forward MDCT trashes the input array */ -void clt_mdct_forward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out, - const celt_coef *window, int overlap, int shift, int stride, int arch) -{ - int i; - int N, N2, N4; - VARDECL(kiss_fft_scalar, f); - VARDECL(kiss_fft_cpx, f2); - const kiss_fft_state *st = l->kfft[shift]; - const kiss_twiddle_scalar *trig; - celt_coef scale; -#ifdef FIXED_POINT - /* Allows us to scale with MULT16_32_Q16(), which is faster than - MULT16_32_Q15() on ARM. */ - int scale_shift = st->scale_shift-1; - int headroom; -#endif - SAVE_STACK; - (void)arch; - scale = st->scale; - - N = l->n; - trig = l->trig; - for (i=0;i>= 1; - trig += N; - } - N2 = N>>1; - N4 = N>>2; - - ALLOC(f, N2, kiss_fft_scalar); - ALLOC(f2, N4, kiss_fft_cpx); - - /* Consider the input to be composed of four blocks: [a, b, c, d] */ - /* Window, shuffle, fold */ - { - /* Temp pointers to make it really clear to the compiler what we're doing */ - const kiss_fft_scalar * OPUS_RESTRICT xp1 = in+(overlap>>1); - const kiss_fft_scalar * OPUS_RESTRICT xp2 = in+N2-1+(overlap>>1); - kiss_fft_scalar * OPUS_RESTRICT yp = f; - const celt_coef * OPUS_RESTRICT wp1 = window+(overlap>>1); - const celt_coef * OPUS_RESTRICT wp2 = window+(overlap>>1)-1; - for(i=0;i<((overlap+3)>>2);i++) - { - /* Real part arranged as -d-cR, Imag part arranged as -b+aR*/ - *yp++ = S_MUL_ADD(*wp2, xp1[N2],*wp1,*xp2); - *yp++ = S_MUL_SUB(*wp1, *xp1,*wp2, xp2[-N2]); - xp1+=2; - xp2-=2; - wp1+=2; - wp2-=2; - } - wp1 = window; - wp2 = window+overlap-1; - for(;i>2);i++) - { - /* Real part arranged as a-bR, Imag part arranged as -c-dR */ - *yp++ = *xp2; - *yp++ = *xp1; - xp1+=2; - xp2-=2; - } - for(;ibitrev[i]] = yc; - } -#ifdef FIXED_POINT - headroom = IMAX(0, IMIN(scale_shift, 28-celt_ilog2(maxval))); -#endif - } - - /* N/4 complex FFT, does not downscale anymore */ - opus_fft_impl(st, f2 ARG_FIXED(scale_shift-headroom)); - - /* Post-rotate */ - { - /* Temp pointers to make it really clear to the compiler what we're doing */ - const kiss_fft_cpx * OPUS_RESTRICT fp = f2; - kiss_fft_scalar * OPUS_RESTRICT yp1 = out; - kiss_fft_scalar * OPUS_RESTRICT yp2 = out+stride*(N2-1); - const kiss_twiddle_scalar *t = &trig[0]; - /* Temp pointers to make it really clear to the compiler what we're doing */ - for(i=0;ii,t1 , fp->r,t0, headroom); - yi = S_MUL_ADD_PSR(fp->r,t1 , fp->i,t0, headroom); - *yp1 = yr; - *yp2 = yi; - fp++; - yp1 += 2*stride; - yp2 -= 2*stride; - } - } - RESTORE_STACK; -} - -#endif /* OVERRIDE_clt_mdct_forward */ - -#if defined(OVERRIDE_clt_mdct_backward) - -void clt_mdct_backward(const mdct_lookup *l, kiss_fft_scalar *in, kiss_fft_scalar * OPUS_RESTRICT out, - const celt_coef * OPUS_RESTRICT window, int overlap, int shift, int stride, int arch) -{ - int i; - int N, N2, N4; - const kiss_twiddle_scalar *trig; -#ifdef FIXED_POINT - int pre_shift, post_shift, fft_shift; -#endif - (void) arch; - - N = l->n; - trig = l->trig; - for (i=0;i>= 1; - trig += N; - } - N2 = N>>1; - N4 = N>>2; - -#ifdef FIXED_POINT - { - opus_val32 sumval=N2; - opus_val32 maxval=0; - for (i=0;i>1); - const kiss_twiddle_scalar * OPUS_RESTRICT t = &trig[0]; - const opus_int16 * OPUS_RESTRICT bitrev = l->kfft[shift]->bitrev; - for(i=0;ikfft[shift], (kiss_fft_cpx*)(out+(overlap>>1)) ARG_FIXED(fft_shift)); - - /* Post-rotate and de-shuffle from both ends of the buffer at once to make - it in-place. */ - { - kiss_fft_scalar * yp0 = out+(overlap>>1); - kiss_fft_scalar * yp1 = out+(overlap>>1)+N2-2; - const kiss_twiddle_scalar *t = &trig[0]; - /* Loop to (N4+1)>>1 to handle odd N4. When N4 is odd, the - middle pair will be computed twice. */ - for(i=0;i<(N4+1)>>1;i++) - { - kiss_fft_scalar re, im, yr, yi; - kiss_twiddle_scalar t0, t1; - /* We swap real and imag because we're using an FFT instead of an IFFT. */ - re = yp0[1]; - im = yp0[0]; - t0 = t[i]; - t1 = t[N4+i]; - /* We'd scale up by 2 here, but instead it's done when mixing the windows */ - yr = S_MUL_ADD_PSR(re,t0 , im,t1, post_shift); - yi = S_MUL_SUB_PSR(re,t1 , im,t0, post_shift); - /* We swap real and imag because we're using an FFT instead of an IFFT. */ - re = yp1[1]; - im = yp1[0]; - yp0[0] = yr; - yp1[1] = yi; - - t0 = t[(N4-i-1)]; - t1 = t[(N2-i-1)]; - /* We'd scale up by 2 here, but instead it's done when mixing the windows */ - yr = S_MUL_ADD_PSR(re,t0,im,t1, post_shift); - yi = S_MUL_SUB_PSR(re,t1,im,t0, post_shift); - yp1[0] = yr; - yp0[1] = yi; - yp0 += 2; - yp1 -= 2; - } - } - - /* Mirror on both sides for TDAC */ - { - kiss_fft_scalar * OPUS_RESTRICT xp1 = out+overlap-1; - kiss_fft_scalar * OPUS_RESTRICT yp1 = out; - const celt_coef * OPUS_RESTRICT wp1 = window; - const celt_coef * OPUS_RESTRICT wp2 = window+overlap-1; - - for(i = 0; i < overlap/2; i++) - { - kiss_fft_scalar x1, x2; - x1 = *xp1; - x2 = *yp1; - *yp1++ = S_MUL_SUB(x2, *wp2, x1, *wp1); - *xp1-- = S_MUL_ADD(x2, *wp1, x1, *wp2); - wp1++; - wp2--; - } - } -} - -#endif /* OVERRIDE_clt_mdct_backward */ - -#endif /* MDCT_MIPSR1_H__ */ diff --git a/celt/mips/pitch_mipsr1.h b/celt/mips/pitch_mipsr1.h index 9b73a126b..2049a845a 100644 --- a/celt/mips/pitch_mipsr1.h +++ b/celt/mips/pitch_mipsr1.h @@ -29,7 +29,7 @@ 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. -*/ + */ #ifndef PITCH_MIPSR1_H #define PITCH_MIPSR1_H @@ -38,225 +38,218 @@ #if defined (__mips_dsp) && __mips == 32 -#define accumulator_t opus_int64 -#define MIPS_MAC(acc,a,b) \ - __builtin_mips_madd((acc), (int)(a), (int)(b)) +# define accumulator_t oac_int64 +# define MIPS_MAC(acc, a, b) \ + __builtin_mips_madd((acc), (int)(a), (int)(b)) -#define MIPS_MAC16x16_2X(acc,a2x,b2x) \ - __builtin_mips_dpaq_s_w_ph((acc), (a2x), (b2x)) +# define MIPS_MAC16x16_2X(acc, a2x, b2x) \ + __builtin_mips_dpaq_s_w_ph((acc), (a2x), (b2x)) -#define OVERRIDE_CELT_INNER_PROD -#define OVERRIDE_DUAL_INNER_PROD -#define OVERRIDE_XCORR_KERNEL +# define OVERRIDE_CELT_INNER_PROD +# define OVERRIDE_DUAL_INNER_PROD +# define OVERRIDE_XCORR_KERNEL #else /* any other MIPS */ /* using madd is slower due to single accumulator */ -#define accumulator_t opus_int32 -#define MIPS_MAC MAC16_16 +# define accumulator_t oac_int32 +# define MIPS_MAC MAC16_16 -#define OVERRIDE_CELT_INNER_PROD -#define OVERRIDE_DUAL_INNER_PROD -#define OVERRIDE_XCORR_KERNEL +# define OVERRIDE_CELT_INNER_PROD +# define OVERRIDE_DUAL_INNER_PROD +# define OVERRIDE_XCORR_KERNEL #endif /* any other MIPS */ #if defined(OVERRIDE_CELT_INNER_PROD) -static OPUS_INLINE opus_val32 celt_inner_prod(const opus_val16 *x, - const opus_val16 *y, int N, int arch) -{ - int j; - accumulator_t acc = 0; - -#if defined (MIPS_MAC16x16_2X) - const v2i16 *x2x; - const v2i16 *y2x; - int loops; - - /* misaligned */ - if (((long)x | (long)y) & 3) - goto fallback; - - x2x = __builtin_assume_aligned(x, 4); - y2x = __builtin_assume_aligned(y, 4); - loops = N / 8; - for (j = 0; j < loops; j++) - { - acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); - acc = MIPS_MAC16x16_2X(acc, x2x[1], y2x[1]); - acc = MIPS_MAC16x16_2X(acc, x2x[2], y2x[2]); - acc = MIPS_MAC16x16_2X(acc, x2x[3], y2x[3]); - x2x += 4; y2x += 4; - } - - switch (N & 7) { - case 7: - acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); - acc = MIPS_MAC16x16_2X(acc, x2x[1], y2x[1]); - acc = MIPS_MAC16x16_2X(acc, x2x[2], y2x[2]); - acc = MIPS_MAC(acc, x[N-1], y[N-1]); - break; - case 6: - acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); - acc = MIPS_MAC16x16_2X(acc, x2x[1], y2x[1]); - acc = MIPS_MAC16x16_2X(acc, x2x[2], y2x[2]); - break; - case 5: - acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); - acc = MIPS_MAC16x16_2X(acc, x2x[1], y2x[1]); - acc = MIPS_MAC(acc, x[N-1], y[N-1]); - break; - case 4: - acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); - acc = MIPS_MAC16x16_2X(acc, x2x[1], y2x[1]); - break; - case 3: - acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); - acc = MIPS_MAC(acc, x[N-1], y[N-1]); - break; - case 2: - acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); - break; - case 1: - acc = MIPS_MAC(acc, x[N-1], y[N-1]); - break; - case 0: - break; - } - return __builtin_mips_extr_w(acc, 1); +static OAC_INLINE oac_val32 oaci_celt_inner_prod(const oac_val16 *x, + const oac_val16 *y, int N, int arch) { + int j; + accumulator_t acc = 0; + +# if defined (MIPS_MAC16x16_2X) + const v2i16 *x2x; + const v2i16 *y2x; + int loops; + + /* misaligned */ + if (((long)x|(long)y)&3) + goto fallback; + + x2x = __builtin_assume_aligned(x, 4); + y2x = __builtin_assume_aligned(y, 4); + loops = N/8; + for (j = 0; j < loops; j++) { + acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); + acc = MIPS_MAC16x16_2X(acc, x2x[1], y2x[1]); + acc = MIPS_MAC16x16_2X(acc, x2x[2], y2x[2]); + acc = MIPS_MAC16x16_2X(acc, x2x[3], y2x[3]); + x2x += 4; y2x += 4; + } + + switch (N&7) { + case 7: + acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); + acc = MIPS_MAC16x16_2X(acc, x2x[1], y2x[1]); + acc = MIPS_MAC16x16_2X(acc, x2x[2], y2x[2]); + acc = MIPS_MAC(acc, x[N - 1], y[N - 1]); + break; + case 6: + acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); + acc = MIPS_MAC16x16_2X(acc, x2x[1], y2x[1]); + acc = MIPS_MAC16x16_2X(acc, x2x[2], y2x[2]); + break; + case 5: + acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); + acc = MIPS_MAC16x16_2X(acc, x2x[1], y2x[1]); + acc = MIPS_MAC(acc, x[N - 1], y[N - 1]); + break; + case 4: + acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); + acc = MIPS_MAC16x16_2X(acc, x2x[1], y2x[1]); + break; + case 3: + acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); + acc = MIPS_MAC(acc, x[N - 1], y[N - 1]); + break; + case 2: + acc = MIPS_MAC16x16_2X(acc, x2x[0], y2x[0]); + break; + case 1: + acc = MIPS_MAC(acc, x[N - 1], y[N - 1]); + break; + case 0: + break; + } + return __builtin_mips_extr_w(acc, 1); fallback: -#endif - for (j = 0; j < N - 3; j += 4) - { - acc = MIPS_MAC(acc, x[j], y[j]); - acc = MIPS_MAC(acc, x[j+1], y[j+1]); - acc = MIPS_MAC(acc, x[j+2], y[j+2]); - acc = MIPS_MAC(acc, x[j+3], y[j+3]); - } - - switch (N & 3) { - case 3: - acc = MIPS_MAC(acc, x[j], y[j]); - acc = MIPS_MAC(acc, x[j+1], y[j+1]); - acc = MIPS_MAC(acc, x[j+2], y[j+2]); - break; - case 2: - acc = MIPS_MAC(acc, x[j], y[j]); - acc = MIPS_MAC(acc, x[j+1], y[j+1]); - break; - case 1: - acc = MIPS_MAC(acc, x[j], y[j]); - break; - case 0: - break; - } - - (void)arch; - - return (opus_val32)acc; +# endif + for (j = 0; j < N - 3; j += 4) { + acc = MIPS_MAC(acc, x[j], y[j]); + acc = MIPS_MAC(acc, x[j + 1], y[j + 1]); + acc = MIPS_MAC(acc, x[j + 2], y[j + 2]); + acc = MIPS_MAC(acc, x[j + 3], y[j + 3]); + } + + switch (N&3) { + case 3: + acc = MIPS_MAC(acc, x[j], y[j]); + acc = MIPS_MAC(acc, x[j + 1], y[j + 1]); + acc = MIPS_MAC(acc, x[j + 2], y[j + 2]); + break; + case 2: + acc = MIPS_MAC(acc, x[j], y[j]); + acc = MIPS_MAC(acc, x[j + 1], y[j + 1]); + break; + case 1: + acc = MIPS_MAC(acc, x[j], y[j]); + break; + case 0: + break; + } + + (void)arch; + + return (oac_val32)acc; } #endif /* OVERRIDE_CELT_INNER_PROD */ #if defined(OVERRIDE_DUAL_INNER_PROD) -static inline void dual_inner_prod(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2, int arch) -{ - int j; - accumulator_t acc1 = 0; - accumulator_t acc2 = 0; - -#if defined (MIPS_MAC16x16_2X) - const v2i16 *x2x; - const v2i16 *y01_2x; - const v2i16 *y02_2x; - - /* misaligned */ - if (((long)x | (long)y01 | (long)y02) & 3) - goto fallback; - - x2x = __builtin_assume_aligned(x, 4); - y01_2x = __builtin_assume_aligned(y01, 4); - y02_2x = __builtin_assume_aligned(y02, 4); - N /= 2; - - for (j = 0; j < N - 3; j += 4) - { - acc1 = MIPS_MAC16x16_2X(acc1, x2x[j], y01_2x[j]); - acc2 = MIPS_MAC16x16_2X(acc2, x2x[j], y02_2x[j]); - acc1 = MIPS_MAC16x16_2X(acc1, x2x[j+1], y01_2x[j+1]); - acc2 = MIPS_MAC16x16_2X(acc2, x2x[j+1], y02_2x[j+1]); - acc1 = MIPS_MAC16x16_2X(acc1, x2x[j+2], y01_2x[j+2]); - acc2 = MIPS_MAC16x16_2X(acc2, x2x[j+2], y02_2x[j+2]); - acc1 = MIPS_MAC16x16_2X(acc1, x2x[j+3], y01_2x[j+3]); - acc2 = MIPS_MAC16x16_2X(acc2, x2x[j+3], y02_2x[j+3]); - } - - switch (N & 3) { - case 3: - acc1 = MIPS_MAC16x16_2X(acc1, x2x[j], y01_2x[j]); - acc2 = MIPS_MAC16x16_2X(acc2, x2x[j], y02_2x[j]); - acc1 = MIPS_MAC16x16_2X(acc1, x2x[j+1], y01_2x[j+1]); - acc2 = MIPS_MAC16x16_2X(acc2, x2x[j+1], y02_2x[j+1]); - acc1 = MIPS_MAC16x16_2X(acc1, x2x[j+2], y01_2x[j+2]); - acc2 = MIPS_MAC16x16_2X(acc2, x2x[j+2], y02_2x[j+2]); - break; - case 2: - acc1 = MIPS_MAC16x16_2X(acc1, x2x[j], y01_2x[j]); - acc2 = MIPS_MAC16x16_2X(acc2, x2x[j], y02_2x[j]); - acc1 = MIPS_MAC16x16_2X(acc1, x2x[j+1], y01_2x[j+1]); - acc2 = MIPS_MAC16x16_2X(acc2, x2x[j+1], y02_2x[j+1]); - break; - case 1: - acc1 = MIPS_MAC16x16_2X(acc1, x2x[j], y01_2x[j]); - acc2 = MIPS_MAC16x16_2X(acc2, x2x[j], y02_2x[j]); - break; - case 0: - break; - } - - *xy1 = __builtin_mips_extr_w(acc1, 1); - *xy2 = __builtin_mips_extr_w(acc2, 1); - return; +static inline void oaci_dual_inner_prod(const oac_val16 *x, const oac_val16 *y01, const oac_val16 *y02, + int N, oac_val32 *xy1, oac_val32 *xy2, int arch) { + int j; + accumulator_t acc1 = 0; + accumulator_t acc2 = 0; + +# if defined (MIPS_MAC16x16_2X) + const v2i16 *x2x; + const v2i16 *y01_2x; + const v2i16 *y02_2x; + + /* misaligned */ + if (((long)x|(long)y01|(long)y02)&3) + goto fallback; + + x2x = __builtin_assume_aligned(x, 4); + y01_2x = __builtin_assume_aligned(y01, 4); + y02_2x = __builtin_assume_aligned(y02, 4); + N /= 2; + + for (j = 0; j < N - 3; j += 4) { + acc1 = MIPS_MAC16x16_2X(acc1, x2x[j], y01_2x[j]); + acc2 = MIPS_MAC16x16_2X(acc2, x2x[j], y02_2x[j]); + acc1 = MIPS_MAC16x16_2X(acc1, x2x[j + 1], y01_2x[j + 1]); + acc2 = MIPS_MAC16x16_2X(acc2, x2x[j + 1], y02_2x[j + 1]); + acc1 = MIPS_MAC16x16_2X(acc1, x2x[j + 2], y01_2x[j + 2]); + acc2 = MIPS_MAC16x16_2X(acc2, x2x[j + 2], y02_2x[j + 2]); + acc1 = MIPS_MAC16x16_2X(acc1, x2x[j + 3], y01_2x[j + 3]); + acc2 = MIPS_MAC16x16_2X(acc2, x2x[j + 3], y02_2x[j + 3]); + } + + switch (N&3) { + case 3: + acc1 = MIPS_MAC16x16_2X(acc1, x2x[j], y01_2x[j]); + acc2 = MIPS_MAC16x16_2X(acc2, x2x[j], y02_2x[j]); + acc1 = MIPS_MAC16x16_2X(acc1, x2x[j + 1], y01_2x[j + 1]); + acc2 = MIPS_MAC16x16_2X(acc2, x2x[j + 1], y02_2x[j + 1]); + acc1 = MIPS_MAC16x16_2X(acc1, x2x[j + 2], y01_2x[j + 2]); + acc2 = MIPS_MAC16x16_2X(acc2, x2x[j + 2], y02_2x[j + 2]); + break; + case 2: + acc1 = MIPS_MAC16x16_2X(acc1, x2x[j], y01_2x[j]); + acc2 = MIPS_MAC16x16_2X(acc2, x2x[j], y02_2x[j]); + acc1 = MIPS_MAC16x16_2X(acc1, x2x[j + 1], y01_2x[j + 1]); + acc2 = MIPS_MAC16x16_2X(acc2, x2x[j + 1], y02_2x[j + 1]); + break; + case 1: + acc1 = MIPS_MAC16x16_2X(acc1, x2x[j], y01_2x[j]); + acc2 = MIPS_MAC16x16_2X(acc2, x2x[j], y02_2x[j]); + break; + case 0: + break; + } + + *xy1 = __builtin_mips_extr_w(acc1, 1); + *xy2 = __builtin_mips_extr_w(acc2, 1); + return; fallback: -#endif - /* Compute the norm of X+Y and X-Y as |X|^2 + |Y|^2 +/- sum(xy) */ - for (j = 0; j < N - 3; j += 4) - { - acc1 = MIPS_MAC(acc1, x[j], y01[j]); - acc2 = MIPS_MAC(acc2, x[j], y02[j]); - acc1 = MIPS_MAC(acc1, x[j+1], y01[j+1]); - acc2 = MIPS_MAC(acc2, x[j+1], y02[j+1]); - acc1 = MIPS_MAC(acc1, x[j+2], y01[j+2]); - acc2 = MIPS_MAC(acc2, x[j+2], y02[j+2]); - acc1 = MIPS_MAC(acc1, x[j+3], y01[j+3]); - acc2 = MIPS_MAC(acc2, x[j+3], y02[j+3]); - } - - if (j < N) { - acc1 = MIPS_MAC(acc1, x[j], y01[j]); - acc2 = MIPS_MAC(acc2, x[j], y02[j]); - acc1 = MIPS_MAC(acc1, x[j+1], y01[j+1]); - acc2 = MIPS_MAC(acc2, x[j+1], y02[j+1]); - } - - (void)arch; - - *xy1 = (opus_val32)acc1; - *xy2 = (opus_val32)acc2; +# endif + /* Compute the norm of X+Y and X-Y as |X|^2 + |Y|^2 +/- sum(xy) */ + for (j = 0; j < N - 3; j += 4) { + acc1 = MIPS_MAC(acc1, x[j], y01[j]); + acc2 = MIPS_MAC(acc2, x[j], y02[j]); + acc1 = MIPS_MAC(acc1, x[j + 1], y01[j + 1]); + acc2 = MIPS_MAC(acc2, x[j + 1], y02[j + 1]); + acc1 = MIPS_MAC(acc1, x[j + 2], y01[j + 2]); + acc2 = MIPS_MAC(acc2, x[j + 2], y02[j + 2]); + acc1 = MIPS_MAC(acc1, x[j + 3], y01[j + 3]); + acc2 = MIPS_MAC(acc2, x[j + 3], y02[j + 3]); + } + + if (j < N) { + acc1 = MIPS_MAC(acc1, x[j], y01[j]); + acc2 = MIPS_MAC(acc2, x[j], y02[j]); + acc1 = MIPS_MAC(acc1, x[j + 1], y01[j + 1]); + acc2 = MIPS_MAC(acc2, x[j + 1], y02[j + 1]); + } + + (void)arch; + + *xy1 = (oac_val32)acc1; + *xy2 = (oac_val32)acc2; } #endif /* OVERRIDE_DUAL_INNER_PROD */ #if defined(OVERRIDE_XCORR_KERNEL) -static inline void xcorr_kernel_mips(const opus_val16 * x, - const opus_val16 * y, opus_val32 sum[4], int len) -{ - int j; - opus_val16 y_0, y_1, y_2, y_3; +static inline void oaci_xcorr_kernel_mips(const oac_val16 * x, + const oac_val16 * y, oac_val32 sum[4], int len) { + int j; + oac_val16 y_0, y_1, y_2, y_3; accumulator_t sum_0, sum_1, sum_2, sum_3; sum_0 = (accumulator_t)sum[0]; @@ -264,95 +257,94 @@ static inline void xcorr_kernel_mips(const opus_val16 * x, sum_2 = (accumulator_t)sum[2]; sum_3 = (accumulator_t)sum[3]; - y_0=*y++; - y_1=*y++; - y_2=*y++; - for (j=0;j= Fs) - break; - - /* Find where the linear part ends (i.e. where the spacing is more than min_width */ - for (lin=0;lin= res) - break; - - low = (bark_freq[lin]+res/2)/res; - high = nBark-lin; - *nbEBands = low+high; - eBands = opus_alloc(sizeof(opus_int16)*(*nbEBands+2)); - - if (eBands==NULL) - return NULL; - - /* Linear spacing (min_width) */ - for (i=0;i0) - offset = eBands[low-1]*res - bark_freq[lin-1]; - /* Spacing follows critical bands */ - for (i=0;i frame_size) - eBands[*nbEBands] = frame_size; - for (i=1;i<*nbEBands-1;i++) - { - if (eBands[i+1]-eBands[i] < eBands[i]-eBands[i-1]) - { - eBands[i] -= (2*eBands[i]-eBands[i-1]-eBands[i+1])/2; - } - } - /* Remove any empty bands. */ - for (i=j=0;i<*nbEBands;i++) - if(eBands[i+1]>eBands[j]) - eBands[++j]=eBands[i+1]; - *nbEBands=j; - - for (i=1;i<*nbEBands;i++) - { - /* Every band must be smaller than the last band. */ - celt_assert(eBands[i]-eBands[i-1]<=eBands[*nbEBands]-eBands[*nbEBands-1]); - /* Each band must be no larger than twice the size of the previous one. */ - celt_assert(eBands[i+1]-eBands[i]<=2*(eBands[i]-eBands[i-1])); - } - - return eBands; + 1270, 1480, 1720, 2000, 2320, + 2700, 3150, 3700, 4400, 5300, + 6400, 7700, 9500, 12000, 15500, + 20000 +}; + +static oac_int16 *oaci_compute_ebands(oac_int32 Fs, int frame_size, int res, int *nbEBands) { + oac_int16 *eBands; + int i, j, lin, low, high, nBark, offset = 0; + + /* All modes that have 2.5 ms short blocks use the same definition */ + if (Fs == 400*(oac_int32)frame_size) { + *nbEBands = sizeof(eband5ms)/sizeof(eband5ms[0]) - 1; + eBands = oac_alloc(sizeof(oac_int16)*(*nbEBands + 1)); + for (i = 0; i < *nbEBands + 1; i++) + eBands[i] = eband5ms[i]; + return eBands; + } + /* Find the number of critical bands supported by our sampling rate */ + for (nBark = 1; nBark < BARK_BANDS; nBark++) + if (bark_freq[nBark + 1]*2 >= Fs) + break; + + /* Find where the linear part ends (i.e. where the spacing is more than min_width */ + for (lin = 0; lin < nBark; lin++) + if (bark_freq[lin + 1] - bark_freq[lin] >= res) + break; + + low = (bark_freq[lin] + res/2)/res; + high = nBark - lin; + *nbEBands = low + high; + eBands = oac_alloc(sizeof(oac_int16)*(*nbEBands + 2)); + + if (eBands == NULL) + return NULL; + + /* Linear spacing (min_width) */ + for (i = 0; i < low; i++) + eBands[i] = i; + if (low > 0) + offset = eBands[low - 1]*res - bark_freq[lin - 1]; + /* Spacing follows critical bands */ + for (i = 0; i < high; i++) { + int target = bark_freq[lin + i]; + /* Round to an even value */ + eBands[i + low] = (target + offset/2 + res)/(2*res)*2; + offset = eBands[i + low]*res - target; + } + /* Enforce the minimum spacing at the boundary */ + for (i = 0; i < *nbEBands; i++) + if (eBands[i] < i) + eBands[i] = i; + /* Round to an even value */ + eBands[*nbEBands] = (bark_freq[nBark] + res)/(2*res)*2; + if (eBands[*nbEBands] > frame_size) + eBands[*nbEBands] = frame_size; + for (i = 1; i < *nbEBands - 1; i++) { + if (eBands[i + 1] - eBands[i] < eBands[i] - eBands[i - 1]) { + eBands[i] -= (2*eBands[i] - eBands[i - 1] - eBands[i + 1])/2; + } + } + /* Remove any empty bands. */ + for (i = j = 0; i < *nbEBands; i++) + if (eBands[i + 1] > eBands[j]) + eBands[++j] = eBands[i + 1]; + *nbEBands = j; + + for (i = 1; i < *nbEBands; i++) { + /* Every band must be smaller than the last band. */ + celt_assert(eBands[i] - eBands[i - 1] <= eBands[*nbEBands] - eBands[*nbEBands - 1]); + /* Each band must be no larger than twice the size of the previous one. */ + celt_assert(eBands[i + 1] - eBands[i] <= 2*(eBands[i] - eBands[i - 1])); + } + + return eBands; } -static void compute_allocation_table(CELTMode *mode) -{ - int i, j; - unsigned char *allocVectors; - int maxBands = sizeof(eband5ms)/sizeof(eband5ms[0])-1; - - 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) - { - for (i=0;inbEBands;i++) - allocVectors[i] = band_allocation[i]; - mode->allocVectors = allocVectors; - return; - } - /* If not the standard mode, interpolate */ - /* Compute per-codec-band allocation from per-critical-band matrix */ - for (i=0;inbEBands;j++) - { - int k; - for (k=0;k mode->eBands[j]*(opus_int32)mode->Fs/mode->shortMdctSize) - break; - } - if (k>maxBands-1) - allocVectors[i*mode->nbEBands+j] = band_allocation[i*maxBands + maxBands-1]; - else { - opus_int32 a0, a1; - a1 = mode->eBands[j]*(opus_int32)mode->Fs/mode->shortMdctSize - 400*(opus_int32)eband5ms[k-1]; - a0 = 400*(opus_int32)eband5ms[k] - mode->eBands[j]*(opus_int32)mode->Fs/mode->shortMdctSize; - allocVectors[i*mode->nbEBands+j] = (a0*band_allocation[i*maxBands+k-1] - + a1*band_allocation[i*maxBands+k])/(a0+a1); - } - } - } - - /*printf ("\n"); - for (i=0;inbEBands;j++) - printf ("%d ", allocVectors[i*mode->nbEBands+j]); - printf ("\n"); - } - exit(0);*/ - - mode->allocVectors = allocVectors; +static void oaci_compute_allocation_table(CELTMode *mode) { + int i, j; + unsigned char *allocVectors; + int maxBands = sizeof(eband5ms)/sizeof(eband5ms[0]) - 1; + + mode->nbAllocVectors = BITALLOC_SIZE; + allocVectors = oac_alloc(sizeof(unsigned char)*(BITALLOC_SIZE*mode->nbEBands)); + if (allocVectors == NULL) { + mode->allocVectors = NULL; + return; + } + + /* Check for standard mode */ + if (mode->Fs == 400*(oac_int32)mode->shortMdctSize) { + for (i = 0; i < BITALLOC_SIZE*mode->nbEBands; i++) + allocVectors[i] = band_allocation[i]; + mode->allocVectors = allocVectors; + return; + } + /* If not the standard mode, interpolate */ + /* Compute per-codec-band allocation from per-critical-band matrix */ + for (i = 0; i < BITALLOC_SIZE; i++) { + for (j = 0; j < mode->nbEBands; j++) { + int k; + for (k = 0; k < maxBands; k++) { + if (400*(oac_int32)eband5ms[k] > mode->eBands[j]*(oac_int32)mode->Fs/mode->shortMdctSize) + break; + } + if (k > maxBands - 1) + allocVectors[i*mode->nbEBands + j] = band_allocation[i*maxBands + maxBands - 1]; + else { + oac_int32 a0, a1; + a1 = mode->eBands[j]*(oac_int32)mode->Fs/mode->shortMdctSize - 400*(oac_int32)eband5ms[k - 1]; + a0 = 400*(oac_int32)eband5ms[k] - mode->eBands[j]*(oac_int32)mode->Fs/mode->shortMdctSize; + allocVectors[i*mode->nbEBands + j] = (a0*band_allocation[i*maxBands + k - 1] + + a1*band_allocation[i*maxBands + k])/(a0 + a1); + } + } + } + + /*printf ("\n"); + for (i=0;inbEBands;j++) + printf ("%d ", allocVectors[i*mode->nbEBands+j]); + printf ("\n"); + } + exit(0);*/ + + mode->allocVectors = allocVectors; } #endif /* CUSTOM_MODES */ -CELTMode *opus_custom_mode_create(opus_int32 Fs, int frame_size, int *error) -{ - int i; +CELTMode *oac_custom_mode_create(oac_int32 Fs, int frame_size, int *error) { + int i; #ifdef CUSTOM_MODES - CELTMode *mode=NULL; - int res; - celt_coef *window; - opus_int16 *logN; - int LM; - int arch = opus_select_arch(); - ALLOC_STACK; -#if !defined(VAR_ARRAYS) && !defined(USE_ALLOCA) - if (global_stack==NULL) - goto failure; -#endif + CELTMode *mode = NULL; + int res; + celt_coef *window; + oac_int16 *logN; + int LM; + int arch = oac_select_arch(); + ALLOC_STACK; +# if !defined(VAR_ARRAYS) && !defined(USE_ALLOCA) + if (global_stack == NULL) + goto failure; +# endif #endif #ifndef CUSTOM_MODES_ONLY - for (i=0;iFs && - (frame_size<shortMdctSize*static_mode_list[i]->nbShortMdcts) - { - if (error) - *error = OPUS_OK; - return (CELTMode*)static_mode_list[i]; - } - } - } + for (i = 0; i < TOTAL_MODES; i++) { + int j; + for (j = 0; j < 4; j++) { + if (Fs == static_mode_list[i]->Fs + && (frame_size<shortMdctSize*static_mode_list[i]->nbShortMdcts) { + if (error) + *error = OAC_OK; + return (CELTMode*)static_mode_list[i]; + } + } + } #endif /* CUSTOM_MODES_ONLY */ #ifndef CUSTOM_MODES - if (error) - *error = OPUS_BAD_ARG; - return NULL; + if (error) + *error = OAC_BAD_ARG; + return NULL; #else - /* The good thing here is that permutation of the arguments will automatically be invalid */ + /* The good thing here is that permutation of the arguments will automatically be invalid */ - if (Fs < 8000 || Fs > 96000) - { - if (error) - *error = OPUS_BAD_ARG; - return NULL; - } -#ifdef ENABLE_QEXT - if (frame_size < 40 || frame_size > 2048 || frame_size%2!=0) -#else - if (frame_size < 40 || frame_size > 1024 || frame_size%2!=0) -#endif - { - if (error) - *error = OPUS_BAD_ARG; - return NULL; - } - /* Frames of less than 1ms are not supported. */ - if ((opus_int32)frame_size*1000 < Fs) - { - if (error) - *error = OPUS_BAD_ARG; - return NULL; - } - - if ((opus_int32)frame_size*75 >= Fs && (frame_size%16)==0) - { - LM = 3; - } else if ((opus_int32)frame_size*150 >= Fs && (frame_size%8)==0) - { - LM = 2; - } else if ((opus_int32)frame_size*300 >= Fs && (frame_size%4)==0) - { - LM = 1; - } else - { - LM = 0; - } - - /* Shorts longer than 3.3ms are not supported. */ - if ((opus_int32)(frame_size>>LM)*300 > Fs) - { - if (error) - *error = OPUS_BAD_ARG; - return NULL; - } - - mode = opus_alloc(sizeof(CELTMode)); - if (mode==NULL) - goto failure; - mode->Fs = Fs; - - /* Pre/de-emphasis depends on sampling rate. The "standard" pre-emphasis - is defined as A(z) = 1 - 0.85*z^-1 at 48 kHz. Other rates should - approximate that. */ -#ifdef ENABLE_QEXT - if(Fs == 96000) /* 96 kHz */ - { - mode->preemph[0] = QCONST16(0.9230041504f, 15); - mode->preemph[1] = QCONST16(0.2200012207f, 15); - mode->preemph[2] = QCONST16(1.5128347184f, SIG_SHIFT); /* exact 1/preemph[3] */ - mode->preemph[3] = QCONST16(0.6610107422f, 13); - } else -#endif - if(Fs < 12000) /* 8 kHz */ - { - mode->preemph[0] = QCONST16(0.3500061035f, 15); - mode->preemph[1] = -QCONST16(0.1799926758f, 15); - mode->preemph[2] = QCONST16(0.2719968125f, SIG_SHIFT); /* exact 1/preemph[3] */ - mode->preemph[3] = QCONST16(3.6765136719f, 13); - } else if(Fs < 24000) /* 16 kHz */ - { - mode->preemph[0] = QCONST16(0.6000061035f, 15); - mode->preemph[1] = -QCONST16(0.1799926758f, 15); - mode->preemph[2] = QCONST16(0.4424998650f, SIG_SHIFT); /* exact 1/preemph[3] */ - mode->preemph[3] = QCONST16(2.2598876953f, 13); - } else if(Fs < 40000) /* 32 kHz */ - { - mode->preemph[0] = QCONST16(0.7799987793f, 15); - mode->preemph[1] = -QCONST16(0.1000061035f, 15); - mode->preemph[2] = QCONST16(0.7499771125f, SIG_SHIFT); /* exact 1/preemph[3] */ - mode->preemph[3] = QCONST16(1.3333740234f, 13); - } else /* 48 kHz */ - { - mode->preemph[0] = QCONST16(0.8500061035f, 15); - mode->preemph[1] = QCONST16(0.0f, 15); - mode->preemph[2] = QCONST16(1.f, SIG_SHIFT); - mode->preemph[3] = QCONST16(1.f, 13); - } - - mode->maxLM = LM; - mode->nbShortMdcts = 1<shortMdctSize = frame_size/mode->nbShortMdcts; - res = (mode->Fs+mode->shortMdctSize)/(2*mode->shortMdctSize); - - mode->eBands = compute_ebands(Fs, mode->shortMdctSize, res, &mode->nbEBands); - if (mode->eBands==NULL) - goto failure; -#if !defined(SMALL_FOOTPRINT) - /* Make sure we don't allocate a band larger than our PVQ table. - 208 should be enough, but let's be paranoid. */ - if ((mode->eBands[mode->nbEBands] - mode->eBands[mode->nbEBands-1])< - 208) { - goto failure; - } -#endif + if (Fs < 8000 || Fs > 96000) { + if (error) + *error = OAC_BAD_ARG; + return NULL; + } +# ifdef ENABLE_QEXT + if (frame_size < 40 || frame_size > 2048 || frame_size%2 != 0) +# else + if (frame_size < 40 || frame_size > 1024 || frame_size%2 != 0) +# endif + { + if (error) + *error = OAC_BAD_ARG; + return NULL; + } + /* Frames of less than 1ms are not supported. */ + if ((oac_int32)frame_size*1000 < Fs) { + if (error) + *error = OAC_BAD_ARG; + return NULL; + } + + if ((oac_int32)frame_size*75 >= Fs && (frame_size%16) == 0) { + LM = 3; + } else if ((oac_int32)frame_size*150 >= Fs && (frame_size%8) == 0) { + LM = 2; + } else if ((oac_int32)frame_size*300 >= Fs && (frame_size%4) == 0) { + LM = 1; + } else { + LM = 0; + } + + /* Shorts longer than 3.3ms are not supported. */ + if ((oac_int32)(frame_size>>LM)*300 > Fs) { + if (error) + *error = OAC_BAD_ARG; + return NULL; + } + + mode = oac_alloc(sizeof(CELTMode)); + if (mode == NULL) + goto failure; + mode->Fs = Fs; + + /* Pre/de-emphasis depends on sampling rate. The "standard" pre-emphasis + is defined as A(z) = 1 - 0.85*z^-1 at 48 kHz. Other rates should + approximate that. */ +# ifdef ENABLE_QEXT + if (Fs == 96000) { /* 96 kHz */ + mode->preemph[0] = QCONST16(0.9230041504f, 15); + mode->preemph[1] = QCONST16(0.2200012207f, 15); + mode->preemph[2] = QCONST16(1.5128347184f, SIG_SHIFT);/* exact 1/preemph[3] */ + mode->preemph[3] = QCONST16(0.6610107422f, 13); + } else +# endif + if (Fs < 12000) { /* 8 kHz */ + mode->preemph[0] = QCONST16(0.3500061035f, 15); + mode->preemph[1] = -QCONST16(0.1799926758f, 15); + mode->preemph[2] = QCONST16(0.2719968125f, SIG_SHIFT);/* exact 1/preemph[3] */ + mode->preemph[3] = QCONST16(3.6765136719f, 13); + } else if (Fs < 24000) { /* 16 kHz */ + mode->preemph[0] = QCONST16(0.6000061035f, 15); + mode->preemph[1] = -QCONST16(0.1799926758f, 15); + mode->preemph[2] = QCONST16(0.4424998650f, SIG_SHIFT);/* exact 1/preemph[3] */ + mode->preemph[3] = QCONST16(2.2598876953f, 13); + } else if (Fs < 40000) { /* 32 kHz */ + mode->preemph[0] = QCONST16(0.7799987793f, 15); + mode->preemph[1] = -QCONST16(0.1000061035f, 15); + mode->preemph[2] = QCONST16(0.7499771125f, SIG_SHIFT);/* exact 1/preemph[3] */ + mode->preemph[3] = QCONST16(1.3333740234f, 13); + } else { /* 48 kHz */ + mode->preemph[0] = QCONST16(0.8500061035f, 15); + mode->preemph[1] = QCONST16(0.0f, 15); + mode->preemph[2] = QCONST16(1.f, SIG_SHIFT); + mode->preemph[3] = QCONST16(1.f, 13); + } + + mode->maxLM = LM; + mode->nbShortMdcts = 1<shortMdctSize = frame_size/mode->nbShortMdcts; + res = (mode->Fs + mode->shortMdctSize)/(2*mode->shortMdctSize); + + mode->eBands = oaci_compute_ebands(Fs, mode->shortMdctSize, res, &mode->nbEBands); + if (mode->eBands == NULL) + goto failure; +# if !defined(SMALL_FOOTPRINT) + /* Make sure we don't allocate a band larger than our PVQ table. + 208 should be enough, but let's be paranoid. */ + if ((mode->eBands[mode->nbEBands] - mode->eBands[mode->nbEBands - 1])< + 208) { + goto failure; + } +# endif - mode->effEBands = mode->nbEBands; - while (mode->eBands[mode->effEBands] > mode->shortMdctSize) - mode->effEBands--; + mode->effEBands = mode->nbEBands; + while (mode->eBands[mode->effEBands] > mode->shortMdctSize) + mode->effEBands--; - /* Overlap must be divisible by 4 */ - mode->overlap = ((mode->shortMdctSize>>2)<<2); + /* Overlap must be divisible by 4 */ + mode->overlap = ((mode->shortMdctSize>>2)<<2); - compute_allocation_table(mode); - if (mode->allocVectors==NULL) - goto failure; + oaci_compute_allocation_table(mode); + if (mode->allocVectors == NULL) + goto failure; - window = (celt_coef*)opus_alloc(mode->overlap*sizeof(*window)); - if (window==NULL) - goto failure; + window = (celt_coef*)oac_alloc(mode->overlap*sizeof(*window)); + if (window == NULL) + goto failure; -#ifndef FIXED_POINT - for (i=0;ioverlap;i++) - window[i] = Q15ONE*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/mode->overlap) * sin(.5*M_PI*(i+.5)/mode->overlap)); -#else -# ifdef ENABLE_QEXT - for (i=0;ioverlap;i++) - window[i] = MIN32(2147483647, 2147483648*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/mode->overlap) * sin(.5*M_PI*(i+.5)/mode->overlap))); +# ifndef FIXED_POINT + for (i = 0; i < mode->overlap; i++) + window[i] = Q15ONE*sin(.5*M_PI*sin(.5*M_PI*(i + .5)/mode->overlap)*sin(.5*M_PI*(i + .5)/mode->overlap)); # else - for (i=0;ioverlap;i++) - window[i] = MIN32(32767,floor(.5+32768.*sin(.5*M_PI* sin(.5*M_PI*(i+.5)/mode->overlap) * sin(.5*M_PI*(i+.5)/mode->overlap)))); + for (i = 0; i < mode->overlap; i++) + window[i] = MIN32(2147483647, + 2147483648*sin(.5*M_PI*sin(.5*M_PI*(i + .5)/mode->overlap)*sin(.5*M_PI*(i + .5)/mode->overlap))); # endif -#endif - mode->window = window; - - logN = (opus_int16*)opus_alloc(mode->nbEBands*sizeof(opus_int16)); - if (logN==NULL) - goto failure; - - for (i=0;inbEBands;i++) - logN[i] = log2_frac(mode->eBands[i+1]-mode->eBands[i], BITRES); - mode->logN = logN; - - compute_pulse_cache(mode, mode->maxLM); -#ifdef ENABLE_QEXT - OPUS_CLEAR(&mode->qext_cache, 1); - if ( (mode->Fs == 48000 && (mode->shortMdctSize==120 || mode->shortMdctSize==90)) || (mode->Fs == 96000 && (mode->shortMdctSize==240 || mode->shortMdctSize==180)) ) { - CELTMode dummy; - compute_qext_mode(&dummy, mode); - compute_pulse_cache(&dummy, dummy.maxLM); - OPUS_COPY(&mode->qext_cache, &dummy.cache, 1); - } -#endif + mode->window = window; + + logN = (oac_int16*)oac_alloc(mode->nbEBands*sizeof(oac_int16)); + if (logN == NULL) + goto failure; + + for (i = 0; i < mode->nbEBands; i++) + logN[i] = oaci_log2_frac(mode->eBands[i + 1] - mode->eBands[i], BITRES); + mode->logN = logN; - if (clt_mdct_init(&mode->mdct, 2*mode->shortMdctSize*mode->nbShortMdcts, + oaci_compute_pulse_cache(mode, mode->maxLM); + + if (oaci_clt_mdct_init(&mode->mdct, 2*mode->shortMdctSize*mode->nbShortMdcts, mode->maxLM, arch) == 0) - goto failure; + goto failure; - if (error) - *error = OPUS_OK; + if (error) + *error = OAC_OK; - return mode; + return mode; failure: - if (error) - *error = OPUS_ALLOC_FAIL; - if (mode!=NULL) - opus_custom_mode_destroy(mode); - return NULL; + if (error) + *error = OAC_ALLOC_FAIL; + if (mode != NULL) + oac_custom_mode_destroy(mode); + return NULL; #endif /* !CUSTOM_MODES */ } -#if defined(CUSTOM_MODES) || defined(ENABLE_OPUS_CUSTOM_API) -void opus_custom_mode_destroy(CELTMode *mode) -{ - int arch = opus_select_arch(); - - if (mode == NULL) - return; -#ifndef CUSTOM_MODES_ONLY - { - int i; - for (i=0;iqext_cache.index) opus_free((opus_int16*)mode->qext_cache.index); - if (mode->qext_cache.bits) opus_free((unsigned char*)mode->qext_cache.bits); - if (mode->qext_cache.caps) opus_free((unsigned char*)mode->qext_cache.caps); -#endif - opus_free((opus_int16*)mode->eBands); - opus_free((unsigned char*)mode->allocVectors); - - opus_free((opus_val16*)mode->window); - opus_free((opus_int16*)mode->logN); - - opus_free((opus_int16*)mode->cache.index); - opus_free((unsigned char*)mode->cache.bits); - opus_free((unsigned char*)mode->cache.caps); - clt_mdct_clear(&mode->mdct, arch); + } +# endif /* CUSTOM_MODES_ONLY */ +# ifdef CUSTOM_MODES + oac_free((oac_int16*)mode->eBands); + oac_free((unsigned char*)mode->allocVectors); - opus_free((CELTMode *)mode); -#else - (void)arch; - celt_assert(0); -#endif -} -#endif - -#ifdef ENABLE_QEXT + oac_free((oac_val16*)mode->window); + oac_free((oac_int16*)mode->logN); -static const opus_int16 qext_eBands_180[] = { -/* 20k 22k 24k 26k 28k 30k 32k 34k 36k 38k 40k 42k 44k 47k 48k */ - 74, 82, 90, 98, 106, 114, 122, 130, 138, 146, 154, 162, 168, 174, 180 -}; + oac_free((oac_int16*)mode->cache.index); + oac_free((unsigned char*)mode->cache.bits); + oac_free((unsigned char*)mode->cache.caps); + oaci_clt_mdct_clear(&mode->mdct, arch); -static const opus_int16 qext_logN_180[] = {24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 21, 21, 21}; - -/* Extra bands. */ -static const opus_int16 qext_eBands_240[] = { -/* 20k 22k 24k 26k 28k 30k 32k 34k 36k 38k 40k 42k 44k 47k 48k */ - 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240 -}; - -static const opus_int16 qext_logN_240[] = {27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27}; - -void compute_qext_mode(CELTMode *qext, const CELTMode *m) -{ - OPUS_COPY(qext, m, 1); - if (m->shortMdctSize*48000 == 120*m->Fs) { - qext->eBands = qext_eBands_240; - qext->logN = qext_logN_240; - } else if (m->shortMdctSize*48000 == 90*m->Fs) { - qext->eBands = qext_eBands_180; - qext->logN = qext_logN_180; - } else { - celt_assert(0); - } - qext->nbEBands = qext->effEBands = NB_QEXT_BANDS; - while (qext->eBands[qext->effEBands] > qext->shortMdctSize) - qext->effEBands--; - qext->nbAllocVectors = 0; - qext->allocVectors = NULL; - OPUS_COPY(&qext->cache, &m->qext_cache, 1); + oac_free((CELTMode *)mode); +# else + (void)arch; + celt_assert(0); +# endif } #endif diff --git a/celt/modes.h b/celt/modes.h index 06bfc65f1..a8dd5f9c8 100644 --- a/celt/modes.h +++ b/celt/modes.h @@ -25,12 +25,12 @@ 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. -*/ + */ #ifndef MODES_H #define MODES_H -#include "opus_types.h" +#include "oac_types.h" #include "celt.h" #include "arch.h" #include "mdct.h" @@ -42,44 +42,36 @@ #define DEC_PITCH_BUF_SIZE 2048 typedef struct { - int size; - const opus_int16 *index; - const unsigned char *bits; - const unsigned char *caps; + int size; + const oac_int16 *index; + const unsigned char *bits; + const unsigned char *caps; } PulseCache; /** Mode definition (opaque) - @brief Mode definition + @brief Mode definition */ -struct OpusCustomMode { - opus_int32 Fs; - int overlap; +struct OacCustomMode { + oac_int32 Fs; + int overlap; - int nbEBands; - int effEBands; - opus_val16 preemph[4]; - const opus_int16 *eBands; /**< Definition for each "pseudo-critical band" */ + int nbEBands; + int effEBands; + oac_val16 preemph[4]; + const oac_int16 *eBands; /**< Definition for each "pseudo-critical band" */ - int maxLM; - int nbShortMdcts; - int shortMdctSize; + int maxLM; + int nbShortMdcts; + int shortMdctSize; - int nbAllocVectors; /**< Number of lines in the matrix below */ - const unsigned char *allocVectors; /**< Number of bits in each band for several rates */ - const opus_int16 *logN; + int nbAllocVectors; /**< Number of lines in the matrix below */ + const unsigned char *allocVectors; /**< Number of bits in each band for several rates */ + const oac_int16 *logN; - const celt_coef *window; - mdct_lookup mdct; - PulseCache cache; -#ifdef ENABLE_QEXT - PulseCache qext_cache; -#endif + const celt_coef *window; + mdct_lookup mdct; + PulseCache cache; }; -#ifdef ENABLE_QEXT -#define QEXT_PACKET_SIZE_CAP 3825 -#define NB_QEXT_BANDS 14 -void compute_qext_mode(CELTMode *qext, const CELTMode *m); -#endif #endif diff --git a/celt/oac_custom_demo.c b/celt/oac_custom_demo.c new file mode 100644 index 000000000..f50dd660a --- /dev/null +++ b/celt/oac_custom_demo.c @@ -0,0 +1,459 @@ +/* Copyright (c) 2007-2008 CSIRO + Copyright (c) 2007-2009 Xiph.Org Foundation + Written by Jean-Marc Valin */ +/* + 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 "oac_custom.h" +#include "arch.h" +#include "modes.h" +#include +#include +#include +#include + +#define MAX_PACKET 1275 + +static OAC_INLINE void _oac_ctl_failed(const char *file, int line) { + fprintf(stderr, "\n ***************************************************\n"); + fprintf(stderr, " *** A fatal error was detected. ***\n"); + fprintf(stderr, " ***************************************************\n"); + fprintf(stderr, "En/decoder ctl function %s failed at %d for %s.\n", + file, line, oac_get_version_string()); +} + +#define oac_ctl_failed() _oac_ctl_failed(__FILE__, __LINE__); + +static void print_usage(char **argv) { + fprintf (stderr, "Usage: %s [-e | -d] " + " [] [options] " + " \n", argv[0]); + fprintf (stderr, " -e encode only (default is encode and decode)\n"); + fprintf (stderr, " -d decode only (default is encode and decode)\n"); + fprintf (stderr, " : required only when encoding\n"); + fprintf (stderr, "options:\n"); + fprintf (stderr, " -16 format is 16-bit little-endian (default)\n"); + fprintf (stderr, " -24 format is 24-bit little-endian\n"); + fprintf (stderr, " -f32 format is 32-bit float little-endian\n"); + fprintf (stderr, " -complexity <0-10> optional only when encoding\n"); + fprintf (stderr, " -loss encoding (robsutness setting) and decoding (simulating loss)\n"); +} + +static void int_to_char(oac_uint32 i, unsigned char ch[4]) { + ch[0] = i>>24; + ch[1] = (i>>16)&0xFF; + ch[2] = (i>>8)&0xFF; + ch[3] = i&0xFF; +} + +static oac_uint32 char_to_int(unsigned char ch[4]) { + return ((oac_uint32)ch[0]<<24)|((oac_uint32)ch[1]<<16) + |((oac_uint32)ch[2]<<8)|(oac_uint32)ch[3]; +} + +#define check_encoder_option(decode_only, \ + opt) do {if (decode_only) {fprintf(stderr, "option %s is only for encoding\n", opt); \ + goto failure;}} while (0) +#define check_decoder_option(encode_only, \ + opt) do {if (encode_only) {fprintf(stderr, "option %s is only for decoding\n", opt); \ + goto failure;}} while (0) + +#define FORMAT_S16_LE 0 +#define FORMAT_S24_LE 1 +#define FORMAT_F32_LE 2 + +static const int format_size[3] = {2, 3, 4}; + +typedef union { + oac_int32 i; + float f; +} float_bits; + + +int main(int argc, char *argv[]) { + int err; + int ret = 1; + int args; + oac_uint32 enc_final_range; + oac_uint32 dec_final_range; + int encode_only = 0, decode_only = 0; + char *inFile, *outFile; + FILE *fin = NULL, *fout = NULL; + OacCustomMode *mode = NULL; + OacCustomEncoder *enc = NULL; + OacCustomDecoder *dec = NULL; + int len; + oac_int32 frame_size, channels, rate; + int format = FORMAT_S16_LE; + int bytes_per_packet = 0; + unsigned char data[MAX_PACKET]; + int complexity = -1; + float percent_loss = -1; + int i; +#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH) + double rmsd = 0; +#endif + int count = 0; + oac_int32 skip; + oac_int32 *in = NULL, *out = NULL; + unsigned char *fbytes = NULL; + args = 1; + if (argc < 7) { + print_usage(argv); + goto failure; + } + if (strcmp(argv[args], "-e") == 0) { + encode_only = 1; + args++; + } else if (strcmp(argv[args], "-d") == 0) { + decode_only = 1; + args++; + } + + rate = (oac_int32)atol(argv[args]); + args++; + + if (rate != 8000 && rate != 12000 + && rate != 16000 && rate != 24000 + && rate != 48000 +#ifdef ENABLE_QEXT + && rate != 96000 +#endif + ) { + fprintf(stderr, "Supported sampling rates are 8000, 12000, 16000, 24000" +#ifdef ENABLE_QEXT + ", 48000 and 96000.\n"); +#else + " and 48000.\n"); +#endif + goto failure; + } + + channels = atoi(argv[args]); + args++; + + if (channels < 1 || channels > 2) { + fprintf(stderr, "Oac_demo supports only 1 or 2 channels.\n"); + goto failure; + } + + frame_size = atoi(argv[args]); + args++; + + if (!decode_only) { + bytes_per_packet = (oac_int32)atol(argv[args]); + args++; + if (bytes_per_packet < 0 || bytes_per_packet > MAX_PACKET) { + fprintf (stderr, "bytes per packet must be between 0 and %d\n", + MAX_PACKET); + goto failure; + } + } + + mode = oac_custom_mode_create(rate, frame_size, NULL); + if (mode == NULL) { + fprintf(stderr, "failed to create a mode\n"); + goto failure; + } + while (args < argc - 2) { + /* process command line options */ + if (strcmp( argv[ args ], "-complexity" ) == 0) { + check_encoder_option(decode_only, "-complexity"); + args++; + complexity = atoi(argv[args]); + args++; + } else if (strcmp( argv[ args ], "-loss" ) == 0) { + args++; + percent_loss = atof(argv[args]); + args++; + } else if (strcmp( argv[ args ], "-16" ) == 0) { + format = FORMAT_S16_LE; + args++; + } else if (strcmp( argv[ args ], "-24" ) == 0) { + format = FORMAT_S24_LE; + args++; + } else if (strcmp( argv[ args ], "-f32" ) == 0) { + format = FORMAT_F32_LE; + args++; + } else { + printf( "Error: unrecognized setting: %s\n\n", argv[ args ] ); + print_usage( argv ); + goto failure; + } + } + if (!decode_only) { + enc = oac_custom_encoder_create(mode, channels, &err); + if (err != 0) { + fprintf(stderr, "Failed to create the encoder: %s\n", oac_strerror(err)); + goto failure; + } + if (complexity >= 0) { + if (oac_custom_encoder_ctl( + enc, OAC_SET_COMPLEXITY(complexity)) != OAC_OK) { + oac_ctl_failed(); + goto failure; + } + } + if (percent_loss >= 0) { + if (oac_custom_encoder_ctl( + enc, OAC_SET_PACKET_LOSS_PERC((int)percent_loss)) != + OAC_OK) { + oac_ctl_failed(); + goto failure; + } + } + } + if (!encode_only) { + dec = oac_custom_decoder_create(mode, channels, &err); + if (err != 0) { + fprintf(stderr, "Failed to create the decoder: %s\n", oac_strerror(err)); + goto failure; + } + if (oac_custom_decoder_ctl(dec, OAC_GET_LOOKAHEAD(&skip)) != OAC_OK) { + oac_ctl_failed(); + goto failure; + } + } + if (argc - args != 2) { + print_usage(argv); + goto failure; + } + inFile = argv[argc - 2]; + fin = fopen(inFile, "rb"); + if (!fin) { + fprintf (stderr, "Could not open input file %s\n", argv[argc - 2]); + goto failure; + } + outFile = argv[argc - 1]; + fout = fopen(outFile, "wb+"); + if (!fout) { + fprintf (stderr, "Could not open output file %s\n", argv[argc - 1]); + goto failure; + } + in = (oac_int32*)malloc(frame_size*channels*sizeof(oac_int32)); + out = (oac_int32*)malloc(frame_size*channels*sizeof(oac_int32)); + fbytes = (unsigned char*)malloc(frame_size*channels*4); + + while (!feof(fin)) { + int lost = 0; + if (decode_only) { + unsigned char ch[4]; + size_t num_read = fread(ch, 1, 4, fin); + if (num_read != 4) + break; + len = char_to_int(ch); + if (len > MAX_PACKET || len < 0) { + fprintf(stderr, "Invalid payload length: %d\n", len); + break; + } + num_read = fread(ch, 1, 4, fin); + if (num_read != 4) + break; + enc_final_range = char_to_int(ch); + num_read = fread(data, 1, len, fin); + if (num_read != (size_t)len) { + fprintf(stderr, "Ran out of input, " + "expecting %d bytes got %d\n", + len, (int)num_read); + break; + } + } else { + err = fread(fbytes, format_size[format], frame_size*channels, fin); + if (feof(fin)) + break; + if (format == FORMAT_S16_LE) { + for (i = 0; i < frame_size*channels; i++) { + oac_int32 s; + s = fbytes[2*i + 1]<<8|fbytes[2*i]; + s = ((s&0xFFFF)^0x8000) - 0x8000; + in[i] = s*256; + } + } else if (format == FORMAT_S24_LE) { + for (i = 0; i < frame_size*channels; i++) { + oac_int32 s; + s = fbytes[3*i + 2]<<16|fbytes[3*i + 1]<<8|fbytes[3*i]; + s = ((s&0xFFFFFF)^0x800000) - 0x800000; + in[i] = s; + } + } else if (format == FORMAT_F32_LE) { + for (i = 0; i < frame_size*channels; i++) { + float_bits s; + s.i = (unsigned)fbytes[4*i + 3]<<24|fbytes[4*i + 2]<<16|fbytes[4*i + 1]<<8|fbytes[4*i]; + in[i] = (int)floor(.5 + s.f*8388608); + } + } + len = oac_custom_encode24(enc, in, frame_size, data, bytes_per_packet); + if (oac_custom_encoder_ctl( + enc, OAC_GET_FINAL_RANGE(&enc_final_range)) != OAC_OK) { + oac_ctl_failed(); + goto failure; + } + if (len <= 0) + fprintf (stderr, "oac_custom_encode() failed: %s\n", oac_strerror(len)); + } + + if (encode_only) { + unsigned char int_field[4]; + int_to_char(len, int_field); + if (fwrite(int_field, 1, 4, fout) != 4) { + fprintf(stderr, "Error writing.\n"); + goto failure; + } + int_to_char(enc_final_range, int_field); + if (fwrite(int_field, 1, 4, fout) != 4) { + fprintf(stderr, "Error writing.\n"); + goto failure; + } + if (fwrite(data, 1, len, fout) != (unsigned)len) { + fprintf(stderr, "Error writing.\n"); + goto failure; + } + } else { + /* This is for simulating bit errors */ +#if 0 + int errors = 0; + int eid = 0; + /* This simulates random bit error */ + for (i = 0; i < len*8; i++) { + if (rand()%atoi(argv[8]) == 0) { + if (i < 64) { + errors++; + eid = i; + } + data[i/8] ^= 1<<(7 - (i%8)); + } + } + if (errors == 1) + data[eid/8] ^= 1<<(7 - (eid%8)); + else if (errors%2 == 1) + data[rand()%8] ^= 1< 0x007fff00) s = 0x007fff00; + if (s < -0x007fff00) s = -0x007fff00; + s = (s + 128)>>8; + fbytes[2*i] = s&0xFF; + fbytes[2*i + 1] = (s>>8)&0xFF; + } + } else if (format == FORMAT_S24_LE) { + for (i = 0; i < (ret - skip)*channels; i++) { + oac_int32 s; + s = out[i + (skip*channels)]; + if (s > 0x007fffff) s = 0x007fffff; + if (s < -0x007fffff) s = -0x007fffff; + fbytes[3*i] = s&0xFF; + fbytes[3*i + 1] = (s>>8)&0xFF; + fbytes[3*i + 2] = (s>>16)&0xFF; + } + } else if (format == FORMAT_F32_LE) { + for (i = 0; i < (ret - skip)*channels; i++) { + float_bits s; + s.f = out[i + (skip*channels)]*(1.f/8388608.f); + fbytes[4*i] = s.i&0xFF; + fbytes[4*i + 1] = (s.i>>8)&0xFF; + fbytes[4*i + 2] = (s.i>>16)&0xFF; + fbytes[4*i + 3] = (s.i>>24)&0xFF; + } + } + fwrite(fbytes, format_size[format], (ret - skip)*channels, fout); + } + + /* compare final range encoder rng values of encoder and decoder */ + if (enc_final_range != 0 && !encode_only + && !lost + && dec_final_range != enc_final_range) { + fprintf (stderr, "Error: Range coder state mismatch " + "between encoder and decoder " + "in frame %ld: 0x%8lx vs 0x%8lx\n", + (long)count, + (unsigned long)enc_final_range, + (unsigned long)dec_final_range); + goto failure; + } + + count++; + skip = 0; + } + PRINT_MIPS(stderr); + ret = EXIT_SUCCESS; +#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH) + if (!encode_only && !decode_only) { + if (rmsd > 0) { + rmsd = sqrt(rmsd/(1.0*frame_size*channels*count)); + fprintf (stderr, "Error: encoder doesn't match decoder\n"); + fprintf (stderr, "RMS mismatch is %f\n", rmsd); + ret = 1; + } else { + fprintf (stderr, "Encoder matches decoder!!\n"); + } + } +#endif +failure: + /* Cleanup after ourselves. */ + if (enc) oac_custom_encoder_destroy(enc); + if (dec) oac_custom_decoder_destroy(dec); + if (fin) fclose(fin); + if (fout) fclose(fout); + if (mode) oac_custom_mode_destroy(mode); + if (in) free(in); + if (out) free(out); + if (fbytes) free(fbytes); + return ret; +} diff --git a/celt/opus_custom_demo.c b/celt/opus_custom_demo.c deleted file mode 100644 index 44132813e..000000000 --- a/celt/opus_custom_demo.c +++ /dev/null @@ -1,512 +0,0 @@ -/* Copyright (c) 2007-2008 CSIRO - Copyright (c) 2007-2009 Xiph.Org Foundation - Written by Jean-Marc Valin */ -/* - 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 "opus_custom.h" -#include "arch.h" -#include "modes.h" -#include -#include -#include -#include - -#ifdef ENABLE_QEXT -#define MAX_PACKET QEXT_PACKET_SIZE_CAP -#else -#define MAX_PACKET 1275 -#endif - -static OPUS_INLINE void _opus_ctl_failed(const char *file, int line) -{ - fprintf(stderr, "\n ***************************************************\n"); - fprintf(stderr, " *** A fatal error was detected. ***\n"); - fprintf(stderr, " ***************************************************\n"); - fprintf(stderr, "En/decoder ctl function %s failed at %d for %s.\n", - file, line, opus_get_version_string()); -} - -#define opus_ctl_failed() _opus_ctl_failed(__FILE__, __LINE__); - -static void print_usage(char **argv) { - fprintf (stderr, "Usage: %s [-e | -d] " - " [] [options] " - " \n", argv[0]); - fprintf (stderr, " -e encode only (default is encode and decode)\n"); - fprintf (stderr, " -d decode only (default is encode and decode)\n"); - fprintf (stderr, " : required only when encoding\n"); - fprintf (stderr, "options:\n"); - fprintf (stderr, " -16 format is 16-bit little-endian (default)\n"); - fprintf (stderr, " -24 format is 24-bit little-endian\n"); - fprintf (stderr, " -f32 format is 32-bit float little-endian\n"); - fprintf (stderr, " -complexity <0-10> optional only when encoding\n"); - fprintf (stderr, " -loss encoding (robsutness setting) and decoding (simulating loss)\n"); -#ifdef ENABLE_QEXT - fprintf (stderr, " -qext use quality extension\n"); -#endif -} - -static void int_to_char(opus_uint32 i, unsigned char ch[4]) -{ - ch[0] = i>>24; - ch[1] = (i>>16)&0xFF; - ch[2] = (i>>8)&0xFF; - ch[3] = i&0xFF; -} - -static opus_uint32 char_to_int(unsigned char ch[4]) -{ - return ((opus_uint32)ch[0]<<24) | ((opus_uint32)ch[1]<<16) - | ((opus_uint32)ch[2]<< 8) | (opus_uint32)ch[3]; -} - -#define check_encoder_option(decode_only, opt) do {if (decode_only) {fprintf(stderr, "option %s is only for encoding\n", opt); goto failure;}} while(0) -#define check_decoder_option(encode_only, opt) do {if (encode_only) {fprintf(stderr, "option %s is only for decoding\n", opt); goto failure;}} while(0) - -#define FORMAT_S16_LE 0 -#define FORMAT_S24_LE 1 -#define FORMAT_F32_LE 2 - -static const int format_size[3] = {2, 3, 4}; - -typedef union { - opus_int32 i; - float f; -} float_bits; - - -int main(int argc, char *argv[]) -{ - int err; - int ret=1; - int args; - opus_uint32 enc_final_range; - opus_uint32 dec_final_range; - int encode_only=0, decode_only=0; - char *inFile, *outFile; - FILE *fin=NULL, *fout=NULL; - OpusCustomMode *mode=NULL; - OpusCustomEncoder *enc=NULL; - OpusCustomDecoder *dec=NULL; - int len; - opus_int32 frame_size, channels, rate; - int format=FORMAT_S16_LE; - int bytes_per_packet=0; - unsigned char data[MAX_PACKET]; - int complexity=-1; - float percent_loss = -1; - int i; -#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH) - double rmsd = 0; -#endif -#ifdef ENABLE_QEXT - int qext = 0; -#endif - int count = 0; - opus_int32 skip; - opus_int32 *in=NULL, *out=NULL; - unsigned char *fbytes=NULL; - args = 1; - if (argc < 7) - { - print_usage(argv); - goto failure; - } - if (strcmp(argv[args], "-e")==0) - { - encode_only = 1; - args++; - } else if (strcmp(argv[args], "-d")==0) - { - decode_only = 1; - args++; - } - - rate = (opus_int32)atol(argv[args]); - args++; - - if (rate != 8000 && rate != 12000 - && rate != 16000 && rate != 24000 - && rate != 48000 -#ifdef ENABLE_QEXT - && rate != 96000 -#endif - ) - { - fprintf(stderr, "Supported sampling rates are 8000, 12000, 16000, 24000" -#ifdef ENABLE_QEXT - ", 48000 and 96000.\n"); -#else - " and 48000.\n"); -#endif - goto failure; - } - - channels = atoi(argv[args]); - args++; - - if (channels < 1 || channels > 2) - { - fprintf(stderr, "Opus_demo supports only 1 or 2 channels.\n"); - goto failure; - } - - frame_size = atoi(argv[args]); - args++; - - if (!decode_only) - { - bytes_per_packet = (opus_int32)atol(argv[args]); - args++; - if (bytes_per_packet < 0 || bytes_per_packet > MAX_PACKET) - { - fprintf (stderr, "bytes per packet must be between 0 and %d\n", - MAX_PACKET); - goto failure; - } - } - - mode = opus_custom_mode_create(rate, frame_size, NULL); - if (mode == NULL) - { - fprintf(stderr, "failed to create a mode\n"); - goto failure; - } - while( args < argc - 2 ) { - /* process command line options */ - if( strcmp( argv[ args ], "-complexity" ) == 0 ) { - check_encoder_option(decode_only, "-complexity"); - args++; - complexity=atoi(argv[args]); - args++; - } else if( strcmp( argv[ args ], "-loss" ) == 0 ) { - args++; - percent_loss = atof(argv[args]); - args++; - } else if( strcmp( argv[ args ], "-16" ) == 0 ) { - format = FORMAT_S16_LE; - args++; - } else if( strcmp( argv[ args ], "-24" ) == 0 ) { - format = FORMAT_S24_LE; - args++; - } else if( strcmp( argv[ args ], "-f32" ) == 0 ) { - format = FORMAT_F32_LE; - args++; -#ifdef ENABLE_QEXT - } else if( strcmp( argv[ args ], "-qext" ) == 0 ) { - qext = 1; - args++; -#endif - } else { - printf( "Error: unrecognized setting: %s\n\n", argv[ args ] ); - print_usage( argv ); - goto failure; - } - } - if (!decode_only) { - enc = opus_custom_encoder_create(mode, channels, &err); - if (err != 0) - { - fprintf(stderr, "Failed to create the encoder: %s\n", opus_strerror(err)); - goto failure; - } - if (complexity >= 0) - { - if(opus_custom_encoder_ctl( - enc, OPUS_SET_COMPLEXITY(complexity)) != OPUS_OK) { - opus_ctl_failed(); - goto failure; - } - } - if (percent_loss >= 0) { - if(opus_custom_encoder_ctl( - enc, OPUS_SET_PACKET_LOSS_PERC((int)percent_loss)) != - OPUS_OK) { - opus_ctl_failed(); - goto failure; - } - } -#ifdef ENABLE_QEXT - if(opus_custom_encoder_ctl(enc, OPUS_SET_QEXT(qext)) != OPUS_OK) { - opus_ctl_failed(); - goto failure; - } -#endif - } - if (!encode_only) { - dec = opus_custom_decoder_create(mode, channels, &err); - if (err != 0) - { - fprintf(stderr, "Failed to create the decoder: %s\n", opus_strerror(err)); - goto failure; - } - if(opus_custom_decoder_ctl(dec, OPUS_GET_LOOKAHEAD(&skip)) != OPUS_OK) { - opus_ctl_failed(); - goto failure; - } - } - if (argc-args != 2) - { - print_usage(argv); - goto failure; - } - inFile = argv[argc-2]; - fin = fopen(inFile, "rb"); - if (!fin) - { - fprintf (stderr, "Could not open input file %s\n", argv[argc-2]); - goto failure; - } - outFile = argv[argc-1]; - fout = fopen(outFile, "wb+"); - if (!fout) - { - fprintf (stderr, "Could not open output file %s\n", argv[argc-1]); - goto failure; - } - in = (opus_int32*)malloc(frame_size*channels*sizeof(opus_int32)); - out = (opus_int32*)malloc(frame_size*channels*sizeof(opus_int32)); - fbytes = (unsigned char*)malloc(frame_size*channels*4); - - while (!feof(fin)) - { - int lost = 0; - if (decode_only) - { - unsigned char ch[4]; - size_t num_read = fread(ch, 1, 4, fin); - if (num_read!=4) - break; - len = char_to_int(ch); - if (len>MAX_PACKET || len<0) - { - fprintf(stderr, "Invalid payload length: %d\n",len); - break; - } - num_read = fread(ch, 1, 4, fin); - if (num_read!=4) - break; - enc_final_range = char_to_int(ch); - num_read = fread(data, 1, len, fin); - if (num_read!=(size_t)len) - { - fprintf(stderr, "Ran out of input, " - "expecting %d bytes got %d\n", - len,(int)num_read); - break; - } - } else { - err = fread(fbytes, format_size[format], frame_size*channels, fin); - if (feof(fin)) - break; - if (format == FORMAT_S16_LE) { - for(i=0;i 0x007fff00) s = 0x007fff00; - if (s < -0x007fff00) s = -0x007fff00; - s=(s+128)>>8; - fbytes[2*i]=s&0xFF; - fbytes[2*i+1]=(s>>8)&0xFF; - } - } else if (format == FORMAT_S24_LE) { - for(i=0;i<(ret-skip)*channels;i++) - { - opus_int32 s; - s=out[i+(skip*channels)]; - if (s > 0x007fffff) s = 0x007fffff; - if (s < -0x007fffff) s = -0x007fffff; - fbytes[3*i]=s&0xFF; - fbytes[3*i+1]=(s>>8)&0xFF; - fbytes[3*i+2]=(s>>16)&0xFF; - } - } else if (format == FORMAT_F32_LE) { - for(i=0;i<(ret-skip)*channels;i++) - { - float_bits s; - s.f=out[i+(skip*channels)]*(1.f/8388608.f); - fbytes[4*i]=s.i&0xFF; - fbytes[4*i+1]=(s.i>>8)&0xFF; - fbytes[4*i+2]=(s.i>>16)&0xFF; - fbytes[4*i+3]=(s.i>>24)&0xFF; - } - } - fwrite(fbytes, format_size[format], (ret-skip)*channels, fout); - } - - /* compare final range encoder rng values of encoder and decoder */ - if( enc_final_range!=0 && !encode_only - && !lost - && dec_final_range != enc_final_range ) { - fprintf (stderr, "Error: Range coder state mismatch " - "between encoder and decoder " - "in frame %ld: 0x%8lx vs 0x%8lx\n", - (long)count, - (unsigned long)enc_final_range, - (unsigned long)dec_final_range); - goto failure; - } - - count++; - skip = 0; - } - PRINT_MIPS(stderr); - ret = EXIT_SUCCESS; -#if !(defined (FIXED_POINT) && !defined(CUSTOM_MODES)) && defined(RESYNTH) - if (!encode_only && !decode_only) - { - if (rmsd > 0) - { - rmsd = sqrt(rmsd/(1.0*frame_size*channels*count)); - fprintf (stderr, "Error: encoder doesn't match decoder\n"); - fprintf (stderr, "RMS mismatch is %f\n", rmsd); - ret = 1; - } else { - fprintf (stderr, "Encoder matches decoder!!\n"); - } - } -#endif -failure: - /* Cleanup after ourselves. */ - if (enc) opus_custom_encoder_destroy(enc); - if (dec) opus_custom_decoder_destroy(dec); - if (fin) fclose(fin); - if (fout) fclose(fout); - if (mode) opus_custom_mode_destroy(mode); - if (in) free(in); - if (out) free(out); - if (fbytes) free(fbytes); - return ret; -} diff --git a/celt/os_support.h b/celt/os_support.h index 48d742b3d..56699f041 100644 --- a/celt/os_support.h +++ b/celt/os_support.h @@ -26,73 +26,69 @@ 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. -*/ + */ #ifndef OS_SUPPORT_H #define OS_SUPPORT_H #ifdef CUSTOM_SUPPORT -# include "custom_support.h" +# include "custom_support.h" #endif -#include "opus_types.h" -#include "opus_defines.h" +#include "oac_types.h" +#include "oac_defines.h" #include #include -/** Opus wrapper for malloc(). To do your own dynamic allocation replace this function, opus_realloc, and opus_free */ -#ifndef OVERRIDE_OPUS_ALLOC -static OPUS_INLINE void *opus_alloc (size_t size) -{ - return malloc(size); +/** Oac wrapper for malloc(). To do your own dynamic allocation replace this function, oac_realloc, and oac_free */ +#ifndef OVERRIDE_OAC_ALLOC +static OAC_INLINE void *oac_alloc (size_t size) { + return malloc(size); } #endif -#ifndef OVERRIDE_OPUS_REALLOC -static OPUS_INLINE void *opus_realloc (void *ptr, size_t size) -{ - return realloc(ptr, size); +#ifndef OVERRIDE_OAC_REALLOC +static OAC_INLINE void *oac_realloc (void *ptr, size_t size) { + return realloc(ptr, size); } #endif /** Used only for non-threadsafe pseudostack. If desired, this can always return the same area of memory rather than allocating a new one every time. */ -#ifndef OVERRIDE_OPUS_ALLOC_SCRATCH -static OPUS_INLINE void *opus_alloc_scratch (size_t size) -{ - /* Scratch space doesn't need to be cleared */ - return opus_alloc(size); +#ifndef OVERRIDE_OAC_ALLOC_SCRATCH +static OAC_INLINE void *oac_alloc_scratch (size_t size) { + /* Scratch space doesn't need to be cleared */ + return oac_alloc(size); } #endif -/** Opus wrapper for free(). To do your own dynamic allocation replace this function, opus_realloc, and opus_free */ -#ifndef OVERRIDE_OPUS_FREE -static OPUS_INLINE void opus_free (void *ptr) -{ - free(ptr); +/** Oac wrapper for free(). To do your own dynamic allocation replace this function, oac_realloc, and oac_free */ +#ifndef OVERRIDE_OAC_FREE +static OAC_INLINE void oac_free (void *ptr) { + free(ptr); } #endif /** Copy n elements from src to dst. The 0* term provides compile-time type checking */ -#ifndef OVERRIDE_OPUS_COPY -#define OPUS_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) +#ifndef OVERRIDE_OAC_COPY +# define OAC_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst) - (src)))) #endif /** Copy n elements from src to dst, allowing overlapping regions. The 0* term provides compile-time type checking */ -#ifndef OVERRIDE_OPUS_MOVE -#define OPUS_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) +#ifndef OVERRIDE_OAC_MOVE +# define OAC_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst) - (src)))) #endif /** Set n elements of dst to zero */ -#ifndef OVERRIDE_OPUS_CLEAR -#define OPUS_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst)))) +#ifndef OVERRIDE_OAC_CLEAR +# define OAC_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst)))) #endif /*#ifdef __GNUC__ -#pragma GCC poison printf sprintf -#pragma GCC poison malloc free realloc calloc -#endif*/ + #pragma GCC poison printf sprintf + #pragma GCC poison malloc free realloc calloc + #endif*/ #endif /* OS_SUPPORT_H */ diff --git a/celt/pitch.c b/celt/pitch.c index fe3b0bd31..d6badf737 100644 --- a/celt/pitch.c +++ b/celt/pitch.c @@ -29,10 +29,10 @@ 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" +# include "config.h" #endif #include "pitch.h" @@ -42,519 +42,491 @@ #include "mathops.h" #include "celt_lpc.h" -static void find_best_pitch(opus_val32 *xcorr, opus_val16 *y, int len, +static void oaci_find_best_pitch(oac_val32 *xcorr, oac_val16 *y, int len, int max_pitch, int *best_pitch #ifdef FIXED_POINT - , int yshift, opus_val32 maxcorr + , int yshift, oac_val32 maxcorr #endif - ) -{ - int i, j; - opus_val32 Syy=1; - opus_val16 best_num[2]; - opus_val32 best_den[2]; + ) { + int i, j; + oac_val32 Syy = 1; + oac_val16 best_num[2]; + oac_val32 best_den[2]; #ifdef FIXED_POINT - int xshift; + int xshift; - xshift = celt_ilog2(maxcorr)-14; + xshift = oaci_celt_ilog2(maxcorr) - 14; #endif - best_num[0] = -1; - best_num[1] = -1; - best_den[0] = 0; - best_den[1] = 0; - best_pitch[0] = 0; - best_pitch[1] = 1; - for (j=0;j0) - { - opus_val16 num; - opus_val32 xcorr16; - xcorr16 = EXTRACT16(VSHR32(xcorr[i], xshift)); + best_num[0] = -1; + best_num[1] = -1; + best_den[0] = 0; + best_den[1] = 0; + best_pitch[0] = 0; + best_pitch[1] = 1; + for (j = 0; j < len; j++) + Syy = ADD32(Syy, SHR32(MULT16_16(y[j], y[j]), yshift)); + for (i = 0; i < max_pitch; i++) { + if (xcorr[i] > 0) { + oac_val16 num; + oac_val32 xcorr16; + xcorr16 = EXTRACT16(VSHR32(xcorr[i], xshift)); #ifndef FIXED_POINT - /* Considering the range of xcorr16, this should avoid both underflows - and overflows (inf) when squaring xcorr16 */ - xcorr16 *= 1e-12f; + /* Considering the range of xcorr16, this should avoid both underflows + and overflows (inf) when squaring xcorr16 */ + xcorr16 *= 1e-12f; #endif - num = MULT16_16_Q15(xcorr16,xcorr16); - if (MULT16_32_Q15(num,best_den[1]) > MULT16_32_Q15(best_num[1],Syy)) - { - if (MULT16_32_Q15(num,best_den[0]) > MULT16_32_Q15(best_num[0],Syy)) - { - best_num[1] = best_num[0]; - best_den[1] = best_den[0]; - best_pitch[1] = best_pitch[0]; - best_num[0] = num; - best_den[0] = Syy; - best_pitch[0] = i; - } else { - best_num[1] = num; - best_den[1] = Syy; - best_pitch[1] = i; + num = MULT16_16_Q15(xcorr16, xcorr16); + if (MULT16_32_Q15(num, best_den[1]) > MULT16_32_Q15(best_num[1], Syy)) { + if (MULT16_32_Q15(num, best_den[0]) > MULT16_32_Q15(best_num[0], Syy)) { + best_num[1] = best_num[0]; + best_den[1] = best_den[0]; + best_pitch[1] = best_pitch[0]; + best_num[0] = num; + best_den[0] = Syy; + best_pitch[0] = i; + } else { + best_num[1] = num; + best_den[1] = Syy; + best_pitch[1] = i; + } } - } - } - Syy += SHR32(MULT16_16(y[i+len],y[i+len]),yshift) - SHR32(MULT16_16(y[i],y[i]),yshift); - Syy = MAX32(1, Syy); - } + } + Syy += SHR32(MULT16_16(y[i + len], y[i + len]), yshift) - SHR32(MULT16_16(y[i], y[i]), yshift); + Syy = MAX32(1, Syy); + } } -static void celt_fir5(opus_val16 *x, - const opus_val16 *num, - int N) -{ - int i; - opus_val16 num0, num1, num2, num3, num4; - opus_val32 mem0, mem1, mem2, mem3, mem4; - num0=num[0]; - num1=num[1]; - num2=num[2]; - num3=num[3]; - num4=num[4]; - mem0=0; - mem1=0; - mem2=0; - mem3=0; - mem4=0; - for (i=0;i0); - celt_sig_assert(((size_t)_x&3)==0); - for (i=0;i 0); + celt_sig_assert(((size_t)_x&3) == 0); + for (i = 0; i < max_pitch - 3; i += 4) { + oac_val32 sum[4] = {0, 0, 0, 0}; +# if defined(OAC_CHECK_ASM) && defined(FIXED_POINT) + { + oac_val32 sum_c[4] = {0, 0, 0, 0}; + oaci_xcorr_kernel_c(_x, _y + i, sum_c, len); +# endif + oaci_xcorr_kernel(_x, _y + i, sum, len, arch); +# if defined(OAC_CHECK_ASM) && defined(FIXED_POINT) + celt_assert(memcmp(sum, sum_c, sizeof(sum)) == 0); + } +# endif + xcorr[i] = sum[0]; + xcorr[i + 1] = sum[1]; + xcorr[i + 2] = sum[2]; + xcorr[i + 3] = sum[3]; +# ifdef FIXED_POINT + sum[0] = MAX32(sum[0], sum[1]); + sum[2] = MAX32(sum[2], sum[3]); + sum[0] = MAX32(sum[0], sum[2]); + maxcorr = MAX32(maxcorr, sum[0]); +# endif + } + /* In case max_pitch isn't a multiple of 4, do non-unrolled version. */ + for (; i < max_pitch; i++) { + oac_val32 sum; + sum = oaci_celt_inner_prod(_x, _y + i, len, arch); + xcorr[i] = sum; +# ifdef FIXED_POINT + maxcorr = MAX32(maxcorr, sum); +# endif + } +# ifdef FIXED_POINT + return maxcorr; +# endif #endif } -void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTRICT y, - int len, int max_pitch, int *pitch, int arch) -{ - int i, j; - int lag; - int best_pitch[2]={0,0}; - VARDECL(opus_val16, x_lp4); - VARDECL(opus_val16, y_lp4); - VARDECL(opus_val32, xcorr); +void oaci_pitch_search(const oac_val16 * OAC_RESTRICT x_lp, oac_val16 * OAC_RESTRICT y, + int len, int max_pitch, int *pitch, int arch) { + int i, j; + int lag; + int best_pitch[2] = {0, 0}; + VARDECL(oac_val16, x_lp4); + VARDECL(oac_val16, y_lp4); + VARDECL(oac_val32, xcorr); #ifdef FIXED_POINT - opus_val32 maxcorr; - opus_val32 xmax, ymax; - int shift=0; + oac_val32 maxcorr; + oac_val32 xmax, ymax; + int shift = 0; #endif - int offset; + int offset; - SAVE_STACK; + SAVE_STACK; - celt_assert(len>0); - celt_assert(max_pitch>0); - lag = len+max_pitch; + celt_assert(len > 0); + celt_assert(max_pitch > 0); + lag = len + max_pitch; - ALLOC(x_lp4, len>>2, opus_val16); - ALLOC(y_lp4, lag>>2, opus_val16); - ALLOC(xcorr, max_pitch>>1, opus_val32); + ALLOC(x_lp4, len>>2, oac_val16); + ALLOC(y_lp4, lag>>2, oac_val16); + ALLOC(xcorr, max_pitch>>1, oac_val32); - /* Downsample by 2 again */ - for (j=0;j>2;j++) - x_lp4[j] = x_lp[2*j]; - for (j=0;j>2;j++) - y_lp4[j] = y[2*j]; + /* Downsample by 2 again */ + for (j = 0; j < len>>2; j++) + x_lp4[j] = x_lp[2*j]; + for (j = 0; j < lag>>2; j++) + y_lp4[j] = y[2*j]; #ifdef FIXED_POINT - xmax = celt_maxabs16(x_lp4, len>>2); - ymax = celt_maxabs16(y_lp4, lag>>2); - shift = celt_ilog2(MAX32(1, MAX32(xmax, ymax))) - 14 + celt_ilog2(len)/2; - if (shift>0) - { - for (j=0;j>2;j++) - x_lp4[j] = SHR16(x_lp4[j], shift); - for (j=0;j>2;j++) - y_lp4[j] = SHR16(y_lp4[j], shift); - /* Use double the shift for a MAC */ - shift *= 2; - } else { - shift = 0; - } + xmax = oaci_celt_maxabs16(x_lp4, len>>2); + ymax = oaci_celt_maxabs16(y_lp4, lag>>2); + shift = oaci_celt_ilog2(MAX32(1, MAX32(xmax, ymax))) - 14 + oaci_celt_ilog2(len)/2; + if (shift > 0) { + for (j = 0; j < len>>2; j++) + x_lp4[j] = SHR16(x_lp4[j], shift); + for (j = 0; j < lag>>2; j++) + y_lp4[j] = SHR16(y_lp4[j], shift); + /* Use double the shift for a MAC */ + shift *= 2; + } else { + shift = 0; + } #endif - /* Coarse search with 4x decimation */ + /* Coarse search with 4x decimation */ #ifdef FIXED_POINT - maxcorr = + maxcorr = #endif - celt_pitch_xcorr(x_lp4, y_lp4, xcorr, len>>2, max_pitch>>2, arch); + oaci_celt_pitch_xcorr(x_lp4, y_lp4, xcorr, len>>2, max_pitch>>2, arch); - find_best_pitch(xcorr, y_lp4, len>>2, max_pitch>>2, best_pitch + oaci_find_best_pitch(xcorr, y_lp4, len>>2, max_pitch>>2, best_pitch #ifdef FIXED_POINT - , 0, maxcorr + , 0, maxcorr #endif - ); + ); - /* Finer search with 2x decimation */ + /* Finer search with 2x decimation */ #ifdef FIXED_POINT - maxcorr=1; + maxcorr = 1; #endif - for (i=0;i>1;i++) - { - opus_val32 sum; - xcorr[i] = 0; - if (abs(i-2*best_pitch[0])>2 && abs(i-2*best_pitch[1])>2) - continue; + for (i = 0; i < max_pitch>>1; i++) { + oac_val32 sum; + xcorr[i] = 0; + if (abs(i - 2*best_pitch[0]) > 2 && abs(i - 2*best_pitch[1]) > 2) + continue; #ifdef FIXED_POINT - sum = 0; - for (j=0;j>1;j++) - sum += SHR32(MULT16_16(x_lp[j],y[i+j]), shift); + sum = 0; + for (j = 0; j < len>>1; j++) + sum += SHR32(MULT16_16(x_lp[j], y[i + j]), shift); #else - sum = celt_inner_prod(x_lp, y+i, len>>1, arch); + sum = oaci_celt_inner_prod(x_lp, y + i, len>>1, arch); #endif - xcorr[i] = MAX32(-1, sum); + xcorr[i] = MAX32(-1, sum); #ifdef FIXED_POINT - maxcorr = MAX32(maxcorr, sum); + maxcorr = MAX32(maxcorr, sum); #endif - } - find_best_pitch(xcorr, y, len>>1, max_pitch>>1, best_pitch + } + oaci_find_best_pitch(xcorr, y, len>>1, max_pitch>>1, best_pitch #ifdef FIXED_POINT - , shift+1, maxcorr + , shift + 1, maxcorr #endif - ); - - /* Refine by pseudo-interpolation */ - if (best_pitch[0]>0 && best_pitch[0]<(max_pitch>>1)-1) - { - opus_val32 a, b, c; - a = xcorr[best_pitch[0]-1]; - b = xcorr[best_pitch[0]]; - c = xcorr[best_pitch[0]+1]; - if ((c-a) > MULT16_32_Q15(QCONST16(.7f,15),b-a)) - offset = 1; - else if ((a-c) > MULT16_32_Q15(QCONST16(.7f,15),b-c)) - offset = -1; - else - offset = 0; - } else { - offset = 0; - } - *pitch = 2*best_pitch[0]-offset; - - RESTORE_STACK; + ); + + /* Refine by pseudo-interpolation */ + if (best_pitch[0] > 0 && best_pitch[0] < (max_pitch>>1) - 1) { + oac_val32 a, b, c; + a = xcorr[best_pitch[0] - 1]; + b = xcorr[best_pitch[0]]; + c = xcorr[best_pitch[0] + 1]; + if ((c - a) > MULT16_32_Q15(QCONST16(.7f, 15), b - a)) + offset = 1; + else if ((a - c) > MULT16_32_Q15(QCONST16(.7f, 15), b - c)) + offset = -1; + else + offset = 0; + } else { + offset = 0; + } + *pitch = 2*best_pitch[0] - offset; + + RESTORE_STACK; } #ifdef FIXED_POINT -static opus_val16 compute_pitch_gain(opus_val32 xy, opus_val32 xx, opus_val32 yy) -{ - opus_val32 x2y2; - int sx, sy, shift; - opus_val32 g; - opus_val16 den; - if (xy == 0 || xx == 0 || yy == 0) - return 0; - sx = celt_ilog2(xx)-14; - sy = celt_ilog2(yy)-14; - shift = sx + sy; - x2y2 = SHR32(MULT16_16(VSHR32(xx, sx), VSHR32(yy, sy)), 14); - if (shift & 1) { - if (x2y2 < 32768) - { - x2y2 <<= 1; - shift--; - } else { - x2y2 >>= 1; - shift++; - } - } - den = celt_rsqrt_norm(x2y2); - g = MULT16_32_Q15(den, xy); - g = VSHR32(g, (shift>>1)-1); - return EXTRACT16(MAX32(-Q15ONE, MIN32(g, Q15ONE))); +static oac_val16 oaci_compute_pitch_gain(oac_val32 xy, oac_val32 xx, oac_val32 yy) { + oac_val32 x2y2; + int sx, sy, shift; + oac_val32 g; + oac_val16 den; + if (xy == 0 || xx == 0 || yy == 0) + return 0; + sx = oaci_celt_ilog2(xx) - 14; + sy = oaci_celt_ilog2(yy) - 14; + shift = sx + sy; + x2y2 = SHR32(MULT16_16(VSHR32(xx, sx), VSHR32(yy, sy)), 14); + if (shift&1) { + if (x2y2 < 32768) { + x2y2 <<= 1; + shift--; + } else { + x2y2 >>= 1; + shift++; + } + } + den = oaci_celt_rsqrt_norm(x2y2); + g = MULT16_32_Q15(den, xy); + g = VSHR32(g, (shift>>1) - 1); + return EXTRACT16(MAX32(-Q15ONE, MIN32(g, Q15ONE))); } #else -static opus_val16 compute_pitch_gain(opus_val32 xy, opus_val32 xx, opus_val32 yy) -{ - return xy/celt_sqrt(1+xx*yy); +static oac_val16 oaci_compute_pitch_gain(oac_val32 xy, oac_val32 xx, oac_val32 yy) { + return xy/oaci_celt_sqrt(1 + xx*yy); } #endif static const int second_check[16] = {0, 0, 3, 2, 3, 2, 5, 2, 3, 2, 3, 2, 5, 2, 3, 2}; -opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, - int N, int *T0_, int prev_period, opus_val16 prev_gain, int arch) -{ - int k, i, T, T0; - opus_val16 g, g0; - opus_val16 pg; - opus_val32 xy,xx,yy,xy2; - opus_val32 xcorr[3]; - opus_val32 best_xy, best_yy; - int offset; - int minperiod0; - VARDECL(opus_val32, yy_lookup); - SAVE_STACK; - - minperiod0 = minperiod; - maxperiod /= 2; - minperiod /= 2; - *T0_ /= 2; - prev_period /= 2; - N /= 2; - x += maxperiod; - if (*T0_>=maxperiod) - *T0_=maxperiod-1; - - T = T0 = *T0_; - ALLOC(yy_lookup, maxperiod+1, opus_val32); - dual_inner_prod(x, x, x-T0, N, &xx, &xy, arch); - yy_lookup[0] = xx; - yy=xx; - for (i=1;i<=maxperiod;i++) - { - yy = yy+MULT16_16(x[-i],x[-i])-MULT16_16(x[N-i],x[N-i]); - yy_lookup[i] = MAX32(0, yy); - } - yy = yy_lookup[T0]; - best_xy = xy; - best_yy = yy; - g = g0 = compute_pitch_gain(xy, xx, yy); - /* Look for any pitch at T/k */ - for (k=2;k<=15;k++) - { - int T1, T1b; - opus_val16 g1; - opus_val16 cont=0; - opus_val16 thresh; - T1 = celt_udiv(2*T0+k, 2*k); - if (T1 < minperiod) - break; - /* Look for another strong correlation at T1b */ - if (k==2) - { - if (T1+T0>maxperiod) - T1b = T0; - else - T1b = T0+T1; - } else - { - T1b = celt_udiv(2*second_check[k]*T0+k, 2*k); - } - dual_inner_prod(x, &x[-T1], &x[-T1b], N, &xy, &xy2, arch); - xy = HALF32(xy + xy2); - yy = HALF32(yy_lookup[T1] + yy_lookup[T1b]); - g1 = compute_pitch_gain(xy, xx, yy); - if (abs(T1-prev_period)<=1) - cont = prev_gain; - else if (abs(T1-prev_period)<=2 && 5*k*k < T0) - cont = HALF16(prev_gain); - else - cont = 0; - thresh = MAX16(QCONST16(.3f,15), MULT16_16_Q15(QCONST16(.7f,15),g0)-cont); - /* Bias against very high pitch (very short period) to avoid false-positives - due to short-term correlation */ - if (T1<3*minperiod) - thresh = MAX16(QCONST16(.4f,15), MULT16_16_Q15(QCONST16(.85f,15),g0)-cont); - else if (T1<2*minperiod) - thresh = MAX16(QCONST16(.5f,15), MULT16_16_Q15(QCONST16(.9f,15),g0)-cont); - if (g1 > thresh) - { - best_xy = xy; - best_yy = yy; - T = T1; - g = g1; - } - } - best_xy = MAX32(0, best_xy); - if (best_yy <= best_xy) - pg = Q15ONE; - else - pg = SHR32(frac_div32(best_xy,best_yy+1),16); - - for (k=0;k<3;k++) - xcorr[k] = celt_inner_prod(x, x-(T+k-1), N, arch); - if ((xcorr[2]-xcorr[0]) > MULT16_32_Q15(QCONST16(.7f,15),xcorr[1]-xcorr[0])) - offset = 1; - else if ((xcorr[0]-xcorr[2]) > MULT16_32_Q15(QCONST16(.7f,15),xcorr[1]-xcorr[2])) - offset = -1; - else - offset = 0; - if (pg > g) - pg = g; - *T0_ = 2*T+offset; - - if (*T0_= maxperiod) + *T0_ = maxperiod - 1; + + T = T0 = *T0_; + ALLOC(yy_lookup, maxperiod + 1, oac_val32); + oaci_dual_inner_prod(x, x, x - T0, N, &xx, &xy, arch); + yy_lookup[0] = xx; + yy = xx; + for (i = 1; i <= maxperiod; i++) { + yy = yy + MULT16_16(x[-i], x[-i]) - MULT16_16(x[N - i], x[N - i]); + yy_lookup[i] = MAX32(0, yy); + } + yy = yy_lookup[T0]; + best_xy = xy; + best_yy = yy; + g = g0 = oaci_compute_pitch_gain(xy, xx, yy); + /* Look for any pitch at T/k */ + for (k = 2; k <= 15; k++) { + int T1, T1b; + oac_val16 g1; + oac_val16 cont = 0; + oac_val16 thresh; + T1 = oaci_celt_udiv(2*T0 + k, 2*k); + if (T1 < minperiod) + break; + /* Look for another strong correlation at T1b */ + if (k == 2) { + if (T1 + T0 > maxperiod) + T1b = T0; + else + T1b = T0 + T1; + } else { + T1b = oaci_celt_udiv(2*second_check[k]*T0 + k, 2*k); + } + oaci_dual_inner_prod(x, &x[-T1], &x[-T1b], N, &xy, &xy2, arch); + xy = HALF32(xy + xy2); + yy = HALF32(yy_lookup[T1] + yy_lookup[T1b]); + g1 = oaci_compute_pitch_gain(xy, xx, yy); + if (abs(T1 - prev_period) <= 1) + cont = prev_gain; + else if (abs(T1 - prev_period) <= 2 && 5*k*k < T0) + cont = HALF16(prev_gain); + else + cont = 0; + thresh = MAX16(QCONST16(.3f, 15), MULT16_16_Q15(QCONST16(.7f, 15), g0) - cont); + /* Bias against very high pitch (very short period) to avoid false-positives + due to short-term correlation */ + if (T1 < 3*minperiod) + thresh = MAX16(QCONST16(.4f, 15), MULT16_16_Q15(QCONST16(.85f, 15), g0) - cont); + else if (T1 < 2*minperiod) + thresh = MAX16(QCONST16(.5f, 15), MULT16_16_Q15(QCONST16(.9f, 15), g0) - cont); + if (g1 > thresh) { + best_xy = xy; + best_yy = yy; + T = T1; + g = g1; + } + } + best_xy = MAX32(0, best_xy); + if (best_yy <= best_xy) + pg = Q15ONE; + else + pg = SHR32(oaci_frac_div32(best_xy, best_yy + 1), 16); + + for (k = 0; k < 3; k++) + xcorr[k] = oaci_celt_inner_prod(x, x - (T + k - 1), N, arch); + if ((xcorr[2] - xcorr[0]) > MULT16_32_Q15(QCONST16(.7f, 15), xcorr[1] - xcorr[0])) + offset = 1; + else if ((xcorr[0] - xcorr[2]) > MULT16_32_Q15(QCONST16(.7f, 15), xcorr[1] - xcorr[2])) + offset = -1; + else + offset = 0; + if (pg > g) + pg = g; + *T0_ = 2*T + offset; + + if (*T0_ < minperiod0) + *T0_ = minperiod0; + RESTORE_STACK; + return pg; } diff --git a/celt/pitch.h b/celt/pitch.h index e5eecdd9a..3f939e7b4 100644 --- a/celt/pitch.h +++ b/celt/pitch.h @@ -29,7 +29,7 @@ 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. -*/ + */ #ifndef PITCH_H #define PITCH_H @@ -37,166 +37,158 @@ #include "modes.h" #include "cpu_support.h" -#if (defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT)) \ - || ((defined(OPUS_X86_MAY_HAVE_SSE4_1) || defined(OPUS_X86_MAY_HAVE_SSE2)) && defined(FIXED_POINT)) -#include "x86/pitch_sse.h" +#if (defined(OAC_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT)) \ + || ((defined(OAC_X86_MAY_HAVE_SSE4_1) || defined(OAC_X86_MAY_HAVE_SSE2)) && defined(FIXED_POINT)) +# include "x86/pitch_sse.h" #endif #if defined(FIXED_POINT) && defined(__mips) -#include "mips/pitch_mipsr1.h" +# include "mips/pitch_mipsr1.h" #endif -#if (defined(OPUS_ARM_ASM) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR)) +#if (defined(OAC_ARM_ASM) || defined(OAC_ARM_MAY_HAVE_NEON_INTR)) # include "arm/pitch_arm.h" #endif -void pitch_downsample(celt_sig * OPUS_RESTRICT x[], opus_val16 * OPUS_RESTRICT x_lp, - int len, int C, int factor, int arch); +void oaci_pitch_downsample(celt_sig * OAC_RESTRICT x[], oac_val16 * OAC_RESTRICT x_lp, + int len, int C, int factor, int arch); -void pitch_search(const opus_val16 * OPUS_RESTRICT x_lp, opus_val16 * OPUS_RESTRICT y, - int len, int max_pitch, int *pitch, int arch); +void oaci_pitch_search(const oac_val16 * OAC_RESTRICT x_lp, oac_val16 * OAC_RESTRICT y, + int len, int max_pitch, int *pitch, int arch); -opus_val16 remove_doubling(opus_val16 *x, int maxperiod, int minperiod, - int N, int *T0, int prev_period, opus_val16 prev_gain, int arch); +oac_val16 oaci_remove_doubling(oac_val16 *x, int maxperiod, int minperiod, + int N, int *T0, int prev_period, oac_val16 prev_gain, int arch); /* OPT: This is the kernel you really want to optimize. It gets used a lot by the prefilter and by the PLC. */ -static OPUS_INLINE void xcorr_kernel_c(const opus_val16 * x, const opus_val16 * y, opus_val32 sum[4], int len) -{ - int j; - opus_val16 y_0, y_1, y_2, y_3; - celt_assert(len>=3); - y_3=0; /* gcc doesn't realize that y_3 can't be used uninitialized */ - y_0=*y++; - y_1=*y++; - y_2=*y++; - for (j=0;j= 3); + y_3 = 0; /* gcc doesn't realize that y_3 can't be used uninitialized */ + y_0 = *y++; + y_1 = *y++; + y_2 = *y++; + for (j = 0; j < len - 3; j += 4) { + oac_val16 tmp; + tmp = *x++; + y_3 = *y++; + sum[0] = MAC16_16(sum[0], tmp, y_0); + sum[1] = MAC16_16(sum[1], tmp, y_1); + sum[2] = MAC16_16(sum[2], tmp, y_2); + sum[3] = MAC16_16(sum[3], tmp, y_3); + tmp = *x++; + y_0 = *y++; + sum[0] = MAC16_16(sum[0], tmp, y_1); + sum[1] = MAC16_16(sum[1], tmp, y_2); + sum[2] = MAC16_16(sum[2], tmp, y_3); + sum[3] = MAC16_16(sum[3], tmp, y_0); + tmp = *x++; + y_1 = *y++; + sum[0] = MAC16_16(sum[0], tmp, y_2); + sum[1] = MAC16_16(sum[1], tmp, y_3); + sum[2] = MAC16_16(sum[2], tmp, y_0); + sum[3] = MAC16_16(sum[3], tmp, y_1); + tmp = *x++; + y_2 = *y++; + sum[0] = MAC16_16(sum[0], tmp, y_3); + sum[1] = MAC16_16(sum[1], tmp, y_0); + sum[2] = MAC16_16(sum[2], tmp, y_1); + sum[3] = MAC16_16(sum[3], tmp, y_2); + } + if (j++ < len) { + oac_val16 tmp = *x++; + y_3 = *y++; + sum[0] = MAC16_16(sum[0], tmp, y_0); + sum[1] = MAC16_16(sum[1], tmp, y_1); + sum[2] = MAC16_16(sum[2], tmp, y_2); + sum[3] = MAC16_16(sum[3], tmp, y_3); + } + if (j++ < len) { + oac_val16 tmp = *x++; + y_0 = *y++; + sum[0] = MAC16_16(sum[0], tmp, y_1); + sum[1] = MAC16_16(sum[1], tmp, y_2); + sum[2] = MAC16_16(sum[2], tmp, y_3); + sum[3] = MAC16_16(sum[3], tmp, y_0); + } + if (j < len) { + oac_val16 tmp = *x++; + y_1 = *y++; + sum[0] = MAC16_16(sum[0], tmp, y_2); + sum[1] = MAC16_16(sum[1], tmp, y_3); + sum[2] = MAC16_16(sum[2], tmp, y_0); + sum[3] = MAC16_16(sum[3], tmp, y_1); + } } #ifndef OVERRIDE_XCORR_KERNEL -#define xcorr_kernel(x, y, sum, len, arch) \ - ((void)(arch),xcorr_kernel_c(x, y, sum, len)) +# define oaci_xcorr_kernel(x, y, sum, len, arch) \ + ((void)(arch), oaci_xcorr_kernel_c(x, y, sum, len)) #endif /* OVERRIDE_XCORR_KERNEL */ -static OPUS_INLINE void dual_inner_prod_c(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2) -{ - int i; - opus_val32 xy01=0; - opus_val32 xy02=0; - for (i=0;inbEBands]; - oldE = MAXG(-GCONST(9.f), oldEBands[i+c*m->nbEBands]); +static int oaci_quant_coarse_energy_impl(const CELTMode *m, int start, int end, + const celt_glog *eBands, celt_glog *oldEBands, + oac_int32 budget, oac_int32 tell, + const unsigned char *prob_model, celt_glog *error, ec_enc *enc, + int C, int LM, int intra, celt_glog max_decay, int lfe) { + int i, c; + int badness = 0; + oac_val32 prev[2] = {0, 0}; + oac_val16 coef; + oac_val16 beta; + + if (tell + 3 <= budget) + oaci_ec_enc_bit_logp(enc, intra, 3); + if (intra) { + coef = 0; + beta = beta_intra; + } else { + beta = beta_coef[LM]; + coef = pred_coef[LM]; + } + + /* Encode at a fixed coarse resolution */ + for (i = start; i < end; i++) { + c = 0; + do { + int bits_left; + int qi, qi0; + oac_val32 q; + celt_glog x; + oac_val32 f, tmp; + celt_glog oldE; + celt_glog decay_bound; + x = eBands[i + c*m->nbEBands]; + oldE = MAXG(-GCONST(9.f), oldEBands[i + c*m->nbEBands]); #ifdef FIXED_POINT - f = x - MULT16_32_Q15(coef,oldE) - prev[c]; - /* Rounding to nearest integer here is really important! */ - qi = (f+QCONST32(.5f,DB_SHIFT))>>DB_SHIFT; - decay_bound = MAXG(-GCONST(28.f), SUB32((opus_val32)oldEBands[i+c*m->nbEBands],max_decay)); + f = x - MULT16_32_Q15(coef, oldE) - prev[c]; + /* Rounding to nearest integer here is really important! */ + qi = (f + QCONST32(.5f, DB_SHIFT))>>DB_SHIFT; + decay_bound = MAXG(-GCONST(28.f), SUB32((oac_val32)oldEBands[i + c*m->nbEBands], max_decay)); #else - f = x-coef*oldE-prev[c]; - /* Rounding to nearest integer here is really important! */ - qi = (int)floor(.5f+f); - decay_bound = MAXG(-GCONST(28.f), oldEBands[i+c*m->nbEBands]) - max_decay; + f = x - coef*oldE - prev[c]; + /* Rounding to nearest integer here is really important! */ + qi = (int)floor(.5f + f); + decay_bound = MAXG(-GCONST(28.f), oldEBands[i + c*m->nbEBands]) - max_decay; #endif - /* Prevent the energy from going down too quickly (e.g. for bands - that have just one bin) */ - if (qi < 0 && x < decay_bound) - { - qi += (int)SHR32(SUB32(decay_bound,x), DB_SHIFT); - if (qi > 0) - qi = 0; - } - qi0 = qi; - /* If we don't have enough bits to encode all the energy, just assume - something safe. */ - tell = ec_tell(enc); - bits_left = budget-tell-3*C*(end-i); - if (i!=start && bits_left < 30) - { - if (bits_left < 24) - qi = IMIN(1, qi); - if (bits_left < 16) - qi = IMAX(-1, qi); - } - if (lfe && i>=2) - qi = IMIN(qi, 0); - if (budget-tell >= 15) - { - int pi; - pi = 2*IMIN(i,20); - ec_laplace_encode(enc, &qi, - prob_model[pi]<<7, prob_model[pi+1]<<6); - } - else if(budget-tell >= 2) - { - qi = IMAX(-1, IMIN(qi, 1)); - ec_enc_icdf(enc, 2*qi^-(qi<0), small_energy_icdf, 2); - } - else if(budget-tell >= 1) - { - qi = IMIN(0, qi); - ec_enc_bit_logp(enc, -qi, 1); - } - else - qi = -1; - error[i+c*m->nbEBands] = f - SHL32(qi,DB_SHIFT); - badness += abs(qi0-qi); - q = (opus_val32)SHL32(EXTEND32(qi),DB_SHIFT); - - tmp = MULT16_32_Q15(coef,oldE) + prev[c] + q; + /* Prevent the energy from going down too quickly (e.g. for bands + that have just one bin) */ + if (qi < 0 && x < decay_bound) { + qi += (int)SHR32(SUB32(decay_bound, x), DB_SHIFT); + if (qi > 0) + qi = 0; + } + qi0 = qi; + /* If we don't have enough bits to encode all the energy, just assume + something safe. */ + tell = oaci_ec_tell(enc); + bits_left = budget - tell - 3*C*(end - i); + if (i != start && bits_left < 30) { + if (bits_left < 24) + qi = IMIN(1, qi); + if (bits_left < 16) + qi = IMAX(-1, qi); + } + if (lfe && i >= 2) + qi = IMIN(qi, 0); + if (budget - tell >= 15) { + int pi; + pi = 2*IMIN(i, 20); + oaci_ec_laplace_encode(enc, &qi, + prob_model[pi]<<7, prob_model[pi + 1]<<6); + } else if (budget - tell >= 2) { + qi = IMAX(-1, IMIN(qi, 1)); + oaci_ec_enc_icdf(enc, 2*qi^-(qi < 0), small_energy_icdf, 2); + } else if (budget - tell >= 1) { + qi = IMIN(0, qi); + oaci_ec_enc_bit_logp(enc, -qi, 1); + } else + qi = -1; + error[i + c*m->nbEBands] = f - SHL32(qi, DB_SHIFT); + badness += abs(qi0 - qi); + q = (oac_val32)SHL32(EXTEND32(qi), DB_SHIFT); + + tmp = MULT16_32_Q15(coef, oldE) + prev[c] + q; #ifdef FIXED_POINT - tmp = MAX32(-GCONST(28.f), tmp); + tmp = MAX32(-GCONST(28.f), tmp); #endif - oldEBands[i+c*m->nbEBands] = tmp; - prev[c] = prev[c] + q - MULT16_32_Q15(beta,q); - } while (++c < C); - } - return lfe ? 0 : badness; + oldEBands[i + c*m->nbEBands] = tmp; + prev[c] = prev[c] + q - MULT16_32_Q15(beta, q); + } while (++c < C); + } + return lfe ? 0 : badness; } -void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, - const celt_glog *eBands, celt_glog *oldEBands, opus_uint32 budget, - celt_glog *error, ec_enc *enc, int C, int LM, int nbAvailableBytes, - int force_intra, opus_val32 *delayedIntra, int two_pass, int loss_rate, int lfe) -{ - int intra; - celt_glog max_decay; - VARDECL(celt_glog, oldEBands_intra); - VARDECL(celt_glog, error_intra); - ec_enc enc_start_state; - opus_uint32 tell; - int badness1=0; - opus_int32 intra_bias; - opus_val32 new_distortion; - SAVE_STACK; - - intra = force_intra || (!two_pass && *delayedIntra>2*C*(end-start) && nbAvailableBytes > (end-start)*C); - intra_bias = (opus_int32)((budget**delayedIntra*loss_rate)/(C*512)); - new_distortion = loss_distortion(eBands, oldEBands, start, effEnd, m->nbEBands, C); - - tell = ec_tell(enc); - if (tell+3 > budget) - two_pass = intra = 0; - - max_decay = GCONST(16.f); - if (end-start>10) - { +void oaci_quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, + const celt_glog *eBands, celt_glog *oldEBands, oac_uint32 budget, + celt_glog *error, ec_enc *enc, int C, int LM, int nbAvailableBytes, + int force_intra, oac_val32 *delayedIntra, int two_pass, int loss_rate, int lfe) { + int intra; + celt_glog max_decay; + VARDECL(celt_glog, oldEBands_intra); + VARDECL(celt_glog, error_intra); + ec_enc enc_start_state; + oac_uint32 tell; + int badness1 = 0; + oac_int32 intra_bias; + oac_val32 new_distortion; + SAVE_STACK; + + intra = force_intra || (!two_pass && *delayedIntra > 2*C*(end - start) && nbAvailableBytes > (end - start)*C); + intra_bias = (oac_int32)((budget**delayedIntra*loss_rate)/(C*512)); + new_distortion = oaci_loss_distortion(eBands, oldEBands, start, effEnd, m->nbEBands, C); + + tell = oaci_ec_tell(enc); + if (tell + 3 > budget) + two_pass = intra = 0; + + max_decay = GCONST(16.f); + if (end - start > 10) { #ifdef FIXED_POINT - max_decay = SHL32(MIN32(SHR32(max_decay,DB_SHIFT-3), EXTEND32(nbAvailableBytes)),DB_SHIFT-3); + max_decay = SHL32(MIN32(SHR32(max_decay, DB_SHIFT - 3), EXTEND32(nbAvailableBytes)), DB_SHIFT - 3); #else - max_decay = MIN32(max_decay, .125f*nbAvailableBytes); + max_decay = MIN32(max_decay, .125f*nbAvailableBytes); #endif - } - if (lfe) - max_decay = GCONST(3.f); - enc_start_state = *enc; - - ALLOC(oldEBands_intra, C*m->nbEBands, celt_glog); - ALLOC(error_intra, C*m->nbEBands, celt_glog); - OPUS_COPY(oldEBands_intra, oldEBands, C*m->nbEBands); - - if (two_pass || intra) - { - badness1 = quant_coarse_energy_impl(m, start, end, eBands, oldEBands_intra, budget, + } + if (lfe) + max_decay = GCONST(3.f); + enc_start_state = *enc; + + ALLOC(oldEBands_intra, C*m->nbEBands, celt_glog); + ALLOC(error_intra, C*m->nbEBands, celt_glog); + OAC_COPY(oldEBands_intra, oldEBands, C*m->nbEBands); + + if (two_pass || intra) { + badness1 = oaci_quant_coarse_energy_impl(m, start, end, eBands, oldEBands_intra, budget, tell, e_prob_model[LM][1], error_intra, enc, C, LM, 1, max_decay, lfe); - } - - if (!intra) - { - unsigned char *intra_buf; - ec_enc enc_intra_state; - opus_int32 tell_intra; - opus_uint32 nstart_bytes; - opus_uint32 nintra_bytes; - opus_uint32 save_bytes; - int badness2; - VARDECL(unsigned char, intra_bits); - - tell_intra = ec_tell_frac(enc); - - enc_intra_state = *enc; - - nstart_bytes = ec_range_bytes(&enc_start_state); - nintra_bytes = ec_range_bytes(&enc_intra_state); - intra_buf = ec_get_buffer(&enc_intra_state) + nstart_bytes; - save_bytes = nintra_bytes-nstart_bytes; - if (save_bytes == 0) - save_bytes = ALLOC_NONE; - ALLOC(intra_bits, save_bytes, unsigned char); - /* Copy bits from intra bit-stream */ - OPUS_COPY(intra_bits, intra_buf, nintra_bytes - nstart_bytes); - - *enc = enc_start_state; - - badness2 = quant_coarse_energy_impl(m, start, end, eBands, oldEBands, budget, + } + + if (!intra) { + unsigned char *intra_buf; + ec_enc enc_intra_state; + oac_int32 tell_intra; + oac_uint32 nstart_bytes; + oac_uint32 nintra_bytes; + oac_uint32 save_bytes; + int badness2; + VARDECL(unsigned char, intra_bits); + + tell_intra = oaci_ec_tell_frac(enc); + + enc_intra_state = *enc; + + nstart_bytes = oaci_ec_range_bytes(&enc_start_state); + nintra_bytes = oaci_ec_range_bytes(&enc_intra_state); + intra_buf = oaci_ec_get_buffer(&enc_intra_state) + nstart_bytes; + save_bytes = nintra_bytes - nstart_bytes; + if (save_bytes == 0) + save_bytes = ALLOC_NONE; + ALLOC(intra_bits, save_bytes, unsigned char); + /* Copy bits from intra bit-stream */ + OAC_COPY(intra_bits, intra_buf, nintra_bytes - nstart_bytes); + + *enc = enc_start_state; + + badness2 = oaci_quant_coarse_energy_impl(m, start, end, eBands, oldEBands, budget, tell, e_prob_model[LM][intra], error, enc, C, LM, 0, max_decay, lfe); - if (two_pass && (badness1 < badness2 || (badness1 == badness2 && ((opus_int32)ec_tell_frac(enc))+intra_bias > tell_intra))) - { - *enc = enc_intra_state; - /* Copy intra bits to bit-stream */ - OPUS_COPY(intra_buf, intra_bits, nintra_bytes - nstart_bytes); - OPUS_COPY(oldEBands, oldEBands_intra, C*m->nbEBands); - OPUS_COPY(error, error_intra, C*m->nbEBands); - intra = 1; - } - } else { - OPUS_COPY(oldEBands, oldEBands_intra, C*m->nbEBands); - OPUS_COPY(error, error_intra, C*m->nbEBands); - } - - if (intra) - *delayedIntra = new_distortion; - else - *delayedIntra = ADD32(MULT16_32_Q15(MULT16_16_Q15(pred_coef[LM], pred_coef[LM]),*delayedIntra), + if (two_pass + && (badness1 < badness2 + || (badness1 == badness2 && ((oac_int32)oaci_ec_tell_frac(enc)) + intra_bias > tell_intra))) { + *enc = enc_intra_state; + /* Copy intra bits to bit-stream */ + OAC_COPY(intra_buf, intra_bits, nintra_bytes - nstart_bytes); + OAC_COPY(oldEBands, oldEBands_intra, C*m->nbEBands); + OAC_COPY(error, error_intra, C*m->nbEBands); + intra = 1; + } + } else { + OAC_COPY(oldEBands, oldEBands_intra, C*m->nbEBands); + OAC_COPY(error, error_intra, C*m->nbEBands); + } + + if (intra) + *delayedIntra = new_distortion; + else + *delayedIntra = ADD32(MULT16_32_Q15(MULT16_16_Q15(pred_coef[LM], pred_coef[LM]), *delayedIntra), new_distortion); - RESTORE_STACK; + RESTORE_STACK; } -void quant_fine_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, celt_glog *error, int *prev_quant, int *extra_quant, ec_enc *enc, int C) -{ - int i, c; - /* Encode finer resolution */ - for (i=start;i (opus_int32)enc->storage*8) continue; - prev = (prev_quant!=NULL) ? prev_quant[i] : 0; - c=0; - do { - int q2; - celt_glog offset; +void oaci_quant_fine_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, celt_glog *error, int *prev_quant, + int *extra_quant, ec_enc *enc, int C) { + int i, c; + /* Encode finer resolution */ + for (i = start; i < end; i++) { + oac_int16 extra, prev; + extra = 1< (oac_int32)enc->storage*8) continue; + prev = (prev_quant != NULL) ? prev_quant[i] : 0; + c = 0; + do { + int q2; + celt_glog offset; #ifdef FIXED_POINT - /* Has to be without rounding */ - q2 = VSHR32(ADD32(error[i+c*m->nbEBands], SHR32(GCONST(.5f), prev)), DB_SHIFT-extra_quant[i]-prev); + /* Has to be without rounding */ + q2 = VSHR32(ADD32(error[i + c*m->nbEBands], SHR32(GCONST(.5f), prev)), DB_SHIFT - extra_quant[i] - prev); #else - q2 = (int)floor((error[i+c*m->nbEBands]*(1<nbEBands]*(1< extra-1) - q2 = extra-1; - if (q2<0) - q2 = 0; - ec_enc_bits(enc, q2, extra_quant[i]); + if (q2 > extra - 1) + q2 = extra - 1; + if (q2 < 0) + q2 = 0; + oaci_ec_enc_bits(enc, q2, extra_quant[i]); #ifdef FIXED_POINT - offset = SUB32(VSHR32(2*q2+1, extra_quant[i]-DB_SHIFT+1), GCONST(.5f)); - offset = SHR32(offset, prev); + offset = SUB32(VSHR32(2*q2 + 1, extra_quant[i] - DB_SHIFT + 1), GCONST(.5f)); + offset = SHR32(offset, prev); #else - offset = (q2+.5f)*(1<<(14-extra_quant[i]))*(1.f/16384) - .5f; - offset *= (1<<(14-prev))*(1.f/16384); + offset = (q2 + .5f)*(1<<(14 - extra_quant[i]))*(1.f/16384) - .5f; + offset *= (1<<(14 - prev))*(1.f/16384); #endif - oldEBands[i+c*m->nbEBands] += offset; - error[i+c*m->nbEBands] -= offset; - /*printf ("%f ", error[i] - offset);*/ - } while (++c < C); - } + oldEBands[i + c*m->nbEBands] += offset; + error[i + c*m->nbEBands] -= offset; + /*printf ("%f ", error[i] - offset);*/ + } while (++c < C); + } } -void quant_energy_finalise(const CELTMode *m, int start, int end, celt_glog *oldEBands, celt_glog *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int C) -{ - int i, prio, c; - - /* Use up the remaining bits */ - for (prio=0;prio<2;prio++) - { - for (i=start;i=C ;i++) - { - if (fine_quant[i] >= MAX_FINE_BITS || fine_priority[i]!=prio) - continue; - c=0; - do { - int q2; - celt_glog offset; - q2 = error[i+c*m->nbEBands]<0 ? 0 : 1; - ec_enc_bits(enc, q2, 1); +void oaci_quant_energy_finalise(const CELTMode *m, int start, int end, celt_glog *oldEBands, celt_glog *error, + int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int C) { + int i, prio, c; + + /* Use up the remaining bits */ + for (prio = 0; prio < 2; prio++) { + for (i = start; i < end && bits_left >= C ; i++) { + if (fine_quant[i] >= MAX_FINE_BITS || fine_priority[i] != prio) + continue; + c = 0; + do { + int q2; + celt_glog offset; + q2 = error[i + c*m->nbEBands] < 0 ? 0 : 1; + oaci_ec_enc_bits(enc, q2, 1); #ifdef FIXED_POINT - offset = SHR32(SHL32(q2,DB_SHIFT)-GCONST(.5f),fine_quant[i]+1); + offset = SHR32(SHL32(q2, DB_SHIFT) - GCONST(.5f), fine_quant[i] + 1); #else - offset = (q2-.5f)*(1<<(14-fine_quant[i]-1))*(1.f/16384); + offset = (q2 - .5f)*(1<<(14 - fine_quant[i] - 1))*(1.f/16384); #endif - if (oldEBands != NULL) oldEBands[i+c*m->nbEBands] += offset; - error[i+c*m->nbEBands] -= offset; - bits_left--; - } while (++c < C); - } - } + if (oldEBands != NULL) oldEBands[i + c*m->nbEBands] += offset; + error[i + c*m->nbEBands] -= offset; + bits_left--; + } while (++c < C); + } + } } -void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, int intra, ec_dec *dec, int C, int LM) -{ - const unsigned char *prob_model = e_prob_model[LM][intra]; - int i, c; - opus_val64 prev[2] = {0, 0}; - opus_val16 coef; - opus_val16 beta; - opus_int32 budget; - opus_int32 tell; - - if (intra) - { - coef = 0; - beta = beta_intra; - } else { - beta = beta_coef[LM]; - coef = pred_coef[LM]; - } - - budget = dec->storage*8; - - /* Decode at a fixed coarse resolution */ - for (i=start;i=15) - { - int pi; - pi = 2*IMIN(i,20); - qi = ec_laplace_decode(dec, - prob_model[pi]<<7, prob_model[pi+1]<<6); - } - else if(budget-tell>=2) - { - qi = ec_dec_icdf(dec, small_energy_icdf, 2); - qi = (qi>>1)^-(qi&1); - } - else if(budget-tell>=1) - { - qi = -ec_dec_bit_logp(dec, 1); - } - else - qi = -1; - q = (opus_val32)SHL32(EXTEND32(qi),DB_SHIFT); - - oldEBands[i+c*m->nbEBands] = MAXG(-GCONST(9.f), oldEBands[i+c*m->nbEBands]); - tmp = MULT16_32_Q15(coef,oldEBands[i+c*m->nbEBands]) + prev[c] + q; +void oaci_unquant_coarse_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, int intra, ec_dec *dec, int C, + int LM) { + const unsigned char *prob_model = e_prob_model[LM][intra]; + int i, c; + oac_val64 prev[2] = {0, 0}; + oac_val16 coef; + oac_val16 beta; + oac_int32 budget; + oac_int32 tell; + + if (intra) { + coef = 0; + beta = beta_intra; + } else { + beta = beta_coef[LM]; + coef = pred_coef[LM]; + } + + budget = dec->storage*8; + + /* Decode at a fixed coarse resolution */ + for (i = start; i < end; i++) { + c = 0; + do { + int qi; + oac_val32 q; + oac_val32 tmp; + /* It would be better to express this invariant as a + test on C at function entry, but that isn't enough + to make the static analyzer happy. */ + celt_sig_assert(c < 2); + tell = oaci_ec_tell(dec); + if (budget - tell >= 15) { + int pi; + pi = 2*IMIN(i, 20); + qi = oaci_ec_laplace_decode(dec, + prob_model[pi]<<7, prob_model[pi + 1]<<6); + } else if (budget - tell >= 2) { + qi = oaci_ec_dec_icdf(dec, small_energy_icdf, 2); + qi = (qi>>1)^-(qi&1); + } else if (budget - tell >= 1) { + qi = -oaci_ec_dec_bit_logp(dec, 1); + } else + qi = -1; + q = (oac_val32)SHL32(EXTEND32(qi), DB_SHIFT); + + oldEBands[i + c*m->nbEBands] = MAXG(-GCONST(9.f), oldEBands[i + c*m->nbEBands]); + tmp = MULT16_32_Q15(coef, oldEBands[i + c*m->nbEBands]) + prev[c] + q; #ifdef FIXED_POINT - tmp = MIN32(GCONST(28.f), MAX32(-GCONST(28.f), tmp)); + tmp = MIN32(GCONST(28.f), MAX32(-GCONST(28.f), tmp)); #endif - oldEBands[i+c*m->nbEBands] = tmp; - prev[c] = prev[c] + q - MULT16_32_Q15(beta,q); - } while (++c < C); - } + oldEBands[i + c*m->nbEBands] = tmp; + prev[c] = prev[c] + q - MULT16_32_Q15(beta, q); + } while (++c < C); + } } -void unquant_fine_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, int *prev_quant, int *extra_quant, ec_dec *dec, int C) -{ - int i, c; - /* Decode finer resolution */ - for (i=start;i (opus_int32)dec->storage*8) continue; - prev = (prev_quant!=NULL) ? prev_quant[i] : 0; - c=0; - do { - int q2; - celt_glog offset; - q2 = ec_dec_bits(dec, extra); +void oaci_unquant_fine_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, int *prev_quant, int *extra_quant, + ec_dec *dec, int C) { + int i, c; + /* Decode finer resolution */ + for (i = start; i < end; i++) { + oac_int16 extra, prev; + extra = extra_quant[i]; + if (extra_quant[i] <= 0) + continue; + if (oaci_ec_tell(dec) + C*extra_quant[i] > (oac_int32)dec->storage*8) continue; + prev = (prev_quant != NULL) ? prev_quant[i] : 0; + c = 0; + do { + int q2; + celt_glog offset; + q2 = oaci_ec_dec_bits(dec, extra); #ifdef FIXED_POINT - offset = SUB32(VSHR32(2*q2+1, extra-DB_SHIFT+1), GCONST(.5f)); - offset = SHR32(offset, prev); + offset = SUB32(VSHR32(2*q2 + 1, extra - DB_SHIFT + 1), GCONST(.5f)); + offset = SHR32(offset, prev); #else - offset = (q2+.5f)*(1<<(14-extra))*(1.f/16384) - .5f; - offset *= (1<<(14-prev))*(1.f/16384); + offset = (q2 + .5f)*(1<<(14 - extra))*(1.f/16384) - .5f; + offset *= (1<<(14 - prev))*(1.f/16384); #endif - oldEBands[i+c*m->nbEBands] += offset; - } while (++c < C); - } + oldEBands[i + c*m->nbEBands] += offset; + } while (++c < C); + } } -void unquant_energy_finalise(const CELTMode *m, int start, int end, celt_glog *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int C) -{ - int i, prio, c; - - /* Use up the remaining bits */ - for (prio=0;prio<2;prio++) - { - for (i=start;i=C ;i++) - { - if (fine_quant[i] >= MAX_FINE_BITS || fine_priority[i]!=prio) - continue; - c=0; - do { - int q2; - celt_glog offset; - q2 = ec_dec_bits(dec, 1); +void oaci_unquant_energy_finalise(const CELTMode *m, int start, int end, celt_glog *oldEBands, int *fine_quant, + int *fine_priority, int bits_left, ec_dec *dec, int C) { + int i, prio, c; + + /* Use up the remaining bits */ + for (prio = 0; prio < 2; prio++) { + for (i = start; i < end && bits_left >= C ; i++) { + if (fine_quant[i] >= MAX_FINE_BITS || fine_priority[i] != prio) + continue; + c = 0; + do { + int q2; + celt_glog offset; + q2 = oaci_ec_dec_bits(dec, 1); #ifdef FIXED_POINT - offset = SHR32(SHL32(q2,DB_SHIFT)-GCONST(.5f),fine_quant[i]+1); + offset = SHR32(SHL32(q2, DB_SHIFT) - GCONST(.5f), fine_quant[i] + 1); #else - offset = (q2-.5f)*(1<<(14-fine_quant[i]-1))*(1.f/16384); + offset = (q2 - .5f)*(1<<(14 - fine_quant[i] - 1))*(1.f/16384); #endif - if (oldEBands != NULL) oldEBands[i+c*m->nbEBands] += offset; - bits_left--; - } while (++c < C); - } - } + if (oldEBands != NULL) oldEBands[i + c*m->nbEBands] += offset; + bits_left--; + } while (++c < C); + } + } } -void amp2Log2(const CELTMode *m, int effEnd, int end, - celt_ener *bandE, celt_glog *bandLogE, int C) -{ - int c, i; - c=0; - do { - for (i=0;inbEBands] = - celt_log2_db(bandE[i+c*m->nbEBands]) - - SHL32((celt_glog)eMeans[i],DB_SHIFT-4); +void oaci_amp2Log2(const CELTMode *m, int effEnd, int end, + celt_ener *bandE, celt_glog *bandLogE, int C) { + int c, i; + c = 0; + do { + for (i = 0; i < effEnd; i++) { + bandLogE[i + c*m->nbEBands] = + oaci_celt_log2_db(bandE[i + c*m->nbEBands]) + - SHL32((celt_glog)oaci_eMeans[i], DB_SHIFT - 4); #ifdef FIXED_POINT - /* Compensate for bandE[] being Q12 but celt_log2() taking a Q14 input. */ - bandLogE[i+c*m->nbEBands] += GCONST(2.f); + /* Compensate for bandE[] being Q12 but oaci_celt_log2() taking a Q14 input. */ + bandLogE[i + c*m->nbEBands] += GCONST(2.f); #endif - } - for (i=effEnd;inbEBands+i] = -GCONST(14.f); - } while (++c < C); + } + for (i = effEnd; i < end; i++) + bandLogE[c*m->nbEBands + i] = -GCONST(14.f); + } while (++c < C); } diff --git a/celt/quant_bands.h b/celt/quant_bands.h index 6677fca2c..f35c25d99 100644 --- a/celt/quant_bands.h +++ b/celt/quant_bands.h @@ -24,7 +24,7 @@ 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. -*/ + */ #ifndef QUANT_BANDS #define QUANT_BANDS @@ -36,31 +36,36 @@ #include "mathops.h" #ifdef FIXED_POINT -extern const signed char eMeans[25]; +extern const signed char oaci_eMeans[25]; #else -extern const opus_val16 eMeans[25]; +extern const oac_val16 oaci_eMeans[25]; #endif -void amp2Log2(const CELTMode *m, int effEnd, int end, - celt_ener *bandE, celt_glog *bandLogE, int C); +void oaci_amp2Log2(const CELTMode *m, int effEnd, int end, + celt_ener *bandE, celt_glog *bandLogE, int C); void log2Amp(const CELTMode *m, int start, int end, - celt_ener *eBands, const celt_glog *oldEBands, int C); + celt_ener *eBands, const celt_glog *oldEBands, int C); -void quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, - const celt_glog *eBands, celt_glog *oldEBands, opus_uint32 budget, - celt_glog *error, ec_enc *enc, int C, int LM, - int nbAvailableBytes, int force_intra, opus_val32 *delayedIntra, - int two_pass, int loss_rate, int lfe); +void oaci_quant_coarse_energy(const CELTMode *m, int start, int end, int effEnd, + const celt_glog *eBands, celt_glog *oldEBands, oac_uint32 budget, + celt_glog *error, ec_enc *enc, int C, int LM, + int nbAvailableBytes, int force_intra, oac_val32 *delayedIntra, + int two_pass, int loss_rate, int lfe); -void quant_fine_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, celt_glog *error, int *fine_quant, int *extra_quant, ec_enc *enc, int C); +void oaci_quant_fine_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, celt_glog *error, int *fine_quant, + int *extra_quant, ec_enc *enc, int C); -void quant_energy_finalise(const CELTMode *m, int start, int end, celt_glog *oldEBands, celt_glog *error, int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int C); +void oaci_quant_energy_finalise(const CELTMode *m, int start, int end, celt_glog *oldEBands, celt_glog *error, + int *fine_quant, int *fine_priority, int bits_left, ec_enc *enc, int C); -void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, int intra, ec_dec *dec, int C, int LM); +void oaci_unquant_coarse_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, int intra, ec_dec *dec, int C, + int LM); -void unquant_fine_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, int *fine_quant, int *extra_quant, ec_dec *dec, int C); +void oaci_unquant_fine_energy(const CELTMode *m, int start, int end, celt_glog *oldEBands, int *fine_quant, int *extra_quant, + ec_dec *dec, int C); -void unquant_energy_finalise(const CELTMode *m, int start, int end, celt_glog *oldEBands, int *fine_quant, int *fine_priority, int bits_left, ec_dec *dec, int C); +void oaci_unquant_energy_finalise(const CELTMode *m, int start, int end, celt_glog *oldEBands, int *fine_quant, + int *fine_priority, int bits_left, ec_dec *dec, int C); #endif /* QUANT_BANDS */ diff --git a/celt/rate.c b/celt/rate.c index 9eed2e1ec..99dcc81f1 100644 --- a/celt/rate.c +++ b/celt/rate.c @@ -24,10 +24,10 @@ 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" +# include "config.h" #endif #include @@ -38,839 +38,567 @@ #include "entcode.h" #include "rate.h" -#include "quant_bands.h" - -static const unsigned char LOG2_FRAC_TABLE[24]={ - 0, - 8,13, - 16,19,21,23, - 24,26,27,28,29,30,31,32, - 32,33,34,34,35,36,36,37,37 + +static const unsigned char LOG2_FRAC_TABLE[24] = { + 0, + 8, 13, + 16, 19, 21, 23, + 24, 26, 27, 28, 29, 30, 31, 32, + 32, 33, 34, 34, 35, 36, 36, 37, 37 }; #if defined(CUSTOM_MODES) /*Determines if V(N,K) fits in a 32-bit unsigned integer. - N and K are themselves limited to 15 bits.*/ -static int fits_in32(int _n, int _k) -{ - static const opus_int16 maxN[15] = { - 32767, 32767, 32767, 1476, 283, 109, 60, 40, - 29, 24, 20, 18, 16, 14, 13}; - static const opus_int16 maxK[15] = { - 32767, 32767, 32767, 32767, 1172, 238, 95, 53, - 36, 27, 22, 18, 16, 15, 13}; - if (_n>=14) - { - if (_k>=14) - return 0; - else - return _n <= maxN[_k]; - } else { - return _k <= maxK[_n]; - } + N and K are themselves limited to 15 bits.*/ +static int oaci_fits_in32(int _n, int _k) { + static const oac_int16 maxN[15] = { + 32767, 32767, 32767, 1476, 283, 109, 60, 40, + 29, 24, 20, 18, 16, 14, 13 + }; + static const oac_int16 maxK[15] = { + 32767, 32767, 32767, 32767, 1172, 238, 95, 53, + 36, 27, 22, 18, 16, 15, 13 + }; + if (_n >= 14) { + if (_k >= 14) + return 0; + else + return _n <= maxN[_k]; + } else { + return _k <= maxK[_n]; + } } -void compute_pulse_cache(CELTMode *m, int LM) -{ - int C; - int i; - int j; - int curr=0; - int nbEntries=0; - int entryN[100], entryK[100], entryI[100]; - const opus_int16 *eBands = m->eBands; - PulseCache *cache = &m->cache; - opus_int16 *cindex; - unsigned char *bits; - unsigned char *cap; - - cindex = (opus_int16 *)opus_alloc(sizeof(cache->index[0])*m->nbEBands*(LM+2)); - cache->index = cindex; - - /* Scan for all unique band sizes */ - for (i=0;i<=LM+1;i++) - { - for (j=0;jnbEBands;j++) - { - int k; - int N = (eBands[j+1]-eBands[j])<>1; - cindex[i*m->nbEBands+j] = -1; - /* Find other bands that have the same size */ - for (k=0;k<=i;k++) - { - int n; - for (n=0;nnbEBands && (k!=i || n>1) - { - cindex[i*m->nbEBands+j] = cindex[k*m->nbEBands+n]; - break; - } +void oaci_compute_pulse_cache(CELTMode *m, int LM) { + int C; + int i; + int j; + int curr = 0; + int nbEntries = 0; + int entryN[100], entryK[100], entryI[100]; + const oac_int16 *eBands = m->eBands; + PulseCache *cache = &m->cache; + oac_int16 *cindex; + unsigned char *bits; + unsigned char *cap; + + cindex = (oac_int16 *)oac_alloc(sizeof(cache->index[0])*m->nbEBands*(LM + 2)); + cache->index = cindex; + + /* Scan for all unique band sizes */ + for (i = 0; i <= LM + 1; i++) { + for (j = 0; j < m->nbEBands; j++) { + int k; + int N = (eBands[j + 1] - eBands[j])<>1; + cindex[i*m->nbEBands + j] = -1; + /* Find other bands that have the same size */ + for (k = 0; k <= i; k++) { + int n; + for (n = 0; n < m->nbEBands && (k != i || n < j); n++) { + if (N == (eBands[n + 1] - eBands[n])<>1) { + cindex[i*m->nbEBands + j] = cindex[k*m->nbEBands + n]; + break; + } + } } - } - if (cache->index[i*m->nbEBands+j] == -1 && N!=0) - { - int K; - entryN[nbEntries] = N; - K = 0; - while (fits_in32(N,get_pulses(K+1)) && KnbEBands+j] = curr; - entryI[nbEntries] = curr; - - curr += K+1; - nbEntries++; - } - } - } - bits = (unsigned char *)opus_alloc(sizeof(unsigned char)*curr); - cache->bits = bits; - cache->size = curr; - /* Compute the cache for all unique sizes */ - for (i=0;icaps = cap = (unsigned char *)opus_alloc(sizeof(cache->caps[0])*(LM+1)*2*m->nbEBands); - for (i=0;i<=LM;i++) - { - for (C=1;C<=2;C++) - { - for (j=0;jnbEBands;j++) - { - int N0; - int max_bits; - N0 = m->eBands[j+1]-m->eBands[j]; - /* N=1 bands only have a sign bit and fine bits. */ - if (N0<1 are even, including custom modes.*/ - if (N0 > 2) - { - N0>>=1; - LM0--; - } - /* N0=1 bands can't be split down to N<2. */ - else if (N0 <= 1) - { - LM0=IMIN(i,1); - N0<<=LM0; - } - /* Compute the cost for the lowest-level PVQ of a fully split - band. */ - pcache = bits + cindex[(LM0+1)*m->nbEBands+j]; - max_bits = pcache[pcache[0]]+1; - /* Add in the cost of coding regular splits. */ - N = N0; - for(k=0;klogN[j]+(opus_int32)((opus_uint32)(LM0+k)<>1)-QTHETA_OFFSET; - /* The number of qtheta bits we'll allocate if the remainder - is to be max_bits. - The average measured cost for theta is 0.89701 times qb, - approximated here as 459/512. */ - num=459*(opus_int32)((2*N-1)*offset+max_bits); - den=((opus_int32)(2*N-1)<<9)-459; - qb = IMIN((num+(den>>1))/den, 57); - celt_assert(qb >= 0); - max_bits += qb; - N <<= 1; - } - /* Add in the cost of a stereo split, if necessary. */ - if (C==2) - { - max_bits <<= 1; - offset = ((m->logN[j]+(i<>1)-(N==2?QTHETA_OFFSET_TWOPHASE:QTHETA_OFFSET); - ndof = 2*N-1-(N==2); - /* The average measured cost for theta with the step PDF is - 0.95164 times qb, approximated here as 487/512. */ - num = (N==2?512:487)*(opus_int32)(max_bits+ndof*offset); - den = ((opus_int32)ndof<<9)-(N==2?512:487); - qb = IMIN((num+(den>>1))/den, (N==2?64:61)); - celt_assert(qb >= 0); - max_bits += qb; - } - /* Add the fine bits we'll use. */ - /* Compensate for the extra DoF in stereo */ - ndof = C*N + ((C==2 && N>2) ? 1 : 0); - /* Offset the number of fine bits by log2(N)/2 + FINE_OFFSET - compared to their "fair share" of total/N */ - offset = ((m->logN[j] + (i<>1)-FINE_OFFSET; - /* N=2 is the only point that doesn't match the curve */ - if (N==2) - offset += 1<>2; - /* The number of fine bits we'll allocate if the remainder is - to be max_bits. */ - num = max_bits+ndof*offset; - den = (ndof-1)<>1))/den, MAX_FINE_BITS); - celt_assert(qb >= 0); - max_bits += C*qb<index[i*m->nbEBands + j] == -1 && N != 0) { + int K; + entryN[nbEntries] = N; + K = 0; + while (oaci_fits_in32(N, oaci_get_pulses(K + 1)) && K < MAX_PSEUDO) + K++; + entryK[nbEntries] = K; + cindex[i*m->nbEBands + j] = curr; + entryI[nbEntries] = curr; + + curr += K + 1; + nbEntries++; } - max_bits = (4*max_bits/(C*((m->eBands[j+1]-m->eBands[j])<= 0); - celt_assert(max_bits < 256); - *cap++ = (unsigned char)max_bits; - } - } - } + } + } + bits = (unsigned char *)oac_alloc(sizeof(unsigned char)*curr); + cache->bits = bits; + cache->size = curr; + /* Compute the cache for all unique sizes */ + for (i = 0; i < nbEntries; i++) { + unsigned char *ptr = bits + entryI[i]; + oac_int16 tmp[CELT_MAX_PULSES + 1]; + oaci_get_required_bits(tmp, entryN[i], oaci_get_pulses(entryK[i]), BITRES); + for (j = 1; j <= entryK[i]; j++) + ptr[j] = tmp[oaci_get_pulses(j)] - 1; + ptr[0] = entryK[i]; + } + + /* Compute the maximum rate for each band at which we'll reliably use as + many bits as we ask for. */ + cache->caps = cap = (unsigned char *)oac_alloc(sizeof(cache->caps[0])*(LM + 1)*2*m->nbEBands); + for (i = 0; i <= LM; i++) { + for (C = 1; C <= 2; C++) { + for (j = 0; j < m->nbEBands; j++) { + int N0; + int max_bits; + N0 = m->eBands[j + 1] - m->eBands[j]; + /* N=1 bands only have a sign bit and fine bits. */ + if (N0<1 are even, including custom modes.*/ + if (N0 > 2) { + N0 >>= 1; + LM0--; + } + /* N0=1 bands can't be split down to N<2. */ + else if (N0 <= 1) { + LM0 = IMIN(i, 1); + N0 <<= LM0; + } + /* Compute the cost for the lowest-level PVQ of a fully split + band. */ + pcache = bits + cindex[(LM0 + 1)*m->nbEBands + j]; + max_bits = pcache[pcache[0]] + 1; + /* Add in the cost of coding regular splits. */ + N = N0; + for (k = 0; k < i - LM0; k++) { + max_bits <<= 1; + /* Offset the number of qtheta bits by log2(N)/2 + + QTHETA_OFFSET compared to their "fair share" of + total/N */ + offset = ((m->logN[j] + (oac_int32)((oac_uint32)(LM0 + k)<>1) - QTHETA_OFFSET; + /* The number of qtheta bits we'll allocate if the remainder + is to be max_bits. + The average measured cost for theta is 0.89701 times qb, + approximated here as 459/512. */ + num = 459*(oac_int32)((2*N - 1)*offset + max_bits); + den = ((oac_int32)(2*N - 1)<<9) - 459; + qb = IMIN((num + (den>>1))/den, 57); + celt_assert(qb >= 0); + max_bits += qb; + N <<= 1; + } + /* Add in the cost of a stereo split, if necessary. */ + if (C == 2) { + max_bits <<= 1; + offset = ((m->logN[j] + (i<>1) - (N == 2?QTHETA_OFFSET_TWOPHASE:QTHETA_OFFSET); + ndof = 2*N - 1 - (N == 2); + /* The average measured cost for theta with the step PDF is + 0.95164 times qb, approximated here as 487/512. */ + num = (N == 2?512:487)*(oac_int32)(max_bits + ndof*offset); + den = ((oac_int32)ndof<<9) - (N == 2?512:487); + qb = IMIN((num + (den>>1))/den, (N == 2?64:61)); + celt_assert(qb >= 0); + max_bits += qb; + } + /* Add the fine bits we'll use. */ + /* Compensate for the extra DoF in stereo */ + ndof = C*N + ((C == 2 && N > 2) ? 1 : 0); + /* Offset the number of fine bits by log2(N)/2 + FINE_OFFSET + compared to their "fair share" of total/N */ + offset = ((m->logN[j] + (i<>1) - FINE_OFFSET; + /* N=2 is the only point that doesn't match the curve */ + if (N == 2) + offset += 1<>2; + /* The number of fine bits we'll allocate if the remainder is + to be max_bits. */ + num = max_bits + ndof*offset; + den = (ndof - 1)<>1))/den, MAX_FINE_BITS); + celt_assert(qb >= 0); + max_bits += C*qb<eBands[j + 1] - m->eBands[j])<= 0); + celt_assert(max_bits < 256); + *cap++ = (unsigned char)max_bits; + } + } + } } #endif /* CUSTOM_MODES */ #define ALLOC_STEPS 6 -static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, int skip_start, - const int *bits1, const int *bits2, const int *thresh, const int *cap, opus_int32 total, opus_int32 *_balance, - int skip_rsv, int *intensity, int intensity_rsv, int *dual_stereo, int dual_stereo_rsv, int *bits, - int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth) -{ - opus_int32 psum; - int lo, hi; - int i, j; - int logM; - int stereo; - int codedBands=-1; - int alloc_floor; - opus_int32 left, percoeff; - int done; - opus_int32 balance; - SAVE_STACK; - - alloc_floor = C<1; - - logM = LM<>1; - psum = 0; - done = 0; - for (j=end;j-->start;) - { - int tmp = bits1[j] + (mid*(opus_int32)bits2[j]>>ALLOC_STEPS); - if (tmp >= thresh[j] || done) - { - done = 1; - /* Don't allocate more than we can actually use */ - psum += IMIN(tmp, cap[j]); - } else { +static OAC_INLINE int oaci_interp_bits2pulses(const CELTMode *m, int start, int end, int skip_start, + const int *bits1, const int *bits2, const int *thresh, const int *cap, + oac_int32 total, oac_int32 *_balance, + int skip_rsv, int *intensity, int intensity_rsv, int *dual_stereo, + int dual_stereo_rsv, int *bits, + int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, + int prev, int signalBandwidth) { + oac_int32 psum; + int lo, hi; + int i, j; + int logM; + int stereo; + int codedBands = -1; + int alloc_floor; + oac_int32 left, percoeff; + int done; + oac_int32 balance; + SAVE_STACK; + + alloc_floor = C< 1; + + logM = LM<>1; + psum = 0; + done = 0; + for (j = end; j-- > start;) { + int tmp = bits1[j] + (mid*(oac_int32)bits2[j]>>ALLOC_STEPS); + if (tmp >= thresh[j] || done) { + done = 1; + /* Don't allocate more than we can actually use */ + psum += IMIN(tmp, cap[j]); + } else { + if (tmp >= alloc_floor) + psum += alloc_floor; + } + } + if (psum > total) + hi = mid; + else + lo = mid; + } + psum = 0; + /*printf ("interp bisection gave %d\n", lo);*/ + done = 0; + for (j = end; j-- > start;) { + int tmp = bits1[j] + ((oac_int32)lo*bits2[j]>>ALLOC_STEPS); + if (tmp < thresh[j] && !done) { if (tmp >= alloc_floor) - psum += alloc_floor; - } - } - if (psum > total) - hi = mid; - else - lo = mid; - } - psum = 0; - /*printf ("interp bisection gave %d\n", lo);*/ - done = 0; - for (j=end;j-->start;) - { - int tmp = bits1[j] + ((opus_int32)lo*bits2[j]>>ALLOC_STEPS); - if (tmp < thresh[j] && !done) - { - if (tmp >= alloc_floor) - tmp = alloc_floor; - else - tmp = 0; - } else - done = 1; - /* Don't allocate more than we can actually use */ - tmp = IMIN(tmp, cap[j]); - bits[j] = tmp; - psum += tmp; - } - - /* Decide which bands to skip, working backwards from the end. */ - for (codedBands=end;;codedBands--) - { - int band_width; - int band_bits; - int rem; - j = codedBands-1; - /* Never skip the first band, nor a band that has been boosted by - dynalloc. - In the first case, we'd be coding a bit to signal we're going to waste - all the other bits. - In the second case, we'd be coding a bit to redistribute all the bits - we just signaled should be concentrated in this band. */ - if (j<=skip_start) - { - /* Give the bit we reserved to end skipping back. */ - total += skip_rsv; - break; - } - /*Figure out how many left-over bits we would be adding to this band. - This can include bits we've stolen back from higher, skipped bands.*/ - left = total-psum; - percoeff = celt_udiv(left, m->eBands[codedBands]-m->eBands[start]); - left -= (m->eBands[codedBands]-m->eBands[start])*percoeff; - rem = IMAX(left-(m->eBands[j]-m->eBands[start]),0); - band_width = m->eBands[codedBands]-m->eBands[j]; - band_bits = (int)(bits[j] + percoeff*band_width + rem); - /*Only code a skip decision if we're above the threshold for this band. - Otherwise it is force-skipped. - This ensures that we have enough bits to code the skip flag.*/ - if (band_bits >= IMAX(thresh[j], alloc_floor+(1< 17) - depth_threshold = jeBands[codedBands] - m->eBands[start]); + left -= (m->eBands[codedBands] - m->eBands[start])*percoeff; + rem = IMAX(left - (m->eBands[j] - m->eBands[start]), 0); + band_width = m->eBands[codedBands] - m->eBands[j]; + band_bits = (int)(bits[j] + percoeff*band_width + rem); + /*Only code a skip decision if we're above the threshold for this band. + Otherwise it is force-skipped. + This ensures that we have enough bits to code the skip flag.*/ + if (band_bits >= IMAX(thresh[j], alloc_floor + (1< 17) + depth_threshold = j < prev ? 7 : 9; + else + depth_threshold = 0; #ifdef FUZZING - (void)signalBandwidth; - (void)depth_threshold; - if ((rand()&0x1) == 0) + (void)signalBandwidth; + (void)depth_threshold; + if ((rand()&0x1) == 0) #else - if (codedBands<=start+2 || (band_bits > (depth_threshold*band_width<>4 && j<=signalBandwidth)) + if (codedBands <= start + 2 + || (band_bits > (depth_threshold*band_width<>4 && j <= signalBandwidth)) #endif - { - ec_enc_bit_logp(ec, 1, 1); - break; + { + oaci_ec_enc_bit_logp(ec, 1, 1); + break; + } + oaci_ec_enc_bit_logp(ec, 0, 1); + } else if (oaci_ec_dec_bit_logp(ec, 1)) { + break; } - ec_enc_bit_logp(ec, 0, 1); - } else if (ec_dec_bit_logp(ec, 1)) { - break; - } - /*We used a bit to skip this band.*/ - psum += 1< 0) - intensity_rsv = LOG2_FRAC_TABLE[j-start]; - psum += intensity_rsv; - if (band_bits >= alloc_floor) - { - /*If we have enough for a fine energy bit per channel, use it.*/ - psum += alloc_floor; - bits[j] = alloc_floor; - } else { - /*Otherwise this band gets nothing at all.*/ - bits[j] = 0; - } - } - - celt_assert(codedBands > start); - /* Code the intensity and dual stereo parameters. */ - if (intensity_rsv > 0) - { - if (encode) - { - *intensity = IMIN(*intensity, codedBands); - ec_enc_uint(ec, *intensity-start, codedBands+1-start); - } - else - *intensity = start+ec_dec_uint(ec, codedBands+1-start); - } - else - *intensity = 0; - if (*intensity <= start) - { - total += dual_stereo_rsv; - dual_stereo_rsv = 0; - } - if (dual_stereo_rsv > 0) - { - if (encode) - ec_enc_bit_logp(ec, *dual_stereo, 1); - else - *dual_stereo = ec_dec_bit_logp(ec, 1); - } - else - *dual_stereo = 0; - - /* Allocate the remaining bits */ - left = total-psum; - percoeff = celt_udiv(left, m->eBands[codedBands]-m->eBands[start]); - left -= (m->eBands[codedBands]-m->eBands[start])*percoeff; - for (j=start;jeBands[j+1]-m->eBands[j])); - for (j=start;jeBands[j+1]-m->eBands[j]); - bits[j] += tmp; - left -= tmp; - } - /*for (j=0;j= 0); - N0 = m->eBands[j+1]-m->eBands[j]; - N=N0<1) - { - excess = MAX32(bit-cap[j],0); - bits[j] = bit-excess; - - /* Compensate for the extra DoF in stereo */ - den=(C*N+ ((C==2 && N>2 && !*dual_stereo && j<*intensity) ? 1 : 0)); - - NClogN = den*(m->logN[j] + logM); - - /* Offset for the number of fine bits by log2(N)/2 + FINE_OFFSET - compared to their "fair share" of total/N */ - offset = (NClogN>>1)-den*FINE_OFFSET; - - /* N=2 is the only point that doesn't match the curve */ - if (N==2) - offset += den<>2; - - /* Changing the offset for allocating the second and third - fine energy bit */ - if (bits[j] + offset < den*2<>2; - else if (bits[j] + offset < den*3<>3; - - /* Divide with rounding */ - ebits[j] = IMAX(0, (bits[j] + offset + (den<<(BITRES-1)))); - ebits[j] = celt_udiv(ebits[j], den)>>BITRES; - - /* Make sure not to bust */ - if (C*ebits[j] > (bits[j]>>BITRES)) - ebits[j] = bits[j] >> stereo >> BITRES; - - /* More than that is useless because that's about as far as PVQ can go */ - ebits[j] = IMIN(ebits[j], MAX_FINE_BITS); - - /* If we rounded down or capped this band, make it a candidate for the - final fine energy pass */ - fine_priority[j] = ebits[j]*(den<= bits[j]+offset; - - /* Remove the allocated fine bits; the rest are assigned to PVQ */ - bits[j] -= C*ebits[j]< 0) - { - int extra_fine; - int extra_bits; - extra_fine = IMIN(excess>>(stereo+BITRES),MAX_FINE_BITS-ebits[j]); - ebits[j] += extra_fine; - extra_bits = extra_fine*C<= excess-balance; - excess -= extra_bits; - } - balance = excess; - - celt_assert(bits[j] >= 0); - celt_assert(ebits[j] >= 0); - } - /* Save any remaining bits over the cap for the rebalancing in - quant_all_bands(). */ - *_balance = balance; - - /* The skipped bands use all their bits for fine energy. */ - for (;j> stereo >> BITRES; - celt_assert(C*ebits[j]< 0) + intensity_rsv = LOG2_FRAC_TABLE[j - start]; + psum += intensity_rsv; + if (band_bits >= alloc_floor) { + /*If we have enough for a fine energy bit per channel, use it.*/ + psum += alloc_floor; + bits[j] = alloc_floor; + } else { + /*Otherwise this band gets nothing at all.*/ + bits[j] = 0; + } + } + + celt_assert(codedBands > start); + /* Code the intensity and dual stereo parameters. */ + if (intensity_rsv > 0) { + if (encode) { + *intensity = IMIN(*intensity, codedBands); + oaci_ec_enc_uint(ec, *intensity - start, codedBands + 1 - start); + } else + *intensity = start + oaci_ec_dec_uint(ec, codedBands + 1 - start); + } else + *intensity = 0; + if (*intensity <= start) { + total += dual_stereo_rsv; + dual_stereo_rsv = 0; + } + if (dual_stereo_rsv > 0) { + if (encode) + oaci_ec_enc_bit_logp(ec, *dual_stereo, 1); + else + *dual_stereo = oaci_ec_dec_bit_logp(ec, 1); + } else + *dual_stereo = 0; + + /* Allocate the remaining bits */ + left = total - psum; + percoeff = oaci_celt_udiv(left, m->eBands[codedBands] - m->eBands[start]); + left -= (m->eBands[codedBands] - m->eBands[start])*percoeff; + for (j = start; j < codedBands; j++) + bits[j] += ((int)percoeff*(m->eBands[j + 1] - m->eBands[j])); + for (j = start; j < codedBands; j++) { + int tmp = (int)IMIN(left, m->eBands[j + 1] - m->eBands[j]); + bits[j] += tmp; + left -= tmp; + } + /*for (j=0;j= 0); + N0 = m->eBands[j + 1] - m->eBands[j]; + N = N0< 1) { + excess = MAX32(bit - cap[j], 0); + bits[j] = bit - excess; + + /* Compensate for the extra DoF in stereo */ + den = (C*N + ((C == 2 && N > 2 && !*dual_stereo && j < *intensity) ? 1 : 0)); + + NClogN = den*(m->logN[j] + logM); + + /* Offset for the number of fine bits by log2(N)/2 + FINE_OFFSET + compared to their "fair share" of total/N */ + offset = (NClogN>>1) - den*FINE_OFFSET; + + /* N=2 is the only point that doesn't match the curve */ + if (N == 2) + offset += den<>2; + + /* Changing the offset for allocating the second and third + fine energy bit */ + if (bits[j] + offset < den*2<>2; + else if (bits[j] + offset < den*3<>3; + + /* Divide with rounding */ + ebits[j] = IMAX(0, (bits[j] + offset + (den<<(BITRES - 1)))); + ebits[j] = oaci_celt_udiv(ebits[j], den)>>BITRES; + + /* Make sure not to bust */ + if (C*ebits[j] > (bits[j]>>BITRES)) + ebits[j] = bits[j]>>stereo>>BITRES; + + /* More than that is useless because that's about as far as PVQ can go */ + ebits[j] = IMIN(ebits[j], MAX_FINE_BITS); + + /* If we rounded down or capped this band, make it a candidate for the + final fine energy pass */ + fine_priority[j] = ebits[j]*(den<= bits[j] + offset; + + /* Remove the allocated fine bits; the rest are assigned to PVQ */ + bits[j] -= C*ebits[j]< 0) { + int extra_fine; + int extra_bits; + extra_fine = IMIN(excess>>(stereo + BITRES), MAX_FINE_BITS - ebits[j]); + ebits[j] += extra_fine; + extra_bits = extra_fine*C<= excess - balance; + excess -= extra_bits; + } + balance = excess; + + celt_assert(bits[j] >= 0); + celt_assert(ebits[j] >= 0); + } + /* Save any remaining bits over the cap for the rebalancing in + oaci_quant_all_bands(). */ + *_balance = balance; + + /* The skipped bands use all their bits for fine energy. */ + for (; j < end; j++) { + ebits[j] = bits[j]>>stereo>>BITRES; + celt_assert(C*ebits[j]<nbEBands; - skip_start = start; - /* Reserve a bit to signal the end of manually skipped bands. */ - skip_rsv = total >= 1<total) - intensity_rsv = 0; - else - { - total -= intensity_rsv; - dual_stereo_rsv = total>=1<eBands[j+1]-m->eBands[j])<>4); - /* Tilt of the allocation curve */ - trim_offset[j] = C*(m->eBands[j+1]-m->eBands[j])*(alloc_trim-5-LM)*(end-j-1) - *(1<<(LM+BITRES))>>6; - /* Giving less resolution to single-coefficient bands because they get - more benefit from having one coarse value per coefficient*/ - if ((m->eBands[j+1]-m->eBands[j])<nbAllocVectors - 1; - do - { - int done = 0; - int psum = 0; - int mid = (lo+hi) >> 1; - for (j=end;j-->start;) - { - int bitsj; - int N = m->eBands[j+1]-m->eBands[j]; - bitsj = C*N*m->allocVectors[mid*len+j]<>2; - if (bitsj > 0) - bitsj = IMAX(0, bitsj + trim_offset[j]); - bitsj += offsets[j]; - if (bitsj >= thresh[j] || done) - { - done = 1; - /* Don't allocate more than we can actually use */ - psum += IMIN(bitsj, cap[j]); - } else { - if (bitsj >= C< total) - hi = mid - 1; - else - lo = mid + 1; - /*printf ("lo = %d, hi = %d\n", lo, hi);*/ - } - while (lo <= hi); - hi = lo--; - /*printf ("interp between %d and %d\n", lo, hi);*/ - for (j=start;jeBands[j+1]-m->eBands[j]; - bits1j = C*N*m->allocVectors[lo*len+j]<>2; - bits2j = hi>=m->nbAllocVectors ? - cap[j] : C*N*m->allocVectors[hi*len+j]<>2; - if (bits1j > 0) - bits1j = IMAX(0, bits1j + trim_offset[j]); - if (bits2j > 0) - bits2j = IMAX(0, bits2j + trim_offset[j]); - if (lo > 0) - bits1j += offsets[j]; - bits2j += offsets[j]; - if (offsets[j]>0) - skip_start = j; - bits2j = IMAX(0,bits2j-bits1j); - bits1[j] = bits1j; - bits2[j] = bits2j; - } - codedBands = interp_bits2pulses(m, start, end, skip_start, bits1, bits2, thresh, cap, +int oaci_clt_compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, + int *intensity, int *dual_stereo, + oac_int32 total, oac_int32 *balance, int *pulses, int *ebits, int *fine_priority, int C, + int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth) { + int lo, hi, len, j; + int codedBands; + int skip_start; + int skip_rsv; + int intensity_rsv; + int dual_stereo_rsv; + VARDECL(int, bits1); + VARDECL(int, bits2); + VARDECL(int, thresh); + VARDECL(int, trim_offset); + SAVE_STACK; + + total = IMAX(total, 0); + len = m->nbEBands; + skip_start = start; + /* Reserve a bit to signal the end of manually skipped bands. */ + skip_rsv = total >= 1< total) + intensity_rsv = 0; + else { + total -= intensity_rsv; + dual_stereo_rsv = total >= 1<eBands[j + 1] - m->eBands[j])<>4); + /* Tilt of the allocation curve */ + trim_offset[j] = C*(m->eBands[j + 1] - m->eBands[j])*(alloc_trim - 5 - LM)*(end - j - 1) + *(1<<(LM + BITRES))>>6; + /* Giving less resolution to single-coefficient bands because they get + more benefit from having one coarse value per coefficient*/ + if ((m->eBands[j + 1] - m->eBands[j])<nbAllocVectors - 1; + do { + int done = 0; + int psum = 0; + int mid = (lo + hi)>>1; + for (j = end; j-- > start;) { + int bitsj; + int N = m->eBands[j + 1] - m->eBands[j]; + bitsj = C*N*m->allocVectors[mid*len + j]<>2; + if (bitsj > 0) + bitsj = IMAX(0, bitsj + trim_offset[j]); + bitsj += offsets[j]; + if (bitsj >= thresh[j] || done) { + done = 1; + /* Don't allocate more than we can actually use */ + psum += IMIN(bitsj, cap[j]); + } else { + if (bitsj >= C< total) + hi = mid - 1; + else + lo = mid + 1; + /*printf ("lo = %d, hi = %d\n", lo, hi);*/ + } while (lo <= hi); + hi = lo--; + /*printf ("interp between %d and %d\n", lo, hi);*/ + for (j = start; j < end; j++) { + int bits1j, bits2j; + int N = m->eBands[j + 1] - m->eBands[j]; + bits1j = C*N*m->allocVectors[lo*len + j]<>2; + bits2j = hi >= m->nbAllocVectors ? + cap[j] : C*N*m->allocVectors[hi*len + j]<>2; + if (bits1j > 0) + bits1j = IMAX(0, bits1j + trim_offset[j]); + if (bits2j > 0) + bits2j = IMAX(0, bits2j + trim_offset[j]); + if (lo > 0) + bits1j += offsets[j]; + bits2j += offsets[j]; + if (offsets[j] > 0) + skip_start = j; + bits2j = IMAX(0, bits2j - bits1j); + bits1[j] = bits1j; + bits2[j] = bits2j; + } + codedBands = oaci_interp_bits2pulses(m, start, end, skip_start, bits1, bits2, thresh, cap, total, balance, skip_rsv, intensity, intensity_rsv, dual_stereo, dual_stereo_rsv, pulses, ebits, fine_priority, C, LM, ec, encode, prev, signalBandwidth); - RESTORE_STACK; - return codedBands; -} -#ifdef ENABLE_QEXT - -static const unsigned char last_zero[3] = {64, 50, 0}; -static const unsigned char last_cap[3] = {110, 60, 0}; -static const unsigned char last_other[4] = {120, 112, 70, 0}; - -static void ec_enc_depth(ec_enc *enc, opus_int32 depth, opus_int32 cap, opus_int32 *last) { - int sym = 3; - if (depth==*last) sym = 2; - if (depth==cap) sym = 1; - if (depth==0) sym = 0; - if (*last == 0) { - ec_enc_icdf(enc, IMIN(sym, 2), last_zero, 7); - } else if (*last == cap) { - ec_enc_icdf(enc, IMIN(sym, 2), last_cap, 7); - } else { - ec_enc_icdf(enc, sym, last_other, 7); - } - /* We accept some redundancy if depth==last (for last different from 0 and cap). */ - if (sym == 3) ec_enc_uint(enc, depth-1, cap); - *last = depth; + RESTORE_STACK; + return codedBands; } - -static int ec_dec_depth(ec_dec *dec, opus_int32 cap, opus_int32 *last) { - int depth, sym; - if (*last == 0) { - sym = ec_dec_icdf(dec, last_zero, 7); - if (sym==2) sym=3; - } else if (*last == cap) { - sym = ec_dec_icdf(dec, last_cap, 7); - if (sym==2) sym=3; - } else { - sym = ec_dec_icdf(dec, last_other, 7); - } - if (sym==0) depth=0; - else if (sym==1) depth=cap; - else if (sym==2) depth=*last; - else depth = 1 + ec_dec_uint(dec, cap); - *last = depth; - return depth; -} - -#define MSWAP16(a,b) do {opus_val16 tmp = a;a=b;b=tmp;} while(0) -static opus_val16 median_of_5_val16(const opus_val16 *x) -{ - opus_val16 t0, t1, t2, t3, t4; - t2 = x[2]; - if (x[0] > x[1]) - { - t0 = x[1]; - t1 = x[0]; - } else { - t0 = x[0]; - t1 = x[1]; - } - if (x[3] > x[4]) - { - t3 = x[4]; - t4 = x[3]; - } else { - t3 = x[3]; - t4 = x[4]; - } - if (t0 > t3) - { - MSWAP16(t0, t3); - MSWAP16(t1, t4); - } - if (t2 > t1) - { - if (t1 < t3) - return MIN16(t2, t3); - else - return MIN16(t4, t1); - } else { - if (t2 < t3) - return MIN16(t1, t3); - else - return MIN16(t2, t4); - } -} - -void clt_compute_extra_allocation(const CELTMode *m, const CELTMode *qext_mode, int start, int end, int qext_end, const celt_glog *bandLogE, const celt_glog *qext_bandLogE, - opus_int32 total, int *extra_pulses, int *extra_equant, int C, int LM, ec_ctx *ec, int encode, opus_val16 tone_freq, opus_val32 toneishness) -{ - int i; - opus_int32 last=0; - opus_val32 sum; - opus_val32 fill; - int iter; - int tot_bands; - int tot_samples; - VARDECL(int, depth); - VARDECL(opus_int32, cap); -#ifdef FUZZING - float depth_std; -#endif - SAVE_STACK; -#ifdef FUZZING - depth_std = -10.f*log(1e-8+(float)rand()/(float)RAND_MAX); - depth_std = FMAX(0, FMIN(48, depth_std)); -#endif - if (qext_mode != NULL) { - celt_assert(end==m->nbEBands); - tot_bands = end + qext_end; - tot_samples = qext_mode->eBands[qext_end]*C<eBands[end]-m->eBands[start])*C<nbEBands+qext_end;i++) { - extra_pulses[i] = extra_equant[i] = 0; - } - RESTORE_STACK; - return; - } - ALLOC(depth, tot_bands, int); - if (encode) { - VARDECL(opus_val16, flatE); - VARDECL(int, Ncoef); - VARDECL(opus_val16, min); - VARDECL(opus_val16, follower); - - ALLOC(flatE, tot_bands, opus_val16); - ALLOC(min, tot_bands, opus_val16); - ALLOC(Ncoef, tot_bands, int); - for (i=start;ieBands[i+1]-m->eBands[i])*C<logN[i] + SHL32(eMeans[i],DB_SHIFT-4) - GCONST(.0062f)*(i+5)*(i+5), DB_SHIFT-10); - min[i] = 0; - } - if (C==2) { - for (i=start;inbEBands+i] - GCONST(0.0625f)*m->logN[i] + SHL32(eMeans[i],DB_SHIFT-4) - GCONST(.0062f)*(i+5)*(i+5), DB_SHIFT-10)); - } - } - flatE[end-1] += QCONST16(2.f, 10); - if (qext_mode != NULL) { - opus_val16 min_depth = 0; - /* If we have enough bits, give at least 1 bit of depth to all higher bands. */ - if (total >= 3*C*(qext_mode->eBands[qext_end]-qext_mode->eBands[start])< 1.33f)) - min_depth = QCONST16(1.f, 10); - for (i=0;ieBands[i+1]-qext_mode->eBands[i])*C<logN[i] + SHL32(eMeans[i],DB_SHIFT-4) - GCONST(.0062f)*(end+i+5)*(end+i+5), DB_SHIFT-10); - } - if (C==2) { - for (i=0;ilogN[i] + SHL32(eMeans[i],DB_SHIFT-4) - GCONST(.0062f)*(end+i+5)*(end+i+5), DB_SHIFT-10)); - } - } - } - ALLOC(follower, tot_bands, opus_val16); - for (i=start+2;i=start;i--) { - follower[i] = MAX16(follower[i], follower[i+1]-QCONST16(1.f, 10)); - } - for (i=start;i>= BITRES; - fill = (SHL32(total, 10) + sum)/tot_samples; - /* Iteratively refine the fill level considering the depth min and cap. */ - for (iter=0;iter<10;iter++) { - sum = 0; - for (i=start;istorage*8<storage*8<>2; - extra_pulses[i] = ((((m->eBands[i+1]-m->eBands[i])<>2; - } - if (qext_mode) { - for (i=0;i>2; - extra_pulses[end+i] = ((((qext_mode->eBands[i+1]-qext_mode->eBands[i])<>2; - } - } - RESTORE_STACK; -} -#endif diff --git a/celt/rate.h b/celt/rate.h index 659c80f3a..8e352c8ac 100644 --- a/celt/rate.h +++ b/celt/rate.h @@ -24,7 +24,7 @@ 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. -*/ + */ #ifndef RATE_H #define RATE_H @@ -43,62 +43,57 @@ #include "cwrs.h" #include "modes.h" -void compute_pulse_cache(CELTMode *m, int LM); +void oaci_compute_pulse_cache(CELTMode *m, int LM); -static OPUS_INLINE int get_pulses(int i) -{ - return i<8 ? i : (8 + (i&7)) << ((i>>3)-1); +static OAC_INLINE int oaci_get_pulses(int i) { + return i < 8 ? i : (8 + (i&7))<<((i>>3) - 1); } -static OPUS_INLINE int bits2pulses(const CELTMode *m, int band, int LM, int bits) -{ - int i; - int lo, hi; - const unsigned char *cache; - - LM++; - cache = m->cache.bits + m->cache.index[LM*m->nbEBands+band]; - - lo = 0; - hi = cache[0]; - bits--; - for (i=0;i>1; - /* OPT: Make sure this is implemented with a conditional move */ - if ((int)cache[mid] >= bits) - hi = mid; - else - lo = mid; - } - if (bits- (lo == 0 ? -1 : (int)cache[lo]) <= (int)cache[hi]-bits) - return lo; - else - return hi; +static OAC_INLINE int oaci_bits2pulses(const CELTMode *m, int band, int LM, int bits) { + int i; + int lo, hi; + const unsigned char *cache; + + LM++; + cache = m->cache.bits + m->cache.index[LM*m->nbEBands + band]; + + lo = 0; + hi = cache[0]; + bits--; + for (i = 0; i < LOG_MAX_PSEUDO; i++) { + int mid = (lo + hi + 1)>>1; + /* OPT: Make sure this is implemented with a conditional move */ + if ((int)cache[mid] >= bits) + hi = mid; + else + lo = mid; + } + if (bits - (lo == 0 ? -1 : (int)cache[lo]) <= (int)cache[hi] - bits) + return lo; + else + return hi; } -static OPUS_INLINE int pulses2bits(const CELTMode *m, int band, int LM, int pulses) -{ - const unsigned char *cache; +static OAC_INLINE int oaci_pulses2bits(const CELTMode *m, int band, int LM, int pulses) { + const unsigned char *cache; - LM++; - cache = m->cache.bits + m->cache.index[LM*m->nbEBands+band]; - return pulses == 0 ? 0 : cache[pulses]+1; + LM++; + cache = m->cache.bits + m->cache.index[LM*m->nbEBands + band]; + return pulses == 0 ? 0 : cache[pulses] + 1; } /** Compute the pulse allocation, i.e. how many pulses will go in each - * band. - @param m mode - @param offsets Requested increase or decrease in the number of bits for + * band. + @param m mode + @param offsets Requested increase or decrease in the number of bits for each band - @param total Number of bands - @param pulses Number of pulses per band (returned) - @return Total number of bits allocated -*/ -int clt_compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, int *intensity, int *dual_stereo, - opus_int32 total, opus_int32 *balance, int *pulses, int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, int encode, int prev, int signalBandwidth); - -void clt_compute_extra_allocation(const CELTMode *m, const CELTMode *qext_mode, int start, int end, int qext_end, const celt_glog *bandLogE, const celt_glog *qext_bandLogE, - opus_int32 total, int *extra_pulses, int *extra_equant, int C, int LM, ec_ctx *ec, int encode, opus_val16 tone_freq, opus_val32 toneishness); + @param total Number of bands + @param pulses Number of pulses per band (returned) + @return Total number of bits allocated + */ +int oaci_clt_compute_allocation(const CELTMode *m, int start, int end, const int *offsets, const int *cap, int alloc_trim, + int *intensity, int *dual_stereo, + oac_int32 total, oac_int32 *balance, int *pulses, int *ebits, int *fine_priority, int C, int LM, ec_ctx *ec, + int encode, int prev, int signalBandwidth); #endif diff --git a/celt/stack_alloc.h b/celt/stack_alloc.h index 04b14ff26..bbf14a13e 100644 --- a/celt/stack_alloc.h +++ b/celt/stack_alloc.h @@ -3,7 +3,7 @@ /** @file stack_alloc.h @brief Temporary memory allocation on stack -*/ + */ /* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions @@ -27,16 +27,17 @@ 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. -*/ + */ #ifndef STACK_ALLOC_H #define STACK_ALLOC_H -#include "opus_types.h" -#include "opus_defines.h" +#include "oac_types.h" +#include "oac_defines.h" #if (!defined (VAR_ARRAYS) && !defined (USE_ALLOCA) && !defined (NONTHREADSAFE_PSEUDOSTACK)) -#error "Opus requires one of VAR_ARRAYS, USE_ALLOCA, or NONTHREADSAFE_PSEUDOSTACK be defined to select the temporary allocation mode." +# error \ + "Oac requires one of VAR_ARRAYS, USE_ALLOCA, or NONTHREADSAFE_PSEUDOSTACK be defined to select the temporary allocation mode." #endif #ifdef USE_ALLOCA @@ -90,17 +91,17 @@ #if defined(VAR_ARRAYS) -#define VARDECL(type, var) -#define ALLOC(var, size, type) type var[size] -#define SAVE_STACK -#define RESTORE_STACK -#define ALLOC_STACK +# define VARDECL(type, var) +# define ALLOC(var, size, type) type var[size] +# define SAVE_STACK +# define RESTORE_STACK +# define ALLOC_STACK /* C99 does not allow VLAs of size zero */ -#define ALLOC_NONE 1 +# define ALLOC_NONE 1 #elif defined(USE_ALLOCA) -#define VARDECL(type, var) type *var +# define VARDECL(type, var) type *var # ifdef _WIN32 # define ALLOC(var, size, type) var = ((type*)_alloca(sizeof(type)*(size))) @@ -108,100 +109,121 @@ # define ALLOC(var, size, type) var = ((type*)alloca(sizeof(type)*(size))) # endif -#define SAVE_STACK -#define RESTORE_STACK -#define ALLOC_STACK -#define ALLOC_NONE 0 +# define SAVE_STACK +# define RESTORE_STACK +# define ALLOC_STACK +# define ALLOC_NONE 0 #else -#ifdef CELT_C -char *scratch_ptr=0; -char *global_stack=0; -#else +# ifdef CELT_C +char *scratch_ptr = 0; +char *global_stack = 0; +# else extern char *global_stack; extern char *scratch_ptr; -#endif /* CELT_C */ +# endif /* CELT_C */ -#if __STDC_VERSION__ >= 201112L +# if __STDC_VERSION__ >= 201112L # include # define ALIGNOF(T) alignof(T) -#elif defined(__GNUC__) || defined(__clang__) +# elif defined(__GNUC__) || defined(__clang__) # define ALIGNOF(T) __alignof__(T) -#else -# include -# ifdef __cplusplus +# else +# include +# ifdef __cplusplus template struct alignment_helper { char c; T member; }; -# define ALIGNOF(T) (offsetof(alignment_helper, member)) -# else -# define ALIGNOF(T) (offsetof(struct { char c; T member; }, member)) +# define ALIGNOF(T) (offsetof(alignment_helper, member)) +# else +# define ALIGNOF(T) (offsetof(struct { char c; T member; }, member)) +# endif # endif -#endif -#ifdef ENABLE_VALGRIND +# ifdef ENABLE_VALGRIND -#include +# include -#ifdef CELT_C -char *global_stack_top=0; -#else +# ifdef CELT_C +char *global_stack_top = 0; +# else extern char *global_stack_top; -#endif /* CELT_C */ - -#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) -#define PUSH(stack, size, type) (VALGRIND_MAKE_MEM_NOACCESS(stack, global_stack_top-stack),ALIGN((stack),ALIGNOF(type)),VALGRIND_MAKE_MEM_UNDEFINED(stack, ((size)*sizeof(type)/sizeof(char))),(stack)+=(2*(size)*sizeof(type)/sizeof(char)),(type*)((stack)-(2*(size)*sizeof(type)/sizeof(char)))) -#define RESTORE_STACK ((global_stack = _saved_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack)) -#define ALLOC_STACK char *_saved_stack; ((global_stack = (global_stack==0) ? ((global_stack_top=(char*)opus_alloc_scratch(GLOBAL_STACK_SIZE*2)+(GLOBAL_STACK_SIZE*2))-(GLOBAL_STACK_SIZE*2)) : global_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack)); _saved_stack = global_stack; +# endif /* CELT_C */ + +# define ALIGN(stack, size) ((stack) += ((size) - (long)(stack))&((size) - 1)) +# define PUSH(stack, size, type) (VALGRIND_MAKE_MEM_NOACCESS(stack, global_stack_top - stack), \ + ALIGN((stack), ALIGNOF(type)), \ + VALGRIND_MAKE_MEM_UNDEFINED(stack, ((size)*sizeof(type)/sizeof(char))), \ + (stack) += (2*(size)*sizeof(type)/sizeof(char)), \ + (type*)((stack) - (2*(size)*sizeof(type)/sizeof(char)))) +# define RESTORE_STACK ((global_stack = _saved_stack), \ + VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top - global_stack)) +# define ALLOC_STACK char *_saved_stack; \ + ((global_stack = (global_stack == \ + 0) ? ((global_stack_top = (char*)oac_alloc_scratch(GLOBAL_STACK_SIZE*2) \ + + (GLOBAL_STACK_SIZE*2)) - (GLOBAL_STACK_SIZE*2)) : global_stack), \ + VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top - global_stack)); _saved_stack = global_stack; -#else +# else -#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) -#ifdef ENABLE_HARDENING -#include "arch.h" -#define PUSH(stack, size, type) (ALIGN((stack),ALIGNOF(type)),(void)(((int)((size)*(sizeof(type)/(sizeof(char)))) <= (scratch_ptr)+GLOBAL_STACK_SIZE-(stack))?0:CELT_FATAL("pseudostack overflow")),(stack)+=(size)*(sizeof(type)/(sizeof(char))),(type*)(void*)((stack)-(size)*(sizeof(type)/(sizeof(char))))) -#else -#define PUSH(stack, size, type) (ALIGN((stack),ALIGNOF(type)),(stack)+=(size)*(sizeof(type)/(sizeof(char))),(type*)(void*)((stack)-(size)*(sizeof(type)/(sizeof(char))))) -#endif +# define ALIGN(stack, size) ((stack) += ((size) - (long)(stack))&((size) - 1)) +# ifdef ENABLE_HARDENING +# include "arch.h" +# define PUSH(stack, size, type) (ALIGN((stack), ALIGNOF(type)), \ + (void)(((int)((size)*(sizeof(type)/(sizeof(char)))) <= \ + (scratch_ptr) + GLOBAL_STACK_SIZE \ + - (stack))?0:CELT_FATAL("pseudostack overflow")), \ + (stack) += (size)*(sizeof(type)/(sizeof(char))), \ + (type*)(void*)((stack) - (size)*(sizeof(type)/(sizeof(char))))) +# else +# define PUSH(stack, size, type) (ALIGN((stack), ALIGNOF(type)), (stack) += (size)*(sizeof(type)/(sizeof(char))), \ + (type*)(void*)((stack) - (size)*(sizeof(type)/(sizeof(char))))) +# endif -#if 0 /* Set this to 1 to instrument pseudostack usage */ -#define RESTORE_STACK (printf("%ld %s:%d\n", global_stack-scratch_ptr, __FILE__, __LINE__),global_stack = _saved_stack) -#else -#define RESTORE_STACK (global_stack = _saved_stack) -#endif -#define ALLOC_STACK char *_saved_stack; (global_stack = (global_stack==0) ? (scratch_ptr=(char*)opus_alloc_scratch(GLOBAL_STACK_SIZE)) : global_stack); _saved_stack = global_stack; +# if 0 /* Set this to 1 to instrument pseudostack usage */ +# define RESTORE_STACK (printf("%ld %s:%d\n", global_stack - scratch_ptr, __FILE__, __LINE__), \ + global_stack = _saved_stack) +# else +# define RESTORE_STACK (global_stack = _saved_stack) +# endif +# define ALLOC_STACK char *_saved_stack; \ + (global_stack = (global_stack == \ + 0) ? (scratch_ptr = (char*)oac_alloc_scratch(GLOBAL_STACK_SIZE)) : global_stack); \ + _saved_stack = global_stack; -#endif /* ENABLE_VALGRIND */ +# endif /* ENABLE_VALGRIND */ -#include "os_support.h" -#define VARDECL(type, var) type *var -#define ALLOC(var, size, type) var = PUSH(global_stack, size, type) -#define SAVE_STACK char *_saved_stack = global_stack; -#define ALLOC_NONE 0 +# include "os_support.h" +# define VARDECL(type, var) type *var +# define ALLOC(var, size, type) var = PUSH(global_stack, size, type) +# define SAVE_STACK char *_saved_stack = global_stack; +# define ALLOC_NONE 0 #endif /* VAR_ARRAYS */ #ifdef ENABLE_VALGRIND -#include -#define OPUS_CHECK_ARRAY(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*sizeof(*ptr)) -#define OPUS_CHECK_VALUE(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value) -#define OPUS_CHECK_ARRAY_COND(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*sizeof(*ptr)) -#define OPUS_CHECK_VALUE_COND(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value) -#define OPUS_PRINT_INT(value) do {fprintf(stderr, #value " = %d at %s:%d\n", value, __FILE__, __LINE__);}while(0) -#define OPUS_FPRINTF fprintf +# include +# define OAC_CHECK_ARRAY(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*sizeof(*ptr)) +# define OAC_CHECK_VALUE(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value) +# define OAC_CHECK_ARRAY_COND(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*sizeof(*ptr)) +# define OAC_CHECK_VALUE_COND(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value) +# define OAC_PRINT_INT(value) do {fprintf(stderr, #value " = %d at %s:%d\n", value, __FILE__, __LINE__);} while (0) +# define OAC_FPRINTF fprintf #else -static OPUS_INLINE int _opus_false(void) {return 0;} -#define OPUS_CHECK_ARRAY(ptr, len) _opus_false() -#define OPUS_CHECK_VALUE(value) _opus_false() -#define OPUS_PRINT_INT(value) do{}while(0) -#define OPUS_FPRINTF (void) +static OAC_INLINE int _oac_false(void) { + return 0; +} +# define OAC_CHECK_ARRAY(ptr, len) _oac_false() +# define OAC_CHECK_VALUE(value) _oac_false() +# define OAC_PRINT_INT(value) do {} while (0) +# define OAC_FPRINTF (void) #endif diff --git a/celt/static_modes_fixed.h b/celt/static_modes_fixed.h index 5bac867a7..301a68aba 100644 --- a/celt/static_modes_fixed.h +++ b/celt/static_modes_fixed.h @@ -5,4442 +5,2460 @@ #include "rate.h" #ifdef HAVE_ARM_NE10 -#define OVERRIDE_FFT 1 -#include "static_modes_fixed_arm_ne10.h" +# define OVERRIDE_FFT 1 +# include "static_modes_fixed_arm_ne10.h" #endif #ifndef DEF_WINDOW120 -#define DEF_WINDOW120 +# define DEF_WINDOW120 static const celt_coef window120[120] = { -#ifdef ENABLE_QEXT -144497, 1300330, 3611201, 7075520, 11690888, -17454086, 24361057, 32406886, 41585775, 51891010, -63314937, 75848919, 89483305, 104207389, 120009370, -136876310, 154794092, 173747379, 193719571, 214692768, -236647730, 259563841, 283419077, 308189974, 333851611, -360377579, 387739975, 415909390, 444854905, 474544098, -504943052, 536016380, 567727246, 600037405, 632907246, -666295842, 700161014, 734459402, 769146541, 804176950, -839504226, 875081152, 910859802, 946791664, 982827767, -1018918807, 1055015290, 1091067670, 1127026498, 1162842573, -1198467087, 1233851789, 1268949131, 1303712428, 1338096006, -1372055358, 1405547288, 1438530058, 1470963524, 1502809271, -1534030739, 1564593342, 1594464577, 1623614128, 1652013956, -1679638382, 1706464158, 1732470524, 1757639263, 1781954729, -1805403879, 1827976282, 1849664120, 1870462177, 1890367816, -1909380946, 1927503971, 1944741741, 1961101475, 1976592692, -1991227121, 2005018607, 2017983004, 2030138067, 2041503335, -2052100006, 2061950806, 2071079861, 2079512553, 2087275384, -2094395835, 2100902218, 2106823532, 2112189321, 2117029527, -2121374347, 2125254092, 2128699049, 2131739343, 2134404804, -2136724838, 2138728301, 2140443380, 2141897478, 2143117097, -2144127740, 2144953807, 2145618502, 2146143741, 2146550077, -2146856618, 2147080958, 2147239113, 2147345467, 2147412716, -2147451825, 2147471991, 2147480611, 2147483254, 2147483643, -#else -2, 20, 55, 108, 178, -266, 372, 494, 635, 792, -966, 1157, 1365, 1590, 1831, -2089, 2362, 2651, 2956, 3276, -3611, 3961, 4325, 4703, 5094, -5499, 5916, 6346, 6788, 7241, -7705, 8179, 8663, 9156, 9657, -10167, 10684, 11207, 11736, 12271, -12810, 13353, 13899, 14447, 14997, -15547, 16098, 16648, 17197, 17744, -18287, 18827, 19363, 19893, 20418, -20936, 21447, 21950, 22445, 22931, -23407, 23874, 24330, 24774, 25208, -25629, 26039, 26435, 26819, 27190, -27548, 27893, 28224, 28541, 28845, -29135, 29411, 29674, 29924, 30160, -30384, 30594, 30792, 30977, 31151, -31313, 31463, 31602, 31731, 31849, -31958, 32057, 32148, 32229, 32303, -32370, 32429, 32481, 32528, 32568, -32604, 32634, 32661, 32683, 32701, -32717, 32729, 32740, 32748, 32754, -32758, 32762, 32764, 32766, 32767, -32767, 32767, 32767, 32767, 32767, -#endif + 144497, 1300330, 3611201, 7075520, 11690888, + 17454086, 24361057, 32406886, 41585775, 51891010, + 63314937, 75848919, 89483305, 104207389, 120009370, + 136876310, 154794092, 173747379, 193719571, 214692768, + 236647730, 259563841, 283419077, 308189974, 333851611, + 360377579, 387739975, 415909390, 444854905, 474544098, + 504943052, 536016380, 567727246, 600037405, 632907246, + 666295842, 700161014, 734459402, 769146541, 804176950, + 839504226, 875081152, 910859802, 946791664, 982827767, + 1018918807, 1055015290, 1091067670, 1127026498, 1162842573, + 1198467087, 1233851789, 1268949131, 1303712428, 1338096006, + 1372055358, 1405547288, 1438530058, 1470963524, 1502809271, + 1534030739, 1564593342, 1594464577, 1623614128, 1652013956, + 1679638382, 1706464158, 1732470524, 1757639263, 1781954729, + 1805403879, 1827976282, 1849664120, 1870462177, 1890367816, + 1909380946, 1927503971, 1944741741, 1961101475, 1976592692, + 1991227121, 2005018607, 2017983004, 2030138067, 2041503335, + 2052100006, 2061950806, 2071079861, 2079512553, 2087275384, + 2094395835, 2100902218, 2106823532, 2112189321, 2117029527, + 2121374347, 2125254092, 2128699049, 2131739343, 2134404804, + 2136724838, 2138728301, 2140443380, 2141897478, 2143117097, + 2144127740, 2144953807, 2145618502, 2146143741, 2146550077, + 2146856618, 2147080958, 2147239113, 2147345467, 2147412716, + 2147451825, 2147471991, 2147480611, 2147483254, 2147483643, }; #endif #ifndef DEF_LOGN400 -#define DEF_LOGN400 -static const opus_int16 logN400[21] = { -0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36, }; +# define DEF_LOGN400 +static const oac_int16 logN400[21] = { + 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36, }; #endif #ifndef DEF_PULSE_CACHE50 -#define DEF_PULSE_CACHE50 -static const opus_int16 cache_index50[105] = { --1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, -82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, -41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41, -41, 41, 41, 41, 41, 123, 123, 123, 123, 240, 240, 240, 266, 266, 305, -318, 328, 336, 123, 123, 123, 123, 123, 123, 123, 123, 240, 240, 240, 240, -305, 305, 305, 318, 318, 343, 351, 358, 364, 240, 240, 240, 240, 240, 240, -240, 240, 305, 305, 305, 305, 343, 343, 343, 351, 351, 370, 376, 382, 387, +# define DEF_PULSE_CACHE50 +static const oac_int16 cache_index50[105] = { + -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, + 82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, + 41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41, + 41, 41, 41, 41, 41, 123, 123, 123, 123, 240, 240, 240, 266, 266, 305, + 318, 328, 336, 123, 123, 123, 123, 123, 123, 123, 123, 240, 240, 240, 240, + 305, 305, 305, 318, 318, 343, 351, 358, 364, 240, 240, 240, 240, 240, 240, + 240, 240, 305, 305, 305, 305, 343, 343, 343, 351, 351, 370, 376, 382, 387, }; static const unsigned char cache_bits50[392] = { -40, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 40, 15, 23, 28, -31, 34, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47, 47, 49, 50, -51, 52, 53, 54, 55, 55, 57, 58, 59, 60, 61, 62, 63, 63, 65, -66, 67, 68, 69, 70, 71, 71, 40, 20, 33, 41, 48, 53, 57, 61, -64, 66, 69, 71, 73, 75, 76, 78, 80, 82, 85, 87, 89, 91, 92, -94, 96, 98, 101, 103, 105, 107, 108, 110, 112, 114, 117, 119, 121, 123, -124, 126, 128, 40, 23, 39, 51, 60, 67, 73, 79, 83, 87, 91, 94, -97, 100, 102, 105, 107, 111, 115, 118, 121, 124, 126, 129, 131, 135, 139, -142, 145, 148, 150, 153, 155, 159, 163, 166, 169, 172, 174, 177, 179, 35, -28, 49, 65, 78, 89, 99, 107, 114, 120, 126, 132, 136, 141, 145, 149, -153, 159, 165, 171, 176, 180, 185, 189, 192, 199, 205, 211, 216, 220, 225, -229, 232, 239, 245, 251, 21, 33, 58, 79, 97, 112, 125, 137, 148, 157, -166, 174, 182, 189, 195, 201, 207, 217, 227, 235, 243, 251, 17, 35, 63, -86, 106, 123, 139, 152, 165, 177, 187, 197, 206, 214, 222, 230, 237, 250, -25, 31, 55, 75, 91, 105, 117, 128, 138, 146, 154, 161, 168, 174, 180, -185, 190, 200, 208, 215, 222, 229, 235, 240, 245, 255, 16, 36, 65, 89, -110, 128, 144, 159, 173, 185, 196, 207, 217, 226, 234, 242, 250, 11, 41, -74, 103, 128, 151, 172, 191, 209, 225, 241, 255, 9, 43, 79, 110, 138, -163, 186, 207, 227, 246, 12, 39, 71, 99, 123, 144, 164, 182, 198, 214, -228, 241, 253, 9, 44, 81, 113, 142, 168, 192, 214, 235, 255, 7, 49, -90, 127, 160, 191, 220, 247, 6, 51, 95, 134, 170, 203, 234, 7, 47, -87, 123, 155, 184, 212, 237, 6, 52, 97, 137, 174, 208, 240, 5, 57, -106, 151, 192, 231, 5, 59, 111, 158, 202, 243, 5, 55, 103, 147, 187, -224, 5, 60, 113, 161, 206, 248, 4, 65, 122, 175, 224, 4, 67, 127, -182, 234, }; + 40, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 40, 15, 23, 28, + 31, 34, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47, 47, 49, 50, + 51, 52, 53, 54, 55, 55, 57, 58, 59, 60, 61, 62, 63, 63, 65, + 66, 67, 68, 69, 70, 71, 71, 40, 20, 33, 41, 48, 53, 57, 61, + 64, 66, 69, 71, 73, 75, 76, 78, 80, 82, 85, 87, 89, 91, 92, + 94, 96, 98, 101, 103, 105, 107, 108, 110, 112, 114, 117, 119, 121, 123, + 124, 126, 128, 40, 23, 39, 51, 60, 67, 73, 79, 83, 87, 91, 94, + 97, 100, 102, 105, 107, 111, 115, 118, 121, 124, 126, 129, 131, 135, 139, + 142, 145, 148, 150, 153, 155, 159, 163, 166, 169, 172, 174, 177, 179, 35, + 28, 49, 65, 78, 89, 99, 107, 114, 120, 126, 132, 136, 141, 145, 149, + 153, 159, 165, 171, 176, 180, 185, 189, 192, 199, 205, 211, 216, 220, 225, + 229, 232, 239, 245, 251, 21, 33, 58, 79, 97, 112, 125, 137, 148, 157, + 166, 174, 182, 189, 195, 201, 207, 217, 227, 235, 243, 251, 17, 35, 63, + 86, 106, 123, 139, 152, 165, 177, 187, 197, 206, 214, 222, 230, 237, 250, + 25, 31, 55, 75, 91, 105, 117, 128, 138, 146, 154, 161, 168, 174, 180, + 185, 190, 200, 208, 215, 222, 229, 235, 240, 245, 255, 16, 36, 65, 89, + 110, 128, 144, 159, 173, 185, 196, 207, 217, 226, 234, 242, 250, 11, 41, + 74, 103, 128, 151, 172, 191, 209, 225, 241, 255, 9, 43, 79, 110, 138, + 163, 186, 207, 227, 246, 12, 39, 71, 99, 123, 144, 164, 182, 198, 214, + 228, 241, 253, 9, 44, 81, 113, 142, 168, 192, 214, 235, 255, 7, 49, + 90, 127, 160, 191, 220, 247, 6, 51, 95, 134, 170, 203, 234, 7, 47, + 87, 123, 155, 184, 212, 237, 6, 52, 97, 137, 174, 208, 240, 5, 57, + 106, 151, 192, 231, 5, 59, 111, 158, 202, 243, 5, 55, 103, 147, 187, + 224, 5, 60, 113, 161, 206, 248, 4, 65, 122, 175, 224, 4, 67, 127, + 182, 234, }; static const unsigned char cache_caps50[168] = { -224, 224, 224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 185, 185, 185, -178, 178, 168, 134, 61, 37, 224, 224, 224, 224, 224, 224, 224, 224, 240, -240, 240, 240, 207, 207, 207, 198, 198, 183, 144, 66, 40, 160, 160, 160, -160, 160, 160, 160, 160, 185, 185, 185, 185, 193, 193, 193, 183, 183, 172, -138, 64, 38, 240, 240, 240, 240, 240, 240, 240, 240, 207, 207, 207, 207, -204, 204, 204, 193, 193, 180, 143, 66, 40, 185, 185, 185, 185, 185, 185, -185, 185, 193, 193, 193, 193, 193, 193, 193, 183, 183, 172, 138, 65, 39, -207, 207, 207, 207, 207, 207, 207, 207, 204, 204, 204, 204, 201, 201, 201, -188, 188, 176, 141, 66, 40, 193, 193, 193, 193, 193, 193, 193, 193, 193, -193, 193, 193, 194, 194, 194, 184, 184, 173, 139, 65, 39, 204, 204, 204, -204, 204, 204, 204, 204, 201, 201, 201, 201, 198, 198, 198, 187, 187, 175, -140, 66, 40, }; -#endif - -#ifdef ENABLE_QEXT -# ifndef DEF_QEXT_PULSE_CACHE50 -# define DEF_QEXT_PULSE_CACHE50 -static const opus_int16 qext_cache_index50[70] = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, -41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 61, 61, -61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 72, 72, 72, -72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 80, 80, 80, 80, -80, 80, 80, 80, 80, 80, 80, 80, 80, 80, }; -static const unsigned char qext_cache_bits50[86] = { -40, 26, 45, 59, 70, 79, 87, 94, 100, 105, 110, 114, 118, 122, 125, -128, 131, 136, 141, 146, 150, 153, 157, 160, 163, 168, 173, 178, 182, 185, -189, 192, 195, 200, 205, 210, 214, 217, 221, 224, 227, 19, 34, 61, 83, -101, 118, 132, 145, 157, 167, 177, 186, 194, 202, 209, 216, 222, 234, 245, -254, 10, 42, 77, 107, 133, 157, 179, 200, 219, 236, 253, 7, 50, 93, -131, 165, 197, 227, 255, 5, 58, 109, 155, 197, 237, }; -static const unsigned char qext_cache_caps50[112] = { -159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 171, -171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 167, 167, 167, -167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 166, 166, 166, 166, 166, -166, 166, 166, 166, 166, 166, 166, 166, 166, 163, 163, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 165, 165, 165, 165, 165, 165, 165, -165, 165, 165, 165, 165, 165, 165, }; -# endif + 224, 224, 224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 185, 185, 185, + 178, 178, 168, 134, 61, 37, 224, 224, 224, 224, 224, 224, 224, 224, 240, + 240, 240, 240, 207, 207, 207, 198, 198, 183, 144, 66, 40, 160, 160, 160, + 160, 160, 160, 160, 160, 185, 185, 185, 185, 193, 193, 193, 183, 183, 172, + 138, 64, 38, 240, 240, 240, 240, 240, 240, 240, 240, 207, 207, 207, 207, + 204, 204, 204, 193, 193, 180, 143, 66, 40, 185, 185, 185, 185, 185, 185, + 185, 185, 193, 193, 193, 193, 193, 193, 193, 183, 183, 172, 138, 65, 39, + 207, 207, 207, 207, 207, 207, 207, 207, 204, 204, 204, 204, 201, 201, 201, + 188, 188, 176, 141, 66, 40, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 194, 194, 194, 184, 184, 173, 139, 65, 39, 204, 204, 204, + 204, 204, 204, 204, 204, 201, 201, 201, 201, 198, 198, 198, 187, 187, 175, + 140, 66, 40, }; #endif #ifndef FFT_TWIDDLES48000_960 -#define FFT_TWIDDLES48000_960 +# define FFT_TWIDDLES48000_960 static const kiss_twiddle_cpx fft_twiddles48000_960[480] = { -#ifdef ENABLE_QEXT -{2147483647, 0}, {2147299668, -28109692}, -{2146747759, -56214568}, {2145828016, -84309812}, -{2144540596, -112390610}, {2142885721, -140452151}, -{2140863673, -168489625}, {2138474799, -196498230}, -{2135719508, -224473166}, {2132598273, -252409639}, -{2129111628, -280302863}, {2125260170, -308148059}, -{2121044561, -335940456}, {2116465521, -363675290}, -{2111523836, -391347811}, {2106220352, -418953276}, -{2100555978, -446486956}, {2094531684, -473944133}, -{2088148504, -501320102}, {2081407530, -528610172}, -{2074309917, -555809667}, {2066856882, -582913927}, -{2059049702, -609918309}, {2050889714, -636818183}, -{2042378317, -663608942}, {2033516969, -690285996}, -{2024307188, -716844772}, {2014750553, -743280720}, -{2004848700, -769589312}, {1994603327, -795766038}, -{1984016189, -821806413}, {1973089100, -847705977}, -{1961823932, -873460290}, {1950222616, -899064940}, -{1938287139, -924515541}, {1926019547, -949807730}, -{1913421941, -974937175}, {1900496480, -999899569}, -{1887245379, -1024690635}, {1873670908, -1049306126}, -{1859775393, -1073741824}, {1845561216, -1097993542}, -{1831030811, -1122057124}, {1816186668, -1145928447}, -{1801031331, -1169603422}, {1785567396, -1193077991}, -{1769797514, -1216348132}, {1753724386, -1239409858}, -{1737350766, -1262259218}, {1720679461, -1284892296}, -{1703713325, -1307305214}, {1686455268, -1329494133}, -{1668908244, -1351455249}, {1651075262, -1373184801}, -{1632959377, -1394679064}, {1614563692, -1415934356}, -{1595891361, -1436947036}, {1576945581, -1457713501}, -{1557729600, -1478230195}, {1538246711, -1498493602}, -{1518500250, -1518500250}, {1498493602, -1538246711}, -{1478230195, -1557729600}, {1457713501, -1576945581}, -{1436947036, -1595891361}, {1415934356, -1614563692}, -{1394679064, -1632959377}, {1373184801, -1651075262}, -{1351455249, -1668908244}, {1329494133, -1686455268}, -{1307305214, -1703713325}, {1284892296, -1720679461}, -{1262259218, -1737350766}, {1239409858, -1753724386}, -{1216348132, -1769797514}, {1193077991, -1785567396}, -{1169603422, -1801031331}, {1145928447, -1816186668}, -{1122057124, -1831030811}, {1097993542, -1845561216}, -{1073741824, -1859775393}, {1049306126, -1873670908}, -{1024690635, -1887245379}, {999899569, -1900496480}, -{974937175, -1913421941}, {949807730, -1926019547}, -{924515541, -1938287139}, {899064940, -1950222616}, -{873460290, -1961823932}, {847705977, -1973089100}, -{821806413, -1984016189}, {795766038, -1994603327}, -{769589312, -2004848700}, {743280720, -2014750553}, -{716844772, -2024307188}, {690285996, -2033516969}, -{663608942, -2042378317}, {636818183, -2050889714}, -{609918309, -2059049702}, {582913927, -2066856882}, -{555809667, -2074309917}, {528610172, -2081407530}, -{501320102, -2088148504}, {473944133, -2094531684}, -{446486956, -2100555978}, {418953276, -2106220352}, -{391347811, -2111523836}, {363675290, -2116465521}, -{335940456, -2121044561}, {308148059, -2125260170}, -{280302863, -2129111628}, {252409639, -2132598273}, -{224473166, -2135719508}, {196498230, -2138474799}, -{168489625, -2140863673}, {140452151, -2142885721}, -{112390610, -2144540596}, {84309812, -2145828016}, -{56214568, -2146747759}, {28109692, -2147299668}, -{0, -2147483648}, {-28109692, -2147299668}, -{-56214568, -2146747759}, {-84309812, -2145828016}, -{-112390610, -2144540596}, {-140452151, -2142885721}, -{-168489625, -2140863673}, {-196498230, -2138474799}, -{-224473166, -2135719508}, {-252409639, -2132598273}, -{-280302863, -2129111628}, {-308148059, -2125260170}, -{-335940456, -2121044561}, {-363675290, -2116465521}, -{-391347811, -2111523836}, {-418953276, -2106220352}, -{-446486956, -2100555978}, {-473944133, -2094531684}, -{-501320102, -2088148504}, {-528610172, -2081407530}, -{-555809667, -2074309917}, {-582913927, -2066856882}, -{-609918309, -2059049702}, {-636818183, -2050889714}, -{-663608942, -2042378317}, {-690285996, -2033516969}, -{-716844772, -2024307188}, {-743280720, -2014750553}, -{-769589312, -2004848700}, {-795766038, -1994603327}, -{-821806413, -1984016189}, {-847705977, -1973089100}, -{-873460290, -1961823932}, {-899064940, -1950222616}, -{-924515541, -1938287139}, {-949807730, -1926019547}, -{-974937175, -1913421941}, {-999899569, -1900496480}, -{-1024690635, -1887245379}, {-1049306126, -1873670908}, -{-1073741824, -1859775393}, {-1097993542, -1845561216}, -{-1122057124, -1831030811}, {-1145928447, -1816186668}, -{-1169603422, -1801031331}, {-1193077991, -1785567396}, -{-1216348132, -1769797514}, {-1239409858, -1753724386}, -{-1262259218, -1737350766}, {-1284892296, -1720679461}, -{-1307305214, -1703713325}, {-1329494133, -1686455268}, -{-1351455249, -1668908244}, {-1373184801, -1651075262}, -{-1394679064, -1632959377}, {-1415934356, -1614563692}, -{-1436947036, -1595891361}, {-1457713501, -1576945581}, -{-1478230195, -1557729600}, {-1498493602, -1538246711}, -{-1518500250, -1518500250}, {-1538246711, -1498493602}, -{-1557729600, -1478230195}, {-1576945581, -1457713501}, -{-1595891361, -1436947036}, {-1614563692, -1415934356}, -{-1632959377, -1394679064}, {-1651075262, -1373184801}, -{-1668908244, -1351455249}, {-1686455268, -1329494133}, -{-1703713325, -1307305214}, {-1720679461, -1284892296}, -{-1737350766, -1262259218}, {-1753724386, -1239409858}, -{-1769797514, -1216348132}, {-1785567396, -1193077991}, -{-1801031331, -1169603422}, {-1816186668, -1145928447}, -{-1831030811, -1122057124}, {-1845561216, -1097993542}, -{-1859775393, -1073741824}, {-1873670908, -1049306126}, -{-1887245379, -1024690635}, {-1900496480, -999899569}, -{-1913421941, -974937175}, {-1926019547, -949807730}, -{-1938287139, -924515541}, {-1950222616, -899064940}, -{-1961823932, -873460290}, {-1973089100, -847705977}, -{-1984016189, -821806413}, {-1994603327, -795766038}, -{-2004848700, -769589312}, {-2014750553, -743280720}, -{-2024307188, -716844772}, {-2033516969, -690285996}, -{-2042378317, -663608942}, {-2050889714, -636818183}, -{-2059049702, -609918309}, {-2066856882, -582913927}, -{-2074309917, -555809667}, {-2081407530, -528610172}, -{-2088148504, -501320102}, {-2094531684, -473944133}, -{-2100555978, -446486956}, {-2106220352, -418953276}, -{-2111523836, -391347811}, {-2116465521, -363675290}, -{-2121044561, -335940456}, {-2125260170, -308148059}, -{-2129111628, -280302863}, {-2132598273, -252409639}, -{-2135719508, -224473166}, {-2138474799, -196498230}, -{-2140863673, -168489625}, {-2142885721, -140452151}, -{-2144540596, -112390610}, {-2145828016, -84309812}, -{-2146747759, -56214568}, {-2147299668, -28109692}, -{-2147483648, 0}, {-2147299668, 28109692}, -{-2146747759, 56214568}, {-2145828016, 84309812}, -{-2144540596, 112390610}, {-2142885721, 140452151}, -{-2140863673, 168489625}, {-2138474799, 196498230}, -{-2135719508, 224473166}, {-2132598273, 252409639}, -{-2129111628, 280302863}, {-2125260170, 308148059}, -{-2121044561, 335940456}, {-2116465521, 363675290}, -{-2111523836, 391347811}, {-2106220352, 418953276}, -{-2100555978, 446486956}, {-2094531684, 473944133}, -{-2088148504, 501320102}, {-2081407530, 528610172}, -{-2074309917, 555809667}, {-2066856882, 582913927}, -{-2059049702, 609918309}, {-2050889714, 636818183}, -{-2042378317, 663608942}, {-2033516969, 690285996}, -{-2024307188, 716844772}, {-2014750553, 743280720}, -{-2004848700, 769589312}, {-1994603327, 795766038}, -{-1984016189, 821806413}, {-1973089100, 847705977}, -{-1961823932, 873460290}, {-1950222616, 899064940}, -{-1938287139, 924515541}, {-1926019547, 949807730}, -{-1913421941, 974937175}, {-1900496480, 999899569}, -{-1887245379, 1024690635}, {-1873670908, 1049306126}, -{-1859775393, 1073741824}, {-1845561216, 1097993542}, -{-1831030811, 1122057124}, {-1816186668, 1145928447}, -{-1801031331, 1169603422}, {-1785567396, 1193077991}, -{-1769797514, 1216348132}, {-1753724386, 1239409858}, -{-1737350766, 1262259218}, {-1720679461, 1284892296}, -{-1703713325, 1307305214}, {-1686455268, 1329494133}, -{-1668908244, 1351455249}, {-1651075262, 1373184801}, -{-1632959377, 1394679064}, {-1614563692, 1415934356}, -{-1595891361, 1436947036}, {-1576945581, 1457713501}, -{-1557729600, 1478230195}, {-1538246711, 1498493602}, -{-1518500250, 1518500250}, {-1498493602, 1538246711}, -{-1478230195, 1557729600}, {-1457713501, 1576945581}, -{-1436947036, 1595891361}, {-1415934356, 1614563692}, -{-1394679064, 1632959377}, {-1373184801, 1651075262}, -{-1351455249, 1668908244}, {-1329494133, 1686455268}, -{-1307305214, 1703713325}, {-1284892296, 1720679461}, -{-1262259218, 1737350766}, {-1239409858, 1753724386}, -{-1216348132, 1769797514}, {-1193077991, 1785567396}, -{-1169603422, 1801031331}, {-1145928447, 1816186668}, -{-1122057124, 1831030811}, {-1097993542, 1845561216}, -{-1073741824, 1859775393}, {-1049306126, 1873670908}, -{-1024690635, 1887245379}, {-999899569, 1900496480}, -{-974937175, 1913421941}, {-949807730, 1926019547}, -{-924515541, 1938287139}, {-899064940, 1950222616}, -{-873460290, 1961823932}, {-847705977, 1973089100}, -{-821806413, 1984016189}, {-795766038, 1994603327}, -{-769589312, 2004848700}, {-743280720, 2014750553}, -{-716844772, 2024307188}, {-690285996, 2033516969}, -{-663608942, 2042378317}, {-636818183, 2050889714}, -{-609918309, 2059049702}, {-582913927, 2066856882}, -{-555809667, 2074309917}, {-528610172, 2081407530}, -{-501320102, 2088148504}, {-473944133, 2094531684}, -{-446486956, 2100555978}, {-418953276, 2106220352}, -{-391347811, 2111523836}, {-363675290, 2116465521}, -{-335940456, 2121044561}, {-308148059, 2125260170}, -{-280302863, 2129111628}, {-252409639, 2132598273}, -{-224473166, 2135719508}, {-196498230, 2138474799}, -{-168489625, 2140863673}, {-140452151, 2142885721}, -{-112390610, 2144540596}, {-84309812, 2145828016}, -{-56214568, 2146747759}, {-28109692, 2147299668}, -{0, 2147483647}, {28109692, 2147299668}, -{56214568, 2146747759}, {84309812, 2145828016}, -{112390610, 2144540596}, {140452151, 2142885721}, -{168489625, 2140863673}, {196498230, 2138474799}, -{224473166, 2135719508}, {252409639, 2132598273}, -{280302863, 2129111628}, {308148059, 2125260170}, -{335940456, 2121044561}, {363675290, 2116465521}, -{391347811, 2111523836}, {418953276, 2106220352}, -{446486956, 2100555978}, {473944133, 2094531684}, -{501320102, 2088148504}, {528610172, 2081407530}, -{555809667, 2074309917}, {582913927, 2066856882}, -{609918309, 2059049702}, {636818183, 2050889714}, -{663608942, 2042378317}, {690285996, 2033516969}, -{716844772, 2024307188}, {743280720, 2014750553}, -{769589312, 2004848700}, {795766038, 1994603327}, -{821806413, 1984016189}, {847705977, 1973089100}, -{873460290, 1961823932}, {899064940, 1950222616}, -{924515541, 1938287139}, {949807730, 1926019547}, -{974937175, 1913421941}, {999899569, 1900496480}, -{1024690635, 1887245379}, {1049306126, 1873670908}, -{1073741824, 1859775393}, {1097993542, 1845561216}, -{1122057124, 1831030811}, {1145928447, 1816186668}, -{1169603422, 1801031331}, {1193077991, 1785567396}, -{1216348132, 1769797514}, {1239409858, 1753724386}, -{1262259218, 1737350766}, {1284892296, 1720679461}, -{1307305214, 1703713325}, {1329494133, 1686455268}, -{1351455249, 1668908244}, {1373184801, 1651075262}, -{1394679064, 1632959377}, {1415934356, 1614563692}, -{1436947036, 1595891361}, {1457713501, 1576945581}, -{1478230195, 1557729600}, {1498493602, 1538246711}, -{1518500250, 1518500250}, {1538246711, 1498493602}, -{1557729600, 1478230195}, {1576945581, 1457713501}, -{1595891361, 1436947036}, {1614563692, 1415934356}, -{1632959377, 1394679064}, {1651075262, 1373184801}, -{1668908244, 1351455249}, {1686455268, 1329494133}, -{1703713325, 1307305214}, {1720679461, 1284892296}, -{1737350766, 1262259218}, {1753724386, 1239409858}, -{1769797514, 1216348132}, {1785567396, 1193077991}, -{1801031331, 1169603422}, {1816186668, 1145928447}, -{1831030811, 1122057124}, {1845561216, 1097993542}, -{1859775393, 1073741824}, {1873670908, 1049306126}, -{1887245379, 1024690635}, {1900496480, 999899569}, -{1913421941, 974937175}, {1926019547, 949807730}, -{1938287139, 924515541}, {1950222616, 899064940}, -{1961823932, 873460290}, {1973089100, 847705977}, -{1984016189, 821806413}, {1994603327, 795766038}, -{2004848700, 769589312}, {2014750553, 743280720}, -{2024307188, 716844772}, {2033516969, 690285996}, -{2042378317, 663608942}, {2050889714, 636818183}, -{2059049702, 609918309}, {2066856882, 582913927}, -{2074309917, 555809667}, {2081407530, 528610172}, -{2088148504, 501320102}, {2094531684, 473944133}, -{2100555978, 446486956}, {2106220352, 418953276}, -{2111523836, 391347811}, {2116465521, 363675290}, -{2121044561, 335940456}, {2125260170, 308148059}, -{2129111628, 280302863}, {2132598273, 252409639}, -{2135719508, 224473166}, {2138474799, 196498230}, -{2140863673, 168489625}, {2142885721, 140452151}, -{2144540596, 112390610}, {2145828016, 84309812}, -{2146747759, 56214568}, {2147299668, 28109692}, -#else -{32767, 0}, {32765, -429}, -{32757, -858}, {32743, -1286}, -{32723, -1715}, {32698, -2143}, -{32667, -2571}, {32631, -2998}, -{32588, -3425}, {32541, -3851}, -{32488, -4277}, {32429, -4702}, -{32365, -5126}, {32295, -5549}, -{32219, -5971}, {32138, -6393}, -{32052, -6813}, {31960, -7232}, -{31863, -7650}, {31760, -8066}, -{31651, -8481}, {31538, -8895}, -{31419, -9307}, {31294, -9717}, -{31164, -10126}, {31029, -10533}, -{30888, -10938}, {30743, -11342}, -{30592, -11743}, {30435, -12142}, -{30274, -12540}, {30107, -12935}, -{29935, -13328}, {29758, -13719}, -{29576, -14107}, {29389, -14493}, -{29197, -14876}, {28999, -15257}, -{28797, -15636}, {28590, -16011}, -{28378, -16384}, {28161, -16754}, -{27939, -17121}, {27713, -17485}, -{27482, -17847}, {27246, -18205}, -{27005, -18560}, {26760, -18912}, -{26510, -19261}, {26255, -19606}, -{25997, -19948}, {25733, -20286}, -{25466, -20622}, {25193, -20953}, -{24917, -21281}, {24636, -21605}, -{24351, -21926}, {24062, -22243}, -{23769, -22556}, {23472, -22865}, -{23170, -23170}, {22865, -23472}, -{22556, -23769}, {22243, -24062}, -{21926, -24351}, {21605, -24636}, -{21281, -24917}, {20953, -25193}, -{20622, -25466}, {20286, -25733}, -{19948, -25997}, {19606, -26255}, -{19261, -26510}, {18912, -26760}, -{18560, -27005}, {18205, -27246}, -{17847, -27482}, {17485, -27713}, -{17121, -27939}, {16754, -28161}, -{16384, -28378}, {16011, -28590}, -{15636, -28797}, {15257, -28999}, -{14876, -29197}, {14493, -29389}, -{14107, -29576}, {13719, -29758}, -{13328, -29935}, {12935, -30107}, -{12540, -30274}, {12142, -30435}, -{11743, -30592}, {11342, -30743}, -{10938, -30888}, {10533, -31029}, -{10126, -31164}, {9717, -31294}, -{9307, -31419}, {8895, -31538}, -{8481, -31651}, {8066, -31760}, -{7650, -31863}, {7232, -31960}, -{6813, -32052}, {6393, -32138}, -{5971, -32219}, {5549, -32295}, -{5126, -32365}, {4702, -32429}, -{4277, -32488}, {3851, -32541}, -{3425, -32588}, {2998, -32631}, -{2571, -32667}, {2143, -32698}, -{1715, -32723}, {1286, -32743}, -{858, -32757}, {429, -32765}, -{0, -32767}, {-429, -32765}, -{-858, -32757}, {-1286, -32743}, -{-1715, -32723}, {-2143, -32698}, -{-2571, -32667}, {-2998, -32631}, -{-3425, -32588}, {-3851, -32541}, -{-4277, -32488}, {-4702, -32429}, -{-5126, -32365}, {-5549, -32295}, -{-5971, -32219}, {-6393, -32138}, -{-6813, -32052}, {-7232, -31960}, -{-7650, -31863}, {-8066, -31760}, -{-8481, -31651}, {-8895, -31538}, -{-9307, -31419}, {-9717, -31294}, -{-10126, -31164}, {-10533, -31029}, -{-10938, -30888}, {-11342, -30743}, -{-11743, -30592}, {-12142, -30435}, -{-12540, -30274}, {-12935, -30107}, -{-13328, -29935}, {-13719, -29758}, -{-14107, -29576}, {-14493, -29389}, -{-14876, -29197}, {-15257, -28999}, -{-15636, -28797}, {-16011, -28590}, -{-16384, -28378}, {-16754, -28161}, -{-17121, -27939}, {-17485, -27713}, -{-17847, -27482}, {-18205, -27246}, -{-18560, -27005}, {-18912, -26760}, -{-19261, -26510}, {-19606, -26255}, -{-19948, -25997}, {-20286, -25733}, -{-20622, -25466}, {-20953, -25193}, -{-21281, -24917}, {-21605, -24636}, -{-21926, -24351}, {-22243, -24062}, -{-22556, -23769}, {-22865, -23472}, -{-23170, -23170}, {-23472, -22865}, -{-23769, -22556}, {-24062, -22243}, -{-24351, -21926}, {-24636, -21605}, -{-24917, -21281}, {-25193, -20953}, -{-25466, -20622}, {-25733, -20286}, -{-25997, -19948}, {-26255, -19606}, -{-26510, -19261}, {-26760, -18912}, -{-27005, -18560}, {-27246, -18205}, -{-27482, -17847}, {-27713, -17485}, -{-27939, -17121}, {-28161, -16754}, -{-28378, -16384}, {-28590, -16011}, -{-28797, -15636}, {-28999, -15257}, -{-29197, -14876}, {-29389, -14493}, -{-29576, -14107}, {-29758, -13719}, -{-29935, -13328}, {-30107, -12935}, -{-30274, -12540}, {-30435, -12142}, -{-30592, -11743}, {-30743, -11342}, -{-30888, -10938}, {-31029, -10533}, -{-31164, -10126}, {-31294, -9717}, -{-31419, -9307}, {-31538, -8895}, -{-31651, -8481}, {-31760, -8066}, -{-31863, -7650}, {-31960, -7232}, -{-32052, -6813}, {-32138, -6393}, -{-32219, -5971}, {-32295, -5549}, -{-32365, -5126}, {-32429, -4702}, -{-32488, -4277}, {-32541, -3851}, -{-32588, -3425}, {-32631, -2998}, -{-32667, -2571}, {-32698, -2143}, -{-32723, -1715}, {-32743, -1286}, -{-32757, -858}, {-32765, -429}, -{-32767, 0}, {-32765, 429}, -{-32757, 858}, {-32743, 1286}, -{-32723, 1715}, {-32698, 2143}, -{-32667, 2571}, {-32631, 2998}, -{-32588, 3425}, {-32541, 3851}, -{-32488, 4277}, {-32429, 4702}, -{-32365, 5126}, {-32295, 5549}, -{-32219, 5971}, {-32138, 6393}, -{-32052, 6813}, {-31960, 7232}, -{-31863, 7650}, {-31760, 8066}, -{-31651, 8481}, {-31538, 8895}, -{-31419, 9307}, {-31294, 9717}, -{-31164, 10126}, {-31029, 10533}, -{-30888, 10938}, {-30743, 11342}, -{-30592, 11743}, {-30435, 12142}, -{-30274, 12540}, {-30107, 12935}, -{-29935, 13328}, {-29758, 13719}, -{-29576, 14107}, {-29389, 14493}, -{-29197, 14876}, {-28999, 15257}, -{-28797, 15636}, {-28590, 16011}, -{-28378, 16384}, {-28161, 16754}, -{-27939, 17121}, {-27713, 17485}, -{-27482, 17847}, {-27246, 18205}, -{-27005, 18560}, {-26760, 18912}, -{-26510, 19261}, {-26255, 19606}, -{-25997, 19948}, {-25733, 20286}, -{-25466, 20622}, {-25193, 20953}, -{-24917, 21281}, {-24636, 21605}, -{-24351, 21926}, {-24062, 22243}, -{-23769, 22556}, {-23472, 22865}, -{-23170, 23170}, {-22865, 23472}, -{-22556, 23769}, {-22243, 24062}, -{-21926, 24351}, {-21605, 24636}, -{-21281, 24917}, {-20953, 25193}, -{-20622, 25466}, {-20286, 25733}, -{-19948, 25997}, {-19606, 26255}, -{-19261, 26510}, {-18912, 26760}, -{-18560, 27005}, {-18205, 27246}, -{-17847, 27482}, {-17485, 27713}, -{-17121, 27939}, {-16754, 28161}, -{-16384, 28378}, {-16011, 28590}, -{-15636, 28797}, {-15257, 28999}, -{-14876, 29197}, {-14493, 29389}, -{-14107, 29576}, {-13719, 29758}, -{-13328, 29935}, {-12935, 30107}, -{-12540, 30274}, {-12142, 30435}, -{-11743, 30592}, {-11342, 30743}, -{-10938, 30888}, {-10533, 31029}, -{-10126, 31164}, {-9717, 31294}, -{-9307, 31419}, {-8895, 31538}, -{-8481, 31651}, {-8066, 31760}, -{-7650, 31863}, {-7232, 31960}, -{-6813, 32052}, {-6393, 32138}, -{-5971, 32219}, {-5549, 32295}, -{-5126, 32365}, {-4702, 32429}, -{-4277, 32488}, {-3851, 32541}, -{-3425, 32588}, {-2998, 32631}, -{-2571, 32667}, {-2143, 32698}, -{-1715, 32723}, {-1286, 32743}, -{-858, 32757}, {-429, 32765}, -{0, 32767}, {429, 32765}, -{858, 32757}, {1286, 32743}, -{1715, 32723}, {2143, 32698}, -{2571, 32667}, {2998, 32631}, -{3425, 32588}, {3851, 32541}, -{4277, 32488}, {4702, 32429}, -{5126, 32365}, {5549, 32295}, -{5971, 32219}, {6393, 32138}, -{6813, 32052}, {7232, 31960}, -{7650, 31863}, {8066, 31760}, -{8481, 31651}, {8895, 31538}, -{9307, 31419}, {9717, 31294}, -{10126, 31164}, {10533, 31029}, -{10938, 30888}, {11342, 30743}, -{11743, 30592}, {12142, 30435}, -{12540, 30274}, {12935, 30107}, -{13328, 29935}, {13719, 29758}, -{14107, 29576}, {14493, 29389}, -{14876, 29197}, {15257, 28999}, -{15636, 28797}, {16011, 28590}, -{16384, 28378}, {16754, 28161}, -{17121, 27939}, {17485, 27713}, -{17847, 27482}, {18205, 27246}, -{18560, 27005}, {18912, 26760}, -{19261, 26510}, {19606, 26255}, -{19948, 25997}, {20286, 25733}, -{20622, 25466}, {20953, 25193}, -{21281, 24917}, {21605, 24636}, -{21926, 24351}, {22243, 24062}, -{22556, 23769}, {22865, 23472}, -{23170, 23170}, {23472, 22865}, -{23769, 22556}, {24062, 22243}, -{24351, 21926}, {24636, 21605}, -{24917, 21281}, {25193, 20953}, -{25466, 20622}, {25733, 20286}, -{25997, 19948}, {26255, 19606}, -{26510, 19261}, {26760, 18912}, -{27005, 18560}, {27246, 18205}, -{27482, 17847}, {27713, 17485}, -{27939, 17121}, {28161, 16754}, -{28378, 16384}, {28590, 16011}, -{28797, 15636}, {28999, 15257}, -{29197, 14876}, {29389, 14493}, -{29576, 14107}, {29758, 13719}, -{29935, 13328}, {30107, 12935}, -{30274, 12540}, {30435, 12142}, -{30592, 11743}, {30743, 11342}, -{30888, 10938}, {31029, 10533}, -{31164, 10126}, {31294, 9717}, -{31419, 9307}, {31538, 8895}, -{31651, 8481}, {31760, 8066}, -{31863, 7650}, {31960, 7232}, -{32052, 6813}, {32138, 6393}, -{32219, 5971}, {32295, 5549}, -{32365, 5126}, {32429, 4702}, -{32488, 4277}, {32541, 3851}, -{32588, 3425}, {32631, 2998}, -{32667, 2571}, {32698, 2143}, -{32723, 1715}, {32743, 1286}, -{32757, 858}, {32765, 429}, -#endif + {2147483647, 0}, {2147299668, -28109692}, + {2146747759, -56214568}, {2145828016, -84309812}, + {2144540596, -112390610}, {2142885721, -140452151}, + {2140863673, -168489625}, {2138474799, -196498230}, + {2135719508, -224473166}, {2132598273, -252409639}, + {2129111628, -280302863}, {2125260170, -308148059}, + {2121044561, -335940456}, {2116465521, -363675290}, + {2111523836, -391347811}, {2106220352, -418953276}, + {2100555978, -446486956}, {2094531684, -473944133}, + {2088148504, -501320102}, {2081407530, -528610172}, + {2074309917, -555809667}, {2066856882, -582913927}, + {2059049702, -609918309}, {2050889714, -636818183}, + {2042378317, -663608942}, {2033516969, -690285996}, + {2024307188, -716844772}, {2014750553, -743280720}, + {2004848700, -769589312}, {1994603327, -795766038}, + {1984016189, -821806413}, {1973089100, -847705977}, + {1961823932, -873460290}, {1950222616, -899064940}, + {1938287139, -924515541}, {1926019547, -949807730}, + {1913421941, -974937175}, {1900496480, -999899569}, + {1887245379, -1024690635}, {1873670908, -1049306126}, + {1859775393, -1073741824}, {1845561216, -1097993542}, + {1831030811, -1122057124}, {1816186668, -1145928447}, + {1801031331, -1169603422}, {1785567396, -1193077991}, + {1769797514, -1216348132}, {1753724386, -1239409858}, + {1737350766, -1262259218}, {1720679461, -1284892296}, + {1703713325, -1307305214}, {1686455268, -1329494133}, + {1668908244, -1351455249}, {1651075262, -1373184801}, + {1632959377, -1394679064}, {1614563692, -1415934356}, + {1595891361, -1436947036}, {1576945581, -1457713501}, + {1557729600, -1478230195}, {1538246711, -1498493602}, + {1518500250, -1518500250}, {1498493602, -1538246711}, + {1478230195, -1557729600}, {1457713501, -1576945581}, + {1436947036, -1595891361}, {1415934356, -1614563692}, + {1394679064, -1632959377}, {1373184801, -1651075262}, + {1351455249, -1668908244}, {1329494133, -1686455268}, + {1307305214, -1703713325}, {1284892296, -1720679461}, + {1262259218, -1737350766}, {1239409858, -1753724386}, + {1216348132, -1769797514}, {1193077991, -1785567396}, + {1169603422, -1801031331}, {1145928447, -1816186668}, + {1122057124, -1831030811}, {1097993542, -1845561216}, + {1073741824, -1859775393}, {1049306126, -1873670908}, + {1024690635, -1887245379}, {999899569, -1900496480}, + {974937175, -1913421941}, {949807730, -1926019547}, + {924515541, -1938287139}, {899064940, -1950222616}, + {873460290, -1961823932}, {847705977, -1973089100}, + {821806413, -1984016189}, {795766038, -1994603327}, + {769589312, -2004848700}, {743280720, -2014750553}, + {716844772, -2024307188}, {690285996, -2033516969}, + {663608942, -2042378317}, {636818183, -2050889714}, + {609918309, -2059049702}, {582913927, -2066856882}, + {555809667, -2074309917}, {528610172, -2081407530}, + {501320102, -2088148504}, {473944133, -2094531684}, + {446486956, -2100555978}, {418953276, -2106220352}, + {391347811, -2111523836}, {363675290, -2116465521}, + {335940456, -2121044561}, {308148059, -2125260170}, + {280302863, -2129111628}, {252409639, -2132598273}, + {224473166, -2135719508}, {196498230, -2138474799}, + {168489625, -2140863673}, {140452151, -2142885721}, + {112390610, -2144540596}, {84309812, -2145828016}, + {56214568, -2146747759}, {28109692, -2147299668}, + {0, -2147483648}, {-28109692, -2147299668}, + {-56214568, -2146747759}, {-84309812, -2145828016}, + {-112390610, -2144540596}, {-140452151, -2142885721}, + {-168489625, -2140863673}, {-196498230, -2138474799}, + {-224473166, -2135719508}, {-252409639, -2132598273}, + {-280302863, -2129111628}, {-308148059, -2125260170}, + {-335940456, -2121044561}, {-363675290, -2116465521}, + {-391347811, -2111523836}, {-418953276, -2106220352}, + {-446486956, -2100555978}, {-473944133, -2094531684}, + {-501320102, -2088148504}, {-528610172, -2081407530}, + {-555809667, -2074309917}, {-582913927, -2066856882}, + {-609918309, -2059049702}, {-636818183, -2050889714}, + {-663608942, -2042378317}, {-690285996, -2033516969}, + {-716844772, -2024307188}, {-743280720, -2014750553}, + {-769589312, -2004848700}, {-795766038, -1994603327}, + {-821806413, -1984016189}, {-847705977, -1973089100}, + {-873460290, -1961823932}, {-899064940, -1950222616}, + {-924515541, -1938287139}, {-949807730, -1926019547}, + {-974937175, -1913421941}, {-999899569, -1900496480}, + {-1024690635, -1887245379}, {-1049306126, -1873670908}, + {-1073741824, -1859775393}, {-1097993542, -1845561216}, + {-1122057124, -1831030811}, {-1145928447, -1816186668}, + {-1169603422, -1801031331}, {-1193077991, -1785567396}, + {-1216348132, -1769797514}, {-1239409858, -1753724386}, + {-1262259218, -1737350766}, {-1284892296, -1720679461}, + {-1307305214, -1703713325}, {-1329494133, -1686455268}, + {-1351455249, -1668908244}, {-1373184801, -1651075262}, + {-1394679064, -1632959377}, {-1415934356, -1614563692}, + {-1436947036, -1595891361}, {-1457713501, -1576945581}, + {-1478230195, -1557729600}, {-1498493602, -1538246711}, + {-1518500250, -1518500250}, {-1538246711, -1498493602}, + {-1557729600, -1478230195}, {-1576945581, -1457713501}, + {-1595891361, -1436947036}, {-1614563692, -1415934356}, + {-1632959377, -1394679064}, {-1651075262, -1373184801}, + {-1668908244, -1351455249}, {-1686455268, -1329494133}, + {-1703713325, -1307305214}, {-1720679461, -1284892296}, + {-1737350766, -1262259218}, {-1753724386, -1239409858}, + {-1769797514, -1216348132}, {-1785567396, -1193077991}, + {-1801031331, -1169603422}, {-1816186668, -1145928447}, + {-1831030811, -1122057124}, {-1845561216, -1097993542}, + {-1859775393, -1073741824}, {-1873670908, -1049306126}, + {-1887245379, -1024690635}, {-1900496480, -999899569}, + {-1913421941, -974937175}, {-1926019547, -949807730}, + {-1938287139, -924515541}, {-1950222616, -899064940}, + {-1961823932, -873460290}, {-1973089100, -847705977}, + {-1984016189, -821806413}, {-1994603327, -795766038}, + {-2004848700, -769589312}, {-2014750553, -743280720}, + {-2024307188, -716844772}, {-2033516969, -690285996}, + {-2042378317, -663608942}, {-2050889714, -636818183}, + {-2059049702, -609918309}, {-2066856882, -582913927}, + {-2074309917, -555809667}, {-2081407530, -528610172}, + {-2088148504, -501320102}, {-2094531684, -473944133}, + {-2100555978, -446486956}, {-2106220352, -418953276}, + {-2111523836, -391347811}, {-2116465521, -363675290}, + {-2121044561, -335940456}, {-2125260170, -308148059}, + {-2129111628, -280302863}, {-2132598273, -252409639}, + {-2135719508, -224473166}, {-2138474799, -196498230}, + {-2140863673, -168489625}, {-2142885721, -140452151}, + {-2144540596, -112390610}, {-2145828016, -84309812}, + {-2146747759, -56214568}, {-2147299668, -28109692}, + {-2147483648, 0}, {-2147299668, 28109692}, + {-2146747759, 56214568}, {-2145828016, 84309812}, + {-2144540596, 112390610}, {-2142885721, 140452151}, + {-2140863673, 168489625}, {-2138474799, 196498230}, + {-2135719508, 224473166}, {-2132598273, 252409639}, + {-2129111628, 280302863}, {-2125260170, 308148059}, + {-2121044561, 335940456}, {-2116465521, 363675290}, + {-2111523836, 391347811}, {-2106220352, 418953276}, + {-2100555978, 446486956}, {-2094531684, 473944133}, + {-2088148504, 501320102}, {-2081407530, 528610172}, + {-2074309917, 555809667}, {-2066856882, 582913927}, + {-2059049702, 609918309}, {-2050889714, 636818183}, + {-2042378317, 663608942}, {-2033516969, 690285996}, + {-2024307188, 716844772}, {-2014750553, 743280720}, + {-2004848700, 769589312}, {-1994603327, 795766038}, + {-1984016189, 821806413}, {-1973089100, 847705977}, + {-1961823932, 873460290}, {-1950222616, 899064940}, + {-1938287139, 924515541}, {-1926019547, 949807730}, + {-1913421941, 974937175}, {-1900496480, 999899569}, + {-1887245379, 1024690635}, {-1873670908, 1049306126}, + {-1859775393, 1073741824}, {-1845561216, 1097993542}, + {-1831030811, 1122057124}, {-1816186668, 1145928447}, + {-1801031331, 1169603422}, {-1785567396, 1193077991}, + {-1769797514, 1216348132}, {-1753724386, 1239409858}, + {-1737350766, 1262259218}, {-1720679461, 1284892296}, + {-1703713325, 1307305214}, {-1686455268, 1329494133}, + {-1668908244, 1351455249}, {-1651075262, 1373184801}, + {-1632959377, 1394679064}, {-1614563692, 1415934356}, + {-1595891361, 1436947036}, {-1576945581, 1457713501}, + {-1557729600, 1478230195}, {-1538246711, 1498493602}, + {-1518500250, 1518500250}, {-1498493602, 1538246711}, + {-1478230195, 1557729600}, {-1457713501, 1576945581}, + {-1436947036, 1595891361}, {-1415934356, 1614563692}, + {-1394679064, 1632959377}, {-1373184801, 1651075262}, + {-1351455249, 1668908244}, {-1329494133, 1686455268}, + {-1307305214, 1703713325}, {-1284892296, 1720679461}, + {-1262259218, 1737350766}, {-1239409858, 1753724386}, + {-1216348132, 1769797514}, {-1193077991, 1785567396}, + {-1169603422, 1801031331}, {-1145928447, 1816186668}, + {-1122057124, 1831030811}, {-1097993542, 1845561216}, + {-1073741824, 1859775393}, {-1049306126, 1873670908}, + {-1024690635, 1887245379}, {-999899569, 1900496480}, + {-974937175, 1913421941}, {-949807730, 1926019547}, + {-924515541, 1938287139}, {-899064940, 1950222616}, + {-873460290, 1961823932}, {-847705977, 1973089100}, + {-821806413, 1984016189}, {-795766038, 1994603327}, + {-769589312, 2004848700}, {-743280720, 2014750553}, + {-716844772, 2024307188}, {-690285996, 2033516969}, + {-663608942, 2042378317}, {-636818183, 2050889714}, + {-609918309, 2059049702}, {-582913927, 2066856882}, + {-555809667, 2074309917}, {-528610172, 2081407530}, + {-501320102, 2088148504}, {-473944133, 2094531684}, + {-446486956, 2100555978}, {-418953276, 2106220352}, + {-391347811, 2111523836}, {-363675290, 2116465521}, + {-335940456, 2121044561}, {-308148059, 2125260170}, + {-280302863, 2129111628}, {-252409639, 2132598273}, + {-224473166, 2135719508}, {-196498230, 2138474799}, + {-168489625, 2140863673}, {-140452151, 2142885721}, + {-112390610, 2144540596}, {-84309812, 2145828016}, + {-56214568, 2146747759}, {-28109692, 2147299668}, + {0, 2147483647}, {28109692, 2147299668}, + {56214568, 2146747759}, {84309812, 2145828016}, + {112390610, 2144540596}, {140452151, 2142885721}, + {168489625, 2140863673}, {196498230, 2138474799}, + {224473166, 2135719508}, {252409639, 2132598273}, + {280302863, 2129111628}, {308148059, 2125260170}, + {335940456, 2121044561}, {363675290, 2116465521}, + {391347811, 2111523836}, {418953276, 2106220352}, + {446486956, 2100555978}, {473944133, 2094531684}, + {501320102, 2088148504}, {528610172, 2081407530}, + {555809667, 2074309917}, {582913927, 2066856882}, + {609918309, 2059049702}, {636818183, 2050889714}, + {663608942, 2042378317}, {690285996, 2033516969}, + {716844772, 2024307188}, {743280720, 2014750553}, + {769589312, 2004848700}, {795766038, 1994603327}, + {821806413, 1984016189}, {847705977, 1973089100}, + {873460290, 1961823932}, {899064940, 1950222616}, + {924515541, 1938287139}, {949807730, 1926019547}, + {974937175, 1913421941}, {999899569, 1900496480}, + {1024690635, 1887245379}, {1049306126, 1873670908}, + {1073741824, 1859775393}, {1097993542, 1845561216}, + {1122057124, 1831030811}, {1145928447, 1816186668}, + {1169603422, 1801031331}, {1193077991, 1785567396}, + {1216348132, 1769797514}, {1239409858, 1753724386}, + {1262259218, 1737350766}, {1284892296, 1720679461}, + {1307305214, 1703713325}, {1329494133, 1686455268}, + {1351455249, 1668908244}, {1373184801, 1651075262}, + {1394679064, 1632959377}, {1415934356, 1614563692}, + {1436947036, 1595891361}, {1457713501, 1576945581}, + {1478230195, 1557729600}, {1498493602, 1538246711}, + {1518500250, 1518500250}, {1538246711, 1498493602}, + {1557729600, 1478230195}, {1576945581, 1457713501}, + {1595891361, 1436947036}, {1614563692, 1415934356}, + {1632959377, 1394679064}, {1651075262, 1373184801}, + {1668908244, 1351455249}, {1686455268, 1329494133}, + {1703713325, 1307305214}, {1720679461, 1284892296}, + {1737350766, 1262259218}, {1753724386, 1239409858}, + {1769797514, 1216348132}, {1785567396, 1193077991}, + {1801031331, 1169603422}, {1816186668, 1145928447}, + {1831030811, 1122057124}, {1845561216, 1097993542}, + {1859775393, 1073741824}, {1873670908, 1049306126}, + {1887245379, 1024690635}, {1900496480, 999899569}, + {1913421941, 974937175}, {1926019547, 949807730}, + {1938287139, 924515541}, {1950222616, 899064940}, + {1961823932, 873460290}, {1973089100, 847705977}, + {1984016189, 821806413}, {1994603327, 795766038}, + {2004848700, 769589312}, {2014750553, 743280720}, + {2024307188, 716844772}, {2033516969, 690285996}, + {2042378317, 663608942}, {2050889714, 636818183}, + {2059049702, 609918309}, {2066856882, 582913927}, + {2074309917, 555809667}, {2081407530, 528610172}, + {2088148504, 501320102}, {2094531684, 473944133}, + {2100555978, 446486956}, {2106220352, 418953276}, + {2111523836, 391347811}, {2116465521, 363675290}, + {2121044561, 335940456}, {2125260170, 308148059}, + {2129111628, 280302863}, {2132598273, 252409639}, + {2135719508, 224473166}, {2138474799, 196498230}, + {2140863673, 168489625}, {2142885721, 140452151}, + {2144540596, 112390610}, {2145828016, 84309812}, + {2146747759, 56214568}, {2147299668, 28109692}, }; -#ifndef FFT_BITREV480 -#define FFT_BITREV480 -static const opus_int16 fft_bitrev480[480] = { -0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, -8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, -16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, -24, 120, 216, 312, 408, 56, 152, 248, 344, 440, 88, 184, 280, 376, 472, -4, 100, 196, 292, 388, 36, 132, 228, 324, 420, 68, 164, 260, 356, 452, -12, 108, 204, 300, 396, 44, 140, 236, 332, 428, 76, 172, 268, 364, 460, -20, 116, 212, 308, 404, 52, 148, 244, 340, 436, 84, 180, 276, 372, 468, -28, 124, 220, 316, 412, 60, 156, 252, 348, 444, 92, 188, 284, 380, 476, -1, 97, 193, 289, 385, 33, 129, 225, 321, 417, 65, 161, 257, 353, 449, -9, 105, 201, 297, 393, 41, 137, 233, 329, 425, 73, 169, 265, 361, 457, -17, 113, 209, 305, 401, 49, 145, 241, 337, 433, 81, 177, 273, 369, 465, -25, 121, 217, 313, 409, 57, 153, 249, 345, 441, 89, 185, 281, 377, 473, -5, 101, 197, 293, 389, 37, 133, 229, 325, 421, 69, 165, 261, 357, 453, -13, 109, 205, 301, 397, 45, 141, 237, 333, 429, 77, 173, 269, 365, 461, -21, 117, 213, 309, 405, 53, 149, 245, 341, 437, 85, 181, 277, 373, 469, -29, 125, 221, 317, 413, 61, 157, 253, 349, 445, 93, 189, 285, 381, 477, -2, 98, 194, 290, 386, 34, 130, 226, 322, 418, 66, 162, 258, 354, 450, -10, 106, 202, 298, 394, 42, 138, 234, 330, 426, 74, 170, 266, 362, 458, -18, 114, 210, 306, 402, 50, 146, 242, 338, 434, 82, 178, 274, 370, 466, -26, 122, 218, 314, 410, 58, 154, 250, 346, 442, 90, 186, 282, 378, 474, -6, 102, 198, 294, 390, 38, 134, 230, 326, 422, 70, 166, 262, 358, 454, -14, 110, 206, 302, 398, 46, 142, 238, 334, 430, 78, 174, 270, 366, 462, -22, 118, 214, 310, 406, 54, 150, 246, 342, 438, 86, 182, 278, 374, 470, -30, 126, 222, 318, 414, 62, 158, 254, 350, 446, 94, 190, 286, 382, 478, -3, 99, 195, 291, 387, 35, 131, 227, 323, 419, 67, 163, 259, 355, 451, -11, 107, 203, 299, 395, 43, 139, 235, 331, 427, 75, 171, 267, 363, 459, -19, 115, 211, 307, 403, 51, 147, 243, 339, 435, 83, 179, 275, 371, 467, -27, 123, 219, 315, 411, 59, 155, 251, 347, 443, 91, 187, 283, 379, 475, -7, 103, 199, 295, 391, 39, 135, 231, 327, 423, 71, 167, 263, 359, 455, -15, 111, 207, 303, 399, 47, 143, 239, 335, 431, 79, 175, 271, 367, 463, -23, 119, 215, 311, 407, 55, 151, 247, 343, 439, 87, 183, 279, 375, 471, -31, 127, 223, 319, 415, 63, 159, 255, 351, 447, 95, 191, 287, 383, 479, +# ifndef FFT_BITREV480 +# define FFT_BITREV480 +static const oac_int16 fft_bitrev480[480] = { + 0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, + 8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, + 16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, + 24, 120, 216, 312, 408, 56, 152, 248, 344, 440, 88, 184, 280, 376, 472, + 4, 100, 196, 292, 388, 36, 132, 228, 324, 420, 68, 164, 260, 356, 452, + 12, 108, 204, 300, 396, 44, 140, 236, 332, 428, 76, 172, 268, 364, 460, + 20, 116, 212, 308, 404, 52, 148, 244, 340, 436, 84, 180, 276, 372, 468, + 28, 124, 220, 316, 412, 60, 156, 252, 348, 444, 92, 188, 284, 380, 476, + 1, 97, 193, 289, 385, 33, 129, 225, 321, 417, 65, 161, 257, 353, 449, + 9, 105, 201, 297, 393, 41, 137, 233, 329, 425, 73, 169, 265, 361, 457, + 17, 113, 209, 305, 401, 49, 145, 241, 337, 433, 81, 177, 273, 369, 465, + 25, 121, 217, 313, 409, 57, 153, 249, 345, 441, 89, 185, 281, 377, 473, + 5, 101, 197, 293, 389, 37, 133, 229, 325, 421, 69, 165, 261, 357, 453, + 13, 109, 205, 301, 397, 45, 141, 237, 333, 429, 77, 173, 269, 365, 461, + 21, 117, 213, 309, 405, 53, 149, 245, 341, 437, 85, 181, 277, 373, 469, + 29, 125, 221, 317, 413, 61, 157, 253, 349, 445, 93, 189, 285, 381, 477, + 2, 98, 194, 290, 386, 34, 130, 226, 322, 418, 66, 162, 258, 354, 450, + 10, 106, 202, 298, 394, 42, 138, 234, 330, 426, 74, 170, 266, 362, 458, + 18, 114, 210, 306, 402, 50, 146, 242, 338, 434, 82, 178, 274, 370, 466, + 26, 122, 218, 314, 410, 58, 154, 250, 346, 442, 90, 186, 282, 378, 474, + 6, 102, 198, 294, 390, 38, 134, 230, 326, 422, 70, 166, 262, 358, 454, + 14, 110, 206, 302, 398, 46, 142, 238, 334, 430, 78, 174, 270, 366, 462, + 22, 118, 214, 310, 406, 54, 150, 246, 342, 438, 86, 182, 278, 374, 470, + 30, 126, 222, 318, 414, 62, 158, 254, 350, 446, 94, 190, 286, 382, 478, + 3, 99, 195, 291, 387, 35, 131, 227, 323, 419, 67, 163, 259, 355, 451, + 11, 107, 203, 299, 395, 43, 139, 235, 331, 427, 75, 171, 267, 363, 459, + 19, 115, 211, 307, 403, 51, 147, 243, 339, 435, 83, 179, 275, 371, 467, + 27, 123, 219, 315, 411, 59, 155, 251, 347, 443, 91, 187, 283, 379, 475, + 7, 103, 199, 295, 391, 39, 135, 231, 327, 423, 71, 167, 263, 359, 455, + 15, 111, 207, 303, 399, 47, 143, 239, 335, 431, 79, 175, 271, 367, 463, + 23, 119, 215, 311, 407, 55, 151, 247, 343, 439, 87, 183, 279, 375, 471, + 31, 127, 223, 319, 415, 63, 159, 255, 351, 447, 95, 191, 287, 383, 479, }; -#endif +# endif -#ifndef FFT_BITREV240 -#define FFT_BITREV240 -static const opus_int16 fft_bitrev240[240] = { -0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, -4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, -8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, -12, 60, 108, 156, 204, 28, 76, 124, 172, 220, 44, 92, 140, 188, 236, -1, 49, 97, 145, 193, 17, 65, 113, 161, 209, 33, 81, 129, 177, 225, -5, 53, 101, 149, 197, 21, 69, 117, 165, 213, 37, 85, 133, 181, 229, -9, 57, 105, 153, 201, 25, 73, 121, 169, 217, 41, 89, 137, 185, 233, -13, 61, 109, 157, 205, 29, 77, 125, 173, 221, 45, 93, 141, 189, 237, -2, 50, 98, 146, 194, 18, 66, 114, 162, 210, 34, 82, 130, 178, 226, -6, 54, 102, 150, 198, 22, 70, 118, 166, 214, 38, 86, 134, 182, 230, -10, 58, 106, 154, 202, 26, 74, 122, 170, 218, 42, 90, 138, 186, 234, -14, 62, 110, 158, 206, 30, 78, 126, 174, 222, 46, 94, 142, 190, 238, -3, 51, 99, 147, 195, 19, 67, 115, 163, 211, 35, 83, 131, 179, 227, -7, 55, 103, 151, 199, 23, 71, 119, 167, 215, 39, 87, 135, 183, 231, -11, 59, 107, 155, 203, 27, 75, 123, 171, 219, 43, 91, 139, 187, 235, -15, 63, 111, 159, 207, 31, 79, 127, 175, 223, 47, 95, 143, 191, 239, +# ifndef FFT_BITREV240 +# define FFT_BITREV240 +static const oac_int16 fft_bitrev240[240] = { + 0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, + 4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, + 8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, + 12, 60, 108, 156, 204, 28, 76, 124, 172, 220, 44, 92, 140, 188, 236, + 1, 49, 97, 145, 193, 17, 65, 113, 161, 209, 33, 81, 129, 177, 225, + 5, 53, 101, 149, 197, 21, 69, 117, 165, 213, 37, 85, 133, 181, 229, + 9, 57, 105, 153, 201, 25, 73, 121, 169, 217, 41, 89, 137, 185, 233, + 13, 61, 109, 157, 205, 29, 77, 125, 173, 221, 45, 93, 141, 189, 237, + 2, 50, 98, 146, 194, 18, 66, 114, 162, 210, 34, 82, 130, 178, 226, + 6, 54, 102, 150, 198, 22, 70, 118, 166, 214, 38, 86, 134, 182, 230, + 10, 58, 106, 154, 202, 26, 74, 122, 170, 218, 42, 90, 138, 186, 234, + 14, 62, 110, 158, 206, 30, 78, 126, 174, 222, 46, 94, 142, 190, 238, + 3, 51, 99, 147, 195, 19, 67, 115, 163, 211, 35, 83, 131, 179, 227, + 7, 55, 103, 151, 199, 23, 71, 119, 167, 215, 39, 87, 135, 183, 231, + 11, 59, 107, 155, 203, 27, 75, 123, 171, 219, 43, 91, 139, 187, 235, + 15, 63, 111, 159, 207, 31, 79, 127, 175, 223, 47, 95, 143, 191, 239, }; -#endif +# endif -#ifndef FFT_BITREV120 -#define FFT_BITREV120 -static const opus_int16 fft_bitrev120[120] = { -0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, -4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, -1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, -5, 29, 53, 77, 101, 13, 37, 61, 85, 109, 21, 45, 69, 93, 117, -2, 26, 50, 74, 98, 10, 34, 58, 82, 106, 18, 42, 66, 90, 114, -6, 30, 54, 78, 102, 14, 38, 62, 86, 110, 22, 46, 70, 94, 118, -3, 27, 51, 75, 99, 11, 35, 59, 83, 107, 19, 43, 67, 91, 115, -7, 31, 55, 79, 103, 15, 39, 63, 87, 111, 23, 47, 71, 95, 119, +# ifndef FFT_BITREV120 +# define FFT_BITREV120 +static const oac_int16 fft_bitrev120[120] = { + 0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, + 4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, + 1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, + 5, 29, 53, 77, 101, 13, 37, 61, 85, 109, 21, 45, 69, 93, 117, + 2, 26, 50, 74, 98, 10, 34, 58, 82, 106, 18, 42, 66, 90, 114, + 6, 30, 54, 78, 102, 14, 38, 62, 86, 110, 22, 46, 70, 94, 118, + 3, 27, 51, 75, 99, 11, 35, 59, 83, 107, 19, 43, 67, 91, 115, + 7, 31, 55, 79, 103, 15, 39, 63, 87, 111, 23, 47, 71, 95, 119, }; -#endif +# endif -#ifndef FFT_BITREV60 -#define FFT_BITREV60 -static const opus_int16 fft_bitrev60[60] = { -0, 12, 24, 36, 48, 4, 16, 28, 40, 52, 8, 20, 32, 44, 56, -1, 13, 25, 37, 49, 5, 17, 29, 41, 53, 9, 21, 33, 45, 57, -2, 14, 26, 38, 50, 6, 18, 30, 42, 54, 10, 22, 34, 46, 58, -3, 15, 27, 39, 51, 7, 19, 31, 43, 55, 11, 23, 35, 47, 59, +# ifndef FFT_BITREV60 +# define FFT_BITREV60 +static const oac_int16 fft_bitrev60[60] = { + 0, 12, 24, 36, 48, 4, 16, 28, 40, 52, 8, 20, 32, 44, 56, + 1, 13, 25, 37, 49, 5, 17, 29, 41, 53, 9, 21, 33, 45, 57, + 2, 14, 26, 38, 50, 6, 18, 30, 42, 54, 10, 22, 34, 46, 58, + 3, 15, 27, 39, 51, 7, 19, 31, 43, 55, 11, 23, 35, 47, 59, }; -#endif +# endif -#ifndef FFT_STATE48000_960_0 -#define FFT_STATE48000_960_0 +# ifndef FFT_STATE48000_960_0 +# define FFT_STATE48000_960_0 static const kiss_fft_state fft_state48000_960_0 = { -480, /* nfft */ -#ifdef ENABLE_QEXT -572662306, /* scale */ -#else -17476, /* scale */ -#endif -8, /* scale_shift */ --1, /* shift */ -{5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev480, /* bitrev */ -fft_twiddles48000_960, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_480, -#else -NULL, -#endif + 480, /* nfft */ + 572662306, /* scale */ + 8, /* scale_shift */ + -1, /* shift */ + {5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev480, /* bitrev */ + fft_twiddles48000_960, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_480, +# else + NULL, +# endif }; -#endif +# endif -#ifndef FFT_STATE48000_960_1 -#define FFT_STATE48000_960_1 +# ifndef FFT_STATE48000_960_1 +# define FFT_STATE48000_960_1 static const kiss_fft_state fft_state48000_960_1 = { -240, /* nfft */ -#ifdef ENABLE_QEXT -572662306, /* scale */ -#else -17476, /* scale */ -#endif -7, /* scale_shift */ -1, /* shift */ -{5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev240, /* bitrev */ -fft_twiddles48000_960, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_240, -#else -NULL, -#endif + 240, /* nfft */ + 572662306, /* scale */ + 7, /* scale_shift */ + 1, /* shift */ + {5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev240, /* bitrev */ + fft_twiddles48000_960, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_240, +# else + NULL, +# endif }; -#endif +# endif -#ifndef FFT_STATE48000_960_2 -#define FFT_STATE48000_960_2 +# ifndef FFT_STATE48000_960_2 +# define FFT_STATE48000_960_2 static const kiss_fft_state fft_state48000_960_2 = { -120, /* nfft */ -#ifdef ENABLE_QEXT -572662306, /* scale */ -#else -17476, /* scale */ -#endif -6, /* scale_shift */ -2, /* shift */ -{5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev120, /* bitrev */ -fft_twiddles48000_960, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_120, -#else -NULL, -#endif + 120, /* nfft */ + 572662306, /* scale */ + 6, /* scale_shift */ + 2, /* shift */ + {5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev120, /* bitrev */ + fft_twiddles48000_960, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_120, +# else + NULL, +# endif }; -#endif +# endif -#ifndef FFT_STATE48000_960_3 -#define FFT_STATE48000_960_3 +# ifndef FFT_STATE48000_960_3 +# define FFT_STATE48000_960_3 static const kiss_fft_state fft_state48000_960_3 = { -60, /* nfft */ -#ifdef ENABLE_QEXT -572662306, /* scale */ -#else -17476, /* scale */ -#endif -5, /* scale_shift */ -3, /* shift */ -{5, 12, 3, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev60, /* bitrev */ -fft_twiddles48000_960, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_60, -#else -NULL, -#endif + 60, /* nfft */ + 572662306, /* scale */ + 5, /* scale_shift */ + 3, /* shift */ + {5, 12, 3, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev60, /* bitrev */ + fft_twiddles48000_960, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_60, +# else + NULL, +# endif }; -#endif +# endif #endif #ifndef MDCT_TWIDDLES960 -#define MDCT_TWIDDLES960 +# define MDCT_TWIDDLES960 static const celt_coef mdct_twiddles960[1800] = { -#ifdef ENABLE_QEXT -2147483468, 2147469095, 2147431723, 2147371355, 2147287990, -2147181629, 2147052273, 2146899924, 2146724584, 2146526254, -2146304937, 2146060634, 2145793349, 2145503083, 2145189842, -2144853627, 2144494442, 2144112292, 2143707180, 2143279110, -2142828088, 2142354118, 2141857204, 2141337354, 2140794571, -2140228862, 2139640233, 2139028690, 2138394240, 2137736889, -2137056645, 2136353515, 2135627506, 2134878626, 2134106884, -2133312286, 2132494843, 2131654563, 2130791454, 2129905526, -2128996788, 2128065251, 2127110924, 2126133817, 2125133941, -2124111307, 2123065925, 2121997806, 2120906963, 2119793407, -2118657149, 2117498202, 2116316578, 2115112291, 2113885352, -2112635775, 2111363574, 2110068761, 2108751352, 2107411359, -2106048798, 2104663683, 2103256028, 2101825849, 2100373162, -2098897981, 2097400322, 2095880202, 2094337637, 2092772643, -2091185237, 2089575437, 2087943258, 2086288720, 2084611839, -2082912633, 2081191122, 2079447322, 2077681253, 2075892934, -2074082383, 2072249621, 2070394667, 2068517540, 2066618262, -2064696851, 2062753329, 2060787717, 2058800036, 2056790306, -2054758550, 2052704789, 2050629045, 2048531340, 2046411698, -2044270140, 2042106689, 2039921369, 2037714204, 2035485216, -2033234429, 2030961869, 2028667558, 2026351522, 2024013785, -2021654373, 2019273310, 2016870623, 2014446336, 2012000477, -2009533071, 2007044144, 2004533723, 2002001835, 1999448508, -1996873768, 1994277643, 1991660161, 1989021350, 1986361238, -1983679853, 1980977226, 1978253383, 1975508355, 1972742171, -1969954860, 1967146453, 1964316979, 1961466469, 1958594953, -1955702462, 1952789027, 1949854680, 1946899451, 1943923372, -1940926475, 1937908793, 1934870357, 1931811201, 1928731356, -1925630856, 1922509734, 1919368023, 1916205758, 1913022972, -1909819698, 1906595972, 1903351828, 1900087301, 1896802425, -1893497236, 1890171769, 1886826060, 1883460144, 1880074058, -1876667838, 1873241521, 1869795142, 1866328740, 1862842350, -1859336011, 1855809760, 1852263635, 1848697674, 1845111914, -1841506395, 1837881155, 1834236233, 1830571667, 1826887497, -1823183763, 1819460504, 1815717761, 1811955572, 1808173978, -1804373021, 1800552740, 1796713177, 1792854372, 1788976368, -1785079205, 1781162925, 1777227570, 1773273182, 1769299805, -1765307479, 1761296249, 1757266156, 1753217244, 1749149557, -1745063138, 1740958031, 1736834279, 1732691928, 1728531020, -1724351602, 1720153717, 1715937410, 1711702727, 1707449714, -1703178415, 1698888876, 1694581143, 1690255263, 1685911282, -1681549245, 1677169201, 1672771196, 1668355276, 1663921490, -1659469885, 1655000508, 1650513407, 1646008631, 1641486227, -1636946244, 1632388731, 1627813736, 1623221309, 1618611498, -1613984353, 1609339924, 1604678260, 1599999411, 1595303428, -1590590360, 1585860258, 1581113173, 1576349155, 1571568256, -1566770527, 1561956018, 1557124783, 1552276872, 1547412337, -1542531231, 1537633606, 1532719513, 1527789007, 1522842139, -1517878963, 1512899531, 1507903898, 1502892116, 1497864239, -1492820322, 1487760417, 1482684580, 1477592864, 1472485325, -1467362016, 1462222994, 1457068312, 1451898025, 1446712191, -1441510863, 1436294098, 1431061951, 1425814478, 1420551737, -1415273782, 1409980671, 1404672460, 1399349206, 1394010966, -1388657798, 1383289758, 1377906904, 1372509294, 1367096986, -1361670037, 1356228505, 1350772450, 1345301929, 1339817000, -1334317724, 1328804158, 1323276361, 1317734393, 1312178313, -1306608181, 1301024057, 1295425999, 1289814068, 1284188325, -1278548828, 1272895640, 1267228820, 1261548429, 1255854528, -1250147177, 1244426439, 1238692373, 1232945043, 1227184508, -1221410831, 1215624074, 1209824299, 1204011567, 1198185941, -1192347484, 1186496258, 1180632325, 1174755748, 1168866591, -1162964917, 1157050787, 1151124267, 1145185419, 1139234307, -1133270995, 1127295547, 1121308026, 1115308496, 1109297023, -1103273670, 1097238502, 1091191583, 1085132978, 1079062753, -1072980972, 1066887699, 1060783002, 1054666944, 1048539592, -1042401010, 1036251266, 1030090423, 1023918550, 1017735711, -1011541973, 1005337402, 999122065, 992896028, 986659358, -980412122, 974154386, 967886217, 961607684, 955318852, -949019790, 942710564, 936391243, 930061894, 923722585, -917373383, 911014357, 904645574, 898267104, 891879014, -885481373, 879074249, 872657710, 866231826, 859796666, -853352298, 846898791, 840436214, 833964638, 827484130, -820994760, 814496598, 807989714, 801474176, 794950056, -788417422, 781876345, 775326894, 768769141, 762203154, -755629005, 749046764, 742456501, 735858287, 729252193, -722638289, 716016646, 709387335, 702750427, 696105993, -689454104, 682794832, 676128248, 669454423, 662773428, -656085336, 649390218, 642688145, 635979190, 629263424, -622540918, 615811746, 609075979, 602333690, 595584950, -588829831, 582068407, 575300749, 568526931, 561747023, -554961100, 548169234, 541371497, 534567963, 527758704, -520943793, 514123303, 507297307, 500465878, 493629090, -486787016, 479939728, 473087301, 466229807, 459367320, -452499914, 445627662, 438750638, 431868915, 424982567, -418091668, 411196291, 404296511, 397392401, 390484035, -383571488, 376654833, 369734144, 362809495, 355880961, -348948616, 342012534, 335072790, 328129457, 321182610, -314232323, 307278671, 300321729, 293361570, 286398270, -279431902, 272462542, 265490265, 258515144, 251537254, -244556671, 237573469, 230587722, 223599506, 216608896, -209615966, 202620791, 195623446, 188624006, 181622546, -174619141, 167613866, 160606796, 153598006, 146587571, -139575567, 132562067, 125547148, 118530885, 111513352, -104494625, 97474778, 90453888, 83432030, 76409277, -69385707, 62361393, 55336412, 48310838, 41284746, -34258213, 27231312, 20204120, 13176712, 6149162, --878453, -7906059, -14933580, -21960942, -28988068, --36014884, -43041314, -50067283, -57092716, -64117537, --71141672, -78165045, -85187581, -92209205, -99229841, --106249414, -113267850, -120285073, -127301007, -134315578, --141328711, -148340330, -155350361, -162358728, -169365356, --176370170, -183373096, -190374058, -197372981, -204369791, --211364411, -218356769, -225346788, -232334393, -239319511, --246302065, -253281982, -260259186, -267233603, -274205159, --281173778, -288139385, -295101907, -302061269, -309017396, --315970213, -322919647, -329865622, -336808065, -343746901, --350682056, -357613455, -364541025, -371464690, -378384377, --385300013, -392211522, -399118830, -406021865, -412920551, --419814815, -426704583, -433589782, -440470337, -447346176, --454217223, -461083406, -467944652, -474800886, -481652035, --488498026, -495338786, -502174241, -509004318, -515828944, --522648046, -529461551, -536269386, -543071478, -549867754, --556658141, -563442567, -570220959, -576993244, -583759350, --590519205, -597272736, -604019870, -610760536, -617494660, --624222173, -630943000, -637657070, -644364312, -651064652, --657758021, -664444345, -671123554, -677795576, -684460338, --691117771, -697767803, -704410362, -711045377, -717672778, --724292493, -730904451, -737508582, -744104815, -750693079, --757273304, -763845419, -770409354, -776965038, -783512402, --790051375, -796581887, -803103868, -809617249, -816121959, --822617929, -829105090, -835583372, -842052705, -848513021, --854964249, -861406322, -867839170, -874262724, -880676915, --887081675, -893476935, -899862626, -906238681, -912605031, --918961607, -925308342, -931645168, -937972016, -944288820, --950595511, -956892022, -963178285, -969454234, -975719800, --981974918, -988219519, -994453537, -1000676905, -1006889557, --1013091426, -1019282445, -1025462549, -1031631671, -1037789745, --1043936705, -1050072485, -1056197020, -1062310244, -1068412091, --1074502497, -1080581395, -1086648722, -1092704411, -1098748398, --1104780618, -1110801008, -1116809501, -1122806034, -1128790543, --1134762964, -1140723232, -1146671283, -1152607055, -1158530484, --1164441505, -1170340057, -1176226074, -1182099496, -1187960258, --1193808298, -1199643553, -1205465961, -1211275460, -1217071986, --1222855479, -1228625876, -1234383115, -1240127136, -1245857875, --1251575272, -1257279266, -1262969796, -1268646800, -1274310217, --1279959989, -1285596052, -1291218348, -1296826816, -1302421396, --1308002029, -1313568653, -1319121210, -1324659641, -1330183885, --1335693885, -1341189580, -1346670912, -1352137822, -1357590252, --1363028143, -1368451438, -1373860077, -1379254004, -1384633159, --1389997487, -1395346928, -1400681427, -1406000925, -1411305366, --1416594694, -1421868850, -1427127780, -1432371426, -1437599733, --1442812644, -1448010104, -1453192057, -1458358447, -1463509220, --1468644319, -1473763690, -1478867279, -1483955030, -1489026889, --1494082802, -1499122714, -1504146572, -1509154322, -1514145910, --1519121283, -1524080387, -1529023170, -1533949577, -1538859558, --1543753058, -1548630027, -1553490410, -1558334157, -1563161216, --1567971534, -1572765060, -1577541744, -1582301533, -1587044377, --1591770225, -1596479027, -1601170732, -1605845289, -1610502649, --1615142762, -1619765578, -1624371047, -1628959121, -1633529750, --1638082885, -1642618478, -1647136479, -1651636841, -1656119516, --1660584454, -1665031609, -1669460933, -1673872378, -1678265898, --1682641444, -1686998971, -1691338432, -1695659779, -1699962968, --1704247951, -1708514683, -1712763118, -1716993211, -1721204917, --1725398189, -1729572984, -1733729257, -1737866963, -1741986057, --1746086497, -1750168237, -1754231234, -1758275445, -1762300826, --1766307335, -1770294927, -1774263561, -1778213194, -1782143784, --1786055289, -1789947667, -1793820875, -1797674873, -1801509620, --1805325074, -1809121194, -1812897940, -1816655271, -1820393147, --1824111529, -1827810376, -1831489648, -1835149306, -1838789312, --1842409625, -1846010208, -1849591022, -1853152028, -1856693188, --1860214464, -1863715819, -1867197215, -1870658615, -1874099982, --1877521279, -1880922469, -1884303515, -1887664383, -1891005035, --1894325435, -1897625550, -1900905342, -1904164776, -1907403819, --1910622435, -1913820590, -1916998250, -1920155379, -1923291946, --1926407915, -1929503255, -1932577931, -1935631910, -1938665161, --1941677650, -1944669345, -1947640214, -1950590226, -1953519348, --1956427550, -1959314800, -1962181067, -1965026321, -1967850531, --1970653667, -1973435699, -1976196596, -1978936331, -1981654873, --1984352192, -1987028261, -1989683050, -1992316532, -1994928677, --1997519459, -2000088848, -2002636818, -2005163342, -2007668391, --2010151941, -2012613963, -2015054432, -2017473321, -2019870604, --2022246257, -2024600252, -2026932566, -2029243173, -2031532049, --2033799168, -2036044507, -2038268042, -2040469748, -2042649603, --2044807583, -2046943664, -2049057824, -2051150040, -2053220291, --2055268553, -2057294804, -2059299024, -2061281190, -2063241282, --2065179277, -2067095157, -2068988899, -2070860485, -2072709893, --2074537104, -2076342098, -2078124857, -2079885360, -2081623590, --2083339527, -2085033153, -2086704450, -2088353400, -2089979985, --2091584189, -2093165993, -2094725382, -2096262337, -2097776843, --2099268884, -2100738443, -2102185505, -2103610054, -2105012075, --2106391553, -2107748474, -2109082822, -2110394584, -2111683744, --2112950291, -2114194210, -2115415487, -2116614110, -2117790065, --2118943341, -2120073924, -2121181804, -2122266967, -2123329402, --2124369098, -2125386044, -2126380229, -2127351642, -2128300272, --2129226111, -2130129147, -2131009371, -2131866773, -2132701345, --2133513078, -2134301962, -2135067990, -2135811153, -2136531442, --2137228852, -2137903373, -2138555000, -2139183723, -2139789539, --2140372438, -2140932416, -2141469466, -2141983583, -2142474761, --2142942995, -2143388280, -2143810610, -2144209982, -2144586392, --2144939834, -2145270306, -2145577804, -2145862324, -2146123864, --2146362421, -2146577992, -2146770575, -2146940167, -2147086768, --2147210375, -2147310987, -2147388603, -2147443222, -2147474844, -2147482929, 2147425435, 2147275952, 2147034487, 2146701050, -2146275656, 2145758322, 2145149071, 2144447929, 2143654926, -2142770096, 2141793477, 2140725111, 2139565043, 2138313323, -2136970005, 2135535146, 2134008809, 2132391057, 2130681961, -2128881593, 2126990031, 2125007356, 2122933653, 2120769010, -2118513521, 2116167282, 2113730393, 2111202959, 2108585087, -2105876892, 2103078487, 2100189994, 2097211535, 2094143239, -2090985237, 2087737664, 2084400659, 2080974365, 2077458929, -2073854502, 2070161238, 2066379295, 2062508835, 2058550025, -2054503033, 2050368032, 2046145201, 2041834720, 2037436773, -2032951550, 2028379241, 2023720043, 2018974156, 2014141783, -2009223131, 2004218410, 1999127836, 1993951625, 1988690000, -1983343186, 1977911412, 1972394912, 1966793920, 1961108677, -1955339428, 1949486417, 1943549898, 1937530123, 1931427351, -1925241843, 1918973864, 1912623682, 1906191570, 1899677803, -1893082661, 1886406424, 1879649381, 1872811820, 1865894033, -1858896318, 1851818974, 1844662304, 1837426615, 1830112217, -1822719423, 1815248550, 1807699917, 1800073849, 1792370671, -1784590714, 1776734311, 1768801799, 1760793518, 1752709809, -1744551021, 1736317502, 1728009604, 1719627685, 1711172102, -1702643219, 1694041400, 1685367013, 1676620432, 1667802029, -1658912184, 1649951276, 1640919689, 1631817811, 1622646032, -1613404744, 1604094343, 1594715227, 1585267800, 1575752465, -1566169630, 1556519705, 1546803104, 1537020244, 1527171542, -1517257422, 1507278307, 1497234626, 1487126808, 1476955286, -1466720497, 1456422878, 1446062871, 1435640919, 1425157469, -1414612971, 1404007875, 1393342636, 1382617710, 1371833558, -1360990642, 1350089425, 1339130374, 1328113960, 1317040654, -1305910930, 1294725265, 1283484138, 1272188032, 1260837429, -1249432816, 1237974681, 1226463516, 1214899813, 1203284068, -1191616778, 1179898443, 1168129565, 1156310649, 1144442200, -1132524727, 1120558740, 1108544752, 1096483278, 1084374834, -1072219940, 1060019115, 1047772882, 1035481766, 1023146293, -1010766993, 998344394, 985879030, 973371434, 960822142, -948231691, 935600622, 922929474, 910218791, 897469118, -884680999, 871854984, 858991622, 846091463, 833155061, -820182969, 807175743, 794133941, 781058120, 767948841, -754806666, 741632158, 728425880, 715188400, 701920283, -688622098, 675294414, 661937804, 648552838, 635140090, -621700135, 608233549, 594740907, 581222789, 567679774, -554112440, 540521371, 526907147, 513270353, 499611571, -485931388, 472230390, 458509162, 444768294, 431008373, -417229989, 403433732, 389620194, 375789965, 361943639, -348081809, 334205068, 320314011, 306409232, 292491328, -278560894, 264618528, 250664827, 236700388, 222725809, -208741690, 194748629, 180747225, 166738079, 152721790, -138698959, 124670187, 110636075, 96597223, 82554233, -68507707, 54458246, 40406452, 26352928, 12298274, --1756906, -15812011, -29866438, -43919586, -57970853, --72019637, -86065335, -100107347, -114145071, -128177904, --142205248, -156226499, -170241059, -184248325, -198247699, --212238581, -226220372, -240192472, -254154282, -268105206, --282044645, -295972002, -309886680, -323788084, -337675619, --351548688, -365406698, -379249055, -393075166, -406884440, --420676284, -434450107, -448205320, -461941333, -475657559, --489353409, -503028296, -516681636, -530312842, -543921332, --557506522, -571067830, -584604676, -598116479, -611602660, --625062643, -638495850, -651901706, -665279637, -678629069, --691949432, -705240153, -718500664, -731730397, -744928785, --758095263, -771229267, -784330234, -797397602, -810430813, --823429308, -836392529, -849319923, -862210934, -875065011, --887881603, -900660162, -913400139, -926100989, -938762167, --951383133, -963963344, -976502263, -988999351, -1001454074, --1013865898, -1026234291, -1038558724, -1050838668, -1063073598, --1075262990, -1087406320, -1099503070, -1111552721, -1123554757, --1135508663, -1147413928, -1159270041, -1171076495, -1182832785, --1194538405, -1206192856, -1217795637, -1229346252, -1240844206, --1252289006, -1263680162, -1275017186, -1286299593, -1297526899, --1308698624, -1319814288, -1330873416, -1341875533, -1352820169, --1363706855, -1374535124, -1385304512, -1396014559, -1406664805, --1417254794, -1427784073, -1438252190, -1448658697, -1459003149, --1469285102, -1479504115, -1489659751, -1499751576, -1509779156, --1519742062, -1529639867, -1539472148, -1549238483, -1558938453, --1568571644, -1578137643, -1587636039, -1597066426, -1606428400, --1615721561, -1624945509, -1634099849, -1643184191, -1652198144, --1661141322, -1670013342, -1678813825, -1687542393, -1696198672, --1704782292, -1713292884, -1721730085, -1730093532, -1738382868, --1746597738, -1754737789, -1762802673, -1770792044, -1778705561, --1786542883, -1794303676, -1801987607, -1809594347, -1817123570, --1824574954, -1831948179, -1839242929, -1846458892, -1853595759, --1860653224, -1867630985, -1874528743, -1881346202, -1888083070, --1894739060, -1901313885, -1907807264, -1914218919, -1920548575, --1926795962, -1932960811, -1939042858, -1945041843, -1950957509, --1956789602, -1962537873, -1968202076, -1973781967, -1979277308, --1984687864, -1990013401, -1995253694, -2000408516, -2005477648, --2010460871, -2015357973, -2020168744, -2024892978, -2029530472, --2034081027, -2038544449, -2042920547, -2047209133, -2051410023, --2055523038, -2059548001, -2063484740, -2067333086, -2071092874, --2074763944, -2078346137, -2081839301, -2085243286, -2088557947, --2091783140, -2094918728, -2097964577, -2100920556, -2103786539, --2106562402, -2109248028, -2111843300, -2114348108, -2116762344, --2119085905, -2121318692, -2123460608, -2125511562, -2127471467, --2129340237, -2131117794, -2132804061, -2134398966, -2135902440, --2137314419, -2138634843, -2139863654, -2141000801, -2142046235, --2142999911, -2143861787, -2144631828, -2145310000, -2145896274, --2146390624, -2146793031, -2147103476, -2147321946, -2147448433, -2147480773, 2147250799, 2146652904, 2145687192, 2144353827, -2142653038, 2140585116, 2138150417, 2135349356, 2132182414, -2128650133, 2124753120, 2120492040, 2115867626, 2110880668, -2105532022, 2099822604, 2093753392, 2087325426, 2080539807, -2073397699, 2065900325, 2058048970, 2049844978, 2041289756, -2032384769, 2023131544, 2013531666, 2003586779, 1993298588, -1982668856, 1971699403, 1960392110, 1948748914, 1936771810, -1924462850, 1911824143, 1898857855, 1885566207, 1871951478, -1858015999, 1843762158, 1829192399, 1814309216, 1799115162, -1783612838, 1767804901, 1751694060, 1735283075, 1718574758, -1701571972, 1684277631, 1666694698, 1648826185, 1630675154, -1612244715, 1593538026, 1574558293, 1555308768, 1535792748, -1516013578, 1495974647, 1475679389, 1455131280, 1434333842, -1413290638, 1392005275, 1370481398, 1348722696, 1326732898, -1304515771, 1282075122, 1259414796, 1236538675, 1213450681, -1190154767, 1166654927, 1142955186, 1119059606, 1094972281, -1070697338, 1046238936, 1021601267, 996788551, 971805042, -946655018, 921342790, 895872694, 870249095, 844476384, -818558976, 792501312, 766307857, 739983099, 713531549, -686957739, 660266222, 633461572, 606548381, 579531262, -552414843, 525203770, 497902707, 470516330, 443049333, -415506422, 387892316, 360211746, 332469456, 304670200, -276818739, 248919847, 220978304, 192998897, 164986421, -136945676, 108881465, 80798598, 52701887, 24596146, --3513810, -31623164, -59727099, -87820801, -115899455, --143958250, -171992378, -199997036, -227967426, -255898755, --283786237, -311625094, -339410555, -367137861, -394802258, --422399009, -449923384, -477370666, -504736154, -532015158, --559203003, -586295032, -613286603, -640173090, -666949886, --693612404, -720156076, -746576352, -772868706, -799028633, --825051651, -850933300, -876669146, -902254780, -927685817, --952957899, -978066697, -1003007909, -1027777260, -1052370507, --1076783436, -1101011863, -1125051638, -1148898640, -1172548785, --1195998020, -1219242327, -1242277723, -1265100260, -1287706030, --1310091157, -1332251808, -1354184184, -1375884527, -1397349119, --1418574283, -1439556382, -1460291820, -1480777044, -1501008545, --1520982856, -1540696555, -1560146263, -1579328647, -1598240423, --1616878347, -1635239228, -1653319919, -1671117323, -1688628389, --1705850117, -1722779556, -1739413807, -1755750017, -1771785389, --1787517174, -1802942678, -1818059257, -1832864320, -1847355332, --1861529809, -1875385322, -1888919498, -1902130017, -1915014616, --1927571087, -1939797279, -1951691096, -1963250501, -1974473513, --1985358210, -1995902725, -2006105253, -2015964045, -2025477412, --2034643724, -2043461410, -2051928960, -2060044922, -2067807906, --2075216581, -2082269679, -2088965991, -2095304370, -2101283728, --2106903043, -2112161350, -2117057750, -2121591402, -2125761531, --2129567422, -2133008422, -2136083942, -2138793455, -2141136497, --2143112666, -2144721624, -2145963095, -2146836866, -2147342788, -2147472149, 2146552303, 2144161316, 2140300829, 2134973487, -2128182940, 2119933843, 2110231849, 2099083608, 2086496759, -2072479930, 2057042727, 2040195730, 2021950484, 2002319494, -1981316215, 1958955040, 1935251296, 1910221227, 1883881987, -1856251629, 1827349089, 1797194176, 1765807555, 1733210737, -1699426064, 1664476689, 1628386565, 1591180426, 1552883771, -1513522847, 1473124631, 1431716808, 1389327759, 1345986533, -1301722835, 1256567002, 1210549980, 1163703308, 1116059092, -1067649985, 1018509163, 968670307, 918167572, 867035571, -815309347, 763024350, 710216415, 656921734, 603176830, -549018540, 494483979, 439610524, 384435782, 328997567, -273333873, 217482850, 161482775, 105372028, 49189064, --7027611, -63239471, -119407989, -175494670, -231461077, --287268852, -342879747, -398255649, -453358607, -508150855, --562594842, -616653255, -670289044, -723465451, -776146031, --828294679, -879875655, -930853609, -981193602, -1030861133, --1079822164, -1128043139, -1175491010, -1222133257, -1267937916, --1312873593, -1356909492, -1400015434, -1442161874, -1483319929, --1523461391, -1562558748, -1600585205, -1637514702, -1673321927, --1707982341, -1741472190, -1773768520, -1804849198, -1834692923, --1863279241, -1890588560, -1916602164, -1941302225, -1964671814, --1986694916, -2007356435, -2026642214, -2044539032, -2061034626, --2076117690, -2089777886, -2102005853, -2112793210, -2122132564, --2130017514, -2136442657, -2141403589, -2144896910, -2146920225, -#else -32767, 32767, 32767, 32766, 32765, -32763, 32761, 32759, 32756, 32753, -32750, 32746, 32742, 32738, 32733, -32728, 32722, 32717, 32710, 32704, -32697, 32690, 32682, 32674, 32666, -32657, 32648, 32639, 32629, 32619, -32609, 32598, 32587, 32576, 32564, -32552, 32539, 32526, 32513, 32500, -32486, 32472, 32457, 32442, 32427, -32411, 32395, 32379, 32362, 32345, -32328, 32310, 32292, 32274, 32255, -32236, 32217, 32197, 32177, 32157, -32136, 32115, 32093, 32071, 32049, -32027, 32004, 31981, 31957, 31933, -31909, 31884, 31859, 31834, 31809, -31783, 31756, 31730, 31703, 31676, -31648, 31620, 31592, 31563, 31534, -31505, 31475, 31445, 31415, 31384, -31353, 31322, 31290, 31258, 31226, -31193, 31160, 31127, 31093, 31059, -31025, 30990, 30955, 30920, 30884, -30848, 30812, 30775, 30738, 30701, -30663, 30625, 30587, 30548, 30509, -30470, 30430, 30390, 30350, 30309, -30269, 30227, 30186, 30144, 30102, -30059, 30016, 29973, 29930, 29886, -29842, 29797, 29752, 29707, 29662, -29616, 29570, 29524, 29477, 29430, -29383, 29335, 29287, 29239, 29190, -29142, 29092, 29043, 28993, 28943, -28892, 28842, 28791, 28739, 28688, -28636, 28583, 28531, 28478, 28425, -28371, 28317, 28263, 28209, 28154, -28099, 28044, 27988, 27932, 27876, -27820, 27763, 27706, 27648, 27591, -27533, 27474, 27416, 27357, 27298, -27238, 27178, 27118, 27058, 26997, -26936, 26875, 26814, 26752, 26690, -26628, 26565, 26502, 26439, 26375, -26312, 26247, 26183, 26119, 26054, -25988, 25923, 25857, 25791, 25725, -25658, 25592, 25524, 25457, 25389, -25322, 25253, 25185, 25116, 25047, -24978, 24908, 24838, 24768, 24698, -24627, 24557, 24485, 24414, 24342, -24270, 24198, 24126, 24053, 23980, -23907, 23834, 23760, 23686, 23612, -23537, 23462, 23387, 23312, 23237, -23161, 23085, 23009, 22932, 22856, -22779, 22701, 22624, 22546, 22468, -22390, 22312, 22233, 22154, 22075, -21996, 21916, 21836, 21756, 21676, -21595, 21515, 21434, 21352, 21271, -21189, 21107, 21025, 20943, 20860, -20777, 20694, 20611, 20528, 20444, -20360, 20276, 20192, 20107, 20022, -19937, 19852, 19767, 19681, 19595, -19509, 19423, 19336, 19250, 19163, -19076, 18988, 18901, 18813, 18725, -18637, 18549, 18460, 18372, 18283, -18194, 18104, 18015, 17925, 17835, -17745, 17655, 17565, 17474, 17383, -17292, 17201, 17110, 17018, 16927, -16835, 16743, 16650, 16558, 16465, -16372, 16279, 16186, 16093, 15999, -15906, 15812, 15718, 15624, 15529, -15435, 15340, 15245, 15150, 15055, -14960, 14864, 14769, 14673, 14577, -14481, 14385, 14288, 14192, 14095, -13998, 13901, 13804, 13706, 13609, -13511, 13414, 13316, 13218, 13119, -13021, 12923, 12824, 12725, 12626, -12527, 12428, 12329, 12230, 12130, -12030, 11930, 11831, 11730, 11630, -11530, 11430, 11329, 11228, 11128, -11027, 10926, 10824, 10723, 10622, -10520, 10419, 10317, 10215, 10113, -10011, 9909, 9807, 9704, 9602, -9499, 9397, 9294, 9191, 9088, -8985, 8882, 8778, 8675, 8572, -8468, 8364, 8261, 8157, 8053, -7949, 7845, 7741, 7637, 7532, -7428, 7323, 7219, 7114, 7009, -6905, 6800, 6695, 6590, 6485, -6380, 6274, 6169, 6064, 5958, -5853, 5747, 5642, 5536, 5430, -5325, 5219, 5113, 5007, 4901, -4795, 4689, 4583, 4476, 4370, -4264, 4157, 4051, 3945, 3838, -3732, 3625, 3518, 3412, 3305, -3198, 3092, 2985, 2878, 2771, -2664, 2558, 2451, 2344, 2237, -2130, 2023, 1916, 1809, 1702, -1594, 1487, 1380, 1273, 1166, -1059, 952, 844, 737, 630, -523, 416, 308, 201, 94, --13, -121, -228, -335, -442, --550, -657, -764, -871, -978, --1086, -1193, -1300, -1407, -1514, --1621, -1728, -1835, -1942, -2049, --2157, -2263, -2370, -2477, -2584, --2691, -2798, -2905, -3012, -3118, --3225, -3332, -3439, -3545, -3652, --3758, -3865, -3971, -4078, -4184, --4290, -4397, -4503, -4609, -4715, --4821, -4927, -5033, -5139, -5245, --5351, -5457, -5562, -5668, -5774, --5879, -5985, -6090, -6195, -6301, --6406, -6511, -6616, -6721, -6826, --6931, -7036, -7140, -7245, -7349, --7454, -7558, -7663, -7767, -7871, --7975, -8079, -8183, -8287, -8390, --8494, -8597, -8701, -8804, -8907, --9011, -9114, -9217, -9319, -9422, --9525, -9627, -9730, -9832, -9934, --10037, -10139, -10241, -10342, -10444, --10546, -10647, -10748, -10850, -10951, --11052, -11153, -11253, -11354, -11455, --11555, -11655, -11756, -11856, -11955, --12055, -12155, -12254, -12354, -12453, --12552, -12651, -12750, -12849, -12947, --13046, -13144, -13242, -13340, -13438, --13536, -13633, -13731, -13828, -13925, --14022, -14119, -14216, -14312, -14409, --14505, -14601, -14697, -14793, -14888, --14984, -15079, -15174, -15269, -15364, --15459, -15553, -15647, -15741, -15835, --15929, -16023, -16116, -16210, -16303, --16396, -16488, -16581, -16673, -16766, --16858, -16949, -17041, -17133, -17224, --17315, -17406, -17497, -17587, -17678, --17768, -17858, -17948, -18037, -18127, --18216, -18305, -18394, -18483, -18571, --18659, -18747, -18835, -18923, -19010, --19098, -19185, -19271, -19358, -19444, --19531, -19617, -19702, -19788, -19873, --19959, -20043, -20128, -20213, -20297, --20381, -20465, -20549, -20632, -20715, --20798, -20881, -20963, -21046, -21128, --21210, -21291, -21373, -21454, -21535, --21616, -21696, -21776, -21856, -21936, --22016, -22095, -22174, -22253, -22331, --22410, -22488, -22566, -22643, -22721, --22798, -22875, -22951, -23028, -23104, --23180, -23256, -23331, -23406, -23481, --23556, -23630, -23704, -23778, -23852, --23925, -23998, -24071, -24144, -24216, --24288, -24360, -24432, -24503, -24574, --24645, -24716, -24786, -24856, -24926, --24995, -25064, -25133, -25202, -25270, --25339, -25406, -25474, -25541, -25608, --25675, -25742, -25808, -25874, -25939, --26005, -26070, -26135, -26199, -26264, --26327, -26391, -26455, -26518, -26581, --26643, -26705, -26767, -26829, -26891, --26952, -27013, -27073, -27133, -27193, --27253, -27312, -27372, -27430, -27489, --27547, -27605, -27663, -27720, -27777, --27834, -27890, -27946, -28002, -28058, --28113, -28168, -28223, -28277, -28331, --28385, -28438, -28491, -28544, -28596, --28649, -28701, -28752, -28803, -28854, --28905, -28955, -29006, -29055, -29105, --29154, -29203, -29251, -29299, -29347, --29395, -29442, -29489, -29535, -29582, --29628, -29673, -29719, -29764, -29808, --29853, -29897, -29941, -29984, -30027, --30070, -30112, -30154, -30196, -30238, --30279, -30320, -30360, -30400, -30440, --30480, -30519, -30558, -30596, -30635, --30672, -30710, -30747, -30784, -30821, --30857, -30893, -30929, -30964, -30999, --31033, -31068, -31102, -31135, -31168, --31201, -31234, -31266, -31298, -31330, --31361, -31392, -31422, -31453, -31483, --31512, -31541, -31570, -31599, -31627, --31655, -31682, -31710, -31737, -31763, --31789, -31815, -31841, -31866, -31891, --31915, -31939, -31963, -31986, -32010, --32032, -32055, -32077, -32099, -32120, --32141, -32162, -32182, -32202, -32222, --32241, -32260, -32279, -32297, -32315, --32333, -32350, -32367, -32383, -32399, --32415, -32431, -32446, -32461, -32475, --32489, -32503, -32517, -32530, -32542, --32555, -32567, -32579, -32590, -32601, --32612, -32622, -32632, -32641, -32651, --32659, -32668, -32676, -32684, -32692, --32699, -32706, -32712, -32718, -32724, --32729, -32734, -32739, -32743, -32747, --32751, -32754, -32757, -32760, -32762, --32764, -32765, -32767, -32767, -32767, -32767, 32767, 32765, 32761, 32756, -32750, 32742, 32732, 32722, 32710, -32696, 32681, 32665, 32647, 32628, -32608, 32586, 32562, 32538, 32512, -32484, 32455, 32425, 32393, 32360, -32326, 32290, 32253, 32214, 32174, -32133, 32090, 32046, 32001, 31954, -31906, 31856, 31805, 31753, 31700, -31645, 31588, 31530, 31471, 31411, -31349, 31286, 31222, 31156, 31089, -31020, 30951, 30880, 30807, 30733, -30658, 30582, 30504, 30425, 30345, -30263, 30181, 30096, 30011, 29924, -29836, 29747, 29656, 29564, 29471, -29377, 29281, 29184, 29086, 28987, -28886, 28784, 28681, 28577, 28471, -28365, 28257, 28147, 28037, 27925, -27812, 27698, 27583, 27467, 27349, -27231, 27111, 26990, 26868, 26744, -26620, 26494, 26367, 26239, 26110, -25980, 25849, 25717, 25583, 25449, -25313, 25176, 25038, 24900, 24760, -24619, 24477, 24333, 24189, 24044, -23898, 23751, 23602, 23453, 23303, -23152, 22999, 22846, 22692, 22537, -22380, 22223, 22065, 21906, 21746, -21585, 21423, 21261, 21097, 20933, -20767, 20601, 20434, 20265, 20096, -19927, 19756, 19584, 19412, 19239, -19065, 18890, 18714, 18538, 18361, -18183, 18004, 17824, 17644, 17463, -17281, 17098, 16915, 16731, 16546, -16361, 16175, 15988, 15800, 15612, -15423, 15234, 15043, 14852, 14661, -14469, 14276, 14083, 13889, 13694, -13499, 13303, 13107, 12910, 12713, -12515, 12317, 12118, 11918, 11718, -11517, 11316, 11115, 10913, 10710, -10508, 10304, 10100, 9896, 9691, -9486, 9281, 9075, 8869, 8662, -8455, 8248, 8040, 7832, 7623, -7415, 7206, 6996, 6787, 6577, -6366, 6156, 5945, 5734, 5523, -5311, 5100, 4888, 4675, 4463, -4251, 4038, 3825, 3612, 3399, -3185, 2972, 2758, 2544, 2330, -2116, 1902, 1688, 1474, 1260, -1045, 831, 617, 402, 188, --27, -241, -456, -670, -885, --1099, -1313, -1528, -1742, -1956, --2170, -2384, -2598, -2811, -3025, --3239, -3452, -3665, -3878, -4091, --4304, -4516, -4728, -4941, -5153, --5364, -5576, -5787, -5998, -6209, --6419, -6629, -6839, -7049, -7258, --7467, -7676, -7884, -8092, -8300, --8507, -8714, -8920, -9127, -9332, --9538, -9743, -9947, -10151, -10355, --10558, -10761, -10963, -11165, -11367, --11568, -11768, -11968, -12167, -12366, --12565, -12762, -12960, -13156, -13352, --13548, -13743, -13937, -14131, -14324, --14517, -14709, -14900, -15091, -15281, --15470, -15659, -15847, -16035, -16221, --16407, -16593, -16777, -16961, -17144, --17326, -17508, -17689, -17869, -18049, --18227, -18405, -18582, -18758, -18934, --19108, -19282, -19455, -19627, -19799, --19969, -20139, -20308, -20475, -20642, --20809, -20974, -21138, -21301, -21464, --21626, -21786, -21946, -22105, -22263, --22420, -22575, -22730, -22884, -23037, --23189, -23340, -23490, -23640, -23788, --23935, -24080, -24225, -24369, -24512, --24654, -24795, -24934, -25073, -25211, --25347, -25482, -25617, -25750, -25882, --26013, -26143, -26272, -26399, -26526, --26651, -26775, -26898, -27020, -27141, --27260, -27379, -27496, -27612, -27727, --27841, -27953, -28065, -28175, -28284, --28391, -28498, -28603, -28707, -28810, --28911, -29012, -29111, -29209, -29305, --29401, -29495, -29587, -29679, -29769, --29858, -29946, -30032, -30118, -30201, --30284, -30365, -30445, -30524, -30601, --30677, -30752, -30825, -30897, -30968, --31038, -31106, -31172, -31238, -31302, --31365, -31426, -31486, -31545, -31602, --31658, -31713, -31766, -31818, -31869, --31918, -31966, -32012, -32058, -32101, --32144, -32185, -32224, -32262, -32299, --32335, -32369, -32401, -32433, -32463, --32491, -32518, -32544, -32568, -32591, --32613, -32633, -32652, -32669, -32685, --32700, -32713, -32724, -32735, -32744, --32751, -32757, -32762, -32766, -32767, -32767, 32764, 32755, 32741, 32720, -32694, 32663, 32626, 32583, 32535, -32481, 32421, 32356, 32286, 32209, -32128, 32041, 31948, 31850, 31747, -31638, 31523, 31403, 31278, 31148, -31012, 30871, 30724, 30572, 30415, -30253, 30086, 29913, 29736, 29553, -29365, 29172, 28974, 28771, 28564, -28351, 28134, 27911, 27684, 27452, -27216, 26975, 26729, 26478, 26223, -25964, 25700, 25432, 25159, 24882, -24601, 24315, 24026, 23732, 23434, -23133, 22827, 22517, 22204, 21886, -21565, 21240, 20912, 20580, 20244, -19905, 19563, 19217, 18868, 18516, -18160, 17802, 17440, 17075, 16708, -16338, 15964, 15588, 15210, 14829, -14445, 14059, 13670, 13279, 12886, -12490, 12093, 11693, 11291, 10888, -10482, 10075, 9666, 9255, 8843, -8429, 8014, 7597, 7180, 6760, -6340, 5919, 5496, 5073, 4649, -4224, 3798, 3372, 2945, 2517, -2090, 1661, 1233, 804, 375, --54, -483, -911, -1340, -1768, --2197, -2624, -3052, -3479, -3905, --4330, -4755, -5179, -5602, -6024, --6445, -6865, -7284, -7702, -8118, --8533, -8946, -9358, -9768, -10177, --10584, -10989, -11392, -11793, -12192, --12589, -12984, -13377, -13767, -14155, --14541, -14924, -15305, -15683, -16058, --16430, -16800, -17167, -17531, -17892, --18249, -18604, -18956, -19304, -19649, --19990, -20329, -20663, -20994, -21322, --21646, -21966, -22282, -22595, -22904, --23208, -23509, -23806, -24099, -24387, --24672, -24952, -25228, -25499, -25766, --26029, -26288, -26541, -26791, -27035, --27275, -27511, -27741, -27967, -28188, --28405, -28616, -28823, -29024, -29221, --29412, -29599, -29780, -29957, -30128, --30294, -30455, -30611, -30761, -30906, --31046, -31181, -31310, -31434, -31552, --31665, -31773, -31875, -31972, -32063, --32149, -32229, -32304, -32373, -32437, --32495, -32547, -32594, -32635, -32671, --32701, -32726, -32745, -32758, -32766, -32767, 32754, 32717, 32658, 32577, -32473, 32348, 32200, 32029, 31837, -31624, 31388, 31131, 30853, 30553, -30232, 29891, 29530, 29148, 28746, -28324, 27883, 27423, 26944, 26447, -25931, 25398, 24847, 24279, 23695, -23095, 22478, 21846, 21199, 20538, -19863, 19174, 18472, 17757, 17030, -16291, 15541, 14781, 14010, 13230, -12441, 11643, 10837, 10024, 9204, -8377, 7545, 6708, 5866, 5020, -4171, 3319, 2464, 1608, 751, --107, -965, -1822, -2678, -3532, --4383, -5232, -6077, -6918, -7754, --8585, -9409, -10228, -11039, -11843, --12639, -13426, -14204, -14972, -15730, --16477, -17213, -17937, -18648, -19347, --20033, -20705, -21363, -22006, -22634, --23246, -23843, -24423, -24986, -25533, --26062, -26573, -27066, -27540, -27995, --28431, -28848, -29245, -29622, -29979, --30315, -30630, -30924, -31197, -31449, --31679, -31887, -32074, -32239, -32381, --32501, -32600, -32675, -32729, -32759, -#endif + 2147483468, 2147469095, 2147431723, 2147371355, 2147287990, + 2147181629, 2147052273, 2146899924, 2146724584, 2146526254, + 2146304937, 2146060634, 2145793349, 2145503083, 2145189842, + 2144853627, 2144494442, 2144112292, 2143707180, 2143279110, + 2142828088, 2142354118, 2141857204, 2141337354, 2140794571, + 2140228862, 2139640233, 2139028690, 2138394240, 2137736889, + 2137056645, 2136353515, 2135627506, 2134878626, 2134106884, + 2133312286, 2132494843, 2131654563, 2130791454, 2129905526, + 2128996788, 2128065251, 2127110924, 2126133817, 2125133941, + 2124111307, 2123065925, 2121997806, 2120906963, 2119793407, + 2118657149, 2117498202, 2116316578, 2115112291, 2113885352, + 2112635775, 2111363574, 2110068761, 2108751352, 2107411359, + 2106048798, 2104663683, 2103256028, 2101825849, 2100373162, + 2098897981, 2097400322, 2095880202, 2094337637, 2092772643, + 2091185237, 2089575437, 2087943258, 2086288720, 2084611839, + 2082912633, 2081191122, 2079447322, 2077681253, 2075892934, + 2074082383, 2072249621, 2070394667, 2068517540, 2066618262, + 2064696851, 2062753329, 2060787717, 2058800036, 2056790306, + 2054758550, 2052704789, 2050629045, 2048531340, 2046411698, + 2044270140, 2042106689, 2039921369, 2037714204, 2035485216, + 2033234429, 2030961869, 2028667558, 2026351522, 2024013785, + 2021654373, 2019273310, 2016870623, 2014446336, 2012000477, + 2009533071, 2007044144, 2004533723, 2002001835, 1999448508, + 1996873768, 1994277643, 1991660161, 1989021350, 1986361238, + 1983679853, 1980977226, 1978253383, 1975508355, 1972742171, + 1969954860, 1967146453, 1964316979, 1961466469, 1958594953, + 1955702462, 1952789027, 1949854680, 1946899451, 1943923372, + 1940926475, 1937908793, 1934870357, 1931811201, 1928731356, + 1925630856, 1922509734, 1919368023, 1916205758, 1913022972, + 1909819698, 1906595972, 1903351828, 1900087301, 1896802425, + 1893497236, 1890171769, 1886826060, 1883460144, 1880074058, + 1876667838, 1873241521, 1869795142, 1866328740, 1862842350, + 1859336011, 1855809760, 1852263635, 1848697674, 1845111914, + 1841506395, 1837881155, 1834236233, 1830571667, 1826887497, + 1823183763, 1819460504, 1815717761, 1811955572, 1808173978, + 1804373021, 1800552740, 1796713177, 1792854372, 1788976368, + 1785079205, 1781162925, 1777227570, 1773273182, 1769299805, + 1765307479, 1761296249, 1757266156, 1753217244, 1749149557, + 1745063138, 1740958031, 1736834279, 1732691928, 1728531020, + 1724351602, 1720153717, 1715937410, 1711702727, 1707449714, + 1703178415, 1698888876, 1694581143, 1690255263, 1685911282, + 1681549245, 1677169201, 1672771196, 1668355276, 1663921490, + 1659469885, 1655000508, 1650513407, 1646008631, 1641486227, + 1636946244, 1632388731, 1627813736, 1623221309, 1618611498, + 1613984353, 1609339924, 1604678260, 1599999411, 1595303428, + 1590590360, 1585860258, 1581113173, 1576349155, 1571568256, + 1566770527, 1561956018, 1557124783, 1552276872, 1547412337, + 1542531231, 1537633606, 1532719513, 1527789007, 1522842139, + 1517878963, 1512899531, 1507903898, 1502892116, 1497864239, + 1492820322, 1487760417, 1482684580, 1477592864, 1472485325, + 1467362016, 1462222994, 1457068312, 1451898025, 1446712191, + 1441510863, 1436294098, 1431061951, 1425814478, 1420551737, + 1415273782, 1409980671, 1404672460, 1399349206, 1394010966, + 1388657798, 1383289758, 1377906904, 1372509294, 1367096986, + 1361670037, 1356228505, 1350772450, 1345301929, 1339817000, + 1334317724, 1328804158, 1323276361, 1317734393, 1312178313, + 1306608181, 1301024057, 1295425999, 1289814068, 1284188325, + 1278548828, 1272895640, 1267228820, 1261548429, 1255854528, + 1250147177, 1244426439, 1238692373, 1232945043, 1227184508, + 1221410831, 1215624074, 1209824299, 1204011567, 1198185941, + 1192347484, 1186496258, 1180632325, 1174755748, 1168866591, + 1162964917, 1157050787, 1151124267, 1145185419, 1139234307, + 1133270995, 1127295547, 1121308026, 1115308496, 1109297023, + 1103273670, 1097238502, 1091191583, 1085132978, 1079062753, + 1072980972, 1066887699, 1060783002, 1054666944, 1048539592, + 1042401010, 1036251266, 1030090423, 1023918550, 1017735711, + 1011541973, 1005337402, 999122065, 992896028, 986659358, + 980412122, 974154386, 967886217, 961607684, 955318852, + 949019790, 942710564, 936391243, 930061894, 923722585, + 917373383, 911014357, 904645574, 898267104, 891879014, + 885481373, 879074249, 872657710, 866231826, 859796666, + 853352298, 846898791, 840436214, 833964638, 827484130, + 820994760, 814496598, 807989714, 801474176, 794950056, + 788417422, 781876345, 775326894, 768769141, 762203154, + 755629005, 749046764, 742456501, 735858287, 729252193, + 722638289, 716016646, 709387335, 702750427, 696105993, + 689454104, 682794832, 676128248, 669454423, 662773428, + 656085336, 649390218, 642688145, 635979190, 629263424, + 622540918, 615811746, 609075979, 602333690, 595584950, + 588829831, 582068407, 575300749, 568526931, 561747023, + 554961100, 548169234, 541371497, 534567963, 527758704, + 520943793, 514123303, 507297307, 500465878, 493629090, + 486787016, 479939728, 473087301, 466229807, 459367320, + 452499914, 445627662, 438750638, 431868915, 424982567, + 418091668, 411196291, 404296511, 397392401, 390484035, + 383571488, 376654833, 369734144, 362809495, 355880961, + 348948616, 342012534, 335072790, 328129457, 321182610, + 314232323, 307278671, 300321729, 293361570, 286398270, + 279431902, 272462542, 265490265, 258515144, 251537254, + 244556671, 237573469, 230587722, 223599506, 216608896, + 209615966, 202620791, 195623446, 188624006, 181622546, + 174619141, 167613866, 160606796, 153598006, 146587571, + 139575567, 132562067, 125547148, 118530885, 111513352, + 104494625, 97474778, 90453888, 83432030, 76409277, + 69385707, 62361393, 55336412, 48310838, 41284746, + 34258213, 27231312, 20204120, 13176712, 6149162, + -878453, -7906059, -14933580, -21960942, -28988068, + -36014884, -43041314, -50067283, -57092716, -64117537, + -71141672, -78165045, -85187581, -92209205, -99229841, + -106249414, -113267850, -120285073, -127301007, -134315578, + -141328711, -148340330, -155350361, -162358728, -169365356, + -176370170, -183373096, -190374058, -197372981, -204369791, + -211364411, -218356769, -225346788, -232334393, -239319511, + -246302065, -253281982, -260259186, -267233603, -274205159, + -281173778, -288139385, -295101907, -302061269, -309017396, + -315970213, -322919647, -329865622, -336808065, -343746901, + -350682056, -357613455, -364541025, -371464690, -378384377, + -385300013, -392211522, -399118830, -406021865, -412920551, + -419814815, -426704583, -433589782, -440470337, -447346176, + -454217223, -461083406, -467944652, -474800886, -481652035, + -488498026, -495338786, -502174241, -509004318, -515828944, + -522648046, -529461551, -536269386, -543071478, -549867754, + -556658141, -563442567, -570220959, -576993244, -583759350, + -590519205, -597272736, -604019870, -610760536, -617494660, + -624222173, -630943000, -637657070, -644364312, -651064652, + -657758021, -664444345, -671123554, -677795576, -684460338, + -691117771, -697767803, -704410362, -711045377, -717672778, + -724292493, -730904451, -737508582, -744104815, -750693079, + -757273304, -763845419, -770409354, -776965038, -783512402, + -790051375, -796581887, -803103868, -809617249, -816121959, + -822617929, -829105090, -835583372, -842052705, -848513021, + -854964249, -861406322, -867839170, -874262724, -880676915, + -887081675, -893476935, -899862626, -906238681, -912605031, + -918961607, -925308342, -931645168, -937972016, -944288820, + -950595511, -956892022, -963178285, -969454234, -975719800, + -981974918, -988219519, -994453537, -1000676905, -1006889557, + -1013091426, -1019282445, -1025462549, -1031631671, -1037789745, + -1043936705, -1050072485, -1056197020, -1062310244, -1068412091, + -1074502497, -1080581395, -1086648722, -1092704411, -1098748398, + -1104780618, -1110801008, -1116809501, -1122806034, -1128790543, + -1134762964, -1140723232, -1146671283, -1152607055, -1158530484, + -1164441505, -1170340057, -1176226074, -1182099496, -1187960258, + -1193808298, -1199643553, -1205465961, -1211275460, -1217071986, + -1222855479, -1228625876, -1234383115, -1240127136, -1245857875, + -1251575272, -1257279266, -1262969796, -1268646800, -1274310217, + -1279959989, -1285596052, -1291218348, -1296826816, -1302421396, + -1308002029, -1313568653, -1319121210, -1324659641, -1330183885, + -1335693885, -1341189580, -1346670912, -1352137822, -1357590252, + -1363028143, -1368451438, -1373860077, -1379254004, -1384633159, + -1389997487, -1395346928, -1400681427, -1406000925, -1411305366, + -1416594694, -1421868850, -1427127780, -1432371426, -1437599733, + -1442812644, -1448010104, -1453192057, -1458358447, -1463509220, + -1468644319, -1473763690, -1478867279, -1483955030, -1489026889, + -1494082802, -1499122714, -1504146572, -1509154322, -1514145910, + -1519121283, -1524080387, -1529023170, -1533949577, -1538859558, + -1543753058, -1548630027, -1553490410, -1558334157, -1563161216, + -1567971534, -1572765060, -1577541744, -1582301533, -1587044377, + -1591770225, -1596479027, -1601170732, -1605845289, -1610502649, + -1615142762, -1619765578, -1624371047, -1628959121, -1633529750, + -1638082885, -1642618478, -1647136479, -1651636841, -1656119516, + -1660584454, -1665031609, -1669460933, -1673872378, -1678265898, + -1682641444, -1686998971, -1691338432, -1695659779, -1699962968, + -1704247951, -1708514683, -1712763118, -1716993211, -1721204917, + -1725398189, -1729572984, -1733729257, -1737866963, -1741986057, + -1746086497, -1750168237, -1754231234, -1758275445, -1762300826, + -1766307335, -1770294927, -1774263561, -1778213194, -1782143784, + -1786055289, -1789947667, -1793820875, -1797674873, -1801509620, + -1805325074, -1809121194, -1812897940, -1816655271, -1820393147, + -1824111529, -1827810376, -1831489648, -1835149306, -1838789312, + -1842409625, -1846010208, -1849591022, -1853152028, -1856693188, + -1860214464, -1863715819, -1867197215, -1870658615, -1874099982, + -1877521279, -1880922469, -1884303515, -1887664383, -1891005035, + -1894325435, -1897625550, -1900905342, -1904164776, -1907403819, + -1910622435, -1913820590, -1916998250, -1920155379, -1923291946, + -1926407915, -1929503255, -1932577931, -1935631910, -1938665161, + -1941677650, -1944669345, -1947640214, -1950590226, -1953519348, + -1956427550, -1959314800, -1962181067, -1965026321, -1967850531, + -1970653667, -1973435699, -1976196596, -1978936331, -1981654873, + -1984352192, -1987028261, -1989683050, -1992316532, -1994928677, + -1997519459, -2000088848, -2002636818, -2005163342, -2007668391, + -2010151941, -2012613963, -2015054432, -2017473321, -2019870604, + -2022246257, -2024600252, -2026932566, -2029243173, -2031532049, + -2033799168, -2036044507, -2038268042, -2040469748, -2042649603, + -2044807583, -2046943664, -2049057824, -2051150040, -2053220291, + -2055268553, -2057294804, -2059299024, -2061281190, -2063241282, + -2065179277, -2067095157, -2068988899, -2070860485, -2072709893, + -2074537104, -2076342098, -2078124857, -2079885360, -2081623590, + -2083339527, -2085033153, -2086704450, -2088353400, -2089979985, + -2091584189, -2093165993, -2094725382, -2096262337, -2097776843, + -2099268884, -2100738443, -2102185505, -2103610054, -2105012075, + -2106391553, -2107748474, -2109082822, -2110394584, -2111683744, + -2112950291, -2114194210, -2115415487, -2116614110, -2117790065, + -2118943341, -2120073924, -2121181804, -2122266967, -2123329402, + -2124369098, -2125386044, -2126380229, -2127351642, -2128300272, + -2129226111, -2130129147, -2131009371, -2131866773, -2132701345, + -2133513078, -2134301962, -2135067990, -2135811153, -2136531442, + -2137228852, -2137903373, -2138555000, -2139183723, -2139789539, + -2140372438, -2140932416, -2141469466, -2141983583, -2142474761, + -2142942995, -2143388280, -2143810610, -2144209982, -2144586392, + -2144939834, -2145270306, -2145577804, -2145862324, -2146123864, + -2146362421, -2146577992, -2146770575, -2146940167, -2147086768, + -2147210375, -2147310987, -2147388603, -2147443222, -2147474844, + 2147482929, 2147425435, 2147275952, 2147034487, 2146701050, + 2146275656, 2145758322, 2145149071, 2144447929, 2143654926, + 2142770096, 2141793477, 2140725111, 2139565043, 2138313323, + 2136970005, 2135535146, 2134008809, 2132391057, 2130681961, + 2128881593, 2126990031, 2125007356, 2122933653, 2120769010, + 2118513521, 2116167282, 2113730393, 2111202959, 2108585087, + 2105876892, 2103078487, 2100189994, 2097211535, 2094143239, + 2090985237, 2087737664, 2084400659, 2080974365, 2077458929, + 2073854502, 2070161238, 2066379295, 2062508835, 2058550025, + 2054503033, 2050368032, 2046145201, 2041834720, 2037436773, + 2032951550, 2028379241, 2023720043, 2018974156, 2014141783, + 2009223131, 2004218410, 1999127836, 1993951625, 1988690000, + 1983343186, 1977911412, 1972394912, 1966793920, 1961108677, + 1955339428, 1949486417, 1943549898, 1937530123, 1931427351, + 1925241843, 1918973864, 1912623682, 1906191570, 1899677803, + 1893082661, 1886406424, 1879649381, 1872811820, 1865894033, + 1858896318, 1851818974, 1844662304, 1837426615, 1830112217, + 1822719423, 1815248550, 1807699917, 1800073849, 1792370671, + 1784590714, 1776734311, 1768801799, 1760793518, 1752709809, + 1744551021, 1736317502, 1728009604, 1719627685, 1711172102, + 1702643219, 1694041400, 1685367013, 1676620432, 1667802029, + 1658912184, 1649951276, 1640919689, 1631817811, 1622646032, + 1613404744, 1604094343, 1594715227, 1585267800, 1575752465, + 1566169630, 1556519705, 1546803104, 1537020244, 1527171542, + 1517257422, 1507278307, 1497234626, 1487126808, 1476955286, + 1466720497, 1456422878, 1446062871, 1435640919, 1425157469, + 1414612971, 1404007875, 1393342636, 1382617710, 1371833558, + 1360990642, 1350089425, 1339130374, 1328113960, 1317040654, + 1305910930, 1294725265, 1283484138, 1272188032, 1260837429, + 1249432816, 1237974681, 1226463516, 1214899813, 1203284068, + 1191616778, 1179898443, 1168129565, 1156310649, 1144442200, + 1132524727, 1120558740, 1108544752, 1096483278, 1084374834, + 1072219940, 1060019115, 1047772882, 1035481766, 1023146293, + 1010766993, 998344394, 985879030, 973371434, 960822142, + 948231691, 935600622, 922929474, 910218791, 897469118, + 884680999, 871854984, 858991622, 846091463, 833155061, + 820182969, 807175743, 794133941, 781058120, 767948841, + 754806666, 741632158, 728425880, 715188400, 701920283, + 688622098, 675294414, 661937804, 648552838, 635140090, + 621700135, 608233549, 594740907, 581222789, 567679774, + 554112440, 540521371, 526907147, 513270353, 499611571, + 485931388, 472230390, 458509162, 444768294, 431008373, + 417229989, 403433732, 389620194, 375789965, 361943639, + 348081809, 334205068, 320314011, 306409232, 292491328, + 278560894, 264618528, 250664827, 236700388, 222725809, + 208741690, 194748629, 180747225, 166738079, 152721790, + 138698959, 124670187, 110636075, 96597223, 82554233, + 68507707, 54458246, 40406452, 26352928, 12298274, + -1756906, -15812011, -29866438, -43919586, -57970853, + -72019637, -86065335, -100107347, -114145071, -128177904, + -142205248, -156226499, -170241059, -184248325, -198247699, + -212238581, -226220372, -240192472, -254154282, -268105206, + -282044645, -295972002, -309886680, -323788084, -337675619, + -351548688, -365406698, -379249055, -393075166, -406884440, + -420676284, -434450107, -448205320, -461941333, -475657559, + -489353409, -503028296, -516681636, -530312842, -543921332, + -557506522, -571067830, -584604676, -598116479, -611602660, + -625062643, -638495850, -651901706, -665279637, -678629069, + -691949432, -705240153, -718500664, -731730397, -744928785, + -758095263, -771229267, -784330234, -797397602, -810430813, + -823429308, -836392529, -849319923, -862210934, -875065011, + -887881603, -900660162, -913400139, -926100989, -938762167, + -951383133, -963963344, -976502263, -988999351, -1001454074, + -1013865898, -1026234291, -1038558724, -1050838668, -1063073598, + -1075262990, -1087406320, -1099503070, -1111552721, -1123554757, + -1135508663, -1147413928, -1159270041, -1171076495, -1182832785, + -1194538405, -1206192856, -1217795637, -1229346252, -1240844206, + -1252289006, -1263680162, -1275017186, -1286299593, -1297526899, + -1308698624, -1319814288, -1330873416, -1341875533, -1352820169, + -1363706855, -1374535124, -1385304512, -1396014559, -1406664805, + -1417254794, -1427784073, -1438252190, -1448658697, -1459003149, + -1469285102, -1479504115, -1489659751, -1499751576, -1509779156, + -1519742062, -1529639867, -1539472148, -1549238483, -1558938453, + -1568571644, -1578137643, -1587636039, -1597066426, -1606428400, + -1615721561, -1624945509, -1634099849, -1643184191, -1652198144, + -1661141322, -1670013342, -1678813825, -1687542393, -1696198672, + -1704782292, -1713292884, -1721730085, -1730093532, -1738382868, + -1746597738, -1754737789, -1762802673, -1770792044, -1778705561, + -1786542883, -1794303676, -1801987607, -1809594347, -1817123570, + -1824574954, -1831948179, -1839242929, -1846458892, -1853595759, + -1860653224, -1867630985, -1874528743, -1881346202, -1888083070, + -1894739060, -1901313885, -1907807264, -1914218919, -1920548575, + -1926795962, -1932960811, -1939042858, -1945041843, -1950957509, + -1956789602, -1962537873, -1968202076, -1973781967, -1979277308, + -1984687864, -1990013401, -1995253694, -2000408516, -2005477648, + -2010460871, -2015357973, -2020168744, -2024892978, -2029530472, + -2034081027, -2038544449, -2042920547, -2047209133, -2051410023, + -2055523038, -2059548001, -2063484740, -2067333086, -2071092874, + -2074763944, -2078346137, -2081839301, -2085243286, -2088557947, + -2091783140, -2094918728, -2097964577, -2100920556, -2103786539, + -2106562402, -2109248028, -2111843300, -2114348108, -2116762344, + -2119085905, -2121318692, -2123460608, -2125511562, -2127471467, + -2129340237, -2131117794, -2132804061, -2134398966, -2135902440, + -2137314419, -2138634843, -2139863654, -2141000801, -2142046235, + -2142999911, -2143861787, -2144631828, -2145310000, -2145896274, + -2146390624, -2146793031, -2147103476, -2147321946, -2147448433, + 2147480773, 2147250799, 2146652904, 2145687192, 2144353827, + 2142653038, 2140585116, 2138150417, 2135349356, 2132182414, + 2128650133, 2124753120, 2120492040, 2115867626, 2110880668, + 2105532022, 2099822604, 2093753392, 2087325426, 2080539807, + 2073397699, 2065900325, 2058048970, 2049844978, 2041289756, + 2032384769, 2023131544, 2013531666, 2003586779, 1993298588, + 1982668856, 1971699403, 1960392110, 1948748914, 1936771810, + 1924462850, 1911824143, 1898857855, 1885566207, 1871951478, + 1858015999, 1843762158, 1829192399, 1814309216, 1799115162, + 1783612838, 1767804901, 1751694060, 1735283075, 1718574758, + 1701571972, 1684277631, 1666694698, 1648826185, 1630675154, + 1612244715, 1593538026, 1574558293, 1555308768, 1535792748, + 1516013578, 1495974647, 1475679389, 1455131280, 1434333842, + 1413290638, 1392005275, 1370481398, 1348722696, 1326732898, + 1304515771, 1282075122, 1259414796, 1236538675, 1213450681, + 1190154767, 1166654927, 1142955186, 1119059606, 1094972281, + 1070697338, 1046238936, 1021601267, 996788551, 971805042, + 946655018, 921342790, 895872694, 870249095, 844476384, + 818558976, 792501312, 766307857, 739983099, 713531549, + 686957739, 660266222, 633461572, 606548381, 579531262, + 552414843, 525203770, 497902707, 470516330, 443049333, + 415506422, 387892316, 360211746, 332469456, 304670200, + 276818739, 248919847, 220978304, 192998897, 164986421, + 136945676, 108881465, 80798598, 52701887, 24596146, + -3513810, -31623164, -59727099, -87820801, -115899455, + -143958250, -171992378, -199997036, -227967426, -255898755, + -283786237, -311625094, -339410555, -367137861, -394802258, + -422399009, -449923384, -477370666, -504736154, -532015158, + -559203003, -586295032, -613286603, -640173090, -666949886, + -693612404, -720156076, -746576352, -772868706, -799028633, + -825051651, -850933300, -876669146, -902254780, -927685817, + -952957899, -978066697, -1003007909, -1027777260, -1052370507, + -1076783436, -1101011863, -1125051638, -1148898640, -1172548785, + -1195998020, -1219242327, -1242277723, -1265100260, -1287706030, + -1310091157, -1332251808, -1354184184, -1375884527, -1397349119, + -1418574283, -1439556382, -1460291820, -1480777044, -1501008545, + -1520982856, -1540696555, -1560146263, -1579328647, -1598240423, + -1616878347, -1635239228, -1653319919, -1671117323, -1688628389, + -1705850117, -1722779556, -1739413807, -1755750017, -1771785389, + -1787517174, -1802942678, -1818059257, -1832864320, -1847355332, + -1861529809, -1875385322, -1888919498, -1902130017, -1915014616, + -1927571087, -1939797279, -1951691096, -1963250501, -1974473513, + -1985358210, -1995902725, -2006105253, -2015964045, -2025477412, + -2034643724, -2043461410, -2051928960, -2060044922, -2067807906, + -2075216581, -2082269679, -2088965991, -2095304370, -2101283728, + -2106903043, -2112161350, -2117057750, -2121591402, -2125761531, + -2129567422, -2133008422, -2136083942, -2138793455, -2141136497, + -2143112666, -2144721624, -2145963095, -2146836866, -2147342788, + 2147472149, 2146552303, 2144161316, 2140300829, 2134973487, + 2128182940, 2119933843, 2110231849, 2099083608, 2086496759, + 2072479930, 2057042727, 2040195730, 2021950484, 2002319494, + 1981316215, 1958955040, 1935251296, 1910221227, 1883881987, + 1856251629, 1827349089, 1797194176, 1765807555, 1733210737, + 1699426064, 1664476689, 1628386565, 1591180426, 1552883771, + 1513522847, 1473124631, 1431716808, 1389327759, 1345986533, + 1301722835, 1256567002, 1210549980, 1163703308, 1116059092, + 1067649985, 1018509163, 968670307, 918167572, 867035571, + 815309347, 763024350, 710216415, 656921734, 603176830, + 549018540, 494483979, 439610524, 384435782, 328997567, + 273333873, 217482850, 161482775, 105372028, 49189064, + -7027611, -63239471, -119407989, -175494670, -231461077, + -287268852, -342879747, -398255649, -453358607, -508150855, + -562594842, -616653255, -670289044, -723465451, -776146031, + -828294679, -879875655, -930853609, -981193602, -1030861133, + -1079822164, -1128043139, -1175491010, -1222133257, -1267937916, + -1312873593, -1356909492, -1400015434, -1442161874, -1483319929, + -1523461391, -1562558748, -1600585205, -1637514702, -1673321927, + -1707982341, -1741472190, -1773768520, -1804849198, -1834692923, + -1863279241, -1890588560, -1916602164, -1941302225, -1964671814, + -1986694916, -2007356435, -2026642214, -2044539032, -2061034626, + -2076117690, -2089777886, -2102005853, -2112793210, -2122132564, + -2130017514, -2136442657, -2141403589, -2144896910, -2146920225, }; #endif static const CELTMode mode48000_960_120 = { -48000, /* Fs */ -120, /* overlap */ -21, /* nbEBands */ -21, /* effEBands */ -{27853, 0, 4096, 8192, }, /* preemph */ -eband5ms, /* eBands */ -3, /* maxLM */ -8, /* nbShortMdcts */ -120, /* shortMdctSize */ -11, /* nbAllocVectors */ -band_allocation, /* allocVectors */ -logN400, /* logN */ -window120, /* window */ -{1920, 3, {&fft_state48000_960_0, &fft_state48000_960_1, &fft_state48000_960_2, &fft_state48000_960_3, }, mdct_twiddles960}, /* mdct */ -{392, cache_index50, cache_bits50, cache_caps50}, /* cache */ -#ifdef ENABLE_QEXT -{86, qext_cache_index50, qext_cache_bits50, qext_cache_caps50}, /* qext_cache */ -#endif + 48000, /* Fs */ + 120, /* overlap */ + 21, /* nbEBands */ + 21, /* effEBands */ + {27853, 0, 4096, 8192, }, /* preemph */ + eband5ms, /* eBands */ + 3, /* maxLM */ + 8, /* nbShortMdcts */ + 120, /* shortMdctSize */ + 11, /* nbAllocVectors */ + band_allocation, /* allocVectors */ + logN400, /* logN */ + window120, /* window */ + {1920, 3, {&fft_state48000_960_0, &fft_state48000_960_1, &fft_state48000_960_2, &fft_state48000_960_3, }, + mdct_twiddles960}, /* mdct */ + {392, cache_index50, cache_bits50, cache_caps50}, /* cache */ }; #ifdef ENABLE_QEXT -#ifndef DEF_WINDOW240 -#define DEF_WINDOW240 +# ifndef DEF_WINDOW240 +# define DEF_WINDOW240 static const celt_coef window240[240] = { -#ifdef ENABLE_QEXT -36124, 325113, 903042, 1769811, 2925272, -4369225, 6101422, 8121563, 10429297, 13024223, -15905885, 19073777, 22527339, 26265958, 30288963, -34595631, 39185180, 44056771, 49209509, 54642435, -60354533, 66344724, 72611866, 79154752, 85972112, -93062609, 100424835, 108057317, 115958510, 124126796, -132560487, 141257817, 150216948, 159435962, 168912864, -178645581, 188631957, 198869754, 209356654, 220090250, -231068053, 242287487, 253745886, 265440499, 277368483, -289526906, 301912744, 314522883, 327354113, 340403136, -353666556, 367140886, 380822544, 394707853, 408793044, -423074251, 437547515, 452208783, 467053909, 482078654, -497278684, 512649576, 528186815, 543885797, 559741828, -575750127, 591905825, 608203972, 624639532, 641207388, -657902345, 674719130, 691652394, 708696716, 725846605, -743096501, 760440782, 777873759, 795389689, 812982769, -830647145, 848376914, 866166126, 884008788, 901898872, -919830310, 937797006, 955792839, 973811661, 991847308, -1009893601, 1027944353, 1045993369, 1064034454, 1082061416, -1100068075, 1118048258, 1135995815, 1153904614, 1171768555, -1189581567, 1207337616, 1225030710, 1242654904, 1260204305, -1277673075, 1295055437, 1312345681, 1329538165, 1346627326, -1363607677, 1380473817, 1397220435, 1413842311, 1430334323, -1446691453, 1462908786, 1478981520, 1494904965, 1510674550, -1526285825, 1541734465, 1557016274, 1572127189, 1587063280, -1601820758, 1616395971, 1630785416, 1644985731, 1658993707, -1672806283, 1686420553, 1699833765, 1713043324, 1726046792, -1738841892, 1751426506, 1763798678, 1775956615, 1787898686, -1799623424, 1811129525, 1822415848, 1833481417, 1844325418, -1854947198, 1865346267, 1875522297, 1885475119, 1895204720, -1904711247, 1913995001, 1923056438, 1931896164, 1940514936, -1948913657, 1957093375, 1965055281, 1972800706, 1980331118, -1987648116, 1994753433, 2001648928, 2008336584, 2014818504, -2021096911, 2027174137, 2033052626, 2038734929, 2044223696, -2049521676, 2054631712, 2059556735, 2064299763, 2068863893, -2073252301, 2077468232, 2081515002, 2085395988, 2089114627, -2092674410, 2096078878, 2099331616, 2102436251, 2105396446, -2108215896, 2110898322, 2113447469, 2115867100, 2118160991, -2120332927, 2122386699, 2124326098, 2126154912, 2127876920, -2129495889, 2131015570, 2132439692, 2133771963, 2135016059, -2136175624, 2137254268, 2138255559, 2139183022, 2140040133, -2140830320, 2141556955, 2142223351, 2142832762, 2143388377, -2143893317, 2144350634, 2144763305, 2145134231, 2145466235, -2145762059, 2146024357, 2146255701, 2146458570, 2146635355, -2146788350, 2146919756, 2147031676, 2147126111, 2147204964, -2147270033, 2147323012, 2147365487, 2147398940, 2147424741, -2147444152, 2147458322, 2147468290, 2147474980, 2147479203, -2147481655, 2147482918, 2147483458, 2147483623, 2147483647, -#else -1, 5, 14, 27, 45, -67, 93, 124, 159, 199, -243, 291, 344, 401, 462, -528, 598, 672, 751, 834, -921, 1012, 1108, 1208, 1312, -1420, 1532, 1649, 1769, 1894, -2023, 2155, 2292, 2433, 2577, -2726, 2878, 3035, 3195, 3358, -3526, 3697, 3872, 4050, 4232, -4418, 4607, 4799, 4995, 5194, -5397, 5602, 5811, 6023, 6238, -6456, 6676, 6900, 7127, 7356, -7588, 7822, 8059, 8299, 8541, -8785, 9032, 9280, 9531, 9784, -10039, 10295, 10554, 10814, 11076, -11339, 11603, 11869, 12137, 12405, -12675, 12945, 13217, 13489, 13762, -14035, 14310, 14584, 14859, 15134, -15410, 15685, 15961, 16236, 16511, -16786, 17060, 17334, 17607, 17880, -18152, 18423, 18692, 18961, 19229, -19496, 19761, 20025, 20287, 20548, -20807, 21064, 21320, 21574, 21825, -22075, 22322, 22567, 22810, 23051, -23289, 23525, 23758, 23989, 24217, -24442, 24664, 24884, 25100, 25314, -25525, 25733, 25937, 26139, 26337, -26533, 26725, 26913, 27099, 27281, -27460, 27636, 27808, 27977, 28142, -28304, 28463, 28618, 28770, 28919, -29064, 29205, 29344, 29478, 29610, -29738, 29863, 29984, 30103, 30217, -30329, 30438, 30543, 30645, 30744, -30839, 30932, 31022, 31109, 31192, -31273, 31351, 31426, 31499, 31568, -31635, 31700, 31761, 31821, 31877, -31932, 31984, 32033, 32081, 32126, -32169, 32210, 32249, 32286, 32321, -32354, 32385, 32415, 32443, 32469, -32494, 32517, 32538, 32559, 32578, -32595, 32612, 32627, 32641, 32654, -32666, 32678, 32688, 32697, 32706, -32713, 32720, 32726, 32732, 32737, -32742, 32746, 32749, 32752, 32755, -32757, 32759, 32761, 32763, 32764, -32765, 32766, 32766, 32767, 32767, -32767, 32767, 32767, 32767, 32767, -32767, 32767, 32767, 32767, 32767, -#endif + 36124, 325113, 903042, 1769811, 2925272, + 4369225, 6101422, 8121563, 10429297, 13024223, + 15905885, 19073777, 22527339, 26265958, 30288963, + 34595631, 39185180, 44056771, 49209509, 54642435, + 60354533, 66344724, 72611866, 79154752, 85972112, + 93062609, 100424835, 108057317, 115958510, 124126796, + 132560487, 141257817, 150216948, 159435962, 168912864, + 178645581, 188631957, 198869754, 209356654, 220090250, + 231068053, 242287487, 253745886, 265440499, 277368483, + 289526906, 301912744, 314522883, 327354113, 340403136, + 353666556, 367140886, 380822544, 394707853, 408793044, + 423074251, 437547515, 452208783, 467053909, 482078654, + 497278684, 512649576, 528186815, 543885797, 559741828, + 575750127, 591905825, 608203972, 624639532, 641207388, + 657902345, 674719130, 691652394, 708696716, 725846605, + 743096501, 760440782, 777873759, 795389689, 812982769, + 830647145, 848376914, 866166126, 884008788, 901898872, + 919830310, 937797006, 955792839, 973811661, 991847308, + 1009893601, 1027944353, 1045993369, 1064034454, 1082061416, + 1100068075, 1118048258, 1135995815, 1153904614, 1171768555, + 1189581567, 1207337616, 1225030710, 1242654904, 1260204305, + 1277673075, 1295055437, 1312345681, 1329538165, 1346627326, + 1363607677, 1380473817, 1397220435, 1413842311, 1430334323, + 1446691453, 1462908786, 1478981520, 1494904965, 1510674550, + 1526285825, 1541734465, 1557016274, 1572127189, 1587063280, + 1601820758, 1616395971, 1630785416, 1644985731, 1658993707, + 1672806283, 1686420553, 1699833765, 1713043324, 1726046792, + 1738841892, 1751426506, 1763798678, 1775956615, 1787898686, + 1799623424, 1811129525, 1822415848, 1833481417, 1844325418, + 1854947198, 1865346267, 1875522297, 1885475119, 1895204720, + 1904711247, 1913995001, 1923056438, 1931896164, 1940514936, + 1948913657, 1957093375, 1965055281, 1972800706, 1980331118, + 1987648116, 1994753433, 2001648928, 2008336584, 2014818504, + 2021096911, 2027174137, 2033052626, 2038734929, 2044223696, + 2049521676, 2054631712, 2059556735, 2064299763, 2068863893, + 2073252301, 2077468232, 2081515002, 2085395988, 2089114627, + 2092674410, 2096078878, 2099331616, 2102436251, 2105396446, + 2108215896, 2110898322, 2113447469, 2115867100, 2118160991, + 2120332927, 2122386699, 2124326098, 2126154912, 2127876920, + 2129495889, 2131015570, 2132439692, 2133771963, 2135016059, + 2136175624, 2137254268, 2138255559, 2139183022, 2140040133, + 2140830320, 2141556955, 2142223351, 2142832762, 2143388377, + 2143893317, 2144350634, 2144763305, 2145134231, 2145466235, + 2145762059, 2146024357, 2146255701, 2146458570, 2146635355, + 2146788350, 2146919756, 2147031676, 2147126111, 2147204964, + 2147270033, 2147323012, 2147365487, 2147398940, 2147424741, + 2147444152, 2147458322, 2147468290, 2147474980, 2147479203, + 2147481655, 2147482918, 2147483458, 2147483623, 2147483647, }; -#endif +# endif -#ifndef DEF_LOGN400 -#define DEF_LOGN400 -static const opus_int16 logN400[21] = { -0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36, }; -#endif +# ifndef DEF_LOGN400 +# define DEF_LOGN400 +static const oac_int16 logN400[21] = { + 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36, }; +# endif -#ifndef DEF_PULSE_CACHE50 -#define DEF_PULSE_CACHE50 -static const opus_int16 cache_index50[105] = { --1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, -82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, -41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41, -41, 41, 41, 41, 41, 123, 123, 123, 123, 240, 240, 240, 266, 266, 305, -318, 328, 336, 123, 123, 123, 123, 123, 123, 123, 123, 240, 240, 240, 240, -305, 305, 305, 318, 318, 343, 351, 358, 364, 240, 240, 240, 240, 240, 240, -240, 240, 305, 305, 305, 305, 343, 343, 343, 351, 351, 370, 376, 382, 387, +# ifndef DEF_PULSE_CACHE50 +# define DEF_PULSE_CACHE50 +static const oac_int16 cache_index50[105] = { + -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, + 82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, + 41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41, + 41, 41, 41, 41, 41, 123, 123, 123, 123, 240, 240, 240, 266, 266, 305, + 318, 328, 336, 123, 123, 123, 123, 123, 123, 123, 123, 240, 240, 240, 240, + 305, 305, 305, 318, 318, 343, 351, 358, 364, 240, 240, 240, 240, 240, 240, + 240, 240, 305, 305, 305, 305, 343, 343, 343, 351, 351, 370, 376, 382, 387, }; static const unsigned char cache_bits50[392] = { -40, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 40, 15, 23, 28, -31, 34, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47, 47, 49, 50, -51, 52, 53, 54, 55, 55, 57, 58, 59, 60, 61, 62, 63, 63, 65, -66, 67, 68, 69, 70, 71, 71, 40, 20, 33, 41, 48, 53, 57, 61, -64, 66, 69, 71, 73, 75, 76, 78, 80, 82, 85, 87, 89, 91, 92, -94, 96, 98, 101, 103, 105, 107, 108, 110, 112, 114, 117, 119, 121, 123, -124, 126, 128, 40, 23, 39, 51, 60, 67, 73, 79, 83, 87, 91, 94, -97, 100, 102, 105, 107, 111, 115, 118, 121, 124, 126, 129, 131, 135, 139, -142, 145, 148, 150, 153, 155, 159, 163, 166, 169, 172, 174, 177, 179, 35, -28, 49, 65, 78, 89, 99, 107, 114, 120, 126, 132, 136, 141, 145, 149, -153, 159, 165, 171, 176, 180, 185, 189, 192, 199, 205, 211, 216, 220, 225, -229, 232, 239, 245, 251, 21, 33, 58, 79, 97, 112, 125, 137, 148, 157, -166, 174, 182, 189, 195, 201, 207, 217, 227, 235, 243, 251, 17, 35, 63, -86, 106, 123, 139, 152, 165, 177, 187, 197, 206, 214, 222, 230, 237, 250, -25, 31, 55, 75, 91, 105, 117, 128, 138, 146, 154, 161, 168, 174, 180, -185, 190, 200, 208, 215, 222, 229, 235, 240, 245, 255, 16, 36, 65, 89, -110, 128, 144, 159, 173, 185, 196, 207, 217, 226, 234, 242, 250, 11, 41, -74, 103, 128, 151, 172, 191, 209, 225, 241, 255, 9, 43, 79, 110, 138, -163, 186, 207, 227, 246, 12, 39, 71, 99, 123, 144, 164, 182, 198, 214, -228, 241, 253, 9, 44, 81, 113, 142, 168, 192, 214, 235, 255, 7, 49, -90, 127, 160, 191, 220, 247, 6, 51, 95, 134, 170, 203, 234, 7, 47, -87, 123, 155, 184, 212, 237, 6, 52, 97, 137, 174, 208, 240, 5, 57, -106, 151, 192, 231, 5, 59, 111, 158, 202, 243, 5, 55, 103, 147, 187, -224, 5, 60, 113, 161, 206, 248, 4, 65, 122, 175, 224, 4, 67, 127, -182, 234, }; + 40, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 40, 15, 23, 28, + 31, 34, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47, 47, 49, 50, + 51, 52, 53, 54, 55, 55, 57, 58, 59, 60, 61, 62, 63, 63, 65, + 66, 67, 68, 69, 70, 71, 71, 40, 20, 33, 41, 48, 53, 57, 61, + 64, 66, 69, 71, 73, 75, 76, 78, 80, 82, 85, 87, 89, 91, 92, + 94, 96, 98, 101, 103, 105, 107, 108, 110, 112, 114, 117, 119, 121, 123, + 124, 126, 128, 40, 23, 39, 51, 60, 67, 73, 79, 83, 87, 91, 94, + 97, 100, 102, 105, 107, 111, 115, 118, 121, 124, 126, 129, 131, 135, 139, + 142, 145, 148, 150, 153, 155, 159, 163, 166, 169, 172, 174, 177, 179, 35, + 28, 49, 65, 78, 89, 99, 107, 114, 120, 126, 132, 136, 141, 145, 149, + 153, 159, 165, 171, 176, 180, 185, 189, 192, 199, 205, 211, 216, 220, 225, + 229, 232, 239, 245, 251, 21, 33, 58, 79, 97, 112, 125, 137, 148, 157, + 166, 174, 182, 189, 195, 201, 207, 217, 227, 235, 243, 251, 17, 35, 63, + 86, 106, 123, 139, 152, 165, 177, 187, 197, 206, 214, 222, 230, 237, 250, + 25, 31, 55, 75, 91, 105, 117, 128, 138, 146, 154, 161, 168, 174, 180, + 185, 190, 200, 208, 215, 222, 229, 235, 240, 245, 255, 16, 36, 65, 89, + 110, 128, 144, 159, 173, 185, 196, 207, 217, 226, 234, 242, 250, 11, 41, + 74, 103, 128, 151, 172, 191, 209, 225, 241, 255, 9, 43, 79, 110, 138, + 163, 186, 207, 227, 246, 12, 39, 71, 99, 123, 144, 164, 182, 198, 214, + 228, 241, 253, 9, 44, 81, 113, 142, 168, 192, 214, 235, 255, 7, 49, + 90, 127, 160, 191, 220, 247, 6, 51, 95, 134, 170, 203, 234, 7, 47, + 87, 123, 155, 184, 212, 237, 6, 52, 97, 137, 174, 208, 240, 5, 57, + 106, 151, 192, 231, 5, 59, 111, 158, 202, 243, 5, 55, 103, 147, 187, + 224, 5, 60, 113, 161, 206, 248, 4, 65, 122, 175, 224, 4, 67, 127, + 182, 234, }; static const unsigned char cache_caps50[168] = { -224, 224, 224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 185, 185, 185, -178, 178, 168, 134, 61, 37, 224, 224, 224, 224, 224, 224, 224, 224, 240, -240, 240, 240, 207, 207, 207, 198, 198, 183, 144, 66, 40, 160, 160, 160, -160, 160, 160, 160, 160, 185, 185, 185, 185, 193, 193, 193, 183, 183, 172, -138, 64, 38, 240, 240, 240, 240, 240, 240, 240, 240, 207, 207, 207, 207, -204, 204, 204, 193, 193, 180, 143, 66, 40, 185, 185, 185, 185, 185, 185, -185, 185, 193, 193, 193, 193, 193, 193, 193, 183, 183, 172, 138, 65, 39, -207, 207, 207, 207, 207, 207, 207, 207, 204, 204, 204, 204, 201, 201, 201, -188, 188, 176, 141, 66, 40, 193, 193, 193, 193, 193, 193, 193, 193, 193, -193, 193, 193, 194, 194, 194, 184, 184, 173, 139, 65, 39, 204, 204, 204, -204, 204, 204, 204, 204, 201, 201, 201, 201, 198, 198, 198, 187, 187, 175, -140, 66, 40, }; -#endif - -#ifdef ENABLE_QEXT -# ifndef DEF_QEXT_PULSE_CACHE50 -# define DEF_QEXT_PULSE_CACHE50 -static const opus_int16 qext_cache_index50[70] = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, -41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 61, 61, -61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 72, 72, 72, -72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 80, 80, 80, 80, -80, 80, 80, 80, 80, 80, 80, 80, 80, 80, }; -static const unsigned char qext_cache_bits50[86] = { -40, 26, 45, 59, 70, 79, 87, 94, 100, 105, 110, 114, 118, 122, 125, -128, 131, 136, 141, 146, 150, 153, 157, 160, 163, 168, 173, 178, 182, 185, -189, 192, 195, 200, 205, 210, 214, 217, 221, 224, 227, 19, 34, 61, 83, -101, 118, 132, 145, 157, 167, 177, 186, 194, 202, 209, 216, 222, 234, 245, -254, 10, 42, 77, 107, 133, 157, 179, 200, 219, 236, 253, 7, 50, 93, -131, 165, 197, 227, 255, 5, 58, 109, 155, 197, 237, }; -static const unsigned char qext_cache_caps50[112] = { -159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 171, -171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 167, 167, 167, -167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 166, 166, 166, 166, 166, -166, 166, 166, 166, 166, 166, 166, 166, 166, 163, 163, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 165, 165, 165, 165, 165, 165, 165, -165, 165, 165, 165, 165, 165, 165, }; + 224, 224, 224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 185, 185, 185, + 178, 178, 168, 134, 61, 37, 224, 224, 224, 224, 224, 224, 224, 224, 240, + 240, 240, 240, 207, 207, 207, 198, 198, 183, 144, 66, 40, 160, 160, 160, + 160, 160, 160, 160, 160, 185, 185, 185, 185, 193, 193, 193, 183, 183, 172, + 138, 64, 38, 240, 240, 240, 240, 240, 240, 240, 240, 207, 207, 207, 207, + 204, 204, 204, 193, 193, 180, 143, 66, 40, 185, 185, 185, 185, 185, 185, + 185, 185, 193, 193, 193, 193, 193, 193, 193, 183, 183, 172, 138, 65, 39, + 207, 207, 207, 207, 207, 207, 207, 207, 204, 204, 204, 204, 201, 201, 201, + 188, 188, 176, 141, 66, 40, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 194, 194, 194, 184, 184, 173, 139, 65, 39, 204, 204, 204, + 204, 204, 204, 204, 204, 201, 201, 201, 201, 198, 198, 198, 187, 187, 175, + 140, 66, 40, }; # endif -#endif -#ifndef FFT_TWIDDLES96000_1920 -#define FFT_TWIDDLES96000_1920 +# ifndef FFT_TWIDDLES96000_1920 +# define FFT_TWIDDLES96000_1920 static const kiss_twiddle_cpx fft_twiddles96000_1920[960] = { -#ifdef ENABLE_QEXT -{2147483647, 0}, {2147437652, -14055147}, -{2147299668, -28109692}, {2147069700, -42163034}, -{2146747759, -56214568}, {2146333858, -70263695}, -{2145828016, -84309812}, {2145230253, -98352318}, -{2144540596, -112390610}, {2143759074, -126424088}, -{2142885721, -140452151}, {2141920573, -154474196}, -{2140863673, -168489625}, {2139715065, -182497836}, -{2138474799, -196498230}, {2137142927, -210490206}, -{2135719508, -224473166}, {2134204601, -238446509}, -{2132598273, -252409639}, {2130900591, -266361956}, -{2129111628, -280302863}, {2127231461, -294231763}, -{2125260170, -308148059}, {2123197841, -322051155}, -{2121044561, -335940456}, {2118800422, -349815365}, -{2116465521, -363675290}, {2114039958, -377519637}, -{2111523836, -391347811}, {2108917263, -405159222}, -{2106220352, -418953276}, {2103433217, -432729385}, -{2100555978, -446486956}, {2097588758, -460225402}, -{2094531684, -473944133}, {2091384888, -487642562}, -{2088148504, -501320102}, {2084822670, -514976167}, -{2081407530, -528610172}, {2077903229, -542221533}, -{2074309917, -555809667}, {2070627749, -569373992}, -{2066856882, -582913927}, {2062997478, -596428893}, -{2059049702, -609918309}, {2055013723, -623381598}, -{2050889714, -636818183}, {2046677852, -650227490}, -{2042378317, -663608942}, {2037991293, -676961968}, -{2033516969, -690285996}, {2028955535, -703580453}, -{2024307188, -716844772}, {2019572126, -730078383}, -{2014750553, -743280720}, {2009842674, -756451218}, -{2004848700, -769589312}, {1999768845, -782694439}, -{1994603327, -795766038}, {1989352366, -808803549}, -{1984016189, -821806413}, {1978595022, -834774075}, -{1973089100, -847705977}, {1967498656, -860601566}, -{1961823932, -873460290}, {1956065170, -886281598}, -{1950222616, -899064940}, {1944296521, -911809770}, -{1938287139, -924515541}, {1932194727, -937181708}, -{1926019547, -949807730}, {1919761862, -962393065}, -{1913421941, -974937175}, {1907000055, -987439521}, -{1900496480, -999899569}, {1893911494, -1012316784}, -{1887245379, -1024690635}, {1880498421, -1037020592}, -{1873670908, -1049306126}, {1866763134, -1061546712}, -{1859775393, -1073741824}, {1852707986, -1085890941}, -{1845561216, -1097993542}, {1838335387, -1110049108}, -{1831030811, -1122057124}, {1823647799, -1134017074}, -{1816186668, -1145928447}, {1808647737, -1157790732}, -{1801031331, -1169603422}, {1793337774, -1181366009}, -{1785567396, -1193077991}, {1777720531, -1204738865}, -{1769797514, -1216348132}, {1761798685, -1227905295}, -{1753724386, -1239409858}, {1745574963, -1250861329}, -{1737350766, -1262259218}, {1729052147, -1273603035}, -{1720679461, -1284892296}, {1712233066, -1296126516}, -{1703713325, -1307305214}, {1695120603, -1318427912}, -{1686455268, -1329494133}, {1677717690, -1340503402}, -{1668908244, -1351455249}, {1660027308, -1362349204}, -{1651075262, -1373184801}, {1642052490, -1383961574}, -{1632959377, -1394679064}, {1623796314, -1405336810}, -{1614563692, -1415934356}, {1605261909, -1426471249}, -{1595891361, -1436947036}, {1586452450, -1447361268}, -{1576945581, -1457713501}, {1567371161, -1468003290}, -{1557729600, -1478230195}, {1548021312, -1488393778}, -{1538246711, -1498493602}, {1528406216, -1508529236}, -{1518500250, -1518500250}, {1508529236, -1528406216}, -{1498493602, -1538246711}, {1488393778, -1548021312}, -{1478230195, -1557729600}, {1468003290, -1567371161}, -{1457713501, -1576945581}, {1447361268, -1586452450}, -{1436947036, -1595891361}, {1426471249, -1605261909}, -{1415934356, -1614563692}, {1405336810, -1623796314}, -{1394679064, -1632959377}, {1383961574, -1642052490}, -{1373184801, -1651075262}, {1362349204, -1660027308}, -{1351455249, -1668908244}, {1340503402, -1677717690}, -{1329494133, -1686455268}, {1318427912, -1695120603}, -{1307305214, -1703713325}, {1296126516, -1712233066}, -{1284892296, -1720679461}, {1273603035, -1729052147}, -{1262259218, -1737350766}, {1250861329, -1745574963}, -{1239409858, -1753724386}, {1227905295, -1761798685}, -{1216348132, -1769797514}, {1204738865, -1777720531}, -{1193077991, -1785567396}, {1181366009, -1793337774}, -{1169603422, -1801031331}, {1157790732, -1808647737}, -{1145928447, -1816186668}, {1134017074, -1823647799}, -{1122057124, -1831030811}, {1110049108, -1838335387}, -{1097993542, -1845561216}, {1085890941, -1852707986}, -{1073741824, -1859775393}, {1061546712, -1866763134}, -{1049306126, -1873670908}, {1037020592, -1880498421}, -{1024690635, -1887245379}, {1012316784, -1893911494}, -{999899569, -1900496480}, {987439521, -1907000055}, -{974937175, -1913421941}, {962393065, -1919761862}, -{949807730, -1926019547}, {937181708, -1932194727}, -{924515541, -1938287139}, {911809770, -1944296521}, -{899064940, -1950222616}, {886281598, -1956065170}, -{873460290, -1961823932}, {860601566, -1967498656}, -{847705977, -1973089100}, {834774075, -1978595022}, -{821806413, -1984016189}, {808803549, -1989352366}, -{795766038, -1994603327}, {782694439, -1999768845}, -{769589312, -2004848700}, {756451218, -2009842674}, -{743280720, -2014750553}, {730078383, -2019572126}, -{716844772, -2024307188}, {703580453, -2028955535}, -{690285996, -2033516969}, {676961968, -2037991293}, -{663608942, -2042378317}, {650227490, -2046677852}, -{636818183, -2050889714}, {623381598, -2055013723}, -{609918309, -2059049702}, {596428893, -2062997478}, -{582913927, -2066856882}, {569373992, -2070627749}, -{555809667, -2074309917}, {542221533, -2077903229}, -{528610172, -2081407530}, {514976167, -2084822670}, -{501320102, -2088148504}, {487642562, -2091384888}, -{473944133, -2094531684}, {460225402, -2097588758}, -{446486956, -2100555978}, {432729385, -2103433217}, -{418953276, -2106220352}, {405159222, -2108917263}, -{391347811, -2111523836}, {377519637, -2114039958}, -{363675290, -2116465521}, {349815365, -2118800422}, -{335940456, -2121044561}, {322051155, -2123197841}, -{308148059, -2125260170}, {294231763, -2127231461}, -{280302863, -2129111628}, {266361956, -2130900591}, -{252409639, -2132598273}, {238446509, -2134204601}, -{224473166, -2135719508}, {210490206, -2137142927}, -{196498230, -2138474799}, {182497836, -2139715065}, -{168489625, -2140863673}, {154474196, -2141920573}, -{140452151, -2142885721}, {126424088, -2143759074}, -{112390610, -2144540596}, {98352318, -2145230253}, -{84309812, -2145828016}, {70263695, -2146333858}, -{56214568, -2146747759}, {42163034, -2147069700}, -{28109692, -2147299668}, {14055147, -2147437652}, -{0, -2147483648}, {-14055147, -2147437652}, -{-28109692, -2147299668}, {-42163034, -2147069700}, -{-56214568, -2146747759}, {-70263695, -2146333858}, -{-84309812, -2145828016}, {-98352318, -2145230253}, -{-112390610, -2144540596}, {-126424088, -2143759074}, -{-140452151, -2142885721}, {-154474196, -2141920573}, -{-168489625, -2140863673}, {-182497836, -2139715065}, -{-196498230, -2138474799}, {-210490206, -2137142927}, -{-224473166, -2135719508}, {-238446509, -2134204601}, -{-252409639, -2132598273}, {-266361956, -2130900591}, -{-280302863, -2129111628}, {-294231763, -2127231461}, -{-308148059, -2125260170}, {-322051155, -2123197841}, -{-335940456, -2121044561}, {-349815365, -2118800422}, -{-363675290, -2116465521}, {-377519637, -2114039958}, -{-391347811, -2111523836}, {-405159222, -2108917263}, -{-418953276, -2106220352}, {-432729385, -2103433217}, -{-446486956, -2100555978}, {-460225402, -2097588758}, -{-473944133, -2094531684}, {-487642562, -2091384888}, -{-501320102, -2088148504}, {-514976167, -2084822670}, -{-528610172, -2081407530}, {-542221533, -2077903229}, -{-555809667, -2074309917}, {-569373992, -2070627749}, -{-582913927, -2066856882}, {-596428893, -2062997478}, -{-609918309, -2059049702}, {-623381598, -2055013723}, -{-636818183, -2050889714}, {-650227490, -2046677852}, -{-663608942, -2042378317}, {-676961968, -2037991293}, -{-690285996, -2033516969}, {-703580453, -2028955535}, -{-716844772, -2024307188}, {-730078383, -2019572126}, -{-743280720, -2014750553}, {-756451218, -2009842674}, -{-769589312, -2004848700}, {-782694439, -1999768845}, -{-795766038, -1994603327}, {-808803549, -1989352366}, -{-821806413, -1984016189}, {-834774075, -1978595022}, -{-847705977, -1973089100}, {-860601566, -1967498656}, -{-873460290, -1961823932}, {-886281598, -1956065170}, -{-899064940, -1950222616}, {-911809770, -1944296521}, -{-924515541, -1938287139}, {-937181708, -1932194727}, -{-949807730, -1926019547}, {-962393065, -1919761862}, -{-974937175, -1913421941}, {-987439521, -1907000055}, -{-999899569, -1900496480}, {-1012316784, -1893911494}, -{-1024690635, -1887245379}, {-1037020592, -1880498421}, -{-1049306126, -1873670908}, {-1061546712, -1866763134}, -{-1073741824, -1859775393}, {-1085890941, -1852707986}, -{-1097993542, -1845561216}, {-1110049108, -1838335387}, -{-1122057124, -1831030811}, {-1134017074, -1823647799}, -{-1145928447, -1816186668}, {-1157790732, -1808647737}, -{-1169603422, -1801031331}, {-1181366009, -1793337774}, -{-1193077991, -1785567396}, {-1204738865, -1777720531}, -{-1216348132, -1769797514}, {-1227905295, -1761798685}, -{-1239409858, -1753724386}, {-1250861329, -1745574963}, -{-1262259218, -1737350766}, {-1273603035, -1729052147}, -{-1284892296, -1720679461}, {-1296126516, -1712233066}, -{-1307305214, -1703713325}, {-1318427912, -1695120603}, -{-1329494133, -1686455268}, {-1340503402, -1677717690}, -{-1351455249, -1668908244}, {-1362349204, -1660027308}, -{-1373184801, -1651075262}, {-1383961574, -1642052490}, -{-1394679064, -1632959377}, {-1405336810, -1623796314}, -{-1415934356, -1614563692}, {-1426471249, -1605261909}, -{-1436947036, -1595891361}, {-1447361268, -1586452450}, -{-1457713501, -1576945581}, {-1468003290, -1567371161}, -{-1478230195, -1557729600}, {-1488393778, -1548021312}, -{-1498493602, -1538246711}, {-1508529236, -1528406216}, -{-1518500250, -1518500250}, {-1528406216, -1508529236}, -{-1538246711, -1498493602}, {-1548021312, -1488393778}, -{-1557729600, -1478230195}, {-1567371161, -1468003290}, -{-1576945581, -1457713501}, {-1586452450, -1447361268}, -{-1595891361, -1436947036}, {-1605261909, -1426471249}, -{-1614563692, -1415934356}, {-1623796314, -1405336810}, -{-1632959377, -1394679064}, {-1642052490, -1383961574}, -{-1651075262, -1373184801}, {-1660027308, -1362349204}, -{-1668908244, -1351455249}, {-1677717690, -1340503402}, -{-1686455268, -1329494133}, {-1695120603, -1318427912}, -{-1703713325, -1307305214}, {-1712233066, -1296126516}, -{-1720679461, -1284892296}, {-1729052147, -1273603035}, -{-1737350766, -1262259218}, {-1745574963, -1250861329}, -{-1753724386, -1239409858}, {-1761798685, -1227905295}, -{-1769797514, -1216348132}, {-1777720531, -1204738865}, -{-1785567396, -1193077991}, {-1793337774, -1181366009}, -{-1801031331, -1169603422}, {-1808647737, -1157790732}, -{-1816186668, -1145928447}, {-1823647799, -1134017074}, -{-1831030811, -1122057124}, {-1838335387, -1110049108}, -{-1845561216, -1097993542}, {-1852707986, -1085890941}, -{-1859775393, -1073741824}, {-1866763134, -1061546712}, -{-1873670908, -1049306126}, {-1880498421, -1037020592}, -{-1887245379, -1024690635}, {-1893911494, -1012316784}, -{-1900496480, -999899569}, {-1907000055, -987439521}, -{-1913421941, -974937175}, {-1919761862, -962393065}, -{-1926019547, -949807730}, {-1932194727, -937181708}, -{-1938287139, -924515541}, {-1944296521, -911809770}, -{-1950222616, -899064940}, {-1956065170, -886281598}, -{-1961823932, -873460290}, {-1967498656, -860601566}, -{-1973089100, -847705977}, {-1978595022, -834774075}, -{-1984016189, -821806413}, {-1989352366, -808803549}, -{-1994603327, -795766038}, {-1999768845, -782694439}, -{-2004848700, -769589312}, {-2009842674, -756451218}, -{-2014750553, -743280720}, {-2019572126, -730078383}, -{-2024307188, -716844772}, {-2028955535, -703580453}, -{-2033516969, -690285996}, {-2037991293, -676961968}, -{-2042378317, -663608942}, {-2046677852, -650227490}, -{-2050889714, -636818183}, {-2055013723, -623381598}, -{-2059049702, -609918309}, {-2062997478, -596428893}, -{-2066856882, -582913927}, {-2070627749, -569373992}, -{-2074309917, -555809667}, {-2077903229, -542221533}, -{-2081407530, -528610172}, {-2084822670, -514976167}, -{-2088148504, -501320102}, {-2091384888, -487642562}, -{-2094531684, -473944133}, {-2097588758, -460225402}, -{-2100555978, -446486956}, {-2103433217, -432729385}, -{-2106220352, -418953276}, {-2108917263, -405159222}, -{-2111523836, -391347811}, {-2114039958, -377519637}, -{-2116465521, -363675290}, {-2118800422, -349815365}, -{-2121044561, -335940456}, {-2123197841, -322051155}, -{-2125260170, -308148059}, {-2127231461, -294231763}, -{-2129111628, -280302863}, {-2130900591, -266361956}, -{-2132598273, -252409639}, {-2134204601, -238446509}, -{-2135719508, -224473166}, {-2137142927, -210490206}, -{-2138474799, -196498230}, {-2139715065, -182497836}, -{-2140863673, -168489625}, {-2141920573, -154474196}, -{-2142885721, -140452151}, {-2143759074, -126424088}, -{-2144540596, -112390610}, {-2145230253, -98352318}, -{-2145828016, -84309812}, {-2146333858, -70263695}, -{-2146747759, -56214568}, {-2147069700, -42163034}, -{-2147299668, -28109692}, {-2147437652, -14055147}, -{-2147483648, 0}, {-2147437652, 14055147}, -{-2147299668, 28109692}, {-2147069700, 42163034}, -{-2146747759, 56214568}, {-2146333858, 70263695}, -{-2145828016, 84309812}, {-2145230253, 98352318}, -{-2144540596, 112390610}, {-2143759074, 126424088}, -{-2142885721, 140452151}, {-2141920573, 154474196}, -{-2140863673, 168489625}, {-2139715065, 182497836}, -{-2138474799, 196498230}, {-2137142927, 210490206}, -{-2135719508, 224473166}, {-2134204601, 238446509}, -{-2132598273, 252409639}, {-2130900591, 266361956}, -{-2129111628, 280302863}, {-2127231461, 294231763}, -{-2125260170, 308148059}, {-2123197841, 322051155}, -{-2121044561, 335940456}, {-2118800422, 349815365}, -{-2116465521, 363675290}, {-2114039958, 377519637}, -{-2111523836, 391347811}, {-2108917263, 405159222}, -{-2106220352, 418953276}, {-2103433217, 432729385}, -{-2100555978, 446486956}, {-2097588758, 460225402}, -{-2094531684, 473944133}, {-2091384888, 487642562}, -{-2088148504, 501320102}, {-2084822670, 514976167}, -{-2081407530, 528610172}, {-2077903229, 542221533}, -{-2074309917, 555809667}, {-2070627749, 569373992}, -{-2066856882, 582913927}, {-2062997478, 596428893}, -{-2059049702, 609918309}, {-2055013723, 623381598}, -{-2050889714, 636818183}, {-2046677852, 650227490}, -{-2042378317, 663608942}, {-2037991293, 676961968}, -{-2033516969, 690285996}, {-2028955535, 703580453}, -{-2024307188, 716844772}, {-2019572126, 730078383}, -{-2014750553, 743280720}, {-2009842674, 756451218}, -{-2004848700, 769589312}, {-1999768845, 782694439}, -{-1994603327, 795766038}, {-1989352366, 808803549}, -{-1984016189, 821806413}, {-1978595022, 834774075}, -{-1973089100, 847705977}, {-1967498656, 860601566}, -{-1961823932, 873460290}, {-1956065170, 886281598}, -{-1950222616, 899064940}, {-1944296521, 911809770}, -{-1938287139, 924515541}, {-1932194727, 937181708}, -{-1926019547, 949807730}, {-1919761862, 962393065}, -{-1913421941, 974937175}, {-1907000055, 987439521}, -{-1900496480, 999899569}, {-1893911494, 1012316784}, -{-1887245379, 1024690635}, {-1880498421, 1037020592}, -{-1873670908, 1049306126}, {-1866763134, 1061546712}, -{-1859775393, 1073741824}, {-1852707986, 1085890941}, -{-1845561216, 1097993542}, {-1838335387, 1110049108}, -{-1831030811, 1122057124}, {-1823647799, 1134017074}, -{-1816186668, 1145928447}, {-1808647737, 1157790732}, -{-1801031331, 1169603422}, {-1793337774, 1181366009}, -{-1785567396, 1193077991}, {-1777720531, 1204738865}, -{-1769797514, 1216348132}, {-1761798685, 1227905295}, -{-1753724386, 1239409858}, {-1745574963, 1250861329}, -{-1737350766, 1262259218}, {-1729052147, 1273603035}, -{-1720679461, 1284892296}, {-1712233066, 1296126516}, -{-1703713325, 1307305214}, {-1695120603, 1318427912}, -{-1686455268, 1329494133}, {-1677717690, 1340503402}, -{-1668908244, 1351455249}, {-1660027308, 1362349204}, -{-1651075262, 1373184801}, {-1642052490, 1383961574}, -{-1632959377, 1394679064}, {-1623796314, 1405336810}, -{-1614563692, 1415934356}, {-1605261909, 1426471249}, -{-1595891361, 1436947036}, {-1586452450, 1447361268}, -{-1576945581, 1457713501}, {-1567371161, 1468003290}, -{-1557729600, 1478230195}, {-1548021312, 1488393778}, -{-1538246711, 1498493602}, {-1528406216, 1508529236}, -{-1518500250, 1518500250}, {-1508529236, 1528406216}, -{-1498493602, 1538246711}, {-1488393778, 1548021312}, -{-1478230195, 1557729600}, {-1468003290, 1567371161}, -{-1457713501, 1576945581}, {-1447361268, 1586452450}, -{-1436947036, 1595891361}, {-1426471249, 1605261909}, -{-1415934356, 1614563692}, {-1405336810, 1623796314}, -{-1394679064, 1632959377}, {-1383961574, 1642052490}, -{-1373184801, 1651075262}, {-1362349204, 1660027308}, -{-1351455249, 1668908244}, {-1340503402, 1677717690}, -{-1329494133, 1686455268}, {-1318427912, 1695120603}, -{-1307305214, 1703713325}, {-1296126516, 1712233066}, -{-1284892296, 1720679461}, {-1273603035, 1729052147}, -{-1262259218, 1737350766}, {-1250861329, 1745574963}, -{-1239409858, 1753724386}, {-1227905295, 1761798685}, -{-1216348132, 1769797514}, {-1204738865, 1777720531}, -{-1193077991, 1785567396}, {-1181366009, 1793337774}, -{-1169603422, 1801031331}, {-1157790732, 1808647737}, -{-1145928447, 1816186668}, {-1134017074, 1823647799}, -{-1122057124, 1831030811}, {-1110049108, 1838335387}, -{-1097993542, 1845561216}, {-1085890941, 1852707986}, -{-1073741824, 1859775393}, {-1061546712, 1866763134}, -{-1049306126, 1873670908}, {-1037020592, 1880498421}, -{-1024690635, 1887245379}, {-1012316784, 1893911494}, -{-999899569, 1900496480}, {-987439521, 1907000055}, -{-974937175, 1913421941}, {-962393065, 1919761862}, -{-949807730, 1926019547}, {-937181708, 1932194727}, -{-924515541, 1938287139}, {-911809770, 1944296521}, -{-899064940, 1950222616}, {-886281598, 1956065170}, -{-873460290, 1961823932}, {-860601566, 1967498656}, -{-847705977, 1973089100}, {-834774075, 1978595022}, -{-821806413, 1984016189}, {-808803549, 1989352366}, -{-795766038, 1994603327}, {-782694439, 1999768845}, -{-769589312, 2004848700}, {-756451218, 2009842674}, -{-743280720, 2014750553}, {-730078383, 2019572126}, -{-716844772, 2024307188}, {-703580453, 2028955535}, -{-690285996, 2033516969}, {-676961968, 2037991293}, -{-663608942, 2042378317}, {-650227490, 2046677852}, -{-636818183, 2050889714}, {-623381598, 2055013723}, -{-609918309, 2059049702}, {-596428893, 2062997478}, -{-582913927, 2066856882}, {-569373992, 2070627749}, -{-555809667, 2074309917}, {-542221533, 2077903229}, -{-528610172, 2081407530}, {-514976167, 2084822670}, -{-501320102, 2088148504}, {-487642562, 2091384888}, -{-473944133, 2094531684}, {-460225402, 2097588758}, -{-446486956, 2100555978}, {-432729385, 2103433217}, -{-418953276, 2106220352}, {-405159222, 2108917263}, -{-391347811, 2111523836}, {-377519637, 2114039958}, -{-363675290, 2116465521}, {-349815365, 2118800422}, -{-335940456, 2121044561}, {-322051155, 2123197841}, -{-308148059, 2125260170}, {-294231763, 2127231461}, -{-280302863, 2129111628}, {-266361956, 2130900591}, -{-252409639, 2132598273}, {-238446509, 2134204601}, -{-224473166, 2135719508}, {-210490206, 2137142927}, -{-196498230, 2138474799}, {-182497836, 2139715065}, -{-168489625, 2140863673}, {-154474196, 2141920573}, -{-140452151, 2142885721}, {-126424088, 2143759074}, -{-112390610, 2144540596}, {-98352318, 2145230253}, -{-84309812, 2145828016}, {-70263695, 2146333858}, -{-56214568, 2146747759}, {-42163034, 2147069700}, -{-28109692, 2147299668}, {-14055147, 2147437652}, -{0, 2147483647}, {14055147, 2147437652}, -{28109692, 2147299668}, {42163034, 2147069700}, -{56214568, 2146747759}, {70263695, 2146333858}, -{84309812, 2145828016}, {98352318, 2145230253}, -{112390610, 2144540596}, {126424088, 2143759074}, -{140452151, 2142885721}, {154474196, 2141920573}, -{168489625, 2140863673}, {182497836, 2139715065}, -{196498230, 2138474799}, {210490206, 2137142927}, -{224473166, 2135719508}, {238446509, 2134204601}, -{252409639, 2132598273}, {266361956, 2130900591}, -{280302863, 2129111628}, {294231763, 2127231461}, -{308148059, 2125260170}, {322051155, 2123197841}, -{335940456, 2121044561}, {349815365, 2118800422}, -{363675290, 2116465521}, {377519637, 2114039958}, -{391347811, 2111523836}, {405159222, 2108917263}, -{418953276, 2106220352}, {432729385, 2103433217}, -{446486956, 2100555978}, {460225402, 2097588758}, -{473944133, 2094531684}, {487642562, 2091384888}, -{501320102, 2088148504}, {514976167, 2084822670}, -{528610172, 2081407530}, {542221533, 2077903229}, -{555809667, 2074309917}, {569373992, 2070627749}, -{582913927, 2066856882}, {596428893, 2062997478}, -{609918309, 2059049702}, {623381598, 2055013723}, -{636818183, 2050889714}, {650227490, 2046677852}, -{663608942, 2042378317}, {676961968, 2037991293}, -{690285996, 2033516969}, {703580453, 2028955535}, -{716844772, 2024307188}, {730078383, 2019572126}, -{743280720, 2014750553}, {756451218, 2009842674}, -{769589312, 2004848700}, {782694439, 1999768845}, -{795766038, 1994603327}, {808803549, 1989352366}, -{821806413, 1984016189}, {834774075, 1978595022}, -{847705977, 1973089100}, {860601566, 1967498656}, -{873460290, 1961823932}, {886281598, 1956065170}, -{899064940, 1950222616}, {911809770, 1944296521}, -{924515541, 1938287139}, {937181708, 1932194727}, -{949807730, 1926019547}, {962393065, 1919761862}, -{974937175, 1913421941}, {987439521, 1907000055}, -{999899569, 1900496480}, {1012316784, 1893911494}, -{1024690635, 1887245379}, {1037020592, 1880498421}, -{1049306126, 1873670908}, {1061546712, 1866763134}, -{1073741824, 1859775393}, {1085890941, 1852707986}, -{1097993542, 1845561216}, {1110049108, 1838335387}, -{1122057124, 1831030811}, {1134017074, 1823647799}, -{1145928447, 1816186668}, {1157790732, 1808647737}, -{1169603422, 1801031331}, {1181366009, 1793337774}, -{1193077991, 1785567396}, {1204738865, 1777720531}, -{1216348132, 1769797514}, {1227905295, 1761798685}, -{1239409858, 1753724386}, {1250861329, 1745574963}, -{1262259218, 1737350766}, {1273603035, 1729052147}, -{1284892296, 1720679461}, {1296126516, 1712233066}, -{1307305214, 1703713325}, {1318427912, 1695120603}, -{1329494133, 1686455268}, {1340503402, 1677717690}, -{1351455249, 1668908244}, {1362349204, 1660027308}, -{1373184801, 1651075262}, {1383961574, 1642052490}, -{1394679064, 1632959377}, {1405336810, 1623796314}, -{1415934356, 1614563692}, {1426471249, 1605261909}, -{1436947036, 1595891361}, {1447361268, 1586452450}, -{1457713501, 1576945581}, {1468003290, 1567371161}, -{1478230195, 1557729600}, {1488393778, 1548021312}, -{1498493602, 1538246711}, {1508529236, 1528406216}, -{1518500250, 1518500250}, {1528406216, 1508529236}, -{1538246711, 1498493602}, {1548021312, 1488393778}, -{1557729600, 1478230195}, {1567371161, 1468003290}, -{1576945581, 1457713501}, {1586452450, 1447361268}, -{1595891361, 1436947036}, {1605261909, 1426471249}, -{1614563692, 1415934356}, {1623796314, 1405336810}, -{1632959377, 1394679064}, {1642052490, 1383961574}, -{1651075262, 1373184801}, {1660027308, 1362349204}, -{1668908244, 1351455249}, {1677717690, 1340503402}, -{1686455268, 1329494133}, {1695120603, 1318427912}, -{1703713325, 1307305214}, {1712233066, 1296126516}, -{1720679461, 1284892296}, {1729052147, 1273603035}, -{1737350766, 1262259218}, {1745574963, 1250861329}, -{1753724386, 1239409858}, {1761798685, 1227905295}, -{1769797514, 1216348132}, {1777720531, 1204738865}, -{1785567396, 1193077991}, {1793337774, 1181366009}, -{1801031331, 1169603422}, {1808647737, 1157790732}, -{1816186668, 1145928447}, {1823647799, 1134017074}, -{1831030811, 1122057124}, {1838335387, 1110049108}, -{1845561216, 1097993542}, {1852707986, 1085890941}, -{1859775393, 1073741824}, {1866763134, 1061546712}, -{1873670908, 1049306126}, {1880498421, 1037020592}, -{1887245379, 1024690635}, {1893911494, 1012316784}, -{1900496480, 999899569}, {1907000055, 987439521}, -{1913421941, 974937175}, {1919761862, 962393065}, -{1926019547, 949807730}, {1932194727, 937181708}, -{1938287139, 924515541}, {1944296521, 911809770}, -{1950222616, 899064940}, {1956065170, 886281598}, -{1961823932, 873460290}, {1967498656, 860601566}, -{1973089100, 847705977}, {1978595022, 834774075}, -{1984016189, 821806413}, {1989352366, 808803549}, -{1994603327, 795766038}, {1999768845, 782694439}, -{2004848700, 769589312}, {2009842674, 756451218}, -{2014750553, 743280720}, {2019572126, 730078383}, -{2024307188, 716844772}, {2028955535, 703580453}, -{2033516969, 690285996}, {2037991293, 676961968}, -{2042378317, 663608942}, {2046677852, 650227490}, -{2050889714, 636818183}, {2055013723, 623381598}, -{2059049702, 609918309}, {2062997478, 596428893}, -{2066856882, 582913927}, {2070627749, 569373992}, -{2074309917, 555809667}, {2077903229, 542221533}, -{2081407530, 528610172}, {2084822670, 514976167}, -{2088148504, 501320102}, {2091384888, 487642562}, -{2094531684, 473944133}, {2097588758, 460225402}, -{2100555978, 446486956}, {2103433217, 432729385}, -{2106220352, 418953276}, {2108917263, 405159222}, -{2111523836, 391347811}, {2114039958, 377519637}, -{2116465521, 363675290}, {2118800422, 349815365}, -{2121044561, 335940456}, {2123197841, 322051155}, -{2125260170, 308148059}, {2127231461, 294231763}, -{2129111628, 280302863}, {2130900591, 266361956}, -{2132598273, 252409639}, {2134204601, 238446509}, -{2135719508, 224473166}, {2137142927, 210490206}, -{2138474799, 196498230}, {2139715065, 182497836}, -{2140863673, 168489625}, {2141920573, 154474196}, -{2142885721, 140452151}, {2143759074, 126424088}, -{2144540596, 112390610}, {2145230253, 98352318}, -{2145828016, 84309812}, {2146333858, 70263695}, -{2146747759, 56214568}, {2147069700, 42163034}, -{2147299668, 28109692}, {2147437652, 14055147}, -#else -{32767, 0}, {32767, -214}, -{32765, -429}, {32762, -643}, -{32757, -858}, {32750, -1072}, -{32743, -1286}, {32734, -1501}, -{32723, -1715}, {32711, -1929}, -{32698, -2143}, {32683, -2357}, -{32667, -2571}, {32649, -2785}, -{32631, -2998}, {32610, -3212}, -{32588, -3425}, {32565, -3638}, -{32541, -3851}, {32515, -4064}, -{32488, -4277}, {32459, -4490}, -{32429, -4702}, {32397, -4914}, -{32365, -5126}, {32330, -5338}, -{32295, -5549}, {32258, -5760}, -{32219, -5971}, {32180, -6182}, -{32138, -6393}, {32096, -6603}, -{32052, -6813}, {32007, -7022}, -{31960, -7232}, {31912, -7441}, -{31863, -7650}, {31812, -7858}, -{31760, -8066}, {31706, -8274}, -{31651, -8481}, {31595, -8688}, -{31538, -8895}, {31479, -9101}, -{31419, -9307}, {31357, -9512}, -{31294, -9717}, {31230, -9922}, -{31164, -10126}, {31097, -10330}, -{31029, -10533}, {30959, -10736}, -{30888, -10938}, {30816, -11140}, -{30743, -11342}, {30668, -11543}, -{30592, -11743}, {30514, -11943}, -{30435, -12142}, {30355, -12341}, -{30274, -12540}, {30191, -12738}, -{30107, -12935}, {30022, -13132}, -{29935, -13328}, {29847, -13524}, -{29758, -13719}, {29668, -13913}, -{29576, -14107}, {29483, -14300}, -{29389, -14493}, {29293, -14685}, -{29197, -14876}, {29099, -15067}, -{28999, -15257}, {28899, -15447}, -{28797, -15636}, {28694, -15824}, -{28590, -16011}, {28485, -16198}, -{28378, -16384}, {28270, -16569}, -{28161, -16754}, {28051, -16938}, -{27939, -17121}, {27827, -17304}, -{27713, -17485}, {27598, -17666}, -{27482, -17847}, {27364, -18026}, -{27246, -18205}, {27126, -18383}, -{27005, -18560}, {26883, -18736}, -{26760, -18912}, {26635, -19087}, -{26510, -19261}, {26383, -19434}, -{26255, -19606}, {26127, -19777}, -{25997, -19948}, {25865, -20118}, -{25733, -20286}, {25600, -20454}, -{25466, -20622}, {25330, -20788}, -{25193, -20953}, {25056, -21118}, -{24917, -21281}, {24777, -21444}, -{24636, -21605}, {24494, -21766}, -{24351, -21926}, {24207, -22085}, -{24062, -22243}, {23916, -22400}, -{23769, -22556}, {23621, -22711}, -{23472, -22865}, {23322, -23018}, -{23170, -23170}, {23018, -23322}, -{22865, -23472}, {22711, -23621}, -{22556, -23769}, {22400, -23916}, -{22243, -24062}, {22085, -24207}, -{21926, -24351}, {21766, -24494}, -{21605, -24636}, {21444, -24777}, -{21281, -24917}, {21118, -25056}, -{20953, -25193}, {20788, -25330}, -{20622, -25466}, {20454, -25600}, -{20286, -25733}, {20118, -25865}, -{19948, -25997}, {19777, -26127}, -{19606, -26255}, {19434, -26383}, -{19261, -26510}, {19087, -26635}, -{18912, -26760}, {18736, -26883}, -{18560, -27005}, {18383, -27126}, -{18205, -27246}, {18026, -27364}, -{17847, -27482}, {17666, -27598}, -{17485, -27713}, {17304, -27827}, -{17121, -27939}, {16938, -28051}, -{16754, -28161}, {16569, -28270}, -{16384, -28378}, {16198, -28485}, -{16011, -28590}, {15824, -28694}, -{15636, -28797}, {15447, -28899}, -{15257, -28999}, {15067, -29099}, -{14876, -29197}, {14685, -29293}, -{14493, -29389}, {14300, -29483}, -{14107, -29576}, {13913, -29668}, -{13719, -29758}, {13524, -29847}, -{13328, -29935}, {13132, -30022}, -{12935, -30107}, {12738, -30191}, -{12540, -30274}, {12341, -30355}, -{12142, -30435}, {11943, -30514}, -{11743, -30592}, {11543, -30668}, -{11342, -30743}, {11140, -30816}, -{10938, -30888}, {10736, -30959}, -{10533, -31029}, {10330, -31097}, -{10126, -31164}, {9922, -31230}, -{9717, -31294}, {9512, -31357}, -{9307, -31419}, {9101, -31479}, -{8895, -31538}, {8688, -31595}, -{8481, -31651}, {8274, -31706}, -{8066, -31760}, {7858, -31812}, -{7650, -31863}, {7441, -31912}, -{7232, -31960}, {7022, -32007}, -{6813, -32052}, {6603, -32096}, -{6393, -32138}, {6182, -32180}, -{5971, -32219}, {5760, -32258}, -{5549, -32295}, {5338, -32330}, -{5126, -32365}, {4914, -32397}, -{4702, -32429}, {4490, -32459}, -{4277, -32488}, {4064, -32515}, -{3851, -32541}, {3638, -32565}, -{3425, -32588}, {3212, -32610}, -{2998, -32631}, {2785, -32649}, -{2571, -32667}, {2357, -32683}, -{2143, -32698}, {1929, -32711}, -{1715, -32723}, {1501, -32734}, -{1286, -32743}, {1072, -32750}, -{858, -32757}, {643, -32762}, -{429, -32765}, {214, -32767}, -{0, -32767}, {-214, -32767}, -{-429, -32765}, {-643, -32762}, -{-858, -32757}, {-1072, -32750}, -{-1286, -32743}, {-1501, -32734}, -{-1715, -32723}, {-1929, -32711}, -{-2143, -32698}, {-2357, -32683}, -{-2571, -32667}, {-2785, -32649}, -{-2998, -32631}, {-3212, -32610}, -{-3425, -32588}, {-3638, -32565}, -{-3851, -32541}, {-4064, -32515}, -{-4277, -32488}, {-4490, -32459}, -{-4702, -32429}, {-4914, -32397}, -{-5126, -32365}, {-5338, -32330}, -{-5549, -32295}, {-5760, -32258}, -{-5971, -32219}, {-6182, -32180}, -{-6393, -32138}, {-6603, -32096}, -{-6813, -32052}, {-7022, -32007}, -{-7232, -31960}, {-7441, -31912}, -{-7650, -31863}, {-7858, -31812}, -{-8066, -31760}, {-8274, -31706}, -{-8481, -31651}, {-8688, -31595}, -{-8895, -31538}, {-9101, -31479}, -{-9307, -31419}, {-9512, -31357}, -{-9717, -31294}, {-9922, -31230}, -{-10126, -31164}, {-10330, -31097}, -{-10533, -31029}, {-10736, -30959}, -{-10938, -30888}, {-11140, -30816}, -{-11342, -30743}, {-11543, -30668}, -{-11743, -30592}, {-11943, -30514}, -{-12142, -30435}, {-12341, -30355}, -{-12540, -30274}, {-12738, -30191}, -{-12935, -30107}, {-13132, -30022}, -{-13328, -29935}, {-13524, -29847}, -{-13719, -29758}, {-13913, -29668}, -{-14107, -29576}, {-14300, -29483}, -{-14493, -29389}, {-14685, -29293}, -{-14876, -29197}, {-15067, -29099}, -{-15257, -28999}, {-15447, -28899}, -{-15636, -28797}, {-15824, -28694}, -{-16011, -28590}, {-16198, -28485}, -{-16384, -28378}, {-16569, -28270}, -{-16754, -28161}, {-16938, -28051}, -{-17121, -27939}, {-17304, -27827}, -{-17485, -27713}, {-17666, -27598}, -{-17847, -27482}, {-18026, -27364}, -{-18205, -27246}, {-18383, -27126}, -{-18560, -27005}, {-18736, -26883}, -{-18912, -26760}, {-19087, -26635}, -{-19261, -26510}, {-19434, -26383}, -{-19606, -26255}, {-19777, -26127}, -{-19948, -25997}, {-20118, -25865}, -{-20286, -25733}, {-20454, -25600}, -{-20622, -25466}, {-20788, -25330}, -{-20953, -25193}, {-21118, -25056}, -{-21281, -24917}, {-21444, -24777}, -{-21605, -24636}, {-21766, -24494}, -{-21926, -24351}, {-22085, -24207}, -{-22243, -24062}, {-22400, -23916}, -{-22556, -23769}, {-22711, -23621}, -{-22865, -23472}, {-23018, -23322}, -{-23170, -23170}, {-23322, -23018}, -{-23472, -22865}, {-23621, -22711}, -{-23769, -22556}, {-23916, -22400}, -{-24062, -22243}, {-24207, -22085}, -{-24351, -21926}, {-24494, -21766}, -{-24636, -21605}, {-24777, -21444}, -{-24917, -21281}, {-25056, -21118}, -{-25193, -20953}, {-25330, -20788}, -{-25466, -20622}, {-25600, -20454}, -{-25733, -20286}, {-25865, -20118}, -{-25997, -19948}, {-26127, -19777}, -{-26255, -19606}, {-26383, -19434}, -{-26510, -19261}, {-26635, -19087}, -{-26760, -18912}, {-26883, -18736}, -{-27005, -18560}, {-27126, -18383}, -{-27246, -18205}, {-27364, -18026}, -{-27482, -17847}, {-27598, -17666}, -{-27713, -17485}, {-27827, -17304}, -{-27939, -17121}, {-28051, -16938}, -{-28161, -16754}, {-28270, -16569}, -{-28378, -16384}, {-28485, -16198}, -{-28590, -16011}, {-28694, -15824}, -{-28797, -15636}, {-28899, -15447}, -{-28999, -15257}, {-29099, -15067}, -{-29197, -14876}, {-29293, -14685}, -{-29389, -14493}, {-29483, -14300}, -{-29576, -14107}, {-29668, -13913}, -{-29758, -13719}, {-29847, -13524}, -{-29935, -13328}, {-30022, -13132}, -{-30107, -12935}, {-30191, -12738}, -{-30274, -12540}, {-30355, -12341}, -{-30435, -12142}, {-30514, -11943}, -{-30592, -11743}, {-30668, -11543}, -{-30743, -11342}, {-30816, -11140}, -{-30888, -10938}, {-30959, -10736}, -{-31029, -10533}, {-31097, -10330}, -{-31164, -10126}, {-31230, -9922}, -{-31294, -9717}, {-31357, -9512}, -{-31419, -9307}, {-31479, -9101}, -{-31538, -8895}, {-31595, -8688}, -{-31651, -8481}, {-31706, -8274}, -{-31760, -8066}, {-31812, -7858}, -{-31863, -7650}, {-31912, -7441}, -{-31960, -7232}, {-32007, -7022}, -{-32052, -6813}, {-32096, -6603}, -{-32138, -6393}, {-32180, -6182}, -{-32219, -5971}, {-32258, -5760}, -{-32295, -5549}, {-32330, -5338}, -{-32365, -5126}, {-32397, -4914}, -{-32429, -4702}, {-32459, -4490}, -{-32488, -4277}, {-32515, -4064}, -{-32541, -3851}, {-32565, -3638}, -{-32588, -3425}, {-32610, -3212}, -{-32631, -2998}, {-32649, -2785}, -{-32667, -2571}, {-32683, -2357}, -{-32698, -2143}, {-32711, -1929}, -{-32723, -1715}, {-32734, -1501}, -{-32743, -1286}, {-32750, -1072}, -{-32757, -858}, {-32762, -643}, -{-32765, -429}, {-32767, -214}, -{-32767, 0}, {-32767, 214}, -{-32765, 429}, {-32762, 643}, -{-32757, 858}, {-32750, 1072}, -{-32743, 1286}, {-32734, 1501}, -{-32723, 1715}, {-32711, 1929}, -{-32698, 2143}, {-32683, 2357}, -{-32667, 2571}, {-32649, 2785}, -{-32631, 2998}, {-32610, 3212}, -{-32588, 3425}, {-32565, 3638}, -{-32541, 3851}, {-32515, 4064}, -{-32488, 4277}, {-32459, 4490}, -{-32429, 4702}, {-32397, 4914}, -{-32365, 5126}, {-32330, 5338}, -{-32295, 5549}, {-32258, 5760}, -{-32219, 5971}, {-32180, 6182}, -{-32138, 6393}, {-32096, 6603}, -{-32052, 6813}, {-32007, 7022}, -{-31960, 7232}, {-31912, 7441}, -{-31863, 7650}, {-31812, 7858}, -{-31760, 8066}, {-31706, 8274}, -{-31651, 8481}, {-31595, 8688}, -{-31538, 8895}, {-31479, 9101}, -{-31419, 9307}, {-31357, 9512}, -{-31294, 9717}, {-31230, 9922}, -{-31164, 10126}, {-31097, 10330}, -{-31029, 10533}, {-30959, 10736}, -{-30888, 10938}, {-30816, 11140}, -{-30743, 11342}, {-30668, 11543}, -{-30592, 11743}, {-30514, 11943}, -{-30435, 12142}, {-30355, 12341}, -{-30274, 12540}, {-30191, 12738}, -{-30107, 12935}, {-30022, 13132}, -{-29935, 13328}, {-29847, 13524}, -{-29758, 13719}, {-29668, 13913}, -{-29576, 14107}, {-29483, 14300}, -{-29389, 14493}, {-29293, 14685}, -{-29197, 14876}, {-29099, 15067}, -{-28999, 15257}, {-28899, 15447}, -{-28797, 15636}, {-28694, 15824}, -{-28590, 16011}, {-28485, 16198}, -{-28378, 16384}, {-28270, 16569}, -{-28161, 16754}, {-28051, 16938}, -{-27939, 17121}, {-27827, 17304}, -{-27713, 17485}, {-27598, 17666}, -{-27482, 17847}, {-27364, 18026}, -{-27246, 18205}, {-27126, 18383}, -{-27005, 18560}, {-26883, 18736}, -{-26760, 18912}, {-26635, 19087}, -{-26510, 19261}, {-26383, 19434}, -{-26255, 19606}, {-26127, 19777}, -{-25997, 19948}, {-25865, 20118}, -{-25733, 20286}, {-25600, 20454}, -{-25466, 20622}, {-25330, 20788}, -{-25193, 20953}, {-25056, 21118}, -{-24917, 21281}, {-24777, 21444}, -{-24636, 21605}, {-24494, 21766}, -{-24351, 21926}, {-24207, 22085}, -{-24062, 22243}, {-23916, 22400}, -{-23769, 22556}, {-23621, 22711}, -{-23472, 22865}, {-23322, 23018}, -{-23170, 23170}, {-23018, 23322}, -{-22865, 23472}, {-22711, 23621}, -{-22556, 23769}, {-22400, 23916}, -{-22243, 24062}, {-22085, 24207}, -{-21926, 24351}, {-21766, 24494}, -{-21605, 24636}, {-21444, 24777}, -{-21281, 24917}, {-21118, 25056}, -{-20953, 25193}, {-20788, 25330}, -{-20622, 25466}, {-20454, 25600}, -{-20286, 25733}, {-20118, 25865}, -{-19948, 25997}, {-19777, 26127}, -{-19606, 26255}, {-19434, 26383}, -{-19261, 26510}, {-19087, 26635}, -{-18912, 26760}, {-18736, 26883}, -{-18560, 27005}, {-18383, 27126}, -{-18205, 27246}, {-18026, 27364}, -{-17847, 27482}, {-17666, 27598}, -{-17485, 27713}, {-17304, 27827}, -{-17121, 27939}, {-16938, 28051}, -{-16754, 28161}, {-16569, 28270}, -{-16384, 28378}, {-16198, 28485}, -{-16011, 28590}, {-15824, 28694}, -{-15636, 28797}, {-15447, 28899}, -{-15257, 28999}, {-15067, 29099}, -{-14876, 29197}, {-14685, 29293}, -{-14493, 29389}, {-14300, 29483}, -{-14107, 29576}, {-13913, 29668}, -{-13719, 29758}, {-13524, 29847}, -{-13328, 29935}, {-13132, 30022}, -{-12935, 30107}, {-12738, 30191}, -{-12540, 30274}, {-12341, 30355}, -{-12142, 30435}, {-11943, 30514}, -{-11743, 30592}, {-11543, 30668}, -{-11342, 30743}, {-11140, 30816}, -{-10938, 30888}, {-10736, 30959}, -{-10533, 31029}, {-10330, 31097}, -{-10126, 31164}, {-9922, 31230}, -{-9717, 31294}, {-9512, 31357}, -{-9307, 31419}, {-9101, 31479}, -{-8895, 31538}, {-8688, 31595}, -{-8481, 31651}, {-8274, 31706}, -{-8066, 31760}, {-7858, 31812}, -{-7650, 31863}, {-7441, 31912}, -{-7232, 31960}, {-7022, 32007}, -{-6813, 32052}, {-6603, 32096}, -{-6393, 32138}, {-6182, 32180}, -{-5971, 32219}, {-5760, 32258}, -{-5549, 32295}, {-5338, 32330}, -{-5126, 32365}, {-4914, 32397}, -{-4702, 32429}, {-4490, 32459}, -{-4277, 32488}, {-4064, 32515}, -{-3851, 32541}, {-3638, 32565}, -{-3425, 32588}, {-3212, 32610}, -{-2998, 32631}, {-2785, 32649}, -{-2571, 32667}, {-2357, 32683}, -{-2143, 32698}, {-1929, 32711}, -{-1715, 32723}, {-1501, 32734}, -{-1286, 32743}, {-1072, 32750}, -{-858, 32757}, {-643, 32762}, -{-429, 32765}, {-214, 32767}, -{0, 32767}, {214, 32767}, -{429, 32765}, {643, 32762}, -{858, 32757}, {1072, 32750}, -{1286, 32743}, {1501, 32734}, -{1715, 32723}, {1929, 32711}, -{2143, 32698}, {2357, 32683}, -{2571, 32667}, {2785, 32649}, -{2998, 32631}, {3212, 32610}, -{3425, 32588}, {3638, 32565}, -{3851, 32541}, {4064, 32515}, -{4277, 32488}, {4490, 32459}, -{4702, 32429}, {4914, 32397}, -{5126, 32365}, {5338, 32330}, -{5549, 32295}, {5760, 32258}, -{5971, 32219}, {6182, 32180}, -{6393, 32138}, {6603, 32096}, -{6813, 32052}, {7022, 32007}, -{7232, 31960}, {7441, 31912}, -{7650, 31863}, {7858, 31812}, -{8066, 31760}, {8274, 31706}, -{8481, 31651}, {8688, 31595}, -{8895, 31538}, {9101, 31479}, -{9307, 31419}, {9512, 31357}, -{9717, 31294}, {9922, 31230}, -{10126, 31164}, {10330, 31097}, -{10533, 31029}, {10736, 30959}, -{10938, 30888}, {11140, 30816}, -{11342, 30743}, {11543, 30668}, -{11743, 30592}, {11943, 30514}, -{12142, 30435}, {12341, 30355}, -{12540, 30274}, {12738, 30191}, -{12935, 30107}, {13132, 30022}, -{13328, 29935}, {13524, 29847}, -{13719, 29758}, {13913, 29668}, -{14107, 29576}, {14300, 29483}, -{14493, 29389}, {14685, 29293}, -{14876, 29197}, {15067, 29099}, -{15257, 28999}, {15447, 28899}, -{15636, 28797}, {15824, 28694}, -{16011, 28590}, {16198, 28485}, -{16384, 28378}, {16569, 28270}, -{16754, 28161}, {16938, 28051}, -{17121, 27939}, {17304, 27827}, -{17485, 27713}, {17666, 27598}, -{17847, 27482}, {18026, 27364}, -{18205, 27246}, {18383, 27126}, -{18560, 27005}, {18736, 26883}, -{18912, 26760}, {19087, 26635}, -{19261, 26510}, {19434, 26383}, -{19606, 26255}, {19777, 26127}, -{19948, 25997}, {20118, 25865}, -{20286, 25733}, {20454, 25600}, -{20622, 25466}, {20788, 25330}, -{20953, 25193}, {21118, 25056}, -{21281, 24917}, {21444, 24777}, -{21605, 24636}, {21766, 24494}, -{21926, 24351}, {22085, 24207}, -{22243, 24062}, {22400, 23916}, -{22556, 23769}, {22711, 23621}, -{22865, 23472}, {23018, 23322}, -{23170, 23170}, {23322, 23018}, -{23472, 22865}, {23621, 22711}, -{23769, 22556}, {23916, 22400}, -{24062, 22243}, {24207, 22085}, -{24351, 21926}, {24494, 21766}, -{24636, 21605}, {24777, 21444}, -{24917, 21281}, {25056, 21118}, -{25193, 20953}, {25330, 20788}, -{25466, 20622}, {25600, 20454}, -{25733, 20286}, {25865, 20118}, -{25997, 19948}, {26127, 19777}, -{26255, 19606}, {26383, 19434}, -{26510, 19261}, {26635, 19087}, -{26760, 18912}, {26883, 18736}, -{27005, 18560}, {27126, 18383}, -{27246, 18205}, {27364, 18026}, -{27482, 17847}, {27598, 17666}, -{27713, 17485}, {27827, 17304}, -{27939, 17121}, {28051, 16938}, -{28161, 16754}, {28270, 16569}, -{28378, 16384}, {28485, 16198}, -{28590, 16011}, {28694, 15824}, -{28797, 15636}, {28899, 15447}, -{28999, 15257}, {29099, 15067}, -{29197, 14876}, {29293, 14685}, -{29389, 14493}, {29483, 14300}, -{29576, 14107}, {29668, 13913}, -{29758, 13719}, {29847, 13524}, -{29935, 13328}, {30022, 13132}, -{30107, 12935}, {30191, 12738}, -{30274, 12540}, {30355, 12341}, -{30435, 12142}, {30514, 11943}, -{30592, 11743}, {30668, 11543}, -{30743, 11342}, {30816, 11140}, -{30888, 10938}, {30959, 10736}, -{31029, 10533}, {31097, 10330}, -{31164, 10126}, {31230, 9922}, -{31294, 9717}, {31357, 9512}, -{31419, 9307}, {31479, 9101}, -{31538, 8895}, {31595, 8688}, -{31651, 8481}, {31706, 8274}, -{31760, 8066}, {31812, 7858}, -{31863, 7650}, {31912, 7441}, -{31960, 7232}, {32007, 7022}, -{32052, 6813}, {32096, 6603}, -{32138, 6393}, {32180, 6182}, -{32219, 5971}, {32258, 5760}, -{32295, 5549}, {32330, 5338}, -{32365, 5126}, {32397, 4914}, -{32429, 4702}, {32459, 4490}, -{32488, 4277}, {32515, 4064}, -{32541, 3851}, {32565, 3638}, -{32588, 3425}, {32610, 3212}, -{32631, 2998}, {32649, 2785}, -{32667, 2571}, {32683, 2357}, -{32698, 2143}, {32711, 1929}, -{32723, 1715}, {32734, 1501}, -{32743, 1286}, {32750, 1072}, -{32757, 858}, {32762, 643}, -{32765, 429}, {32767, 214}, -#endif + {2147483647, 0}, {2147437652, -14055147}, + {2147299668, -28109692}, {2147069700, -42163034}, + {2146747759, -56214568}, {2146333858, -70263695}, + {2145828016, -84309812}, {2145230253, -98352318}, + {2144540596, -112390610}, {2143759074, -126424088}, + {2142885721, -140452151}, {2141920573, -154474196}, + {2140863673, -168489625}, {2139715065, -182497836}, + {2138474799, -196498230}, {2137142927, -210490206}, + {2135719508, -224473166}, {2134204601, -238446509}, + {2132598273, -252409639}, {2130900591, -266361956}, + {2129111628, -280302863}, {2127231461, -294231763}, + {2125260170, -308148059}, {2123197841, -322051155}, + {2121044561, -335940456}, {2118800422, -349815365}, + {2116465521, -363675290}, {2114039958, -377519637}, + {2111523836, -391347811}, {2108917263, -405159222}, + {2106220352, -418953276}, {2103433217, -432729385}, + {2100555978, -446486956}, {2097588758, -460225402}, + {2094531684, -473944133}, {2091384888, -487642562}, + {2088148504, -501320102}, {2084822670, -514976167}, + {2081407530, -528610172}, {2077903229, -542221533}, + {2074309917, -555809667}, {2070627749, -569373992}, + {2066856882, -582913927}, {2062997478, -596428893}, + {2059049702, -609918309}, {2055013723, -623381598}, + {2050889714, -636818183}, {2046677852, -650227490}, + {2042378317, -663608942}, {2037991293, -676961968}, + {2033516969, -690285996}, {2028955535, -703580453}, + {2024307188, -716844772}, {2019572126, -730078383}, + {2014750553, -743280720}, {2009842674, -756451218}, + {2004848700, -769589312}, {1999768845, -782694439}, + {1994603327, -795766038}, {1989352366, -808803549}, + {1984016189, -821806413}, {1978595022, -834774075}, + {1973089100, -847705977}, {1967498656, -860601566}, + {1961823932, -873460290}, {1956065170, -886281598}, + {1950222616, -899064940}, {1944296521, -911809770}, + {1938287139, -924515541}, {1932194727, -937181708}, + {1926019547, -949807730}, {1919761862, -962393065}, + {1913421941, -974937175}, {1907000055, -987439521}, + {1900496480, -999899569}, {1893911494, -1012316784}, + {1887245379, -1024690635}, {1880498421, -1037020592}, + {1873670908, -1049306126}, {1866763134, -1061546712}, + {1859775393, -1073741824}, {1852707986, -1085890941}, + {1845561216, -1097993542}, {1838335387, -1110049108}, + {1831030811, -1122057124}, {1823647799, -1134017074}, + {1816186668, -1145928447}, {1808647737, -1157790732}, + {1801031331, -1169603422}, {1793337774, -1181366009}, + {1785567396, -1193077991}, {1777720531, -1204738865}, + {1769797514, -1216348132}, {1761798685, -1227905295}, + {1753724386, -1239409858}, {1745574963, -1250861329}, + {1737350766, -1262259218}, {1729052147, -1273603035}, + {1720679461, -1284892296}, {1712233066, -1296126516}, + {1703713325, -1307305214}, {1695120603, -1318427912}, + {1686455268, -1329494133}, {1677717690, -1340503402}, + {1668908244, -1351455249}, {1660027308, -1362349204}, + {1651075262, -1373184801}, {1642052490, -1383961574}, + {1632959377, -1394679064}, {1623796314, -1405336810}, + {1614563692, -1415934356}, {1605261909, -1426471249}, + {1595891361, -1436947036}, {1586452450, -1447361268}, + {1576945581, -1457713501}, {1567371161, -1468003290}, + {1557729600, -1478230195}, {1548021312, -1488393778}, + {1538246711, -1498493602}, {1528406216, -1508529236}, + {1518500250, -1518500250}, {1508529236, -1528406216}, + {1498493602, -1538246711}, {1488393778, -1548021312}, + {1478230195, -1557729600}, {1468003290, -1567371161}, + {1457713501, -1576945581}, {1447361268, -1586452450}, + {1436947036, -1595891361}, {1426471249, -1605261909}, + {1415934356, -1614563692}, {1405336810, -1623796314}, + {1394679064, -1632959377}, {1383961574, -1642052490}, + {1373184801, -1651075262}, {1362349204, -1660027308}, + {1351455249, -1668908244}, {1340503402, -1677717690}, + {1329494133, -1686455268}, {1318427912, -1695120603}, + {1307305214, -1703713325}, {1296126516, -1712233066}, + {1284892296, -1720679461}, {1273603035, -1729052147}, + {1262259218, -1737350766}, {1250861329, -1745574963}, + {1239409858, -1753724386}, {1227905295, -1761798685}, + {1216348132, -1769797514}, {1204738865, -1777720531}, + {1193077991, -1785567396}, {1181366009, -1793337774}, + {1169603422, -1801031331}, {1157790732, -1808647737}, + {1145928447, -1816186668}, {1134017074, -1823647799}, + {1122057124, -1831030811}, {1110049108, -1838335387}, + {1097993542, -1845561216}, {1085890941, -1852707986}, + {1073741824, -1859775393}, {1061546712, -1866763134}, + {1049306126, -1873670908}, {1037020592, -1880498421}, + {1024690635, -1887245379}, {1012316784, -1893911494}, + {999899569, -1900496480}, {987439521, -1907000055}, + {974937175, -1913421941}, {962393065, -1919761862}, + {949807730, -1926019547}, {937181708, -1932194727}, + {924515541, -1938287139}, {911809770, -1944296521}, + {899064940, -1950222616}, {886281598, -1956065170}, + {873460290, -1961823932}, {860601566, -1967498656}, + {847705977, -1973089100}, {834774075, -1978595022}, + {821806413, -1984016189}, {808803549, -1989352366}, + {795766038, -1994603327}, {782694439, -1999768845}, + {769589312, -2004848700}, {756451218, -2009842674}, + {743280720, -2014750553}, {730078383, -2019572126}, + {716844772, -2024307188}, {703580453, -2028955535}, + {690285996, -2033516969}, {676961968, -2037991293}, + {663608942, -2042378317}, {650227490, -2046677852}, + {636818183, -2050889714}, {623381598, -2055013723}, + {609918309, -2059049702}, {596428893, -2062997478}, + {582913927, -2066856882}, {569373992, -2070627749}, + {555809667, -2074309917}, {542221533, -2077903229}, + {528610172, -2081407530}, {514976167, -2084822670}, + {501320102, -2088148504}, {487642562, -2091384888}, + {473944133, -2094531684}, {460225402, -2097588758}, + {446486956, -2100555978}, {432729385, -2103433217}, + {418953276, -2106220352}, {405159222, -2108917263}, + {391347811, -2111523836}, {377519637, -2114039958}, + {363675290, -2116465521}, {349815365, -2118800422}, + {335940456, -2121044561}, {322051155, -2123197841}, + {308148059, -2125260170}, {294231763, -2127231461}, + {280302863, -2129111628}, {266361956, -2130900591}, + {252409639, -2132598273}, {238446509, -2134204601}, + {224473166, -2135719508}, {210490206, -2137142927}, + {196498230, -2138474799}, {182497836, -2139715065}, + {168489625, -2140863673}, {154474196, -2141920573}, + {140452151, -2142885721}, {126424088, -2143759074}, + {112390610, -2144540596}, {98352318, -2145230253}, + {84309812, -2145828016}, {70263695, -2146333858}, + {56214568, -2146747759}, {42163034, -2147069700}, + {28109692, -2147299668}, {14055147, -2147437652}, + {0, -2147483648}, {-14055147, -2147437652}, + {-28109692, -2147299668}, {-42163034, -2147069700}, + {-56214568, -2146747759}, {-70263695, -2146333858}, + {-84309812, -2145828016}, {-98352318, -2145230253}, + {-112390610, -2144540596}, {-126424088, -2143759074}, + {-140452151, -2142885721}, {-154474196, -2141920573}, + {-168489625, -2140863673}, {-182497836, -2139715065}, + {-196498230, -2138474799}, {-210490206, -2137142927}, + {-224473166, -2135719508}, {-238446509, -2134204601}, + {-252409639, -2132598273}, {-266361956, -2130900591}, + {-280302863, -2129111628}, {-294231763, -2127231461}, + {-308148059, -2125260170}, {-322051155, -2123197841}, + {-335940456, -2121044561}, {-349815365, -2118800422}, + {-363675290, -2116465521}, {-377519637, -2114039958}, + {-391347811, -2111523836}, {-405159222, -2108917263}, + {-418953276, -2106220352}, {-432729385, -2103433217}, + {-446486956, -2100555978}, {-460225402, -2097588758}, + {-473944133, -2094531684}, {-487642562, -2091384888}, + {-501320102, -2088148504}, {-514976167, -2084822670}, + {-528610172, -2081407530}, {-542221533, -2077903229}, + {-555809667, -2074309917}, {-569373992, -2070627749}, + {-582913927, -2066856882}, {-596428893, -2062997478}, + {-609918309, -2059049702}, {-623381598, -2055013723}, + {-636818183, -2050889714}, {-650227490, -2046677852}, + {-663608942, -2042378317}, {-676961968, -2037991293}, + {-690285996, -2033516969}, {-703580453, -2028955535}, + {-716844772, -2024307188}, {-730078383, -2019572126}, + {-743280720, -2014750553}, {-756451218, -2009842674}, + {-769589312, -2004848700}, {-782694439, -1999768845}, + {-795766038, -1994603327}, {-808803549, -1989352366}, + {-821806413, -1984016189}, {-834774075, -1978595022}, + {-847705977, -1973089100}, {-860601566, -1967498656}, + {-873460290, -1961823932}, {-886281598, -1956065170}, + {-899064940, -1950222616}, {-911809770, -1944296521}, + {-924515541, -1938287139}, {-937181708, -1932194727}, + {-949807730, -1926019547}, {-962393065, -1919761862}, + {-974937175, -1913421941}, {-987439521, -1907000055}, + {-999899569, -1900496480}, {-1012316784, -1893911494}, + {-1024690635, -1887245379}, {-1037020592, -1880498421}, + {-1049306126, -1873670908}, {-1061546712, -1866763134}, + {-1073741824, -1859775393}, {-1085890941, -1852707986}, + {-1097993542, -1845561216}, {-1110049108, -1838335387}, + {-1122057124, -1831030811}, {-1134017074, -1823647799}, + {-1145928447, -1816186668}, {-1157790732, -1808647737}, + {-1169603422, -1801031331}, {-1181366009, -1793337774}, + {-1193077991, -1785567396}, {-1204738865, -1777720531}, + {-1216348132, -1769797514}, {-1227905295, -1761798685}, + {-1239409858, -1753724386}, {-1250861329, -1745574963}, + {-1262259218, -1737350766}, {-1273603035, -1729052147}, + {-1284892296, -1720679461}, {-1296126516, -1712233066}, + {-1307305214, -1703713325}, {-1318427912, -1695120603}, + {-1329494133, -1686455268}, {-1340503402, -1677717690}, + {-1351455249, -1668908244}, {-1362349204, -1660027308}, + {-1373184801, -1651075262}, {-1383961574, -1642052490}, + {-1394679064, -1632959377}, {-1405336810, -1623796314}, + {-1415934356, -1614563692}, {-1426471249, -1605261909}, + {-1436947036, -1595891361}, {-1447361268, -1586452450}, + {-1457713501, -1576945581}, {-1468003290, -1567371161}, + {-1478230195, -1557729600}, {-1488393778, -1548021312}, + {-1498493602, -1538246711}, {-1508529236, -1528406216}, + {-1518500250, -1518500250}, {-1528406216, -1508529236}, + {-1538246711, -1498493602}, {-1548021312, -1488393778}, + {-1557729600, -1478230195}, {-1567371161, -1468003290}, + {-1576945581, -1457713501}, {-1586452450, -1447361268}, + {-1595891361, -1436947036}, {-1605261909, -1426471249}, + {-1614563692, -1415934356}, {-1623796314, -1405336810}, + {-1632959377, -1394679064}, {-1642052490, -1383961574}, + {-1651075262, -1373184801}, {-1660027308, -1362349204}, + {-1668908244, -1351455249}, {-1677717690, -1340503402}, + {-1686455268, -1329494133}, {-1695120603, -1318427912}, + {-1703713325, -1307305214}, {-1712233066, -1296126516}, + {-1720679461, -1284892296}, {-1729052147, -1273603035}, + {-1737350766, -1262259218}, {-1745574963, -1250861329}, + {-1753724386, -1239409858}, {-1761798685, -1227905295}, + {-1769797514, -1216348132}, {-1777720531, -1204738865}, + {-1785567396, -1193077991}, {-1793337774, -1181366009}, + {-1801031331, -1169603422}, {-1808647737, -1157790732}, + {-1816186668, -1145928447}, {-1823647799, -1134017074}, + {-1831030811, -1122057124}, {-1838335387, -1110049108}, + {-1845561216, -1097993542}, {-1852707986, -1085890941}, + {-1859775393, -1073741824}, {-1866763134, -1061546712}, + {-1873670908, -1049306126}, {-1880498421, -1037020592}, + {-1887245379, -1024690635}, {-1893911494, -1012316784}, + {-1900496480, -999899569}, {-1907000055, -987439521}, + {-1913421941, -974937175}, {-1919761862, -962393065}, + {-1926019547, -949807730}, {-1932194727, -937181708}, + {-1938287139, -924515541}, {-1944296521, -911809770}, + {-1950222616, -899064940}, {-1956065170, -886281598}, + {-1961823932, -873460290}, {-1967498656, -860601566}, + {-1973089100, -847705977}, {-1978595022, -834774075}, + {-1984016189, -821806413}, {-1989352366, -808803549}, + {-1994603327, -795766038}, {-1999768845, -782694439}, + {-2004848700, -769589312}, {-2009842674, -756451218}, + {-2014750553, -743280720}, {-2019572126, -730078383}, + {-2024307188, -716844772}, {-2028955535, -703580453}, + {-2033516969, -690285996}, {-2037991293, -676961968}, + {-2042378317, -663608942}, {-2046677852, -650227490}, + {-2050889714, -636818183}, {-2055013723, -623381598}, + {-2059049702, -609918309}, {-2062997478, -596428893}, + {-2066856882, -582913927}, {-2070627749, -569373992}, + {-2074309917, -555809667}, {-2077903229, -542221533}, + {-2081407530, -528610172}, {-2084822670, -514976167}, + {-2088148504, -501320102}, {-2091384888, -487642562}, + {-2094531684, -473944133}, {-2097588758, -460225402}, + {-2100555978, -446486956}, {-2103433217, -432729385}, + {-2106220352, -418953276}, {-2108917263, -405159222}, + {-2111523836, -391347811}, {-2114039958, -377519637}, + {-2116465521, -363675290}, {-2118800422, -349815365}, + {-2121044561, -335940456}, {-2123197841, -322051155}, + {-2125260170, -308148059}, {-2127231461, -294231763}, + {-2129111628, -280302863}, {-2130900591, -266361956}, + {-2132598273, -252409639}, {-2134204601, -238446509}, + {-2135719508, -224473166}, {-2137142927, -210490206}, + {-2138474799, -196498230}, {-2139715065, -182497836}, + {-2140863673, -168489625}, {-2141920573, -154474196}, + {-2142885721, -140452151}, {-2143759074, -126424088}, + {-2144540596, -112390610}, {-2145230253, -98352318}, + {-2145828016, -84309812}, {-2146333858, -70263695}, + {-2146747759, -56214568}, {-2147069700, -42163034}, + {-2147299668, -28109692}, {-2147437652, -14055147}, + {-2147483648, 0}, {-2147437652, 14055147}, + {-2147299668, 28109692}, {-2147069700, 42163034}, + {-2146747759, 56214568}, {-2146333858, 70263695}, + {-2145828016, 84309812}, {-2145230253, 98352318}, + {-2144540596, 112390610}, {-2143759074, 126424088}, + {-2142885721, 140452151}, {-2141920573, 154474196}, + {-2140863673, 168489625}, {-2139715065, 182497836}, + {-2138474799, 196498230}, {-2137142927, 210490206}, + {-2135719508, 224473166}, {-2134204601, 238446509}, + {-2132598273, 252409639}, {-2130900591, 266361956}, + {-2129111628, 280302863}, {-2127231461, 294231763}, + {-2125260170, 308148059}, {-2123197841, 322051155}, + {-2121044561, 335940456}, {-2118800422, 349815365}, + {-2116465521, 363675290}, {-2114039958, 377519637}, + {-2111523836, 391347811}, {-2108917263, 405159222}, + {-2106220352, 418953276}, {-2103433217, 432729385}, + {-2100555978, 446486956}, {-2097588758, 460225402}, + {-2094531684, 473944133}, {-2091384888, 487642562}, + {-2088148504, 501320102}, {-2084822670, 514976167}, + {-2081407530, 528610172}, {-2077903229, 542221533}, + {-2074309917, 555809667}, {-2070627749, 569373992}, + {-2066856882, 582913927}, {-2062997478, 596428893}, + {-2059049702, 609918309}, {-2055013723, 623381598}, + {-2050889714, 636818183}, {-2046677852, 650227490}, + {-2042378317, 663608942}, {-2037991293, 676961968}, + {-2033516969, 690285996}, {-2028955535, 703580453}, + {-2024307188, 716844772}, {-2019572126, 730078383}, + {-2014750553, 743280720}, {-2009842674, 756451218}, + {-2004848700, 769589312}, {-1999768845, 782694439}, + {-1994603327, 795766038}, {-1989352366, 808803549}, + {-1984016189, 821806413}, {-1978595022, 834774075}, + {-1973089100, 847705977}, {-1967498656, 860601566}, + {-1961823932, 873460290}, {-1956065170, 886281598}, + {-1950222616, 899064940}, {-1944296521, 911809770}, + {-1938287139, 924515541}, {-1932194727, 937181708}, + {-1926019547, 949807730}, {-1919761862, 962393065}, + {-1913421941, 974937175}, {-1907000055, 987439521}, + {-1900496480, 999899569}, {-1893911494, 1012316784}, + {-1887245379, 1024690635}, {-1880498421, 1037020592}, + {-1873670908, 1049306126}, {-1866763134, 1061546712}, + {-1859775393, 1073741824}, {-1852707986, 1085890941}, + {-1845561216, 1097993542}, {-1838335387, 1110049108}, + {-1831030811, 1122057124}, {-1823647799, 1134017074}, + {-1816186668, 1145928447}, {-1808647737, 1157790732}, + {-1801031331, 1169603422}, {-1793337774, 1181366009}, + {-1785567396, 1193077991}, {-1777720531, 1204738865}, + {-1769797514, 1216348132}, {-1761798685, 1227905295}, + {-1753724386, 1239409858}, {-1745574963, 1250861329}, + {-1737350766, 1262259218}, {-1729052147, 1273603035}, + {-1720679461, 1284892296}, {-1712233066, 1296126516}, + {-1703713325, 1307305214}, {-1695120603, 1318427912}, + {-1686455268, 1329494133}, {-1677717690, 1340503402}, + {-1668908244, 1351455249}, {-1660027308, 1362349204}, + {-1651075262, 1373184801}, {-1642052490, 1383961574}, + {-1632959377, 1394679064}, {-1623796314, 1405336810}, + {-1614563692, 1415934356}, {-1605261909, 1426471249}, + {-1595891361, 1436947036}, {-1586452450, 1447361268}, + {-1576945581, 1457713501}, {-1567371161, 1468003290}, + {-1557729600, 1478230195}, {-1548021312, 1488393778}, + {-1538246711, 1498493602}, {-1528406216, 1508529236}, + {-1518500250, 1518500250}, {-1508529236, 1528406216}, + {-1498493602, 1538246711}, {-1488393778, 1548021312}, + {-1478230195, 1557729600}, {-1468003290, 1567371161}, + {-1457713501, 1576945581}, {-1447361268, 1586452450}, + {-1436947036, 1595891361}, {-1426471249, 1605261909}, + {-1415934356, 1614563692}, {-1405336810, 1623796314}, + {-1394679064, 1632959377}, {-1383961574, 1642052490}, + {-1373184801, 1651075262}, {-1362349204, 1660027308}, + {-1351455249, 1668908244}, {-1340503402, 1677717690}, + {-1329494133, 1686455268}, {-1318427912, 1695120603}, + {-1307305214, 1703713325}, {-1296126516, 1712233066}, + {-1284892296, 1720679461}, {-1273603035, 1729052147}, + {-1262259218, 1737350766}, {-1250861329, 1745574963}, + {-1239409858, 1753724386}, {-1227905295, 1761798685}, + {-1216348132, 1769797514}, {-1204738865, 1777720531}, + {-1193077991, 1785567396}, {-1181366009, 1793337774}, + {-1169603422, 1801031331}, {-1157790732, 1808647737}, + {-1145928447, 1816186668}, {-1134017074, 1823647799}, + {-1122057124, 1831030811}, {-1110049108, 1838335387}, + {-1097993542, 1845561216}, {-1085890941, 1852707986}, + {-1073741824, 1859775393}, {-1061546712, 1866763134}, + {-1049306126, 1873670908}, {-1037020592, 1880498421}, + {-1024690635, 1887245379}, {-1012316784, 1893911494}, + {-999899569, 1900496480}, {-987439521, 1907000055}, + {-974937175, 1913421941}, {-962393065, 1919761862}, + {-949807730, 1926019547}, {-937181708, 1932194727}, + {-924515541, 1938287139}, {-911809770, 1944296521}, + {-899064940, 1950222616}, {-886281598, 1956065170}, + {-873460290, 1961823932}, {-860601566, 1967498656}, + {-847705977, 1973089100}, {-834774075, 1978595022}, + {-821806413, 1984016189}, {-808803549, 1989352366}, + {-795766038, 1994603327}, {-782694439, 1999768845}, + {-769589312, 2004848700}, {-756451218, 2009842674}, + {-743280720, 2014750553}, {-730078383, 2019572126}, + {-716844772, 2024307188}, {-703580453, 2028955535}, + {-690285996, 2033516969}, {-676961968, 2037991293}, + {-663608942, 2042378317}, {-650227490, 2046677852}, + {-636818183, 2050889714}, {-623381598, 2055013723}, + {-609918309, 2059049702}, {-596428893, 2062997478}, + {-582913927, 2066856882}, {-569373992, 2070627749}, + {-555809667, 2074309917}, {-542221533, 2077903229}, + {-528610172, 2081407530}, {-514976167, 2084822670}, + {-501320102, 2088148504}, {-487642562, 2091384888}, + {-473944133, 2094531684}, {-460225402, 2097588758}, + {-446486956, 2100555978}, {-432729385, 2103433217}, + {-418953276, 2106220352}, {-405159222, 2108917263}, + {-391347811, 2111523836}, {-377519637, 2114039958}, + {-363675290, 2116465521}, {-349815365, 2118800422}, + {-335940456, 2121044561}, {-322051155, 2123197841}, + {-308148059, 2125260170}, {-294231763, 2127231461}, + {-280302863, 2129111628}, {-266361956, 2130900591}, + {-252409639, 2132598273}, {-238446509, 2134204601}, + {-224473166, 2135719508}, {-210490206, 2137142927}, + {-196498230, 2138474799}, {-182497836, 2139715065}, + {-168489625, 2140863673}, {-154474196, 2141920573}, + {-140452151, 2142885721}, {-126424088, 2143759074}, + {-112390610, 2144540596}, {-98352318, 2145230253}, + {-84309812, 2145828016}, {-70263695, 2146333858}, + {-56214568, 2146747759}, {-42163034, 2147069700}, + {-28109692, 2147299668}, {-14055147, 2147437652}, + {0, 2147483647}, {14055147, 2147437652}, + {28109692, 2147299668}, {42163034, 2147069700}, + {56214568, 2146747759}, {70263695, 2146333858}, + {84309812, 2145828016}, {98352318, 2145230253}, + {112390610, 2144540596}, {126424088, 2143759074}, + {140452151, 2142885721}, {154474196, 2141920573}, + {168489625, 2140863673}, {182497836, 2139715065}, + {196498230, 2138474799}, {210490206, 2137142927}, + {224473166, 2135719508}, {238446509, 2134204601}, + {252409639, 2132598273}, {266361956, 2130900591}, + {280302863, 2129111628}, {294231763, 2127231461}, + {308148059, 2125260170}, {322051155, 2123197841}, + {335940456, 2121044561}, {349815365, 2118800422}, + {363675290, 2116465521}, {377519637, 2114039958}, + {391347811, 2111523836}, {405159222, 2108917263}, + {418953276, 2106220352}, {432729385, 2103433217}, + {446486956, 2100555978}, {460225402, 2097588758}, + {473944133, 2094531684}, {487642562, 2091384888}, + {501320102, 2088148504}, {514976167, 2084822670}, + {528610172, 2081407530}, {542221533, 2077903229}, + {555809667, 2074309917}, {569373992, 2070627749}, + {582913927, 2066856882}, {596428893, 2062997478}, + {609918309, 2059049702}, {623381598, 2055013723}, + {636818183, 2050889714}, {650227490, 2046677852}, + {663608942, 2042378317}, {676961968, 2037991293}, + {690285996, 2033516969}, {703580453, 2028955535}, + {716844772, 2024307188}, {730078383, 2019572126}, + {743280720, 2014750553}, {756451218, 2009842674}, + {769589312, 2004848700}, {782694439, 1999768845}, + {795766038, 1994603327}, {808803549, 1989352366}, + {821806413, 1984016189}, {834774075, 1978595022}, + {847705977, 1973089100}, {860601566, 1967498656}, + {873460290, 1961823932}, {886281598, 1956065170}, + {899064940, 1950222616}, {911809770, 1944296521}, + {924515541, 1938287139}, {937181708, 1932194727}, + {949807730, 1926019547}, {962393065, 1919761862}, + {974937175, 1913421941}, {987439521, 1907000055}, + {999899569, 1900496480}, {1012316784, 1893911494}, + {1024690635, 1887245379}, {1037020592, 1880498421}, + {1049306126, 1873670908}, {1061546712, 1866763134}, + {1073741824, 1859775393}, {1085890941, 1852707986}, + {1097993542, 1845561216}, {1110049108, 1838335387}, + {1122057124, 1831030811}, {1134017074, 1823647799}, + {1145928447, 1816186668}, {1157790732, 1808647737}, + {1169603422, 1801031331}, {1181366009, 1793337774}, + {1193077991, 1785567396}, {1204738865, 1777720531}, + {1216348132, 1769797514}, {1227905295, 1761798685}, + {1239409858, 1753724386}, {1250861329, 1745574963}, + {1262259218, 1737350766}, {1273603035, 1729052147}, + {1284892296, 1720679461}, {1296126516, 1712233066}, + {1307305214, 1703713325}, {1318427912, 1695120603}, + {1329494133, 1686455268}, {1340503402, 1677717690}, + {1351455249, 1668908244}, {1362349204, 1660027308}, + {1373184801, 1651075262}, {1383961574, 1642052490}, + {1394679064, 1632959377}, {1405336810, 1623796314}, + {1415934356, 1614563692}, {1426471249, 1605261909}, + {1436947036, 1595891361}, {1447361268, 1586452450}, + {1457713501, 1576945581}, {1468003290, 1567371161}, + {1478230195, 1557729600}, {1488393778, 1548021312}, + {1498493602, 1538246711}, {1508529236, 1528406216}, + {1518500250, 1518500250}, {1528406216, 1508529236}, + {1538246711, 1498493602}, {1548021312, 1488393778}, + {1557729600, 1478230195}, {1567371161, 1468003290}, + {1576945581, 1457713501}, {1586452450, 1447361268}, + {1595891361, 1436947036}, {1605261909, 1426471249}, + {1614563692, 1415934356}, {1623796314, 1405336810}, + {1632959377, 1394679064}, {1642052490, 1383961574}, + {1651075262, 1373184801}, {1660027308, 1362349204}, + {1668908244, 1351455249}, {1677717690, 1340503402}, + {1686455268, 1329494133}, {1695120603, 1318427912}, + {1703713325, 1307305214}, {1712233066, 1296126516}, + {1720679461, 1284892296}, {1729052147, 1273603035}, + {1737350766, 1262259218}, {1745574963, 1250861329}, + {1753724386, 1239409858}, {1761798685, 1227905295}, + {1769797514, 1216348132}, {1777720531, 1204738865}, + {1785567396, 1193077991}, {1793337774, 1181366009}, + {1801031331, 1169603422}, {1808647737, 1157790732}, + {1816186668, 1145928447}, {1823647799, 1134017074}, + {1831030811, 1122057124}, {1838335387, 1110049108}, + {1845561216, 1097993542}, {1852707986, 1085890941}, + {1859775393, 1073741824}, {1866763134, 1061546712}, + {1873670908, 1049306126}, {1880498421, 1037020592}, + {1887245379, 1024690635}, {1893911494, 1012316784}, + {1900496480, 999899569}, {1907000055, 987439521}, + {1913421941, 974937175}, {1919761862, 962393065}, + {1926019547, 949807730}, {1932194727, 937181708}, + {1938287139, 924515541}, {1944296521, 911809770}, + {1950222616, 899064940}, {1956065170, 886281598}, + {1961823932, 873460290}, {1967498656, 860601566}, + {1973089100, 847705977}, {1978595022, 834774075}, + {1984016189, 821806413}, {1989352366, 808803549}, + {1994603327, 795766038}, {1999768845, 782694439}, + {2004848700, 769589312}, {2009842674, 756451218}, + {2014750553, 743280720}, {2019572126, 730078383}, + {2024307188, 716844772}, {2028955535, 703580453}, + {2033516969, 690285996}, {2037991293, 676961968}, + {2042378317, 663608942}, {2046677852, 650227490}, + {2050889714, 636818183}, {2055013723, 623381598}, + {2059049702, 609918309}, {2062997478, 596428893}, + {2066856882, 582913927}, {2070627749, 569373992}, + {2074309917, 555809667}, {2077903229, 542221533}, + {2081407530, 528610172}, {2084822670, 514976167}, + {2088148504, 501320102}, {2091384888, 487642562}, + {2094531684, 473944133}, {2097588758, 460225402}, + {2100555978, 446486956}, {2103433217, 432729385}, + {2106220352, 418953276}, {2108917263, 405159222}, + {2111523836, 391347811}, {2114039958, 377519637}, + {2116465521, 363675290}, {2118800422, 349815365}, + {2121044561, 335940456}, {2123197841, 322051155}, + {2125260170, 308148059}, {2127231461, 294231763}, + {2129111628, 280302863}, {2130900591, 266361956}, + {2132598273, 252409639}, {2134204601, 238446509}, + {2135719508, 224473166}, {2137142927, 210490206}, + {2138474799, 196498230}, {2139715065, 182497836}, + {2140863673, 168489625}, {2141920573, 154474196}, + {2142885721, 140452151}, {2143759074, 126424088}, + {2144540596, 112390610}, {2145230253, 98352318}, + {2145828016, 84309812}, {2146333858, 70263695}, + {2146747759, 56214568}, {2147069700, 42163034}, + {2147299668, 28109692}, {2147437652, 14055147}, }; -#ifndef FFT_BITREV960 -#define FFT_BITREV960 -static const opus_int16 fft_bitrev960[960] = { -0, 192, 384, 576, 768, 64, 256, 448, 640, 832, 128, 320, 512, 704, 896, -16, 208, 400, 592, 784, 80, 272, 464, 656, 848, 144, 336, 528, 720, 912, -32, 224, 416, 608, 800, 96, 288, 480, 672, 864, 160, 352, 544, 736, 928, -48, 240, 432, 624, 816, 112, 304, 496, 688, 880, 176, 368, 560, 752, 944, -4, 196, 388, 580, 772, 68, 260, 452, 644, 836, 132, 324, 516, 708, 900, -20, 212, 404, 596, 788, 84, 276, 468, 660, 852, 148, 340, 532, 724, 916, -36, 228, 420, 612, 804, 100, 292, 484, 676, 868, 164, 356, 548, 740, 932, -52, 244, 436, 628, 820, 116, 308, 500, 692, 884, 180, 372, 564, 756, 948, -8, 200, 392, 584, 776, 72, 264, 456, 648, 840, 136, 328, 520, 712, 904, -24, 216, 408, 600, 792, 88, 280, 472, 664, 856, 152, 344, 536, 728, 920, -40, 232, 424, 616, 808, 104, 296, 488, 680, 872, 168, 360, 552, 744, 936, -56, 248, 440, 632, 824, 120, 312, 504, 696, 888, 184, 376, 568, 760, 952, -12, 204, 396, 588, 780, 76, 268, 460, 652, 844, 140, 332, 524, 716, 908, -28, 220, 412, 604, 796, 92, 284, 476, 668, 860, 156, 348, 540, 732, 924, -44, 236, 428, 620, 812, 108, 300, 492, 684, 876, 172, 364, 556, 748, 940, -60, 252, 444, 636, 828, 124, 316, 508, 700, 892, 188, 380, 572, 764, 956, -1, 193, 385, 577, 769, 65, 257, 449, 641, 833, 129, 321, 513, 705, 897, -17, 209, 401, 593, 785, 81, 273, 465, 657, 849, 145, 337, 529, 721, 913, -33, 225, 417, 609, 801, 97, 289, 481, 673, 865, 161, 353, 545, 737, 929, -49, 241, 433, 625, 817, 113, 305, 497, 689, 881, 177, 369, 561, 753, 945, -5, 197, 389, 581, 773, 69, 261, 453, 645, 837, 133, 325, 517, 709, 901, -21, 213, 405, 597, 789, 85, 277, 469, 661, 853, 149, 341, 533, 725, 917, -37, 229, 421, 613, 805, 101, 293, 485, 677, 869, 165, 357, 549, 741, 933, -53, 245, 437, 629, 821, 117, 309, 501, 693, 885, 181, 373, 565, 757, 949, -9, 201, 393, 585, 777, 73, 265, 457, 649, 841, 137, 329, 521, 713, 905, -25, 217, 409, 601, 793, 89, 281, 473, 665, 857, 153, 345, 537, 729, 921, -41, 233, 425, 617, 809, 105, 297, 489, 681, 873, 169, 361, 553, 745, 937, -57, 249, 441, 633, 825, 121, 313, 505, 697, 889, 185, 377, 569, 761, 953, -13, 205, 397, 589, 781, 77, 269, 461, 653, 845, 141, 333, 525, 717, 909, -29, 221, 413, 605, 797, 93, 285, 477, 669, 861, 157, 349, 541, 733, 925, -45, 237, 429, 621, 813, 109, 301, 493, 685, 877, 173, 365, 557, 749, 941, -61, 253, 445, 637, 829, 125, 317, 509, 701, 893, 189, 381, 573, 765, 957, -2, 194, 386, 578, 770, 66, 258, 450, 642, 834, 130, 322, 514, 706, 898, -18, 210, 402, 594, 786, 82, 274, 466, 658, 850, 146, 338, 530, 722, 914, -34, 226, 418, 610, 802, 98, 290, 482, 674, 866, 162, 354, 546, 738, 930, -50, 242, 434, 626, 818, 114, 306, 498, 690, 882, 178, 370, 562, 754, 946, -6, 198, 390, 582, 774, 70, 262, 454, 646, 838, 134, 326, 518, 710, 902, -22, 214, 406, 598, 790, 86, 278, 470, 662, 854, 150, 342, 534, 726, 918, -38, 230, 422, 614, 806, 102, 294, 486, 678, 870, 166, 358, 550, 742, 934, -54, 246, 438, 630, 822, 118, 310, 502, 694, 886, 182, 374, 566, 758, 950, -10, 202, 394, 586, 778, 74, 266, 458, 650, 842, 138, 330, 522, 714, 906, -26, 218, 410, 602, 794, 90, 282, 474, 666, 858, 154, 346, 538, 730, 922, -42, 234, 426, 618, 810, 106, 298, 490, 682, 874, 170, 362, 554, 746, 938, -58, 250, 442, 634, 826, 122, 314, 506, 698, 890, 186, 378, 570, 762, 954, -14, 206, 398, 590, 782, 78, 270, 462, 654, 846, 142, 334, 526, 718, 910, -30, 222, 414, 606, 798, 94, 286, 478, 670, 862, 158, 350, 542, 734, 926, -46, 238, 430, 622, 814, 110, 302, 494, 686, 878, 174, 366, 558, 750, 942, -62, 254, 446, 638, 830, 126, 318, 510, 702, 894, 190, 382, 574, 766, 958, -3, 195, 387, 579, 771, 67, 259, 451, 643, 835, 131, 323, 515, 707, 899, -19, 211, 403, 595, 787, 83, 275, 467, 659, 851, 147, 339, 531, 723, 915, -35, 227, 419, 611, 803, 99, 291, 483, 675, 867, 163, 355, 547, 739, 931, -51, 243, 435, 627, 819, 115, 307, 499, 691, 883, 179, 371, 563, 755, 947, -7, 199, 391, 583, 775, 71, 263, 455, 647, 839, 135, 327, 519, 711, 903, -23, 215, 407, 599, 791, 87, 279, 471, 663, 855, 151, 343, 535, 727, 919, -39, 231, 423, 615, 807, 103, 295, 487, 679, 871, 167, 359, 551, 743, 935, -55, 247, 439, 631, 823, 119, 311, 503, 695, 887, 183, 375, 567, 759, 951, -11, 203, 395, 587, 779, 75, 267, 459, 651, 843, 139, 331, 523, 715, 907, -27, 219, 411, 603, 795, 91, 283, 475, 667, 859, 155, 347, 539, 731, 923, -43, 235, 427, 619, 811, 107, 299, 491, 683, 875, 171, 363, 555, 747, 939, -59, 251, 443, 635, 827, 123, 315, 507, 699, 891, 187, 379, 571, 763, 955, -15, 207, 399, 591, 783, 79, 271, 463, 655, 847, 143, 335, 527, 719, 911, -31, 223, 415, 607, 799, 95, 287, 479, 671, 863, 159, 351, 543, 735, 927, -47, 239, 431, 623, 815, 111, 303, 495, 687, 879, 175, 367, 559, 751, 943, -63, 255, 447, 639, 831, 127, 319, 511, 703, 895, 191, 383, 575, 767, 959, +# ifndef FFT_BITREV960 +# define FFT_BITREV960 +static const oac_int16 fft_bitrev960[960] = { + 0, 192, 384, 576, 768, 64, 256, 448, 640, 832, 128, 320, 512, 704, 896, + 16, 208, 400, 592, 784, 80, 272, 464, 656, 848, 144, 336, 528, 720, 912, + 32, 224, 416, 608, 800, 96, 288, 480, 672, 864, 160, 352, 544, 736, 928, + 48, 240, 432, 624, 816, 112, 304, 496, 688, 880, 176, 368, 560, 752, 944, + 4, 196, 388, 580, 772, 68, 260, 452, 644, 836, 132, 324, 516, 708, 900, + 20, 212, 404, 596, 788, 84, 276, 468, 660, 852, 148, 340, 532, 724, 916, + 36, 228, 420, 612, 804, 100, 292, 484, 676, 868, 164, 356, 548, 740, 932, + 52, 244, 436, 628, 820, 116, 308, 500, 692, 884, 180, 372, 564, 756, 948, + 8, 200, 392, 584, 776, 72, 264, 456, 648, 840, 136, 328, 520, 712, 904, + 24, 216, 408, 600, 792, 88, 280, 472, 664, 856, 152, 344, 536, 728, 920, + 40, 232, 424, 616, 808, 104, 296, 488, 680, 872, 168, 360, 552, 744, 936, + 56, 248, 440, 632, 824, 120, 312, 504, 696, 888, 184, 376, 568, 760, 952, + 12, 204, 396, 588, 780, 76, 268, 460, 652, 844, 140, 332, 524, 716, 908, + 28, 220, 412, 604, 796, 92, 284, 476, 668, 860, 156, 348, 540, 732, 924, + 44, 236, 428, 620, 812, 108, 300, 492, 684, 876, 172, 364, 556, 748, 940, + 60, 252, 444, 636, 828, 124, 316, 508, 700, 892, 188, 380, 572, 764, 956, + 1, 193, 385, 577, 769, 65, 257, 449, 641, 833, 129, 321, 513, 705, 897, + 17, 209, 401, 593, 785, 81, 273, 465, 657, 849, 145, 337, 529, 721, 913, + 33, 225, 417, 609, 801, 97, 289, 481, 673, 865, 161, 353, 545, 737, 929, + 49, 241, 433, 625, 817, 113, 305, 497, 689, 881, 177, 369, 561, 753, 945, + 5, 197, 389, 581, 773, 69, 261, 453, 645, 837, 133, 325, 517, 709, 901, + 21, 213, 405, 597, 789, 85, 277, 469, 661, 853, 149, 341, 533, 725, 917, + 37, 229, 421, 613, 805, 101, 293, 485, 677, 869, 165, 357, 549, 741, 933, + 53, 245, 437, 629, 821, 117, 309, 501, 693, 885, 181, 373, 565, 757, 949, + 9, 201, 393, 585, 777, 73, 265, 457, 649, 841, 137, 329, 521, 713, 905, + 25, 217, 409, 601, 793, 89, 281, 473, 665, 857, 153, 345, 537, 729, 921, + 41, 233, 425, 617, 809, 105, 297, 489, 681, 873, 169, 361, 553, 745, 937, + 57, 249, 441, 633, 825, 121, 313, 505, 697, 889, 185, 377, 569, 761, 953, + 13, 205, 397, 589, 781, 77, 269, 461, 653, 845, 141, 333, 525, 717, 909, + 29, 221, 413, 605, 797, 93, 285, 477, 669, 861, 157, 349, 541, 733, 925, + 45, 237, 429, 621, 813, 109, 301, 493, 685, 877, 173, 365, 557, 749, 941, + 61, 253, 445, 637, 829, 125, 317, 509, 701, 893, 189, 381, 573, 765, 957, + 2, 194, 386, 578, 770, 66, 258, 450, 642, 834, 130, 322, 514, 706, 898, + 18, 210, 402, 594, 786, 82, 274, 466, 658, 850, 146, 338, 530, 722, 914, + 34, 226, 418, 610, 802, 98, 290, 482, 674, 866, 162, 354, 546, 738, 930, + 50, 242, 434, 626, 818, 114, 306, 498, 690, 882, 178, 370, 562, 754, 946, + 6, 198, 390, 582, 774, 70, 262, 454, 646, 838, 134, 326, 518, 710, 902, + 22, 214, 406, 598, 790, 86, 278, 470, 662, 854, 150, 342, 534, 726, 918, + 38, 230, 422, 614, 806, 102, 294, 486, 678, 870, 166, 358, 550, 742, 934, + 54, 246, 438, 630, 822, 118, 310, 502, 694, 886, 182, 374, 566, 758, 950, + 10, 202, 394, 586, 778, 74, 266, 458, 650, 842, 138, 330, 522, 714, 906, + 26, 218, 410, 602, 794, 90, 282, 474, 666, 858, 154, 346, 538, 730, 922, + 42, 234, 426, 618, 810, 106, 298, 490, 682, 874, 170, 362, 554, 746, 938, + 58, 250, 442, 634, 826, 122, 314, 506, 698, 890, 186, 378, 570, 762, 954, + 14, 206, 398, 590, 782, 78, 270, 462, 654, 846, 142, 334, 526, 718, 910, + 30, 222, 414, 606, 798, 94, 286, 478, 670, 862, 158, 350, 542, 734, 926, + 46, 238, 430, 622, 814, 110, 302, 494, 686, 878, 174, 366, 558, 750, 942, + 62, 254, 446, 638, 830, 126, 318, 510, 702, 894, 190, 382, 574, 766, 958, + 3, 195, 387, 579, 771, 67, 259, 451, 643, 835, 131, 323, 515, 707, 899, + 19, 211, 403, 595, 787, 83, 275, 467, 659, 851, 147, 339, 531, 723, 915, + 35, 227, 419, 611, 803, 99, 291, 483, 675, 867, 163, 355, 547, 739, 931, + 51, 243, 435, 627, 819, 115, 307, 499, 691, 883, 179, 371, 563, 755, 947, + 7, 199, 391, 583, 775, 71, 263, 455, 647, 839, 135, 327, 519, 711, 903, + 23, 215, 407, 599, 791, 87, 279, 471, 663, 855, 151, 343, 535, 727, 919, + 39, 231, 423, 615, 807, 103, 295, 487, 679, 871, 167, 359, 551, 743, 935, + 55, 247, 439, 631, 823, 119, 311, 503, 695, 887, 183, 375, 567, 759, 951, + 11, 203, 395, 587, 779, 75, 267, 459, 651, 843, 139, 331, 523, 715, 907, + 27, 219, 411, 603, 795, 91, 283, 475, 667, 859, 155, 347, 539, 731, 923, + 43, 235, 427, 619, 811, 107, 299, 491, 683, 875, 171, 363, 555, 747, 939, + 59, 251, 443, 635, 827, 123, 315, 507, 699, 891, 187, 379, 571, 763, 955, + 15, 207, 399, 591, 783, 79, 271, 463, 655, 847, 143, 335, 527, 719, 911, + 31, 223, 415, 607, 799, 95, 287, 479, 671, 863, 159, 351, 543, 735, 927, + 47, 239, 431, 623, 815, 111, 303, 495, 687, 879, 175, 367, 559, 751, 943, + 63, 255, 447, 639, 831, 127, 319, 511, 703, 895, 191, 383, 575, 767, 959, }; -#endif +# endif -#ifndef FFT_BITREV480 -#define FFT_BITREV480 -static const opus_int16 fft_bitrev480[480] = { -0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, -8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, -16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, -24, 120, 216, 312, 408, 56, 152, 248, 344, 440, 88, 184, 280, 376, 472, -4, 100, 196, 292, 388, 36, 132, 228, 324, 420, 68, 164, 260, 356, 452, -12, 108, 204, 300, 396, 44, 140, 236, 332, 428, 76, 172, 268, 364, 460, -20, 116, 212, 308, 404, 52, 148, 244, 340, 436, 84, 180, 276, 372, 468, -28, 124, 220, 316, 412, 60, 156, 252, 348, 444, 92, 188, 284, 380, 476, -1, 97, 193, 289, 385, 33, 129, 225, 321, 417, 65, 161, 257, 353, 449, -9, 105, 201, 297, 393, 41, 137, 233, 329, 425, 73, 169, 265, 361, 457, -17, 113, 209, 305, 401, 49, 145, 241, 337, 433, 81, 177, 273, 369, 465, -25, 121, 217, 313, 409, 57, 153, 249, 345, 441, 89, 185, 281, 377, 473, -5, 101, 197, 293, 389, 37, 133, 229, 325, 421, 69, 165, 261, 357, 453, -13, 109, 205, 301, 397, 45, 141, 237, 333, 429, 77, 173, 269, 365, 461, -21, 117, 213, 309, 405, 53, 149, 245, 341, 437, 85, 181, 277, 373, 469, -29, 125, 221, 317, 413, 61, 157, 253, 349, 445, 93, 189, 285, 381, 477, -2, 98, 194, 290, 386, 34, 130, 226, 322, 418, 66, 162, 258, 354, 450, -10, 106, 202, 298, 394, 42, 138, 234, 330, 426, 74, 170, 266, 362, 458, -18, 114, 210, 306, 402, 50, 146, 242, 338, 434, 82, 178, 274, 370, 466, -26, 122, 218, 314, 410, 58, 154, 250, 346, 442, 90, 186, 282, 378, 474, -6, 102, 198, 294, 390, 38, 134, 230, 326, 422, 70, 166, 262, 358, 454, -14, 110, 206, 302, 398, 46, 142, 238, 334, 430, 78, 174, 270, 366, 462, -22, 118, 214, 310, 406, 54, 150, 246, 342, 438, 86, 182, 278, 374, 470, -30, 126, 222, 318, 414, 62, 158, 254, 350, 446, 94, 190, 286, 382, 478, -3, 99, 195, 291, 387, 35, 131, 227, 323, 419, 67, 163, 259, 355, 451, -11, 107, 203, 299, 395, 43, 139, 235, 331, 427, 75, 171, 267, 363, 459, -19, 115, 211, 307, 403, 51, 147, 243, 339, 435, 83, 179, 275, 371, 467, -27, 123, 219, 315, 411, 59, 155, 251, 347, 443, 91, 187, 283, 379, 475, -7, 103, 199, 295, 391, 39, 135, 231, 327, 423, 71, 167, 263, 359, 455, -15, 111, 207, 303, 399, 47, 143, 239, 335, 431, 79, 175, 271, 367, 463, -23, 119, 215, 311, 407, 55, 151, 247, 343, 439, 87, 183, 279, 375, 471, -31, 127, 223, 319, 415, 63, 159, 255, 351, 447, 95, 191, 287, 383, 479, +# ifndef FFT_BITREV480 +# define FFT_BITREV480 +static const oac_int16 fft_bitrev480[480] = { + 0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, + 8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, + 16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, + 24, 120, 216, 312, 408, 56, 152, 248, 344, 440, 88, 184, 280, 376, 472, + 4, 100, 196, 292, 388, 36, 132, 228, 324, 420, 68, 164, 260, 356, 452, + 12, 108, 204, 300, 396, 44, 140, 236, 332, 428, 76, 172, 268, 364, 460, + 20, 116, 212, 308, 404, 52, 148, 244, 340, 436, 84, 180, 276, 372, 468, + 28, 124, 220, 316, 412, 60, 156, 252, 348, 444, 92, 188, 284, 380, 476, + 1, 97, 193, 289, 385, 33, 129, 225, 321, 417, 65, 161, 257, 353, 449, + 9, 105, 201, 297, 393, 41, 137, 233, 329, 425, 73, 169, 265, 361, 457, + 17, 113, 209, 305, 401, 49, 145, 241, 337, 433, 81, 177, 273, 369, 465, + 25, 121, 217, 313, 409, 57, 153, 249, 345, 441, 89, 185, 281, 377, 473, + 5, 101, 197, 293, 389, 37, 133, 229, 325, 421, 69, 165, 261, 357, 453, + 13, 109, 205, 301, 397, 45, 141, 237, 333, 429, 77, 173, 269, 365, 461, + 21, 117, 213, 309, 405, 53, 149, 245, 341, 437, 85, 181, 277, 373, 469, + 29, 125, 221, 317, 413, 61, 157, 253, 349, 445, 93, 189, 285, 381, 477, + 2, 98, 194, 290, 386, 34, 130, 226, 322, 418, 66, 162, 258, 354, 450, + 10, 106, 202, 298, 394, 42, 138, 234, 330, 426, 74, 170, 266, 362, 458, + 18, 114, 210, 306, 402, 50, 146, 242, 338, 434, 82, 178, 274, 370, 466, + 26, 122, 218, 314, 410, 58, 154, 250, 346, 442, 90, 186, 282, 378, 474, + 6, 102, 198, 294, 390, 38, 134, 230, 326, 422, 70, 166, 262, 358, 454, + 14, 110, 206, 302, 398, 46, 142, 238, 334, 430, 78, 174, 270, 366, 462, + 22, 118, 214, 310, 406, 54, 150, 246, 342, 438, 86, 182, 278, 374, 470, + 30, 126, 222, 318, 414, 62, 158, 254, 350, 446, 94, 190, 286, 382, 478, + 3, 99, 195, 291, 387, 35, 131, 227, 323, 419, 67, 163, 259, 355, 451, + 11, 107, 203, 299, 395, 43, 139, 235, 331, 427, 75, 171, 267, 363, 459, + 19, 115, 211, 307, 403, 51, 147, 243, 339, 435, 83, 179, 275, 371, 467, + 27, 123, 219, 315, 411, 59, 155, 251, 347, 443, 91, 187, 283, 379, 475, + 7, 103, 199, 295, 391, 39, 135, 231, 327, 423, 71, 167, 263, 359, 455, + 15, 111, 207, 303, 399, 47, 143, 239, 335, 431, 79, 175, 271, 367, 463, + 23, 119, 215, 311, 407, 55, 151, 247, 343, 439, 87, 183, 279, 375, 471, + 31, 127, 223, 319, 415, 63, 159, 255, 351, 447, 95, 191, 287, 383, 479, }; -#endif +# endif -#ifndef FFT_BITREV240 -#define FFT_BITREV240 -static const opus_int16 fft_bitrev240[240] = { -0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, -4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, -8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, -12, 60, 108, 156, 204, 28, 76, 124, 172, 220, 44, 92, 140, 188, 236, -1, 49, 97, 145, 193, 17, 65, 113, 161, 209, 33, 81, 129, 177, 225, -5, 53, 101, 149, 197, 21, 69, 117, 165, 213, 37, 85, 133, 181, 229, -9, 57, 105, 153, 201, 25, 73, 121, 169, 217, 41, 89, 137, 185, 233, -13, 61, 109, 157, 205, 29, 77, 125, 173, 221, 45, 93, 141, 189, 237, -2, 50, 98, 146, 194, 18, 66, 114, 162, 210, 34, 82, 130, 178, 226, -6, 54, 102, 150, 198, 22, 70, 118, 166, 214, 38, 86, 134, 182, 230, -10, 58, 106, 154, 202, 26, 74, 122, 170, 218, 42, 90, 138, 186, 234, -14, 62, 110, 158, 206, 30, 78, 126, 174, 222, 46, 94, 142, 190, 238, -3, 51, 99, 147, 195, 19, 67, 115, 163, 211, 35, 83, 131, 179, 227, -7, 55, 103, 151, 199, 23, 71, 119, 167, 215, 39, 87, 135, 183, 231, -11, 59, 107, 155, 203, 27, 75, 123, 171, 219, 43, 91, 139, 187, 235, -15, 63, 111, 159, 207, 31, 79, 127, 175, 223, 47, 95, 143, 191, 239, +# ifndef FFT_BITREV240 +# define FFT_BITREV240 +static const oac_int16 fft_bitrev240[240] = { + 0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, + 4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, + 8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, + 12, 60, 108, 156, 204, 28, 76, 124, 172, 220, 44, 92, 140, 188, 236, + 1, 49, 97, 145, 193, 17, 65, 113, 161, 209, 33, 81, 129, 177, 225, + 5, 53, 101, 149, 197, 21, 69, 117, 165, 213, 37, 85, 133, 181, 229, + 9, 57, 105, 153, 201, 25, 73, 121, 169, 217, 41, 89, 137, 185, 233, + 13, 61, 109, 157, 205, 29, 77, 125, 173, 221, 45, 93, 141, 189, 237, + 2, 50, 98, 146, 194, 18, 66, 114, 162, 210, 34, 82, 130, 178, 226, + 6, 54, 102, 150, 198, 22, 70, 118, 166, 214, 38, 86, 134, 182, 230, + 10, 58, 106, 154, 202, 26, 74, 122, 170, 218, 42, 90, 138, 186, 234, + 14, 62, 110, 158, 206, 30, 78, 126, 174, 222, 46, 94, 142, 190, 238, + 3, 51, 99, 147, 195, 19, 67, 115, 163, 211, 35, 83, 131, 179, 227, + 7, 55, 103, 151, 199, 23, 71, 119, 167, 215, 39, 87, 135, 183, 231, + 11, 59, 107, 155, 203, 27, 75, 123, 171, 219, 43, 91, 139, 187, 235, + 15, 63, 111, 159, 207, 31, 79, 127, 175, 223, 47, 95, 143, 191, 239, }; -#endif +# endif -#ifndef FFT_BITREV120 -#define FFT_BITREV120 -static const opus_int16 fft_bitrev120[120] = { -0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, -4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, -1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, -5, 29, 53, 77, 101, 13, 37, 61, 85, 109, 21, 45, 69, 93, 117, -2, 26, 50, 74, 98, 10, 34, 58, 82, 106, 18, 42, 66, 90, 114, -6, 30, 54, 78, 102, 14, 38, 62, 86, 110, 22, 46, 70, 94, 118, -3, 27, 51, 75, 99, 11, 35, 59, 83, 107, 19, 43, 67, 91, 115, -7, 31, 55, 79, 103, 15, 39, 63, 87, 111, 23, 47, 71, 95, 119, +# ifndef FFT_BITREV120 +# define FFT_BITREV120 +static const oac_int16 fft_bitrev120[120] = { + 0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, + 4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, + 1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, + 5, 29, 53, 77, 101, 13, 37, 61, 85, 109, 21, 45, 69, 93, 117, + 2, 26, 50, 74, 98, 10, 34, 58, 82, 106, 18, 42, 66, 90, 114, + 6, 30, 54, 78, 102, 14, 38, 62, 86, 110, 22, 46, 70, 94, 118, + 3, 27, 51, 75, 99, 11, 35, 59, 83, 107, 19, 43, 67, 91, 115, + 7, 31, 55, 79, 103, 15, 39, 63, 87, 111, 23, 47, 71, 95, 119, }; -#endif +# endif -#ifndef FFT_STATE96000_1920_0 -#define FFT_STATE96000_1920_0 +# ifndef FFT_STATE96000_1920_0 +# define FFT_STATE96000_1920_0 static const kiss_fft_state fft_state96000_1920_0 = { -960, /* nfft */ -#ifdef ENABLE_QEXT -572662306, /* scale */ -#else -17476, /* scale */ -#endif -9, /* scale_shift */ --1, /* shift */ -{5, 192, 3, 64, 4, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev960, /* bitrev */ -fft_twiddles96000_1920, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_960, -#else -NULL, -#endif + 960, /* nfft */ + 572662306, /* scale */ + 9, /* scale_shift */ + -1, /* shift */ + {5, 192, 3, 64, 4, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev960, /* bitrev */ + fft_twiddles96000_1920, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_960, +# else + NULL, +# endif }; -#endif +# endif -#ifndef FFT_STATE96000_1920_1 -#define FFT_STATE96000_1920_1 +# ifndef FFT_STATE96000_1920_1 +# define FFT_STATE96000_1920_1 static const kiss_fft_state fft_state96000_1920_1 = { -480, /* nfft */ -#ifdef ENABLE_QEXT -572662306, /* scale */ -#else -17476, /* scale */ -#endif -8, /* scale_shift */ -1, /* shift */ -{5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev480, /* bitrev */ -fft_twiddles96000_1920, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_480, -#else -NULL, -#endif + 480, /* nfft */ + 572662306, /* scale */ + 8, /* scale_shift */ + 1, /* shift */ + {5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev480, /* bitrev */ + fft_twiddles96000_1920, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_480, +# else + NULL, +# endif }; -#endif +# endif -#ifndef FFT_STATE96000_1920_2 -#define FFT_STATE96000_1920_2 +# ifndef FFT_STATE96000_1920_2 +# define FFT_STATE96000_1920_2 static const kiss_fft_state fft_state96000_1920_2 = { -240, /* nfft */ -#ifdef ENABLE_QEXT -572662306, /* scale */ -#else -17476, /* scale */ -#endif -7, /* scale_shift */ -2, /* shift */ -{5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev240, /* bitrev */ -fft_twiddles96000_1920, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_240, -#else -NULL, -#endif + 240, /* nfft */ + 572662306, /* scale */ + 7, /* scale_shift */ + 2, /* shift */ + {5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev240, /* bitrev */ + fft_twiddles96000_1920, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_240, +# else + NULL, +# endif }; -#endif +# endif -#ifndef FFT_STATE96000_1920_3 -#define FFT_STATE96000_1920_3 +# ifndef FFT_STATE96000_1920_3 +# define FFT_STATE96000_1920_3 static const kiss_fft_state fft_state96000_1920_3 = { -120, /* nfft */ -#ifdef ENABLE_QEXT -572662306, /* scale */ -#else -17476, /* scale */ -#endif -6, /* scale_shift */ -3, /* shift */ -{5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev120, /* bitrev */ -fft_twiddles96000_1920, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_120, -#else -NULL, -#endif + 120, /* nfft */ + 572662306, /* scale */ + 6, /* scale_shift */ + 3, /* shift */ + {5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev120, /* bitrev */ + fft_twiddles96000_1920, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_120, +# else + NULL, +# endif }; -#endif +# endif -#endif +# endif -#ifndef MDCT_TWIDDLES1920 -#define MDCT_TWIDDLES1920 +# ifndef MDCT_TWIDDLES1920 +# define MDCT_TWIDDLES1920 static const celt_coef mdct_twiddles1920[3600] = { -#ifdef ENABLE_QEXT -2147483603, 2147480010, 2147470667, 2147455575, 2147434733, -2147408142, 2147375802, 2147337712, 2147293874, 2147244286, -2147188950, 2147127865, 2147061032, 2146988450, 2146910120, -2146826042, 2146736216, 2146640643, 2146539323, 2146432256, -2146319442, 2146200882, 2146076576, 2145946524, 2145810727, -2145669185, 2145521898, 2145368867, 2145210092, 2145045574, -2144875313, 2144699310, 2144517564, 2144330077, 2144136849, -2143937880, 2143733172, 2143522724, 2143306537, 2143084612, -2142856949, 2142623549, 2142384413, 2142139541, 2141888933, -2141632592, 2141370516, 2141102708, 2140829167, 2140549894, -2140264890, 2139974157, 2139677694, 2139375502, 2139067583, -2138753936, 2138434564, 2138109466, 2137778644, 2137442099, -2137099831, 2136751841, 2136398131, 2136038701, 2135673552, -2135302685, 2134926101, 2134543801, 2134155787, 2133762059, -2133362618, 2132957466, 2132546603, 2132130030, 2131707749, -2131279761, 2130846067, 2130406668, 2129961565, 2129510759, -2129054253, 2128592046, 2128124140, 2127650537, 2127171237, -2126686242, 2126195553, 2125699172, 2125197100, 2124689338, -2124175888, 2123656750, 2123131927, 2122601420, 2122065230, -2121523358, 2120975806, 2120422576, 2119863669, 2119299086, -2118728830, 2118152901, 2117571301, 2116984031, 2116391094, -2115792491, 2115188222, 2114578291, 2113962699, 2113341447, -2112714537, 2112081970, 2111443749, 2110799875, 2110150349, -2109495174, 2108834352, 2108167883, 2107495770, 2106818015, -2106134619, 2105445584, 2104750913, 2104050606, 2103344666, -2102633095, 2101915895, 2101193067, 2100464614, 2099730537, -2098990838, 2098245520, 2097494584, 2096738032, 2095975867, -2095208091, 2094434705, 2093655711, 2092871112, 2092080910, -2091285107, 2090483704, 2089676705, 2088864111, 2088045925, -2087222148, 2086392783, 2085557833, 2084717298, 2083871182, -2083019487, 2082162216, 2081299369, 2080430950, 2079556962, -2078677406, 2077792284, 2076901600, 2076005355, 2075103552, -2074196194, 2073283282, 2072364819, 2071440808, 2070511251, -2069576151, 2068635510, 2067689330, 2066737615, 2065780367, -2064817587, 2063849280, 2062875447, 2061896091, 2060911215, -2059920821, 2058924912, 2057923491, 2056916560, 2055904122, -2054886179, 2053862736, 2052833793, 2051799354, 2050759422, -2049714000, 2048663090, 2047606695, 2046544818, 2045477461, -2044404629, 2043326323, 2042242546, 2041153301, 2040058592, -2038958421, 2037852791, 2036741705, 2035625166, 2034503177, -2033375742, 2032242862, 2031104541, 2029960782, 2028811589, -2027656964, 2026496910, 2025331431, 2024160529, 2022984208, -2021802471, 2020615320, 2019422760, 2018224794, 2017021424, -2015812654, 2014598487, 2013378926, 2012153975, 2010923636, -2009687914, 2008446811, 2007200332, 2005948478, 2004691253, -2003428662, 2002160707, 2000887391, 1999608718, 1998324692, -1997035316, 1995740593, 1994440527, 1993135121, 1991824379, -1990508304, 1989186900, 1987860170, 1986528118, 1985190748, -1983848063, 1982500066, 1981146762, 1979788153, 1978424244, -1977055038, 1975680539, 1974300751, 1972915676, 1971525320, -1970129685, 1968728776, 1967322596, 1965911148, 1964494438, -1963072467, 1961645241, 1960212764, 1958775038, 1957332067, -1955883857, 1954430410, 1952971730, 1951507822, 1950038689, -1948564335, 1947084764, 1945599980, 1944109987, 1942614790, -1941114391, 1939608795, 1938098007, 1936582029, 1935060867, -1933534524, 1932003004, 1930466312, 1928924452, 1927377427, -1925825242, 1924267900, 1922705408, 1921137767, 1919564983, -1917987059, 1916404001, 1914815812, 1913222496, 1911624058, -1910020502, 1908411833, 1906798054, 1905179170, 1903555185, -1901926103, 1900291930, 1898652669, 1897008325, 1895358902, -1893704404, 1892044837, 1890380204, 1888710510, 1887035759, -1885355956, 1883671105, 1881981211, 1880286279, 1878586312, -1876881316, 1875171295, 1873456254, 1871736196, 1870011128, -1868281053, 1866545976, 1864805901, 1863060834, 1861310779, -1859555741, 1857795724, 1856030734, 1854260774, 1852485850, -1850705966, 1848921127, 1847131338, 1845336604, 1843536929, -1841732318, 1839922777, 1838108310, 1836288921, 1834464616, -1832635400, 1830801277, 1828962253, 1827118332, 1825269519, -1823415819, 1821557238, 1819693779, 1817825449, 1815952252, -1814074193, 1812191278, 1810303510, 1808410896, 1806513440, -1804611147, 1802704023, 1800792073, 1798875302, 1796953714, -1795027315, 1793096111, 1791160105, 1789219305, 1787273714, -1785323338, 1783368182, 1781408251, 1779443552, 1777474088, -1775499865, 1773520888, 1771537164, 1769548696, 1767555491, -1765557554, 1763554889, 1761547504, 1759535401, 1757518588, -1755497070, 1753470852, 1751439939, 1749404337, 1747364051, -1745319087, 1743269451, 1741215147, 1739156181, 1737092559, -1735024287, 1732951369, 1730873811, 1728791620, 1726704800, -1724613357, 1722517297, 1720416625, 1718311347, 1716201468, -1714086995, 1711967933, 1709844287, 1707716063, 1705583268, -1703445906, 1701303983, 1699157505, 1697006479, 1694850909, -1692690801, 1690526161, 1688356996, 1686183310, 1684005110, -1681822401, 1679635189, 1677443481, 1675247281, 1673046596, -1670841433, 1668631795, 1666417691, 1664199124, 1661976103, -1659748631, 1657516716, 1655280364, 1653039579, 1650794369, -1648544739, 1646290696, 1644032245, 1641769393, 1639502145, -1637230507, 1634954486, 1632674088, 1630389319, 1628100184, -1625806691, 1623508845, 1621206653, 1618900119, 1616589252, -1614274057, 1611954539, 1609630706, 1607302564, 1604970118, -1602633375, 1600292342, 1597947024, 1595597428, 1593243560, -1590885426, 1588523033, 1586156387, 1583785495, 1581410362, -1579030995, 1576647401, 1574259586, 1571867556, 1569471317, -1567070877, 1564666241, 1562257416, 1559844408, 1557427224, -1555005871, 1552580354, 1550150681, 1547716857, 1545278889, -1542836785, 1540390550, 1537940190, 1535485713, 1533027126, -1530564434, 1528097644, 1525626762, 1523151797, 1520672753, -1518189638, 1515702459, 1513211221, 1510715932, 1508216599, -1505713227, 1503205824, 1500694397, 1498178952, 1495659496, -1493136035, 1490608577, 1488077129, 1485541696, 1483002286, -1480458905, 1477911561, 1475360260, 1472805009, 1470245815, -1467682684, 1465115624, 1462544642, 1459969744, 1457390937, -1454808228, 1452221624, 1449631133, 1447036760, 1444438513, -1441836399, 1439230424, 1436620597, 1434006923, 1431389409, -1428768064, 1426142893, 1423513904, 1420881104, 1418244500, -1415604099, 1412959907, 1410311933, 1407660183, 1405004664, -1402345384, 1399682349, 1397015567, 1394345044, 1391670789, -1388992807, 1386311107, 1383625695, 1380936579, 1378243766, -1375547262, 1372847076, 1370143215, 1367435685, 1364724494, -1362009649, 1359291158, 1356569027, 1353843265, 1351113878, -1348380873, 1345644259, 1342904042, 1340160229, 1337412829, -1334661848, 1331907293, 1329149173, 1326387494, 1323622264, -1320853490, 1318081180, 1315305341, 1312525981, 1309743106, -1306956725, 1304166845, 1301373473, 1298576617, 1295776285, -1292972483, 1290165219, 1287354501, 1284540337, 1281722734, -1278901699, 1276077240, 1273249364, 1270418080, 1267583394, -1264745315, 1261903850, 1259059006, 1256210791, 1253359213, -1250504279, 1247645998, 1244784376, 1241919421, 1239051142, -1236179545, 1233304638, 1230426430, 1227544927, 1224660138, -1221772070, 1218880731, 1215986128, 1213088271, 1210187165, -1207282819, 1204375241, 1201464439, 1198550419, 1195633191, -1192712762, 1189789140, 1186862332, 1183932347, 1180999192, -1178062875, 1175123404, 1172180786, 1169235031, 1166286145, -1163334137, 1160379014, 1157420784, 1154459456, 1151495036, -1148527534, 1145556957, 1142583313, 1139606610, 1136626856, -1133644058, 1130658226, 1127669367, 1124677488, 1121682598, -1118684705, 1115683818, 1112679943, 1109673089, 1106663264, -1103650476, 1100634734, 1097616045, 1094594417, 1091569858, -1088542378, 1085511982, 1082478681, 1079442481, 1076403392, -1073361420, 1070316575, 1067268864, 1064218296, 1061164879, -1058108621, 1055049529, 1051987613, 1048922881, 1045855340, -1042784999, 1039711867, 1036635950, 1033557259, 1030475800, -1027391582, 1024304614, 1021214903, 1018122458, 1015027288, -1011929400, 1008828802, 1005725504, 1002619513, 999510838, -996399486, 993285468, 990168789, 987049460, 983927488, -980802882, 977675650, 974545800, 971413342, 968278282, -965140630, 962000395, 958857583, 955712205, 952564267, -949413780, 946260750, 943105188, 939947100, 936786495, -933623383, 930457771, 927289668, 924119082, 920946022, -917770497, 914592514, 911412082, 908229211, 905043908, -901856182, 898666041, 895473494, 892278550, 889081217, -885881504, 882679419, 879474970, 876268167, 873059018, -869847532, 866633717, 863417581, 860199134, 856978384, -853755339, 850530009, 847302402, 844072526, 840840390, -837606003, 834369373, 831130510, 827889422, 824646117, -821400604, 818152892, 814902989, 811650905, 808396648, -805140227, 801881649, 798620925, 795358063, 792093072, -788825960, 785556735, 782285408, 779011986, 775736479, -772458895, 769179242, 765897531, 762613768, 759327964, -756040127, 752750266, 749458390, 746164507, 742868626, -739570757, 736270907, 732969086, 729665303, 726359567, -723051885, 719742268, 716430724, 713117261, 709801890, -706484618, 703165455, 699844409, 696521489, 693196705, -689870064, 686541577, 683211252, 679879097, 676545122, -673209336, 669871748, 666532366, 663191199, 659848257, -656503549, 653157082, 649808867, 646458913, 643107227, -639753820, 636398700, 633041876, 629683357, 626323153, -622961271, 619597722, 616232514, 612865656, 609497157, -606127026, 602755273, 599381905, 596006934, 592630366, -589252212, 585872480, 582491179, 579108320, 575723909, -572337957, 568950473, 565561466, 562170945, 558778918, -555385395, 551990386, 548593898, 545195942, 541796526, -538395660, 534993352, 531589612, 528184449, 524777871, -521369889, 517960510, 514549745, 511137603, 507724092, -504309221, 500893000, 497475439, 494056545, 490636329, -487214799, 483791965, 480367835, 476942419, 473515727, -470087766, 466658548, 463228079, 459796371, 456363431, -452929270, 449493896, 446057319, 442619547, 439180590, -435740458, 432299159, 428856702, 425413098, 421968354, -418522481, 415075487, 411627382, 408178175, 404727875, -401276491, 397824033, 394370510, 390915931, 387460306, -384003643, 380545952, 377087242, 373627523, 370166803, -366705093, 363242400, 359778735, 356314107, 352848525, -349381998, 345914536, 342446148, 338976842, 335506630, -332035519, 328563519, 325090639, 321616889, 318142278, -314666815, 311190510, 307713372, 304235410, 300756633, -297277051, 293796673, 290315508, 286833567, 283350857, -279867389, 276383171, 272898214, 269412525, 265926116, -262438995, 258951170, 255462653, 251973452, 248483576, -244993035, 241501838, 238009994, 234517513, 231024404, -227530677, 224036341, 220541404, 217045878, 213549770, -210053090, 206555848, 203058053, 199559715, 196060842, -192561444, 189061531, 185561111, 182060195, 178558791, -175056909, 171554559, 168051749, 164548489, 161044789, -157540658, 154036105, 150531139, 147025770, 143520008, -140013862, 136507340, 133000453, 129493210, 125985621, -122477694, 118969439, 115460866, 111951983, 108442801, -104933329, 101423575, 97913550, 94403263, 90892723, -87381940, 83870923, 80359681, 76848224, 73336562, -69824703, 66312657, 62800433, 59288042, 55775491, -52262792, 48749952, 45236982, 41723891, 38210688, -34697383, 31183985, 27670503, 24156947, 20643327, -17129651, 13615930, 10102172, 6588387, 3074584, --439226, -3953036, -7466835, -10980614, -14494364, --18008075, -21521738, -25035343, -28548881, -32062342, --35575718, -39088999, -42602174, -46115236, -49628175, --53140980, -56653643, -60166155, -63678505, -67190685, --70702685, -74214496, -77726108, -81237512, -84748698, --88259658, -91770381, -95280859, -98791081, -102301039, --105810723, -109320124, -112829232, -116338038, -119846533, --123354707, -126862550, -130370054, -133877209, -137384005, --140890434, -144396485, -147902150, -151407418, -154912282, --158416730, -161920755, -165424346, -168927494, -172430190, --175932424, -179434187, -182935470, -186436263, -189936557, --193436342, -196935610, -200434350, -203932553, -207430211, --210927313, -214423851, -217919814, -221415194, -224909981, --228404166, -231897740, -235390693, -238883015, -242374698, --245865732, -249356108, -252845816, -256334847, -259823192, --263310841, -266797785, -270284015, -273769522, -277254295, --280738326, -284221606, -287704124, -291185873, -294666841, --298147021, -301626403, -305104977, -308582734, -312059665, --315535760, -319011011, -322485408, -325958941, -329431602, --332903380, -336374268, -339844254, -343313331, -346781489, --350248718, -353715010, -357180354, -360644742, -364108165, --367570613, -371032077, -374492547, -377952015, -381410471, --384867905, -388324310, -391779674, -395233990, -398687248, --402139438, -405590552, -409040579, -412489512, -415937340, --419384055, -422829646, -426274106, -429717424, -433159592, --436600601, -440040440, -443479101, -446916575, -450352853, --453787924, -457221781, -460654414, -464085813, -467515970, --470944875, -474372519, -477798893, -481223988, -484647795, --488070304, -491491506, -494911393, -498329954, -501747182, --505163066, -508577597, -511990767, -515402566, -518812985, --522222016, -525629648, -529035873, -532440681, -535844064, --539246012, -542646517, -546045568, -549443158, -552839277, --556233916, -559627065, -563018716, -566408860, -569797488, --573184589, -576570157, -579954180, -583336651, -586717560, --590096899, -593474657, -596850827, -600225398, -603598363, --606969711, -610339435, -613707524, -617073971, -620438765, --623801898, -627163361, -630523145, -633881241, -637237640, --640592333, -643945310, -647296564, -650646085, -653993863, --657339891, -660684159, -664026658, -667367379, -670706313, --674043452, -677378786, -680712307, -684044005, -687373872, --690701898, -694028075, -697352394, -700674846, -703995422, --707314114, -710630911, -713945806, -717258790, -720569853, --723878987, -727186183, -730491433, -733794726, -737096055, --740395410, -743692783, -746988165, -750281547, -753572921, --756862277, -760149606, -763434901, -766718151, -769999349, --773278485, -776555551, -779830538, -783103437, -786374239, --789642936, -792909519, -796173979, -799436307, -802696495, --805954534, -809210416, -812464130, -815715670, -818965026, --822212189, -825457150, -828699902, -831940435, -835178741, --838414810, -841648635, -844880207, -848109516, -851336555, --854561315, -857783787, -861003962, -864221832, -867437388, --870650622, -873861525, -877070088, -880276304, -883480162, --886681655, -889880774, -893077511, -896271856, -899463802, --902653340, -905840461, -909025157, -912207419, -915387239, --918564609, -921739519, -924911961, -928081927, -931249408, --934414396, -937576882, -940736858, -943894315, -947049246, --950201640, -953351491, -956498790, -959643527, -962785695, --965925286, -969062291, -972196701, -975328508, -978457704, --981584280, -984708228, -987829540, -990948208, -994064222, --997177575, -1000288258, -1003396263, -1006501581, -1009604205, --1012704126, -1015801336, -1018895826, -1021987588, -1025076613, --1028162895, -1031246424, -1034327191, -1037405190, -1040480411, --1043552847, -1046622488, -1049689328, -1052753357, -1055814567, --1058872951, -1061928500, -1064981206, -1068031060, -1071078055, --1074122183, -1077163435, -1080201802, -1083237278, -1086269854, --1089299521, -1092326272, -1095350099, -1098370993, -1101388946, --1104403951, -1107415998, -1110425081, -1113431191, -1116434320, --1119434460, -1122431603, -1125425740, -1128416865, -1131404968, --1134390043, -1137372080, -1140351072, -1143327011, -1146299889, --1149269698, -1152236431, -1155200078, -1158160632, -1161118086, --1164072431, -1167023660, -1169971764, -1172916735, -1175858567, --1178797250, -1181732777, -1184665141, -1187594332, -1190520344, --1193443169, -1196362799, -1199279225, -1202192441, -1205102438, --1208009209, -1210912745, -1213813040, -1216710085, -1219603872, --1222494394, -1225381643, -1228265611, -1231146291, -1234023675, --1236897754, -1239768523, -1242635972, -1245500094, -1248360882, --1251218327, -1254072422, -1256923160, -1259770533, -1262614533, --1265455153, -1268292384, -1271126220, -1273956653, -1276783675, --1279607279, -1282427457, -1285244201, -1288057504, -1290867359, --1293673758, -1296476693, -1299276157, -1302072143, -1304864643, --1307653649, -1310439154, -1313221151, -1315999631, -1318774589, --1321546016, -1324313904, -1327078247, -1329839037, -1332596266, --1335349928, -1338100015, -1340846519, -1343589433, -1346328751, --1349064463, -1351796564, -1354525046, -1357249901, -1359971122, --1362688702, -1365402634, -1368112911, -1370819524, -1373522468, --1376221734, -1378917315, -1381609205, -1384297396, -1386981880, --1389662652, -1392339702, -1395013025, -1397682613, -1400348459, --1403010556, -1405668897, -1408323474, -1410974281, -1413621310, --1416264555, -1418904007, -1421539661, -1424171509, -1426799544, --1429423759, -1432044147, -1434660701, -1437273414, -1439882279, --1442487289, -1445088437, -1447685717, -1450279120, -1452868640, --1455454271, -1458036005, -1460613835, -1463187755, -1465757757, --1468323835, -1470885982, -1473444191, -1475998456, -1478548768, --1481095122, -1483637511, -1486175927, -1488710365, -1491240816, --1493767276, -1496289736, -1498808190, -1501322631, -1503833053, --1506339448, -1508841811, -1511340134, -1513834411, -1516324634, --1518810798, -1521292896, -1523770921, -1526244866, -1528714725, --1531180491, -1533642158, -1536099718, -1538553166, -1541002495, --1543447698, -1545888769, -1548325701, -1550758488, -1553187123, --1555611600, -1558031911, -1560448052, -1562860014, -1565267793, --1567671380, -1570070771, -1572465958, -1574856935, -1577243696, --1579626234, -1582004542, -1584378616, -1586748447, -1589114030, --1591475359, -1593832427, -1596185227, -1598533754, -1600878002, --1603217963, -1605553632, -1607885003, -1610212069, -1612534823, --1614853261, -1617167375, -1619477159, -1621782608, -1624083714, --1626380473, -1628672877, -1630960921, -1633244598, -1635523902, --1637798828, -1640069368, -1642335518, -1644597271, -1646854620, --1649107561, -1651356086, -1653600190, -1655839867, -1658075111, --1660305916, -1662532275, -1664754184, -1666971635, -1669184624, --1671393143, -1673597188, -1675796752, -1677991829, -1680182414, --1682368500, -1684550083, -1686727155, -1688899711, -1691067746, --1693231253, -1695390227, -1697544662, -1699694551, -1701839891, --1703980674, -1706116895, -1708248548, -1710375628, -1712498128, --1714616044, -1716729369, -1718838098, -1720942225, -1723041744, --1725136651, -1727226938, -1729312602, -1731393635, -1733470033, --1735541790, -1737608901, -1739671359, -1741729160, -1743782298, --1745830767, -1747874561, -1749913677, -1751948107, -1753977847, --1756002891, -1758023233, -1760038869, -1762049792, -1764055998, --1766057481, -1768054236, -1770046258, -1772033540, -1774016078, --1775993866, -1777966900, -1779935173, -1781898681, -1783857419, --1785811380, -1787760560, -1789704954, -1791644556, -1793579362, --1795509366, -1797434562, -1799354946, -1801270513, -1803181257, --1805087174, -1806988258, -1808884503, -1810775906, -1812662462, --1814544164, -1816421007, -1818292988, -1820160101, -1822022340, --1823879702, -1825732180, -1827579771, -1829422468, -1831260267, --1833093164, -1834921153, -1836744229, -1838562388, -1840375624, --1842183933, -1843987310, -1845785751, -1847579249, -1849367801, --1851151401, -1852930046, -1854703729, -1856472447, -1858236195, --1859994968, -1861748761, -1863497569, -1865241388, -1866980214, --1868714041, -1870442864, -1872166681, -1873885484, -1875599271, --1877308036, -1879011776, -1880710484, -1882404157, -1884092791, --1885776380, -1887454920, -1889128407, -1890796837, -1892460204, --1894118504, -1895771734, -1897419887, -1899062961, -1900700951, --1902333851, -1903961659, -1905584369, -1907201977, -1908814479, --1910421871, -1912024148, -1913621306, -1915213340, -1916800247, --1918382022, -1919958661, -1921530159, -1923096514, -1924657719, --1926213771, -1927764667, -1929310401, -1930850970, -1932386369, --1933916595, -1935441643, -1936961510, -1938476190, -1939985681, --1941489978, -1942989077, -1944482974, -1945971664, -1947455145, --1948933412, -1950406461, -1951874289, -1953336890, -1954794262, --1956246401, -1957693301, -1959134961, -1960571375, -1962002540, --1963428453, -1964849109, -1966264504, -1967674635, -1969079498, --1970479089, -1971873404, -1973262440, -1974646194, -1976024660, --1977397836, -1978765718, -1980128302, -1981485585, -1982837563, --1984184232, -1985525589, -1986861630, -1988192351, -1989517750, --1990837822, -1992152564, -1993461973, -1994766044, -1996064775, --1997358161, -1998646200, -1999928888, -2001206222, -2002478198, --2003744813, -2005006063, -2006261945, -2007512455, -2008757591, --2009997349, -2011231726, -2012460718, -2013684322, -2014902534, --2016115352, -2017322773, -2018524792, -2019721407, -2020912615, --2022098413, -2023278796, -2024453763, -2025623309, -2026787432, --2027946129, -2029099397, -2030247232, -2031389631, -2032526592, --2033658111, -2034784185, -2035904812, -2037019988, -2038129710, --2039233976, -2040332782, -2041426125, -2042514003, -2043596412, --2044673350, -2045744814, -2046810801, -2047871308, -2048926332, --2049975870, -2051019920, -2052058479, -2053091544, -2054119112, --2055141181, -2056157747, -2057168809, -2058174363, -2059174406, --2060168936, -2061157951, -2062141448, -2063119423, -2064091875, --2065058800, -2066020197, -2066976063, -2067926394, -2068871190, --2069810446, -2070744160, -2071672331, -2072594955, -2073512030, --2074423554, -2075329524, -2076229937, -2077124792, -2078014086, --2078897817, -2079775981, -2080648577, -2081515603, -2082377056, --2083232934, -2084083234, -2084927955, -2085767094, -2086600648, --2087428616, -2088250996, -2089067784, -2089878979, -2090684580, --2091484582, -2092278986, -2093067787, -2093850985, -2094628577, --2095400561, -2096166935, -2096927697, -2097682844, -2098432376, --2099176290, -2099914583, -2100647254, -2101374302, -2102095723, --2102811516, -2103521679, -2104226211, -2104925109, -2105618372, --2106305997, -2106987983, -2107664327, -2108335029, -2109000087, --2109659498, -2110313260, -2110961373, -2111603834, -2112240642, --2112871795, -2113497290, -2114117128, -2114731305, -2115339820, --2115942673, -2116539860, -2117131380, -2117717232, -2118297415, --2118871926, -2119440764, -2120003928, -2120561416, -2121113227, --2121659358, -2122199810, -2122734579, -2123263666, -2123787068, --2124304784, -2124816812, -2125323152, -2125823801, -2126318759, --2126808025, -2127291596, -2127769472, -2128241651, -2128708132, --2129168914, -2129623995, -2130073375, -2130517052, -2130955025, --2131387293, -2131813854, -2132234708, -2132649854, -2133059289, --2133463014, -2133861027, -2134253326, -2134639912, -2135020783, --2135395937, -2135765375, -2136129094, -2136487095, -2136839375, --2137185934, -2137526772, -2137861886, -2138191277, -2138514944, --2138832885, -2139145099, -2139451587, -2139752346, -2140047377, --2140336678, -2140620249, -2140898089, -2141170197, -2141436573, --2141697215, -2141952123, -2142201296, -2142444735, -2142682437, --2142914403, -2143140631, -2143361122, -2143575874, -2143784887, --2143988161, -2144185694, -2144377487, -2144563539, -2144743849, --2144918417, -2145087242, -2145250325, -2145407663, -2145559258, --2145705109, -2145845215, -2145979576, -2146108191, -2146231061, --2146348185, -2146459562, -2146565192, -2146665076, -2146759212, --2146847600, -2146930241, -2147007134, -2147078279, -2147143675, --2147203323, -2147257222, -2147305372, -2147347773, -2147384426, --2147415329, -2147440482, -2147459887, -2147473542, -2147481447, -2147483468, 2147469095, 2147431723, 2147371355, 2147287990, -2147181629, 2147052273, 2146899924, 2146724584, 2146526254, -2146304937, 2146060634, 2145793349, 2145503083, 2145189842, -2144853627, 2144494442, 2144112292, 2143707180, 2143279110, -2142828088, 2142354118, 2141857204, 2141337354, 2140794571, -2140228862, 2139640233, 2139028690, 2138394240, 2137736889, -2137056645, 2136353515, 2135627506, 2134878626, 2134106884, -2133312286, 2132494843, 2131654563, 2130791454, 2129905526, -2128996788, 2128065251, 2127110924, 2126133817, 2125133941, -2124111307, 2123065925, 2121997806, 2120906963, 2119793407, -2118657149, 2117498202, 2116316578, 2115112291, 2113885352, -2112635775, 2111363574, 2110068761, 2108751352, 2107411359, -2106048798, 2104663683, 2103256028, 2101825849, 2100373162, -2098897981, 2097400322, 2095880202, 2094337637, 2092772643, -2091185237, 2089575437, 2087943258, 2086288720, 2084611839, -2082912633, 2081191122, 2079447322, 2077681253, 2075892934, -2074082383, 2072249621, 2070394667, 2068517540, 2066618262, -2064696851, 2062753329, 2060787717, 2058800036, 2056790306, -2054758550, 2052704789, 2050629045, 2048531340, 2046411698, -2044270140, 2042106689, 2039921369, 2037714204, 2035485216, -2033234429, 2030961869, 2028667558, 2026351522, 2024013785, -2021654373, 2019273310, 2016870623, 2014446336, 2012000477, -2009533071, 2007044144, 2004533723, 2002001835, 1999448508, -1996873768, 1994277643, 1991660161, 1989021350, 1986361238, -1983679853, 1980977226, 1978253383, 1975508355, 1972742171, -1969954860, 1967146453, 1964316979, 1961466469, 1958594953, -1955702462, 1952789027, 1949854680, 1946899451, 1943923372, -1940926475, 1937908793, 1934870357, 1931811201, 1928731356, -1925630856, 1922509734, 1919368023, 1916205758, 1913022972, -1909819698, 1906595972, 1903351828, 1900087301, 1896802425, -1893497236, 1890171769, 1886826060, 1883460144, 1880074058, -1876667838, 1873241521, 1869795142, 1866328740, 1862842350, -1859336011, 1855809760, 1852263635, 1848697674, 1845111914, -1841506395, 1837881155, 1834236233, 1830571667, 1826887497, -1823183763, 1819460504, 1815717761, 1811955572, 1808173978, -1804373021, 1800552740, 1796713177, 1792854372, 1788976368, -1785079205, 1781162925, 1777227570, 1773273182, 1769299805, -1765307479, 1761296249, 1757266156, 1753217244, 1749149557, -1745063138, 1740958031, 1736834279, 1732691928, 1728531020, -1724351602, 1720153717, 1715937410, 1711702727, 1707449714, -1703178415, 1698888876, 1694581143, 1690255263, 1685911282, -1681549245, 1677169201, 1672771196, 1668355276, 1663921490, -1659469885, 1655000508, 1650513407, 1646008631, 1641486227, -1636946244, 1632388731, 1627813736, 1623221309, 1618611498, -1613984353, 1609339924, 1604678260, 1599999411, 1595303428, -1590590360, 1585860258, 1581113173, 1576349155, 1571568256, -1566770527, 1561956018, 1557124783, 1552276872, 1547412337, -1542531231, 1537633606, 1532719513, 1527789007, 1522842139, -1517878963, 1512899531, 1507903898, 1502892116, 1497864239, -1492820322, 1487760417, 1482684580, 1477592864, 1472485325, -1467362016, 1462222994, 1457068312, 1451898025, 1446712191, -1441510863, 1436294098, 1431061951, 1425814478, 1420551737, -1415273782, 1409980671, 1404672460, 1399349206, 1394010966, -1388657798, 1383289758, 1377906904, 1372509294, 1367096986, -1361670037, 1356228505, 1350772450, 1345301929, 1339817000, -1334317724, 1328804158, 1323276361, 1317734393, 1312178313, -1306608181, 1301024057, 1295425999, 1289814068, 1284188325, -1278548828, 1272895640, 1267228820, 1261548429, 1255854528, -1250147177, 1244426439, 1238692373, 1232945043, 1227184508, -1221410831, 1215624074, 1209824299, 1204011567, 1198185941, -1192347484, 1186496258, 1180632325, 1174755748, 1168866591, -1162964917, 1157050787, 1151124267, 1145185419, 1139234307, -1133270995, 1127295547, 1121308026, 1115308496, 1109297023, -1103273670, 1097238502, 1091191583, 1085132978, 1079062753, -1072980972, 1066887699, 1060783002, 1054666944, 1048539592, -1042401010, 1036251266, 1030090423, 1023918550, 1017735711, -1011541973, 1005337402, 999122065, 992896028, 986659358, -980412122, 974154386, 967886217, 961607684, 955318852, -949019790, 942710564, 936391243, 930061894, 923722585, -917373383, 911014357, 904645574, 898267104, 891879014, -885481373, 879074249, 872657710, 866231826, 859796666, -853352298, 846898791, 840436214, 833964638, 827484130, -820994760, 814496598, 807989714, 801474176, 794950056, -788417422, 781876345, 775326894, 768769141, 762203154, -755629005, 749046764, 742456501, 735858287, 729252193, -722638289, 716016646, 709387335, 702750427, 696105993, -689454104, 682794832, 676128248, 669454423, 662773428, -656085336, 649390218, 642688145, 635979190, 629263424, -622540918, 615811746, 609075979, 602333690, 595584950, -588829831, 582068407, 575300749, 568526931, 561747023, -554961100, 548169234, 541371497, 534567963, 527758704, -520943793, 514123303, 507297307, 500465878, 493629090, -486787016, 479939728, 473087301, 466229807, 459367320, -452499914, 445627662, 438750638, 431868915, 424982567, -418091668, 411196291, 404296511, 397392401, 390484035, -383571488, 376654833, 369734144, 362809495, 355880961, -348948616, 342012534, 335072790, 328129457, 321182610, -314232323, 307278671, 300321729, 293361570, 286398270, -279431902, 272462542, 265490265, 258515144, 251537254, -244556671, 237573469, 230587722, 223599506, 216608896, -209615966, 202620791, 195623446, 188624006, 181622546, -174619141, 167613866, 160606796, 153598006, 146587571, -139575567, 132562067, 125547148, 118530885, 111513352, -104494625, 97474778, 90453888, 83432030, 76409277, -69385707, 62361393, 55336412, 48310838, 41284746, -34258213, 27231312, 20204120, 13176712, 6149162, --878453, -7906059, -14933580, -21960942, -28988068, --36014884, -43041314, -50067283, -57092716, -64117537, --71141672, -78165045, -85187581, -92209205, -99229841, --106249414, -113267850, -120285073, -127301007, -134315578, --141328711, -148340330, -155350361, -162358728, -169365356, --176370170, -183373096, -190374058, -197372981, -204369791, --211364411, -218356769, -225346788, -232334393, -239319511, --246302065, -253281982, -260259186, -267233603, -274205159, --281173778, -288139385, -295101907, -302061269, -309017396, --315970213, -322919647, -329865622, -336808065, -343746901, --350682056, -357613455, -364541025, -371464690, -378384377, --385300013, -392211522, -399118830, -406021865, -412920551, --419814815, -426704583, -433589782, -440470337, -447346176, --454217223, -461083406, -467944652, -474800886, -481652035, --488498026, -495338786, -502174241, -509004318, -515828944, --522648046, -529461551, -536269386, -543071478, -549867754, --556658141, -563442567, -570220959, -576993244, -583759350, --590519205, -597272736, -604019870, -610760536, -617494660, --624222173, -630943000, -637657070, -644364312, -651064652, --657758021, -664444345, -671123554, -677795576, -684460338, --691117771, -697767803, -704410362, -711045377, -717672778, --724292493, -730904451, -737508582, -744104815, -750693079, --757273304, -763845419, -770409354, -776965038, -783512402, --790051375, -796581887, -803103868, -809617249, -816121959, --822617929, -829105090, -835583372, -842052705, -848513021, --854964249, -861406322, -867839170, -874262724, -880676915, --887081675, -893476935, -899862626, -906238681, -912605031, --918961607, -925308342, -931645168, -937972016, -944288820, --950595511, -956892022, -963178285, -969454234, -975719800, --981974918, -988219519, -994453537, -1000676905, -1006889557, --1013091426, -1019282445, -1025462549, -1031631671, -1037789745, --1043936705, -1050072485, -1056197020, -1062310244, -1068412091, --1074502497, -1080581395, -1086648722, -1092704411, -1098748398, --1104780618, -1110801008, -1116809501, -1122806034, -1128790543, --1134762964, -1140723232, -1146671283, -1152607055, -1158530484, --1164441505, -1170340057, -1176226074, -1182099496, -1187960258, --1193808298, -1199643553, -1205465961, -1211275460, -1217071986, --1222855479, -1228625876, -1234383115, -1240127136, -1245857875, --1251575272, -1257279266, -1262969796, -1268646800, -1274310217, --1279959989, -1285596052, -1291218348, -1296826816, -1302421396, --1308002029, -1313568653, -1319121210, -1324659641, -1330183885, --1335693885, -1341189580, -1346670912, -1352137822, -1357590252, --1363028143, -1368451438, -1373860077, -1379254004, -1384633159, --1389997487, -1395346928, -1400681427, -1406000925, -1411305366, --1416594694, -1421868850, -1427127780, -1432371426, -1437599733, --1442812644, -1448010104, -1453192057, -1458358447, -1463509220, --1468644319, -1473763690, -1478867279, -1483955030, -1489026889, --1494082802, -1499122714, -1504146572, -1509154322, -1514145910, --1519121283, -1524080387, -1529023170, -1533949577, -1538859558, --1543753058, -1548630027, -1553490410, -1558334157, -1563161216, --1567971534, -1572765060, -1577541744, -1582301533, -1587044377, --1591770225, -1596479027, -1601170732, -1605845289, -1610502649, --1615142762, -1619765578, -1624371047, -1628959121, -1633529750, --1638082885, -1642618478, -1647136479, -1651636841, -1656119516, --1660584454, -1665031609, -1669460933, -1673872378, -1678265898, --1682641444, -1686998971, -1691338432, -1695659779, -1699962968, --1704247951, -1708514683, -1712763118, -1716993211, -1721204917, --1725398189, -1729572984, -1733729257, -1737866963, -1741986057, --1746086497, -1750168237, -1754231234, -1758275445, -1762300826, --1766307335, -1770294927, -1774263561, -1778213194, -1782143784, --1786055289, -1789947667, -1793820875, -1797674873, -1801509620, --1805325074, -1809121194, -1812897940, -1816655271, -1820393147, --1824111529, -1827810376, -1831489648, -1835149306, -1838789312, --1842409625, -1846010208, -1849591022, -1853152028, -1856693188, --1860214464, -1863715819, -1867197215, -1870658615, -1874099982, --1877521279, -1880922469, -1884303515, -1887664383, -1891005035, --1894325435, -1897625550, -1900905342, -1904164776, -1907403819, --1910622435, -1913820590, -1916998250, -1920155379, -1923291946, --1926407915, -1929503255, -1932577931, -1935631910, -1938665161, --1941677650, -1944669345, -1947640214, -1950590226, -1953519348, --1956427550, -1959314800, -1962181067, -1965026321, -1967850531, --1970653667, -1973435699, -1976196596, -1978936331, -1981654873, --1984352192, -1987028261, -1989683050, -1992316532, -1994928677, --1997519459, -2000088848, -2002636818, -2005163342, -2007668391, --2010151941, -2012613963, -2015054432, -2017473321, -2019870604, --2022246257, -2024600252, -2026932566, -2029243173, -2031532049, --2033799168, -2036044507, -2038268042, -2040469748, -2042649603, --2044807583, -2046943664, -2049057824, -2051150040, -2053220291, --2055268553, -2057294804, -2059299024, -2061281190, -2063241282, --2065179277, -2067095157, -2068988899, -2070860485, -2072709893, --2074537104, -2076342098, -2078124857, -2079885360, -2081623590, --2083339527, -2085033153, -2086704450, -2088353400, -2089979985, --2091584189, -2093165993, -2094725382, -2096262337, -2097776843, --2099268884, -2100738443, -2102185505, -2103610054, -2105012075, --2106391553, -2107748474, -2109082822, -2110394584, -2111683744, --2112950291, -2114194210, -2115415487, -2116614110, -2117790065, --2118943341, -2120073924, -2121181804, -2122266967, -2123329402, --2124369098, -2125386044, -2126380229, -2127351642, -2128300272, --2129226111, -2130129147, -2131009371, -2131866773, -2132701345, --2133513078, -2134301962, -2135067990, -2135811153, -2136531442, --2137228852, -2137903373, -2138555000, -2139183723, -2139789539, --2140372438, -2140932416, -2141469466, -2141983583, -2142474761, --2142942995, -2143388280, -2143810610, -2144209982, -2144586392, --2144939834, -2145270306, -2145577804, -2145862324, -2146123864, --2146362421, -2146577992, -2146770575, -2146940167, -2147086768, --2147210375, -2147310987, -2147388603, -2147443222, -2147474844, -2147482929, 2147425435, 2147275952, 2147034487, 2146701050, -2146275656, 2145758322, 2145149071, 2144447929, 2143654926, -2142770096, 2141793477, 2140725111, 2139565043, 2138313323, -2136970005, 2135535146, 2134008809, 2132391057, 2130681961, -2128881593, 2126990031, 2125007356, 2122933653, 2120769010, -2118513521, 2116167282, 2113730393, 2111202959, 2108585087, -2105876892, 2103078487, 2100189994, 2097211535, 2094143239, -2090985237, 2087737664, 2084400659, 2080974365, 2077458929, -2073854502, 2070161238, 2066379295, 2062508835, 2058550025, -2054503033, 2050368032, 2046145201, 2041834720, 2037436773, -2032951550, 2028379241, 2023720043, 2018974156, 2014141783, -2009223131, 2004218410, 1999127836, 1993951625, 1988690000, -1983343186, 1977911412, 1972394912, 1966793920, 1961108677, -1955339428, 1949486417, 1943549898, 1937530123, 1931427351, -1925241843, 1918973864, 1912623682, 1906191570, 1899677803, -1893082661, 1886406424, 1879649381, 1872811820, 1865894033, -1858896318, 1851818974, 1844662304, 1837426615, 1830112217, -1822719423, 1815248550, 1807699917, 1800073849, 1792370671, -1784590714, 1776734311, 1768801799, 1760793518, 1752709809, -1744551021, 1736317502, 1728009604, 1719627685, 1711172102, -1702643219, 1694041400, 1685367013, 1676620432, 1667802029, -1658912184, 1649951276, 1640919689, 1631817811, 1622646032, -1613404744, 1604094343, 1594715227, 1585267800, 1575752465, -1566169630, 1556519705, 1546803104, 1537020244, 1527171542, -1517257422, 1507278307, 1497234626, 1487126808, 1476955286, -1466720497, 1456422878, 1446062871, 1435640919, 1425157469, -1414612971, 1404007875, 1393342636, 1382617710, 1371833558, -1360990642, 1350089425, 1339130374, 1328113960, 1317040654, -1305910930, 1294725265, 1283484138, 1272188032, 1260837429, -1249432816, 1237974681, 1226463516, 1214899813, 1203284068, -1191616778, 1179898443, 1168129565, 1156310649, 1144442200, -1132524727, 1120558740, 1108544752, 1096483278, 1084374834, -1072219940, 1060019115, 1047772882, 1035481766, 1023146293, -1010766993, 998344394, 985879030, 973371434, 960822142, -948231691, 935600622, 922929474, 910218791, 897469118, -884680999, 871854984, 858991622, 846091463, 833155061, -820182969, 807175743, 794133941, 781058120, 767948841, -754806666, 741632158, 728425880, 715188400, 701920283, -688622098, 675294414, 661937804, 648552838, 635140090, -621700135, 608233549, 594740907, 581222789, 567679774, -554112440, 540521371, 526907147, 513270353, 499611571, -485931388, 472230390, 458509162, 444768294, 431008373, -417229989, 403433732, 389620194, 375789965, 361943639, -348081809, 334205068, 320314011, 306409232, 292491328, -278560894, 264618528, 250664827, 236700388, 222725809, -208741690, 194748629, 180747225, 166738079, 152721790, -138698959, 124670187, 110636075, 96597223, 82554233, -68507707, 54458246, 40406452, 26352928, 12298274, --1756906, -15812011, -29866438, -43919586, -57970853, --72019637, -86065335, -100107347, -114145071, -128177904, --142205248, -156226499, -170241059, -184248325, -198247699, --212238581, -226220372, -240192472, -254154282, -268105206, --282044645, -295972002, -309886680, -323788084, -337675619, --351548688, -365406698, -379249055, -393075166, -406884440, --420676284, -434450107, -448205320, -461941333, -475657559, --489353409, -503028296, -516681636, -530312842, -543921332, --557506522, -571067830, -584604676, -598116479, -611602660, --625062643, -638495850, -651901706, -665279637, -678629069, --691949432, -705240153, -718500664, -731730397, -744928785, --758095263, -771229267, -784330234, -797397602, -810430813, --823429308, -836392529, -849319923, -862210934, -875065011, --887881603, -900660162, -913400139, -926100989, -938762167, --951383133, -963963344, -976502263, -988999351, -1001454074, --1013865898, -1026234291, -1038558724, -1050838668, -1063073598, --1075262990, -1087406320, -1099503070, -1111552721, -1123554757, --1135508663, -1147413928, -1159270041, -1171076495, -1182832785, --1194538405, -1206192856, -1217795637, -1229346252, -1240844206, --1252289006, -1263680162, -1275017186, -1286299593, -1297526899, --1308698624, -1319814288, -1330873416, -1341875533, -1352820169, --1363706855, -1374535124, -1385304512, -1396014559, -1406664805, --1417254794, -1427784073, -1438252190, -1448658697, -1459003149, --1469285102, -1479504115, -1489659751, -1499751576, -1509779156, --1519742062, -1529639867, -1539472148, -1549238483, -1558938453, --1568571644, -1578137643, -1587636039, -1597066426, -1606428400, --1615721561, -1624945509, -1634099849, -1643184191, -1652198144, --1661141322, -1670013342, -1678813825, -1687542393, -1696198672, --1704782292, -1713292884, -1721730085, -1730093532, -1738382868, --1746597738, -1754737789, -1762802673, -1770792044, -1778705561, --1786542883, -1794303676, -1801987607, -1809594347, -1817123570, --1824574954, -1831948179, -1839242929, -1846458892, -1853595759, --1860653224, -1867630985, -1874528743, -1881346202, -1888083070, --1894739060, -1901313885, -1907807264, -1914218919, -1920548575, --1926795962, -1932960811, -1939042858, -1945041843, -1950957509, --1956789602, -1962537873, -1968202076, -1973781967, -1979277308, --1984687864, -1990013401, -1995253694, -2000408516, -2005477648, --2010460871, -2015357973, -2020168744, -2024892978, -2029530472, --2034081027, -2038544449, -2042920547, -2047209133, -2051410023, --2055523038, -2059548001, -2063484740, -2067333086, -2071092874, --2074763944, -2078346137, -2081839301, -2085243286, -2088557947, --2091783140, -2094918728, -2097964577, -2100920556, -2103786539, --2106562402, -2109248028, -2111843300, -2114348108, -2116762344, --2119085905, -2121318692, -2123460608, -2125511562, -2127471467, --2129340237, -2131117794, -2132804061, -2134398966, -2135902440, --2137314419, -2138634843, -2139863654, -2141000801, -2142046235, --2142999911, -2143861787, -2144631828, -2145310000, -2145896274, --2146390624, -2146793031, -2147103476, -2147321946, -2147448433, -2147480773, 2147250799, 2146652904, 2145687192, 2144353827, -2142653038, 2140585116, 2138150417, 2135349356, 2132182414, -2128650133, 2124753120, 2120492040, 2115867626, 2110880668, -2105532022, 2099822604, 2093753392, 2087325426, 2080539807, -2073397699, 2065900325, 2058048970, 2049844978, 2041289756, -2032384769, 2023131544, 2013531666, 2003586779, 1993298588, -1982668856, 1971699403, 1960392110, 1948748914, 1936771810, -1924462850, 1911824143, 1898857855, 1885566207, 1871951478, -1858015999, 1843762158, 1829192399, 1814309216, 1799115162, -1783612838, 1767804901, 1751694060, 1735283075, 1718574758, -1701571972, 1684277631, 1666694698, 1648826185, 1630675154, -1612244715, 1593538026, 1574558293, 1555308768, 1535792748, -1516013578, 1495974647, 1475679389, 1455131280, 1434333842, -1413290638, 1392005275, 1370481398, 1348722696, 1326732898, -1304515771, 1282075122, 1259414796, 1236538675, 1213450681, -1190154767, 1166654927, 1142955186, 1119059606, 1094972281, -1070697338, 1046238936, 1021601267, 996788551, 971805042, -946655018, 921342790, 895872694, 870249095, 844476384, -818558976, 792501312, 766307857, 739983099, 713531549, -686957739, 660266222, 633461572, 606548381, 579531262, -552414843, 525203770, 497902707, 470516330, 443049333, -415506422, 387892316, 360211746, 332469456, 304670200, -276818739, 248919847, 220978304, 192998897, 164986421, -136945676, 108881465, 80798598, 52701887, 24596146, --3513810, -31623164, -59727099, -87820801, -115899455, --143958250, -171992378, -199997036, -227967426, -255898755, --283786237, -311625094, -339410555, -367137861, -394802258, --422399009, -449923384, -477370666, -504736154, -532015158, --559203003, -586295032, -613286603, -640173090, -666949886, --693612404, -720156076, -746576352, -772868706, -799028633, --825051651, -850933300, -876669146, -902254780, -927685817, --952957899, -978066697, -1003007909, -1027777260, -1052370507, --1076783436, -1101011863, -1125051638, -1148898640, -1172548785, --1195998020, -1219242327, -1242277723, -1265100260, -1287706030, --1310091157, -1332251808, -1354184184, -1375884527, -1397349119, --1418574283, -1439556382, -1460291820, -1480777044, -1501008545, --1520982856, -1540696555, -1560146263, -1579328647, -1598240423, --1616878347, -1635239228, -1653319919, -1671117323, -1688628389, --1705850117, -1722779556, -1739413807, -1755750017, -1771785389, --1787517174, -1802942678, -1818059257, -1832864320, -1847355332, --1861529809, -1875385322, -1888919498, -1902130017, -1915014616, --1927571087, -1939797279, -1951691096, -1963250501, -1974473513, --1985358210, -1995902725, -2006105253, -2015964045, -2025477412, --2034643724, -2043461410, -2051928960, -2060044922, -2067807906, --2075216581, -2082269679, -2088965991, -2095304370, -2101283728, --2106903043, -2112161350, -2117057750, -2121591402, -2125761531, --2129567422, -2133008422, -2136083942, -2138793455, -2141136497, --2143112666, -2144721624, -2145963095, -2146836866, -2147342788, -#else -32767, 32767, 32767, 32767, 32767, -32767, 32766, 32766, 32765, 32764, -32764, 32763, 32762, 32760, 32759, -32758, 32757, 32755, 32754, 32752, -32750, 32748, 32747, 32745, 32742, -32740, 32738, 32736, 32733, 32731, -32728, 32726, 32723, 32720, 32717, -32714, 32711, 32708, 32704, 32701, -32697, 32694, 32690, 32686, 32683, -32679, 32675, 32671, 32666, 32662, -32658, 32653, 32649, 32644, 32640, -32635, 32630, 32625, 32620, 32615, -32610, 32604, 32599, 32593, 32588, -32582, 32576, 32571, 32565, 32559, -32553, 32546, 32540, 32534, 32527, -32521, 32514, 32507, 32501, 32494, -32487, 32480, 32473, 32465, 32458, -32451, 32443, 32436, 32428, 32420, -32412, 32404, 32396, 32388, 32380, -32372, 32364, 32355, 32347, 32338, -32329, 32320, 32312, 32303, 32294, -32284, 32275, 32266, 32257, 32247, -32237, 32228, 32218, 32208, 32198, -32188, 32178, 32168, 32158, 32147, -32137, 32127, 32116, 32105, 32094, -32084, 32073, 32062, 32051, 32039, -32028, 32017, 32005, 31994, 31982, -31970, 31959, 31947, 31935, 31923, -31910, 31898, 31886, 31874, 31861, -31848, 31836, 31823, 31810, 31797, -31784, 31771, 31758, 31745, 31732, -31718, 31705, 31691, 31677, 31664, -31650, 31636, 31622, 31608, 31593, -31579, 31565, 31550, 31536, 31521, -31507, 31492, 31477, 31462, 31447, -31432, 31417, 31401, 31386, 31371, -31355, 31339, 31324, 31308, 31292, -31276, 31260, 31244, 31228, 31212, -31195, 31179, 31162, 31146, 31129, -31112, 31095, 31078, 31061, 31044, -31027, 31010, 30992, 30975, 30957, -30940, 30922, 30904, 30886, 30868, -30850, 30832, 30814, 30796, 30777, -30759, 30740, 30722, 30703, 30684, -30665, 30646, 30627, 30608, 30589, -30570, 30551, 30531, 30512, 30492, -30472, 30453, 30433, 30413, 30393, -30373, 30353, 30332, 30312, 30292, -30271, 30251, 30230, 30209, 30188, -30167, 30146, 30125, 30104, 30083, -30062, 30040, 30019, 29997, 29976, -29954, 29932, 29910, 29889, 29867, -29844, 29822, 29800, 29778, 29755, -29733, 29710, 29687, 29665, 29642, -29619, 29596, 29573, 29550, 29527, -29503, 29480, 29457, 29433, 29409, -29386, 29362, 29338, 29314, 29290, -29266, 29242, 29218, 29193, 29169, -29145, 29120, 29095, 29071, 29046, -29021, 28996, 28971, 28946, 28921, -28896, 28870, 28845, 28819, 28794, -28768, 28743, 28717, 28691, 28665, -28639, 28613, 28587, 28560, 28534, -28508, 28481, 28455, 28428, 28401, -28375, 28348, 28321, 28294, 28267, -28240, 28212, 28185, 28158, 28130, -28103, 28075, 28047, 28020, 27992, -27964, 27936, 27908, 27880, 27851, -27823, 27795, 27766, 27738, 27709, -27681, 27652, 27623, 27594, 27565, -27536, 27507, 27478, 27449, 27419, -27390, 27360, 27331, 27301, 27272, -27242, 27212, 27182, 27152, 27122, -27092, 27062, 27032, 27001, 26971, -26940, 26910, 26879, 26848, 26818, -26787, 26756, 26725, 26694, 26663, -26631, 26600, 26569, 26537, 26506, -26474, 26443, 26411, 26379, 26347, -26316, 26284, 26251, 26219, 26187, -26155, 26123, 26090, 26058, 26025, -25993, 25960, 25927, 25894, 25861, -25828, 25795, 25762, 25729, 25696, -25663, 25629, 25596, 25562, 25529, -25495, 25461, 25428, 25394, 25360, -25326, 25292, 25258, 25223, 25189, -25155, 25120, 25086, 25051, 25017, -24982, 24947, 24913, 24878, 24843, -24808, 24773, 24738, 24702, 24667, -24632, 24596, 24561, 24525, 24490, -24454, 24419, 24383, 24347, 24311, -24275, 24239, 24203, 24167, 24130, -24094, 24058, 24021, 23985, 23948, -23912, 23875, 23838, 23801, 23764, -23728, 23690, 23653, 23616, 23579, -23542, 23504, 23467, 23430, 23392, -23355, 23317, 23279, 23241, 23204, -23166, 23128, 23090, 23052, 23014, -22975, 22937, 22899, 22860, 22822, -22783, 22745, 22706, 22668, 22629, -22590, 22551, 22512, 22473, 22434, -22395, 22356, 22317, 22277, 22238, -22199, 22159, 22120, 22080, 22040, -22001, 21961, 21921, 21881, 21841, -21801, 21761, 21721, 21681, 21641, -21600, 21560, 21520, 21479, 21439, -21398, 21357, 21317, 21276, 21235, -21194, 21153, 21112, 21071, 21030, -20989, 20948, 20907, 20865, 20824, -20783, 20741, 20700, 20658, 20616, -20575, 20533, 20491, 20449, 20407, -20365, 20323, 20281, 20239, 20197, -20155, 20112, 20070, 20028, 19985, -19943, 19900, 19857, 19815, 19772, -19729, 19686, 19643, 19601, 19558, -19514, 19471, 19428, 19385, 19342, -19298, 19255, 19212, 19168, 19125, -19081, 19038, 18994, 18950, 18906, -18863, 18819, 18775, 18731, 18687, -18643, 18599, 18554, 18510, 18466, -18422, 18377, 18333, 18288, 18244, -18199, 18155, 18110, 18065, 18021, -17976, 17931, 17886, 17841, 17796, -17751, 17706, 17661, 17616, 17570, -17525, 17480, 17434, 17389, 17344, -17298, 17252, 17207, 17161, 17116, -17070, 17024, 16978, 16932, 16886, -16840, 16794, 16748, 16702, 16656, -16610, 16564, 16517, 16471, 16425, -16378, 16332, 16285, 16239, 16192, -16145, 16099, 16052, 16005, 15958, -15912, 15865, 15818, 15771, 15724, -15677, 15630, 15583, 15535, 15488, -15441, 15394, 15346, 15299, 15251, -15204, 15156, 15109, 15061, 15014, -14966, 14918, 14870, 14823, 14775, -14727, 14679, 14631, 14583, 14535, -14487, 14439, 14391, 14342, 14294, -14246, 14198, 14149, 14101, 14053, -14004, 13956, 13907, 13858, 13810, -13761, 13713, 13664, 13615, 13566, -13517, 13469, 13420, 13371, 13322, -13273, 13224, 13175, 13126, 13076, -13027, 12978, 12929, 12880, 12830, -12781, 12731, 12682, 12633, 12583, -12534, 12484, 12434, 12385, 12335, -12285, 12236, 12186, 12136, 12086, -12037, 11987, 11937, 11887, 11837, -11787, 11737, 11687, 11637, 11586, -11536, 11486, 11436, 11386, 11335, -11285, 11235, 11184, 11134, 11083, -11033, 10982, 10932, 10881, 10831, -10780, 10729, 10679, 10628, 10577, -10527, 10476, 10425, 10374, 10323, -10272, 10221, 10170, 10119, 10068, -10017, 9966, 9915, 9864, 9813, -9762, 9711, 9659, 9608, 9557, -9506, 9454, 9403, 9352, 9300, -9249, 9197, 9146, 9094, 9043, -8991, 8940, 8888, 8836, 8785, -8733, 8681, 8630, 8578, 8526, -8475, 8423, 8371, 8319, 8267, -8215, 8163, 8111, 8059, 8007, -7955, 7903, 7851, 7799, 7747, -7695, 7643, 7591, 7539, 7487, -7434, 7382, 7330, 7278, 7225, -7173, 7121, 7068, 7016, 6964, -6911, 6859, 6806, 6754, 6701, -6649, 6596, 6544, 6491, 6439, -6386, 6334, 6281, 6228, 6176, -6123, 6070, 6018, 5965, 5912, -5859, 5807, 5754, 5701, 5648, -5595, 5543, 5490, 5437, 5384, -5331, 5278, 5225, 5172, 5119, -5066, 5013, 4960, 4907, 4854, -4801, 4748, 4695, 4642, 4589, -4536, 4483, 4430, 4377, 4324, -4270, 4217, 4164, 4111, 4058, -4005, 3951, 3898, 3845, 3792, -3738, 3685, 3632, 3578, 3525, -3472, 3419, 3365, 3312, 3259, -3205, 3152, 3098, 3045, 2992, -2938, 2885, 2831, 2778, 2725, -2671, 2618, 2564, 2511, 2457, -2404, 2350, 2297, 2243, 2190, -2136, 2083, 2029, 1976, 1922, -1869, 1815, 1762, 1708, 1655, -1601, 1548, 1494, 1440, 1387, -1333, 1280, 1226, 1173, 1119, -1065, 1012, 958, 905, 851, -797, 744, 690, 637, 583, -529, 476, 422, 369, 315, -261, 208, 154, 101, 47, --7, -60, -114, -168, -221, --275, -328, -382, -436, -489, --543, -596, -650, -704, -757, --811, -864, -918, -972, -1025, --1079, -1132, -1186, -1240, -1293, --1347, -1400, -1454, -1507, -1561, --1615, -1668, -1722, -1775, -1829, --1882, -1936, -1989, -2043, -2096, --2150, -2203, -2257, -2310, -2364, --2417, -2471, -2524, -2578, -2631, --2685, -2738, -2791, -2845, -2898, --2952, -3005, -3058, -3112, -3165, --3218, -3272, -3325, -3379, -3432, --3485, -3538, -3592, -3645, -3698, --3752, -3805, -3858, -3911, -3965, --4018, -4071, -4124, -4177, -4231, --4284, -4337, -4390, -4443, -4496, --4549, -4602, -4656, -4709, -4762, --4815, -4868, -4921, -4974, -5027, --5080, -5133, -5186, -5239, -5291, --5344, -5397, -5450, -5503, -5556, --5609, -5662, -5714, -5767, -5820, --5873, -5925, -5978, -6031, -6083, --6136, -6189, -6241, -6294, -6347, --6399, -6452, -6504, -6557, -6609, --6662, -6714, -6767, -6819, -6872, --6924, -6977, -7029, -7081, -7134, --7186, -7238, -7291, -7343, -7395, --7447, -7500, -7552, -7604, -7656, --7708, -7760, -7812, -7864, -7916, --7968, -8020, -8072, -8124, -8176, --8228, -8280, -8332, -8384, -8436, --8487, -8539, -8591, -8643, -8694, --8746, -8798, -8849, -8901, -8953, --9004, -9056, -9107, -9159, -9210, --9262, -9313, -9364, -9416, -9467, --9518, -9570, -9621, -9672, -9723, --9775, -9826, -9877, -9928, -9979, --10030, -10081, -10132, -10183, -10234, --10285, -10336, -10387, -10438, -10488, --10539, -10590, -10641, -10691, -10742, --10793, -10843, -10894, -10945, -10995, --11046, -11096, -11146, -11197, -11247, --11298, -11348, -11398, -11448, -11499, --11549, -11599, -11649, -11699, -11749, --11799, -11849, -11899, -11949, -11999, --12049, -12099, -12149, -12198, -12248, --12298, -12348, -12397, -12447, -12496, --12546, -12595, -12645, -12694, -12744, --12793, -12843, -12892, -12941, -12990, --13040, -13089, -13138, -13187, -13236, --13285, -13334, -13383, -13432, -13481, --13530, -13579, -13627, -13676, -13725, --13773, -13822, -13871, -13919, -13968, --14016, -14065, -14113, -14161, -14210, --14258, -14306, -14355, -14403, -14451, --14499, -14547, -14595, -14643, -14691, --14739, -14787, -14835, -14882, -14930, --14978, -15025, -15073, -15121, -15168, --15216, -15263, -15311, -15358, -15405, --15453, -15500, -15547, -15594, -15641, --15689, -15736, -15783, -15830, -15876, --15923, -15970, -16017, -16064, -16110, --16157, -16204, -16250, -16297, -16343, --16390, -16436, -16483, -16529, -16575, --16621, -16668, -16714, -16760, -16806, --16852, -16898, -16944, -16990, -17035, --17081, -17127, -17173, -17218, -17264, --17309, -17355, -17400, -17446, -17491, --17536, -17582, -17627, -17672, -17717, --17762, -17807, -17852, -17897, -17942, --17987, -18032, -18077, -18121, -18166, --18210, -18255, -18300, -18344, -18388, --18433, -18477, -18521, -18566, -18610, --18654, -18698, -18742, -18786, -18830, --18874, -18917, -18961, -19005, -19048, --19092, -19136, -19179, -19223, -19266, --19309, -19353, -19396, -19439, -19482, --19525, -19568, -19611, -19654, -19697, --19740, -19783, -19825, -19868, -19911, --19953, -19996, -20038, -20081, -20123, --20165, -20207, -20250, -20292, -20334, --20376, -20418, -20460, -20502, -20543, --20585, -20627, -20668, -20710, -20752, --20793, -20834, -20876, -20917, -20958, --20999, -21041, -21082, -21123, -21164, --21205, -21245, -21286, -21327, -21368, --21408, -21449, -21489, -21530, -21570, --21610, -21651, -21691, -21731, -21771, --21811, -21851, -21891, -21931, -21971, --22011, -22050, -22090, -22130, -22169, --22208, -22248, -22287, -22326, -22366, --22405, -22444, -22483, -22522, -22561, --22600, -22639, -22677, -22716, -22755, --22793, -22832, -22870, -22908, -22947, --22985, -23023, -23061, -23099, -23137, --23175, -23213, -23251, -23289, -23326, --23364, -23402, -23439, -23476, -23514, --23551, -23588, -23626, -23663, -23700, --23737, -23774, -23811, -23847, -23884, --23921, -23957, -23994, -24030, -24067, --24103, -24139, -24176, -24212, -24248, --24284, -24320, -24356, -24392, -24427, --24463, -24499, -24534, -24570, -24605, --24641, -24676, -24711, -24746, -24782, --24817, -24852, -24886, -24921, -24956, --24991, -25025, -25060, -25095, -25129, --25163, -25198, -25232, -25266, -25300, --25334, -25368, -25402, -25436, -25470, --25503, -25537, -25571, -25604, -25638, --25671, -25704, -25737, -25771, -25804, --25837, -25870, -25902, -25935, -25968, --26001, -26033, -26066, -26098, -26131, --26163, -26195, -26227, -26259, -26292, --26323, -26355, -26387, -26419, -26451, --26482, -26514, -26545, -26577, -26608, --26639, -26670, -26702, -26733, -26764, --26794, -26825, -26856, -26887, -26917, --26948, -26978, -27009, -27039, -27069, --27100, -27130, -27160, -27190, -27220, --27249, -27279, -27309, -27338, -27368, --27397, -27427, -27456, -27485, -27514, --27543, -27572, -27601, -27630, -27659, --27688, -27716, -27745, -27773, -27802, --27830, -27858, -27887, -27915, -27943, --27971, -27999, -28026, -28054, -28082, --28109, -28137, -28164, -28192, -28219, --28246, -28273, -28301, -28328, -28354, --28381, -28408, -28435, -28461, -28488, --28514, -28541, -28567, -28593, -28619, --28645, -28671, -28697, -28723, -28749, --28775, -28800, -28826, -28851, -28877, --28902, -28927, -28952, -28977, -29002, --29027, -29052, -29077, -29102, -29126, --29151, -29175, -29200, -29224, -29248, --29272, -29296, -29320, -29344, -29368, --29392, -29415, -29439, -29462, -29486, --29509, -29532, -29556, -29579, -29602, --29625, -29648, -29670, -29693, -29716, --29738, -29761, -29783, -29806, -29828, --29850, -29872, -29894, -29916, -29938, --29960, -29981, -30003, -30024, -30046, --30067, -30088, -30110, -30131, -30152, --30173, -30194, -30214, -30235, -30256, --30276, -30297, -30317, -30337, -30358, --30378, -30398, -30418, -30438, -30458, --30477, -30497, -30516, -30536, -30555, --30575, -30594, -30613, -30632, -30651, --30670, -30689, -30708, -30726, -30745, --30763, -30782, -30800, -30819, -30837, --30855, -30873, -30891, -30909, -30926, --30944, -30962, -30979, -30997, -31014, --31031, -31048, -31065, -31082, -31099, --31116, -31133, -31150, -31166, -31183, --31199, -31216, -31232, -31248, -31264, --31280, -31296, -31312, -31328, -31343, --31359, -31374, -31390, -31405, -31421, --31436, -31451, -31466, -31481, -31496, --31510, -31525, -31540, -31554, -31568, --31583, -31597, -31611, -31625, -31639, --31653, -31667, -31681, -31694, -31708, --31721, -31735, -31748, -31761, -31775, --31788, -31801, -31813, -31826, -31839, --31852, -31864, -31877, -31889, -31901, --31914, -31926, -31938, -31950, -31961, --31973, -31985, -31997, -32008, -32020, --32031, -32042, -32053, -32064, -32075, --32086, -32097, -32108, -32119, -32129, --32140, -32150, -32160, -32171, -32181, --32191, -32201, -32211, -32221, -32230, --32240, -32249, -32259, -32268, -32278, --32287, -32296, -32305, -32314, -32323, --32331, -32340, -32349, -32357, -32366, --32374, -32382, -32390, -32398, -32406, --32414, -32422, -32430, -32437, -32445, --32453, -32460, -32467, -32474, -32482, --32489, -32495, -32502, -32509, -32516, --32522, -32529, -32535, -32542, -32548, --32554, -32560, -32566, -32572, -32578, --32584, -32589, -32595, -32600, -32606, --32611, -32616, -32621, -32626, -32631, --32636, -32641, -32645, -32650, -32655, --32659, -32663, -32668, -32672, -32676, --32680, -32684, -32687, -32691, -32695, --32698, -32702, -32705, -32708, -32712, --32715, -32718, -32721, -32723, -32726, --32729, -32731, -32734, -32736, -32739, --32741, -32743, -32745, -32747, -32749, --32751, -32752, -32754, -32756, -32757, --32758, -32760, -32761, -32762, -32763, --32764, -32765, -32765, -32766, -32766, --32767, -32767, -32767, -32767, -32767, -32767, 32767, 32767, 32766, 32765, -32763, 32761, 32759, 32756, 32753, -32750, 32746, 32742, 32738, 32733, -32728, 32722, 32717, 32710, 32704, -32697, 32690, 32682, 32674, 32666, -32657, 32648, 32639, 32629, 32619, -32609, 32598, 32587, 32576, 32564, -32552, 32539, 32526, 32513, 32500, -32486, 32472, 32457, 32442, 32427, -32411, 32395, 32379, 32362, 32345, -32328, 32310, 32292, 32274, 32255, -32236, 32217, 32197, 32177, 32157, -32136, 32115, 32093, 32071, 32049, -32027, 32004, 31981, 31957, 31933, -31909, 31884, 31859, 31834, 31809, -31783, 31756, 31730, 31703, 31676, -31648, 31620, 31592, 31563, 31534, -31505, 31475, 31445, 31415, 31384, -31353, 31322, 31290, 31258, 31226, -31193, 31160, 31127, 31093, 31059, -31025, 30990, 30955, 30920, 30884, -30848, 30812, 30775, 30738, 30701, -30663, 30625, 30587, 30548, 30509, -30470, 30430, 30390, 30350, 30309, -30269, 30227, 30186, 30144, 30102, -30059, 30016, 29973, 29930, 29886, -29842, 29797, 29752, 29707, 29662, -29616, 29570, 29524, 29477, 29430, -29383, 29335, 29287, 29239, 29190, -29142, 29092, 29043, 28993, 28943, -28892, 28842, 28791, 28739, 28688, -28636, 28583, 28531, 28478, 28425, -28371, 28317, 28263, 28209, 28154, -28099, 28044, 27988, 27932, 27876, -27820, 27763, 27706, 27648, 27591, -27533, 27474, 27416, 27357, 27298, -27238, 27178, 27118, 27058, 26997, -26936, 26875, 26814, 26752, 26690, -26628, 26565, 26502, 26439, 26375, -26312, 26247, 26183, 26119, 26054, -25988, 25923, 25857, 25791, 25725, -25658, 25592, 25524, 25457, 25389, -25322, 25253, 25185, 25116, 25047, -24978, 24908, 24838, 24768, 24698, -24627, 24557, 24485, 24414, 24342, -24270, 24198, 24126, 24053, 23980, -23907, 23834, 23760, 23686, 23612, -23537, 23462, 23387, 23312, 23237, -23161, 23085, 23009, 22932, 22856, -22779, 22701, 22624, 22546, 22468, -22390, 22312, 22233, 22154, 22075, -21996, 21916, 21836, 21756, 21676, -21595, 21515, 21434, 21352, 21271, -21189, 21107, 21025, 20943, 20860, -20777, 20694, 20611, 20528, 20444, -20360, 20276, 20192, 20107, 20022, -19937, 19852, 19767, 19681, 19595, -19509, 19423, 19336, 19250, 19163, -19076, 18988, 18901, 18813, 18725, -18637, 18549, 18460, 18372, 18283, -18194, 18104, 18015, 17925, 17835, -17745, 17655, 17565, 17474, 17383, -17292, 17201, 17110, 17018, 16927, -16835, 16743, 16650, 16558, 16465, -16372, 16279, 16186, 16093, 15999, -15906, 15812, 15718, 15624, 15529, -15435, 15340, 15245, 15150, 15055, -14960, 14864, 14769, 14673, 14577, -14481, 14385, 14288, 14192, 14095, -13998, 13901, 13804, 13706, 13609, -13511, 13414, 13316, 13218, 13119, -13021, 12923, 12824, 12725, 12626, -12527, 12428, 12329, 12230, 12130, -12030, 11930, 11831, 11730, 11630, -11530, 11430, 11329, 11228, 11128, -11027, 10926, 10824, 10723, 10622, -10520, 10419, 10317, 10215, 10113, -10011, 9909, 9807, 9704, 9602, -9499, 9397, 9294, 9191, 9088, -8985, 8882, 8778, 8675, 8572, -8468, 8364, 8261, 8157, 8053, -7949, 7845, 7741, 7637, 7532, -7428, 7323, 7219, 7114, 7009, -6905, 6800, 6695, 6590, 6485, -6380, 6274, 6169, 6064, 5958, -5853, 5747, 5642, 5536, 5430, -5325, 5219, 5113, 5007, 4901, -4795, 4689, 4583, 4476, 4370, -4264, 4157, 4051, 3945, 3838, -3732, 3625, 3518, 3412, 3305, -3198, 3092, 2985, 2878, 2771, -2664, 2558, 2451, 2344, 2237, -2130, 2023, 1916, 1809, 1702, -1594, 1487, 1380, 1273, 1166, -1059, 952, 844, 737, 630, -523, 416, 308, 201, 94, --13, -121, -228, -335, -442, --550, -657, -764, -871, -978, --1086, -1193, -1300, -1407, -1514, --1621, -1728, -1835, -1942, -2049, --2157, -2263, -2370, -2477, -2584, --2691, -2798, -2905, -3012, -3118, --3225, -3332, -3439, -3545, -3652, --3758, -3865, -3971, -4078, -4184, --4290, -4397, -4503, -4609, -4715, --4821, -4927, -5033, -5139, -5245, --5351, -5457, -5562, -5668, -5774, --5879, -5985, -6090, -6195, -6301, --6406, -6511, -6616, -6721, -6826, --6931, -7036, -7140, -7245, -7349, --7454, -7558, -7663, -7767, -7871, --7975, -8079, -8183, -8287, -8390, --8494, -8597, -8701, -8804, -8907, --9011, -9114, -9217, -9319, -9422, --9525, -9627, -9730, -9832, -9934, --10037, -10139, -10241, -10342, -10444, --10546, -10647, -10748, -10850, -10951, --11052, -11153, -11253, -11354, -11455, --11555, -11655, -11756, -11856, -11955, --12055, -12155, -12254, -12354, -12453, --12552, -12651, -12750, -12849, -12947, --13046, -13144, -13242, -13340, -13438, --13536, -13633, -13731, -13828, -13925, --14022, -14119, -14216, -14312, -14409, --14505, -14601, -14697, -14793, -14888, --14984, -15079, -15174, -15269, -15364, --15459, -15553, -15647, -15741, -15835, --15929, -16023, -16116, -16210, -16303, --16396, -16488, -16581, -16673, -16766, --16858, -16949, -17041, -17133, -17224, --17315, -17406, -17497, -17587, -17678, --17768, -17858, -17948, -18037, -18127, --18216, -18305, -18394, -18483, -18571, --18659, -18747, -18835, -18923, -19010, --19098, -19185, -19271, -19358, -19444, --19531, -19617, -19702, -19788, -19873, --19959, -20043, -20128, -20213, -20297, --20381, -20465, -20549, -20632, -20715, --20798, -20881, -20963, -21046, -21128, --21210, -21291, -21373, -21454, -21535, --21616, -21696, -21776, -21856, -21936, --22016, -22095, -22174, -22253, -22331, --22410, -22488, -22566, -22643, -22721, --22798, -22875, -22951, -23028, -23104, --23180, -23256, -23331, -23406, -23481, --23556, -23630, -23704, -23778, -23852, --23925, -23998, -24071, -24144, -24216, --24288, -24360, -24432, -24503, -24574, --24645, -24716, -24786, -24856, -24926, --24995, -25064, -25133, -25202, -25270, --25339, -25406, -25474, -25541, -25608, --25675, -25742, -25808, -25874, -25939, --26005, -26070, -26135, -26199, -26264, --26327, -26391, -26455, -26518, -26581, --26643, -26705, -26767, -26829, -26891, --26952, -27013, -27073, -27133, -27193, --27253, -27312, -27372, -27430, -27489, --27547, -27605, -27663, -27720, -27777, --27834, -27890, -27946, -28002, -28058, --28113, -28168, -28223, -28277, -28331, --28385, -28438, -28491, -28544, -28596, --28649, -28701, -28752, -28803, -28854, --28905, -28955, -29006, -29055, -29105, --29154, -29203, -29251, -29299, -29347, --29395, -29442, -29489, -29535, -29582, --29628, -29673, -29719, -29764, -29808, --29853, -29897, -29941, -29984, -30027, --30070, -30112, -30154, -30196, -30238, --30279, -30320, -30360, -30400, -30440, --30480, -30519, -30558, -30596, -30635, --30672, -30710, -30747, -30784, -30821, --30857, -30893, -30929, -30964, -30999, --31033, -31068, -31102, -31135, -31168, --31201, -31234, -31266, -31298, -31330, --31361, -31392, -31422, -31453, -31483, --31512, -31541, -31570, -31599, -31627, --31655, -31682, -31710, -31737, -31763, --31789, -31815, -31841, -31866, -31891, --31915, -31939, -31963, -31986, -32010, --32032, -32055, -32077, -32099, -32120, --32141, -32162, -32182, -32202, -32222, --32241, -32260, -32279, -32297, -32315, --32333, -32350, -32367, -32383, -32399, --32415, -32431, -32446, -32461, -32475, --32489, -32503, -32517, -32530, -32542, --32555, -32567, -32579, -32590, -32601, --32612, -32622, -32632, -32641, -32651, --32659, -32668, -32676, -32684, -32692, --32699, -32706, -32712, -32718, -32724, --32729, -32734, -32739, -32743, -32747, --32751, -32754, -32757, -32760, -32762, --32764, -32765, -32767, -32767, -32767, -32767, 32767, 32765, 32761, 32756, -32750, 32742, 32732, 32722, 32710, -32696, 32681, 32665, 32647, 32628, -32608, 32586, 32562, 32538, 32512, -32484, 32455, 32425, 32393, 32360, -32326, 32290, 32253, 32214, 32174, -32133, 32090, 32046, 32001, 31954, -31906, 31856, 31805, 31753, 31700, -31645, 31588, 31530, 31471, 31411, -31349, 31286, 31222, 31156, 31089, -31020, 30951, 30880, 30807, 30733, -30658, 30582, 30504, 30425, 30345, -30263, 30181, 30096, 30011, 29924, -29836, 29747, 29656, 29564, 29471, -29377, 29281, 29184, 29086, 28987, -28886, 28784, 28681, 28577, 28471, -28365, 28257, 28147, 28037, 27925, -27812, 27698, 27583, 27467, 27349, -27231, 27111, 26990, 26868, 26744, -26620, 26494, 26367, 26239, 26110, -25980, 25849, 25717, 25583, 25449, -25313, 25176, 25038, 24900, 24760, -24619, 24477, 24333, 24189, 24044, -23898, 23751, 23602, 23453, 23303, -23152, 22999, 22846, 22692, 22537, -22380, 22223, 22065, 21906, 21746, -21585, 21423, 21261, 21097, 20933, -20767, 20601, 20434, 20265, 20096, -19927, 19756, 19584, 19412, 19239, -19065, 18890, 18714, 18538, 18361, -18183, 18004, 17824, 17644, 17463, -17281, 17098, 16915, 16731, 16546, -16361, 16175, 15988, 15800, 15612, -15423, 15234, 15043, 14852, 14661, -14469, 14276, 14083, 13889, 13694, -13499, 13303, 13107, 12910, 12713, -12515, 12317, 12118, 11918, 11718, -11517, 11316, 11115, 10913, 10710, -10508, 10304, 10100, 9896, 9691, -9486, 9281, 9075, 8869, 8662, -8455, 8248, 8040, 7832, 7623, -7415, 7206, 6996, 6787, 6577, -6366, 6156, 5945, 5734, 5523, -5311, 5100, 4888, 4675, 4463, -4251, 4038, 3825, 3612, 3399, -3185, 2972, 2758, 2544, 2330, -2116, 1902, 1688, 1474, 1260, -1045, 831, 617, 402, 188, --27, -241, -456, -670, -885, --1099, -1313, -1528, -1742, -1956, --2170, -2384, -2598, -2811, -3025, --3239, -3452, -3665, -3878, -4091, --4304, -4516, -4728, -4941, -5153, --5364, -5576, -5787, -5998, -6209, --6419, -6629, -6839, -7049, -7258, --7467, -7676, -7884, -8092, -8300, --8507, -8714, -8920, -9127, -9332, --9538, -9743, -9947, -10151, -10355, --10558, -10761, -10963, -11165, -11367, --11568, -11768, -11968, -12167, -12366, --12565, -12762, -12960, -13156, -13352, --13548, -13743, -13937, -14131, -14324, --14517, -14709, -14900, -15091, -15281, --15470, -15659, -15847, -16035, -16221, --16407, -16593, -16777, -16961, -17144, --17326, -17508, -17689, -17869, -18049, --18227, -18405, -18582, -18758, -18934, --19108, -19282, -19455, -19627, -19799, --19969, -20139, -20308, -20475, -20642, --20809, -20974, -21138, -21301, -21464, --21626, -21786, -21946, -22105, -22263, --22420, -22575, -22730, -22884, -23037, --23189, -23340, -23490, -23640, -23788, --23935, -24080, -24225, -24369, -24512, --24654, -24795, -24934, -25073, -25211, --25347, -25482, -25617, -25750, -25882, --26013, -26143, -26272, -26399, -26526, --26651, -26775, -26898, -27020, -27141, --27260, -27379, -27496, -27612, -27727, --27841, -27953, -28065, -28175, -28284, --28391, -28498, -28603, -28707, -28810, --28911, -29012, -29111, -29209, -29305, --29401, -29495, -29587, -29679, -29769, --29858, -29946, -30032, -30118, -30201, --30284, -30365, -30445, -30524, -30601, --30677, -30752, -30825, -30897, -30968, --31038, -31106, -31172, -31238, -31302, --31365, -31426, -31486, -31545, -31602, --31658, -31713, -31766, -31818, -31869, --31918, -31966, -32012, -32058, -32101, --32144, -32185, -32224, -32262, -32299, --32335, -32369, -32401, -32433, -32463, --32491, -32518, -32544, -32568, -32591, --32613, -32633, -32652, -32669, -32685, --32700, -32713, -32724, -32735, -32744, --32751, -32757, -32762, -32766, -32767, -32767, 32764, 32755, 32741, 32720, -32694, 32663, 32626, 32583, 32535, -32481, 32421, 32356, 32286, 32209, -32128, 32041, 31948, 31850, 31747, -31638, 31523, 31403, 31278, 31148, -31012, 30871, 30724, 30572, 30415, -30253, 30086, 29913, 29736, 29553, -29365, 29172, 28974, 28771, 28564, -28351, 28134, 27911, 27684, 27452, -27216, 26975, 26729, 26478, 26223, -25964, 25700, 25432, 25159, 24882, -24601, 24315, 24026, 23732, 23434, -23133, 22827, 22517, 22204, 21886, -21565, 21240, 20912, 20580, 20244, -19905, 19563, 19217, 18868, 18516, -18160, 17802, 17440, 17075, 16708, -16338, 15964, 15588, 15210, 14829, -14445, 14059, 13670, 13279, 12886, -12490, 12093, 11693, 11291, 10888, -10482, 10075, 9666, 9255, 8843, -8429, 8014, 7597, 7180, 6760, -6340, 5919, 5496, 5073, 4649, -4224, 3798, 3372, 2945, 2517, -2090, 1661, 1233, 804, 375, --54, -483, -911, -1340, -1768, --2197, -2624, -3052, -3479, -3905, --4330, -4755, -5179, -5602, -6024, --6445, -6865, -7284, -7702, -8118, --8533, -8946, -9358, -9768, -10177, --10584, -10989, -11392, -11793, -12192, --12589, -12984, -13377, -13767, -14155, --14541, -14924, -15305, -15683, -16058, --16430, -16800, -17167, -17531, -17892, --18249, -18604, -18956, -19304, -19649, --19990, -20329, -20663, -20994, -21322, --21646, -21966, -22282, -22595, -22904, --23208, -23509, -23806, -24099, -24387, --24672, -24952, -25228, -25499, -25766, --26029, -26288, -26541, -26791, -27035, --27275, -27511, -27741, -27967, -28188, --28405, -28616, -28823, -29024, -29221, --29412, -29599, -29780, -29957, -30128, --30294, -30455, -30611, -30761, -30906, --31046, -31181, -31310, -31434, -31552, --31665, -31773, -31875, -31972, -32063, --32149, -32229, -32304, -32373, -32437, --32495, -32547, -32594, -32635, -32671, --32701, -32726, -32745, -32758, -32766, -#endif + 2147483603, 2147480010, 2147470667, 2147455575, 2147434733, + 2147408142, 2147375802, 2147337712, 2147293874, 2147244286, + 2147188950, 2147127865, 2147061032, 2146988450, 2146910120, + 2146826042, 2146736216, 2146640643, 2146539323, 2146432256, + 2146319442, 2146200882, 2146076576, 2145946524, 2145810727, + 2145669185, 2145521898, 2145368867, 2145210092, 2145045574, + 2144875313, 2144699310, 2144517564, 2144330077, 2144136849, + 2143937880, 2143733172, 2143522724, 2143306537, 2143084612, + 2142856949, 2142623549, 2142384413, 2142139541, 2141888933, + 2141632592, 2141370516, 2141102708, 2140829167, 2140549894, + 2140264890, 2139974157, 2139677694, 2139375502, 2139067583, + 2138753936, 2138434564, 2138109466, 2137778644, 2137442099, + 2137099831, 2136751841, 2136398131, 2136038701, 2135673552, + 2135302685, 2134926101, 2134543801, 2134155787, 2133762059, + 2133362618, 2132957466, 2132546603, 2132130030, 2131707749, + 2131279761, 2130846067, 2130406668, 2129961565, 2129510759, + 2129054253, 2128592046, 2128124140, 2127650537, 2127171237, + 2126686242, 2126195553, 2125699172, 2125197100, 2124689338, + 2124175888, 2123656750, 2123131927, 2122601420, 2122065230, + 2121523358, 2120975806, 2120422576, 2119863669, 2119299086, + 2118728830, 2118152901, 2117571301, 2116984031, 2116391094, + 2115792491, 2115188222, 2114578291, 2113962699, 2113341447, + 2112714537, 2112081970, 2111443749, 2110799875, 2110150349, + 2109495174, 2108834352, 2108167883, 2107495770, 2106818015, + 2106134619, 2105445584, 2104750913, 2104050606, 2103344666, + 2102633095, 2101915895, 2101193067, 2100464614, 2099730537, + 2098990838, 2098245520, 2097494584, 2096738032, 2095975867, + 2095208091, 2094434705, 2093655711, 2092871112, 2092080910, + 2091285107, 2090483704, 2089676705, 2088864111, 2088045925, + 2087222148, 2086392783, 2085557833, 2084717298, 2083871182, + 2083019487, 2082162216, 2081299369, 2080430950, 2079556962, + 2078677406, 2077792284, 2076901600, 2076005355, 2075103552, + 2074196194, 2073283282, 2072364819, 2071440808, 2070511251, + 2069576151, 2068635510, 2067689330, 2066737615, 2065780367, + 2064817587, 2063849280, 2062875447, 2061896091, 2060911215, + 2059920821, 2058924912, 2057923491, 2056916560, 2055904122, + 2054886179, 2053862736, 2052833793, 2051799354, 2050759422, + 2049714000, 2048663090, 2047606695, 2046544818, 2045477461, + 2044404629, 2043326323, 2042242546, 2041153301, 2040058592, + 2038958421, 2037852791, 2036741705, 2035625166, 2034503177, + 2033375742, 2032242862, 2031104541, 2029960782, 2028811589, + 2027656964, 2026496910, 2025331431, 2024160529, 2022984208, + 2021802471, 2020615320, 2019422760, 2018224794, 2017021424, + 2015812654, 2014598487, 2013378926, 2012153975, 2010923636, + 2009687914, 2008446811, 2007200332, 2005948478, 2004691253, + 2003428662, 2002160707, 2000887391, 1999608718, 1998324692, + 1997035316, 1995740593, 1994440527, 1993135121, 1991824379, + 1990508304, 1989186900, 1987860170, 1986528118, 1985190748, + 1983848063, 1982500066, 1981146762, 1979788153, 1978424244, + 1977055038, 1975680539, 1974300751, 1972915676, 1971525320, + 1970129685, 1968728776, 1967322596, 1965911148, 1964494438, + 1963072467, 1961645241, 1960212764, 1958775038, 1957332067, + 1955883857, 1954430410, 1952971730, 1951507822, 1950038689, + 1948564335, 1947084764, 1945599980, 1944109987, 1942614790, + 1941114391, 1939608795, 1938098007, 1936582029, 1935060867, + 1933534524, 1932003004, 1930466312, 1928924452, 1927377427, + 1925825242, 1924267900, 1922705408, 1921137767, 1919564983, + 1917987059, 1916404001, 1914815812, 1913222496, 1911624058, + 1910020502, 1908411833, 1906798054, 1905179170, 1903555185, + 1901926103, 1900291930, 1898652669, 1897008325, 1895358902, + 1893704404, 1892044837, 1890380204, 1888710510, 1887035759, + 1885355956, 1883671105, 1881981211, 1880286279, 1878586312, + 1876881316, 1875171295, 1873456254, 1871736196, 1870011128, + 1868281053, 1866545976, 1864805901, 1863060834, 1861310779, + 1859555741, 1857795724, 1856030734, 1854260774, 1852485850, + 1850705966, 1848921127, 1847131338, 1845336604, 1843536929, + 1841732318, 1839922777, 1838108310, 1836288921, 1834464616, + 1832635400, 1830801277, 1828962253, 1827118332, 1825269519, + 1823415819, 1821557238, 1819693779, 1817825449, 1815952252, + 1814074193, 1812191278, 1810303510, 1808410896, 1806513440, + 1804611147, 1802704023, 1800792073, 1798875302, 1796953714, + 1795027315, 1793096111, 1791160105, 1789219305, 1787273714, + 1785323338, 1783368182, 1781408251, 1779443552, 1777474088, + 1775499865, 1773520888, 1771537164, 1769548696, 1767555491, + 1765557554, 1763554889, 1761547504, 1759535401, 1757518588, + 1755497070, 1753470852, 1751439939, 1749404337, 1747364051, + 1745319087, 1743269451, 1741215147, 1739156181, 1737092559, + 1735024287, 1732951369, 1730873811, 1728791620, 1726704800, + 1724613357, 1722517297, 1720416625, 1718311347, 1716201468, + 1714086995, 1711967933, 1709844287, 1707716063, 1705583268, + 1703445906, 1701303983, 1699157505, 1697006479, 1694850909, + 1692690801, 1690526161, 1688356996, 1686183310, 1684005110, + 1681822401, 1679635189, 1677443481, 1675247281, 1673046596, + 1670841433, 1668631795, 1666417691, 1664199124, 1661976103, + 1659748631, 1657516716, 1655280364, 1653039579, 1650794369, + 1648544739, 1646290696, 1644032245, 1641769393, 1639502145, + 1637230507, 1634954486, 1632674088, 1630389319, 1628100184, + 1625806691, 1623508845, 1621206653, 1618900119, 1616589252, + 1614274057, 1611954539, 1609630706, 1607302564, 1604970118, + 1602633375, 1600292342, 1597947024, 1595597428, 1593243560, + 1590885426, 1588523033, 1586156387, 1583785495, 1581410362, + 1579030995, 1576647401, 1574259586, 1571867556, 1569471317, + 1567070877, 1564666241, 1562257416, 1559844408, 1557427224, + 1555005871, 1552580354, 1550150681, 1547716857, 1545278889, + 1542836785, 1540390550, 1537940190, 1535485713, 1533027126, + 1530564434, 1528097644, 1525626762, 1523151797, 1520672753, + 1518189638, 1515702459, 1513211221, 1510715932, 1508216599, + 1505713227, 1503205824, 1500694397, 1498178952, 1495659496, + 1493136035, 1490608577, 1488077129, 1485541696, 1483002286, + 1480458905, 1477911561, 1475360260, 1472805009, 1470245815, + 1467682684, 1465115624, 1462544642, 1459969744, 1457390937, + 1454808228, 1452221624, 1449631133, 1447036760, 1444438513, + 1441836399, 1439230424, 1436620597, 1434006923, 1431389409, + 1428768064, 1426142893, 1423513904, 1420881104, 1418244500, + 1415604099, 1412959907, 1410311933, 1407660183, 1405004664, + 1402345384, 1399682349, 1397015567, 1394345044, 1391670789, + 1388992807, 1386311107, 1383625695, 1380936579, 1378243766, + 1375547262, 1372847076, 1370143215, 1367435685, 1364724494, + 1362009649, 1359291158, 1356569027, 1353843265, 1351113878, + 1348380873, 1345644259, 1342904042, 1340160229, 1337412829, + 1334661848, 1331907293, 1329149173, 1326387494, 1323622264, + 1320853490, 1318081180, 1315305341, 1312525981, 1309743106, + 1306956725, 1304166845, 1301373473, 1298576617, 1295776285, + 1292972483, 1290165219, 1287354501, 1284540337, 1281722734, + 1278901699, 1276077240, 1273249364, 1270418080, 1267583394, + 1264745315, 1261903850, 1259059006, 1256210791, 1253359213, + 1250504279, 1247645998, 1244784376, 1241919421, 1239051142, + 1236179545, 1233304638, 1230426430, 1227544927, 1224660138, + 1221772070, 1218880731, 1215986128, 1213088271, 1210187165, + 1207282819, 1204375241, 1201464439, 1198550419, 1195633191, + 1192712762, 1189789140, 1186862332, 1183932347, 1180999192, + 1178062875, 1175123404, 1172180786, 1169235031, 1166286145, + 1163334137, 1160379014, 1157420784, 1154459456, 1151495036, + 1148527534, 1145556957, 1142583313, 1139606610, 1136626856, + 1133644058, 1130658226, 1127669367, 1124677488, 1121682598, + 1118684705, 1115683818, 1112679943, 1109673089, 1106663264, + 1103650476, 1100634734, 1097616045, 1094594417, 1091569858, + 1088542378, 1085511982, 1082478681, 1079442481, 1076403392, + 1073361420, 1070316575, 1067268864, 1064218296, 1061164879, + 1058108621, 1055049529, 1051987613, 1048922881, 1045855340, + 1042784999, 1039711867, 1036635950, 1033557259, 1030475800, + 1027391582, 1024304614, 1021214903, 1018122458, 1015027288, + 1011929400, 1008828802, 1005725504, 1002619513, 999510838, + 996399486, 993285468, 990168789, 987049460, 983927488, + 980802882, 977675650, 974545800, 971413342, 968278282, + 965140630, 962000395, 958857583, 955712205, 952564267, + 949413780, 946260750, 943105188, 939947100, 936786495, + 933623383, 930457771, 927289668, 924119082, 920946022, + 917770497, 914592514, 911412082, 908229211, 905043908, + 901856182, 898666041, 895473494, 892278550, 889081217, + 885881504, 882679419, 879474970, 876268167, 873059018, + 869847532, 866633717, 863417581, 860199134, 856978384, + 853755339, 850530009, 847302402, 844072526, 840840390, + 837606003, 834369373, 831130510, 827889422, 824646117, + 821400604, 818152892, 814902989, 811650905, 808396648, + 805140227, 801881649, 798620925, 795358063, 792093072, + 788825960, 785556735, 782285408, 779011986, 775736479, + 772458895, 769179242, 765897531, 762613768, 759327964, + 756040127, 752750266, 749458390, 746164507, 742868626, + 739570757, 736270907, 732969086, 729665303, 726359567, + 723051885, 719742268, 716430724, 713117261, 709801890, + 706484618, 703165455, 699844409, 696521489, 693196705, + 689870064, 686541577, 683211252, 679879097, 676545122, + 673209336, 669871748, 666532366, 663191199, 659848257, + 656503549, 653157082, 649808867, 646458913, 643107227, + 639753820, 636398700, 633041876, 629683357, 626323153, + 622961271, 619597722, 616232514, 612865656, 609497157, + 606127026, 602755273, 599381905, 596006934, 592630366, + 589252212, 585872480, 582491179, 579108320, 575723909, + 572337957, 568950473, 565561466, 562170945, 558778918, + 555385395, 551990386, 548593898, 545195942, 541796526, + 538395660, 534993352, 531589612, 528184449, 524777871, + 521369889, 517960510, 514549745, 511137603, 507724092, + 504309221, 500893000, 497475439, 494056545, 490636329, + 487214799, 483791965, 480367835, 476942419, 473515727, + 470087766, 466658548, 463228079, 459796371, 456363431, + 452929270, 449493896, 446057319, 442619547, 439180590, + 435740458, 432299159, 428856702, 425413098, 421968354, + 418522481, 415075487, 411627382, 408178175, 404727875, + 401276491, 397824033, 394370510, 390915931, 387460306, + 384003643, 380545952, 377087242, 373627523, 370166803, + 366705093, 363242400, 359778735, 356314107, 352848525, + 349381998, 345914536, 342446148, 338976842, 335506630, + 332035519, 328563519, 325090639, 321616889, 318142278, + 314666815, 311190510, 307713372, 304235410, 300756633, + 297277051, 293796673, 290315508, 286833567, 283350857, + 279867389, 276383171, 272898214, 269412525, 265926116, + 262438995, 258951170, 255462653, 251973452, 248483576, + 244993035, 241501838, 238009994, 234517513, 231024404, + 227530677, 224036341, 220541404, 217045878, 213549770, + 210053090, 206555848, 203058053, 199559715, 196060842, + 192561444, 189061531, 185561111, 182060195, 178558791, + 175056909, 171554559, 168051749, 164548489, 161044789, + 157540658, 154036105, 150531139, 147025770, 143520008, + 140013862, 136507340, 133000453, 129493210, 125985621, + 122477694, 118969439, 115460866, 111951983, 108442801, + 104933329, 101423575, 97913550, 94403263, 90892723, + 87381940, 83870923, 80359681, 76848224, 73336562, + 69824703, 66312657, 62800433, 59288042, 55775491, + 52262792, 48749952, 45236982, 41723891, 38210688, + 34697383, 31183985, 27670503, 24156947, 20643327, + 17129651, 13615930, 10102172, 6588387, 3074584, + -439226, -3953036, -7466835, -10980614, -14494364, + -18008075, -21521738, -25035343, -28548881, -32062342, + -35575718, -39088999, -42602174, -46115236, -49628175, + -53140980, -56653643, -60166155, -63678505, -67190685, + -70702685, -74214496, -77726108, -81237512, -84748698, + -88259658, -91770381, -95280859, -98791081, -102301039, + -105810723, -109320124, -112829232, -116338038, -119846533, + -123354707, -126862550, -130370054, -133877209, -137384005, + -140890434, -144396485, -147902150, -151407418, -154912282, + -158416730, -161920755, -165424346, -168927494, -172430190, + -175932424, -179434187, -182935470, -186436263, -189936557, + -193436342, -196935610, -200434350, -203932553, -207430211, + -210927313, -214423851, -217919814, -221415194, -224909981, + -228404166, -231897740, -235390693, -238883015, -242374698, + -245865732, -249356108, -252845816, -256334847, -259823192, + -263310841, -266797785, -270284015, -273769522, -277254295, + -280738326, -284221606, -287704124, -291185873, -294666841, + -298147021, -301626403, -305104977, -308582734, -312059665, + -315535760, -319011011, -322485408, -325958941, -329431602, + -332903380, -336374268, -339844254, -343313331, -346781489, + -350248718, -353715010, -357180354, -360644742, -364108165, + -367570613, -371032077, -374492547, -377952015, -381410471, + -384867905, -388324310, -391779674, -395233990, -398687248, + -402139438, -405590552, -409040579, -412489512, -415937340, + -419384055, -422829646, -426274106, -429717424, -433159592, + -436600601, -440040440, -443479101, -446916575, -450352853, + -453787924, -457221781, -460654414, -464085813, -467515970, + -470944875, -474372519, -477798893, -481223988, -484647795, + -488070304, -491491506, -494911393, -498329954, -501747182, + -505163066, -508577597, -511990767, -515402566, -518812985, + -522222016, -525629648, -529035873, -532440681, -535844064, + -539246012, -542646517, -546045568, -549443158, -552839277, + -556233916, -559627065, -563018716, -566408860, -569797488, + -573184589, -576570157, -579954180, -583336651, -586717560, + -590096899, -593474657, -596850827, -600225398, -603598363, + -606969711, -610339435, -613707524, -617073971, -620438765, + -623801898, -627163361, -630523145, -633881241, -637237640, + -640592333, -643945310, -647296564, -650646085, -653993863, + -657339891, -660684159, -664026658, -667367379, -670706313, + -674043452, -677378786, -680712307, -684044005, -687373872, + -690701898, -694028075, -697352394, -700674846, -703995422, + -707314114, -710630911, -713945806, -717258790, -720569853, + -723878987, -727186183, -730491433, -733794726, -737096055, + -740395410, -743692783, -746988165, -750281547, -753572921, + -756862277, -760149606, -763434901, -766718151, -769999349, + -773278485, -776555551, -779830538, -783103437, -786374239, + -789642936, -792909519, -796173979, -799436307, -802696495, + -805954534, -809210416, -812464130, -815715670, -818965026, + -822212189, -825457150, -828699902, -831940435, -835178741, + -838414810, -841648635, -844880207, -848109516, -851336555, + -854561315, -857783787, -861003962, -864221832, -867437388, + -870650622, -873861525, -877070088, -880276304, -883480162, + -886681655, -889880774, -893077511, -896271856, -899463802, + -902653340, -905840461, -909025157, -912207419, -915387239, + -918564609, -921739519, -924911961, -928081927, -931249408, + -934414396, -937576882, -940736858, -943894315, -947049246, + -950201640, -953351491, -956498790, -959643527, -962785695, + -965925286, -969062291, -972196701, -975328508, -978457704, + -981584280, -984708228, -987829540, -990948208, -994064222, + -997177575, -1000288258, -1003396263, -1006501581, -1009604205, + -1012704126, -1015801336, -1018895826, -1021987588, -1025076613, + -1028162895, -1031246424, -1034327191, -1037405190, -1040480411, + -1043552847, -1046622488, -1049689328, -1052753357, -1055814567, + -1058872951, -1061928500, -1064981206, -1068031060, -1071078055, + -1074122183, -1077163435, -1080201802, -1083237278, -1086269854, + -1089299521, -1092326272, -1095350099, -1098370993, -1101388946, + -1104403951, -1107415998, -1110425081, -1113431191, -1116434320, + -1119434460, -1122431603, -1125425740, -1128416865, -1131404968, + -1134390043, -1137372080, -1140351072, -1143327011, -1146299889, + -1149269698, -1152236431, -1155200078, -1158160632, -1161118086, + -1164072431, -1167023660, -1169971764, -1172916735, -1175858567, + -1178797250, -1181732777, -1184665141, -1187594332, -1190520344, + -1193443169, -1196362799, -1199279225, -1202192441, -1205102438, + -1208009209, -1210912745, -1213813040, -1216710085, -1219603872, + -1222494394, -1225381643, -1228265611, -1231146291, -1234023675, + -1236897754, -1239768523, -1242635972, -1245500094, -1248360882, + -1251218327, -1254072422, -1256923160, -1259770533, -1262614533, + -1265455153, -1268292384, -1271126220, -1273956653, -1276783675, + -1279607279, -1282427457, -1285244201, -1288057504, -1290867359, + -1293673758, -1296476693, -1299276157, -1302072143, -1304864643, + -1307653649, -1310439154, -1313221151, -1315999631, -1318774589, + -1321546016, -1324313904, -1327078247, -1329839037, -1332596266, + -1335349928, -1338100015, -1340846519, -1343589433, -1346328751, + -1349064463, -1351796564, -1354525046, -1357249901, -1359971122, + -1362688702, -1365402634, -1368112911, -1370819524, -1373522468, + -1376221734, -1378917315, -1381609205, -1384297396, -1386981880, + -1389662652, -1392339702, -1395013025, -1397682613, -1400348459, + -1403010556, -1405668897, -1408323474, -1410974281, -1413621310, + -1416264555, -1418904007, -1421539661, -1424171509, -1426799544, + -1429423759, -1432044147, -1434660701, -1437273414, -1439882279, + -1442487289, -1445088437, -1447685717, -1450279120, -1452868640, + -1455454271, -1458036005, -1460613835, -1463187755, -1465757757, + -1468323835, -1470885982, -1473444191, -1475998456, -1478548768, + -1481095122, -1483637511, -1486175927, -1488710365, -1491240816, + -1493767276, -1496289736, -1498808190, -1501322631, -1503833053, + -1506339448, -1508841811, -1511340134, -1513834411, -1516324634, + -1518810798, -1521292896, -1523770921, -1526244866, -1528714725, + -1531180491, -1533642158, -1536099718, -1538553166, -1541002495, + -1543447698, -1545888769, -1548325701, -1550758488, -1553187123, + -1555611600, -1558031911, -1560448052, -1562860014, -1565267793, + -1567671380, -1570070771, -1572465958, -1574856935, -1577243696, + -1579626234, -1582004542, -1584378616, -1586748447, -1589114030, + -1591475359, -1593832427, -1596185227, -1598533754, -1600878002, + -1603217963, -1605553632, -1607885003, -1610212069, -1612534823, + -1614853261, -1617167375, -1619477159, -1621782608, -1624083714, + -1626380473, -1628672877, -1630960921, -1633244598, -1635523902, + -1637798828, -1640069368, -1642335518, -1644597271, -1646854620, + -1649107561, -1651356086, -1653600190, -1655839867, -1658075111, + -1660305916, -1662532275, -1664754184, -1666971635, -1669184624, + -1671393143, -1673597188, -1675796752, -1677991829, -1680182414, + -1682368500, -1684550083, -1686727155, -1688899711, -1691067746, + -1693231253, -1695390227, -1697544662, -1699694551, -1701839891, + -1703980674, -1706116895, -1708248548, -1710375628, -1712498128, + -1714616044, -1716729369, -1718838098, -1720942225, -1723041744, + -1725136651, -1727226938, -1729312602, -1731393635, -1733470033, + -1735541790, -1737608901, -1739671359, -1741729160, -1743782298, + -1745830767, -1747874561, -1749913677, -1751948107, -1753977847, + -1756002891, -1758023233, -1760038869, -1762049792, -1764055998, + -1766057481, -1768054236, -1770046258, -1772033540, -1774016078, + -1775993866, -1777966900, -1779935173, -1781898681, -1783857419, + -1785811380, -1787760560, -1789704954, -1791644556, -1793579362, + -1795509366, -1797434562, -1799354946, -1801270513, -1803181257, + -1805087174, -1806988258, -1808884503, -1810775906, -1812662462, + -1814544164, -1816421007, -1818292988, -1820160101, -1822022340, + -1823879702, -1825732180, -1827579771, -1829422468, -1831260267, + -1833093164, -1834921153, -1836744229, -1838562388, -1840375624, + -1842183933, -1843987310, -1845785751, -1847579249, -1849367801, + -1851151401, -1852930046, -1854703729, -1856472447, -1858236195, + -1859994968, -1861748761, -1863497569, -1865241388, -1866980214, + -1868714041, -1870442864, -1872166681, -1873885484, -1875599271, + -1877308036, -1879011776, -1880710484, -1882404157, -1884092791, + -1885776380, -1887454920, -1889128407, -1890796837, -1892460204, + -1894118504, -1895771734, -1897419887, -1899062961, -1900700951, + -1902333851, -1903961659, -1905584369, -1907201977, -1908814479, + -1910421871, -1912024148, -1913621306, -1915213340, -1916800247, + -1918382022, -1919958661, -1921530159, -1923096514, -1924657719, + -1926213771, -1927764667, -1929310401, -1930850970, -1932386369, + -1933916595, -1935441643, -1936961510, -1938476190, -1939985681, + -1941489978, -1942989077, -1944482974, -1945971664, -1947455145, + -1948933412, -1950406461, -1951874289, -1953336890, -1954794262, + -1956246401, -1957693301, -1959134961, -1960571375, -1962002540, + -1963428453, -1964849109, -1966264504, -1967674635, -1969079498, + -1970479089, -1971873404, -1973262440, -1974646194, -1976024660, + -1977397836, -1978765718, -1980128302, -1981485585, -1982837563, + -1984184232, -1985525589, -1986861630, -1988192351, -1989517750, + -1990837822, -1992152564, -1993461973, -1994766044, -1996064775, + -1997358161, -1998646200, -1999928888, -2001206222, -2002478198, + -2003744813, -2005006063, -2006261945, -2007512455, -2008757591, + -2009997349, -2011231726, -2012460718, -2013684322, -2014902534, + -2016115352, -2017322773, -2018524792, -2019721407, -2020912615, + -2022098413, -2023278796, -2024453763, -2025623309, -2026787432, + -2027946129, -2029099397, -2030247232, -2031389631, -2032526592, + -2033658111, -2034784185, -2035904812, -2037019988, -2038129710, + -2039233976, -2040332782, -2041426125, -2042514003, -2043596412, + -2044673350, -2045744814, -2046810801, -2047871308, -2048926332, + -2049975870, -2051019920, -2052058479, -2053091544, -2054119112, + -2055141181, -2056157747, -2057168809, -2058174363, -2059174406, + -2060168936, -2061157951, -2062141448, -2063119423, -2064091875, + -2065058800, -2066020197, -2066976063, -2067926394, -2068871190, + -2069810446, -2070744160, -2071672331, -2072594955, -2073512030, + -2074423554, -2075329524, -2076229937, -2077124792, -2078014086, + -2078897817, -2079775981, -2080648577, -2081515603, -2082377056, + -2083232934, -2084083234, -2084927955, -2085767094, -2086600648, + -2087428616, -2088250996, -2089067784, -2089878979, -2090684580, + -2091484582, -2092278986, -2093067787, -2093850985, -2094628577, + -2095400561, -2096166935, -2096927697, -2097682844, -2098432376, + -2099176290, -2099914583, -2100647254, -2101374302, -2102095723, + -2102811516, -2103521679, -2104226211, -2104925109, -2105618372, + -2106305997, -2106987983, -2107664327, -2108335029, -2109000087, + -2109659498, -2110313260, -2110961373, -2111603834, -2112240642, + -2112871795, -2113497290, -2114117128, -2114731305, -2115339820, + -2115942673, -2116539860, -2117131380, -2117717232, -2118297415, + -2118871926, -2119440764, -2120003928, -2120561416, -2121113227, + -2121659358, -2122199810, -2122734579, -2123263666, -2123787068, + -2124304784, -2124816812, -2125323152, -2125823801, -2126318759, + -2126808025, -2127291596, -2127769472, -2128241651, -2128708132, + -2129168914, -2129623995, -2130073375, -2130517052, -2130955025, + -2131387293, -2131813854, -2132234708, -2132649854, -2133059289, + -2133463014, -2133861027, -2134253326, -2134639912, -2135020783, + -2135395937, -2135765375, -2136129094, -2136487095, -2136839375, + -2137185934, -2137526772, -2137861886, -2138191277, -2138514944, + -2138832885, -2139145099, -2139451587, -2139752346, -2140047377, + -2140336678, -2140620249, -2140898089, -2141170197, -2141436573, + -2141697215, -2141952123, -2142201296, -2142444735, -2142682437, + -2142914403, -2143140631, -2143361122, -2143575874, -2143784887, + -2143988161, -2144185694, -2144377487, -2144563539, -2144743849, + -2144918417, -2145087242, -2145250325, -2145407663, -2145559258, + -2145705109, -2145845215, -2145979576, -2146108191, -2146231061, + -2146348185, -2146459562, -2146565192, -2146665076, -2146759212, + -2146847600, -2146930241, -2147007134, -2147078279, -2147143675, + -2147203323, -2147257222, -2147305372, -2147347773, -2147384426, + -2147415329, -2147440482, -2147459887, -2147473542, -2147481447, + 2147483468, 2147469095, 2147431723, 2147371355, 2147287990, + 2147181629, 2147052273, 2146899924, 2146724584, 2146526254, + 2146304937, 2146060634, 2145793349, 2145503083, 2145189842, + 2144853627, 2144494442, 2144112292, 2143707180, 2143279110, + 2142828088, 2142354118, 2141857204, 2141337354, 2140794571, + 2140228862, 2139640233, 2139028690, 2138394240, 2137736889, + 2137056645, 2136353515, 2135627506, 2134878626, 2134106884, + 2133312286, 2132494843, 2131654563, 2130791454, 2129905526, + 2128996788, 2128065251, 2127110924, 2126133817, 2125133941, + 2124111307, 2123065925, 2121997806, 2120906963, 2119793407, + 2118657149, 2117498202, 2116316578, 2115112291, 2113885352, + 2112635775, 2111363574, 2110068761, 2108751352, 2107411359, + 2106048798, 2104663683, 2103256028, 2101825849, 2100373162, + 2098897981, 2097400322, 2095880202, 2094337637, 2092772643, + 2091185237, 2089575437, 2087943258, 2086288720, 2084611839, + 2082912633, 2081191122, 2079447322, 2077681253, 2075892934, + 2074082383, 2072249621, 2070394667, 2068517540, 2066618262, + 2064696851, 2062753329, 2060787717, 2058800036, 2056790306, + 2054758550, 2052704789, 2050629045, 2048531340, 2046411698, + 2044270140, 2042106689, 2039921369, 2037714204, 2035485216, + 2033234429, 2030961869, 2028667558, 2026351522, 2024013785, + 2021654373, 2019273310, 2016870623, 2014446336, 2012000477, + 2009533071, 2007044144, 2004533723, 2002001835, 1999448508, + 1996873768, 1994277643, 1991660161, 1989021350, 1986361238, + 1983679853, 1980977226, 1978253383, 1975508355, 1972742171, + 1969954860, 1967146453, 1964316979, 1961466469, 1958594953, + 1955702462, 1952789027, 1949854680, 1946899451, 1943923372, + 1940926475, 1937908793, 1934870357, 1931811201, 1928731356, + 1925630856, 1922509734, 1919368023, 1916205758, 1913022972, + 1909819698, 1906595972, 1903351828, 1900087301, 1896802425, + 1893497236, 1890171769, 1886826060, 1883460144, 1880074058, + 1876667838, 1873241521, 1869795142, 1866328740, 1862842350, + 1859336011, 1855809760, 1852263635, 1848697674, 1845111914, + 1841506395, 1837881155, 1834236233, 1830571667, 1826887497, + 1823183763, 1819460504, 1815717761, 1811955572, 1808173978, + 1804373021, 1800552740, 1796713177, 1792854372, 1788976368, + 1785079205, 1781162925, 1777227570, 1773273182, 1769299805, + 1765307479, 1761296249, 1757266156, 1753217244, 1749149557, + 1745063138, 1740958031, 1736834279, 1732691928, 1728531020, + 1724351602, 1720153717, 1715937410, 1711702727, 1707449714, + 1703178415, 1698888876, 1694581143, 1690255263, 1685911282, + 1681549245, 1677169201, 1672771196, 1668355276, 1663921490, + 1659469885, 1655000508, 1650513407, 1646008631, 1641486227, + 1636946244, 1632388731, 1627813736, 1623221309, 1618611498, + 1613984353, 1609339924, 1604678260, 1599999411, 1595303428, + 1590590360, 1585860258, 1581113173, 1576349155, 1571568256, + 1566770527, 1561956018, 1557124783, 1552276872, 1547412337, + 1542531231, 1537633606, 1532719513, 1527789007, 1522842139, + 1517878963, 1512899531, 1507903898, 1502892116, 1497864239, + 1492820322, 1487760417, 1482684580, 1477592864, 1472485325, + 1467362016, 1462222994, 1457068312, 1451898025, 1446712191, + 1441510863, 1436294098, 1431061951, 1425814478, 1420551737, + 1415273782, 1409980671, 1404672460, 1399349206, 1394010966, + 1388657798, 1383289758, 1377906904, 1372509294, 1367096986, + 1361670037, 1356228505, 1350772450, 1345301929, 1339817000, + 1334317724, 1328804158, 1323276361, 1317734393, 1312178313, + 1306608181, 1301024057, 1295425999, 1289814068, 1284188325, + 1278548828, 1272895640, 1267228820, 1261548429, 1255854528, + 1250147177, 1244426439, 1238692373, 1232945043, 1227184508, + 1221410831, 1215624074, 1209824299, 1204011567, 1198185941, + 1192347484, 1186496258, 1180632325, 1174755748, 1168866591, + 1162964917, 1157050787, 1151124267, 1145185419, 1139234307, + 1133270995, 1127295547, 1121308026, 1115308496, 1109297023, + 1103273670, 1097238502, 1091191583, 1085132978, 1079062753, + 1072980972, 1066887699, 1060783002, 1054666944, 1048539592, + 1042401010, 1036251266, 1030090423, 1023918550, 1017735711, + 1011541973, 1005337402, 999122065, 992896028, 986659358, + 980412122, 974154386, 967886217, 961607684, 955318852, + 949019790, 942710564, 936391243, 930061894, 923722585, + 917373383, 911014357, 904645574, 898267104, 891879014, + 885481373, 879074249, 872657710, 866231826, 859796666, + 853352298, 846898791, 840436214, 833964638, 827484130, + 820994760, 814496598, 807989714, 801474176, 794950056, + 788417422, 781876345, 775326894, 768769141, 762203154, + 755629005, 749046764, 742456501, 735858287, 729252193, + 722638289, 716016646, 709387335, 702750427, 696105993, + 689454104, 682794832, 676128248, 669454423, 662773428, + 656085336, 649390218, 642688145, 635979190, 629263424, + 622540918, 615811746, 609075979, 602333690, 595584950, + 588829831, 582068407, 575300749, 568526931, 561747023, + 554961100, 548169234, 541371497, 534567963, 527758704, + 520943793, 514123303, 507297307, 500465878, 493629090, + 486787016, 479939728, 473087301, 466229807, 459367320, + 452499914, 445627662, 438750638, 431868915, 424982567, + 418091668, 411196291, 404296511, 397392401, 390484035, + 383571488, 376654833, 369734144, 362809495, 355880961, + 348948616, 342012534, 335072790, 328129457, 321182610, + 314232323, 307278671, 300321729, 293361570, 286398270, + 279431902, 272462542, 265490265, 258515144, 251537254, + 244556671, 237573469, 230587722, 223599506, 216608896, + 209615966, 202620791, 195623446, 188624006, 181622546, + 174619141, 167613866, 160606796, 153598006, 146587571, + 139575567, 132562067, 125547148, 118530885, 111513352, + 104494625, 97474778, 90453888, 83432030, 76409277, + 69385707, 62361393, 55336412, 48310838, 41284746, + 34258213, 27231312, 20204120, 13176712, 6149162, + -878453, -7906059, -14933580, -21960942, -28988068, + -36014884, -43041314, -50067283, -57092716, -64117537, + -71141672, -78165045, -85187581, -92209205, -99229841, + -106249414, -113267850, -120285073, -127301007, -134315578, + -141328711, -148340330, -155350361, -162358728, -169365356, + -176370170, -183373096, -190374058, -197372981, -204369791, + -211364411, -218356769, -225346788, -232334393, -239319511, + -246302065, -253281982, -260259186, -267233603, -274205159, + -281173778, -288139385, -295101907, -302061269, -309017396, + -315970213, -322919647, -329865622, -336808065, -343746901, + -350682056, -357613455, -364541025, -371464690, -378384377, + -385300013, -392211522, -399118830, -406021865, -412920551, + -419814815, -426704583, -433589782, -440470337, -447346176, + -454217223, -461083406, -467944652, -474800886, -481652035, + -488498026, -495338786, -502174241, -509004318, -515828944, + -522648046, -529461551, -536269386, -543071478, -549867754, + -556658141, -563442567, -570220959, -576993244, -583759350, + -590519205, -597272736, -604019870, -610760536, -617494660, + -624222173, -630943000, -637657070, -644364312, -651064652, + -657758021, -664444345, -671123554, -677795576, -684460338, + -691117771, -697767803, -704410362, -711045377, -717672778, + -724292493, -730904451, -737508582, -744104815, -750693079, + -757273304, -763845419, -770409354, -776965038, -783512402, + -790051375, -796581887, -803103868, -809617249, -816121959, + -822617929, -829105090, -835583372, -842052705, -848513021, + -854964249, -861406322, -867839170, -874262724, -880676915, + -887081675, -893476935, -899862626, -906238681, -912605031, + -918961607, -925308342, -931645168, -937972016, -944288820, + -950595511, -956892022, -963178285, -969454234, -975719800, + -981974918, -988219519, -994453537, -1000676905, -1006889557, + -1013091426, -1019282445, -1025462549, -1031631671, -1037789745, + -1043936705, -1050072485, -1056197020, -1062310244, -1068412091, + -1074502497, -1080581395, -1086648722, -1092704411, -1098748398, + -1104780618, -1110801008, -1116809501, -1122806034, -1128790543, + -1134762964, -1140723232, -1146671283, -1152607055, -1158530484, + -1164441505, -1170340057, -1176226074, -1182099496, -1187960258, + -1193808298, -1199643553, -1205465961, -1211275460, -1217071986, + -1222855479, -1228625876, -1234383115, -1240127136, -1245857875, + -1251575272, -1257279266, -1262969796, -1268646800, -1274310217, + -1279959989, -1285596052, -1291218348, -1296826816, -1302421396, + -1308002029, -1313568653, -1319121210, -1324659641, -1330183885, + -1335693885, -1341189580, -1346670912, -1352137822, -1357590252, + -1363028143, -1368451438, -1373860077, -1379254004, -1384633159, + -1389997487, -1395346928, -1400681427, -1406000925, -1411305366, + -1416594694, -1421868850, -1427127780, -1432371426, -1437599733, + -1442812644, -1448010104, -1453192057, -1458358447, -1463509220, + -1468644319, -1473763690, -1478867279, -1483955030, -1489026889, + -1494082802, -1499122714, -1504146572, -1509154322, -1514145910, + -1519121283, -1524080387, -1529023170, -1533949577, -1538859558, + -1543753058, -1548630027, -1553490410, -1558334157, -1563161216, + -1567971534, -1572765060, -1577541744, -1582301533, -1587044377, + -1591770225, -1596479027, -1601170732, -1605845289, -1610502649, + -1615142762, -1619765578, -1624371047, -1628959121, -1633529750, + -1638082885, -1642618478, -1647136479, -1651636841, -1656119516, + -1660584454, -1665031609, -1669460933, -1673872378, -1678265898, + -1682641444, -1686998971, -1691338432, -1695659779, -1699962968, + -1704247951, -1708514683, -1712763118, -1716993211, -1721204917, + -1725398189, -1729572984, -1733729257, -1737866963, -1741986057, + -1746086497, -1750168237, -1754231234, -1758275445, -1762300826, + -1766307335, -1770294927, -1774263561, -1778213194, -1782143784, + -1786055289, -1789947667, -1793820875, -1797674873, -1801509620, + -1805325074, -1809121194, -1812897940, -1816655271, -1820393147, + -1824111529, -1827810376, -1831489648, -1835149306, -1838789312, + -1842409625, -1846010208, -1849591022, -1853152028, -1856693188, + -1860214464, -1863715819, -1867197215, -1870658615, -1874099982, + -1877521279, -1880922469, -1884303515, -1887664383, -1891005035, + -1894325435, -1897625550, -1900905342, -1904164776, -1907403819, + -1910622435, -1913820590, -1916998250, -1920155379, -1923291946, + -1926407915, -1929503255, -1932577931, -1935631910, -1938665161, + -1941677650, -1944669345, -1947640214, -1950590226, -1953519348, + -1956427550, -1959314800, -1962181067, -1965026321, -1967850531, + -1970653667, -1973435699, -1976196596, -1978936331, -1981654873, + -1984352192, -1987028261, -1989683050, -1992316532, -1994928677, + -1997519459, -2000088848, -2002636818, -2005163342, -2007668391, + -2010151941, -2012613963, -2015054432, -2017473321, -2019870604, + -2022246257, -2024600252, -2026932566, -2029243173, -2031532049, + -2033799168, -2036044507, -2038268042, -2040469748, -2042649603, + -2044807583, -2046943664, -2049057824, -2051150040, -2053220291, + -2055268553, -2057294804, -2059299024, -2061281190, -2063241282, + -2065179277, -2067095157, -2068988899, -2070860485, -2072709893, + -2074537104, -2076342098, -2078124857, -2079885360, -2081623590, + -2083339527, -2085033153, -2086704450, -2088353400, -2089979985, + -2091584189, -2093165993, -2094725382, -2096262337, -2097776843, + -2099268884, -2100738443, -2102185505, -2103610054, -2105012075, + -2106391553, -2107748474, -2109082822, -2110394584, -2111683744, + -2112950291, -2114194210, -2115415487, -2116614110, -2117790065, + -2118943341, -2120073924, -2121181804, -2122266967, -2123329402, + -2124369098, -2125386044, -2126380229, -2127351642, -2128300272, + -2129226111, -2130129147, -2131009371, -2131866773, -2132701345, + -2133513078, -2134301962, -2135067990, -2135811153, -2136531442, + -2137228852, -2137903373, -2138555000, -2139183723, -2139789539, + -2140372438, -2140932416, -2141469466, -2141983583, -2142474761, + -2142942995, -2143388280, -2143810610, -2144209982, -2144586392, + -2144939834, -2145270306, -2145577804, -2145862324, -2146123864, + -2146362421, -2146577992, -2146770575, -2146940167, -2147086768, + -2147210375, -2147310987, -2147388603, -2147443222, -2147474844, + 2147482929, 2147425435, 2147275952, 2147034487, 2146701050, + 2146275656, 2145758322, 2145149071, 2144447929, 2143654926, + 2142770096, 2141793477, 2140725111, 2139565043, 2138313323, + 2136970005, 2135535146, 2134008809, 2132391057, 2130681961, + 2128881593, 2126990031, 2125007356, 2122933653, 2120769010, + 2118513521, 2116167282, 2113730393, 2111202959, 2108585087, + 2105876892, 2103078487, 2100189994, 2097211535, 2094143239, + 2090985237, 2087737664, 2084400659, 2080974365, 2077458929, + 2073854502, 2070161238, 2066379295, 2062508835, 2058550025, + 2054503033, 2050368032, 2046145201, 2041834720, 2037436773, + 2032951550, 2028379241, 2023720043, 2018974156, 2014141783, + 2009223131, 2004218410, 1999127836, 1993951625, 1988690000, + 1983343186, 1977911412, 1972394912, 1966793920, 1961108677, + 1955339428, 1949486417, 1943549898, 1937530123, 1931427351, + 1925241843, 1918973864, 1912623682, 1906191570, 1899677803, + 1893082661, 1886406424, 1879649381, 1872811820, 1865894033, + 1858896318, 1851818974, 1844662304, 1837426615, 1830112217, + 1822719423, 1815248550, 1807699917, 1800073849, 1792370671, + 1784590714, 1776734311, 1768801799, 1760793518, 1752709809, + 1744551021, 1736317502, 1728009604, 1719627685, 1711172102, + 1702643219, 1694041400, 1685367013, 1676620432, 1667802029, + 1658912184, 1649951276, 1640919689, 1631817811, 1622646032, + 1613404744, 1604094343, 1594715227, 1585267800, 1575752465, + 1566169630, 1556519705, 1546803104, 1537020244, 1527171542, + 1517257422, 1507278307, 1497234626, 1487126808, 1476955286, + 1466720497, 1456422878, 1446062871, 1435640919, 1425157469, + 1414612971, 1404007875, 1393342636, 1382617710, 1371833558, + 1360990642, 1350089425, 1339130374, 1328113960, 1317040654, + 1305910930, 1294725265, 1283484138, 1272188032, 1260837429, + 1249432816, 1237974681, 1226463516, 1214899813, 1203284068, + 1191616778, 1179898443, 1168129565, 1156310649, 1144442200, + 1132524727, 1120558740, 1108544752, 1096483278, 1084374834, + 1072219940, 1060019115, 1047772882, 1035481766, 1023146293, + 1010766993, 998344394, 985879030, 973371434, 960822142, + 948231691, 935600622, 922929474, 910218791, 897469118, + 884680999, 871854984, 858991622, 846091463, 833155061, + 820182969, 807175743, 794133941, 781058120, 767948841, + 754806666, 741632158, 728425880, 715188400, 701920283, + 688622098, 675294414, 661937804, 648552838, 635140090, + 621700135, 608233549, 594740907, 581222789, 567679774, + 554112440, 540521371, 526907147, 513270353, 499611571, + 485931388, 472230390, 458509162, 444768294, 431008373, + 417229989, 403433732, 389620194, 375789965, 361943639, + 348081809, 334205068, 320314011, 306409232, 292491328, + 278560894, 264618528, 250664827, 236700388, 222725809, + 208741690, 194748629, 180747225, 166738079, 152721790, + 138698959, 124670187, 110636075, 96597223, 82554233, + 68507707, 54458246, 40406452, 26352928, 12298274, + -1756906, -15812011, -29866438, -43919586, -57970853, + -72019637, -86065335, -100107347, -114145071, -128177904, + -142205248, -156226499, -170241059, -184248325, -198247699, + -212238581, -226220372, -240192472, -254154282, -268105206, + -282044645, -295972002, -309886680, -323788084, -337675619, + -351548688, -365406698, -379249055, -393075166, -406884440, + -420676284, -434450107, -448205320, -461941333, -475657559, + -489353409, -503028296, -516681636, -530312842, -543921332, + -557506522, -571067830, -584604676, -598116479, -611602660, + -625062643, -638495850, -651901706, -665279637, -678629069, + -691949432, -705240153, -718500664, -731730397, -744928785, + -758095263, -771229267, -784330234, -797397602, -810430813, + -823429308, -836392529, -849319923, -862210934, -875065011, + -887881603, -900660162, -913400139, -926100989, -938762167, + -951383133, -963963344, -976502263, -988999351, -1001454074, + -1013865898, -1026234291, -1038558724, -1050838668, -1063073598, + -1075262990, -1087406320, -1099503070, -1111552721, -1123554757, + -1135508663, -1147413928, -1159270041, -1171076495, -1182832785, + -1194538405, -1206192856, -1217795637, -1229346252, -1240844206, + -1252289006, -1263680162, -1275017186, -1286299593, -1297526899, + -1308698624, -1319814288, -1330873416, -1341875533, -1352820169, + -1363706855, -1374535124, -1385304512, -1396014559, -1406664805, + -1417254794, -1427784073, -1438252190, -1448658697, -1459003149, + -1469285102, -1479504115, -1489659751, -1499751576, -1509779156, + -1519742062, -1529639867, -1539472148, -1549238483, -1558938453, + -1568571644, -1578137643, -1587636039, -1597066426, -1606428400, + -1615721561, -1624945509, -1634099849, -1643184191, -1652198144, + -1661141322, -1670013342, -1678813825, -1687542393, -1696198672, + -1704782292, -1713292884, -1721730085, -1730093532, -1738382868, + -1746597738, -1754737789, -1762802673, -1770792044, -1778705561, + -1786542883, -1794303676, -1801987607, -1809594347, -1817123570, + -1824574954, -1831948179, -1839242929, -1846458892, -1853595759, + -1860653224, -1867630985, -1874528743, -1881346202, -1888083070, + -1894739060, -1901313885, -1907807264, -1914218919, -1920548575, + -1926795962, -1932960811, -1939042858, -1945041843, -1950957509, + -1956789602, -1962537873, -1968202076, -1973781967, -1979277308, + -1984687864, -1990013401, -1995253694, -2000408516, -2005477648, + -2010460871, -2015357973, -2020168744, -2024892978, -2029530472, + -2034081027, -2038544449, -2042920547, -2047209133, -2051410023, + -2055523038, -2059548001, -2063484740, -2067333086, -2071092874, + -2074763944, -2078346137, -2081839301, -2085243286, -2088557947, + -2091783140, -2094918728, -2097964577, -2100920556, -2103786539, + -2106562402, -2109248028, -2111843300, -2114348108, -2116762344, + -2119085905, -2121318692, -2123460608, -2125511562, -2127471467, + -2129340237, -2131117794, -2132804061, -2134398966, -2135902440, + -2137314419, -2138634843, -2139863654, -2141000801, -2142046235, + -2142999911, -2143861787, -2144631828, -2145310000, -2145896274, + -2146390624, -2146793031, -2147103476, -2147321946, -2147448433, + 2147480773, 2147250799, 2146652904, 2145687192, 2144353827, + 2142653038, 2140585116, 2138150417, 2135349356, 2132182414, + 2128650133, 2124753120, 2120492040, 2115867626, 2110880668, + 2105532022, 2099822604, 2093753392, 2087325426, 2080539807, + 2073397699, 2065900325, 2058048970, 2049844978, 2041289756, + 2032384769, 2023131544, 2013531666, 2003586779, 1993298588, + 1982668856, 1971699403, 1960392110, 1948748914, 1936771810, + 1924462850, 1911824143, 1898857855, 1885566207, 1871951478, + 1858015999, 1843762158, 1829192399, 1814309216, 1799115162, + 1783612838, 1767804901, 1751694060, 1735283075, 1718574758, + 1701571972, 1684277631, 1666694698, 1648826185, 1630675154, + 1612244715, 1593538026, 1574558293, 1555308768, 1535792748, + 1516013578, 1495974647, 1475679389, 1455131280, 1434333842, + 1413290638, 1392005275, 1370481398, 1348722696, 1326732898, + 1304515771, 1282075122, 1259414796, 1236538675, 1213450681, + 1190154767, 1166654927, 1142955186, 1119059606, 1094972281, + 1070697338, 1046238936, 1021601267, 996788551, 971805042, + 946655018, 921342790, 895872694, 870249095, 844476384, + 818558976, 792501312, 766307857, 739983099, 713531549, + 686957739, 660266222, 633461572, 606548381, 579531262, + 552414843, 525203770, 497902707, 470516330, 443049333, + 415506422, 387892316, 360211746, 332469456, 304670200, + 276818739, 248919847, 220978304, 192998897, 164986421, + 136945676, 108881465, 80798598, 52701887, 24596146, + -3513810, -31623164, -59727099, -87820801, -115899455, + -143958250, -171992378, -199997036, -227967426, -255898755, + -283786237, -311625094, -339410555, -367137861, -394802258, + -422399009, -449923384, -477370666, -504736154, -532015158, + -559203003, -586295032, -613286603, -640173090, -666949886, + -693612404, -720156076, -746576352, -772868706, -799028633, + -825051651, -850933300, -876669146, -902254780, -927685817, + -952957899, -978066697, -1003007909, -1027777260, -1052370507, + -1076783436, -1101011863, -1125051638, -1148898640, -1172548785, + -1195998020, -1219242327, -1242277723, -1265100260, -1287706030, + -1310091157, -1332251808, -1354184184, -1375884527, -1397349119, + -1418574283, -1439556382, -1460291820, -1480777044, -1501008545, + -1520982856, -1540696555, -1560146263, -1579328647, -1598240423, + -1616878347, -1635239228, -1653319919, -1671117323, -1688628389, + -1705850117, -1722779556, -1739413807, -1755750017, -1771785389, + -1787517174, -1802942678, -1818059257, -1832864320, -1847355332, + -1861529809, -1875385322, -1888919498, -1902130017, -1915014616, + -1927571087, -1939797279, -1951691096, -1963250501, -1974473513, + -1985358210, -1995902725, -2006105253, -2015964045, -2025477412, + -2034643724, -2043461410, -2051928960, -2060044922, -2067807906, + -2075216581, -2082269679, -2088965991, -2095304370, -2101283728, + -2106903043, -2112161350, -2117057750, -2121591402, -2125761531, + -2129567422, -2133008422, -2136083942, -2138793455, -2141136497, + -2143112666, -2144721624, -2145963095, -2146836866, -2147342788, }; -#endif +# endif static const CELTMode mode96000_1920_240 = { -96000, /* Fs */ -240, /* overlap */ -21, /* nbEBands */ -21, /* effEBands */ -{30245, 7209, 6197, 5415, }, /* preemph */ -eband5ms, /* eBands */ -3, /* maxLM */ -8, /* nbShortMdcts */ -240, /* shortMdctSize */ -11, /* nbAllocVectors */ -band_allocation, /* allocVectors */ -logN400, /* logN */ -window240, /* window */ -{3840, 3, {&fft_state96000_1920_0, &fft_state96000_1920_1, &fft_state96000_1920_2, &fft_state96000_1920_3, }, mdct_twiddles1920}, /* mdct */ -{392, cache_index50, cache_bits50, cache_caps50}, /* cache */ -#ifdef ENABLE_QEXT -{86, qext_cache_index50, qext_cache_bits50, qext_cache_caps50}, /* qext_cache */ -#endif + 96000, /* Fs */ + 240, /* overlap */ + 21, /* nbEBands */ + 21, /* effEBands */ + {30245, 7209, 6197, 5415, }, /* preemph */ + eband5ms, /* eBands */ + 3, /* maxLM */ + 8, /* nbShortMdcts */ + 240, /* shortMdctSize */ + 11, /* nbAllocVectors */ + band_allocation, /* allocVectors */ + logN400, /* logN */ + window240, /* window */ + {3840, 3, {&fft_state96000_1920_0, &fft_state96000_1920_1, &fft_state96000_1920_2, &fft_state96000_1920_3, }, + mdct_twiddles1920}, /* mdct */ + {392, cache_index50, cache_bits50, cache_caps50}, /* cache */ }; #endif /* ENABLE_QEXT */ /* List of all the available modes */ #ifdef ENABLE_QEXT -#define TOTAL_MODES 2 +# define TOTAL_MODES 2 static const CELTMode * const static_mode_list[TOTAL_MODES] = { -&mode48000_960_120, -&mode96000_1920_240, + &mode48000_960_120, + &mode96000_1920_240, }; #else -#define TOTAL_MODES 1 +# define TOTAL_MODES 1 static const CELTMode * const static_mode_list[TOTAL_MODES] = { -&mode48000_960_120, + &mode48000_960_120, }; #endif diff --git a/celt/static_modes_fixed_arm_ne10.h b/celt/static_modes_fixed_arm_ne10.h index 762309219..dccb8386b 100644 --- a/celt/static_modes_fixed_arm_ne10.h +++ b/celt/static_modes_fixed_arm_ne10.h @@ -4,385 +4,385 @@ #include #ifndef NE10_FFT_PARAMS48000_960 -#define NE10_FFT_PARAMS48000_960 +# define NE10_FFT_PARAMS48000_960 static const ne10_int32_t ne10_factors_480[64] = { -4, 40, 4, 30, 2, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, }; + 4, 40, 4, 30, 2, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, }; static const ne10_int32_t ne10_factors_240[64] = { -3, 20, 4, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, }; + 3, 20, 4, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, }; static const ne10_int32_t ne10_factors_120[64] = { -3, 10, 2, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, }; + 3, 10, 2, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, }; static const ne10_int32_t ne10_factors_60[64] = { -2, 5, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, }; + 2, 5, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, }; static const ne10_fft_cpx_int32_t ne10_twiddles_480[480] = { -{0,0}, {2147483647,0}, {2147483647,0}, -{2147483647,0}, {1961823921,-873460313}, {1436946998,-1595891394}, -{2147483647,0}, {1436946998,-1595891394}, {-224473265,-2135719496}, -{2147483647,0}, {663608871,-2042378339}, {-1737350854,-1262259096}, -{2147483647,0}, {-224473265,-2135719496}, {-2100555935,446487152}, -{2147483647,0}, {2100555974,-446486968}, {1961823921,-873460313}, -{1737350743,-1262259248}, {1436946998,-1595891394}, {1073741769,-1859775424}, -{663608871,-2042378339}, {224473078,-2135719516}, {-224473265,-2135719496}, -{-663609049,-2042378281}, {-1073741932,-1859775330}, {-1436947137,-1595891268}, -{-1737350854,-1262259096}, {-1961823997,-873460141}, {-2100556013,-446486785}, -{2147483647,0}, {2144540595,-112390613}, {2135719506,-224473172}, -{2121044558,-335940465}, {2100555974,-446486968}, {2074309912,-555809682}, -{2042378310,-663608960}, {2004848691,-769589332}, {1961823921,-873460313}, -{1913421927,-974937199}, {1859775377,-1073741851}, {1801031311,-1169603450}, -{1737350743,-1262259248}, {1668908218,-1351455280}, {1595891331,-1436947067}, -{1518500216,-1518500282}, {1436946998,-1595891394}, {1351455207,-1668908277}, -{1262259172,-1737350799}, {1169603371,-1801031362}, {1073741769,-1859775424}, -{974937230,-1913421912}, {873460227,-1961823959}, {769589125,-2004848771}, -{663608871,-2042378339}, {555809715,-2074309903}, {446486876,-2100555994}, -{335940246,-2121044593}, {224473078,-2135719516}, {112390647,-2144540593}, -{2147483647,0}, {2135719506,-224473172}, {2100555974,-446486968}, -{2042378310,-663608960}, {1961823921,-873460313}, {1859775377,-1073741851}, -{1737350743,-1262259248}, {1595891331,-1436947067}, {1436946998,-1595891394}, -{1262259172,-1737350799}, {1073741769,-1859775424}, {873460227,-1961823959}, -{663608871,-2042378339}, {446486876,-2100555994}, {224473078,-2135719516}, -{-94,-2147483647}, {-224473265,-2135719496}, {-446487060,-2100555955}, -{-663609049,-2042378281}, {-873460398,-1961823883}, {-1073741932,-1859775330}, -{-1262259116,-1737350839}, {-1436947137,-1595891268}, {-1595891628,-1436946738}, -{-1737350854,-1262259096}, {-1859775343,-1073741910}, {-1961823997,-873460141}, -{-2042378447,-663608538}, {-2100556013,-446486785}, {-2135719499,-224473240}, -{2147483647,0}, {2121044558,-335940465}, {2042378310,-663608960}, -{1913421927,-974937199}, {1737350743,-1262259248}, {1518500216,-1518500282}, -{1262259172,-1737350799}, {974937230,-1913421912}, {663608871,-2042378339}, -{335940246,-2121044593}, {-94,-2147483647}, {-335940431,-2121044564}, -{-663609049,-2042378281}, {-974937397,-1913421827}, {-1262259116,-1737350839}, -{-1518500258,-1518500240}, {-1737350854,-1262259096}, {-1913422071,-974936918}, -{-2042378447,-663608538}, {-2121044568,-335940406}, {-2147483647,188}, -{-2121044509,335940777}, {-2042378331,663608895}, {-1913421900,974937252}, -{-1737350633,1262259400}, {-1518499993,1518500506}, {-1262258813,1737351059}, -{-974936606,1913422229}, {-663609179,2042378239}, {-335940566,2121044542}, -{2147483647,0}, {2147299667,-28109693}, {2146747758,-56214570}, -{2145828015,-84309815}, {2144540595,-112390613}, {2142885719,-140452154}, -{2140863671,-168489630}, {2138474797,-196498235}, {2135719506,-224473172}, -{2132598271,-252409646}, {2129111626,-280302871}, {2125260168,-308148068}, -{2121044558,-335940465}, {2116465518,-363675300}, {2111523833,-391347822}, -{2106220349,-418953288}, {2100555974,-446486968}, {2094531681,-473944146}, -{2088148500,-501320115}, {2081407525,-528610186}, {2074309912,-555809682}, -{2066856885,-582913912}, {2059049696,-609918325}, {2050889698,-636818231}, -{2042378310,-663608960}, {2033516972,-690285983}, {2024307180,-716844791}, -{2014750533,-743280770}, {2004848691,-769589332}, {1994603329,-795766029}, -{1984016179,-821806435}, {1973089077,-847706028}, {1961823921,-873460313}, -{1950222618,-899064934}, {1938287127,-924515564}, {1926019520,-949807783}, -{1913421927,-974937199}, {1900496481,-999899565}, {1887245364,-1024690661}, -{1873670877,-1049306180}, {1859775377,-1073741851}, {1845561215,-1097993541}, -{1831030826,-1122057097}, {1816186632,-1145928502}, {1801031311,-1169603450}, -{1785567394,-1193077993}, {1769797456,-1216348214}, {1753724345,-1239409914}, -{1737350743,-1262259248}, {1720679456,-1284892300}, {1703713340,-1307305194}, -{1686455222,-1329494189}, {1668908218,-1351455280}, {1651075255,-1373184807}, -{1632959307,-1394679144}, {1614563642,-1415934412}, {1595891331,-1436947067}, -{1576945572,-1457713510}, {1557729613,-1478230181}, {1538246655,-1498493658}, -{1518500216,-1518500282}, {1498493590,-1538246721}, {1478230113,-1557729677}, -{1457713441,-1576945636}, {1436946998,-1595891394}, {1415934341,-1614563704}, -{1394679073,-1632959368}, {1373184735,-1651075315}, {1351455207,-1668908277}, -{1329494115,-1686455280}, {1307305120,-1703713397}, {1284892225,-1720679512}, -{1262259172,-1737350799}, {1239409837,-1753724400}, {1216348136,-1769797510}, -{1193077915,-1785567446}, {1169603371,-1801031362}, {1145928423,-1816186682}, -{1122057017,-1831030875}, {1097993571,-1845561197}, {1073741769,-1859775424}, -{1049305987,-1873670985}, {1024690635,-1887245378}, {999899482,-1900496524}, -{974937230,-1913421912}, {949807699,-1926019561}, {924515422,-1938287195}, -{899064965,-1950222603}, {873460227,-1961823959}, {847705824,-1973089164}, -{821806407,-1984016190}, {795765941,-1994603364}, {769589125,-2004848771}, -{743280682,-2014750566}, {716844642,-2024307233}, {690286016,-2033516961}, -{663608871,-2042378339}, {636818019,-2050889764}, {609918296,-2059049705}, -{582913822,-2066856911}, {555809715,-2074309903}, {528610126,-2081407540}, -{501319962,-2088148536}, {473944148,-2094531680}, {446486876,-2100555994}, -{418953102,-2106220386}, {391347792,-2111523838}, {363675176,-2116465540}, -{335940246,-2121044593}, {308148006,-2125260177}, {280302715,-2129111646}, -{252409648,-2132598271}, {224473078,-2135719516}, {196498046,-2138474814}, -{168489600,-2140863674}, {140452029,-2142885728}, {112390647,-2144540593}, -{84309753,-2145828017}, {56214412,-2146747762}, {28109695,-2147299667}, -{2147483647,0}, {2146747758,-56214570}, {2144540595,-112390613}, -{2140863671,-168489630}, {2135719506,-224473172}, {2129111626,-280302871}, -{2121044558,-335940465}, {2111523833,-391347822}, {2100555974,-446486968}, -{2088148500,-501320115}, {2074309912,-555809682}, {2059049696,-609918325}, -{2042378310,-663608960}, {2024307180,-716844791}, {2004848691,-769589332}, -{1984016179,-821806435}, {1961823921,-873460313}, {1938287127,-924515564}, -{1913421927,-974937199}, {1887245364,-1024690661}, {1859775377,-1073741851}, -{1831030826,-1122057097}, {1801031311,-1169603450}, {1769797456,-1216348214}, -{1737350743,-1262259248}, {1703713340,-1307305194}, {1668908218,-1351455280}, -{1632959307,-1394679144}, {1595891331,-1436947067}, {1557729613,-1478230181}, -{1518500216,-1518500282}, {1478230113,-1557729677}, {1436946998,-1595891394}, -{1394679073,-1632959368}, {1351455207,-1668908277}, {1307305120,-1703713397}, -{1262259172,-1737350799}, {1216348136,-1769797510}, {1169603371,-1801031362}, -{1122057017,-1831030875}, {1073741769,-1859775424}, {1024690635,-1887245378}, -{974937230,-1913421912}, {924515422,-1938287195}, {873460227,-1961823959}, -{821806407,-1984016190}, {769589125,-2004848771}, {716844642,-2024307233}, -{663608871,-2042378339}, {609918296,-2059049705}, {555809715,-2074309903}, -{501319962,-2088148536}, {446486876,-2100555994}, {391347792,-2111523838}, -{335940246,-2121044593}, {280302715,-2129111646}, {224473078,-2135719516}, -{168489600,-2140863674}, {112390647,-2144540593}, {56214412,-2146747762}, -{-94,-2147483647}, {-56214600,-2146747757}, {-112390835,-2144540584}, -{-168489787,-2140863659}, {-224473265,-2135719496}, {-280302901,-2129111622}, -{-335940431,-2121044564}, {-391347977,-2111523804}, {-446487060,-2100555955}, -{-501320144,-2088148493}, {-555809896,-2074309855}, {-609918476,-2059049651}, -{-663609049,-2042378281}, {-716844819,-2024307170}, {-769589300,-2004848703}, -{-821806581,-1984016118}, {-873460398,-1961823883}, {-924515591,-1938287114}, -{-974937397,-1913421827}, {-1024690575,-1887245411}, {-1073741932,-1859775330}, -{-1122057395,-1831030643}, {-1169603421,-1801031330}, {-1216348291,-1769797403}, -{-1262259116,-1737350839}, {-1307305268,-1703713283}, {-1351455453,-1668908078}, -{-1394679021,-1632959413}, {-1436947137,-1595891268}, {-1478230435,-1557729372}, -{-1518500258,-1518500240}, {-1557729742,-1478230045}, {-1595891628,-1436946738}, -{-1632959429,-1394679001}, {-1668908417,-1351455035}, {-1703713298,-1307305248}, -{-1737350854,-1262259096}, {-1769797708,-1216347848}, {-1801031344,-1169603400}, -{-1831030924,-1122056937}, {-1859775343,-1073741910}, {-1887245423,-1024690552}, -{-1913422071,-974936918}, {-1938287125,-924515568}, {-1961823997,-873460141}, -{-1984016324,-821806084}, {-2004848713,-769589276}, {-2024307264,-716844553}, -{-2042378447,-663608538}, {-2059049731,-609918206}, {-2074309994,-555809377}, -{-2088148499,-501320119}, {-2100556013,-446486785}, {-2111523902,-391347448}, -{-2121044568,-335940406}, {-2129111659,-280302621}, {-2135719499,-224473240}, -{-2140863681,-168489506}, {-2144540612,-112390298}, {-2146747758,-56214574}, -{2147483647,0}, {2145828015,-84309815}, {2140863671,-168489630}, -{2132598271,-252409646}, {2121044558,-335940465}, {2106220349,-418953288}, -{2088148500,-501320115}, {2066856885,-582913912}, {2042378310,-663608960}, -{2014750533,-743280770}, {1984016179,-821806435}, {1950222618,-899064934}, -{1913421927,-974937199}, {1873670877,-1049306180}, {1831030826,-1122057097}, -{1785567394,-1193077993}, {1737350743,-1262259248}, {1686455222,-1329494189}, -{1632959307,-1394679144}, {1576945572,-1457713510}, {1518500216,-1518500282}, -{1457713441,-1576945636}, {1394679073,-1632959368}, {1329494115,-1686455280}, -{1262259172,-1737350799}, {1193077915,-1785567446}, {1122057017,-1831030875}, -{1049305987,-1873670985}, {974937230,-1913421912}, {899064965,-1950222603}, -{821806407,-1984016190}, {743280682,-2014750566}, {663608871,-2042378339}, -{582913822,-2066856911}, {501319962,-2088148536}, {418953102,-2106220386}, -{335940246,-2121044593}, {252409648,-2132598271}, {168489600,-2140863674}, -{84309753,-2145828017}, {-94,-2147483647}, {-84309940,-2145828010}, -{-168489787,-2140863659}, {-252409834,-2132598249}, {-335940431,-2121044564}, -{-418953286,-2106220349}, {-501320144,-2088148493}, {-582914003,-2066856860}, -{-663609049,-2042378281}, {-743280858,-2014750501}, {-821806581,-1984016118}, -{-899065136,-1950222525}, {-974937397,-1913421827}, {-1049306374,-1873670768}, -{-1122057395,-1831030643}, {-1193078284,-1785567199}, {-1262259116,-1737350839}, -{-1329494061,-1686455323}, {-1394679021,-1632959413}, {-1457713485,-1576945595}, -{-1518500258,-1518500240}, {-1576945613,-1457713466}, {-1632959429,-1394679001}, -{-1686455338,-1329494041}, {-1737350854,-1262259096}, {-1785567498,-1193077837}, -{-1831030924,-1122056937}, {-1873671031,-1049305905}, {-1913422071,-974936918}, -{-1950222750,-899064648}, {-1984016324,-821806084}, {-2014750687,-743280354}, -{-2042378447,-663608538}, {-2066856867,-582913978}, {-2088148499,-501320119}, -{-2106220354,-418953261}, {-2121044568,-335940406}, {-2132598282,-252409555}, -{-2140863681,-168489506}, {-2145828021,-84309659}, {-2147483647,188}, -{-2145828006,84310034}, {-2140863651,168489881}, {-2132598237,252409928}, -{-2121044509,335940777}, {-2106220281,418953629}, {-2088148411,501320484}, -{-2066856765,582914339}, {-2042378331,663608895}, {-2014750557,743280706}, -{-1984016181,821806431}, {-1950222593,899064989}, {-1913421900,974937252}, -{-1873670848,1049306232}, {-1831030728,1122057257}, {-1785567289,1193078149}, -{-1737350633,1262259400}, {-1686455106,1329494336}, {-1632959185,1394679287}, -{-1576945358,1457713742}, {-1518499993,1518500506}, {-1457713209,1576945850}, -{-1394678735,1632959656}, {-1329493766,1686455555}, {-1262258813,1737351059}, -{-1193077546,1785567692}, {-1122056638,1831031107}, {-1049305599,1873671202}, -{-974936606,1913422229}, {-899064330,1950222896}, {-821805761,1984016458}, -{-743280025,2014750808}, {-663609179,2042378239}, {-582914134,2066856823}, -{-501320277,2088148461}, {-418953420,2106220322}, {-335940566,2121044542}, -{-252409716,2132598263}, {-168489668,2140863668}, {-84309821,2145828015}, + {0, 0}, {2147483647, 0}, {2147483647, 0}, + {2147483647, 0}, {1961823921, -873460313}, {1436946998, -1595891394}, + {2147483647, 0}, {1436946998, -1595891394}, {-224473265, -2135719496}, + {2147483647, 0}, {663608871, -2042378339}, {-1737350854, -1262259096}, + {2147483647, 0}, {-224473265, -2135719496}, {-2100555935, 446487152}, + {2147483647, 0}, {2100555974, -446486968}, {1961823921, -873460313}, + {1737350743, -1262259248}, {1436946998, -1595891394}, {1073741769, -1859775424}, + {663608871, -2042378339}, {224473078, -2135719516}, {-224473265, -2135719496}, + {-663609049, -2042378281}, {-1073741932, -1859775330}, {-1436947137, -1595891268}, + {-1737350854, -1262259096}, {-1961823997, -873460141}, {-2100556013, -446486785}, + {2147483647, 0}, {2144540595, -112390613}, {2135719506, -224473172}, + {2121044558, -335940465}, {2100555974, -446486968}, {2074309912, -555809682}, + {2042378310, -663608960}, {2004848691, -769589332}, {1961823921, -873460313}, + {1913421927, -974937199}, {1859775377, -1073741851}, {1801031311, -1169603450}, + {1737350743, -1262259248}, {1668908218, -1351455280}, {1595891331, -1436947067}, + {1518500216, -1518500282}, {1436946998, -1595891394}, {1351455207, -1668908277}, + {1262259172, -1737350799}, {1169603371, -1801031362}, {1073741769, -1859775424}, + {974937230, -1913421912}, {873460227, -1961823959}, {769589125, -2004848771}, + {663608871, -2042378339}, {555809715, -2074309903}, {446486876, -2100555994}, + {335940246, -2121044593}, {224473078, -2135719516}, {112390647, -2144540593}, + {2147483647, 0}, {2135719506, -224473172}, {2100555974, -446486968}, + {2042378310, -663608960}, {1961823921, -873460313}, {1859775377, -1073741851}, + {1737350743, -1262259248}, {1595891331, -1436947067}, {1436946998, -1595891394}, + {1262259172, -1737350799}, {1073741769, -1859775424}, {873460227, -1961823959}, + {663608871, -2042378339}, {446486876, -2100555994}, {224473078, -2135719516}, + {-94, -2147483647}, {-224473265, -2135719496}, {-446487060, -2100555955}, + {-663609049, -2042378281}, {-873460398, -1961823883}, {-1073741932, -1859775330}, + {-1262259116, -1737350839}, {-1436947137, -1595891268}, {-1595891628, -1436946738}, + {-1737350854, -1262259096}, {-1859775343, -1073741910}, {-1961823997, -873460141}, + {-2042378447, -663608538}, {-2100556013, -446486785}, {-2135719499, -224473240}, + {2147483647, 0}, {2121044558, -335940465}, {2042378310, -663608960}, + {1913421927, -974937199}, {1737350743, -1262259248}, {1518500216, -1518500282}, + {1262259172, -1737350799}, {974937230, -1913421912}, {663608871, -2042378339}, + {335940246, -2121044593}, {-94, -2147483647}, {-335940431, -2121044564}, + {-663609049, -2042378281}, {-974937397, -1913421827}, {-1262259116, -1737350839}, + {-1518500258, -1518500240}, {-1737350854, -1262259096}, {-1913422071, -974936918}, + {-2042378447, -663608538}, {-2121044568, -335940406}, {-2147483647, 188}, + {-2121044509, 335940777}, {-2042378331, 663608895}, {-1913421900, 974937252}, + {-1737350633, 1262259400}, {-1518499993, 1518500506}, {-1262258813, 1737351059}, + {-974936606, 1913422229}, {-663609179, 2042378239}, {-335940566, 2121044542}, + {2147483647, 0}, {2147299667, -28109693}, {2146747758, -56214570}, + {2145828015, -84309815}, {2144540595, -112390613}, {2142885719, -140452154}, + {2140863671, -168489630}, {2138474797, -196498235}, {2135719506, -224473172}, + {2132598271, -252409646}, {2129111626, -280302871}, {2125260168, -308148068}, + {2121044558, -335940465}, {2116465518, -363675300}, {2111523833, -391347822}, + {2106220349, -418953288}, {2100555974, -446486968}, {2094531681, -473944146}, + {2088148500, -501320115}, {2081407525, -528610186}, {2074309912, -555809682}, + {2066856885, -582913912}, {2059049696, -609918325}, {2050889698, -636818231}, + {2042378310, -663608960}, {2033516972, -690285983}, {2024307180, -716844791}, + {2014750533, -743280770}, {2004848691, -769589332}, {1994603329, -795766029}, + {1984016179, -821806435}, {1973089077, -847706028}, {1961823921, -873460313}, + {1950222618, -899064934}, {1938287127, -924515564}, {1926019520, -949807783}, + {1913421927, -974937199}, {1900496481, -999899565}, {1887245364, -1024690661}, + {1873670877, -1049306180}, {1859775377, -1073741851}, {1845561215, -1097993541}, + {1831030826, -1122057097}, {1816186632, -1145928502}, {1801031311, -1169603450}, + {1785567394, -1193077993}, {1769797456, -1216348214}, {1753724345, -1239409914}, + {1737350743, -1262259248}, {1720679456, -1284892300}, {1703713340, -1307305194}, + {1686455222, -1329494189}, {1668908218, -1351455280}, {1651075255, -1373184807}, + {1632959307, -1394679144}, {1614563642, -1415934412}, {1595891331, -1436947067}, + {1576945572, -1457713510}, {1557729613, -1478230181}, {1538246655, -1498493658}, + {1518500216, -1518500282}, {1498493590, -1538246721}, {1478230113, -1557729677}, + {1457713441, -1576945636}, {1436946998, -1595891394}, {1415934341, -1614563704}, + {1394679073, -1632959368}, {1373184735, -1651075315}, {1351455207, -1668908277}, + {1329494115, -1686455280}, {1307305120, -1703713397}, {1284892225, -1720679512}, + {1262259172, -1737350799}, {1239409837, -1753724400}, {1216348136, -1769797510}, + {1193077915, -1785567446}, {1169603371, -1801031362}, {1145928423, -1816186682}, + {1122057017, -1831030875}, {1097993571, -1845561197}, {1073741769, -1859775424}, + {1049305987, -1873670985}, {1024690635, -1887245378}, {999899482, -1900496524}, + {974937230, -1913421912}, {949807699, -1926019561}, {924515422, -1938287195}, + {899064965, -1950222603}, {873460227, -1961823959}, {847705824, -1973089164}, + {821806407, -1984016190}, {795765941, -1994603364}, {769589125, -2004848771}, + {743280682, -2014750566}, {716844642, -2024307233}, {690286016, -2033516961}, + {663608871, -2042378339}, {636818019, -2050889764}, {609918296, -2059049705}, + {582913822, -2066856911}, {555809715, -2074309903}, {528610126, -2081407540}, + {501319962, -2088148536}, {473944148, -2094531680}, {446486876, -2100555994}, + {418953102, -2106220386}, {391347792, -2111523838}, {363675176, -2116465540}, + {335940246, -2121044593}, {308148006, -2125260177}, {280302715, -2129111646}, + {252409648, -2132598271}, {224473078, -2135719516}, {196498046, -2138474814}, + {168489600, -2140863674}, {140452029, -2142885728}, {112390647, -2144540593}, + {84309753, -2145828017}, {56214412, -2146747762}, {28109695, -2147299667}, + {2147483647, 0}, {2146747758, -56214570}, {2144540595, -112390613}, + {2140863671, -168489630}, {2135719506, -224473172}, {2129111626, -280302871}, + {2121044558, -335940465}, {2111523833, -391347822}, {2100555974, -446486968}, + {2088148500, -501320115}, {2074309912, -555809682}, {2059049696, -609918325}, + {2042378310, -663608960}, {2024307180, -716844791}, {2004848691, -769589332}, + {1984016179, -821806435}, {1961823921, -873460313}, {1938287127, -924515564}, + {1913421927, -974937199}, {1887245364, -1024690661}, {1859775377, -1073741851}, + {1831030826, -1122057097}, {1801031311, -1169603450}, {1769797456, -1216348214}, + {1737350743, -1262259248}, {1703713340, -1307305194}, {1668908218, -1351455280}, + {1632959307, -1394679144}, {1595891331, -1436947067}, {1557729613, -1478230181}, + {1518500216, -1518500282}, {1478230113, -1557729677}, {1436946998, -1595891394}, + {1394679073, -1632959368}, {1351455207, -1668908277}, {1307305120, -1703713397}, + {1262259172, -1737350799}, {1216348136, -1769797510}, {1169603371, -1801031362}, + {1122057017, -1831030875}, {1073741769, -1859775424}, {1024690635, -1887245378}, + {974937230, -1913421912}, {924515422, -1938287195}, {873460227, -1961823959}, + {821806407, -1984016190}, {769589125, -2004848771}, {716844642, -2024307233}, + {663608871, -2042378339}, {609918296, -2059049705}, {555809715, -2074309903}, + {501319962, -2088148536}, {446486876, -2100555994}, {391347792, -2111523838}, + {335940246, -2121044593}, {280302715, -2129111646}, {224473078, -2135719516}, + {168489600, -2140863674}, {112390647, -2144540593}, {56214412, -2146747762}, + {-94, -2147483647}, {-56214600, -2146747757}, {-112390835, -2144540584}, + {-168489787, -2140863659}, {-224473265, -2135719496}, {-280302901, -2129111622}, + {-335940431, -2121044564}, {-391347977, -2111523804}, {-446487060, -2100555955}, + {-501320144, -2088148493}, {-555809896, -2074309855}, {-609918476, -2059049651}, + {-663609049, -2042378281}, {-716844819, -2024307170}, {-769589300, -2004848703}, + {-821806581, -1984016118}, {-873460398, -1961823883}, {-924515591, -1938287114}, + {-974937397, -1913421827}, {-1024690575, -1887245411}, {-1073741932, -1859775330}, + {-1122057395, -1831030643}, {-1169603421, -1801031330}, {-1216348291, -1769797403}, + {-1262259116, -1737350839}, {-1307305268, -1703713283}, {-1351455453, -1668908078}, + {-1394679021, -1632959413}, {-1436947137, -1595891268}, {-1478230435, -1557729372}, + {-1518500258, -1518500240}, {-1557729742, -1478230045}, {-1595891628, -1436946738}, + {-1632959429, -1394679001}, {-1668908417, -1351455035}, {-1703713298, -1307305248}, + {-1737350854, -1262259096}, {-1769797708, -1216347848}, {-1801031344, -1169603400}, + {-1831030924, -1122056937}, {-1859775343, -1073741910}, {-1887245423, -1024690552}, + {-1913422071, -974936918}, {-1938287125, -924515568}, {-1961823997, -873460141}, + {-1984016324, -821806084}, {-2004848713, -769589276}, {-2024307264, -716844553}, + {-2042378447, -663608538}, {-2059049731, -609918206}, {-2074309994, -555809377}, + {-2088148499, -501320119}, {-2100556013, -446486785}, {-2111523902, -391347448}, + {-2121044568, -335940406}, {-2129111659, -280302621}, {-2135719499, -224473240}, + {-2140863681, -168489506}, {-2144540612, -112390298}, {-2146747758, -56214574}, + {2147483647, 0}, {2145828015, -84309815}, {2140863671, -168489630}, + {2132598271, -252409646}, {2121044558, -335940465}, {2106220349, -418953288}, + {2088148500, -501320115}, {2066856885, -582913912}, {2042378310, -663608960}, + {2014750533, -743280770}, {1984016179, -821806435}, {1950222618, -899064934}, + {1913421927, -974937199}, {1873670877, -1049306180}, {1831030826, -1122057097}, + {1785567394, -1193077993}, {1737350743, -1262259248}, {1686455222, -1329494189}, + {1632959307, -1394679144}, {1576945572, -1457713510}, {1518500216, -1518500282}, + {1457713441, -1576945636}, {1394679073, -1632959368}, {1329494115, -1686455280}, + {1262259172, -1737350799}, {1193077915, -1785567446}, {1122057017, -1831030875}, + {1049305987, -1873670985}, {974937230, -1913421912}, {899064965, -1950222603}, + {821806407, -1984016190}, {743280682, -2014750566}, {663608871, -2042378339}, + {582913822, -2066856911}, {501319962, -2088148536}, {418953102, -2106220386}, + {335940246, -2121044593}, {252409648, -2132598271}, {168489600, -2140863674}, + {84309753, -2145828017}, {-94, -2147483647}, {-84309940, -2145828010}, + {-168489787, -2140863659}, {-252409834, -2132598249}, {-335940431, -2121044564}, + {-418953286, -2106220349}, {-501320144, -2088148493}, {-582914003, -2066856860}, + {-663609049, -2042378281}, {-743280858, -2014750501}, {-821806581, -1984016118}, + {-899065136, -1950222525}, {-974937397, -1913421827}, {-1049306374, -1873670768}, + {-1122057395, -1831030643}, {-1193078284, -1785567199}, {-1262259116, -1737350839}, + {-1329494061, -1686455323}, {-1394679021, -1632959413}, {-1457713485, -1576945595}, + {-1518500258, -1518500240}, {-1576945613, -1457713466}, {-1632959429, -1394679001}, + {-1686455338, -1329494041}, {-1737350854, -1262259096}, {-1785567498, -1193077837}, + {-1831030924, -1122056937}, {-1873671031, -1049305905}, {-1913422071, -974936918}, + {-1950222750, -899064648}, {-1984016324, -821806084}, {-2014750687, -743280354}, + {-2042378447, -663608538}, {-2066856867, -582913978}, {-2088148499, -501320119}, + {-2106220354, -418953261}, {-2121044568, -335940406}, {-2132598282, -252409555}, + {-2140863681, -168489506}, {-2145828021, -84309659}, {-2147483647, 188}, + {-2145828006, 84310034}, {-2140863651, 168489881}, {-2132598237, 252409928}, + {-2121044509, 335940777}, {-2106220281, 418953629}, {-2088148411, 501320484}, + {-2066856765, 582914339}, {-2042378331, 663608895}, {-2014750557, 743280706}, + {-1984016181, 821806431}, {-1950222593, 899064989}, {-1913421900, 974937252}, + {-1873670848, 1049306232}, {-1831030728, 1122057257}, {-1785567289, 1193078149}, + {-1737350633, 1262259400}, {-1686455106, 1329494336}, {-1632959185, 1394679287}, + {-1576945358, 1457713742}, {-1518499993, 1518500506}, {-1457713209, 1576945850}, + {-1394678735, 1632959656}, {-1329493766, 1686455555}, {-1262258813, 1737351059}, + {-1193077546, 1785567692}, {-1122056638, 1831031107}, {-1049305599, 1873671202}, + {-974936606, 1913422229}, {-899064330, 1950222896}, {-821805761, 1984016458}, + {-743280025, 2014750808}, {-663609179, 2042378239}, {-582914134, 2066856823}, + {-501320277, 2088148461}, {-418953420, 2106220322}, {-335940566, 2121044542}, + {-252409716, 2132598263}, {-168489668, 2140863668}, {-84309821, 2145828015}, }; static const ne10_fft_cpx_int32_t ne10_twiddles_240[240] = { -{0,0}, {2147483647,0}, {2147483647,0}, -{2147483647,0}, {1961823921,-873460313}, {1436946998,-1595891394}, -{2147483647,0}, {1436946998,-1595891394}, {-224473265,-2135719496}, -{2147483647,0}, {663608871,-2042378339}, {-1737350854,-1262259096}, -{2147483647,0}, {-224473265,-2135719496}, {-2100555935,446487152}, -{2147483647,0}, {2135719506,-224473172}, {2100555974,-446486968}, -{2042378310,-663608960}, {1961823921,-873460313}, {1859775377,-1073741851}, -{1737350743,-1262259248}, {1595891331,-1436947067}, {1436946998,-1595891394}, -{1262259172,-1737350799}, {1073741769,-1859775424}, {873460227,-1961823959}, -{663608871,-2042378339}, {446486876,-2100555994}, {224473078,-2135719516}, -{2147483647,0}, {2100555974,-446486968}, {1961823921,-873460313}, -{1737350743,-1262259248}, {1436946998,-1595891394}, {1073741769,-1859775424}, -{663608871,-2042378339}, {224473078,-2135719516}, {-224473265,-2135719496}, -{-663609049,-2042378281}, {-1073741932,-1859775330}, {-1436947137,-1595891268}, -{-1737350854,-1262259096}, {-1961823997,-873460141}, {-2100556013,-446486785}, -{2147483647,0}, {2042378310,-663608960}, {1737350743,-1262259248}, -{1262259172,-1737350799}, {663608871,-2042378339}, {-94,-2147483647}, -{-663609049,-2042378281}, {-1262259116,-1737350839}, {-1737350854,-1262259096}, -{-2042378447,-663608538}, {-2147483647,188}, {-2042378331,663608895}, -{-1737350633,1262259400}, {-1262258813,1737351059}, {-663609179,2042378239}, -{2147483647,0}, {2146747758,-56214570}, {2144540595,-112390613}, -{2140863671,-168489630}, {2135719506,-224473172}, {2129111626,-280302871}, -{2121044558,-335940465}, {2111523833,-391347822}, {2100555974,-446486968}, -{2088148500,-501320115}, {2074309912,-555809682}, {2059049696,-609918325}, -{2042378310,-663608960}, {2024307180,-716844791}, {2004848691,-769589332}, -{1984016179,-821806435}, {1961823921,-873460313}, {1938287127,-924515564}, -{1913421927,-974937199}, {1887245364,-1024690661}, {1859775377,-1073741851}, -{1831030826,-1122057097}, {1801031311,-1169603450}, {1769797456,-1216348214}, -{1737350743,-1262259248}, {1703713340,-1307305194}, {1668908218,-1351455280}, -{1632959307,-1394679144}, {1595891331,-1436947067}, {1557729613,-1478230181}, -{1518500216,-1518500282}, {1478230113,-1557729677}, {1436946998,-1595891394}, -{1394679073,-1632959368}, {1351455207,-1668908277}, {1307305120,-1703713397}, -{1262259172,-1737350799}, {1216348136,-1769797510}, {1169603371,-1801031362}, -{1122057017,-1831030875}, {1073741769,-1859775424}, {1024690635,-1887245378}, -{974937230,-1913421912}, {924515422,-1938287195}, {873460227,-1961823959}, -{821806407,-1984016190}, {769589125,-2004848771}, {716844642,-2024307233}, -{663608871,-2042378339}, {609918296,-2059049705}, {555809715,-2074309903}, -{501319962,-2088148536}, {446486876,-2100555994}, {391347792,-2111523838}, -{335940246,-2121044593}, {280302715,-2129111646}, {224473078,-2135719516}, -{168489600,-2140863674}, {112390647,-2144540593}, {56214412,-2146747762}, -{2147483647,0}, {2144540595,-112390613}, {2135719506,-224473172}, -{2121044558,-335940465}, {2100555974,-446486968}, {2074309912,-555809682}, -{2042378310,-663608960}, {2004848691,-769589332}, {1961823921,-873460313}, -{1913421927,-974937199}, {1859775377,-1073741851}, {1801031311,-1169603450}, -{1737350743,-1262259248}, {1668908218,-1351455280}, {1595891331,-1436947067}, -{1518500216,-1518500282}, {1436946998,-1595891394}, {1351455207,-1668908277}, -{1262259172,-1737350799}, {1169603371,-1801031362}, {1073741769,-1859775424}, -{974937230,-1913421912}, {873460227,-1961823959}, {769589125,-2004848771}, -{663608871,-2042378339}, {555809715,-2074309903}, {446486876,-2100555994}, -{335940246,-2121044593}, {224473078,-2135719516}, {112390647,-2144540593}, -{-94,-2147483647}, {-112390835,-2144540584}, {-224473265,-2135719496}, -{-335940431,-2121044564}, {-446487060,-2100555955}, {-555809896,-2074309855}, -{-663609049,-2042378281}, {-769589300,-2004848703}, {-873460398,-1961823883}, -{-974937397,-1913421827}, {-1073741932,-1859775330}, {-1169603421,-1801031330}, -{-1262259116,-1737350839}, {-1351455453,-1668908078}, {-1436947137,-1595891268}, -{-1518500258,-1518500240}, {-1595891628,-1436946738}, {-1668908417,-1351455035}, -{-1737350854,-1262259096}, {-1801031344,-1169603400}, {-1859775343,-1073741910}, -{-1913422071,-974936918}, {-1961823997,-873460141}, {-2004848713,-769589276}, -{-2042378447,-663608538}, {-2074309994,-555809377}, {-2100556013,-446486785}, -{-2121044568,-335940406}, {-2135719499,-224473240}, {-2144540612,-112390298}, -{2147483647,0}, {2140863671,-168489630}, {2121044558,-335940465}, -{2088148500,-501320115}, {2042378310,-663608960}, {1984016179,-821806435}, -{1913421927,-974937199}, {1831030826,-1122057097}, {1737350743,-1262259248}, -{1632959307,-1394679144}, {1518500216,-1518500282}, {1394679073,-1632959368}, -{1262259172,-1737350799}, {1122057017,-1831030875}, {974937230,-1913421912}, -{821806407,-1984016190}, {663608871,-2042378339}, {501319962,-2088148536}, -{335940246,-2121044593}, {168489600,-2140863674}, {-94,-2147483647}, -{-168489787,-2140863659}, {-335940431,-2121044564}, {-501320144,-2088148493}, -{-663609049,-2042378281}, {-821806581,-1984016118}, {-974937397,-1913421827}, -{-1122057395,-1831030643}, {-1262259116,-1737350839}, {-1394679021,-1632959413}, -{-1518500258,-1518500240}, {-1632959429,-1394679001}, {-1737350854,-1262259096}, -{-1831030924,-1122056937}, {-1913422071,-974936918}, {-1984016324,-821806084}, -{-2042378447,-663608538}, {-2088148499,-501320119}, {-2121044568,-335940406}, -{-2140863681,-168489506}, {-2147483647,188}, {-2140863651,168489881}, -{-2121044509,335940777}, {-2088148411,501320484}, {-2042378331,663608895}, -{-1984016181,821806431}, {-1913421900,974937252}, {-1831030728,1122057257}, -{-1737350633,1262259400}, {-1632959185,1394679287}, {-1518499993,1518500506}, -{-1394678735,1632959656}, {-1262258813,1737351059}, {-1122056638,1831031107}, -{-974936606,1913422229}, {-821805761,1984016458}, {-663609179,2042378239}, -{-501320277,2088148461}, {-335940566,2121044542}, {-168489668,2140863668}, + {0, 0}, {2147483647, 0}, {2147483647, 0}, + {2147483647, 0}, {1961823921, -873460313}, {1436946998, -1595891394}, + {2147483647, 0}, {1436946998, -1595891394}, {-224473265, -2135719496}, + {2147483647, 0}, {663608871, -2042378339}, {-1737350854, -1262259096}, + {2147483647, 0}, {-224473265, -2135719496}, {-2100555935, 446487152}, + {2147483647, 0}, {2135719506, -224473172}, {2100555974, -446486968}, + {2042378310, -663608960}, {1961823921, -873460313}, {1859775377, -1073741851}, + {1737350743, -1262259248}, {1595891331, -1436947067}, {1436946998, -1595891394}, + {1262259172, -1737350799}, {1073741769, -1859775424}, {873460227, -1961823959}, + {663608871, -2042378339}, {446486876, -2100555994}, {224473078, -2135719516}, + {2147483647, 0}, {2100555974, -446486968}, {1961823921, -873460313}, + {1737350743, -1262259248}, {1436946998, -1595891394}, {1073741769, -1859775424}, + {663608871, -2042378339}, {224473078, -2135719516}, {-224473265, -2135719496}, + {-663609049, -2042378281}, {-1073741932, -1859775330}, {-1436947137, -1595891268}, + {-1737350854, -1262259096}, {-1961823997, -873460141}, {-2100556013, -446486785}, + {2147483647, 0}, {2042378310, -663608960}, {1737350743, -1262259248}, + {1262259172, -1737350799}, {663608871, -2042378339}, {-94, -2147483647}, + {-663609049, -2042378281}, {-1262259116, -1737350839}, {-1737350854, -1262259096}, + {-2042378447, -663608538}, {-2147483647, 188}, {-2042378331, 663608895}, + {-1737350633, 1262259400}, {-1262258813, 1737351059}, {-663609179, 2042378239}, + {2147483647, 0}, {2146747758, -56214570}, {2144540595, -112390613}, + {2140863671, -168489630}, {2135719506, -224473172}, {2129111626, -280302871}, + {2121044558, -335940465}, {2111523833, -391347822}, {2100555974, -446486968}, + {2088148500, -501320115}, {2074309912, -555809682}, {2059049696, -609918325}, + {2042378310, -663608960}, {2024307180, -716844791}, {2004848691, -769589332}, + {1984016179, -821806435}, {1961823921, -873460313}, {1938287127, -924515564}, + {1913421927, -974937199}, {1887245364, -1024690661}, {1859775377, -1073741851}, + {1831030826, -1122057097}, {1801031311, -1169603450}, {1769797456, -1216348214}, + {1737350743, -1262259248}, {1703713340, -1307305194}, {1668908218, -1351455280}, + {1632959307, -1394679144}, {1595891331, -1436947067}, {1557729613, -1478230181}, + {1518500216, -1518500282}, {1478230113, -1557729677}, {1436946998, -1595891394}, + {1394679073, -1632959368}, {1351455207, -1668908277}, {1307305120, -1703713397}, + {1262259172, -1737350799}, {1216348136, -1769797510}, {1169603371, -1801031362}, + {1122057017, -1831030875}, {1073741769, -1859775424}, {1024690635, -1887245378}, + {974937230, -1913421912}, {924515422, -1938287195}, {873460227, -1961823959}, + {821806407, -1984016190}, {769589125, -2004848771}, {716844642, -2024307233}, + {663608871, -2042378339}, {609918296, -2059049705}, {555809715, -2074309903}, + {501319962, -2088148536}, {446486876, -2100555994}, {391347792, -2111523838}, + {335940246, -2121044593}, {280302715, -2129111646}, {224473078, -2135719516}, + {168489600, -2140863674}, {112390647, -2144540593}, {56214412, -2146747762}, + {2147483647, 0}, {2144540595, -112390613}, {2135719506, -224473172}, + {2121044558, -335940465}, {2100555974, -446486968}, {2074309912, -555809682}, + {2042378310, -663608960}, {2004848691, -769589332}, {1961823921, -873460313}, + {1913421927, -974937199}, {1859775377, -1073741851}, {1801031311, -1169603450}, + {1737350743, -1262259248}, {1668908218, -1351455280}, {1595891331, -1436947067}, + {1518500216, -1518500282}, {1436946998, -1595891394}, {1351455207, -1668908277}, + {1262259172, -1737350799}, {1169603371, -1801031362}, {1073741769, -1859775424}, + {974937230, -1913421912}, {873460227, -1961823959}, {769589125, -2004848771}, + {663608871, -2042378339}, {555809715, -2074309903}, {446486876, -2100555994}, + {335940246, -2121044593}, {224473078, -2135719516}, {112390647, -2144540593}, + {-94, -2147483647}, {-112390835, -2144540584}, {-224473265, -2135719496}, + {-335940431, -2121044564}, {-446487060, -2100555955}, {-555809896, -2074309855}, + {-663609049, -2042378281}, {-769589300, -2004848703}, {-873460398, -1961823883}, + {-974937397, -1913421827}, {-1073741932, -1859775330}, {-1169603421, -1801031330}, + {-1262259116, -1737350839}, {-1351455453, -1668908078}, {-1436947137, -1595891268}, + {-1518500258, -1518500240}, {-1595891628, -1436946738}, {-1668908417, -1351455035}, + {-1737350854, -1262259096}, {-1801031344, -1169603400}, {-1859775343, -1073741910}, + {-1913422071, -974936918}, {-1961823997, -873460141}, {-2004848713, -769589276}, + {-2042378447, -663608538}, {-2074309994, -555809377}, {-2100556013, -446486785}, + {-2121044568, -335940406}, {-2135719499, -224473240}, {-2144540612, -112390298}, + {2147483647, 0}, {2140863671, -168489630}, {2121044558, -335940465}, + {2088148500, -501320115}, {2042378310, -663608960}, {1984016179, -821806435}, + {1913421927, -974937199}, {1831030826, -1122057097}, {1737350743, -1262259248}, + {1632959307, -1394679144}, {1518500216, -1518500282}, {1394679073, -1632959368}, + {1262259172, -1737350799}, {1122057017, -1831030875}, {974937230, -1913421912}, + {821806407, -1984016190}, {663608871, -2042378339}, {501319962, -2088148536}, + {335940246, -2121044593}, {168489600, -2140863674}, {-94, -2147483647}, + {-168489787, -2140863659}, {-335940431, -2121044564}, {-501320144, -2088148493}, + {-663609049, -2042378281}, {-821806581, -1984016118}, {-974937397, -1913421827}, + {-1122057395, -1831030643}, {-1262259116, -1737350839}, {-1394679021, -1632959413}, + {-1518500258, -1518500240}, {-1632959429, -1394679001}, {-1737350854, -1262259096}, + {-1831030924, -1122056937}, {-1913422071, -974936918}, {-1984016324, -821806084}, + {-2042378447, -663608538}, {-2088148499, -501320119}, {-2121044568, -335940406}, + {-2140863681, -168489506}, {-2147483647, 188}, {-2140863651, 168489881}, + {-2121044509, 335940777}, {-2088148411, 501320484}, {-2042378331, 663608895}, + {-1984016181, 821806431}, {-1913421900, 974937252}, {-1831030728, 1122057257}, + {-1737350633, 1262259400}, {-1632959185, 1394679287}, {-1518499993, 1518500506}, + {-1394678735, 1632959656}, {-1262258813, 1737351059}, {-1122056638, 1831031107}, + {-974936606, 1913422229}, {-821805761, 1984016458}, {-663609179, 2042378239}, + {-501320277, 2088148461}, {-335940566, 2121044542}, {-168489668, 2140863668}, }; static const ne10_fft_cpx_int32_t ne10_twiddles_120[120] = { -{0,0}, {2147483647,0}, {2147483647,0}, -{2147483647,0}, {1961823921,-873460313}, {1436946998,-1595891394}, -{2147483647,0}, {1436946998,-1595891394}, {-224473265,-2135719496}, -{2147483647,0}, {663608871,-2042378339}, {-1737350854,-1262259096}, -{2147483647,0}, {-224473265,-2135719496}, {-2100555935,446487152}, -{2147483647,0}, {2100555974,-446486968}, {1961823921,-873460313}, -{1737350743,-1262259248}, {1436946998,-1595891394}, {1073741769,-1859775424}, -{663608871,-2042378339}, {224473078,-2135719516}, {-224473265,-2135719496}, -{-663609049,-2042378281}, {-1073741932,-1859775330}, {-1436947137,-1595891268}, -{-1737350854,-1262259096}, {-1961823997,-873460141}, {-2100556013,-446486785}, -{2147483647,0}, {2144540595,-112390613}, {2135719506,-224473172}, -{2121044558,-335940465}, {2100555974,-446486968}, {2074309912,-555809682}, -{2042378310,-663608960}, {2004848691,-769589332}, {1961823921,-873460313}, -{1913421927,-974937199}, {1859775377,-1073741851}, {1801031311,-1169603450}, -{1737350743,-1262259248}, {1668908218,-1351455280}, {1595891331,-1436947067}, -{1518500216,-1518500282}, {1436946998,-1595891394}, {1351455207,-1668908277}, -{1262259172,-1737350799}, {1169603371,-1801031362}, {1073741769,-1859775424}, -{974937230,-1913421912}, {873460227,-1961823959}, {769589125,-2004848771}, -{663608871,-2042378339}, {555809715,-2074309903}, {446486876,-2100555994}, -{335940246,-2121044593}, {224473078,-2135719516}, {112390647,-2144540593}, -{2147483647,0}, {2135719506,-224473172}, {2100555974,-446486968}, -{2042378310,-663608960}, {1961823921,-873460313}, {1859775377,-1073741851}, -{1737350743,-1262259248}, {1595891331,-1436947067}, {1436946998,-1595891394}, -{1262259172,-1737350799}, {1073741769,-1859775424}, {873460227,-1961823959}, -{663608871,-2042378339}, {446486876,-2100555994}, {224473078,-2135719516}, -{-94,-2147483647}, {-224473265,-2135719496}, {-446487060,-2100555955}, -{-663609049,-2042378281}, {-873460398,-1961823883}, {-1073741932,-1859775330}, -{-1262259116,-1737350839}, {-1436947137,-1595891268}, {-1595891628,-1436946738}, -{-1737350854,-1262259096}, {-1859775343,-1073741910}, {-1961823997,-873460141}, -{-2042378447,-663608538}, {-2100556013,-446486785}, {-2135719499,-224473240}, -{2147483647,0}, {2121044558,-335940465}, {2042378310,-663608960}, -{1913421927,-974937199}, {1737350743,-1262259248}, {1518500216,-1518500282}, -{1262259172,-1737350799}, {974937230,-1913421912}, {663608871,-2042378339}, -{335940246,-2121044593}, {-94,-2147483647}, {-335940431,-2121044564}, -{-663609049,-2042378281}, {-974937397,-1913421827}, {-1262259116,-1737350839}, -{-1518500258,-1518500240}, {-1737350854,-1262259096}, {-1913422071,-974936918}, -{-2042378447,-663608538}, {-2121044568,-335940406}, {-2147483647,188}, -{-2121044509,335940777}, {-2042378331,663608895}, {-1913421900,974937252}, -{-1737350633,1262259400}, {-1518499993,1518500506}, {-1262258813,1737351059}, -{-974936606,1913422229}, {-663609179,2042378239}, {-335940566,2121044542}, + {0, 0}, {2147483647, 0}, {2147483647, 0}, + {2147483647, 0}, {1961823921, -873460313}, {1436946998, -1595891394}, + {2147483647, 0}, {1436946998, -1595891394}, {-224473265, -2135719496}, + {2147483647, 0}, {663608871, -2042378339}, {-1737350854, -1262259096}, + {2147483647, 0}, {-224473265, -2135719496}, {-2100555935, 446487152}, + {2147483647, 0}, {2100555974, -446486968}, {1961823921, -873460313}, + {1737350743, -1262259248}, {1436946998, -1595891394}, {1073741769, -1859775424}, + {663608871, -2042378339}, {224473078, -2135719516}, {-224473265, -2135719496}, + {-663609049, -2042378281}, {-1073741932, -1859775330}, {-1436947137, -1595891268}, + {-1737350854, -1262259096}, {-1961823997, -873460141}, {-2100556013, -446486785}, + {2147483647, 0}, {2144540595, -112390613}, {2135719506, -224473172}, + {2121044558, -335940465}, {2100555974, -446486968}, {2074309912, -555809682}, + {2042378310, -663608960}, {2004848691, -769589332}, {1961823921, -873460313}, + {1913421927, -974937199}, {1859775377, -1073741851}, {1801031311, -1169603450}, + {1737350743, -1262259248}, {1668908218, -1351455280}, {1595891331, -1436947067}, + {1518500216, -1518500282}, {1436946998, -1595891394}, {1351455207, -1668908277}, + {1262259172, -1737350799}, {1169603371, -1801031362}, {1073741769, -1859775424}, + {974937230, -1913421912}, {873460227, -1961823959}, {769589125, -2004848771}, + {663608871, -2042378339}, {555809715, -2074309903}, {446486876, -2100555994}, + {335940246, -2121044593}, {224473078, -2135719516}, {112390647, -2144540593}, + {2147483647, 0}, {2135719506, -224473172}, {2100555974, -446486968}, + {2042378310, -663608960}, {1961823921, -873460313}, {1859775377, -1073741851}, + {1737350743, -1262259248}, {1595891331, -1436947067}, {1436946998, -1595891394}, + {1262259172, -1737350799}, {1073741769, -1859775424}, {873460227, -1961823959}, + {663608871, -2042378339}, {446486876, -2100555994}, {224473078, -2135719516}, + {-94, -2147483647}, {-224473265, -2135719496}, {-446487060, -2100555955}, + {-663609049, -2042378281}, {-873460398, -1961823883}, {-1073741932, -1859775330}, + {-1262259116, -1737350839}, {-1436947137, -1595891268}, {-1595891628, -1436946738}, + {-1737350854, -1262259096}, {-1859775343, -1073741910}, {-1961823997, -873460141}, + {-2042378447, -663608538}, {-2100556013, -446486785}, {-2135719499, -224473240}, + {2147483647, 0}, {2121044558, -335940465}, {2042378310, -663608960}, + {1913421927, -974937199}, {1737350743, -1262259248}, {1518500216, -1518500282}, + {1262259172, -1737350799}, {974937230, -1913421912}, {663608871, -2042378339}, + {335940246, -2121044593}, {-94, -2147483647}, {-335940431, -2121044564}, + {-663609049, -2042378281}, {-974937397, -1913421827}, {-1262259116, -1737350839}, + {-1518500258, -1518500240}, {-1737350854, -1262259096}, {-1913422071, -974936918}, + {-2042378447, -663608538}, {-2121044568, -335940406}, {-2147483647, 188}, + {-2121044509, 335940777}, {-2042378331, 663608895}, {-1913421900, 974937252}, + {-1737350633, 1262259400}, {-1518499993, 1518500506}, {-1262258813, 1737351059}, + {-974936606, 1913422229}, {-663609179, 2042378239}, {-335940566, 2121044542}, }; static const ne10_fft_cpx_int32_t ne10_twiddles_60[60] = { -{0,0}, {2147483647,0}, {2147483647,0}, -{2147483647,0}, {1961823921,-873460313}, {1436946998,-1595891394}, -{2147483647,0}, {1436946998,-1595891394}, {-224473265,-2135719496}, -{2147483647,0}, {663608871,-2042378339}, {-1737350854,-1262259096}, -{2147483647,0}, {-224473265,-2135719496}, {-2100555935,446487152}, -{2147483647,0}, {2135719506,-224473172}, {2100555974,-446486968}, -{2042378310,-663608960}, {1961823921,-873460313}, {1859775377,-1073741851}, -{1737350743,-1262259248}, {1595891331,-1436947067}, {1436946998,-1595891394}, -{1262259172,-1737350799}, {1073741769,-1859775424}, {873460227,-1961823959}, -{663608871,-2042378339}, {446486876,-2100555994}, {224473078,-2135719516}, -{2147483647,0}, {2100555974,-446486968}, {1961823921,-873460313}, -{1737350743,-1262259248}, {1436946998,-1595891394}, {1073741769,-1859775424}, -{663608871,-2042378339}, {224473078,-2135719516}, {-224473265,-2135719496}, -{-663609049,-2042378281}, {-1073741932,-1859775330}, {-1436947137,-1595891268}, -{-1737350854,-1262259096}, {-1961823997,-873460141}, {-2100556013,-446486785}, -{2147483647,0}, {2042378310,-663608960}, {1737350743,-1262259248}, -{1262259172,-1737350799}, {663608871,-2042378339}, {-94,-2147483647}, -{-663609049,-2042378281}, {-1262259116,-1737350839}, {-1737350854,-1262259096}, -{-2042378447,-663608538}, {-2147483647,188}, {-2042378331,663608895}, -{-1737350633,1262259400}, {-1262258813,1737351059}, {-663609179,2042378239}, + {0, 0}, {2147483647, 0}, {2147483647, 0}, + {2147483647, 0}, {1961823921, -873460313}, {1436946998, -1595891394}, + {2147483647, 0}, {1436946998, -1595891394}, {-224473265, -2135719496}, + {2147483647, 0}, {663608871, -2042378339}, {-1737350854, -1262259096}, + {2147483647, 0}, {-224473265, -2135719496}, {-2100555935, 446487152}, + {2147483647, 0}, {2135719506, -224473172}, {2100555974, -446486968}, + {2042378310, -663608960}, {1961823921, -873460313}, {1859775377, -1073741851}, + {1737350743, -1262259248}, {1595891331, -1436947067}, {1436946998, -1595891394}, + {1262259172, -1737350799}, {1073741769, -1859775424}, {873460227, -1961823959}, + {663608871, -2042378339}, {446486876, -2100555994}, {224473078, -2135719516}, + {2147483647, 0}, {2100555974, -446486968}, {1961823921, -873460313}, + {1737350743, -1262259248}, {1436946998, -1595891394}, {1073741769, -1859775424}, + {663608871, -2042378339}, {224473078, -2135719516}, {-224473265, -2135719496}, + {-663609049, -2042378281}, {-1073741932, -1859775330}, {-1436947137, -1595891268}, + {-1737350854, -1262259096}, {-1961823997, -873460141}, {-2100556013, -446486785}, + {2147483647, 0}, {2042378310, -663608960}, {1737350743, -1262259248}, + {1262259172, -1737350799}, {663608871, -2042378339}, {-94, -2147483647}, + {-663609049, -2042378281}, {-1262259116, -1737350839}, {-1737350854, -1262259096}, + {-2042378447, -663608538}, {-2147483647, 188}, {-2042378331, 663608895}, + {-1737350633, 1262259400}, {-1262258813, 1737351059}, {-663609179, 2042378239}, }; static const ne10_fft_state_int32_t ne10_fft_state_int32_t_480 = { -120, -(ne10_int32_t *)ne10_factors_480, -(ne10_fft_cpx_int32_t *)ne10_twiddles_480, -NULL, -(ne10_fft_cpx_int32_t *)&ne10_twiddles_480[120], + 120, + (ne10_int32_t *)ne10_factors_480, + (ne10_fft_cpx_int32_t *)ne10_twiddles_480, + NULL, + (ne10_fft_cpx_int32_t *)&ne10_twiddles_480[120], }; static const arch_fft_state cfg_arch_480 = { -1, -(void *)&ne10_fft_state_int32_t_480, + 1, + (void *)&ne10_fft_state_int32_t_480, }; static const ne10_fft_state_int32_t ne10_fft_state_int32_t_240 = { -60, -(ne10_int32_t *)ne10_factors_240, -(ne10_fft_cpx_int32_t *)ne10_twiddles_240, -NULL, -(ne10_fft_cpx_int32_t *)&ne10_twiddles_240[60], + 60, + (ne10_int32_t *)ne10_factors_240, + (ne10_fft_cpx_int32_t *)ne10_twiddles_240, + NULL, + (ne10_fft_cpx_int32_t *)&ne10_twiddles_240[60], }; static const arch_fft_state cfg_arch_240 = { -1, -(void *)&ne10_fft_state_int32_t_240, + 1, + (void *)&ne10_fft_state_int32_t_240, }; static const ne10_fft_state_int32_t ne10_fft_state_int32_t_120 = { -30, -(ne10_int32_t *)ne10_factors_120, -(ne10_fft_cpx_int32_t *)ne10_twiddles_120, -NULL, -(ne10_fft_cpx_int32_t *)&ne10_twiddles_120[30], + 30, + (ne10_int32_t *)ne10_factors_120, + (ne10_fft_cpx_int32_t *)ne10_twiddles_120, + NULL, + (ne10_fft_cpx_int32_t *)&ne10_twiddles_120[30], }; static const arch_fft_state cfg_arch_120 = { -1, -(void *)&ne10_fft_state_int32_t_120, + 1, + (void *)&ne10_fft_state_int32_t_120, }; static const ne10_fft_state_int32_t ne10_fft_state_int32_t_60 = { -15, -(ne10_int32_t *)ne10_factors_60, -(ne10_fft_cpx_int32_t *)ne10_twiddles_60, -NULL, -(ne10_fft_cpx_int32_t *)&ne10_twiddles_60[15], + 15, + (ne10_int32_t *)ne10_factors_60, + (ne10_fft_cpx_int32_t *)ne10_twiddles_60, + NULL, + (ne10_fft_cpx_int32_t *)&ne10_twiddles_60[15], }; static const arch_fft_state cfg_arch_60 = { -1, -(void *)&ne10_fft_state_int32_t_60, + 1, + (void *)&ne10_fft_state_int32_t_60, }; #endif /* end NE10_FFT_PARAMS48000_960 */ diff --git a/celt/static_modes_float.h b/celt/static_modes_float.h index 1bccc3b40..88600e18c 100644 --- a/celt/static_modes_float.h +++ b/celt/static_modes_float.h @@ -5,2512 +5,2452 @@ #include "rate.h" #ifdef HAVE_ARM_NE10 -#define OVERRIDE_FFT 1 -#include "static_modes_float_arm_ne10.h" +# define OVERRIDE_FFT 1 +# include "static_modes_float_arm_ne10.h" #endif #ifndef DEF_WINDOW120 -#define DEF_WINDOW120 +# define DEF_WINDOW120 static const celt_coef window120[120] = { -6.7286966e-05f, 0.00060551348f, 0.0016815970f, 0.0032947962f, 0.0054439943f, -0.0081276923f, 0.011344001f, 0.015090633f, 0.019364886f, 0.024163635f, -0.029483315f, 0.035319905f, 0.041668911f, 0.048525347f, 0.055883718f, -0.063737999f, 0.072081616f, 0.080907428f, 0.090207705f, 0.099974111f, -0.11019769f, 0.12086883f, 0.13197729f, 0.14351214f, 0.15546177f, -0.16781389f, 0.18055550f, 0.19367290f, 0.20715171f, 0.22097682f, -0.23513243f, 0.24960208f, 0.26436860f, 0.27941419f, 0.29472040f, -0.31026818f, 0.32603788f, 0.34200931f, 0.35816177f, 0.37447407f, -0.39092462f, 0.40749142f, 0.42415215f, 0.44088423f, 0.45766484f, -0.47447104f, 0.49127978f, 0.50806798f, 0.52481261f, 0.54149077f, -0.55807973f, 0.57455701f, 0.59090049f, 0.60708841f, 0.62309951f, -0.63891306f, 0.65450896f, 0.66986776f, 0.68497077f, 0.69980010f, -0.71433873f, 0.72857055f, 0.74248043f, 0.75605425f, 0.76927895f, -0.78214257f, 0.79463430f, 0.80674445f, 0.81846456f, 0.82978733f, -0.84070669f, 0.85121779f, 0.86131698f, 0.87100183f, 0.88027111f, -0.88912479f, 0.89756398f, 0.90559094f, 0.91320904f, 0.92042270f, -0.92723738f, 0.93365955f, 0.93969656f, 0.94535671f, 0.95064907f, -0.95558353f, 0.96017067f, 0.96442171f, 0.96834849f, 0.97196334f, -0.97527906f, 0.97830883f, 0.98106616f, 0.98356480f, 0.98581869f, -0.98784191f, 0.98964856f, 0.99125274f, 0.99266849f, 0.99390969f, -0.99499004f, 0.99592297f, 0.99672162f, 0.99739874f, 0.99796667f, -0.99843728f, 0.99882195f, 0.99913147f, 0.99937606f, 0.99956527f, -0.99970802f, 0.99981248f, 0.99988613f, 0.99993565f, 0.99996697f, -0.99998518f, 0.99999457f, 0.99999859f, 0.99999982f, 1.0000000f, + 6.7286966e-05f, 0.00060551348f, 0.0016815970f, 0.0032947962f, 0.0054439943f, + 0.0081276923f, 0.011344001f, 0.015090633f, 0.019364886f, 0.024163635f, + 0.029483315f, 0.035319905f, 0.041668911f, 0.048525347f, 0.055883718f, + 0.063737999f, 0.072081616f, 0.080907428f, 0.090207705f, 0.099974111f, + 0.11019769f, 0.12086883f, 0.13197729f, 0.14351214f, 0.15546177f, + 0.16781389f, 0.18055550f, 0.19367290f, 0.20715171f, 0.22097682f, + 0.23513243f, 0.24960208f, 0.26436860f, 0.27941419f, 0.29472040f, + 0.31026818f, 0.32603788f, 0.34200931f, 0.35816177f, 0.37447407f, + 0.39092462f, 0.40749142f, 0.42415215f, 0.44088423f, 0.45766484f, + 0.47447104f, 0.49127978f, 0.50806798f, 0.52481261f, 0.54149077f, + 0.55807973f, 0.57455701f, 0.59090049f, 0.60708841f, 0.62309951f, + 0.63891306f, 0.65450896f, 0.66986776f, 0.68497077f, 0.69980010f, + 0.71433873f, 0.72857055f, 0.74248043f, 0.75605425f, 0.76927895f, + 0.78214257f, 0.79463430f, 0.80674445f, 0.81846456f, 0.82978733f, + 0.84070669f, 0.85121779f, 0.86131698f, 0.87100183f, 0.88027111f, + 0.88912479f, 0.89756398f, 0.90559094f, 0.91320904f, 0.92042270f, + 0.92723738f, 0.93365955f, 0.93969656f, 0.94535671f, 0.95064907f, + 0.95558353f, 0.96017067f, 0.96442171f, 0.96834849f, 0.97196334f, + 0.97527906f, 0.97830883f, 0.98106616f, 0.98356480f, 0.98581869f, + 0.98784191f, 0.98964856f, 0.99125274f, 0.99266849f, 0.99390969f, + 0.99499004f, 0.99592297f, 0.99672162f, 0.99739874f, 0.99796667f, + 0.99843728f, 0.99882195f, 0.99913147f, 0.99937606f, 0.99956527f, + 0.99970802f, 0.99981248f, 0.99988613f, 0.99993565f, 0.99996697f, + 0.99998518f, 0.99999457f, 0.99999859f, 0.99999982f, 1.0000000f, }; #endif #ifndef DEF_LOGN400 -#define DEF_LOGN400 -static const opus_int16 logN400[21] = { -0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36, }; +# define DEF_LOGN400 +static const oac_int16 logN400[21] = { + 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36, }; #endif #ifndef DEF_PULSE_CACHE50 -#define DEF_PULSE_CACHE50 -static const opus_int16 cache_index50[105] = { --1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, -82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, -41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41, -41, 41, 41, 41, 41, 123, 123, 123, 123, 240, 240, 240, 266, 266, 305, -318, 328, 336, 123, 123, 123, 123, 123, 123, 123, 123, 240, 240, 240, 240, -305, 305, 305, 318, 318, 343, 351, 358, 364, 240, 240, 240, 240, 240, 240, -240, 240, 305, 305, 305, 305, 343, 343, 343, 351, 351, 370, 376, 382, 387, +# define DEF_PULSE_CACHE50 +static const oac_int16 cache_index50[105] = { + -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, + 82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, + 41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41, + 41, 41, 41, 41, 41, 123, 123, 123, 123, 240, 240, 240, 266, 266, 305, + 318, 328, 336, 123, 123, 123, 123, 123, 123, 123, 123, 240, 240, 240, 240, + 305, 305, 305, 318, 318, 343, 351, 358, 364, 240, 240, 240, 240, 240, 240, + 240, 240, 305, 305, 305, 305, 343, 343, 343, 351, 351, 370, 376, 382, 387, }; static const unsigned char cache_bits50[392] = { -40, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 40, 15, 23, 28, -31, 34, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47, 47, 49, 50, -51, 52, 53, 54, 55, 55, 57, 58, 59, 60, 61, 62, 63, 63, 65, -66, 67, 68, 69, 70, 71, 71, 40, 20, 33, 41, 48, 53, 57, 61, -64, 66, 69, 71, 73, 75, 76, 78, 80, 82, 85, 87, 89, 91, 92, -94, 96, 98, 101, 103, 105, 107, 108, 110, 112, 114, 117, 119, 121, 123, -124, 126, 128, 40, 23, 39, 51, 60, 67, 73, 79, 83, 87, 91, 94, -97, 100, 102, 105, 107, 111, 115, 118, 121, 124, 126, 129, 131, 135, 139, -142, 145, 148, 150, 153, 155, 159, 163, 166, 169, 172, 174, 177, 179, 35, -28, 49, 65, 78, 89, 99, 107, 114, 120, 126, 132, 136, 141, 145, 149, -153, 159, 165, 171, 176, 180, 185, 189, 192, 199, 205, 211, 216, 220, 225, -229, 232, 239, 245, 251, 21, 33, 58, 79, 97, 112, 125, 137, 148, 157, -166, 174, 182, 189, 195, 201, 207, 217, 227, 235, 243, 251, 17, 35, 63, -86, 106, 123, 139, 152, 165, 177, 187, 197, 206, 214, 222, 230, 237, 250, -25, 31, 55, 75, 91, 105, 117, 128, 138, 146, 154, 161, 168, 174, 180, -185, 190, 200, 208, 215, 222, 229, 235, 240, 245, 255, 16, 36, 65, 89, -110, 128, 144, 159, 173, 185, 196, 207, 217, 226, 234, 242, 250, 11, 41, -74, 103, 128, 151, 172, 191, 209, 225, 241, 255, 9, 43, 79, 110, 138, -163, 186, 207, 227, 246, 12, 39, 71, 99, 123, 144, 164, 182, 198, 214, -228, 241, 253, 9, 44, 81, 113, 142, 168, 192, 214, 235, 255, 7, 49, -90, 127, 160, 191, 220, 247, 6, 51, 95, 134, 170, 203, 234, 7, 47, -87, 123, 155, 184, 212, 237, 6, 52, 97, 137, 174, 208, 240, 5, 57, -106, 151, 192, 231, 5, 59, 111, 158, 202, 243, 5, 55, 103, 147, 187, -224, 5, 60, 113, 161, 206, 248, 4, 65, 122, 175, 224, 4, 67, 127, -182, 234, }; + 40, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 40, 15, 23, 28, + 31, 34, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47, 47, 49, 50, + 51, 52, 53, 54, 55, 55, 57, 58, 59, 60, 61, 62, 63, 63, 65, + 66, 67, 68, 69, 70, 71, 71, 40, 20, 33, 41, 48, 53, 57, 61, + 64, 66, 69, 71, 73, 75, 76, 78, 80, 82, 85, 87, 89, 91, 92, + 94, 96, 98, 101, 103, 105, 107, 108, 110, 112, 114, 117, 119, 121, 123, + 124, 126, 128, 40, 23, 39, 51, 60, 67, 73, 79, 83, 87, 91, 94, + 97, 100, 102, 105, 107, 111, 115, 118, 121, 124, 126, 129, 131, 135, 139, + 142, 145, 148, 150, 153, 155, 159, 163, 166, 169, 172, 174, 177, 179, 35, + 28, 49, 65, 78, 89, 99, 107, 114, 120, 126, 132, 136, 141, 145, 149, + 153, 159, 165, 171, 176, 180, 185, 189, 192, 199, 205, 211, 216, 220, 225, + 229, 232, 239, 245, 251, 21, 33, 58, 79, 97, 112, 125, 137, 148, 157, + 166, 174, 182, 189, 195, 201, 207, 217, 227, 235, 243, 251, 17, 35, 63, + 86, 106, 123, 139, 152, 165, 177, 187, 197, 206, 214, 222, 230, 237, 250, + 25, 31, 55, 75, 91, 105, 117, 128, 138, 146, 154, 161, 168, 174, 180, + 185, 190, 200, 208, 215, 222, 229, 235, 240, 245, 255, 16, 36, 65, 89, + 110, 128, 144, 159, 173, 185, 196, 207, 217, 226, 234, 242, 250, 11, 41, + 74, 103, 128, 151, 172, 191, 209, 225, 241, 255, 9, 43, 79, 110, 138, + 163, 186, 207, 227, 246, 12, 39, 71, 99, 123, 144, 164, 182, 198, 214, + 228, 241, 253, 9, 44, 81, 113, 142, 168, 192, 214, 235, 255, 7, 49, + 90, 127, 160, 191, 220, 247, 6, 51, 95, 134, 170, 203, 234, 7, 47, + 87, 123, 155, 184, 212, 237, 6, 52, 97, 137, 174, 208, 240, 5, 57, + 106, 151, 192, 231, 5, 59, 111, 158, 202, 243, 5, 55, 103, 147, 187, + 224, 5, 60, 113, 161, 206, 248, 4, 65, 122, 175, 224, 4, 67, 127, + 182, 234, }; static const unsigned char cache_caps50[168] = { -224, 224, 224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 185, 185, 185, -178, 178, 168, 134, 61, 37, 224, 224, 224, 224, 224, 224, 224, 224, 240, -240, 240, 240, 207, 207, 207, 198, 198, 183, 144, 66, 40, 160, 160, 160, -160, 160, 160, 160, 160, 185, 185, 185, 185, 193, 193, 193, 183, 183, 172, -138, 64, 38, 240, 240, 240, 240, 240, 240, 240, 240, 207, 207, 207, 207, -204, 204, 204, 193, 193, 180, 143, 66, 40, 185, 185, 185, 185, 185, 185, -185, 185, 193, 193, 193, 193, 193, 193, 193, 183, 183, 172, 138, 65, 39, -207, 207, 207, 207, 207, 207, 207, 207, 204, 204, 204, 204, 201, 201, 201, -188, 188, 176, 141, 66, 40, 193, 193, 193, 193, 193, 193, 193, 193, 193, -193, 193, 193, 194, 194, 194, 184, 184, 173, 139, 65, 39, 204, 204, 204, -204, 204, 204, 204, 204, 201, 201, 201, 201, 198, 198, 198, 187, 187, 175, -140, 66, 40, }; -#endif - -#ifdef ENABLE_QEXT -# ifndef DEF_QEXT_PULSE_CACHE50 -# define DEF_QEXT_PULSE_CACHE50 -static const opus_int16 qext_cache_index50[70] = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, -41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 61, 61, -61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 72, 72, 72, -72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 80, 80, 80, 80, -80, 80, 80, 80, 80, 80, 80, 80, 80, 80, }; -static const unsigned char qext_cache_bits50[86] = { -40, 26, 45, 59, 70, 79, 87, 94, 100, 105, 110, 114, 118, 122, 125, -128, 131, 136, 141, 146, 150, 153, 157, 160, 163, 168, 173, 178, 182, 185, -189, 192, 195, 200, 205, 210, 214, 217, 221, 224, 227, 19, 34, 61, 83, -101, 118, 132, 145, 157, 167, 177, 186, 194, 202, 209, 216, 222, 234, 245, -254, 10, 42, 77, 107, 133, 157, 179, 200, 219, 236, 253, 7, 50, 93, -131, 165, 197, 227, 255, 5, 58, 109, 155, 197, 237, }; -static const unsigned char qext_cache_caps50[112] = { -159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 171, -171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 167, 167, 167, -167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 166, 166, 166, 166, 166, -166, 166, 166, 166, 166, 166, 166, 166, 166, 163, 163, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 165, 165, 165, 165, 165, 165, 165, -165, 165, 165, 165, 165, 165, 165, }; -# endif + 224, 224, 224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 185, 185, 185, + 178, 178, 168, 134, 61, 37, 224, 224, 224, 224, 224, 224, 224, 224, 240, + 240, 240, 240, 207, 207, 207, 198, 198, 183, 144, 66, 40, 160, 160, 160, + 160, 160, 160, 160, 160, 185, 185, 185, 185, 193, 193, 193, 183, 183, 172, + 138, 64, 38, 240, 240, 240, 240, 240, 240, 240, 240, 207, 207, 207, 207, + 204, 204, 204, 193, 193, 180, 143, 66, 40, 185, 185, 185, 185, 185, 185, + 185, 185, 193, 193, 193, 193, 193, 193, 193, 183, 183, 172, 138, 65, 39, + 207, 207, 207, 207, 207, 207, 207, 207, 204, 204, 204, 204, 201, 201, 201, + 188, 188, 176, 141, 66, 40, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 194, 194, 194, 184, 184, 173, 139, 65, 39, 204, 204, 204, + 204, 204, 204, 204, 204, 201, 201, 201, 201, 198, 198, 198, 187, 187, 175, + 140, 66, 40, }; #endif #ifndef FFT_TWIDDLES48000_960 -#define FFT_TWIDDLES48000_960 +# define FFT_TWIDDLES48000_960 static const kiss_twiddle_cpx fft_twiddles48000_960[480] = { -{1.0000000f, -0.0000000f}, {0.99991433f, -0.013089596f}, -{0.99965732f, -0.026176948f}, {0.99922904f, -0.039259816f}, -{0.99862953f, -0.052335956f}, {0.99785892f, -0.065403129f}, -{0.99691733f, -0.078459096f}, {0.99580493f, -0.091501619f}, -{0.99452190f, -0.10452846f}, {0.99306846f, -0.11753740f}, -{0.99144486f, -0.13052619f}, {0.98965139f, -0.14349262f}, -{0.98768834f, -0.15643447f}, {0.98555606f, -0.16934950f}, -{0.98325491f, -0.18223553f}, {0.98078528f, -0.19509032f}, -{0.97814760f, -0.20791169f}, {0.97534232f, -0.22069744f}, -{0.97236992f, -0.23344536f}, {0.96923091f, -0.24615329f}, -{0.96592583f, -0.25881905f}, {0.96245524f, -0.27144045f}, -{0.95881973f, -0.28401534f}, {0.95501994f, -0.29654157f}, -{0.95105652f, -0.30901699f}, {0.94693013f, -0.32143947f}, -{0.94264149f, -0.33380686f}, {0.93819134f, -0.34611706f}, -{0.93358043f, -0.35836795f}, {0.92880955f, -0.37055744f}, -{0.92387953f, -0.38268343f}, {0.91879121f, -0.39474386f}, -{0.91354546f, -0.40673664f}, {0.90814317f, -0.41865974f}, -{0.90258528f, -0.43051110f}, {0.89687274f, -0.44228869f}, -{0.89100652f, -0.45399050f}, {0.88498764f, -0.46561452f}, -{0.87881711f, -0.47715876f}, {0.87249601f, -0.48862124f}, -{0.86602540f, -0.50000000f}, {0.85940641f, -0.51129309f}, -{0.85264016f, -0.52249856f}, {0.84572782f, -0.53361452f}, -{0.83867057f, -0.54463904f}, {0.83146961f, -0.55557023f}, -{0.82412619f, -0.56640624f}, {0.81664156f, -0.57714519f}, -{0.80901699f, -0.58778525f}, {0.80125381f, -0.59832460f}, -{0.79335334f, -0.60876143f}, {0.78531693f, -0.61909395f}, -{0.77714596f, -0.62932039f}, {0.76884183f, -0.63943900f}, -{0.76040597f, -0.64944805f}, {0.75183981f, -0.65934582f}, -{0.74314483f, -0.66913061f}, {0.73432251f, -0.67880075f}, -{0.72537437f, -0.68835458f}, {0.71630194f, -0.69779046f}, -{0.70710678f, -0.70710678f}, {0.69779046f, -0.71630194f}, -{0.68835458f, -0.72537437f}, {0.67880075f, -0.73432251f}, -{0.66913061f, -0.74314483f}, {0.65934582f, -0.75183981f}, -{0.64944805f, -0.76040597f}, {0.63943900f, -0.76884183f}, -{0.62932039f, -0.77714596f}, {0.61909395f, -0.78531693f}, -{0.60876143f, -0.79335334f}, {0.59832460f, -0.80125381f}, -{0.58778525f, -0.80901699f}, {0.57714519f, -0.81664156f}, -{0.56640624f, -0.82412619f}, {0.55557023f, -0.83146961f}, -{0.54463904f, -0.83867057f}, {0.53361452f, -0.84572782f}, -{0.52249856f, -0.85264016f}, {0.51129309f, -0.85940641f}, -{0.50000000f, -0.86602540f}, {0.48862124f, -0.87249601f}, -{0.47715876f, -0.87881711f}, {0.46561452f, -0.88498764f}, -{0.45399050f, -0.89100652f}, {0.44228869f, -0.89687274f}, -{0.43051110f, -0.90258528f}, {0.41865974f, -0.90814317f}, -{0.40673664f, -0.91354546f}, {0.39474386f, -0.91879121f}, -{0.38268343f, -0.92387953f}, {0.37055744f, -0.92880955f}, -{0.35836795f, -0.93358043f}, {0.34611706f, -0.93819134f}, -{0.33380686f, -0.94264149f}, {0.32143947f, -0.94693013f}, -{0.30901699f, -0.95105652f}, {0.29654157f, -0.95501994f}, -{0.28401534f, -0.95881973f}, {0.27144045f, -0.96245524f}, -{0.25881905f, -0.96592583f}, {0.24615329f, -0.96923091f}, -{0.23344536f, -0.97236992f}, {0.22069744f, -0.97534232f}, -{0.20791169f, -0.97814760f}, {0.19509032f, -0.98078528f}, -{0.18223553f, -0.98325491f}, {0.16934950f, -0.98555606f}, -{0.15643447f, -0.98768834f}, {0.14349262f, -0.98965139f}, -{0.13052619f, -0.99144486f}, {0.11753740f, -0.99306846f}, -{0.10452846f, -0.99452190f}, {0.091501619f, -0.99580493f}, -{0.078459096f, -0.99691733f}, {0.065403129f, -0.99785892f}, -{0.052335956f, -0.99862953f}, {0.039259816f, -0.99922904f}, -{0.026176948f, -0.99965732f}, {0.013089596f, -0.99991433f}, -{6.1232340e-17f, -1.0000000f}, {-0.013089596f, -0.99991433f}, -{-0.026176948f, -0.99965732f}, {-0.039259816f, -0.99922904f}, -{-0.052335956f, -0.99862953f}, {-0.065403129f, -0.99785892f}, -{-0.078459096f, -0.99691733f}, {-0.091501619f, -0.99580493f}, -{-0.10452846f, -0.99452190f}, {-0.11753740f, -0.99306846f}, -{-0.13052619f, -0.99144486f}, {-0.14349262f, -0.98965139f}, -{-0.15643447f, -0.98768834f}, {-0.16934950f, -0.98555606f}, -{-0.18223553f, -0.98325491f}, {-0.19509032f, -0.98078528f}, -{-0.20791169f, -0.97814760f}, {-0.22069744f, -0.97534232f}, -{-0.23344536f, -0.97236992f}, {-0.24615329f, -0.96923091f}, -{-0.25881905f, -0.96592583f}, {-0.27144045f, -0.96245524f}, -{-0.28401534f, -0.95881973f}, {-0.29654157f, -0.95501994f}, -{-0.30901699f, -0.95105652f}, {-0.32143947f, -0.94693013f}, -{-0.33380686f, -0.94264149f}, {-0.34611706f, -0.93819134f}, -{-0.35836795f, -0.93358043f}, {-0.37055744f, -0.92880955f}, -{-0.38268343f, -0.92387953f}, {-0.39474386f, -0.91879121f}, -{-0.40673664f, -0.91354546f}, {-0.41865974f, -0.90814317f}, -{-0.43051110f, -0.90258528f}, {-0.44228869f, -0.89687274f}, -{-0.45399050f, -0.89100652f}, {-0.46561452f, -0.88498764f}, -{-0.47715876f, -0.87881711f}, {-0.48862124f, -0.87249601f}, -{-0.50000000f, -0.86602540f}, {-0.51129309f, -0.85940641f}, -{-0.52249856f, -0.85264016f}, {-0.53361452f, -0.84572782f}, -{-0.54463904f, -0.83867057f}, {-0.55557023f, -0.83146961f}, -{-0.56640624f, -0.82412619f}, {-0.57714519f, -0.81664156f}, -{-0.58778525f, -0.80901699f}, {-0.59832460f, -0.80125381f}, -{-0.60876143f, -0.79335334f}, {-0.61909395f, -0.78531693f}, -{-0.62932039f, -0.77714596f}, {-0.63943900f, -0.76884183f}, -{-0.64944805f, -0.76040597f}, {-0.65934582f, -0.75183981f}, -{-0.66913061f, -0.74314483f}, {-0.67880075f, -0.73432251f}, -{-0.68835458f, -0.72537437f}, {-0.69779046f, -0.71630194f}, -{-0.70710678f, -0.70710678f}, {-0.71630194f, -0.69779046f}, -{-0.72537437f, -0.68835458f}, {-0.73432251f, -0.67880075f}, -{-0.74314483f, -0.66913061f}, {-0.75183981f, -0.65934582f}, -{-0.76040597f, -0.64944805f}, {-0.76884183f, -0.63943900f}, -{-0.77714596f, -0.62932039f}, {-0.78531693f, -0.61909395f}, -{-0.79335334f, -0.60876143f}, {-0.80125381f, -0.59832460f}, -{-0.80901699f, -0.58778525f}, {-0.81664156f, -0.57714519f}, -{-0.82412619f, -0.56640624f}, {-0.83146961f, -0.55557023f}, -{-0.83867057f, -0.54463904f}, {-0.84572782f, -0.53361452f}, -{-0.85264016f, -0.52249856f}, {-0.85940641f, -0.51129309f}, -{-0.86602540f, -0.50000000f}, {-0.87249601f, -0.48862124f}, -{-0.87881711f, -0.47715876f}, {-0.88498764f, -0.46561452f}, -{-0.89100652f, -0.45399050f}, {-0.89687274f, -0.44228869f}, -{-0.90258528f, -0.43051110f}, {-0.90814317f, -0.41865974f}, -{-0.91354546f, -0.40673664f}, {-0.91879121f, -0.39474386f}, -{-0.92387953f, -0.38268343f}, {-0.92880955f, -0.37055744f}, -{-0.93358043f, -0.35836795f}, {-0.93819134f, -0.34611706f}, -{-0.94264149f, -0.33380686f}, {-0.94693013f, -0.32143947f}, -{-0.95105652f, -0.30901699f}, {-0.95501994f, -0.29654157f}, -{-0.95881973f, -0.28401534f}, {-0.96245524f, -0.27144045f}, -{-0.96592583f, -0.25881905f}, {-0.96923091f, -0.24615329f}, -{-0.97236992f, -0.23344536f}, {-0.97534232f, -0.22069744f}, -{-0.97814760f, -0.20791169f}, {-0.98078528f, -0.19509032f}, -{-0.98325491f, -0.18223553f}, {-0.98555606f, -0.16934950f}, -{-0.98768834f, -0.15643447f}, {-0.98965139f, -0.14349262f}, -{-0.99144486f, -0.13052619f}, {-0.99306846f, -0.11753740f}, -{-0.99452190f, -0.10452846f}, {-0.99580493f, -0.091501619f}, -{-0.99691733f, -0.078459096f}, {-0.99785892f, -0.065403129f}, -{-0.99862953f, -0.052335956f}, {-0.99922904f, -0.039259816f}, -{-0.99965732f, -0.026176948f}, {-0.99991433f, -0.013089596f}, -{-1.0000000f, -1.2246468e-16f}, {-0.99991433f, 0.013089596f}, -{-0.99965732f, 0.026176948f}, {-0.99922904f, 0.039259816f}, -{-0.99862953f, 0.052335956f}, {-0.99785892f, 0.065403129f}, -{-0.99691733f, 0.078459096f}, {-0.99580493f, 0.091501619f}, -{-0.99452190f, 0.10452846f}, {-0.99306846f, 0.11753740f}, -{-0.99144486f, 0.13052619f}, {-0.98965139f, 0.14349262f}, -{-0.98768834f, 0.15643447f}, {-0.98555606f, 0.16934950f}, -{-0.98325491f, 0.18223553f}, {-0.98078528f, 0.19509032f}, -{-0.97814760f, 0.20791169f}, {-0.97534232f, 0.22069744f}, -{-0.97236992f, 0.23344536f}, {-0.96923091f, 0.24615329f}, -{-0.96592583f, 0.25881905f}, {-0.96245524f, 0.27144045f}, -{-0.95881973f, 0.28401534f}, {-0.95501994f, 0.29654157f}, -{-0.95105652f, 0.30901699f}, {-0.94693013f, 0.32143947f}, -{-0.94264149f, 0.33380686f}, {-0.93819134f, 0.34611706f}, -{-0.93358043f, 0.35836795f}, {-0.92880955f, 0.37055744f}, -{-0.92387953f, 0.38268343f}, {-0.91879121f, 0.39474386f}, -{-0.91354546f, 0.40673664f}, {-0.90814317f, 0.41865974f}, -{-0.90258528f, 0.43051110f}, {-0.89687274f, 0.44228869f}, -{-0.89100652f, 0.45399050f}, {-0.88498764f, 0.46561452f}, -{-0.87881711f, 0.47715876f}, {-0.87249601f, 0.48862124f}, -{-0.86602540f, 0.50000000f}, {-0.85940641f, 0.51129309f}, -{-0.85264016f, 0.52249856f}, {-0.84572782f, 0.53361452f}, -{-0.83867057f, 0.54463904f}, {-0.83146961f, 0.55557023f}, -{-0.82412619f, 0.56640624f}, {-0.81664156f, 0.57714519f}, -{-0.80901699f, 0.58778525f}, {-0.80125381f, 0.59832460f}, -{-0.79335334f, 0.60876143f}, {-0.78531693f, 0.61909395f}, -{-0.77714596f, 0.62932039f}, {-0.76884183f, 0.63943900f}, -{-0.76040597f, 0.64944805f}, {-0.75183981f, 0.65934582f}, -{-0.74314483f, 0.66913061f}, {-0.73432251f, 0.67880075f}, -{-0.72537437f, 0.68835458f}, {-0.71630194f, 0.69779046f}, -{-0.70710678f, 0.70710678f}, {-0.69779046f, 0.71630194f}, -{-0.68835458f, 0.72537437f}, {-0.67880075f, 0.73432251f}, -{-0.66913061f, 0.74314483f}, {-0.65934582f, 0.75183981f}, -{-0.64944805f, 0.76040597f}, {-0.63943900f, 0.76884183f}, -{-0.62932039f, 0.77714596f}, {-0.61909395f, 0.78531693f}, -{-0.60876143f, 0.79335334f}, {-0.59832460f, 0.80125381f}, -{-0.58778525f, 0.80901699f}, {-0.57714519f, 0.81664156f}, -{-0.56640624f, 0.82412619f}, {-0.55557023f, 0.83146961f}, -{-0.54463904f, 0.83867057f}, {-0.53361452f, 0.84572782f}, -{-0.52249856f, 0.85264016f}, {-0.51129309f, 0.85940641f}, -{-0.50000000f, 0.86602540f}, {-0.48862124f, 0.87249601f}, -{-0.47715876f, 0.87881711f}, {-0.46561452f, 0.88498764f}, -{-0.45399050f, 0.89100652f}, {-0.44228869f, 0.89687274f}, -{-0.43051110f, 0.90258528f}, {-0.41865974f, 0.90814317f}, -{-0.40673664f, 0.91354546f}, {-0.39474386f, 0.91879121f}, -{-0.38268343f, 0.92387953f}, {-0.37055744f, 0.92880955f}, -{-0.35836795f, 0.93358043f}, {-0.34611706f, 0.93819134f}, -{-0.33380686f, 0.94264149f}, {-0.32143947f, 0.94693013f}, -{-0.30901699f, 0.95105652f}, {-0.29654157f, 0.95501994f}, -{-0.28401534f, 0.95881973f}, {-0.27144045f, 0.96245524f}, -{-0.25881905f, 0.96592583f}, {-0.24615329f, 0.96923091f}, -{-0.23344536f, 0.97236992f}, {-0.22069744f, 0.97534232f}, -{-0.20791169f, 0.97814760f}, {-0.19509032f, 0.98078528f}, -{-0.18223553f, 0.98325491f}, {-0.16934950f, 0.98555606f}, -{-0.15643447f, 0.98768834f}, {-0.14349262f, 0.98965139f}, -{-0.13052619f, 0.99144486f}, {-0.11753740f, 0.99306846f}, -{-0.10452846f, 0.99452190f}, {-0.091501619f, 0.99580493f}, -{-0.078459096f, 0.99691733f}, {-0.065403129f, 0.99785892f}, -{-0.052335956f, 0.99862953f}, {-0.039259816f, 0.99922904f}, -{-0.026176948f, 0.99965732f}, {-0.013089596f, 0.99991433f}, -{-1.8369702e-16f, 1.0000000f}, {0.013089596f, 0.99991433f}, -{0.026176948f, 0.99965732f}, {0.039259816f, 0.99922904f}, -{0.052335956f, 0.99862953f}, {0.065403129f, 0.99785892f}, -{0.078459096f, 0.99691733f}, {0.091501619f, 0.99580493f}, -{0.10452846f, 0.99452190f}, {0.11753740f, 0.99306846f}, -{0.13052619f, 0.99144486f}, {0.14349262f, 0.98965139f}, -{0.15643447f, 0.98768834f}, {0.16934950f, 0.98555606f}, -{0.18223553f, 0.98325491f}, {0.19509032f, 0.98078528f}, -{0.20791169f, 0.97814760f}, {0.22069744f, 0.97534232f}, -{0.23344536f, 0.97236992f}, {0.24615329f, 0.96923091f}, -{0.25881905f, 0.96592583f}, {0.27144045f, 0.96245524f}, -{0.28401534f, 0.95881973f}, {0.29654157f, 0.95501994f}, -{0.30901699f, 0.95105652f}, {0.32143947f, 0.94693013f}, -{0.33380686f, 0.94264149f}, {0.34611706f, 0.93819134f}, -{0.35836795f, 0.93358043f}, {0.37055744f, 0.92880955f}, -{0.38268343f, 0.92387953f}, {0.39474386f, 0.91879121f}, -{0.40673664f, 0.91354546f}, {0.41865974f, 0.90814317f}, -{0.43051110f, 0.90258528f}, {0.44228869f, 0.89687274f}, -{0.45399050f, 0.89100652f}, {0.46561452f, 0.88498764f}, -{0.47715876f, 0.87881711f}, {0.48862124f, 0.87249601f}, -{0.50000000f, 0.86602540f}, {0.51129309f, 0.85940641f}, -{0.52249856f, 0.85264016f}, {0.53361452f, 0.84572782f}, -{0.54463904f, 0.83867057f}, {0.55557023f, 0.83146961f}, -{0.56640624f, 0.82412619f}, {0.57714519f, 0.81664156f}, -{0.58778525f, 0.80901699f}, {0.59832460f, 0.80125381f}, -{0.60876143f, 0.79335334f}, {0.61909395f, 0.78531693f}, -{0.62932039f, 0.77714596f}, {0.63943900f, 0.76884183f}, -{0.64944805f, 0.76040597f}, {0.65934582f, 0.75183981f}, -{0.66913061f, 0.74314483f}, {0.67880075f, 0.73432251f}, -{0.68835458f, 0.72537437f}, {0.69779046f, 0.71630194f}, -{0.70710678f, 0.70710678f}, {0.71630194f, 0.69779046f}, -{0.72537437f, 0.68835458f}, {0.73432251f, 0.67880075f}, -{0.74314483f, 0.66913061f}, {0.75183981f, 0.65934582f}, -{0.76040597f, 0.64944805f}, {0.76884183f, 0.63943900f}, -{0.77714596f, 0.62932039f}, {0.78531693f, 0.61909395f}, -{0.79335334f, 0.60876143f}, {0.80125381f, 0.59832460f}, -{0.80901699f, 0.58778525f}, {0.81664156f, 0.57714519f}, -{0.82412619f, 0.56640624f}, {0.83146961f, 0.55557023f}, -{0.83867057f, 0.54463904f}, {0.84572782f, 0.53361452f}, -{0.85264016f, 0.52249856f}, {0.85940641f, 0.51129309f}, -{0.86602540f, 0.50000000f}, {0.87249601f, 0.48862124f}, -{0.87881711f, 0.47715876f}, {0.88498764f, 0.46561452f}, -{0.89100652f, 0.45399050f}, {0.89687274f, 0.44228869f}, -{0.90258528f, 0.43051110f}, {0.90814317f, 0.41865974f}, -{0.91354546f, 0.40673664f}, {0.91879121f, 0.39474386f}, -{0.92387953f, 0.38268343f}, {0.92880955f, 0.37055744f}, -{0.93358043f, 0.35836795f}, {0.93819134f, 0.34611706f}, -{0.94264149f, 0.33380686f}, {0.94693013f, 0.32143947f}, -{0.95105652f, 0.30901699f}, {0.95501994f, 0.29654157f}, -{0.95881973f, 0.28401534f}, {0.96245524f, 0.27144045f}, -{0.96592583f, 0.25881905f}, {0.96923091f, 0.24615329f}, -{0.97236992f, 0.23344536f}, {0.97534232f, 0.22069744f}, -{0.97814760f, 0.20791169f}, {0.98078528f, 0.19509032f}, -{0.98325491f, 0.18223553f}, {0.98555606f, 0.16934950f}, -{0.98768834f, 0.15643447f}, {0.98965139f, 0.14349262f}, -{0.99144486f, 0.13052619f}, {0.99306846f, 0.11753740f}, -{0.99452190f, 0.10452846f}, {0.99580493f, 0.091501619f}, -{0.99691733f, 0.078459096f}, {0.99785892f, 0.065403129f}, -{0.99862953f, 0.052335956f}, {0.99922904f, 0.039259816f}, -{0.99965732f, 0.026176948f}, {0.99991433f, 0.013089596f}, + {1.0000000f, -0.0000000f}, {0.99991433f, -0.013089596f}, + {0.99965732f, -0.026176948f}, {0.99922904f, -0.039259816f}, + {0.99862953f, -0.052335956f}, {0.99785892f, -0.065403129f}, + {0.99691733f, -0.078459096f}, {0.99580493f, -0.091501619f}, + {0.99452190f, -0.10452846f}, {0.99306846f, -0.11753740f}, + {0.99144486f, -0.13052619f}, {0.98965139f, -0.14349262f}, + {0.98768834f, -0.15643447f}, {0.98555606f, -0.16934950f}, + {0.98325491f, -0.18223553f}, {0.98078528f, -0.19509032f}, + {0.97814760f, -0.20791169f}, {0.97534232f, -0.22069744f}, + {0.97236992f, -0.23344536f}, {0.96923091f, -0.24615329f}, + {0.96592583f, -0.25881905f}, {0.96245524f, -0.27144045f}, + {0.95881973f, -0.28401534f}, {0.95501994f, -0.29654157f}, + {0.95105652f, -0.30901699f}, {0.94693013f, -0.32143947f}, + {0.94264149f, -0.33380686f}, {0.93819134f, -0.34611706f}, + {0.93358043f, -0.35836795f}, {0.92880955f, -0.37055744f}, + {0.92387953f, -0.38268343f}, {0.91879121f, -0.39474386f}, + {0.91354546f, -0.40673664f}, {0.90814317f, -0.41865974f}, + {0.90258528f, -0.43051110f}, {0.89687274f, -0.44228869f}, + {0.89100652f, -0.45399050f}, {0.88498764f, -0.46561452f}, + {0.87881711f, -0.47715876f}, {0.87249601f, -0.48862124f}, + {0.86602540f, -0.50000000f}, {0.85940641f, -0.51129309f}, + {0.85264016f, -0.52249856f}, {0.84572782f, -0.53361452f}, + {0.83867057f, -0.54463904f}, {0.83146961f, -0.55557023f}, + {0.82412619f, -0.56640624f}, {0.81664156f, -0.57714519f}, + {0.80901699f, -0.58778525f}, {0.80125381f, -0.59832460f}, + {0.79335334f, -0.60876143f}, {0.78531693f, -0.61909395f}, + {0.77714596f, -0.62932039f}, {0.76884183f, -0.63943900f}, + {0.76040597f, -0.64944805f}, {0.75183981f, -0.65934582f}, + {0.74314483f, -0.66913061f}, {0.73432251f, -0.67880075f}, + {0.72537437f, -0.68835458f}, {0.71630194f, -0.69779046f}, + {0.70710678f, -0.70710678f}, {0.69779046f, -0.71630194f}, + {0.68835458f, -0.72537437f}, {0.67880075f, -0.73432251f}, + {0.66913061f, -0.74314483f}, {0.65934582f, -0.75183981f}, + {0.64944805f, -0.76040597f}, {0.63943900f, -0.76884183f}, + {0.62932039f, -0.77714596f}, {0.61909395f, -0.78531693f}, + {0.60876143f, -0.79335334f}, {0.59832460f, -0.80125381f}, + {0.58778525f, -0.80901699f}, {0.57714519f, -0.81664156f}, + {0.56640624f, -0.82412619f}, {0.55557023f, -0.83146961f}, + {0.54463904f, -0.83867057f}, {0.53361452f, -0.84572782f}, + {0.52249856f, -0.85264016f}, {0.51129309f, -0.85940641f}, + {0.50000000f, -0.86602540f}, {0.48862124f, -0.87249601f}, + {0.47715876f, -0.87881711f}, {0.46561452f, -0.88498764f}, + {0.45399050f, -0.89100652f}, {0.44228869f, -0.89687274f}, + {0.43051110f, -0.90258528f}, {0.41865974f, -0.90814317f}, + {0.40673664f, -0.91354546f}, {0.39474386f, -0.91879121f}, + {0.38268343f, -0.92387953f}, {0.37055744f, -0.92880955f}, + {0.35836795f, -0.93358043f}, {0.34611706f, -0.93819134f}, + {0.33380686f, -0.94264149f}, {0.32143947f, -0.94693013f}, + {0.30901699f, -0.95105652f}, {0.29654157f, -0.95501994f}, + {0.28401534f, -0.95881973f}, {0.27144045f, -0.96245524f}, + {0.25881905f, -0.96592583f}, {0.24615329f, -0.96923091f}, + {0.23344536f, -0.97236992f}, {0.22069744f, -0.97534232f}, + {0.20791169f, -0.97814760f}, {0.19509032f, -0.98078528f}, + {0.18223553f, -0.98325491f}, {0.16934950f, -0.98555606f}, + {0.15643447f, -0.98768834f}, {0.14349262f, -0.98965139f}, + {0.13052619f, -0.99144486f}, {0.11753740f, -0.99306846f}, + {0.10452846f, -0.99452190f}, {0.091501619f, -0.99580493f}, + {0.078459096f, -0.99691733f}, {0.065403129f, -0.99785892f}, + {0.052335956f, -0.99862953f}, {0.039259816f, -0.99922904f}, + {0.026176948f, -0.99965732f}, {0.013089596f, -0.99991433f}, + {6.1232340e-17f, -1.0000000f}, {-0.013089596f, -0.99991433f}, + {-0.026176948f, -0.99965732f}, {-0.039259816f, -0.99922904f}, + {-0.052335956f, -0.99862953f}, {-0.065403129f, -0.99785892f}, + {-0.078459096f, -0.99691733f}, {-0.091501619f, -0.99580493f}, + {-0.10452846f, -0.99452190f}, {-0.11753740f, -0.99306846f}, + {-0.13052619f, -0.99144486f}, {-0.14349262f, -0.98965139f}, + {-0.15643447f, -0.98768834f}, {-0.16934950f, -0.98555606f}, + {-0.18223553f, -0.98325491f}, {-0.19509032f, -0.98078528f}, + {-0.20791169f, -0.97814760f}, {-0.22069744f, -0.97534232f}, + {-0.23344536f, -0.97236992f}, {-0.24615329f, -0.96923091f}, + {-0.25881905f, -0.96592583f}, {-0.27144045f, -0.96245524f}, + {-0.28401534f, -0.95881973f}, {-0.29654157f, -0.95501994f}, + {-0.30901699f, -0.95105652f}, {-0.32143947f, -0.94693013f}, + {-0.33380686f, -0.94264149f}, {-0.34611706f, -0.93819134f}, + {-0.35836795f, -0.93358043f}, {-0.37055744f, -0.92880955f}, + {-0.38268343f, -0.92387953f}, {-0.39474386f, -0.91879121f}, + {-0.40673664f, -0.91354546f}, {-0.41865974f, -0.90814317f}, + {-0.43051110f, -0.90258528f}, {-0.44228869f, -0.89687274f}, + {-0.45399050f, -0.89100652f}, {-0.46561452f, -0.88498764f}, + {-0.47715876f, -0.87881711f}, {-0.48862124f, -0.87249601f}, + {-0.50000000f, -0.86602540f}, {-0.51129309f, -0.85940641f}, + {-0.52249856f, -0.85264016f}, {-0.53361452f, -0.84572782f}, + {-0.54463904f, -0.83867057f}, {-0.55557023f, -0.83146961f}, + {-0.56640624f, -0.82412619f}, {-0.57714519f, -0.81664156f}, + {-0.58778525f, -0.80901699f}, {-0.59832460f, -0.80125381f}, + {-0.60876143f, -0.79335334f}, {-0.61909395f, -0.78531693f}, + {-0.62932039f, -0.77714596f}, {-0.63943900f, -0.76884183f}, + {-0.64944805f, -0.76040597f}, {-0.65934582f, -0.75183981f}, + {-0.66913061f, -0.74314483f}, {-0.67880075f, -0.73432251f}, + {-0.68835458f, -0.72537437f}, {-0.69779046f, -0.71630194f}, + {-0.70710678f, -0.70710678f}, {-0.71630194f, -0.69779046f}, + {-0.72537437f, -0.68835458f}, {-0.73432251f, -0.67880075f}, + {-0.74314483f, -0.66913061f}, {-0.75183981f, -0.65934582f}, + {-0.76040597f, -0.64944805f}, {-0.76884183f, -0.63943900f}, + {-0.77714596f, -0.62932039f}, {-0.78531693f, -0.61909395f}, + {-0.79335334f, -0.60876143f}, {-0.80125381f, -0.59832460f}, + {-0.80901699f, -0.58778525f}, {-0.81664156f, -0.57714519f}, + {-0.82412619f, -0.56640624f}, {-0.83146961f, -0.55557023f}, + {-0.83867057f, -0.54463904f}, {-0.84572782f, -0.53361452f}, + {-0.85264016f, -0.52249856f}, {-0.85940641f, -0.51129309f}, + {-0.86602540f, -0.50000000f}, {-0.87249601f, -0.48862124f}, + {-0.87881711f, -0.47715876f}, {-0.88498764f, -0.46561452f}, + {-0.89100652f, -0.45399050f}, {-0.89687274f, -0.44228869f}, + {-0.90258528f, -0.43051110f}, {-0.90814317f, -0.41865974f}, + {-0.91354546f, -0.40673664f}, {-0.91879121f, -0.39474386f}, + {-0.92387953f, -0.38268343f}, {-0.92880955f, -0.37055744f}, + {-0.93358043f, -0.35836795f}, {-0.93819134f, -0.34611706f}, + {-0.94264149f, -0.33380686f}, {-0.94693013f, -0.32143947f}, + {-0.95105652f, -0.30901699f}, {-0.95501994f, -0.29654157f}, + {-0.95881973f, -0.28401534f}, {-0.96245524f, -0.27144045f}, + {-0.96592583f, -0.25881905f}, {-0.96923091f, -0.24615329f}, + {-0.97236992f, -0.23344536f}, {-0.97534232f, -0.22069744f}, + {-0.97814760f, -0.20791169f}, {-0.98078528f, -0.19509032f}, + {-0.98325491f, -0.18223553f}, {-0.98555606f, -0.16934950f}, + {-0.98768834f, -0.15643447f}, {-0.98965139f, -0.14349262f}, + {-0.99144486f, -0.13052619f}, {-0.99306846f, -0.11753740f}, + {-0.99452190f, -0.10452846f}, {-0.99580493f, -0.091501619f}, + {-0.99691733f, -0.078459096f}, {-0.99785892f, -0.065403129f}, + {-0.99862953f, -0.052335956f}, {-0.99922904f, -0.039259816f}, + {-0.99965732f, -0.026176948f}, {-0.99991433f, -0.013089596f}, + {-1.0000000f, -1.2246468e-16f}, {-0.99991433f, 0.013089596f}, + {-0.99965732f, 0.026176948f}, {-0.99922904f, 0.039259816f}, + {-0.99862953f, 0.052335956f}, {-0.99785892f, 0.065403129f}, + {-0.99691733f, 0.078459096f}, {-0.99580493f, 0.091501619f}, + {-0.99452190f, 0.10452846f}, {-0.99306846f, 0.11753740f}, + {-0.99144486f, 0.13052619f}, {-0.98965139f, 0.14349262f}, + {-0.98768834f, 0.15643447f}, {-0.98555606f, 0.16934950f}, + {-0.98325491f, 0.18223553f}, {-0.98078528f, 0.19509032f}, + {-0.97814760f, 0.20791169f}, {-0.97534232f, 0.22069744f}, + {-0.97236992f, 0.23344536f}, {-0.96923091f, 0.24615329f}, + {-0.96592583f, 0.25881905f}, {-0.96245524f, 0.27144045f}, + {-0.95881973f, 0.28401534f}, {-0.95501994f, 0.29654157f}, + {-0.95105652f, 0.30901699f}, {-0.94693013f, 0.32143947f}, + {-0.94264149f, 0.33380686f}, {-0.93819134f, 0.34611706f}, + {-0.93358043f, 0.35836795f}, {-0.92880955f, 0.37055744f}, + {-0.92387953f, 0.38268343f}, {-0.91879121f, 0.39474386f}, + {-0.91354546f, 0.40673664f}, {-0.90814317f, 0.41865974f}, + {-0.90258528f, 0.43051110f}, {-0.89687274f, 0.44228869f}, + {-0.89100652f, 0.45399050f}, {-0.88498764f, 0.46561452f}, + {-0.87881711f, 0.47715876f}, {-0.87249601f, 0.48862124f}, + {-0.86602540f, 0.50000000f}, {-0.85940641f, 0.51129309f}, + {-0.85264016f, 0.52249856f}, {-0.84572782f, 0.53361452f}, + {-0.83867057f, 0.54463904f}, {-0.83146961f, 0.55557023f}, + {-0.82412619f, 0.56640624f}, {-0.81664156f, 0.57714519f}, + {-0.80901699f, 0.58778525f}, {-0.80125381f, 0.59832460f}, + {-0.79335334f, 0.60876143f}, {-0.78531693f, 0.61909395f}, + {-0.77714596f, 0.62932039f}, {-0.76884183f, 0.63943900f}, + {-0.76040597f, 0.64944805f}, {-0.75183981f, 0.65934582f}, + {-0.74314483f, 0.66913061f}, {-0.73432251f, 0.67880075f}, + {-0.72537437f, 0.68835458f}, {-0.71630194f, 0.69779046f}, + {-0.70710678f, 0.70710678f}, {-0.69779046f, 0.71630194f}, + {-0.68835458f, 0.72537437f}, {-0.67880075f, 0.73432251f}, + {-0.66913061f, 0.74314483f}, {-0.65934582f, 0.75183981f}, + {-0.64944805f, 0.76040597f}, {-0.63943900f, 0.76884183f}, + {-0.62932039f, 0.77714596f}, {-0.61909395f, 0.78531693f}, + {-0.60876143f, 0.79335334f}, {-0.59832460f, 0.80125381f}, + {-0.58778525f, 0.80901699f}, {-0.57714519f, 0.81664156f}, + {-0.56640624f, 0.82412619f}, {-0.55557023f, 0.83146961f}, + {-0.54463904f, 0.83867057f}, {-0.53361452f, 0.84572782f}, + {-0.52249856f, 0.85264016f}, {-0.51129309f, 0.85940641f}, + {-0.50000000f, 0.86602540f}, {-0.48862124f, 0.87249601f}, + {-0.47715876f, 0.87881711f}, {-0.46561452f, 0.88498764f}, + {-0.45399050f, 0.89100652f}, {-0.44228869f, 0.89687274f}, + {-0.43051110f, 0.90258528f}, {-0.41865974f, 0.90814317f}, + {-0.40673664f, 0.91354546f}, {-0.39474386f, 0.91879121f}, + {-0.38268343f, 0.92387953f}, {-0.37055744f, 0.92880955f}, + {-0.35836795f, 0.93358043f}, {-0.34611706f, 0.93819134f}, + {-0.33380686f, 0.94264149f}, {-0.32143947f, 0.94693013f}, + {-0.30901699f, 0.95105652f}, {-0.29654157f, 0.95501994f}, + {-0.28401534f, 0.95881973f}, {-0.27144045f, 0.96245524f}, + {-0.25881905f, 0.96592583f}, {-0.24615329f, 0.96923091f}, + {-0.23344536f, 0.97236992f}, {-0.22069744f, 0.97534232f}, + {-0.20791169f, 0.97814760f}, {-0.19509032f, 0.98078528f}, + {-0.18223553f, 0.98325491f}, {-0.16934950f, 0.98555606f}, + {-0.15643447f, 0.98768834f}, {-0.14349262f, 0.98965139f}, + {-0.13052619f, 0.99144486f}, {-0.11753740f, 0.99306846f}, + {-0.10452846f, 0.99452190f}, {-0.091501619f, 0.99580493f}, + {-0.078459096f, 0.99691733f}, {-0.065403129f, 0.99785892f}, + {-0.052335956f, 0.99862953f}, {-0.039259816f, 0.99922904f}, + {-0.026176948f, 0.99965732f}, {-0.013089596f, 0.99991433f}, + {-1.8369702e-16f, 1.0000000f}, {0.013089596f, 0.99991433f}, + {0.026176948f, 0.99965732f}, {0.039259816f, 0.99922904f}, + {0.052335956f, 0.99862953f}, {0.065403129f, 0.99785892f}, + {0.078459096f, 0.99691733f}, {0.091501619f, 0.99580493f}, + {0.10452846f, 0.99452190f}, {0.11753740f, 0.99306846f}, + {0.13052619f, 0.99144486f}, {0.14349262f, 0.98965139f}, + {0.15643447f, 0.98768834f}, {0.16934950f, 0.98555606f}, + {0.18223553f, 0.98325491f}, {0.19509032f, 0.98078528f}, + {0.20791169f, 0.97814760f}, {0.22069744f, 0.97534232f}, + {0.23344536f, 0.97236992f}, {0.24615329f, 0.96923091f}, + {0.25881905f, 0.96592583f}, {0.27144045f, 0.96245524f}, + {0.28401534f, 0.95881973f}, {0.29654157f, 0.95501994f}, + {0.30901699f, 0.95105652f}, {0.32143947f, 0.94693013f}, + {0.33380686f, 0.94264149f}, {0.34611706f, 0.93819134f}, + {0.35836795f, 0.93358043f}, {0.37055744f, 0.92880955f}, + {0.38268343f, 0.92387953f}, {0.39474386f, 0.91879121f}, + {0.40673664f, 0.91354546f}, {0.41865974f, 0.90814317f}, + {0.43051110f, 0.90258528f}, {0.44228869f, 0.89687274f}, + {0.45399050f, 0.89100652f}, {0.46561452f, 0.88498764f}, + {0.47715876f, 0.87881711f}, {0.48862124f, 0.87249601f}, + {0.50000000f, 0.86602540f}, {0.51129309f, 0.85940641f}, + {0.52249856f, 0.85264016f}, {0.53361452f, 0.84572782f}, + {0.54463904f, 0.83867057f}, {0.55557023f, 0.83146961f}, + {0.56640624f, 0.82412619f}, {0.57714519f, 0.81664156f}, + {0.58778525f, 0.80901699f}, {0.59832460f, 0.80125381f}, + {0.60876143f, 0.79335334f}, {0.61909395f, 0.78531693f}, + {0.62932039f, 0.77714596f}, {0.63943900f, 0.76884183f}, + {0.64944805f, 0.76040597f}, {0.65934582f, 0.75183981f}, + {0.66913061f, 0.74314483f}, {0.67880075f, 0.73432251f}, + {0.68835458f, 0.72537437f}, {0.69779046f, 0.71630194f}, + {0.70710678f, 0.70710678f}, {0.71630194f, 0.69779046f}, + {0.72537437f, 0.68835458f}, {0.73432251f, 0.67880075f}, + {0.74314483f, 0.66913061f}, {0.75183981f, 0.65934582f}, + {0.76040597f, 0.64944805f}, {0.76884183f, 0.63943900f}, + {0.77714596f, 0.62932039f}, {0.78531693f, 0.61909395f}, + {0.79335334f, 0.60876143f}, {0.80125381f, 0.59832460f}, + {0.80901699f, 0.58778525f}, {0.81664156f, 0.57714519f}, + {0.82412619f, 0.56640624f}, {0.83146961f, 0.55557023f}, + {0.83867057f, 0.54463904f}, {0.84572782f, 0.53361452f}, + {0.85264016f, 0.52249856f}, {0.85940641f, 0.51129309f}, + {0.86602540f, 0.50000000f}, {0.87249601f, 0.48862124f}, + {0.87881711f, 0.47715876f}, {0.88498764f, 0.46561452f}, + {0.89100652f, 0.45399050f}, {0.89687274f, 0.44228869f}, + {0.90258528f, 0.43051110f}, {0.90814317f, 0.41865974f}, + {0.91354546f, 0.40673664f}, {0.91879121f, 0.39474386f}, + {0.92387953f, 0.38268343f}, {0.92880955f, 0.37055744f}, + {0.93358043f, 0.35836795f}, {0.93819134f, 0.34611706f}, + {0.94264149f, 0.33380686f}, {0.94693013f, 0.32143947f}, + {0.95105652f, 0.30901699f}, {0.95501994f, 0.29654157f}, + {0.95881973f, 0.28401534f}, {0.96245524f, 0.27144045f}, + {0.96592583f, 0.25881905f}, {0.96923091f, 0.24615329f}, + {0.97236992f, 0.23344536f}, {0.97534232f, 0.22069744f}, + {0.97814760f, 0.20791169f}, {0.98078528f, 0.19509032f}, + {0.98325491f, 0.18223553f}, {0.98555606f, 0.16934950f}, + {0.98768834f, 0.15643447f}, {0.98965139f, 0.14349262f}, + {0.99144486f, 0.13052619f}, {0.99306846f, 0.11753740f}, + {0.99452190f, 0.10452846f}, {0.99580493f, 0.091501619f}, + {0.99691733f, 0.078459096f}, {0.99785892f, 0.065403129f}, + {0.99862953f, 0.052335956f}, {0.99922904f, 0.039259816f}, + {0.99965732f, 0.026176948f}, {0.99991433f, 0.013089596f}, }; -#ifndef FFT_BITREV480 -#define FFT_BITREV480 -static const opus_int16 fft_bitrev480[480] = { -0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, -8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, -16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, -24, 120, 216, 312, 408, 56, 152, 248, 344, 440, 88, 184, 280, 376, 472, -4, 100, 196, 292, 388, 36, 132, 228, 324, 420, 68, 164, 260, 356, 452, -12, 108, 204, 300, 396, 44, 140, 236, 332, 428, 76, 172, 268, 364, 460, -20, 116, 212, 308, 404, 52, 148, 244, 340, 436, 84, 180, 276, 372, 468, -28, 124, 220, 316, 412, 60, 156, 252, 348, 444, 92, 188, 284, 380, 476, -1, 97, 193, 289, 385, 33, 129, 225, 321, 417, 65, 161, 257, 353, 449, -9, 105, 201, 297, 393, 41, 137, 233, 329, 425, 73, 169, 265, 361, 457, -17, 113, 209, 305, 401, 49, 145, 241, 337, 433, 81, 177, 273, 369, 465, -25, 121, 217, 313, 409, 57, 153, 249, 345, 441, 89, 185, 281, 377, 473, -5, 101, 197, 293, 389, 37, 133, 229, 325, 421, 69, 165, 261, 357, 453, -13, 109, 205, 301, 397, 45, 141, 237, 333, 429, 77, 173, 269, 365, 461, -21, 117, 213, 309, 405, 53, 149, 245, 341, 437, 85, 181, 277, 373, 469, -29, 125, 221, 317, 413, 61, 157, 253, 349, 445, 93, 189, 285, 381, 477, -2, 98, 194, 290, 386, 34, 130, 226, 322, 418, 66, 162, 258, 354, 450, -10, 106, 202, 298, 394, 42, 138, 234, 330, 426, 74, 170, 266, 362, 458, -18, 114, 210, 306, 402, 50, 146, 242, 338, 434, 82, 178, 274, 370, 466, -26, 122, 218, 314, 410, 58, 154, 250, 346, 442, 90, 186, 282, 378, 474, -6, 102, 198, 294, 390, 38, 134, 230, 326, 422, 70, 166, 262, 358, 454, -14, 110, 206, 302, 398, 46, 142, 238, 334, 430, 78, 174, 270, 366, 462, -22, 118, 214, 310, 406, 54, 150, 246, 342, 438, 86, 182, 278, 374, 470, -30, 126, 222, 318, 414, 62, 158, 254, 350, 446, 94, 190, 286, 382, 478, -3, 99, 195, 291, 387, 35, 131, 227, 323, 419, 67, 163, 259, 355, 451, -11, 107, 203, 299, 395, 43, 139, 235, 331, 427, 75, 171, 267, 363, 459, -19, 115, 211, 307, 403, 51, 147, 243, 339, 435, 83, 179, 275, 371, 467, -27, 123, 219, 315, 411, 59, 155, 251, 347, 443, 91, 187, 283, 379, 475, -7, 103, 199, 295, 391, 39, 135, 231, 327, 423, 71, 167, 263, 359, 455, -15, 111, 207, 303, 399, 47, 143, 239, 335, 431, 79, 175, 271, 367, 463, -23, 119, 215, 311, 407, 55, 151, 247, 343, 439, 87, 183, 279, 375, 471, -31, 127, 223, 319, 415, 63, 159, 255, 351, 447, 95, 191, 287, 383, 479, +# ifndef FFT_BITREV480 +# define FFT_BITREV480 +static const oac_int16 fft_bitrev480[480] = { + 0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, + 8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, + 16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, + 24, 120, 216, 312, 408, 56, 152, 248, 344, 440, 88, 184, 280, 376, 472, + 4, 100, 196, 292, 388, 36, 132, 228, 324, 420, 68, 164, 260, 356, 452, + 12, 108, 204, 300, 396, 44, 140, 236, 332, 428, 76, 172, 268, 364, 460, + 20, 116, 212, 308, 404, 52, 148, 244, 340, 436, 84, 180, 276, 372, 468, + 28, 124, 220, 316, 412, 60, 156, 252, 348, 444, 92, 188, 284, 380, 476, + 1, 97, 193, 289, 385, 33, 129, 225, 321, 417, 65, 161, 257, 353, 449, + 9, 105, 201, 297, 393, 41, 137, 233, 329, 425, 73, 169, 265, 361, 457, + 17, 113, 209, 305, 401, 49, 145, 241, 337, 433, 81, 177, 273, 369, 465, + 25, 121, 217, 313, 409, 57, 153, 249, 345, 441, 89, 185, 281, 377, 473, + 5, 101, 197, 293, 389, 37, 133, 229, 325, 421, 69, 165, 261, 357, 453, + 13, 109, 205, 301, 397, 45, 141, 237, 333, 429, 77, 173, 269, 365, 461, + 21, 117, 213, 309, 405, 53, 149, 245, 341, 437, 85, 181, 277, 373, 469, + 29, 125, 221, 317, 413, 61, 157, 253, 349, 445, 93, 189, 285, 381, 477, + 2, 98, 194, 290, 386, 34, 130, 226, 322, 418, 66, 162, 258, 354, 450, + 10, 106, 202, 298, 394, 42, 138, 234, 330, 426, 74, 170, 266, 362, 458, + 18, 114, 210, 306, 402, 50, 146, 242, 338, 434, 82, 178, 274, 370, 466, + 26, 122, 218, 314, 410, 58, 154, 250, 346, 442, 90, 186, 282, 378, 474, + 6, 102, 198, 294, 390, 38, 134, 230, 326, 422, 70, 166, 262, 358, 454, + 14, 110, 206, 302, 398, 46, 142, 238, 334, 430, 78, 174, 270, 366, 462, + 22, 118, 214, 310, 406, 54, 150, 246, 342, 438, 86, 182, 278, 374, 470, + 30, 126, 222, 318, 414, 62, 158, 254, 350, 446, 94, 190, 286, 382, 478, + 3, 99, 195, 291, 387, 35, 131, 227, 323, 419, 67, 163, 259, 355, 451, + 11, 107, 203, 299, 395, 43, 139, 235, 331, 427, 75, 171, 267, 363, 459, + 19, 115, 211, 307, 403, 51, 147, 243, 339, 435, 83, 179, 275, 371, 467, + 27, 123, 219, 315, 411, 59, 155, 251, 347, 443, 91, 187, 283, 379, 475, + 7, 103, 199, 295, 391, 39, 135, 231, 327, 423, 71, 167, 263, 359, 455, + 15, 111, 207, 303, 399, 47, 143, 239, 335, 431, 79, 175, 271, 367, 463, + 23, 119, 215, 311, 407, 55, 151, 247, 343, 439, 87, 183, 279, 375, 471, + 31, 127, 223, 319, 415, 63, 159, 255, 351, 447, 95, 191, 287, 383, 479, }; -#endif +# endif -#ifndef FFT_BITREV240 -#define FFT_BITREV240 -static const opus_int16 fft_bitrev240[240] = { -0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, -4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, -8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, -12, 60, 108, 156, 204, 28, 76, 124, 172, 220, 44, 92, 140, 188, 236, -1, 49, 97, 145, 193, 17, 65, 113, 161, 209, 33, 81, 129, 177, 225, -5, 53, 101, 149, 197, 21, 69, 117, 165, 213, 37, 85, 133, 181, 229, -9, 57, 105, 153, 201, 25, 73, 121, 169, 217, 41, 89, 137, 185, 233, -13, 61, 109, 157, 205, 29, 77, 125, 173, 221, 45, 93, 141, 189, 237, -2, 50, 98, 146, 194, 18, 66, 114, 162, 210, 34, 82, 130, 178, 226, -6, 54, 102, 150, 198, 22, 70, 118, 166, 214, 38, 86, 134, 182, 230, -10, 58, 106, 154, 202, 26, 74, 122, 170, 218, 42, 90, 138, 186, 234, -14, 62, 110, 158, 206, 30, 78, 126, 174, 222, 46, 94, 142, 190, 238, -3, 51, 99, 147, 195, 19, 67, 115, 163, 211, 35, 83, 131, 179, 227, -7, 55, 103, 151, 199, 23, 71, 119, 167, 215, 39, 87, 135, 183, 231, -11, 59, 107, 155, 203, 27, 75, 123, 171, 219, 43, 91, 139, 187, 235, -15, 63, 111, 159, 207, 31, 79, 127, 175, 223, 47, 95, 143, 191, 239, +# ifndef FFT_BITREV240 +# define FFT_BITREV240 +static const oac_int16 fft_bitrev240[240] = { + 0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, + 4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, + 8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, + 12, 60, 108, 156, 204, 28, 76, 124, 172, 220, 44, 92, 140, 188, 236, + 1, 49, 97, 145, 193, 17, 65, 113, 161, 209, 33, 81, 129, 177, 225, + 5, 53, 101, 149, 197, 21, 69, 117, 165, 213, 37, 85, 133, 181, 229, + 9, 57, 105, 153, 201, 25, 73, 121, 169, 217, 41, 89, 137, 185, 233, + 13, 61, 109, 157, 205, 29, 77, 125, 173, 221, 45, 93, 141, 189, 237, + 2, 50, 98, 146, 194, 18, 66, 114, 162, 210, 34, 82, 130, 178, 226, + 6, 54, 102, 150, 198, 22, 70, 118, 166, 214, 38, 86, 134, 182, 230, + 10, 58, 106, 154, 202, 26, 74, 122, 170, 218, 42, 90, 138, 186, 234, + 14, 62, 110, 158, 206, 30, 78, 126, 174, 222, 46, 94, 142, 190, 238, + 3, 51, 99, 147, 195, 19, 67, 115, 163, 211, 35, 83, 131, 179, 227, + 7, 55, 103, 151, 199, 23, 71, 119, 167, 215, 39, 87, 135, 183, 231, + 11, 59, 107, 155, 203, 27, 75, 123, 171, 219, 43, 91, 139, 187, 235, + 15, 63, 111, 159, 207, 31, 79, 127, 175, 223, 47, 95, 143, 191, 239, }; -#endif +# endif -#ifndef FFT_BITREV120 -#define FFT_BITREV120 -static const opus_int16 fft_bitrev120[120] = { -0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, -4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, -1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, -5, 29, 53, 77, 101, 13, 37, 61, 85, 109, 21, 45, 69, 93, 117, -2, 26, 50, 74, 98, 10, 34, 58, 82, 106, 18, 42, 66, 90, 114, -6, 30, 54, 78, 102, 14, 38, 62, 86, 110, 22, 46, 70, 94, 118, -3, 27, 51, 75, 99, 11, 35, 59, 83, 107, 19, 43, 67, 91, 115, -7, 31, 55, 79, 103, 15, 39, 63, 87, 111, 23, 47, 71, 95, 119, +# ifndef FFT_BITREV120 +# define FFT_BITREV120 +static const oac_int16 fft_bitrev120[120] = { + 0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, + 4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, + 1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, + 5, 29, 53, 77, 101, 13, 37, 61, 85, 109, 21, 45, 69, 93, 117, + 2, 26, 50, 74, 98, 10, 34, 58, 82, 106, 18, 42, 66, 90, 114, + 6, 30, 54, 78, 102, 14, 38, 62, 86, 110, 22, 46, 70, 94, 118, + 3, 27, 51, 75, 99, 11, 35, 59, 83, 107, 19, 43, 67, 91, 115, + 7, 31, 55, 79, 103, 15, 39, 63, 87, 111, 23, 47, 71, 95, 119, }; -#endif +# endif -#ifndef FFT_BITREV60 -#define FFT_BITREV60 -static const opus_int16 fft_bitrev60[60] = { -0, 12, 24, 36, 48, 4, 16, 28, 40, 52, 8, 20, 32, 44, 56, -1, 13, 25, 37, 49, 5, 17, 29, 41, 53, 9, 21, 33, 45, 57, -2, 14, 26, 38, 50, 6, 18, 30, 42, 54, 10, 22, 34, 46, 58, -3, 15, 27, 39, 51, 7, 19, 31, 43, 55, 11, 23, 35, 47, 59, +# ifndef FFT_BITREV60 +# define FFT_BITREV60 +static const oac_int16 fft_bitrev60[60] = { + 0, 12, 24, 36, 48, 4, 16, 28, 40, 52, 8, 20, 32, 44, 56, + 1, 13, 25, 37, 49, 5, 17, 29, 41, 53, 9, 21, 33, 45, 57, + 2, 14, 26, 38, 50, 6, 18, 30, 42, 54, 10, 22, 34, 46, 58, + 3, 15, 27, 39, 51, 7, 19, 31, 43, 55, 11, 23, 35, 47, 59, }; -#endif +# endif -#ifndef FFT_STATE48000_960_0 -#define FFT_STATE48000_960_0 +# ifndef FFT_STATE48000_960_0 +# define FFT_STATE48000_960_0 static const kiss_fft_state fft_state48000_960_0 = { -480, /* nfft */ -0.0020833334f, /* scale */ --1, /* shift */ -{5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev480, /* bitrev */ -fft_twiddles48000_960, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_480, -#else -NULL, -#endif + 480, /* nfft */ + 0.0020833334f, /* scale */ + -1, /* shift */ + {5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev480, /* bitrev */ + fft_twiddles48000_960, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_480, +# else + NULL, +# endif }; -#endif +# endif -#ifndef FFT_STATE48000_960_1 -#define FFT_STATE48000_960_1 +# ifndef FFT_STATE48000_960_1 +# define FFT_STATE48000_960_1 static const kiss_fft_state fft_state48000_960_1 = { -240, /* nfft */ -0.0041666669f, /* scale */ -1, /* shift */ -{5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev240, /* bitrev */ -fft_twiddles48000_960, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_240, -#else -NULL, -#endif + 240, /* nfft */ + 0.0041666669f, /* scale */ + 1, /* shift */ + {5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev240, /* bitrev */ + fft_twiddles48000_960, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_240, +# else + NULL, +# endif }; -#endif +# endif -#ifndef FFT_STATE48000_960_2 -#define FFT_STATE48000_960_2 +# ifndef FFT_STATE48000_960_2 +# define FFT_STATE48000_960_2 static const kiss_fft_state fft_state48000_960_2 = { -120, /* nfft */ -0.0083333338f, /* scale */ -2, /* shift */ -{5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev120, /* bitrev */ -fft_twiddles48000_960, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_120, -#else -NULL, -#endif + 120, /* nfft */ + 0.0083333338f, /* scale */ + 2, /* shift */ + {5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev120, /* bitrev */ + fft_twiddles48000_960, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_120, +# else + NULL, +# endif }; -#endif +# endif -#ifndef FFT_STATE48000_960_3 -#define FFT_STATE48000_960_3 +# ifndef FFT_STATE48000_960_3 +# define FFT_STATE48000_960_3 static const kiss_fft_state fft_state48000_960_3 = { -60, /* nfft */ -0.016666668f, /* scale */ -3, /* shift */ -{5, 12, 3, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev60, /* bitrev */ -fft_twiddles48000_960, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_60, -#else -NULL, -#endif + 60, /* nfft */ + 0.016666668f, /* scale */ + 3, /* shift */ + {5, 12, 3, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev60, /* bitrev */ + fft_twiddles48000_960, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_60, +# else + NULL, +# endif }; -#endif +# endif #endif #ifndef MDCT_TWIDDLES960 -#define MDCT_TWIDDLES960 +# define MDCT_TWIDDLES960 static const celt_coef mdct_twiddles960[1800] = { -0.99999992f, 0.99999322f, 0.99997582f, 0.99994771f, 0.99990889f, -0.99985936f, 0.99979913f, 0.99972818f, 0.99964653f, 0.99955418f, -0.99945112f, 0.99933736f, 0.99921289f, 0.99907773f, 0.99893186f, -0.99877530f, 0.99860804f, 0.99843009f, 0.99824144f, 0.99804211f, -0.99783209f, 0.99761138f, 0.99737998f, 0.99713791f, 0.99688516f, -0.99662173f, 0.99634763f, 0.99606285f, 0.99576741f, 0.99546131f, -0.99514455f, 0.99481713f, 0.99447905f, 0.99413033f, 0.99377096f, -0.99340095f, 0.99302029f, 0.99262901f, 0.99222709f, 0.99181455f, -0.99139139f, 0.99095760f, 0.99051321f, 0.99005821f, 0.98959261f, -0.98911641f, 0.98862961f, 0.98813223f, 0.98762427f, 0.98710573f, -0.98657662f, 0.98603694f, 0.98548670f, 0.98492591f, 0.98435457f, -0.98377269f, 0.98318028f, 0.98257734f, 0.98196387f, 0.98133989f, -0.98070539f, 0.98006040f, 0.97940491f, 0.97873893f, 0.97806247f, -0.97737554f, 0.97667813f, 0.97597027f, 0.97525196f, 0.97452320f, -0.97378401f, 0.97303439f, 0.97227435f, 0.97150389f, 0.97072303f, -0.96993178f, 0.96913014f, 0.96831812f, 0.96749573f, 0.96666298f, -0.96581987f, 0.96496643f, 0.96410265f, 0.96322854f, 0.96234412f, -0.96144939f, 0.96054437f, 0.95962906f, 0.95870347f, 0.95776762f, -0.95682151f, 0.95586515f, 0.95489856f, 0.95392174f, 0.95293471f, -0.95193746f, 0.95093003f, 0.94991241f, 0.94888462f, 0.94784667f, -0.94679856f, 0.94574032f, 0.94467195f, 0.94359346f, 0.94250486f, -0.94140618f, 0.94029741f, 0.93917857f, 0.93804967f, 0.93691073f, -0.93576176f, 0.93460276f, 0.93343375f, 0.93225475f, 0.93106577f, -0.92986681f, 0.92865789f, 0.92743903f, 0.92621024f, 0.92497153f, -0.92372291f, 0.92246440f, 0.92119602f, 0.91991776f, 0.91862966f, -0.91733172f, 0.91602395f, 0.91470637f, 0.91337900f, 0.91204185f, -0.91069493f, 0.90933825f, 0.90797184f, 0.90659570f, 0.90520986f, -0.90381432f, 0.90240910f, 0.90099422f, 0.89956969f, 0.89813553f, -0.89669174f, 0.89523836f, 0.89377538f, 0.89230284f, 0.89082074f, -0.88932910f, 0.88782793f, 0.88631726f, 0.88479710f, 0.88326746f, -0.88172836f, 0.88017982f, 0.87862185f, 0.87705448f, 0.87547771f, -0.87389156f, 0.87229606f, 0.87069121f, 0.86907704f, 0.86745357f, -0.86582080f, 0.86417876f, 0.86252747f, 0.86086694f, 0.85919719f, -0.85751824f, 0.85583010f, 0.85413281f, 0.85242636f, 0.85071078f, -0.84898610f, 0.84725232f, 0.84550947f, 0.84375756f, 0.84199662f, -0.84022666f, 0.83844771f, 0.83665977f, 0.83486287f, 0.83305704f, -0.83124228f, 0.82941862f, 0.82758608f, 0.82574467f, 0.82389442f, -0.82203535f, 0.82016748f, 0.81829082f, 0.81640540f, 0.81451123f, -0.81260835f, 0.81069676f, 0.80877649f, 0.80684755f, 0.80490998f, -0.80296379f, 0.80100899f, 0.79904562f, 0.79707370f, 0.79509323f, -0.79310425f, 0.79110678f, 0.78910084f, 0.78708644f, 0.78506362f, -0.78303239f, 0.78099277f, 0.77894479f, 0.77688847f, 0.77482382f, -0.77275088f, 0.77066967f, 0.76858020f, 0.76648250f, 0.76437659f, -0.76226250f, 0.76014024f, 0.75800984f, 0.75587132f, 0.75372471f, -0.75157003f, 0.74940730f, 0.74723654f, 0.74505779f, 0.74287105f, -0.74067635f, 0.73847373f, 0.73626320f, 0.73404478f, 0.73181850f, -0.72958438f, 0.72734245f, 0.72509273f, 0.72283525f, 0.72057002f, -0.71829708f, 0.71601644f, 0.71372814f, 0.71143220f, 0.70912863f, -0.70681747f, 0.70449874f, 0.70217247f, 0.69983868f, 0.69749739f, -0.69514863f, 0.69279243f, 0.69042881f, 0.68805780f, 0.68567941f, -0.68329369f, 0.68090064f, 0.67850031f, 0.67609270f, 0.67367786f, -0.67125580f, 0.66882656f, 0.66639015f, 0.66394661f, 0.66149595f, -0.65903821f, 0.65657341f, 0.65410159f, 0.65162275f, 0.64913694f, -0.64664418f, 0.64414449f, 0.64163790f, 0.63912444f, 0.63660414f, -0.63407702f, 0.63154311f, 0.62900244f, 0.62645503f, 0.62390091f, -0.62134011f, 0.61877265f, 0.61619857f, 0.61361789f, 0.61103064f, -0.60843685f, 0.60583654f, 0.60322974f, 0.60061648f, 0.59799679f, -0.59537069f, 0.59273822f, 0.59009940f, 0.58745427f, 0.58480284f, -0.58214514f, 0.57948122f, 0.57681109f, 0.57413478f, 0.57145232f, -0.56876374f, 0.56606907f, 0.56336834f, 0.56066158f, 0.55794881f, -0.55523006f, 0.55250537f, 0.54977477f, 0.54703827f, 0.54429592f, -0.54154774f, 0.53879376f, 0.53603401f, 0.53326852f, 0.53049731f, -0.52772043f, 0.52493790f, 0.52214974f, 0.51935599f, 0.51655668f, -0.51375184f, 0.51094149f, 0.50812568f, 0.50530442f, 0.50247775f, -0.49964570f, 0.49680830f, 0.49396558f, 0.49111757f, 0.48826430f, -0.48540580f, 0.48254210f, 0.47967323f, 0.47679923f, 0.47392012f, -0.47103594f, 0.46814671f, 0.46525247f, 0.46235324f, 0.45944907f, -0.45653997f, 0.45362599f, 0.45070714f, 0.44778347f, 0.44485501f, -0.44192178f, 0.43898381f, 0.43604115f, 0.43309382f, 0.43014185f, -0.42718527f, 0.42422412f, 0.42125842f, 0.41828822f, 0.41531353f, -0.41233440f, 0.40935085f, 0.40636291f, 0.40337063f, 0.40037402f, -0.39737313f, 0.39436798f, 0.39135861f, 0.38834505f, 0.38532733f, -0.38230548f, 0.37927953f, 0.37624953f, 0.37321550f, 0.37017747f, -0.36713547f, 0.36408955f, 0.36103972f, 0.35798603f, 0.35492850f, -0.35186718f, 0.34880208f, 0.34573325f, 0.34266072f, 0.33958451f, -0.33650468f, 0.33342123f, 0.33033422f, 0.32724367f, 0.32414961f, -0.32105209f, 0.31795112f, 0.31484675f, 0.31173901f, 0.30862793f, -0.30551354f, 0.30239588f, 0.29927499f, 0.29615089f, 0.29302362f, -0.28989321f, 0.28675969f, 0.28362310f, 0.28048348f, 0.27734085f, -0.27419526f, 0.27104672f, 0.26789529f, 0.26474098f, 0.26158384f, -0.25842390f, 0.25526119f, 0.25209575f, 0.24892761f, 0.24575680f, -0.24258336f, 0.23940732f, 0.23622872f, 0.23304759f, 0.22986396f, -0.22667787f, 0.22348935f, 0.22029844f, 0.21710517f, 0.21390958f, -0.21071169f, 0.20751155f, 0.20430919f, 0.20110463f, 0.19789793f, -0.19468910f, 0.19147819f, 0.18826523f, 0.18505026f, 0.18183330f, -0.17861439f, 0.17539357f, 0.17217088f, 0.16894634f, 0.16571999f, -0.16249186f, 0.15926200f, 0.15603043f, 0.15279719f, 0.14956231f, -0.14632583f, 0.14308778f, 0.13984820f, 0.13660713f, 0.13336459f, -0.13012062f, 0.12687526f, 0.12362854f, 0.12038049f, 0.11713116f, -0.11388057f, 0.11062877f, 0.10737578f, 0.10412163f, 0.10086638f, -0.097610040f, 0.094352658f, 0.091094266f, 0.087834897f, 0.084574589f, -0.081313374f, 0.078051289f, 0.074788367f, 0.071524645f, 0.068260157f, -0.064994938f, 0.061729023f, 0.058462447f, 0.055195244f, 0.051927451f, -0.048659101f, 0.045390231f, 0.042120874f, 0.038851066f, 0.035580842f, -0.032310238f, 0.029039287f, 0.025768025f, 0.022496487f, 0.019224708f, -0.015952723f, 0.012680568f, 0.0094082767f, 0.0061358846f, 0.0028634269f, --0.00040906153f, -0.0036815456f, -0.0069539902f, -0.010226360f, -0.013498621f, --0.016770737f, -0.020042673f, -0.023314395f, -0.026585867f, -0.029857055f, --0.033127923f, -0.036398436f, -0.039668559f, -0.042938257f, -0.046207495f, --0.049476239f, -0.052744453f, -0.056012102f, -0.059279151f, -0.062545565f, --0.065811309f, -0.069076349f, -0.072340649f, -0.075604174f, -0.078866890f, --0.082128761f, -0.085389752f, -0.088649829f, -0.091908956f, -0.095167100f, --0.098424224f, -0.10168029f, -0.10493528f, -0.10818913f, -0.11144183f, --0.11469334f, -0.11794361f, -0.12119263f, -0.12444034f, -0.12768673f, --0.13093174f, -0.13417536f, -0.13741753f, -0.14065824f, -0.14389744f, --0.14713510f, -0.15037118f, -0.15360565f, -0.15683848f, -0.16006962f, --0.16329906f, -0.16652674f, -0.16975264f, -0.17297673f, -0.17619896f, --0.17941930f, -0.18263772f, -0.18585419f, -0.18906866f, -0.19228112f, --0.19549151f, -0.19869981f, -0.20190598f, -0.20510998f, -0.20831180f, --0.21151138f, -0.21470869f, -0.21790371f, -0.22109639f, -0.22428671f, --0.22747462f, -0.23066010f, -0.23384310f, -0.23702361f, -0.24020157f, --0.24337696f, -0.24654975f, -0.24971989f, -0.25288736f, -0.25605213f, --0.25921415f, -0.26237339f, -0.26552983f, -0.26868342f, -0.27183413f, --0.27498193f, -0.27812679f, -0.28126867f, -0.28440754f, -0.28754336f, --0.29067610f, -0.29380573f, -0.29693221f, -0.30005551f, -0.30317560f, --0.30629245f, -0.30940601f, -0.31251626f, -0.31562316f, -0.31872668f, --0.32182679f, -0.32492345f, -0.32801664f, -0.33110631f, -0.33419243f, --0.33727497f, -0.34035391f, -0.34342920f, -0.34650081f, -0.34956871f, --0.35263286f, -0.35569324f, -0.35874981f, -0.36180254f, -0.36485139f, --0.36789634f, -0.37093735f, -0.37397438f, -0.37700741f, -0.38003640f, --0.38306132f, -0.38608214f, -0.38909883f, -0.39211135f, -0.39511967f, --0.39812375f, -0.40112358f, -0.40411910f, -0.40711031f, -0.41009715f, --0.41307959f, -0.41605762f, -0.41903119f, -0.42200027f, -0.42496483f, --0.42792484f, -0.43088027f, -0.43383109f, -0.43677726f, -0.43971875f, --0.44265553f, -0.44558757f, -0.44851484f, -0.45143731f, -0.45435494f, --0.45726770f, -0.46017557f, -0.46307851f, -0.46597650f, -0.46886949f, --0.47175746f, -0.47464038f, -0.47751821f, -0.48039093f, -0.48325851f, --0.48612091f, -0.48897811f, -0.49183006f, -0.49467676f, -0.49751815f, --0.50035422f, -0.50318492f, -0.50601024f, -0.50883014f, -0.51164459f, --0.51445356f, -0.51725703f, -0.52005495f, -0.52284730f, -0.52563406f, --0.52841518f, -0.53119065f, -0.53396043f, -0.53672449f, -0.53948280f, --0.54223533f, -0.54498206f, -0.54772295f, -0.55045797f, -0.55318710f, --0.55591031f, -0.55862756f, -0.56133883f, -0.56404409f, -0.56674331f, --0.56943646f, -0.57212351f, -0.57480443f, -0.57747920f, -0.58014778f, --0.58281015f, -0.58546628f, -0.58811614f, -0.59075970f, -0.59339694f, --0.59602782f, -0.59865231f, -0.60127040f, -0.60388204f, -0.60648722f, --0.60908591f, -0.61167807f, -0.61426368f, -0.61684271f, -0.61941514f, --0.62198093f, -0.62454007f, -0.62709251f, -0.62963824f, -0.63217722f, --0.63470944f, -0.63723486f, -0.63975345f, -0.64226519f, -0.64477006f, --0.64726802f, -0.64975905f, -0.65224312f, -0.65472020f, -0.65719027f, --0.65965331f, -0.66210928f, -0.66455816f, -0.66699992f, -0.66943454f, --0.67186199f, -0.67428225f, -0.67669528f, -0.67910107f, -0.68149959f, --0.68389080f, -0.68627470f, -0.68865124f, -0.69102041f, -0.69338218f, --0.69573652f, -0.69808341f, -0.70042283f, -0.70275474f, -0.70507913f, --0.70739597f, -0.70970524f, -0.71200690f, -0.71430093f, -0.71658732f, --0.71886604f, -0.72113705f, -0.72340034f, -0.72565589f, -0.72790366f, --0.73014364f, -0.73237580f, -0.73460012f, -0.73681657f, -0.73902513f, --0.74122577f, -0.74341848f, -0.74560322f, -0.74777998f, -0.74994874f, --0.75210946f, -0.75426212f, -0.75640671f, -0.75854320f, -0.76067157f, --0.76279178f, -0.76490383f, -0.76700769f, -0.76910334f, -0.77119075f, --0.77326989f, -0.77534076f, -0.77740333f, -0.77945757f, -0.78150346f, --0.78354098f, -0.78557011f, -0.78759083f, -0.78960312f, -0.79160694f, --0.79360229f, -0.79558915f, -0.79756748f, -0.79953727f, -0.80149850f, --0.80345114f, -0.80539518f, -0.80733060f, -0.80925737f, -0.81117547f, --0.81308489f, -0.81498559f, -0.81687757f, -0.81876081f, -0.82063527f, --0.82250095f, -0.82435781f, -0.82620585f, -0.82804505f, -0.82987537f, --0.83169681f, -0.83350933f, -0.83531294f, -0.83710760f, -0.83889329f, --0.84067000f, -0.84243770f, -0.84419639f, -0.84594603f, -0.84768662f, --0.84941812f, -0.85114053f, -0.85285383f, -0.85455799f, -0.85625300f, --0.85793884f, -0.85961549f, -0.86128294f, -0.86294116f, -0.86459014f, --0.86622986f, -0.86786031f, -0.86948146f, -0.87109330f, -0.87269581f, --0.87428898f, -0.87587278f, -0.87744720f, -0.87901223f, -0.88056784f, --0.88211402f, -0.88365076f, -0.88517803f, -0.88669582f, -0.88820412f, --0.88970290f, -0.89119216f, -0.89267187f, -0.89414203f, -0.89560260f, --0.89705359f, -0.89849497f, -0.89992673f, -0.90134885f, -0.90276131f, --0.90416411f, -0.90555723f, -0.90694065f, -0.90831436f, -0.90967833f, --0.91103257f, -0.91237705f, -0.91371176f, -0.91503669f, -0.91635181f, --0.91765712f, -0.91895261f, -0.92023825f, -0.92151404f, -0.92277996f, --0.92403600f, -0.92528214f, -0.92651837f, -0.92774468f, -0.92896106f, --0.93016748f, -0.93136395f, -0.93255044f, -0.93372694f, -0.93489345f, --0.93604994f, -0.93719641f, -0.93833284f, -0.93945922f, -0.94057555f, --0.94168180f, -0.94277796f, -0.94386403f, -0.94493999f, -0.94600583f, --0.94706154f, -0.94810711f, -0.94914252f, -0.95016777f, -0.95118284f, --0.95218773f, -0.95318242f, -0.95416690f, -0.95514117f, -0.95610520f, --0.95705900f, -0.95800255f, -0.95893583f, -0.95985885f, -0.96077159f, --0.96167404f, -0.96256619f, -0.96344803f, -0.96431956f, -0.96518076f, --0.96603162f, -0.96687213f, -0.96770230f, -0.96852209f, -0.96933152f, --0.97013057f, -0.97091922f, -0.97169748f, -0.97246533f, -0.97322277f, --0.97396979f, -0.97470637f, -0.97543252f, -0.97614822f, -0.97685347f, --0.97754825f, -0.97823257f, -0.97890641f, -0.97956977f, -0.98022263f, --0.98086500f, -0.98149687f, -0.98211822f, -0.98272906f, -0.98332937f, --0.98391915f, -0.98449840f, -0.98506710f, -0.98562525f, -0.98617285f, --0.98670988f, -0.98723635f, -0.98775225f, -0.98825757f, -0.98875230f, --0.98923645f, -0.98971000f, -0.99017295f, -0.99062530f, -0.99106704f, --0.99149817f, -0.99191868f, -0.99232857f, -0.99272783f, -0.99311645f, --0.99349445f, -0.99386180f, -0.99421851f, -0.99456457f, -0.99489998f, --0.99522474f, -0.99553884f, -0.99584227f, -0.99613505f, -0.99641715f, --0.99668858f, -0.99694934f, -0.99719943f, -0.99743883f, -0.99766756f, --0.99788559f, -0.99809295f, -0.99828961f, -0.99847558f, -0.99865086f, --0.99881544f, -0.99896933f, -0.99911252f, -0.99924501f, -0.99936680f, --0.99947789f, -0.99957827f, -0.99966795f, -0.99974692f, -0.99981519f, --0.99987275f, -0.99991960f, -0.99995574f, -0.99998118f, -0.99999590f, -0.99999967f, 0.99997289f, 0.99990328f, 0.99979084f, 0.99963557f, -0.99943748f, 0.99919658f, 0.99891288f, 0.99858638f, 0.99821711f, -0.99780508f, 0.99735031f, 0.99685281f, 0.99631261f, 0.99572973f, -0.99510420f, 0.99443605f, 0.99372529f, 0.99297196f, 0.99217610f, -0.99133774f, 0.99045692f, 0.98953366f, 0.98856802f, 0.98756003f, -0.98650973f, 0.98541718f, 0.98428242f, 0.98310549f, 0.98188645f, -0.98062534f, 0.97932224f, 0.97797718f, 0.97659022f, 0.97516144f, -0.97369088f, 0.97217861f, 0.97062469f, 0.96902920f, 0.96739220f, -0.96571376f, 0.96399395f, 0.96223284f, 0.96043052f, 0.95858705f, -0.95670253f, 0.95477702f, 0.95281061f, 0.95080338f, 0.94875543f, -0.94666684f, 0.94453769f, 0.94236808f, 0.94015810f, 0.93790786f, -0.93561743f, 0.93328693f, 0.93091644f, 0.92850608f, 0.92605595f, -0.92356614f, 0.92103677f, 0.91846795f, 0.91585979f, 0.91321239f, -0.91052587f, 0.90780035f, 0.90503595f, 0.90223277f, 0.89939095f, -0.89651059f, 0.89359184f, 0.89063481f, 0.88763962f, 0.88460641f, -0.88153531f, 0.87842644f, 0.87527995f, 0.87209596f, 0.86887462f, -0.86561605f, 0.86232041f, 0.85898782f, 0.85561844f, 0.85221241f, -0.84876987f, 0.84529098f, 0.84177587f, 0.83822471f, 0.83463763f, -0.83101481f, 0.82735639f, 0.82366252f, 0.81993338f, 0.81616911f, -0.81236987f, 0.80853584f, 0.80466718f, 0.80076404f, 0.79682660f, -0.79285503f, 0.78884950f, 0.78481017f, 0.78073723f, 0.77663084f, -0.77249118f, 0.76831844f, 0.76411277f, 0.75987438f, 0.75560344f, -0.75130013f, 0.74696464f, 0.74259715f, 0.73819784f, 0.73376692f, -0.72930457f, 0.72481097f, 0.72028632f, 0.71573083f, 0.71114467f, -0.70652804f, 0.70188116f, 0.69720420f, 0.69249738f, 0.68776090f, -0.68299495f, 0.67819975f, 0.67337550f, 0.66852240f, 0.66364066f, -0.65873050f, 0.65379211f, 0.64882573f, 0.64383154f, 0.63880978f, -0.63376065f, 0.62868438f, 0.62358117f, 0.61845126f, 0.61329485f, -0.60811216f, 0.60290343f, 0.59766888f, 0.59240872f, 0.58712318f, -0.58181249f, 0.57647688f, 0.57111658f, 0.56573181f, 0.56032281f, -0.55488980f, 0.54943303f, 0.54395272f, 0.53844911f, 0.53292243f, -0.52737292f, 0.52180083f, 0.51620638f, 0.51058981f, 0.50495138f, -0.49929132f, 0.49360987f, 0.48790727f, 0.48218377f, 0.47643962f, -0.47067506f, 0.46489034f, 0.45908570f, 0.45326139f, 0.44741768f, -0.44155479f, 0.43567299f, 0.42977253f, 0.42385365f, 0.41791662f, -0.41196169f, 0.40598911f, 0.39999914f, 0.39399204f, 0.38796806f, -0.38192746f, 0.37587050f, 0.36979743f, 0.36370853f, 0.35760405f, -0.35148424f, 0.34534939f, 0.33919973f, 0.33303555f, 0.32685710f, -0.32066465f, 0.31445847f, 0.30823881f, 0.30200595f, 0.29576015f, -0.28950169f, 0.28323082f, 0.27694782f, 0.27065295f, 0.26434649f, -0.25802871f, 0.25169988f, 0.24536026f, 0.23901013f, 0.23264977f, -0.22627944f, 0.21989941f, 0.21350997f, 0.20711138f, 0.20070391f, -0.19428785f, 0.18786347f, 0.18143104f, 0.17499084f, 0.16854314f, -0.16208822f, 0.15562636f, 0.14915783f, 0.14268292f, 0.13620189f, -0.12971502f, 0.12322260f, 0.11672491f, 0.11022221f, 0.10371479f, -0.097202924f, 0.090686897f, 0.084166986f, 0.077643468f, 0.071116625f, -0.064586736f, 0.058054080f, 0.051518937f, 0.044981587f, 0.038442310f, -0.031901387f, 0.025359097f, 0.018815721f, 0.012271538f, 0.0057268303f, --0.00081812300f, -0.0073630412f, -0.013907644f, -0.020451651f, -0.026994782f, --0.033536757f, -0.040077295f, -0.046616116f, -0.053152941f, -0.059687488f, --0.066219479f, -0.072748633f, -0.079274670f, -0.085797312f, -0.092316279f, --0.098831291f, -0.10534207f, -0.11184834f, -0.11834981f, -0.12484622f, --0.13133727f, -0.13782270f, -0.14430223f, -0.15077558f, -0.15724246f, --0.16370261f, -0.17015575f, -0.17660160f, -0.18303989f, -0.18947033f, --0.19589266f, -0.20230660f, -0.20871187f, -0.21510820f, -0.22149531f, --0.22787294f, -0.23424080f, -0.24059864f, -0.24694616f, -0.25328311f, --0.25960920f, -0.26592418f, -0.27222777f, -0.27851969f, -0.28479968f, --0.29106748f, -0.29732280f, -0.30356539f, -0.30979497f, -0.31601129f, --0.32221406f, -0.32840304f, -0.33457794f, -0.34073852f, -0.34688450f, --0.35301562f, -0.35913161f, -0.36523223f, -0.37131719f, -0.37738626f, --0.38343915f, -0.38947562f, -0.39549541f, -0.40149825f, -0.40748390f, --0.41345209f, -0.41940257f, -0.42533508f, -0.43124938f, -0.43714520f, --0.44302229f, -0.44888041f, -0.45471930f, -0.46053871f, -0.46633839f, --0.47211810f, -0.47787758f, -0.48361659f, -0.48933489f, -0.49503222f, --0.50070835f, -0.50636303f, -0.51199602f, -0.51760707f, -0.52319595f, --0.52876243f, -0.53430625f, -0.53982718f, -0.54532499f, -0.55079944f, --0.55625029f, -0.56167732f, -0.56708028f, -0.57245896f, -0.57781311f, --0.58314251f, -0.58844693f, -0.59372614f, -0.59897992f, -0.60420805f, --0.60941029f, -0.61458642f, -0.61973623f, -0.62485949f, -0.62995598f, --0.63502549f, -0.64006780f, -0.64508268f, -0.65006994f, -0.65502934f, --0.65996069f, -0.66486377f, -0.66973837f, -0.67458427f, -0.67940128f, --0.68418919f, -0.68894779f, -0.69367688f, -0.69837625f, -0.70304571f, --0.70768504f, -0.71229407f, -0.71687258f, -0.72142039f, -0.72593729f, --0.73042309f, -0.73487761f, -0.73930064f, -0.74369201f, -0.74805152f, --0.75237898f, -0.75667422f, -0.76093704f, -0.76516727f, -0.76936471f, --0.77352921f, -0.77766056f, -0.78175861f, -0.78582316f, -0.78985406f, --0.79385112f, -0.79781417f, -0.80174305f, -0.80563758f, -0.80949760f, --0.81332295f, -0.81711346f, -0.82086896f, -0.82458930f, -0.82827432f, --0.83192386f, -0.83553776f, -0.83911587f, -0.84265803f, -0.84616410f, --0.84963392f, -0.85306735f, -0.85646423f, -0.85982442f, -0.86314779f, --0.86643418f, -0.86968345f, -0.87289547f, -0.87607009f, -0.87920719f, --0.88230663f, -0.88536827f, -0.88839199f, -0.89137765f, -0.89432512f, --0.89723429f, -0.90010502f, -0.90293719f, -0.90573069f, -0.90848539f, --0.91120117f, -0.91387791f, -0.91651551f, -0.91911385f, -0.92167282f, --0.92419231f, -0.92667220f, -0.92911240f, -0.93151280f, -0.93387330f, --0.93619380f, -0.93847419f, -0.94071438f, -0.94291427f, -0.94507377f, --0.94719279f, -0.94927123f, -0.95130901f, -0.95330604f, -0.95526223f, --0.95717750f, -0.95905177f, -0.96088496f, -0.96267699f, -0.96442777f, --0.96613725f, -0.96780534f, -0.96943197f, -0.97101707f, -0.97256058f, --0.97406243f, -0.97552255f, -0.97694089f, -0.97831737f, -0.97965195f, --0.98094456f, -0.98219515f, -0.98340367f, -0.98457006f, -0.98569428f, --0.98677627f, -0.98781599f, -0.98881340f, -0.98976845f, -0.99068110f, --0.99155132f, -0.99237906f, -0.99316428f, -0.99390697f, -0.99460708f, --0.99526458f, -0.99587945f, -0.99645166f, -0.99698119f, -0.99746801f, --0.99791210f, -0.99831344f, -0.99867202f, -0.99898782f, -0.99926082f, --0.99949102f, -0.99967841f, -0.99982297f, -0.99992470f, -0.99998360f, -0.99999866f, 0.99989157f, 0.99961315f, 0.99916346f, 0.99854256f, -0.99775057f, 0.99678762f, 0.99565388f, 0.99434953f, 0.99287481f, -0.99122996f, 0.98941527f, 0.98743105f, 0.98527764f, 0.98295541f, -0.98046475f, 0.97780610f, 0.97497990f, 0.97198664f, 0.96882685f, -0.96550104f, 0.96200980f, 0.95835373f, 0.95453345f, 0.95054962f, -0.94640291f, 0.94209404f, 0.93762375f, 0.93299280f, 0.92820199f, -0.92325213f, 0.91814408f, 0.91287871f, 0.90745693f, 0.90187965f, -0.89614785f, 0.89026249f, 0.88422459f, 0.87803519f, 0.87169533f, -0.86520612f, 0.85856866f, 0.85178409f, 0.84485357f, 0.83777828f, -0.83055945f, 0.82319831f, 0.81569611f, 0.80805415f, 0.80027373f, -0.79235620f, 0.78430289f, 0.77611520f, 0.76779452f, 0.75934229f, -0.75075995f, 0.74204897f, 0.73321084f, 0.72424708f, 0.71515923f, -0.70594883f, 0.69661748f, 0.68716676f, 0.67759830f, 0.66791374f, -0.65811474f, 0.64820297f, 0.63818013f, 0.62804795f, 0.61780815f, -0.60746249f, 0.59701275f, 0.58646072f, 0.57580819f, 0.56505701f, -0.55420900f, 0.54326604f, 0.53222998f, 0.52110274f, 0.50988620f, -0.49858230f, 0.48719297f, 0.47572016f, 0.46416584f, 0.45253199f, -0.44082059f, 0.42903367f, 0.41717323f, 0.40524131f, 0.39323996f, -0.38117123f, 0.36903718f, 0.35683990f, 0.34458148f, 0.33226402f, -0.31988962f, 0.30746042f, 0.29497853f, 0.28244610f, 0.26986527f, -0.25723821f, 0.24456706f, 0.23185402f, 0.21910124f, 0.20631092f, -0.19348526f, 0.18062644f, 0.16773667f, 0.15481816f, 0.14187312f, -0.12890377f, 0.11591234f, 0.10290104f, 0.089872115f, 0.076827789f, -0.063770300f, 0.050701883f, 0.037624779f, 0.024541229f, 0.011453473f, --0.0016362454f, -0.014725683f, -0.027812598f, -0.040894747f, -0.053969889f, --0.067035784f, -0.080090192f, -0.093130877f, -0.10615561f, -0.11916214f, --0.13214826f, -0.14511174f, -0.15805036f, -0.17096189f, -0.18384413f, --0.19669487f, -0.20951190f, -0.22229304f, -0.23503609f, -0.24773886f, --0.26039919f, -0.27301490f, -0.28558383f, -0.29810383f, -0.31057274f, --0.32298845f, -0.33534881f, -0.34765171f, -0.35989504f, -0.37207670f, --0.38419461f, -0.39624670f, -0.40823088f, -0.42014512f, -0.43198737f, --0.44375560f, -0.45544780f, -0.46706195f, -0.47859608f, -0.49004821f, --0.50141636f, -0.51269860f, -0.52389299f, -0.53499762f, -0.54601058f, --0.55692998f, -0.56775395f, -0.57848064f, -0.58910822f, -0.59963485f, --0.61005873f, -0.62037809f, -0.63059115f, -0.64069616f, -0.65069139f, --0.66057513f, -0.67034568f, -0.68000137f, -0.68954054f, -0.69896157f, --0.70826283f, -0.71744274f, -0.72649972f, -0.73543221f, -0.74423869f, --0.75291765f, -0.76146760f, -0.76988708f, -0.77817464f, -0.78632887f, --0.79434836f, -0.80223175f, -0.80997767f, -0.81758481f, -0.82505187f, --0.83237755f, -0.83956061f, -0.84659981f, -0.85349396f, -0.86024186f, --0.86684237f, -0.87329434f, -0.87959669f, -0.88574831f, -0.89174817f, --0.89759523f, -0.90328850f, -0.90882699f, -0.91420976f, -0.91943588f, --0.92450446f, -0.92941463f, -0.93416555f, -0.93875641f, -0.94318642f, --0.94745482f, -0.95156087f, -0.95550388f, -0.95928317f, -0.96289809f, --0.96634802f, -0.96963238f, -0.97275059f, -0.97570213f, -0.97848649f, --0.98110318f, -0.98355177f, -0.98583184f, -0.98794298f, -0.98988485f, --0.99165711f, -0.99325945f, -0.99469160f, -0.99595331f, -0.99704438f, --0.99796460f, -0.99871383f, -0.99929194f, -0.99969882f, -0.99993441f, -0.99999465f, 0.99956631f, 0.99845292f, 0.99665524f, 0.99417450f, -0.99101241f, 0.98717112f, 0.98265328f, 0.97746197f, 0.97160077f, -0.96507367f, 0.95788516f, 0.95004017f, 0.94154407f, 0.93240267f, -0.92262226f, 0.91220953f, 0.90117161f, 0.88951608f, 0.87725091f, -0.86438452f, 0.85092573f, 0.83688375f, 0.82226822f, 0.80708914f, -0.79135693f, 0.77508236f, 0.75827658f, 0.74095113f, 0.72311786f, -0.70478900f, 0.68597711f, 0.66669509f, 0.64695615f, 0.62677382f, -0.60616193f, 0.58513461f, 0.56370626f, 0.54189158f, 0.51970551f, -0.49716327f, 0.47428029f, 0.45107226f, 0.42755509f, 0.40374490f, -0.37965800f, 0.35531090f, 0.33072029f, 0.30590302f, 0.28087610f, -0.25565668f, 0.23026205f, 0.20470960f, 0.17901686f, 0.15320143f, -0.12728100f, 0.10127334f, 0.075196277f, 0.049067674f, 0.022905443f, --0.0032724865f, -0.029448173f, -0.055603678f, -0.081721074f, -0.10778246f, --0.13376998f, -0.15966582f, -0.18545224f, -0.21111155f, -0.23662618f, --0.26197864f, -0.28715155f, -0.31212766f, -0.33688985f, -0.36142116f, --0.38570477f, -0.40972403f, -0.43346249f, -0.45690388f, -0.48003212f, --0.50283138f, -0.52528602f, -0.54738066f, -0.56910015f, -0.59042960f, --0.61135441f, -0.63186022f, -0.65193299f, -0.67155895f, -0.69072467f, --0.70941699f, -0.72762312f, -0.74533057f, -0.76252720f, -0.77920124f, --0.79534126f, -0.81093618f, -0.82597533f, -0.84044840f, -0.85434547f, --0.86765701f, -0.88037390f, -0.89248743f, -0.90398929f, -0.91487161f, --0.92512691f, -0.93474818f, -0.94372882f, -0.95206268f, -0.95974404f, --0.96676764f, -0.97312866f, -0.97882275f, -0.98384601f, -0.98819498f, --0.99186670f, -0.99485864f, -0.99716875f, -0.99879546f, -0.99973764f, + 0.99999992f, 0.99999322f, 0.99997582f, 0.99994771f, 0.99990889f, + 0.99985936f, 0.99979913f, 0.99972818f, 0.99964653f, 0.99955418f, + 0.99945112f, 0.99933736f, 0.99921289f, 0.99907773f, 0.99893186f, + 0.99877530f, 0.99860804f, 0.99843009f, 0.99824144f, 0.99804211f, + 0.99783209f, 0.99761138f, 0.99737998f, 0.99713791f, 0.99688516f, + 0.99662173f, 0.99634763f, 0.99606285f, 0.99576741f, 0.99546131f, + 0.99514455f, 0.99481713f, 0.99447905f, 0.99413033f, 0.99377096f, + 0.99340095f, 0.99302029f, 0.99262901f, 0.99222709f, 0.99181455f, + 0.99139139f, 0.99095760f, 0.99051321f, 0.99005821f, 0.98959261f, + 0.98911641f, 0.98862961f, 0.98813223f, 0.98762427f, 0.98710573f, + 0.98657662f, 0.98603694f, 0.98548670f, 0.98492591f, 0.98435457f, + 0.98377269f, 0.98318028f, 0.98257734f, 0.98196387f, 0.98133989f, + 0.98070539f, 0.98006040f, 0.97940491f, 0.97873893f, 0.97806247f, + 0.97737554f, 0.97667813f, 0.97597027f, 0.97525196f, 0.97452320f, + 0.97378401f, 0.97303439f, 0.97227435f, 0.97150389f, 0.97072303f, + 0.96993178f, 0.96913014f, 0.96831812f, 0.96749573f, 0.96666298f, + 0.96581987f, 0.96496643f, 0.96410265f, 0.96322854f, 0.96234412f, + 0.96144939f, 0.96054437f, 0.95962906f, 0.95870347f, 0.95776762f, + 0.95682151f, 0.95586515f, 0.95489856f, 0.95392174f, 0.95293471f, + 0.95193746f, 0.95093003f, 0.94991241f, 0.94888462f, 0.94784667f, + 0.94679856f, 0.94574032f, 0.94467195f, 0.94359346f, 0.94250486f, + 0.94140618f, 0.94029741f, 0.93917857f, 0.93804967f, 0.93691073f, + 0.93576176f, 0.93460276f, 0.93343375f, 0.93225475f, 0.93106577f, + 0.92986681f, 0.92865789f, 0.92743903f, 0.92621024f, 0.92497153f, + 0.92372291f, 0.92246440f, 0.92119602f, 0.91991776f, 0.91862966f, + 0.91733172f, 0.91602395f, 0.91470637f, 0.91337900f, 0.91204185f, + 0.91069493f, 0.90933825f, 0.90797184f, 0.90659570f, 0.90520986f, + 0.90381432f, 0.90240910f, 0.90099422f, 0.89956969f, 0.89813553f, + 0.89669174f, 0.89523836f, 0.89377538f, 0.89230284f, 0.89082074f, + 0.88932910f, 0.88782793f, 0.88631726f, 0.88479710f, 0.88326746f, + 0.88172836f, 0.88017982f, 0.87862185f, 0.87705448f, 0.87547771f, + 0.87389156f, 0.87229606f, 0.87069121f, 0.86907704f, 0.86745357f, + 0.86582080f, 0.86417876f, 0.86252747f, 0.86086694f, 0.85919719f, + 0.85751824f, 0.85583010f, 0.85413281f, 0.85242636f, 0.85071078f, + 0.84898610f, 0.84725232f, 0.84550947f, 0.84375756f, 0.84199662f, + 0.84022666f, 0.83844771f, 0.83665977f, 0.83486287f, 0.83305704f, + 0.83124228f, 0.82941862f, 0.82758608f, 0.82574467f, 0.82389442f, + 0.82203535f, 0.82016748f, 0.81829082f, 0.81640540f, 0.81451123f, + 0.81260835f, 0.81069676f, 0.80877649f, 0.80684755f, 0.80490998f, + 0.80296379f, 0.80100899f, 0.79904562f, 0.79707370f, 0.79509323f, + 0.79310425f, 0.79110678f, 0.78910084f, 0.78708644f, 0.78506362f, + 0.78303239f, 0.78099277f, 0.77894479f, 0.77688847f, 0.77482382f, + 0.77275088f, 0.77066967f, 0.76858020f, 0.76648250f, 0.76437659f, + 0.76226250f, 0.76014024f, 0.75800984f, 0.75587132f, 0.75372471f, + 0.75157003f, 0.74940730f, 0.74723654f, 0.74505779f, 0.74287105f, + 0.74067635f, 0.73847373f, 0.73626320f, 0.73404478f, 0.73181850f, + 0.72958438f, 0.72734245f, 0.72509273f, 0.72283525f, 0.72057002f, + 0.71829708f, 0.71601644f, 0.71372814f, 0.71143220f, 0.70912863f, + 0.70681747f, 0.70449874f, 0.70217247f, 0.69983868f, 0.69749739f, + 0.69514863f, 0.69279243f, 0.69042881f, 0.68805780f, 0.68567941f, + 0.68329369f, 0.68090064f, 0.67850031f, 0.67609270f, 0.67367786f, + 0.67125580f, 0.66882656f, 0.66639015f, 0.66394661f, 0.66149595f, + 0.65903821f, 0.65657341f, 0.65410159f, 0.65162275f, 0.64913694f, + 0.64664418f, 0.64414449f, 0.64163790f, 0.63912444f, 0.63660414f, + 0.63407702f, 0.63154311f, 0.62900244f, 0.62645503f, 0.62390091f, + 0.62134011f, 0.61877265f, 0.61619857f, 0.61361789f, 0.61103064f, + 0.60843685f, 0.60583654f, 0.60322974f, 0.60061648f, 0.59799679f, + 0.59537069f, 0.59273822f, 0.59009940f, 0.58745427f, 0.58480284f, + 0.58214514f, 0.57948122f, 0.57681109f, 0.57413478f, 0.57145232f, + 0.56876374f, 0.56606907f, 0.56336834f, 0.56066158f, 0.55794881f, + 0.55523006f, 0.55250537f, 0.54977477f, 0.54703827f, 0.54429592f, + 0.54154774f, 0.53879376f, 0.53603401f, 0.53326852f, 0.53049731f, + 0.52772043f, 0.52493790f, 0.52214974f, 0.51935599f, 0.51655668f, + 0.51375184f, 0.51094149f, 0.50812568f, 0.50530442f, 0.50247775f, + 0.49964570f, 0.49680830f, 0.49396558f, 0.49111757f, 0.48826430f, + 0.48540580f, 0.48254210f, 0.47967323f, 0.47679923f, 0.47392012f, + 0.47103594f, 0.46814671f, 0.46525247f, 0.46235324f, 0.45944907f, + 0.45653997f, 0.45362599f, 0.45070714f, 0.44778347f, 0.44485501f, + 0.44192178f, 0.43898381f, 0.43604115f, 0.43309382f, 0.43014185f, + 0.42718527f, 0.42422412f, 0.42125842f, 0.41828822f, 0.41531353f, + 0.41233440f, 0.40935085f, 0.40636291f, 0.40337063f, 0.40037402f, + 0.39737313f, 0.39436798f, 0.39135861f, 0.38834505f, 0.38532733f, + 0.38230548f, 0.37927953f, 0.37624953f, 0.37321550f, 0.37017747f, + 0.36713547f, 0.36408955f, 0.36103972f, 0.35798603f, 0.35492850f, + 0.35186718f, 0.34880208f, 0.34573325f, 0.34266072f, 0.33958451f, + 0.33650468f, 0.33342123f, 0.33033422f, 0.32724367f, 0.32414961f, + 0.32105209f, 0.31795112f, 0.31484675f, 0.31173901f, 0.30862793f, + 0.30551354f, 0.30239588f, 0.29927499f, 0.29615089f, 0.29302362f, + 0.28989321f, 0.28675969f, 0.28362310f, 0.28048348f, 0.27734085f, + 0.27419526f, 0.27104672f, 0.26789529f, 0.26474098f, 0.26158384f, + 0.25842390f, 0.25526119f, 0.25209575f, 0.24892761f, 0.24575680f, + 0.24258336f, 0.23940732f, 0.23622872f, 0.23304759f, 0.22986396f, + 0.22667787f, 0.22348935f, 0.22029844f, 0.21710517f, 0.21390958f, + 0.21071169f, 0.20751155f, 0.20430919f, 0.20110463f, 0.19789793f, + 0.19468910f, 0.19147819f, 0.18826523f, 0.18505026f, 0.18183330f, + 0.17861439f, 0.17539357f, 0.17217088f, 0.16894634f, 0.16571999f, + 0.16249186f, 0.15926200f, 0.15603043f, 0.15279719f, 0.14956231f, + 0.14632583f, 0.14308778f, 0.13984820f, 0.13660713f, 0.13336459f, + 0.13012062f, 0.12687526f, 0.12362854f, 0.12038049f, 0.11713116f, + 0.11388057f, 0.11062877f, 0.10737578f, 0.10412163f, 0.10086638f, + 0.097610040f, 0.094352658f, 0.091094266f, 0.087834897f, 0.084574589f, + 0.081313374f, 0.078051289f, 0.074788367f, 0.071524645f, 0.068260157f, + 0.064994938f, 0.061729023f, 0.058462447f, 0.055195244f, 0.051927451f, + 0.048659101f, 0.045390231f, 0.042120874f, 0.038851066f, 0.035580842f, + 0.032310238f, 0.029039287f, 0.025768025f, 0.022496487f, 0.019224708f, + 0.015952723f, 0.012680568f, 0.0094082767f, 0.0061358846f, 0.0028634269f, + -0.00040906153f, -0.0036815456f, -0.0069539902f, -0.010226360f, -0.013498621f, + -0.016770737f, -0.020042673f, -0.023314395f, -0.026585867f, -0.029857055f, + -0.033127923f, -0.036398436f, -0.039668559f, -0.042938257f, -0.046207495f, + -0.049476239f, -0.052744453f, -0.056012102f, -0.059279151f, -0.062545565f, + -0.065811309f, -0.069076349f, -0.072340649f, -0.075604174f, -0.078866890f, + -0.082128761f, -0.085389752f, -0.088649829f, -0.091908956f, -0.095167100f, + -0.098424224f, -0.10168029f, -0.10493528f, -0.10818913f, -0.11144183f, + -0.11469334f, -0.11794361f, -0.12119263f, -0.12444034f, -0.12768673f, + -0.13093174f, -0.13417536f, -0.13741753f, -0.14065824f, -0.14389744f, + -0.14713510f, -0.15037118f, -0.15360565f, -0.15683848f, -0.16006962f, + -0.16329906f, -0.16652674f, -0.16975264f, -0.17297673f, -0.17619896f, + -0.17941930f, -0.18263772f, -0.18585419f, -0.18906866f, -0.19228112f, + -0.19549151f, -0.19869981f, -0.20190598f, -0.20510998f, -0.20831180f, + -0.21151138f, -0.21470869f, -0.21790371f, -0.22109639f, -0.22428671f, + -0.22747462f, -0.23066010f, -0.23384310f, -0.23702361f, -0.24020157f, + -0.24337696f, -0.24654975f, -0.24971989f, -0.25288736f, -0.25605213f, + -0.25921415f, -0.26237339f, -0.26552983f, -0.26868342f, -0.27183413f, + -0.27498193f, -0.27812679f, -0.28126867f, -0.28440754f, -0.28754336f, + -0.29067610f, -0.29380573f, -0.29693221f, -0.30005551f, -0.30317560f, + -0.30629245f, -0.30940601f, -0.31251626f, -0.31562316f, -0.31872668f, + -0.32182679f, -0.32492345f, -0.32801664f, -0.33110631f, -0.33419243f, + -0.33727497f, -0.34035391f, -0.34342920f, -0.34650081f, -0.34956871f, + -0.35263286f, -0.35569324f, -0.35874981f, -0.36180254f, -0.36485139f, + -0.36789634f, -0.37093735f, -0.37397438f, -0.37700741f, -0.38003640f, + -0.38306132f, -0.38608214f, -0.38909883f, -0.39211135f, -0.39511967f, + -0.39812375f, -0.40112358f, -0.40411910f, -0.40711031f, -0.41009715f, + -0.41307959f, -0.41605762f, -0.41903119f, -0.42200027f, -0.42496483f, + -0.42792484f, -0.43088027f, -0.43383109f, -0.43677726f, -0.43971875f, + -0.44265553f, -0.44558757f, -0.44851484f, -0.45143731f, -0.45435494f, + -0.45726770f, -0.46017557f, -0.46307851f, -0.46597650f, -0.46886949f, + -0.47175746f, -0.47464038f, -0.47751821f, -0.48039093f, -0.48325851f, + -0.48612091f, -0.48897811f, -0.49183006f, -0.49467676f, -0.49751815f, + -0.50035422f, -0.50318492f, -0.50601024f, -0.50883014f, -0.51164459f, + -0.51445356f, -0.51725703f, -0.52005495f, -0.52284730f, -0.52563406f, + -0.52841518f, -0.53119065f, -0.53396043f, -0.53672449f, -0.53948280f, + -0.54223533f, -0.54498206f, -0.54772295f, -0.55045797f, -0.55318710f, + -0.55591031f, -0.55862756f, -0.56133883f, -0.56404409f, -0.56674331f, + -0.56943646f, -0.57212351f, -0.57480443f, -0.57747920f, -0.58014778f, + -0.58281015f, -0.58546628f, -0.58811614f, -0.59075970f, -0.59339694f, + -0.59602782f, -0.59865231f, -0.60127040f, -0.60388204f, -0.60648722f, + -0.60908591f, -0.61167807f, -0.61426368f, -0.61684271f, -0.61941514f, + -0.62198093f, -0.62454007f, -0.62709251f, -0.62963824f, -0.63217722f, + -0.63470944f, -0.63723486f, -0.63975345f, -0.64226519f, -0.64477006f, + -0.64726802f, -0.64975905f, -0.65224312f, -0.65472020f, -0.65719027f, + -0.65965331f, -0.66210928f, -0.66455816f, -0.66699992f, -0.66943454f, + -0.67186199f, -0.67428225f, -0.67669528f, -0.67910107f, -0.68149959f, + -0.68389080f, -0.68627470f, -0.68865124f, -0.69102041f, -0.69338218f, + -0.69573652f, -0.69808341f, -0.70042283f, -0.70275474f, -0.70507913f, + -0.70739597f, -0.70970524f, -0.71200690f, -0.71430093f, -0.71658732f, + -0.71886604f, -0.72113705f, -0.72340034f, -0.72565589f, -0.72790366f, + -0.73014364f, -0.73237580f, -0.73460012f, -0.73681657f, -0.73902513f, + -0.74122577f, -0.74341848f, -0.74560322f, -0.74777998f, -0.74994874f, + -0.75210946f, -0.75426212f, -0.75640671f, -0.75854320f, -0.76067157f, + -0.76279178f, -0.76490383f, -0.76700769f, -0.76910334f, -0.77119075f, + -0.77326989f, -0.77534076f, -0.77740333f, -0.77945757f, -0.78150346f, + -0.78354098f, -0.78557011f, -0.78759083f, -0.78960312f, -0.79160694f, + -0.79360229f, -0.79558915f, -0.79756748f, -0.79953727f, -0.80149850f, + -0.80345114f, -0.80539518f, -0.80733060f, -0.80925737f, -0.81117547f, + -0.81308489f, -0.81498559f, -0.81687757f, -0.81876081f, -0.82063527f, + -0.82250095f, -0.82435781f, -0.82620585f, -0.82804505f, -0.82987537f, + -0.83169681f, -0.83350933f, -0.83531294f, -0.83710760f, -0.83889329f, + -0.84067000f, -0.84243770f, -0.84419639f, -0.84594603f, -0.84768662f, + -0.84941812f, -0.85114053f, -0.85285383f, -0.85455799f, -0.85625300f, + -0.85793884f, -0.85961549f, -0.86128294f, -0.86294116f, -0.86459014f, + -0.86622986f, -0.86786031f, -0.86948146f, -0.87109330f, -0.87269581f, + -0.87428898f, -0.87587278f, -0.87744720f, -0.87901223f, -0.88056784f, + -0.88211402f, -0.88365076f, -0.88517803f, -0.88669582f, -0.88820412f, + -0.88970290f, -0.89119216f, -0.89267187f, -0.89414203f, -0.89560260f, + -0.89705359f, -0.89849497f, -0.89992673f, -0.90134885f, -0.90276131f, + -0.90416411f, -0.90555723f, -0.90694065f, -0.90831436f, -0.90967833f, + -0.91103257f, -0.91237705f, -0.91371176f, -0.91503669f, -0.91635181f, + -0.91765712f, -0.91895261f, -0.92023825f, -0.92151404f, -0.92277996f, + -0.92403600f, -0.92528214f, -0.92651837f, -0.92774468f, -0.92896106f, + -0.93016748f, -0.93136395f, -0.93255044f, -0.93372694f, -0.93489345f, + -0.93604994f, -0.93719641f, -0.93833284f, -0.93945922f, -0.94057555f, + -0.94168180f, -0.94277796f, -0.94386403f, -0.94493999f, -0.94600583f, + -0.94706154f, -0.94810711f, -0.94914252f, -0.95016777f, -0.95118284f, + -0.95218773f, -0.95318242f, -0.95416690f, -0.95514117f, -0.95610520f, + -0.95705900f, -0.95800255f, -0.95893583f, -0.95985885f, -0.96077159f, + -0.96167404f, -0.96256619f, -0.96344803f, -0.96431956f, -0.96518076f, + -0.96603162f, -0.96687213f, -0.96770230f, -0.96852209f, -0.96933152f, + -0.97013057f, -0.97091922f, -0.97169748f, -0.97246533f, -0.97322277f, + -0.97396979f, -0.97470637f, -0.97543252f, -0.97614822f, -0.97685347f, + -0.97754825f, -0.97823257f, -0.97890641f, -0.97956977f, -0.98022263f, + -0.98086500f, -0.98149687f, -0.98211822f, -0.98272906f, -0.98332937f, + -0.98391915f, -0.98449840f, -0.98506710f, -0.98562525f, -0.98617285f, + -0.98670988f, -0.98723635f, -0.98775225f, -0.98825757f, -0.98875230f, + -0.98923645f, -0.98971000f, -0.99017295f, -0.99062530f, -0.99106704f, + -0.99149817f, -0.99191868f, -0.99232857f, -0.99272783f, -0.99311645f, + -0.99349445f, -0.99386180f, -0.99421851f, -0.99456457f, -0.99489998f, + -0.99522474f, -0.99553884f, -0.99584227f, -0.99613505f, -0.99641715f, + -0.99668858f, -0.99694934f, -0.99719943f, -0.99743883f, -0.99766756f, + -0.99788559f, -0.99809295f, -0.99828961f, -0.99847558f, -0.99865086f, + -0.99881544f, -0.99896933f, -0.99911252f, -0.99924501f, -0.99936680f, + -0.99947789f, -0.99957827f, -0.99966795f, -0.99974692f, -0.99981519f, + -0.99987275f, -0.99991960f, -0.99995574f, -0.99998118f, -0.99999590f, + 0.99999967f, 0.99997289f, 0.99990328f, 0.99979084f, 0.99963557f, + 0.99943748f, 0.99919658f, 0.99891288f, 0.99858638f, 0.99821711f, + 0.99780508f, 0.99735031f, 0.99685281f, 0.99631261f, 0.99572973f, + 0.99510420f, 0.99443605f, 0.99372529f, 0.99297196f, 0.99217610f, + 0.99133774f, 0.99045692f, 0.98953366f, 0.98856802f, 0.98756003f, + 0.98650973f, 0.98541718f, 0.98428242f, 0.98310549f, 0.98188645f, + 0.98062534f, 0.97932224f, 0.97797718f, 0.97659022f, 0.97516144f, + 0.97369088f, 0.97217861f, 0.97062469f, 0.96902920f, 0.96739220f, + 0.96571376f, 0.96399395f, 0.96223284f, 0.96043052f, 0.95858705f, + 0.95670253f, 0.95477702f, 0.95281061f, 0.95080338f, 0.94875543f, + 0.94666684f, 0.94453769f, 0.94236808f, 0.94015810f, 0.93790786f, + 0.93561743f, 0.93328693f, 0.93091644f, 0.92850608f, 0.92605595f, + 0.92356614f, 0.92103677f, 0.91846795f, 0.91585979f, 0.91321239f, + 0.91052587f, 0.90780035f, 0.90503595f, 0.90223277f, 0.89939095f, + 0.89651059f, 0.89359184f, 0.89063481f, 0.88763962f, 0.88460641f, + 0.88153531f, 0.87842644f, 0.87527995f, 0.87209596f, 0.86887462f, + 0.86561605f, 0.86232041f, 0.85898782f, 0.85561844f, 0.85221241f, + 0.84876987f, 0.84529098f, 0.84177587f, 0.83822471f, 0.83463763f, + 0.83101481f, 0.82735639f, 0.82366252f, 0.81993338f, 0.81616911f, + 0.81236987f, 0.80853584f, 0.80466718f, 0.80076404f, 0.79682660f, + 0.79285503f, 0.78884950f, 0.78481017f, 0.78073723f, 0.77663084f, + 0.77249118f, 0.76831844f, 0.76411277f, 0.75987438f, 0.75560344f, + 0.75130013f, 0.74696464f, 0.74259715f, 0.73819784f, 0.73376692f, + 0.72930457f, 0.72481097f, 0.72028632f, 0.71573083f, 0.71114467f, + 0.70652804f, 0.70188116f, 0.69720420f, 0.69249738f, 0.68776090f, + 0.68299495f, 0.67819975f, 0.67337550f, 0.66852240f, 0.66364066f, + 0.65873050f, 0.65379211f, 0.64882573f, 0.64383154f, 0.63880978f, + 0.63376065f, 0.62868438f, 0.62358117f, 0.61845126f, 0.61329485f, + 0.60811216f, 0.60290343f, 0.59766888f, 0.59240872f, 0.58712318f, + 0.58181249f, 0.57647688f, 0.57111658f, 0.56573181f, 0.56032281f, + 0.55488980f, 0.54943303f, 0.54395272f, 0.53844911f, 0.53292243f, + 0.52737292f, 0.52180083f, 0.51620638f, 0.51058981f, 0.50495138f, + 0.49929132f, 0.49360987f, 0.48790727f, 0.48218377f, 0.47643962f, + 0.47067506f, 0.46489034f, 0.45908570f, 0.45326139f, 0.44741768f, + 0.44155479f, 0.43567299f, 0.42977253f, 0.42385365f, 0.41791662f, + 0.41196169f, 0.40598911f, 0.39999914f, 0.39399204f, 0.38796806f, + 0.38192746f, 0.37587050f, 0.36979743f, 0.36370853f, 0.35760405f, + 0.35148424f, 0.34534939f, 0.33919973f, 0.33303555f, 0.32685710f, + 0.32066465f, 0.31445847f, 0.30823881f, 0.30200595f, 0.29576015f, + 0.28950169f, 0.28323082f, 0.27694782f, 0.27065295f, 0.26434649f, + 0.25802871f, 0.25169988f, 0.24536026f, 0.23901013f, 0.23264977f, + 0.22627944f, 0.21989941f, 0.21350997f, 0.20711138f, 0.20070391f, + 0.19428785f, 0.18786347f, 0.18143104f, 0.17499084f, 0.16854314f, + 0.16208822f, 0.15562636f, 0.14915783f, 0.14268292f, 0.13620189f, + 0.12971502f, 0.12322260f, 0.11672491f, 0.11022221f, 0.10371479f, + 0.097202924f, 0.090686897f, 0.084166986f, 0.077643468f, 0.071116625f, + 0.064586736f, 0.058054080f, 0.051518937f, 0.044981587f, 0.038442310f, + 0.031901387f, 0.025359097f, 0.018815721f, 0.012271538f, 0.0057268303f, + -0.00081812300f, -0.0073630412f, -0.013907644f, -0.020451651f, -0.026994782f, + -0.033536757f, -0.040077295f, -0.046616116f, -0.053152941f, -0.059687488f, + -0.066219479f, -0.072748633f, -0.079274670f, -0.085797312f, -0.092316279f, + -0.098831291f, -0.10534207f, -0.11184834f, -0.11834981f, -0.12484622f, + -0.13133727f, -0.13782270f, -0.14430223f, -0.15077558f, -0.15724246f, + -0.16370261f, -0.17015575f, -0.17660160f, -0.18303989f, -0.18947033f, + -0.19589266f, -0.20230660f, -0.20871187f, -0.21510820f, -0.22149531f, + -0.22787294f, -0.23424080f, -0.24059864f, -0.24694616f, -0.25328311f, + -0.25960920f, -0.26592418f, -0.27222777f, -0.27851969f, -0.28479968f, + -0.29106748f, -0.29732280f, -0.30356539f, -0.30979497f, -0.31601129f, + -0.32221406f, -0.32840304f, -0.33457794f, -0.34073852f, -0.34688450f, + -0.35301562f, -0.35913161f, -0.36523223f, -0.37131719f, -0.37738626f, + -0.38343915f, -0.38947562f, -0.39549541f, -0.40149825f, -0.40748390f, + -0.41345209f, -0.41940257f, -0.42533508f, -0.43124938f, -0.43714520f, + -0.44302229f, -0.44888041f, -0.45471930f, -0.46053871f, -0.46633839f, + -0.47211810f, -0.47787758f, -0.48361659f, -0.48933489f, -0.49503222f, + -0.50070835f, -0.50636303f, -0.51199602f, -0.51760707f, -0.52319595f, + -0.52876243f, -0.53430625f, -0.53982718f, -0.54532499f, -0.55079944f, + -0.55625029f, -0.56167732f, -0.56708028f, -0.57245896f, -0.57781311f, + -0.58314251f, -0.58844693f, -0.59372614f, -0.59897992f, -0.60420805f, + -0.60941029f, -0.61458642f, -0.61973623f, -0.62485949f, -0.62995598f, + -0.63502549f, -0.64006780f, -0.64508268f, -0.65006994f, -0.65502934f, + -0.65996069f, -0.66486377f, -0.66973837f, -0.67458427f, -0.67940128f, + -0.68418919f, -0.68894779f, -0.69367688f, -0.69837625f, -0.70304571f, + -0.70768504f, -0.71229407f, -0.71687258f, -0.72142039f, -0.72593729f, + -0.73042309f, -0.73487761f, -0.73930064f, -0.74369201f, -0.74805152f, + -0.75237898f, -0.75667422f, -0.76093704f, -0.76516727f, -0.76936471f, + -0.77352921f, -0.77766056f, -0.78175861f, -0.78582316f, -0.78985406f, + -0.79385112f, -0.79781417f, -0.80174305f, -0.80563758f, -0.80949760f, + -0.81332295f, -0.81711346f, -0.82086896f, -0.82458930f, -0.82827432f, + -0.83192386f, -0.83553776f, -0.83911587f, -0.84265803f, -0.84616410f, + -0.84963392f, -0.85306735f, -0.85646423f, -0.85982442f, -0.86314779f, + -0.86643418f, -0.86968345f, -0.87289547f, -0.87607009f, -0.87920719f, + -0.88230663f, -0.88536827f, -0.88839199f, -0.89137765f, -0.89432512f, + -0.89723429f, -0.90010502f, -0.90293719f, -0.90573069f, -0.90848539f, + -0.91120117f, -0.91387791f, -0.91651551f, -0.91911385f, -0.92167282f, + -0.92419231f, -0.92667220f, -0.92911240f, -0.93151280f, -0.93387330f, + -0.93619380f, -0.93847419f, -0.94071438f, -0.94291427f, -0.94507377f, + -0.94719279f, -0.94927123f, -0.95130901f, -0.95330604f, -0.95526223f, + -0.95717750f, -0.95905177f, -0.96088496f, -0.96267699f, -0.96442777f, + -0.96613725f, -0.96780534f, -0.96943197f, -0.97101707f, -0.97256058f, + -0.97406243f, -0.97552255f, -0.97694089f, -0.97831737f, -0.97965195f, + -0.98094456f, -0.98219515f, -0.98340367f, -0.98457006f, -0.98569428f, + -0.98677627f, -0.98781599f, -0.98881340f, -0.98976845f, -0.99068110f, + -0.99155132f, -0.99237906f, -0.99316428f, -0.99390697f, -0.99460708f, + -0.99526458f, -0.99587945f, -0.99645166f, -0.99698119f, -0.99746801f, + -0.99791210f, -0.99831344f, -0.99867202f, -0.99898782f, -0.99926082f, + -0.99949102f, -0.99967841f, -0.99982297f, -0.99992470f, -0.99998360f, + 0.99999866f, 0.99989157f, 0.99961315f, 0.99916346f, 0.99854256f, + 0.99775057f, 0.99678762f, 0.99565388f, 0.99434953f, 0.99287481f, + 0.99122996f, 0.98941527f, 0.98743105f, 0.98527764f, 0.98295541f, + 0.98046475f, 0.97780610f, 0.97497990f, 0.97198664f, 0.96882685f, + 0.96550104f, 0.96200980f, 0.95835373f, 0.95453345f, 0.95054962f, + 0.94640291f, 0.94209404f, 0.93762375f, 0.93299280f, 0.92820199f, + 0.92325213f, 0.91814408f, 0.91287871f, 0.90745693f, 0.90187965f, + 0.89614785f, 0.89026249f, 0.88422459f, 0.87803519f, 0.87169533f, + 0.86520612f, 0.85856866f, 0.85178409f, 0.84485357f, 0.83777828f, + 0.83055945f, 0.82319831f, 0.81569611f, 0.80805415f, 0.80027373f, + 0.79235620f, 0.78430289f, 0.77611520f, 0.76779452f, 0.75934229f, + 0.75075995f, 0.74204897f, 0.73321084f, 0.72424708f, 0.71515923f, + 0.70594883f, 0.69661748f, 0.68716676f, 0.67759830f, 0.66791374f, + 0.65811474f, 0.64820297f, 0.63818013f, 0.62804795f, 0.61780815f, + 0.60746249f, 0.59701275f, 0.58646072f, 0.57580819f, 0.56505701f, + 0.55420900f, 0.54326604f, 0.53222998f, 0.52110274f, 0.50988620f, + 0.49858230f, 0.48719297f, 0.47572016f, 0.46416584f, 0.45253199f, + 0.44082059f, 0.42903367f, 0.41717323f, 0.40524131f, 0.39323996f, + 0.38117123f, 0.36903718f, 0.35683990f, 0.34458148f, 0.33226402f, + 0.31988962f, 0.30746042f, 0.29497853f, 0.28244610f, 0.26986527f, + 0.25723821f, 0.24456706f, 0.23185402f, 0.21910124f, 0.20631092f, + 0.19348526f, 0.18062644f, 0.16773667f, 0.15481816f, 0.14187312f, + 0.12890377f, 0.11591234f, 0.10290104f, 0.089872115f, 0.076827789f, + 0.063770300f, 0.050701883f, 0.037624779f, 0.024541229f, 0.011453473f, + -0.0016362454f, -0.014725683f, -0.027812598f, -0.040894747f, -0.053969889f, + -0.067035784f, -0.080090192f, -0.093130877f, -0.10615561f, -0.11916214f, + -0.13214826f, -0.14511174f, -0.15805036f, -0.17096189f, -0.18384413f, + -0.19669487f, -0.20951190f, -0.22229304f, -0.23503609f, -0.24773886f, + -0.26039919f, -0.27301490f, -0.28558383f, -0.29810383f, -0.31057274f, + -0.32298845f, -0.33534881f, -0.34765171f, -0.35989504f, -0.37207670f, + -0.38419461f, -0.39624670f, -0.40823088f, -0.42014512f, -0.43198737f, + -0.44375560f, -0.45544780f, -0.46706195f, -0.47859608f, -0.49004821f, + -0.50141636f, -0.51269860f, -0.52389299f, -0.53499762f, -0.54601058f, + -0.55692998f, -0.56775395f, -0.57848064f, -0.58910822f, -0.59963485f, + -0.61005873f, -0.62037809f, -0.63059115f, -0.64069616f, -0.65069139f, + -0.66057513f, -0.67034568f, -0.68000137f, -0.68954054f, -0.69896157f, + -0.70826283f, -0.71744274f, -0.72649972f, -0.73543221f, -0.74423869f, + -0.75291765f, -0.76146760f, -0.76988708f, -0.77817464f, -0.78632887f, + -0.79434836f, -0.80223175f, -0.80997767f, -0.81758481f, -0.82505187f, + -0.83237755f, -0.83956061f, -0.84659981f, -0.85349396f, -0.86024186f, + -0.86684237f, -0.87329434f, -0.87959669f, -0.88574831f, -0.89174817f, + -0.89759523f, -0.90328850f, -0.90882699f, -0.91420976f, -0.91943588f, + -0.92450446f, -0.92941463f, -0.93416555f, -0.93875641f, -0.94318642f, + -0.94745482f, -0.95156087f, -0.95550388f, -0.95928317f, -0.96289809f, + -0.96634802f, -0.96963238f, -0.97275059f, -0.97570213f, -0.97848649f, + -0.98110318f, -0.98355177f, -0.98583184f, -0.98794298f, -0.98988485f, + -0.99165711f, -0.99325945f, -0.99469160f, -0.99595331f, -0.99704438f, + -0.99796460f, -0.99871383f, -0.99929194f, -0.99969882f, -0.99993441f, + 0.99999465f, 0.99956631f, 0.99845292f, 0.99665524f, 0.99417450f, + 0.99101241f, 0.98717112f, 0.98265328f, 0.97746197f, 0.97160077f, + 0.96507367f, 0.95788516f, 0.95004017f, 0.94154407f, 0.93240267f, + 0.92262226f, 0.91220953f, 0.90117161f, 0.88951608f, 0.87725091f, + 0.86438452f, 0.85092573f, 0.83688375f, 0.82226822f, 0.80708914f, + 0.79135693f, 0.77508236f, 0.75827658f, 0.74095113f, 0.72311786f, + 0.70478900f, 0.68597711f, 0.66669509f, 0.64695615f, 0.62677382f, + 0.60616193f, 0.58513461f, 0.56370626f, 0.54189158f, 0.51970551f, + 0.49716327f, 0.47428029f, 0.45107226f, 0.42755509f, 0.40374490f, + 0.37965800f, 0.35531090f, 0.33072029f, 0.30590302f, 0.28087610f, + 0.25565668f, 0.23026205f, 0.20470960f, 0.17901686f, 0.15320143f, + 0.12728100f, 0.10127334f, 0.075196277f, 0.049067674f, 0.022905443f, + -0.0032724865f, -0.029448173f, -0.055603678f, -0.081721074f, -0.10778246f, + -0.13376998f, -0.15966582f, -0.18545224f, -0.21111155f, -0.23662618f, + -0.26197864f, -0.28715155f, -0.31212766f, -0.33688985f, -0.36142116f, + -0.38570477f, -0.40972403f, -0.43346249f, -0.45690388f, -0.48003212f, + -0.50283138f, -0.52528602f, -0.54738066f, -0.56910015f, -0.59042960f, + -0.61135441f, -0.63186022f, -0.65193299f, -0.67155895f, -0.69072467f, + -0.70941699f, -0.72762312f, -0.74533057f, -0.76252720f, -0.77920124f, + -0.79534126f, -0.81093618f, -0.82597533f, -0.84044840f, -0.85434547f, + -0.86765701f, -0.88037390f, -0.89248743f, -0.90398929f, -0.91487161f, + -0.92512691f, -0.93474818f, -0.94372882f, -0.95206268f, -0.95974404f, + -0.96676764f, -0.97312866f, -0.97882275f, -0.98384601f, -0.98819498f, + -0.99186670f, -0.99485864f, -0.99716875f, -0.99879546f, -0.99973764f, }; #endif static const CELTMode mode48000_960_120 = { -48000, /* Fs */ -120, /* overlap */ -21, /* nbEBands */ -21, /* effEBands */ -{0.85000610f, 0.0000000f, 1.0000000f, 1.0000000f, }, /* preemph */ -eband5ms, /* eBands */ -3, /* maxLM */ -8, /* nbShortMdcts */ -120, /* shortMdctSize */ -11, /* nbAllocVectors */ -band_allocation, /* allocVectors */ -logN400, /* logN */ -window120, /* window */ -{1920, 3, {&fft_state48000_960_0, &fft_state48000_960_1, &fft_state48000_960_2, &fft_state48000_960_3, }, mdct_twiddles960}, /* mdct */ -{392, cache_index50, cache_bits50, cache_caps50}, /* cache */ -#ifdef ENABLE_QEXT -{86, qext_cache_index50, qext_cache_bits50, qext_cache_caps50}, /* qext_cache */ -#endif + 48000, /* Fs */ + 120, /* overlap */ + 21, /* nbEBands */ + 21, /* effEBands */ + {0.85000610f, 0.0000000f, 1.0000000f, 1.0000000f, }, /* preemph */ + eband5ms, /* eBands */ + 3, /* maxLM */ + 8, /* nbShortMdcts */ + 120, /* shortMdctSize */ + 11, /* nbAllocVectors */ + band_allocation, /* allocVectors */ + logN400, /* logN */ + window120, /* window */ + {1920, 3, {&fft_state48000_960_0, &fft_state48000_960_1, &fft_state48000_960_2, &fft_state48000_960_3, }, + mdct_twiddles960}, /* mdct */ + {392, cache_index50, cache_bits50, cache_caps50}, /* cache */ }; #ifdef ENABLE_QEXT -#ifndef DEF_WINDOW240 -#define DEF_WINDOW240 +# ifndef DEF_WINDOW240 +# define DEF_WINDOW240 static const celt_coef window240[240] = { -1.6821922e-05f, 0.00015139297f, 0.00042051200f, 0.00082413284f, 0.0013621862f, -0.0020345793f, 0.0028411964f, 0.0037818978f, 0.0048565203f, 0.0060648765f, -0.0074067550f, 0.0088819198f, 0.010490110f, 0.012231040f, 0.014104398f, -0.016109846f, 0.018247021f, 0.020515533f, 0.022914963f, 0.025444867f, -0.028104770f, 0.030894170f, 0.033812535f, 0.036859304f, 0.040033885f, -0.043335654f, 0.046763958f, 0.050318110f, 0.053997389f, 0.057801044f, -0.061728287f, 0.065778297f, 0.069950217f, 0.074243155f, 0.078656182f, -0.083188331f, 0.087838600f, 0.092605946f, 0.097489289f, 0.10248751f, -0.10759945f, 0.11282390f, 0.11815964f, 0.12360536f, 0.12915977f, -0.13482147f, 0.14058908f, 0.14646113f, 0.15243614f, 0.15851256f, -0.16468882f, 0.17096330f, 0.17733432f, 0.18380017f, 0.19035910f, -0.19700930f, 0.20374894f, 0.21057612f, 0.21748892f, 0.22448537f, -0.23156343f, 0.23872106f, 0.24595615f, 0.25326656f, 0.26065010f, -0.26810455f, 0.27562763f, 0.28321704f, 0.29087045f, 0.29858546f, -0.30635965f, 0.31419058f, 0.32207574f, 0.33001263f, 0.33799866f, -0.34603127f, 0.35410783f, 0.36222570f, 0.37038219f, 0.37857460f, -0.38680022f, 0.39505629f, 0.40334003f, 0.41164867f, 0.41997939f, -0.42832937f, 0.43669576f, 0.44507572f, 0.45346639f, 0.46186489f, -0.47026835f, 0.47867389f, 0.48707862f, 0.49547965f, 0.50387411f, -0.51225912f, 0.52063179f, 0.52898927f, 0.53732871f, 0.54564725f, -0.55394208f, 0.56221039f, 0.57044938f, 0.57865628f, 0.58682836f, -0.59496289f, 0.60305718f, 0.61110858f, 0.61911445f, 0.62707221f, -0.63497931f, 0.64283322f, 0.65063147f, 0.65837163f, 0.66605132f, -0.67366820f, 0.68121999f, 0.68870444f, 0.69611937f, 0.70346266f, -0.71073222f, 0.71792606f, 0.72504220f, 0.73207877f, 0.73903393f, -0.74590592f, 0.75269303f, 0.75939364f, 0.76600617f, 0.77252915f, -0.77896113f, 0.78530077f, 0.79154678f, 0.79769796f, 0.80375317f, -0.80971135f, 0.81557152f, 0.82133276f, 0.82699424f, 0.83255520f, -0.83801496f, 0.84337291f, 0.84862851f, 0.85378132f, 0.85883095f, -0.86377710f, 0.86861954f, 0.87335813f, 0.87799277f, 0.88252347f, -0.88695029f, 0.89127338f, 0.89549294f, 0.89960926f, 0.90362268f, -0.90753364f, 0.91134262f, 0.91505017f, 0.91865692f, 0.92216354f, -0.92557078f, 0.92887945f, 0.93209042f, 0.93520460f, 0.93822298f, -0.94114659f, 0.94397652f, 0.94671390f, 0.94935993f, 0.95191584f, -0.95438290f, 0.95676245f, 0.95905584f, 0.96126449f, 0.96338982f, -0.96543334f, 0.96739653f, 0.96928096f, 0.97108818f, 0.97281981f, -0.97447746f, 0.97606279f, 0.97757746f, 0.97902317f, 0.98040162f, -0.98171453f, 0.98296363f, 0.98415067f, 0.98527740f, 0.98634557f, -0.98735696f, 0.98831332f, 0.98921643f, 0.99006803f, 0.99086991f, -0.99162380f, 0.99233145f, 0.99299461f, 0.99361500f, 0.99419433f, -0.99473429f, 0.99523657f, 0.99570284f, 0.99613472f, 0.99653384f, -0.99690180f, 0.99724017f, 0.99755048f, 0.99783426f, 0.99809299f, -0.99832812f, 0.99854108f, 0.99873324f, 0.99890597f, 0.99906057f, -0.99919832f, 0.99932046f, 0.99942819f, 0.99952266f, 0.99960498f, -0.99967623f, 0.99973742f, 0.99978953f, 0.99983351f, 0.99987023f, -0.99990053f, 0.99992520f, 0.99994498f, 0.99996055f, 0.99997257f, -0.99998161f, 0.99998821f, 0.99999285f, 0.99999596f, 0.99999793f, -0.99999907f, 0.99999966f, 0.99999991f, 0.99999999f, 1.0000000f, + 1.6821922e-05f, 0.00015139297f, 0.00042051200f, 0.00082413284f, 0.0013621862f, + 0.0020345793f, 0.0028411964f, 0.0037818978f, 0.0048565203f, 0.0060648765f, + 0.0074067550f, 0.0088819198f, 0.010490110f, 0.012231040f, 0.014104398f, + 0.016109846f, 0.018247021f, 0.020515533f, 0.022914963f, 0.025444867f, + 0.028104770f, 0.030894170f, 0.033812535f, 0.036859304f, 0.040033885f, + 0.043335654f, 0.046763958f, 0.050318110f, 0.053997389f, 0.057801044f, + 0.061728287f, 0.065778297f, 0.069950217f, 0.074243155f, 0.078656182f, + 0.083188331f, 0.087838600f, 0.092605946f, 0.097489289f, 0.10248751f, + 0.10759945f, 0.11282390f, 0.11815964f, 0.12360536f, 0.12915977f, + 0.13482147f, 0.14058908f, 0.14646113f, 0.15243614f, 0.15851256f, + 0.16468882f, 0.17096330f, 0.17733432f, 0.18380017f, 0.19035910f, + 0.19700930f, 0.20374894f, 0.21057612f, 0.21748892f, 0.22448537f, + 0.23156343f, 0.23872106f, 0.24595615f, 0.25326656f, 0.26065010f, + 0.26810455f, 0.27562763f, 0.28321704f, 0.29087045f, 0.29858546f, + 0.30635965f, 0.31419058f, 0.32207574f, 0.33001263f, 0.33799866f, + 0.34603127f, 0.35410783f, 0.36222570f, 0.37038219f, 0.37857460f, + 0.38680022f, 0.39505629f, 0.40334003f, 0.41164867f, 0.41997939f, + 0.42832937f, 0.43669576f, 0.44507572f, 0.45346639f, 0.46186489f, + 0.47026835f, 0.47867389f, 0.48707862f, 0.49547965f, 0.50387411f, + 0.51225912f, 0.52063179f, 0.52898927f, 0.53732871f, 0.54564725f, + 0.55394208f, 0.56221039f, 0.57044938f, 0.57865628f, 0.58682836f, + 0.59496289f, 0.60305718f, 0.61110858f, 0.61911445f, 0.62707221f, + 0.63497931f, 0.64283322f, 0.65063147f, 0.65837163f, 0.66605132f, + 0.67366820f, 0.68121999f, 0.68870444f, 0.69611937f, 0.70346266f, + 0.71073222f, 0.71792606f, 0.72504220f, 0.73207877f, 0.73903393f, + 0.74590592f, 0.75269303f, 0.75939364f, 0.76600617f, 0.77252915f, + 0.77896113f, 0.78530077f, 0.79154678f, 0.79769796f, 0.80375317f, + 0.80971135f, 0.81557152f, 0.82133276f, 0.82699424f, 0.83255520f, + 0.83801496f, 0.84337291f, 0.84862851f, 0.85378132f, 0.85883095f, + 0.86377710f, 0.86861954f, 0.87335813f, 0.87799277f, 0.88252347f, + 0.88695029f, 0.89127338f, 0.89549294f, 0.89960926f, 0.90362268f, + 0.90753364f, 0.91134262f, 0.91505017f, 0.91865692f, 0.92216354f, + 0.92557078f, 0.92887945f, 0.93209042f, 0.93520460f, 0.93822298f, + 0.94114659f, 0.94397652f, 0.94671390f, 0.94935993f, 0.95191584f, + 0.95438290f, 0.95676245f, 0.95905584f, 0.96126449f, 0.96338982f, + 0.96543334f, 0.96739653f, 0.96928096f, 0.97108818f, 0.97281981f, + 0.97447746f, 0.97606279f, 0.97757746f, 0.97902317f, 0.98040162f, + 0.98171453f, 0.98296363f, 0.98415067f, 0.98527740f, 0.98634557f, + 0.98735696f, 0.98831332f, 0.98921643f, 0.99006803f, 0.99086991f, + 0.99162380f, 0.99233145f, 0.99299461f, 0.99361500f, 0.99419433f, + 0.99473429f, 0.99523657f, 0.99570284f, 0.99613472f, 0.99653384f, + 0.99690180f, 0.99724017f, 0.99755048f, 0.99783426f, 0.99809299f, + 0.99832812f, 0.99854108f, 0.99873324f, 0.99890597f, 0.99906057f, + 0.99919832f, 0.99932046f, 0.99942819f, 0.99952266f, 0.99960498f, + 0.99967623f, 0.99973742f, 0.99978953f, 0.99983351f, 0.99987023f, + 0.99990053f, 0.99992520f, 0.99994498f, 0.99996055f, 0.99997257f, + 0.99998161f, 0.99998821f, 0.99999285f, 0.99999596f, 0.99999793f, + 0.99999907f, 0.99999966f, 0.99999991f, 0.99999999f, 1.0000000f, }; -#endif +# endif -#ifndef DEF_LOGN400 -#define DEF_LOGN400 -static const opus_int16 logN400[21] = { -0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36, }; -#endif +# ifndef DEF_LOGN400 +# define DEF_LOGN400 +static const oac_int16 logN400[21] = { + 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 16, 16, 16, 21, 21, 24, 29, 34, 36, }; +# endif -#ifndef DEF_PULSE_CACHE50 -#define DEF_PULSE_CACHE50 -static const opus_int16 cache_index50[105] = { --1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, -82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, -41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41, -41, 41, 41, 41, 41, 123, 123, 123, 123, 240, 240, 240, 266, 266, 305, -318, 328, 336, 123, 123, 123, 123, 123, 123, 123, 123, 240, 240, 240, 240, -305, 305, 305, 318, 318, 343, 351, 358, 364, 240, 240, 240, 240, 240, 240, -240, 240, 305, 305, 305, 305, 343, 343, 343, 351, 351, 370, 376, 382, 387, +# ifndef DEF_PULSE_CACHE50 +# define DEF_PULSE_CACHE50 +static const oac_int16 cache_index50[105] = { + -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 41, 41, 41, + 82, 82, 123, 164, 200, 222, 0, 0, 0, 0, 0, 0, 0, 0, 41, + 41, 41, 41, 123, 123, 123, 164, 164, 240, 266, 283, 295, 41, 41, 41, + 41, 41, 41, 41, 41, 123, 123, 123, 123, 240, 240, 240, 266, 266, 305, + 318, 328, 336, 123, 123, 123, 123, 123, 123, 123, 123, 240, 240, 240, 240, + 305, 305, 305, 318, 318, 343, 351, 358, 364, 240, 240, 240, 240, 240, 240, + 240, 240, 305, 305, 305, 305, 343, 343, 343, 351, 351, 370, 376, 382, 387, }; static const unsigned char cache_bits50[392] = { -40, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 40, 15, 23, 28, -31, 34, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47, 47, 49, 50, -51, 52, 53, 54, 55, 55, 57, 58, 59, 60, 61, 62, 63, 63, 65, -66, 67, 68, 69, 70, 71, 71, 40, 20, 33, 41, 48, 53, 57, 61, -64, 66, 69, 71, 73, 75, 76, 78, 80, 82, 85, 87, 89, 91, 92, -94, 96, 98, 101, 103, 105, 107, 108, 110, 112, 114, 117, 119, 121, 123, -124, 126, 128, 40, 23, 39, 51, 60, 67, 73, 79, 83, 87, 91, 94, -97, 100, 102, 105, 107, 111, 115, 118, 121, 124, 126, 129, 131, 135, 139, -142, 145, 148, 150, 153, 155, 159, 163, 166, 169, 172, 174, 177, 179, 35, -28, 49, 65, 78, 89, 99, 107, 114, 120, 126, 132, 136, 141, 145, 149, -153, 159, 165, 171, 176, 180, 185, 189, 192, 199, 205, 211, 216, 220, 225, -229, 232, 239, 245, 251, 21, 33, 58, 79, 97, 112, 125, 137, 148, 157, -166, 174, 182, 189, 195, 201, 207, 217, 227, 235, 243, 251, 17, 35, 63, -86, 106, 123, 139, 152, 165, 177, 187, 197, 206, 214, 222, 230, 237, 250, -25, 31, 55, 75, 91, 105, 117, 128, 138, 146, 154, 161, 168, 174, 180, -185, 190, 200, 208, 215, 222, 229, 235, 240, 245, 255, 16, 36, 65, 89, -110, 128, 144, 159, 173, 185, 196, 207, 217, 226, 234, 242, 250, 11, 41, -74, 103, 128, 151, 172, 191, 209, 225, 241, 255, 9, 43, 79, 110, 138, -163, 186, 207, 227, 246, 12, 39, 71, 99, 123, 144, 164, 182, 198, 214, -228, 241, 253, 9, 44, 81, 113, 142, 168, 192, 214, 235, 255, 7, 49, -90, 127, 160, 191, 220, 247, 6, 51, 95, 134, 170, 203, 234, 7, 47, -87, 123, 155, 184, 212, 237, 6, 52, 97, 137, 174, 208, 240, 5, 57, -106, 151, 192, 231, 5, 59, 111, 158, 202, 243, 5, 55, 103, 147, 187, -224, 5, 60, 113, 161, 206, 248, 4, 65, 122, 175, 224, 4, 67, 127, -182, 234, }; + 40, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 40, 15, 23, 28, + 31, 34, 36, 38, 39, 41, 42, 43, 44, 45, 46, 47, 47, 49, 50, + 51, 52, 53, 54, 55, 55, 57, 58, 59, 60, 61, 62, 63, 63, 65, + 66, 67, 68, 69, 70, 71, 71, 40, 20, 33, 41, 48, 53, 57, 61, + 64, 66, 69, 71, 73, 75, 76, 78, 80, 82, 85, 87, 89, 91, 92, + 94, 96, 98, 101, 103, 105, 107, 108, 110, 112, 114, 117, 119, 121, 123, + 124, 126, 128, 40, 23, 39, 51, 60, 67, 73, 79, 83, 87, 91, 94, + 97, 100, 102, 105, 107, 111, 115, 118, 121, 124, 126, 129, 131, 135, 139, + 142, 145, 148, 150, 153, 155, 159, 163, 166, 169, 172, 174, 177, 179, 35, + 28, 49, 65, 78, 89, 99, 107, 114, 120, 126, 132, 136, 141, 145, 149, + 153, 159, 165, 171, 176, 180, 185, 189, 192, 199, 205, 211, 216, 220, 225, + 229, 232, 239, 245, 251, 21, 33, 58, 79, 97, 112, 125, 137, 148, 157, + 166, 174, 182, 189, 195, 201, 207, 217, 227, 235, 243, 251, 17, 35, 63, + 86, 106, 123, 139, 152, 165, 177, 187, 197, 206, 214, 222, 230, 237, 250, + 25, 31, 55, 75, 91, 105, 117, 128, 138, 146, 154, 161, 168, 174, 180, + 185, 190, 200, 208, 215, 222, 229, 235, 240, 245, 255, 16, 36, 65, 89, + 110, 128, 144, 159, 173, 185, 196, 207, 217, 226, 234, 242, 250, 11, 41, + 74, 103, 128, 151, 172, 191, 209, 225, 241, 255, 9, 43, 79, 110, 138, + 163, 186, 207, 227, 246, 12, 39, 71, 99, 123, 144, 164, 182, 198, 214, + 228, 241, 253, 9, 44, 81, 113, 142, 168, 192, 214, 235, 255, 7, 49, + 90, 127, 160, 191, 220, 247, 6, 51, 95, 134, 170, 203, 234, 7, 47, + 87, 123, 155, 184, 212, 237, 6, 52, 97, 137, 174, 208, 240, 5, 57, + 106, 151, 192, 231, 5, 59, 111, 158, 202, 243, 5, 55, 103, 147, 187, + 224, 5, 60, 113, 161, 206, 248, 4, 65, 122, 175, 224, 4, 67, 127, + 182, 234, }; static const unsigned char cache_caps50[168] = { -224, 224, 224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 185, 185, 185, -178, 178, 168, 134, 61, 37, 224, 224, 224, 224, 224, 224, 224, 224, 240, -240, 240, 240, 207, 207, 207, 198, 198, 183, 144, 66, 40, 160, 160, 160, -160, 160, 160, 160, 160, 185, 185, 185, 185, 193, 193, 193, 183, 183, 172, -138, 64, 38, 240, 240, 240, 240, 240, 240, 240, 240, 207, 207, 207, 207, -204, 204, 204, 193, 193, 180, 143, 66, 40, 185, 185, 185, 185, 185, 185, -185, 185, 193, 193, 193, 193, 193, 193, 193, 183, 183, 172, 138, 65, 39, -207, 207, 207, 207, 207, 207, 207, 207, 204, 204, 204, 204, 201, 201, 201, -188, 188, 176, 141, 66, 40, 193, 193, 193, 193, 193, 193, 193, 193, 193, -193, 193, 193, 194, 194, 194, 184, 184, 173, 139, 65, 39, 204, 204, 204, -204, 204, 204, 204, 204, 201, 201, 201, 201, 198, 198, 198, 187, 187, 175, -140, 66, 40, }; -#endif - -#ifdef ENABLE_QEXT -# ifndef DEF_QEXT_PULSE_CACHE50 -# define DEF_QEXT_PULSE_CACHE50 -static const opus_int16 qext_cache_index50[70] = { -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, -41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 61, 61, -61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 72, 72, 72, -72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 80, 80, 80, 80, -80, 80, 80, 80, 80, 80, 80, 80, 80, 80, }; -static const unsigned char qext_cache_bits50[86] = { -40, 26, 45, 59, 70, 79, 87, 94, 100, 105, 110, 114, 118, 122, 125, -128, 131, 136, 141, 146, 150, 153, 157, 160, 163, 168, 173, 178, 182, 185, -189, 192, 195, 200, 205, 210, 214, 217, 221, 224, 227, 19, 34, 61, 83, -101, 118, 132, 145, 157, 167, 177, 186, 194, 202, 209, 216, 222, 234, 245, -254, 10, 42, 77, 107, 133, 157, 179, 200, 219, 236, 253, 7, 50, 93, -131, 165, 197, 227, 255, 5, 58, 109, 155, 197, 237, }; -static const unsigned char qext_cache_caps50[112] = { -159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 171, -171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 167, 167, 167, -167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 167, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 163, 163, 166, 166, 166, 166, 166, -166, 166, 166, 166, 166, 166, 166, 166, 166, 163, 163, 163, 163, 163, 163, -163, 163, 163, 163, 163, 163, 163, 163, 165, 165, 165, 165, 165, 165, 165, -165, 165, 165, 165, 165, 165, 165, }; + 224, 224, 224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 185, 185, 185, + 178, 178, 168, 134, 61, 37, 224, 224, 224, 224, 224, 224, 224, 224, 240, + 240, 240, 240, 207, 207, 207, 198, 198, 183, 144, 66, 40, 160, 160, 160, + 160, 160, 160, 160, 160, 185, 185, 185, 185, 193, 193, 193, 183, 183, 172, + 138, 64, 38, 240, 240, 240, 240, 240, 240, 240, 240, 207, 207, 207, 207, + 204, 204, 204, 193, 193, 180, 143, 66, 40, 185, 185, 185, 185, 185, 185, + 185, 185, 193, 193, 193, 193, 193, 193, 193, 183, 183, 172, 138, 65, 39, + 207, 207, 207, 207, 207, 207, 207, 207, 204, 204, 204, 204, 201, 201, 201, + 188, 188, 176, 141, 66, 40, 193, 193, 193, 193, 193, 193, 193, 193, 193, + 193, 193, 193, 194, 194, 194, 184, 184, 173, 139, 65, 39, 204, 204, 204, + 204, 204, 204, 204, 204, 201, 201, 201, 201, 198, 198, 198, 187, 187, 175, + 140, 66, 40, }; # endif -#endif -#ifndef FFT_TWIDDLES96000_1920 -#define FFT_TWIDDLES96000_1920 +# ifndef FFT_TWIDDLES96000_1920 +# define FFT_TWIDDLES96000_1920 static const kiss_twiddle_cpx fft_twiddles96000_1920[960] = { -{1.0000000f, -0.0000000f}, {0.99997858f, -0.0065449380f}, -{0.99991433f, -0.013089596f}, {0.99980724f, -0.019633692f}, -{0.99965732f, -0.026176948f}, {0.99946459f, -0.032719083f}, -{0.99922904f, -0.039259816f}, {0.99895068f, -0.045798867f}, -{0.99862953f, -0.052335956f}, {0.99826561f, -0.058870804f}, -{0.99785892f, -0.065403129f}, {0.99740949f, -0.071932653f}, -{0.99691733f, -0.078459096f}, {0.99638247f, -0.084982177f}, -{0.99580493f, -0.091501619f}, {0.99518473f, -0.098017140f}, -{0.99452190f, -0.10452846f}, {0.99381646f, -0.11103531f}, -{0.99306846f, -0.11753740f}, {0.99227791f, -0.12403445f}, -{0.99144486f, -0.13052619f}, {0.99056934f, -0.13701234f}, -{0.98965139f, -0.14349262f}, {0.98869104f, -0.14996676f}, -{0.98768834f, -0.15643447f}, {0.98664333f, -0.16289547f}, -{0.98555606f, -0.16934950f}, {0.98442657f, -0.17579628f}, -{0.98325491f, -0.18223553f}, {0.98204113f, -0.18866696f}, -{0.98078528f, -0.19509032f}, {0.97948742f, -0.20150532f}, -{0.97814760f, -0.20791169f}, {0.97676588f, -0.21430915f}, -{0.97534232f, -0.22069744f}, {0.97387698f, -0.22707626f}, -{0.97236992f, -0.23344536f}, {0.97082121f, -0.23980446f}, -{0.96923091f, -0.24615329f}, {0.96759909f, -0.25249158f}, -{0.96592583f, -0.25881905f}, {0.96421118f, -0.26513543f}, -{0.96245524f, -0.27144045f}, {0.96065806f, -0.27773385f}, -{0.95881973f, -0.28401534f}, {0.95694034f, -0.29028468f}, -{0.95501994f, -0.29654157f}, {0.95305864f, -0.30278577f}, -{0.95105652f, -0.30901699f}, {0.94901365f, -0.31523498f}, -{0.94693013f, -0.32143947f}, {0.94480605f, -0.32763018f}, -{0.94264149f, -0.33380686f}, {0.94043656f, -0.33996924f}, -{0.93819134f, -0.34611706f}, {0.93590593f, -0.35225005f}, -{0.93358043f, -0.35836795f}, {0.93121493f, -0.36447050f}, -{0.92880955f, -0.37055744f}, {0.92636438f, -0.37662850f}, -{0.92387953f, -0.38268343f}, {0.92135511f, -0.38872197f}, -{0.91879121f, -0.39474386f}, {0.91618796f, -0.40074883f}, -{0.91354546f, -0.40673664f}, {0.91086382f, -0.41270703f}, -{0.90814317f, -0.41865974f}, {0.90538362f, -0.42459451f}, -{0.90258528f, -0.43051110f}, {0.89974828f, -0.43640924f}, -{0.89687274f, -0.44228869f}, {0.89395878f, -0.44814919f}, -{0.89100652f, -0.45399050f}, {0.88801610f, -0.45981236f}, -{0.88498764f, -0.46561452f}, {0.88192126f, -0.47139674f}, -{0.87881711f, -0.47715876f}, {0.87567532f, -0.48290034f}, -{0.87249601f, -0.48862124f}, {0.86927932f, -0.49432121f}, -{0.86602540f, -0.50000000f}, {0.86273439f, -0.50565737f}, -{0.85940641f, -0.51129309f}, {0.85604162f, -0.51690690f}, -{0.85264016f, -0.52249856f}, {0.84920218f, -0.52806785f}, -{0.84572782f, -0.53361452f}, {0.84221723f, -0.53913832f}, -{0.83867057f, -0.54463904f}, {0.83508798f, -0.55011642f}, -{0.83146961f, -0.55557023f}, {0.82781563f, -0.56100025f}, -{0.82412619f, -0.56640624f}, {0.82040144f, -0.57178796f}, -{0.81664156f, -0.57714519f}, {0.81284668f, -0.58247770f}, -{0.80901699f, -0.58778525f}, {0.80515265f, -0.59306763f}, -{0.80125381f, -0.59832460f}, {0.79732065f, -0.60355594f}, -{0.79335334f, -0.60876143f}, {0.78935204f, -0.61394084f}, -{0.78531693f, -0.61909395f}, {0.78124818f, -0.62422054f}, -{0.77714596f, -0.62932039f}, {0.77301045f, -0.63439328f}, -{0.76884183f, -0.63943900f}, {0.76464028f, -0.64445733f}, -{0.76040597f, -0.64944805f}, {0.75613908f, -0.65441095f}, -{0.75183981f, -0.65934582f}, {0.74750833f, -0.66425244f}, -{0.74314483f, -0.66913061f}, {0.73874949f, -0.67398011f}, -{0.73432251f, -0.67880075f}, {0.72986407f, -0.68359230f}, -{0.72537437f, -0.68835458f}, {0.72085360f, -0.69308736f}, -{0.71630194f, -0.69779046f}, {0.71171961f, -0.70246367f}, -{0.70710678f, -0.70710678f}, {0.70246367f, -0.71171961f}, -{0.69779046f, -0.71630194f}, {0.69308736f, -0.72085360f}, -{0.68835458f, -0.72537437f}, {0.68359230f, -0.72986407f}, -{0.67880075f, -0.73432251f}, {0.67398011f, -0.73874949f}, -{0.66913061f, -0.74314483f}, {0.66425244f, -0.74750833f}, -{0.65934582f, -0.75183981f}, {0.65441095f, -0.75613908f}, -{0.64944805f, -0.76040597f}, {0.64445733f, -0.76464028f}, -{0.63943900f, -0.76884183f}, {0.63439328f, -0.77301045f}, -{0.62932039f, -0.77714596f}, {0.62422054f, -0.78124818f}, -{0.61909395f, -0.78531693f}, {0.61394084f, -0.78935204f}, -{0.60876143f, -0.79335334f}, {0.60355594f, -0.79732065f}, -{0.59832460f, -0.80125381f}, {0.59306763f, -0.80515265f}, -{0.58778525f, -0.80901699f}, {0.58247770f, -0.81284668f}, -{0.57714519f, -0.81664156f}, {0.57178796f, -0.82040144f}, -{0.56640624f, -0.82412619f}, {0.56100025f, -0.82781563f}, -{0.55557023f, -0.83146961f}, {0.55011642f, -0.83508798f}, -{0.54463904f, -0.83867057f}, {0.53913832f, -0.84221723f}, -{0.53361452f, -0.84572782f}, {0.52806785f, -0.84920218f}, -{0.52249856f, -0.85264016f}, {0.51690690f, -0.85604162f}, -{0.51129309f, -0.85940641f}, {0.50565737f, -0.86273439f}, -{0.50000000f, -0.86602540f}, {0.49432121f, -0.86927932f}, -{0.48862124f, -0.87249601f}, {0.48290034f, -0.87567532f}, -{0.47715876f, -0.87881711f}, {0.47139674f, -0.88192126f}, -{0.46561452f, -0.88498764f}, {0.45981236f, -0.88801610f}, -{0.45399050f, -0.89100652f}, {0.44814919f, -0.89395878f}, -{0.44228869f, -0.89687274f}, {0.43640924f, -0.89974828f}, -{0.43051110f, -0.90258528f}, {0.42459451f, -0.90538362f}, -{0.41865974f, -0.90814317f}, {0.41270703f, -0.91086382f}, -{0.40673664f, -0.91354546f}, {0.40074883f, -0.91618796f}, -{0.39474386f, -0.91879121f}, {0.38872197f, -0.92135511f}, -{0.38268343f, -0.92387953f}, {0.37662850f, -0.92636438f}, -{0.37055744f, -0.92880955f}, {0.36447050f, -0.93121493f}, -{0.35836795f, -0.93358043f}, {0.35225005f, -0.93590593f}, -{0.34611706f, -0.93819134f}, {0.33996924f, -0.94043656f}, -{0.33380686f, -0.94264149f}, {0.32763018f, -0.94480605f}, -{0.32143947f, -0.94693013f}, {0.31523498f, -0.94901365f}, -{0.30901699f, -0.95105652f}, {0.30278577f, -0.95305864f}, -{0.29654157f, -0.95501994f}, {0.29028468f, -0.95694034f}, -{0.28401534f, -0.95881973f}, {0.27773385f, -0.96065806f}, -{0.27144045f, -0.96245524f}, {0.26513543f, -0.96421118f}, -{0.25881905f, -0.96592583f}, {0.25249158f, -0.96759909f}, -{0.24615329f, -0.96923091f}, {0.23980446f, -0.97082121f}, -{0.23344536f, -0.97236992f}, {0.22707626f, -0.97387698f}, -{0.22069744f, -0.97534232f}, {0.21430915f, -0.97676588f}, -{0.20791169f, -0.97814760f}, {0.20150532f, -0.97948742f}, -{0.19509032f, -0.98078528f}, {0.18866696f, -0.98204113f}, -{0.18223553f, -0.98325491f}, {0.17579628f, -0.98442657f}, -{0.16934950f, -0.98555606f}, {0.16289547f, -0.98664333f}, -{0.15643447f, -0.98768834f}, {0.14996676f, -0.98869104f}, -{0.14349262f, -0.98965139f}, {0.13701234f, -0.99056934f}, -{0.13052619f, -0.99144486f}, {0.12403445f, -0.99227791f}, -{0.11753740f, -0.99306846f}, {0.11103531f, -0.99381646f}, -{0.10452846f, -0.99452190f}, {0.098017140f, -0.99518473f}, -{0.091501619f, -0.99580493f}, {0.084982177f, -0.99638247f}, -{0.078459096f, -0.99691733f}, {0.071932653f, -0.99740949f}, -{0.065403129f, -0.99785892f}, {0.058870804f, -0.99826561f}, -{0.052335956f, -0.99862953f}, {0.045798867f, -0.99895068f}, -{0.039259816f, -0.99922904f}, {0.032719083f, -0.99946459f}, -{0.026176948f, -0.99965732f}, {0.019633692f, -0.99980724f}, -{0.013089596f, -0.99991433f}, {0.0065449380f, -0.99997858f}, -{6.1232340e-17f, -1.0000000f}, {-0.0065449380f, -0.99997858f}, -{-0.013089596f, -0.99991433f}, {-0.019633692f, -0.99980724f}, -{-0.026176948f, -0.99965732f}, {-0.032719083f, -0.99946459f}, -{-0.039259816f, -0.99922904f}, {-0.045798867f, -0.99895068f}, -{-0.052335956f, -0.99862953f}, {-0.058870804f, -0.99826561f}, -{-0.065403129f, -0.99785892f}, {-0.071932653f, -0.99740949f}, -{-0.078459096f, -0.99691733f}, {-0.084982177f, -0.99638247f}, -{-0.091501619f, -0.99580493f}, {-0.098017140f, -0.99518473f}, -{-0.10452846f, -0.99452190f}, {-0.11103531f, -0.99381646f}, -{-0.11753740f, -0.99306846f}, {-0.12403445f, -0.99227791f}, -{-0.13052619f, -0.99144486f}, {-0.13701234f, -0.99056934f}, -{-0.14349262f, -0.98965139f}, {-0.14996676f, -0.98869104f}, -{-0.15643447f, -0.98768834f}, {-0.16289547f, -0.98664333f}, -{-0.16934950f, -0.98555606f}, {-0.17579628f, -0.98442657f}, -{-0.18223553f, -0.98325491f}, {-0.18866696f, -0.98204113f}, -{-0.19509032f, -0.98078528f}, {-0.20150532f, -0.97948742f}, -{-0.20791169f, -0.97814760f}, {-0.21430915f, -0.97676588f}, -{-0.22069744f, -0.97534232f}, {-0.22707626f, -0.97387698f}, -{-0.23344536f, -0.97236992f}, {-0.23980446f, -0.97082121f}, -{-0.24615329f, -0.96923091f}, {-0.25249158f, -0.96759909f}, -{-0.25881905f, -0.96592583f}, {-0.26513543f, -0.96421118f}, -{-0.27144045f, -0.96245524f}, {-0.27773385f, -0.96065806f}, -{-0.28401534f, -0.95881973f}, {-0.29028468f, -0.95694034f}, -{-0.29654157f, -0.95501994f}, {-0.30278577f, -0.95305864f}, -{-0.30901699f, -0.95105652f}, {-0.31523498f, -0.94901365f}, -{-0.32143947f, -0.94693013f}, {-0.32763018f, -0.94480605f}, -{-0.33380686f, -0.94264149f}, {-0.33996924f, -0.94043656f}, -{-0.34611706f, -0.93819134f}, {-0.35225005f, -0.93590593f}, -{-0.35836795f, -0.93358043f}, {-0.36447050f, -0.93121493f}, -{-0.37055744f, -0.92880955f}, {-0.37662850f, -0.92636438f}, -{-0.38268343f, -0.92387953f}, {-0.38872197f, -0.92135511f}, -{-0.39474386f, -0.91879121f}, {-0.40074883f, -0.91618796f}, -{-0.40673664f, -0.91354546f}, {-0.41270703f, -0.91086382f}, -{-0.41865974f, -0.90814317f}, {-0.42459451f, -0.90538362f}, -{-0.43051110f, -0.90258528f}, {-0.43640924f, -0.89974828f}, -{-0.44228869f, -0.89687274f}, {-0.44814919f, -0.89395878f}, -{-0.45399050f, -0.89100652f}, {-0.45981236f, -0.88801610f}, -{-0.46561452f, -0.88498764f}, {-0.47139674f, -0.88192126f}, -{-0.47715876f, -0.87881711f}, {-0.48290034f, -0.87567532f}, -{-0.48862124f, -0.87249601f}, {-0.49432121f, -0.86927932f}, -{-0.50000000f, -0.86602540f}, {-0.50565737f, -0.86273439f}, -{-0.51129309f, -0.85940641f}, {-0.51690690f, -0.85604162f}, -{-0.52249856f, -0.85264016f}, {-0.52806785f, -0.84920218f}, -{-0.53361452f, -0.84572782f}, {-0.53913832f, -0.84221723f}, -{-0.54463904f, -0.83867057f}, {-0.55011642f, -0.83508798f}, -{-0.55557023f, -0.83146961f}, {-0.56100025f, -0.82781563f}, -{-0.56640624f, -0.82412619f}, {-0.57178796f, -0.82040144f}, -{-0.57714519f, -0.81664156f}, {-0.58247770f, -0.81284668f}, -{-0.58778525f, -0.80901699f}, {-0.59306763f, -0.80515265f}, -{-0.59832460f, -0.80125381f}, {-0.60355594f, -0.79732065f}, -{-0.60876143f, -0.79335334f}, {-0.61394084f, -0.78935204f}, -{-0.61909395f, -0.78531693f}, {-0.62422054f, -0.78124818f}, -{-0.62932039f, -0.77714596f}, {-0.63439328f, -0.77301045f}, -{-0.63943900f, -0.76884183f}, {-0.64445733f, -0.76464028f}, -{-0.64944805f, -0.76040597f}, {-0.65441095f, -0.75613908f}, -{-0.65934582f, -0.75183981f}, {-0.66425244f, -0.74750833f}, -{-0.66913061f, -0.74314483f}, {-0.67398011f, -0.73874949f}, -{-0.67880075f, -0.73432251f}, {-0.68359230f, -0.72986407f}, -{-0.68835458f, -0.72537437f}, {-0.69308736f, -0.72085360f}, -{-0.69779046f, -0.71630194f}, {-0.70246367f, -0.71171961f}, -{-0.70710678f, -0.70710678f}, {-0.71171961f, -0.70246367f}, -{-0.71630194f, -0.69779046f}, {-0.72085360f, -0.69308736f}, -{-0.72537437f, -0.68835458f}, {-0.72986407f, -0.68359230f}, -{-0.73432251f, -0.67880075f}, {-0.73874949f, -0.67398011f}, -{-0.74314483f, -0.66913061f}, {-0.74750833f, -0.66425244f}, -{-0.75183981f, -0.65934582f}, {-0.75613908f, -0.65441095f}, -{-0.76040597f, -0.64944805f}, {-0.76464028f, -0.64445733f}, -{-0.76884183f, -0.63943900f}, {-0.77301045f, -0.63439328f}, -{-0.77714596f, -0.62932039f}, {-0.78124818f, -0.62422054f}, -{-0.78531693f, -0.61909395f}, {-0.78935204f, -0.61394084f}, -{-0.79335334f, -0.60876143f}, {-0.79732065f, -0.60355594f}, -{-0.80125381f, -0.59832460f}, {-0.80515265f, -0.59306763f}, -{-0.80901699f, -0.58778525f}, {-0.81284668f, -0.58247770f}, -{-0.81664156f, -0.57714519f}, {-0.82040144f, -0.57178796f}, -{-0.82412619f, -0.56640624f}, {-0.82781563f, -0.56100025f}, -{-0.83146961f, -0.55557023f}, {-0.83508798f, -0.55011642f}, -{-0.83867057f, -0.54463904f}, {-0.84221723f, -0.53913832f}, -{-0.84572782f, -0.53361452f}, {-0.84920218f, -0.52806785f}, -{-0.85264016f, -0.52249856f}, {-0.85604162f, -0.51690690f}, -{-0.85940641f, -0.51129309f}, {-0.86273439f, -0.50565737f}, -{-0.86602540f, -0.50000000f}, {-0.86927932f, -0.49432121f}, -{-0.87249601f, -0.48862124f}, {-0.87567532f, -0.48290034f}, -{-0.87881711f, -0.47715876f}, {-0.88192126f, -0.47139674f}, -{-0.88498764f, -0.46561452f}, {-0.88801610f, -0.45981236f}, -{-0.89100652f, -0.45399050f}, {-0.89395878f, -0.44814919f}, -{-0.89687274f, -0.44228869f}, {-0.89974828f, -0.43640924f}, -{-0.90258528f, -0.43051110f}, {-0.90538362f, -0.42459451f}, -{-0.90814317f, -0.41865974f}, {-0.91086382f, -0.41270703f}, -{-0.91354546f, -0.40673664f}, {-0.91618796f, -0.40074883f}, -{-0.91879121f, -0.39474386f}, {-0.92135511f, -0.38872197f}, -{-0.92387953f, -0.38268343f}, {-0.92636438f, -0.37662850f}, -{-0.92880955f, -0.37055744f}, {-0.93121493f, -0.36447050f}, -{-0.93358043f, -0.35836795f}, {-0.93590593f, -0.35225005f}, -{-0.93819134f, -0.34611706f}, {-0.94043656f, -0.33996924f}, -{-0.94264149f, -0.33380686f}, {-0.94480605f, -0.32763018f}, -{-0.94693013f, -0.32143947f}, {-0.94901365f, -0.31523498f}, -{-0.95105652f, -0.30901699f}, {-0.95305864f, -0.30278577f}, -{-0.95501994f, -0.29654157f}, {-0.95694034f, -0.29028468f}, -{-0.95881973f, -0.28401534f}, {-0.96065806f, -0.27773385f}, -{-0.96245524f, -0.27144045f}, {-0.96421118f, -0.26513543f}, -{-0.96592583f, -0.25881905f}, {-0.96759909f, -0.25249158f}, -{-0.96923091f, -0.24615329f}, {-0.97082121f, -0.23980446f}, -{-0.97236992f, -0.23344536f}, {-0.97387698f, -0.22707626f}, -{-0.97534232f, -0.22069744f}, {-0.97676588f, -0.21430915f}, -{-0.97814760f, -0.20791169f}, {-0.97948742f, -0.20150532f}, -{-0.98078528f, -0.19509032f}, {-0.98204113f, -0.18866696f}, -{-0.98325491f, -0.18223553f}, {-0.98442657f, -0.17579628f}, -{-0.98555606f, -0.16934950f}, {-0.98664333f, -0.16289547f}, -{-0.98768834f, -0.15643447f}, {-0.98869104f, -0.14996676f}, -{-0.98965139f, -0.14349262f}, {-0.99056934f, -0.13701234f}, -{-0.99144486f, -0.13052619f}, {-0.99227791f, -0.12403445f}, -{-0.99306846f, -0.11753740f}, {-0.99381646f, -0.11103531f}, -{-0.99452190f, -0.10452846f}, {-0.99518473f, -0.098017140f}, -{-0.99580493f, -0.091501619f}, {-0.99638247f, -0.084982177f}, -{-0.99691733f, -0.078459096f}, {-0.99740949f, -0.071932653f}, -{-0.99785892f, -0.065403129f}, {-0.99826561f, -0.058870804f}, -{-0.99862953f, -0.052335956f}, {-0.99895068f, -0.045798867f}, -{-0.99922904f, -0.039259816f}, {-0.99946459f, -0.032719083f}, -{-0.99965732f, -0.026176948f}, {-0.99980724f, -0.019633692f}, -{-0.99991433f, -0.013089596f}, {-0.99997858f, -0.0065449380f}, -{-1.0000000f, -1.2246468e-16f}, {-0.99997858f, 0.0065449380f}, -{-0.99991433f, 0.013089596f}, {-0.99980724f, 0.019633692f}, -{-0.99965732f, 0.026176948f}, {-0.99946459f, 0.032719083f}, -{-0.99922904f, 0.039259816f}, {-0.99895068f, 0.045798867f}, -{-0.99862953f, 0.052335956f}, {-0.99826561f, 0.058870804f}, -{-0.99785892f, 0.065403129f}, {-0.99740949f, 0.071932653f}, -{-0.99691733f, 0.078459096f}, {-0.99638247f, 0.084982177f}, -{-0.99580493f, 0.091501619f}, {-0.99518473f, 0.098017140f}, -{-0.99452190f, 0.10452846f}, {-0.99381646f, 0.11103531f}, -{-0.99306846f, 0.11753740f}, {-0.99227791f, 0.12403445f}, -{-0.99144486f, 0.13052619f}, {-0.99056934f, 0.13701234f}, -{-0.98965139f, 0.14349262f}, {-0.98869104f, 0.14996676f}, -{-0.98768834f, 0.15643447f}, {-0.98664333f, 0.16289547f}, -{-0.98555606f, 0.16934950f}, {-0.98442657f, 0.17579628f}, -{-0.98325491f, 0.18223553f}, {-0.98204113f, 0.18866696f}, -{-0.98078528f, 0.19509032f}, {-0.97948742f, 0.20150532f}, -{-0.97814760f, 0.20791169f}, {-0.97676588f, 0.21430915f}, -{-0.97534232f, 0.22069744f}, {-0.97387698f, 0.22707626f}, -{-0.97236992f, 0.23344536f}, {-0.97082121f, 0.23980446f}, -{-0.96923091f, 0.24615329f}, {-0.96759909f, 0.25249158f}, -{-0.96592583f, 0.25881905f}, {-0.96421118f, 0.26513543f}, -{-0.96245524f, 0.27144045f}, {-0.96065806f, 0.27773385f}, -{-0.95881973f, 0.28401534f}, {-0.95694034f, 0.29028468f}, -{-0.95501994f, 0.29654157f}, {-0.95305864f, 0.30278577f}, -{-0.95105652f, 0.30901699f}, {-0.94901365f, 0.31523498f}, -{-0.94693013f, 0.32143947f}, {-0.94480605f, 0.32763018f}, -{-0.94264149f, 0.33380686f}, {-0.94043656f, 0.33996924f}, -{-0.93819134f, 0.34611706f}, {-0.93590593f, 0.35225005f}, -{-0.93358043f, 0.35836795f}, {-0.93121493f, 0.36447050f}, -{-0.92880955f, 0.37055744f}, {-0.92636438f, 0.37662850f}, -{-0.92387953f, 0.38268343f}, {-0.92135511f, 0.38872197f}, -{-0.91879121f, 0.39474386f}, {-0.91618796f, 0.40074883f}, -{-0.91354546f, 0.40673664f}, {-0.91086382f, 0.41270703f}, -{-0.90814317f, 0.41865974f}, {-0.90538362f, 0.42459451f}, -{-0.90258528f, 0.43051110f}, {-0.89974828f, 0.43640924f}, -{-0.89687274f, 0.44228869f}, {-0.89395878f, 0.44814919f}, -{-0.89100652f, 0.45399050f}, {-0.88801610f, 0.45981236f}, -{-0.88498764f, 0.46561452f}, {-0.88192126f, 0.47139674f}, -{-0.87881711f, 0.47715876f}, {-0.87567532f, 0.48290034f}, -{-0.87249601f, 0.48862124f}, {-0.86927932f, 0.49432121f}, -{-0.86602540f, 0.50000000f}, {-0.86273439f, 0.50565737f}, -{-0.85940641f, 0.51129309f}, {-0.85604162f, 0.51690690f}, -{-0.85264016f, 0.52249856f}, {-0.84920218f, 0.52806785f}, -{-0.84572782f, 0.53361452f}, {-0.84221723f, 0.53913832f}, -{-0.83867057f, 0.54463904f}, {-0.83508798f, 0.55011642f}, -{-0.83146961f, 0.55557023f}, {-0.82781563f, 0.56100025f}, -{-0.82412619f, 0.56640624f}, {-0.82040144f, 0.57178796f}, -{-0.81664156f, 0.57714519f}, {-0.81284668f, 0.58247770f}, -{-0.80901699f, 0.58778525f}, {-0.80515265f, 0.59306763f}, -{-0.80125381f, 0.59832460f}, {-0.79732065f, 0.60355594f}, -{-0.79335334f, 0.60876143f}, {-0.78935204f, 0.61394084f}, -{-0.78531693f, 0.61909395f}, {-0.78124818f, 0.62422054f}, -{-0.77714596f, 0.62932039f}, {-0.77301045f, 0.63439328f}, -{-0.76884183f, 0.63943900f}, {-0.76464028f, 0.64445733f}, -{-0.76040597f, 0.64944805f}, {-0.75613908f, 0.65441095f}, -{-0.75183981f, 0.65934582f}, {-0.74750833f, 0.66425244f}, -{-0.74314483f, 0.66913061f}, {-0.73874949f, 0.67398011f}, -{-0.73432251f, 0.67880075f}, {-0.72986407f, 0.68359230f}, -{-0.72537437f, 0.68835458f}, {-0.72085360f, 0.69308736f}, -{-0.71630194f, 0.69779046f}, {-0.71171961f, 0.70246367f}, -{-0.70710678f, 0.70710678f}, {-0.70246367f, 0.71171961f}, -{-0.69779046f, 0.71630194f}, {-0.69308736f, 0.72085360f}, -{-0.68835458f, 0.72537437f}, {-0.68359230f, 0.72986407f}, -{-0.67880075f, 0.73432251f}, {-0.67398011f, 0.73874949f}, -{-0.66913061f, 0.74314483f}, {-0.66425244f, 0.74750833f}, -{-0.65934582f, 0.75183981f}, {-0.65441095f, 0.75613908f}, -{-0.64944805f, 0.76040597f}, {-0.64445733f, 0.76464028f}, -{-0.63943900f, 0.76884183f}, {-0.63439328f, 0.77301045f}, -{-0.62932039f, 0.77714596f}, {-0.62422054f, 0.78124818f}, -{-0.61909395f, 0.78531693f}, {-0.61394084f, 0.78935204f}, -{-0.60876143f, 0.79335334f}, {-0.60355594f, 0.79732065f}, -{-0.59832460f, 0.80125381f}, {-0.59306763f, 0.80515265f}, -{-0.58778525f, 0.80901699f}, {-0.58247770f, 0.81284668f}, -{-0.57714519f, 0.81664156f}, {-0.57178796f, 0.82040144f}, -{-0.56640624f, 0.82412619f}, {-0.56100025f, 0.82781563f}, -{-0.55557023f, 0.83146961f}, {-0.55011642f, 0.83508798f}, -{-0.54463904f, 0.83867057f}, {-0.53913832f, 0.84221723f}, -{-0.53361452f, 0.84572782f}, {-0.52806785f, 0.84920218f}, -{-0.52249856f, 0.85264016f}, {-0.51690690f, 0.85604162f}, -{-0.51129309f, 0.85940641f}, {-0.50565737f, 0.86273439f}, -{-0.50000000f, 0.86602540f}, {-0.49432121f, 0.86927932f}, -{-0.48862124f, 0.87249601f}, {-0.48290034f, 0.87567532f}, -{-0.47715876f, 0.87881711f}, {-0.47139674f, 0.88192126f}, -{-0.46561452f, 0.88498764f}, {-0.45981236f, 0.88801610f}, -{-0.45399050f, 0.89100652f}, {-0.44814919f, 0.89395878f}, -{-0.44228869f, 0.89687274f}, {-0.43640924f, 0.89974828f}, -{-0.43051110f, 0.90258528f}, {-0.42459451f, 0.90538362f}, -{-0.41865974f, 0.90814317f}, {-0.41270703f, 0.91086382f}, -{-0.40673664f, 0.91354546f}, {-0.40074883f, 0.91618796f}, -{-0.39474386f, 0.91879121f}, {-0.38872197f, 0.92135511f}, -{-0.38268343f, 0.92387953f}, {-0.37662850f, 0.92636438f}, -{-0.37055744f, 0.92880955f}, {-0.36447050f, 0.93121493f}, -{-0.35836795f, 0.93358043f}, {-0.35225005f, 0.93590593f}, -{-0.34611706f, 0.93819134f}, {-0.33996924f, 0.94043656f}, -{-0.33380686f, 0.94264149f}, {-0.32763018f, 0.94480605f}, -{-0.32143947f, 0.94693013f}, {-0.31523498f, 0.94901365f}, -{-0.30901699f, 0.95105652f}, {-0.30278577f, 0.95305864f}, -{-0.29654157f, 0.95501994f}, {-0.29028468f, 0.95694034f}, -{-0.28401534f, 0.95881973f}, {-0.27773385f, 0.96065806f}, -{-0.27144045f, 0.96245524f}, {-0.26513543f, 0.96421118f}, -{-0.25881905f, 0.96592583f}, {-0.25249158f, 0.96759909f}, -{-0.24615329f, 0.96923091f}, {-0.23980446f, 0.97082121f}, -{-0.23344536f, 0.97236992f}, {-0.22707626f, 0.97387698f}, -{-0.22069744f, 0.97534232f}, {-0.21430915f, 0.97676588f}, -{-0.20791169f, 0.97814760f}, {-0.20150532f, 0.97948742f}, -{-0.19509032f, 0.98078528f}, {-0.18866696f, 0.98204113f}, -{-0.18223553f, 0.98325491f}, {-0.17579628f, 0.98442657f}, -{-0.16934950f, 0.98555606f}, {-0.16289547f, 0.98664333f}, -{-0.15643447f, 0.98768834f}, {-0.14996676f, 0.98869104f}, -{-0.14349262f, 0.98965139f}, {-0.13701234f, 0.99056934f}, -{-0.13052619f, 0.99144486f}, {-0.12403445f, 0.99227791f}, -{-0.11753740f, 0.99306846f}, {-0.11103531f, 0.99381646f}, -{-0.10452846f, 0.99452190f}, {-0.098017140f, 0.99518473f}, -{-0.091501619f, 0.99580493f}, {-0.084982177f, 0.99638247f}, -{-0.078459096f, 0.99691733f}, {-0.071932653f, 0.99740949f}, -{-0.065403129f, 0.99785892f}, {-0.058870804f, 0.99826561f}, -{-0.052335956f, 0.99862953f}, {-0.045798867f, 0.99895068f}, -{-0.039259816f, 0.99922904f}, {-0.032719083f, 0.99946459f}, -{-0.026176948f, 0.99965732f}, {-0.019633692f, 0.99980724f}, -{-0.013089596f, 0.99991433f}, {-0.0065449380f, 0.99997858f}, -{-1.8369702e-16f, 1.0000000f}, {0.0065449380f, 0.99997858f}, -{0.013089596f, 0.99991433f}, {0.019633692f, 0.99980724f}, -{0.026176948f, 0.99965732f}, {0.032719083f, 0.99946459f}, -{0.039259816f, 0.99922904f}, {0.045798867f, 0.99895068f}, -{0.052335956f, 0.99862953f}, {0.058870804f, 0.99826561f}, -{0.065403129f, 0.99785892f}, {0.071932653f, 0.99740949f}, -{0.078459096f, 0.99691733f}, {0.084982177f, 0.99638247f}, -{0.091501619f, 0.99580493f}, {0.098017140f, 0.99518473f}, -{0.10452846f, 0.99452190f}, {0.11103531f, 0.99381646f}, -{0.11753740f, 0.99306846f}, {0.12403445f, 0.99227791f}, -{0.13052619f, 0.99144486f}, {0.13701234f, 0.99056934f}, -{0.14349262f, 0.98965139f}, {0.14996676f, 0.98869104f}, -{0.15643447f, 0.98768834f}, {0.16289547f, 0.98664333f}, -{0.16934950f, 0.98555606f}, {0.17579628f, 0.98442657f}, -{0.18223553f, 0.98325491f}, {0.18866696f, 0.98204113f}, -{0.19509032f, 0.98078528f}, {0.20150532f, 0.97948742f}, -{0.20791169f, 0.97814760f}, {0.21430915f, 0.97676588f}, -{0.22069744f, 0.97534232f}, {0.22707626f, 0.97387698f}, -{0.23344536f, 0.97236992f}, {0.23980446f, 0.97082121f}, -{0.24615329f, 0.96923091f}, {0.25249158f, 0.96759909f}, -{0.25881905f, 0.96592583f}, {0.26513543f, 0.96421118f}, -{0.27144045f, 0.96245524f}, {0.27773385f, 0.96065806f}, -{0.28401534f, 0.95881973f}, {0.29028468f, 0.95694034f}, -{0.29654157f, 0.95501994f}, {0.30278577f, 0.95305864f}, -{0.30901699f, 0.95105652f}, {0.31523498f, 0.94901365f}, -{0.32143947f, 0.94693013f}, {0.32763018f, 0.94480605f}, -{0.33380686f, 0.94264149f}, {0.33996924f, 0.94043656f}, -{0.34611706f, 0.93819134f}, {0.35225005f, 0.93590593f}, -{0.35836795f, 0.93358043f}, {0.36447050f, 0.93121493f}, -{0.37055744f, 0.92880955f}, {0.37662850f, 0.92636438f}, -{0.38268343f, 0.92387953f}, {0.38872197f, 0.92135511f}, -{0.39474386f, 0.91879121f}, {0.40074883f, 0.91618796f}, -{0.40673664f, 0.91354546f}, {0.41270703f, 0.91086382f}, -{0.41865974f, 0.90814317f}, {0.42459451f, 0.90538362f}, -{0.43051110f, 0.90258528f}, {0.43640924f, 0.89974828f}, -{0.44228869f, 0.89687274f}, {0.44814919f, 0.89395878f}, -{0.45399050f, 0.89100652f}, {0.45981236f, 0.88801610f}, -{0.46561452f, 0.88498764f}, {0.47139674f, 0.88192126f}, -{0.47715876f, 0.87881711f}, {0.48290034f, 0.87567532f}, -{0.48862124f, 0.87249601f}, {0.49432121f, 0.86927932f}, -{0.50000000f, 0.86602540f}, {0.50565737f, 0.86273439f}, -{0.51129309f, 0.85940641f}, {0.51690690f, 0.85604162f}, -{0.52249856f, 0.85264016f}, {0.52806785f, 0.84920218f}, -{0.53361452f, 0.84572782f}, {0.53913832f, 0.84221723f}, -{0.54463904f, 0.83867057f}, {0.55011642f, 0.83508798f}, -{0.55557023f, 0.83146961f}, {0.56100025f, 0.82781563f}, -{0.56640624f, 0.82412619f}, {0.57178796f, 0.82040144f}, -{0.57714519f, 0.81664156f}, {0.58247770f, 0.81284668f}, -{0.58778525f, 0.80901699f}, {0.59306763f, 0.80515265f}, -{0.59832460f, 0.80125381f}, {0.60355594f, 0.79732065f}, -{0.60876143f, 0.79335334f}, {0.61394084f, 0.78935204f}, -{0.61909395f, 0.78531693f}, {0.62422054f, 0.78124818f}, -{0.62932039f, 0.77714596f}, {0.63439328f, 0.77301045f}, -{0.63943900f, 0.76884183f}, {0.64445733f, 0.76464028f}, -{0.64944805f, 0.76040597f}, {0.65441095f, 0.75613908f}, -{0.65934582f, 0.75183981f}, {0.66425244f, 0.74750833f}, -{0.66913061f, 0.74314483f}, {0.67398011f, 0.73874949f}, -{0.67880075f, 0.73432251f}, {0.68359230f, 0.72986407f}, -{0.68835458f, 0.72537437f}, {0.69308736f, 0.72085360f}, -{0.69779046f, 0.71630194f}, {0.70246367f, 0.71171961f}, -{0.70710678f, 0.70710678f}, {0.71171961f, 0.70246367f}, -{0.71630194f, 0.69779046f}, {0.72085360f, 0.69308736f}, -{0.72537437f, 0.68835458f}, {0.72986407f, 0.68359230f}, -{0.73432251f, 0.67880075f}, {0.73874949f, 0.67398011f}, -{0.74314483f, 0.66913061f}, {0.74750833f, 0.66425244f}, -{0.75183981f, 0.65934582f}, {0.75613908f, 0.65441095f}, -{0.76040597f, 0.64944805f}, {0.76464028f, 0.64445733f}, -{0.76884183f, 0.63943900f}, {0.77301045f, 0.63439328f}, -{0.77714596f, 0.62932039f}, {0.78124818f, 0.62422054f}, -{0.78531693f, 0.61909395f}, {0.78935204f, 0.61394084f}, -{0.79335334f, 0.60876143f}, {0.79732065f, 0.60355594f}, -{0.80125381f, 0.59832460f}, {0.80515265f, 0.59306763f}, -{0.80901699f, 0.58778525f}, {0.81284668f, 0.58247770f}, -{0.81664156f, 0.57714519f}, {0.82040144f, 0.57178796f}, -{0.82412619f, 0.56640624f}, {0.82781563f, 0.56100025f}, -{0.83146961f, 0.55557023f}, {0.83508798f, 0.55011642f}, -{0.83867057f, 0.54463904f}, {0.84221723f, 0.53913832f}, -{0.84572782f, 0.53361452f}, {0.84920218f, 0.52806785f}, -{0.85264016f, 0.52249856f}, {0.85604162f, 0.51690690f}, -{0.85940641f, 0.51129309f}, {0.86273439f, 0.50565737f}, -{0.86602540f, 0.50000000f}, {0.86927932f, 0.49432121f}, -{0.87249601f, 0.48862124f}, {0.87567532f, 0.48290034f}, -{0.87881711f, 0.47715876f}, {0.88192126f, 0.47139674f}, -{0.88498764f, 0.46561452f}, {0.88801610f, 0.45981236f}, -{0.89100652f, 0.45399050f}, {0.89395878f, 0.44814919f}, -{0.89687274f, 0.44228869f}, {0.89974828f, 0.43640924f}, -{0.90258528f, 0.43051110f}, {0.90538362f, 0.42459451f}, -{0.90814317f, 0.41865974f}, {0.91086382f, 0.41270703f}, -{0.91354546f, 0.40673664f}, {0.91618796f, 0.40074883f}, -{0.91879121f, 0.39474386f}, {0.92135511f, 0.38872197f}, -{0.92387953f, 0.38268343f}, {0.92636438f, 0.37662850f}, -{0.92880955f, 0.37055744f}, {0.93121493f, 0.36447050f}, -{0.93358043f, 0.35836795f}, {0.93590593f, 0.35225005f}, -{0.93819134f, 0.34611706f}, {0.94043656f, 0.33996924f}, -{0.94264149f, 0.33380686f}, {0.94480605f, 0.32763018f}, -{0.94693013f, 0.32143947f}, {0.94901365f, 0.31523498f}, -{0.95105652f, 0.30901699f}, {0.95305864f, 0.30278577f}, -{0.95501994f, 0.29654157f}, {0.95694034f, 0.29028468f}, -{0.95881973f, 0.28401534f}, {0.96065806f, 0.27773385f}, -{0.96245524f, 0.27144045f}, {0.96421118f, 0.26513543f}, -{0.96592583f, 0.25881905f}, {0.96759909f, 0.25249158f}, -{0.96923091f, 0.24615329f}, {0.97082121f, 0.23980446f}, -{0.97236992f, 0.23344536f}, {0.97387698f, 0.22707626f}, -{0.97534232f, 0.22069744f}, {0.97676588f, 0.21430915f}, -{0.97814760f, 0.20791169f}, {0.97948742f, 0.20150532f}, -{0.98078528f, 0.19509032f}, {0.98204113f, 0.18866696f}, -{0.98325491f, 0.18223553f}, {0.98442657f, 0.17579628f}, -{0.98555606f, 0.16934950f}, {0.98664333f, 0.16289547f}, -{0.98768834f, 0.15643447f}, {0.98869104f, 0.14996676f}, -{0.98965139f, 0.14349262f}, {0.99056934f, 0.13701234f}, -{0.99144486f, 0.13052619f}, {0.99227791f, 0.12403445f}, -{0.99306846f, 0.11753740f}, {0.99381646f, 0.11103531f}, -{0.99452190f, 0.10452846f}, {0.99518473f, 0.098017140f}, -{0.99580493f, 0.091501619f}, {0.99638247f, 0.084982177f}, -{0.99691733f, 0.078459096f}, {0.99740949f, 0.071932653f}, -{0.99785892f, 0.065403129f}, {0.99826561f, 0.058870804f}, -{0.99862953f, 0.052335956f}, {0.99895068f, 0.045798867f}, -{0.99922904f, 0.039259816f}, {0.99946459f, 0.032719083f}, -{0.99965732f, 0.026176948f}, {0.99980724f, 0.019633692f}, -{0.99991433f, 0.013089596f}, {0.99997858f, 0.0065449380f}, + {1.0000000f, -0.0000000f}, {0.99997858f, -0.0065449380f}, + {0.99991433f, -0.013089596f}, {0.99980724f, -0.019633692f}, + {0.99965732f, -0.026176948f}, {0.99946459f, -0.032719083f}, + {0.99922904f, -0.039259816f}, {0.99895068f, -0.045798867f}, + {0.99862953f, -0.052335956f}, {0.99826561f, -0.058870804f}, + {0.99785892f, -0.065403129f}, {0.99740949f, -0.071932653f}, + {0.99691733f, -0.078459096f}, {0.99638247f, -0.084982177f}, + {0.99580493f, -0.091501619f}, {0.99518473f, -0.098017140f}, + {0.99452190f, -0.10452846f}, {0.99381646f, -0.11103531f}, + {0.99306846f, -0.11753740f}, {0.99227791f, -0.12403445f}, + {0.99144486f, -0.13052619f}, {0.99056934f, -0.13701234f}, + {0.98965139f, -0.14349262f}, {0.98869104f, -0.14996676f}, + {0.98768834f, -0.15643447f}, {0.98664333f, -0.16289547f}, + {0.98555606f, -0.16934950f}, {0.98442657f, -0.17579628f}, + {0.98325491f, -0.18223553f}, {0.98204113f, -0.18866696f}, + {0.98078528f, -0.19509032f}, {0.97948742f, -0.20150532f}, + {0.97814760f, -0.20791169f}, {0.97676588f, -0.21430915f}, + {0.97534232f, -0.22069744f}, {0.97387698f, -0.22707626f}, + {0.97236992f, -0.23344536f}, {0.97082121f, -0.23980446f}, + {0.96923091f, -0.24615329f}, {0.96759909f, -0.25249158f}, + {0.96592583f, -0.25881905f}, {0.96421118f, -0.26513543f}, + {0.96245524f, -0.27144045f}, {0.96065806f, -0.27773385f}, + {0.95881973f, -0.28401534f}, {0.95694034f, -0.29028468f}, + {0.95501994f, -0.29654157f}, {0.95305864f, -0.30278577f}, + {0.95105652f, -0.30901699f}, {0.94901365f, -0.31523498f}, + {0.94693013f, -0.32143947f}, {0.94480605f, -0.32763018f}, + {0.94264149f, -0.33380686f}, {0.94043656f, -0.33996924f}, + {0.93819134f, -0.34611706f}, {0.93590593f, -0.35225005f}, + {0.93358043f, -0.35836795f}, {0.93121493f, -0.36447050f}, + {0.92880955f, -0.37055744f}, {0.92636438f, -0.37662850f}, + {0.92387953f, -0.38268343f}, {0.92135511f, -0.38872197f}, + {0.91879121f, -0.39474386f}, {0.91618796f, -0.40074883f}, + {0.91354546f, -0.40673664f}, {0.91086382f, -0.41270703f}, + {0.90814317f, -0.41865974f}, {0.90538362f, -0.42459451f}, + {0.90258528f, -0.43051110f}, {0.89974828f, -0.43640924f}, + {0.89687274f, -0.44228869f}, {0.89395878f, -0.44814919f}, + {0.89100652f, -0.45399050f}, {0.88801610f, -0.45981236f}, + {0.88498764f, -0.46561452f}, {0.88192126f, -0.47139674f}, + {0.87881711f, -0.47715876f}, {0.87567532f, -0.48290034f}, + {0.87249601f, -0.48862124f}, {0.86927932f, -0.49432121f}, + {0.86602540f, -0.50000000f}, {0.86273439f, -0.50565737f}, + {0.85940641f, -0.51129309f}, {0.85604162f, -0.51690690f}, + {0.85264016f, -0.52249856f}, {0.84920218f, -0.52806785f}, + {0.84572782f, -0.53361452f}, {0.84221723f, -0.53913832f}, + {0.83867057f, -0.54463904f}, {0.83508798f, -0.55011642f}, + {0.83146961f, -0.55557023f}, {0.82781563f, -0.56100025f}, + {0.82412619f, -0.56640624f}, {0.82040144f, -0.57178796f}, + {0.81664156f, -0.57714519f}, {0.81284668f, -0.58247770f}, + {0.80901699f, -0.58778525f}, {0.80515265f, -0.59306763f}, + {0.80125381f, -0.59832460f}, {0.79732065f, -0.60355594f}, + {0.79335334f, -0.60876143f}, {0.78935204f, -0.61394084f}, + {0.78531693f, -0.61909395f}, {0.78124818f, -0.62422054f}, + {0.77714596f, -0.62932039f}, {0.77301045f, -0.63439328f}, + {0.76884183f, -0.63943900f}, {0.76464028f, -0.64445733f}, + {0.76040597f, -0.64944805f}, {0.75613908f, -0.65441095f}, + {0.75183981f, -0.65934582f}, {0.74750833f, -0.66425244f}, + {0.74314483f, -0.66913061f}, {0.73874949f, -0.67398011f}, + {0.73432251f, -0.67880075f}, {0.72986407f, -0.68359230f}, + {0.72537437f, -0.68835458f}, {0.72085360f, -0.69308736f}, + {0.71630194f, -0.69779046f}, {0.71171961f, -0.70246367f}, + {0.70710678f, -0.70710678f}, {0.70246367f, -0.71171961f}, + {0.69779046f, -0.71630194f}, {0.69308736f, -0.72085360f}, + {0.68835458f, -0.72537437f}, {0.68359230f, -0.72986407f}, + {0.67880075f, -0.73432251f}, {0.67398011f, -0.73874949f}, + {0.66913061f, -0.74314483f}, {0.66425244f, -0.74750833f}, + {0.65934582f, -0.75183981f}, {0.65441095f, -0.75613908f}, + {0.64944805f, -0.76040597f}, {0.64445733f, -0.76464028f}, + {0.63943900f, -0.76884183f}, {0.63439328f, -0.77301045f}, + {0.62932039f, -0.77714596f}, {0.62422054f, -0.78124818f}, + {0.61909395f, -0.78531693f}, {0.61394084f, -0.78935204f}, + {0.60876143f, -0.79335334f}, {0.60355594f, -0.79732065f}, + {0.59832460f, -0.80125381f}, {0.59306763f, -0.80515265f}, + {0.58778525f, -0.80901699f}, {0.58247770f, -0.81284668f}, + {0.57714519f, -0.81664156f}, {0.57178796f, -0.82040144f}, + {0.56640624f, -0.82412619f}, {0.56100025f, -0.82781563f}, + {0.55557023f, -0.83146961f}, {0.55011642f, -0.83508798f}, + {0.54463904f, -0.83867057f}, {0.53913832f, -0.84221723f}, + {0.53361452f, -0.84572782f}, {0.52806785f, -0.84920218f}, + {0.52249856f, -0.85264016f}, {0.51690690f, -0.85604162f}, + {0.51129309f, -0.85940641f}, {0.50565737f, -0.86273439f}, + {0.50000000f, -0.86602540f}, {0.49432121f, -0.86927932f}, + {0.48862124f, -0.87249601f}, {0.48290034f, -0.87567532f}, + {0.47715876f, -0.87881711f}, {0.47139674f, -0.88192126f}, + {0.46561452f, -0.88498764f}, {0.45981236f, -0.88801610f}, + {0.45399050f, -0.89100652f}, {0.44814919f, -0.89395878f}, + {0.44228869f, -0.89687274f}, {0.43640924f, -0.89974828f}, + {0.43051110f, -0.90258528f}, {0.42459451f, -0.90538362f}, + {0.41865974f, -0.90814317f}, {0.41270703f, -0.91086382f}, + {0.40673664f, -0.91354546f}, {0.40074883f, -0.91618796f}, + {0.39474386f, -0.91879121f}, {0.38872197f, -0.92135511f}, + {0.38268343f, -0.92387953f}, {0.37662850f, -0.92636438f}, + {0.37055744f, -0.92880955f}, {0.36447050f, -0.93121493f}, + {0.35836795f, -0.93358043f}, {0.35225005f, -0.93590593f}, + {0.34611706f, -0.93819134f}, {0.33996924f, -0.94043656f}, + {0.33380686f, -0.94264149f}, {0.32763018f, -0.94480605f}, + {0.32143947f, -0.94693013f}, {0.31523498f, -0.94901365f}, + {0.30901699f, -0.95105652f}, {0.30278577f, -0.95305864f}, + {0.29654157f, -0.95501994f}, {0.29028468f, -0.95694034f}, + {0.28401534f, -0.95881973f}, {0.27773385f, -0.96065806f}, + {0.27144045f, -0.96245524f}, {0.26513543f, -0.96421118f}, + {0.25881905f, -0.96592583f}, {0.25249158f, -0.96759909f}, + {0.24615329f, -0.96923091f}, {0.23980446f, -0.97082121f}, + {0.23344536f, -0.97236992f}, {0.22707626f, -0.97387698f}, + {0.22069744f, -0.97534232f}, {0.21430915f, -0.97676588f}, + {0.20791169f, -0.97814760f}, {0.20150532f, -0.97948742f}, + {0.19509032f, -0.98078528f}, {0.18866696f, -0.98204113f}, + {0.18223553f, -0.98325491f}, {0.17579628f, -0.98442657f}, + {0.16934950f, -0.98555606f}, {0.16289547f, -0.98664333f}, + {0.15643447f, -0.98768834f}, {0.14996676f, -0.98869104f}, + {0.14349262f, -0.98965139f}, {0.13701234f, -0.99056934f}, + {0.13052619f, -0.99144486f}, {0.12403445f, -0.99227791f}, + {0.11753740f, -0.99306846f}, {0.11103531f, -0.99381646f}, + {0.10452846f, -0.99452190f}, {0.098017140f, -0.99518473f}, + {0.091501619f, -0.99580493f}, {0.084982177f, -0.99638247f}, + {0.078459096f, -0.99691733f}, {0.071932653f, -0.99740949f}, + {0.065403129f, -0.99785892f}, {0.058870804f, -0.99826561f}, + {0.052335956f, -0.99862953f}, {0.045798867f, -0.99895068f}, + {0.039259816f, -0.99922904f}, {0.032719083f, -0.99946459f}, + {0.026176948f, -0.99965732f}, {0.019633692f, -0.99980724f}, + {0.013089596f, -0.99991433f}, {0.0065449380f, -0.99997858f}, + {6.1232340e-17f, -1.0000000f}, {-0.0065449380f, -0.99997858f}, + {-0.013089596f, -0.99991433f}, {-0.019633692f, -0.99980724f}, + {-0.026176948f, -0.99965732f}, {-0.032719083f, -0.99946459f}, + {-0.039259816f, -0.99922904f}, {-0.045798867f, -0.99895068f}, + {-0.052335956f, -0.99862953f}, {-0.058870804f, -0.99826561f}, + {-0.065403129f, -0.99785892f}, {-0.071932653f, -0.99740949f}, + {-0.078459096f, -0.99691733f}, {-0.084982177f, -0.99638247f}, + {-0.091501619f, -0.99580493f}, {-0.098017140f, -0.99518473f}, + {-0.10452846f, -0.99452190f}, {-0.11103531f, -0.99381646f}, + {-0.11753740f, -0.99306846f}, {-0.12403445f, -0.99227791f}, + {-0.13052619f, -0.99144486f}, {-0.13701234f, -0.99056934f}, + {-0.14349262f, -0.98965139f}, {-0.14996676f, -0.98869104f}, + {-0.15643447f, -0.98768834f}, {-0.16289547f, -0.98664333f}, + {-0.16934950f, -0.98555606f}, {-0.17579628f, -0.98442657f}, + {-0.18223553f, -0.98325491f}, {-0.18866696f, -0.98204113f}, + {-0.19509032f, -0.98078528f}, {-0.20150532f, -0.97948742f}, + {-0.20791169f, -0.97814760f}, {-0.21430915f, -0.97676588f}, + {-0.22069744f, -0.97534232f}, {-0.22707626f, -0.97387698f}, + {-0.23344536f, -0.97236992f}, {-0.23980446f, -0.97082121f}, + {-0.24615329f, -0.96923091f}, {-0.25249158f, -0.96759909f}, + {-0.25881905f, -0.96592583f}, {-0.26513543f, -0.96421118f}, + {-0.27144045f, -0.96245524f}, {-0.27773385f, -0.96065806f}, + {-0.28401534f, -0.95881973f}, {-0.29028468f, -0.95694034f}, + {-0.29654157f, -0.95501994f}, {-0.30278577f, -0.95305864f}, + {-0.30901699f, -0.95105652f}, {-0.31523498f, -0.94901365f}, + {-0.32143947f, -0.94693013f}, {-0.32763018f, -0.94480605f}, + {-0.33380686f, -0.94264149f}, {-0.33996924f, -0.94043656f}, + {-0.34611706f, -0.93819134f}, {-0.35225005f, -0.93590593f}, + {-0.35836795f, -0.93358043f}, {-0.36447050f, -0.93121493f}, + {-0.37055744f, -0.92880955f}, {-0.37662850f, -0.92636438f}, + {-0.38268343f, -0.92387953f}, {-0.38872197f, -0.92135511f}, + {-0.39474386f, -0.91879121f}, {-0.40074883f, -0.91618796f}, + {-0.40673664f, -0.91354546f}, {-0.41270703f, -0.91086382f}, + {-0.41865974f, -0.90814317f}, {-0.42459451f, -0.90538362f}, + {-0.43051110f, -0.90258528f}, {-0.43640924f, -0.89974828f}, + {-0.44228869f, -0.89687274f}, {-0.44814919f, -0.89395878f}, + {-0.45399050f, -0.89100652f}, {-0.45981236f, -0.88801610f}, + {-0.46561452f, -0.88498764f}, {-0.47139674f, -0.88192126f}, + {-0.47715876f, -0.87881711f}, {-0.48290034f, -0.87567532f}, + {-0.48862124f, -0.87249601f}, {-0.49432121f, -0.86927932f}, + {-0.50000000f, -0.86602540f}, {-0.50565737f, -0.86273439f}, + {-0.51129309f, -0.85940641f}, {-0.51690690f, -0.85604162f}, + {-0.52249856f, -0.85264016f}, {-0.52806785f, -0.84920218f}, + {-0.53361452f, -0.84572782f}, {-0.53913832f, -0.84221723f}, + {-0.54463904f, -0.83867057f}, {-0.55011642f, -0.83508798f}, + {-0.55557023f, -0.83146961f}, {-0.56100025f, -0.82781563f}, + {-0.56640624f, -0.82412619f}, {-0.57178796f, -0.82040144f}, + {-0.57714519f, -0.81664156f}, {-0.58247770f, -0.81284668f}, + {-0.58778525f, -0.80901699f}, {-0.59306763f, -0.80515265f}, + {-0.59832460f, -0.80125381f}, {-0.60355594f, -0.79732065f}, + {-0.60876143f, -0.79335334f}, {-0.61394084f, -0.78935204f}, + {-0.61909395f, -0.78531693f}, {-0.62422054f, -0.78124818f}, + {-0.62932039f, -0.77714596f}, {-0.63439328f, -0.77301045f}, + {-0.63943900f, -0.76884183f}, {-0.64445733f, -0.76464028f}, + {-0.64944805f, -0.76040597f}, {-0.65441095f, -0.75613908f}, + {-0.65934582f, -0.75183981f}, {-0.66425244f, -0.74750833f}, + {-0.66913061f, -0.74314483f}, {-0.67398011f, -0.73874949f}, + {-0.67880075f, -0.73432251f}, {-0.68359230f, -0.72986407f}, + {-0.68835458f, -0.72537437f}, {-0.69308736f, -0.72085360f}, + {-0.69779046f, -0.71630194f}, {-0.70246367f, -0.71171961f}, + {-0.70710678f, -0.70710678f}, {-0.71171961f, -0.70246367f}, + {-0.71630194f, -0.69779046f}, {-0.72085360f, -0.69308736f}, + {-0.72537437f, -0.68835458f}, {-0.72986407f, -0.68359230f}, + {-0.73432251f, -0.67880075f}, {-0.73874949f, -0.67398011f}, + {-0.74314483f, -0.66913061f}, {-0.74750833f, -0.66425244f}, + {-0.75183981f, -0.65934582f}, {-0.75613908f, -0.65441095f}, + {-0.76040597f, -0.64944805f}, {-0.76464028f, -0.64445733f}, + {-0.76884183f, -0.63943900f}, {-0.77301045f, -0.63439328f}, + {-0.77714596f, -0.62932039f}, {-0.78124818f, -0.62422054f}, + {-0.78531693f, -0.61909395f}, {-0.78935204f, -0.61394084f}, + {-0.79335334f, -0.60876143f}, {-0.79732065f, -0.60355594f}, + {-0.80125381f, -0.59832460f}, {-0.80515265f, -0.59306763f}, + {-0.80901699f, -0.58778525f}, {-0.81284668f, -0.58247770f}, + {-0.81664156f, -0.57714519f}, {-0.82040144f, -0.57178796f}, + {-0.82412619f, -0.56640624f}, {-0.82781563f, -0.56100025f}, + {-0.83146961f, -0.55557023f}, {-0.83508798f, -0.55011642f}, + {-0.83867057f, -0.54463904f}, {-0.84221723f, -0.53913832f}, + {-0.84572782f, -0.53361452f}, {-0.84920218f, -0.52806785f}, + {-0.85264016f, -0.52249856f}, {-0.85604162f, -0.51690690f}, + {-0.85940641f, -0.51129309f}, {-0.86273439f, -0.50565737f}, + {-0.86602540f, -0.50000000f}, {-0.86927932f, -0.49432121f}, + {-0.87249601f, -0.48862124f}, {-0.87567532f, -0.48290034f}, + {-0.87881711f, -0.47715876f}, {-0.88192126f, -0.47139674f}, + {-0.88498764f, -0.46561452f}, {-0.88801610f, -0.45981236f}, + {-0.89100652f, -0.45399050f}, {-0.89395878f, -0.44814919f}, + {-0.89687274f, -0.44228869f}, {-0.89974828f, -0.43640924f}, + {-0.90258528f, -0.43051110f}, {-0.90538362f, -0.42459451f}, + {-0.90814317f, -0.41865974f}, {-0.91086382f, -0.41270703f}, + {-0.91354546f, -0.40673664f}, {-0.91618796f, -0.40074883f}, + {-0.91879121f, -0.39474386f}, {-0.92135511f, -0.38872197f}, + {-0.92387953f, -0.38268343f}, {-0.92636438f, -0.37662850f}, + {-0.92880955f, -0.37055744f}, {-0.93121493f, -0.36447050f}, + {-0.93358043f, -0.35836795f}, {-0.93590593f, -0.35225005f}, + {-0.93819134f, -0.34611706f}, {-0.94043656f, -0.33996924f}, + {-0.94264149f, -0.33380686f}, {-0.94480605f, -0.32763018f}, + {-0.94693013f, -0.32143947f}, {-0.94901365f, -0.31523498f}, + {-0.95105652f, -0.30901699f}, {-0.95305864f, -0.30278577f}, + {-0.95501994f, -0.29654157f}, {-0.95694034f, -0.29028468f}, + {-0.95881973f, -0.28401534f}, {-0.96065806f, -0.27773385f}, + {-0.96245524f, -0.27144045f}, {-0.96421118f, -0.26513543f}, + {-0.96592583f, -0.25881905f}, {-0.96759909f, -0.25249158f}, + {-0.96923091f, -0.24615329f}, {-0.97082121f, -0.23980446f}, + {-0.97236992f, -0.23344536f}, {-0.97387698f, -0.22707626f}, + {-0.97534232f, -0.22069744f}, {-0.97676588f, -0.21430915f}, + {-0.97814760f, -0.20791169f}, {-0.97948742f, -0.20150532f}, + {-0.98078528f, -0.19509032f}, {-0.98204113f, -0.18866696f}, + {-0.98325491f, -0.18223553f}, {-0.98442657f, -0.17579628f}, + {-0.98555606f, -0.16934950f}, {-0.98664333f, -0.16289547f}, + {-0.98768834f, -0.15643447f}, {-0.98869104f, -0.14996676f}, + {-0.98965139f, -0.14349262f}, {-0.99056934f, -0.13701234f}, + {-0.99144486f, -0.13052619f}, {-0.99227791f, -0.12403445f}, + {-0.99306846f, -0.11753740f}, {-0.99381646f, -0.11103531f}, + {-0.99452190f, -0.10452846f}, {-0.99518473f, -0.098017140f}, + {-0.99580493f, -0.091501619f}, {-0.99638247f, -0.084982177f}, + {-0.99691733f, -0.078459096f}, {-0.99740949f, -0.071932653f}, + {-0.99785892f, -0.065403129f}, {-0.99826561f, -0.058870804f}, + {-0.99862953f, -0.052335956f}, {-0.99895068f, -0.045798867f}, + {-0.99922904f, -0.039259816f}, {-0.99946459f, -0.032719083f}, + {-0.99965732f, -0.026176948f}, {-0.99980724f, -0.019633692f}, + {-0.99991433f, -0.013089596f}, {-0.99997858f, -0.0065449380f}, + {-1.0000000f, -1.2246468e-16f}, {-0.99997858f, 0.0065449380f}, + {-0.99991433f, 0.013089596f}, {-0.99980724f, 0.019633692f}, + {-0.99965732f, 0.026176948f}, {-0.99946459f, 0.032719083f}, + {-0.99922904f, 0.039259816f}, {-0.99895068f, 0.045798867f}, + {-0.99862953f, 0.052335956f}, {-0.99826561f, 0.058870804f}, + {-0.99785892f, 0.065403129f}, {-0.99740949f, 0.071932653f}, + {-0.99691733f, 0.078459096f}, {-0.99638247f, 0.084982177f}, + {-0.99580493f, 0.091501619f}, {-0.99518473f, 0.098017140f}, + {-0.99452190f, 0.10452846f}, {-0.99381646f, 0.11103531f}, + {-0.99306846f, 0.11753740f}, {-0.99227791f, 0.12403445f}, + {-0.99144486f, 0.13052619f}, {-0.99056934f, 0.13701234f}, + {-0.98965139f, 0.14349262f}, {-0.98869104f, 0.14996676f}, + {-0.98768834f, 0.15643447f}, {-0.98664333f, 0.16289547f}, + {-0.98555606f, 0.16934950f}, {-0.98442657f, 0.17579628f}, + {-0.98325491f, 0.18223553f}, {-0.98204113f, 0.18866696f}, + {-0.98078528f, 0.19509032f}, {-0.97948742f, 0.20150532f}, + {-0.97814760f, 0.20791169f}, {-0.97676588f, 0.21430915f}, + {-0.97534232f, 0.22069744f}, {-0.97387698f, 0.22707626f}, + {-0.97236992f, 0.23344536f}, {-0.97082121f, 0.23980446f}, + {-0.96923091f, 0.24615329f}, {-0.96759909f, 0.25249158f}, + {-0.96592583f, 0.25881905f}, {-0.96421118f, 0.26513543f}, + {-0.96245524f, 0.27144045f}, {-0.96065806f, 0.27773385f}, + {-0.95881973f, 0.28401534f}, {-0.95694034f, 0.29028468f}, + {-0.95501994f, 0.29654157f}, {-0.95305864f, 0.30278577f}, + {-0.95105652f, 0.30901699f}, {-0.94901365f, 0.31523498f}, + {-0.94693013f, 0.32143947f}, {-0.94480605f, 0.32763018f}, + {-0.94264149f, 0.33380686f}, {-0.94043656f, 0.33996924f}, + {-0.93819134f, 0.34611706f}, {-0.93590593f, 0.35225005f}, + {-0.93358043f, 0.35836795f}, {-0.93121493f, 0.36447050f}, + {-0.92880955f, 0.37055744f}, {-0.92636438f, 0.37662850f}, + {-0.92387953f, 0.38268343f}, {-0.92135511f, 0.38872197f}, + {-0.91879121f, 0.39474386f}, {-0.91618796f, 0.40074883f}, + {-0.91354546f, 0.40673664f}, {-0.91086382f, 0.41270703f}, + {-0.90814317f, 0.41865974f}, {-0.90538362f, 0.42459451f}, + {-0.90258528f, 0.43051110f}, {-0.89974828f, 0.43640924f}, + {-0.89687274f, 0.44228869f}, {-0.89395878f, 0.44814919f}, + {-0.89100652f, 0.45399050f}, {-0.88801610f, 0.45981236f}, + {-0.88498764f, 0.46561452f}, {-0.88192126f, 0.47139674f}, + {-0.87881711f, 0.47715876f}, {-0.87567532f, 0.48290034f}, + {-0.87249601f, 0.48862124f}, {-0.86927932f, 0.49432121f}, + {-0.86602540f, 0.50000000f}, {-0.86273439f, 0.50565737f}, + {-0.85940641f, 0.51129309f}, {-0.85604162f, 0.51690690f}, + {-0.85264016f, 0.52249856f}, {-0.84920218f, 0.52806785f}, + {-0.84572782f, 0.53361452f}, {-0.84221723f, 0.53913832f}, + {-0.83867057f, 0.54463904f}, {-0.83508798f, 0.55011642f}, + {-0.83146961f, 0.55557023f}, {-0.82781563f, 0.56100025f}, + {-0.82412619f, 0.56640624f}, {-0.82040144f, 0.57178796f}, + {-0.81664156f, 0.57714519f}, {-0.81284668f, 0.58247770f}, + {-0.80901699f, 0.58778525f}, {-0.80515265f, 0.59306763f}, + {-0.80125381f, 0.59832460f}, {-0.79732065f, 0.60355594f}, + {-0.79335334f, 0.60876143f}, {-0.78935204f, 0.61394084f}, + {-0.78531693f, 0.61909395f}, {-0.78124818f, 0.62422054f}, + {-0.77714596f, 0.62932039f}, {-0.77301045f, 0.63439328f}, + {-0.76884183f, 0.63943900f}, {-0.76464028f, 0.64445733f}, + {-0.76040597f, 0.64944805f}, {-0.75613908f, 0.65441095f}, + {-0.75183981f, 0.65934582f}, {-0.74750833f, 0.66425244f}, + {-0.74314483f, 0.66913061f}, {-0.73874949f, 0.67398011f}, + {-0.73432251f, 0.67880075f}, {-0.72986407f, 0.68359230f}, + {-0.72537437f, 0.68835458f}, {-0.72085360f, 0.69308736f}, + {-0.71630194f, 0.69779046f}, {-0.71171961f, 0.70246367f}, + {-0.70710678f, 0.70710678f}, {-0.70246367f, 0.71171961f}, + {-0.69779046f, 0.71630194f}, {-0.69308736f, 0.72085360f}, + {-0.68835458f, 0.72537437f}, {-0.68359230f, 0.72986407f}, + {-0.67880075f, 0.73432251f}, {-0.67398011f, 0.73874949f}, + {-0.66913061f, 0.74314483f}, {-0.66425244f, 0.74750833f}, + {-0.65934582f, 0.75183981f}, {-0.65441095f, 0.75613908f}, + {-0.64944805f, 0.76040597f}, {-0.64445733f, 0.76464028f}, + {-0.63943900f, 0.76884183f}, {-0.63439328f, 0.77301045f}, + {-0.62932039f, 0.77714596f}, {-0.62422054f, 0.78124818f}, + {-0.61909395f, 0.78531693f}, {-0.61394084f, 0.78935204f}, + {-0.60876143f, 0.79335334f}, {-0.60355594f, 0.79732065f}, + {-0.59832460f, 0.80125381f}, {-0.59306763f, 0.80515265f}, + {-0.58778525f, 0.80901699f}, {-0.58247770f, 0.81284668f}, + {-0.57714519f, 0.81664156f}, {-0.57178796f, 0.82040144f}, + {-0.56640624f, 0.82412619f}, {-0.56100025f, 0.82781563f}, + {-0.55557023f, 0.83146961f}, {-0.55011642f, 0.83508798f}, + {-0.54463904f, 0.83867057f}, {-0.53913832f, 0.84221723f}, + {-0.53361452f, 0.84572782f}, {-0.52806785f, 0.84920218f}, + {-0.52249856f, 0.85264016f}, {-0.51690690f, 0.85604162f}, + {-0.51129309f, 0.85940641f}, {-0.50565737f, 0.86273439f}, + {-0.50000000f, 0.86602540f}, {-0.49432121f, 0.86927932f}, + {-0.48862124f, 0.87249601f}, {-0.48290034f, 0.87567532f}, + {-0.47715876f, 0.87881711f}, {-0.47139674f, 0.88192126f}, + {-0.46561452f, 0.88498764f}, {-0.45981236f, 0.88801610f}, + {-0.45399050f, 0.89100652f}, {-0.44814919f, 0.89395878f}, + {-0.44228869f, 0.89687274f}, {-0.43640924f, 0.89974828f}, + {-0.43051110f, 0.90258528f}, {-0.42459451f, 0.90538362f}, + {-0.41865974f, 0.90814317f}, {-0.41270703f, 0.91086382f}, + {-0.40673664f, 0.91354546f}, {-0.40074883f, 0.91618796f}, + {-0.39474386f, 0.91879121f}, {-0.38872197f, 0.92135511f}, + {-0.38268343f, 0.92387953f}, {-0.37662850f, 0.92636438f}, + {-0.37055744f, 0.92880955f}, {-0.36447050f, 0.93121493f}, + {-0.35836795f, 0.93358043f}, {-0.35225005f, 0.93590593f}, + {-0.34611706f, 0.93819134f}, {-0.33996924f, 0.94043656f}, + {-0.33380686f, 0.94264149f}, {-0.32763018f, 0.94480605f}, + {-0.32143947f, 0.94693013f}, {-0.31523498f, 0.94901365f}, + {-0.30901699f, 0.95105652f}, {-0.30278577f, 0.95305864f}, + {-0.29654157f, 0.95501994f}, {-0.29028468f, 0.95694034f}, + {-0.28401534f, 0.95881973f}, {-0.27773385f, 0.96065806f}, + {-0.27144045f, 0.96245524f}, {-0.26513543f, 0.96421118f}, + {-0.25881905f, 0.96592583f}, {-0.25249158f, 0.96759909f}, + {-0.24615329f, 0.96923091f}, {-0.23980446f, 0.97082121f}, + {-0.23344536f, 0.97236992f}, {-0.22707626f, 0.97387698f}, + {-0.22069744f, 0.97534232f}, {-0.21430915f, 0.97676588f}, + {-0.20791169f, 0.97814760f}, {-0.20150532f, 0.97948742f}, + {-0.19509032f, 0.98078528f}, {-0.18866696f, 0.98204113f}, + {-0.18223553f, 0.98325491f}, {-0.17579628f, 0.98442657f}, + {-0.16934950f, 0.98555606f}, {-0.16289547f, 0.98664333f}, + {-0.15643447f, 0.98768834f}, {-0.14996676f, 0.98869104f}, + {-0.14349262f, 0.98965139f}, {-0.13701234f, 0.99056934f}, + {-0.13052619f, 0.99144486f}, {-0.12403445f, 0.99227791f}, + {-0.11753740f, 0.99306846f}, {-0.11103531f, 0.99381646f}, + {-0.10452846f, 0.99452190f}, {-0.098017140f, 0.99518473f}, + {-0.091501619f, 0.99580493f}, {-0.084982177f, 0.99638247f}, + {-0.078459096f, 0.99691733f}, {-0.071932653f, 0.99740949f}, + {-0.065403129f, 0.99785892f}, {-0.058870804f, 0.99826561f}, + {-0.052335956f, 0.99862953f}, {-0.045798867f, 0.99895068f}, + {-0.039259816f, 0.99922904f}, {-0.032719083f, 0.99946459f}, + {-0.026176948f, 0.99965732f}, {-0.019633692f, 0.99980724f}, + {-0.013089596f, 0.99991433f}, {-0.0065449380f, 0.99997858f}, + {-1.8369702e-16f, 1.0000000f}, {0.0065449380f, 0.99997858f}, + {0.013089596f, 0.99991433f}, {0.019633692f, 0.99980724f}, + {0.026176948f, 0.99965732f}, {0.032719083f, 0.99946459f}, + {0.039259816f, 0.99922904f}, {0.045798867f, 0.99895068f}, + {0.052335956f, 0.99862953f}, {0.058870804f, 0.99826561f}, + {0.065403129f, 0.99785892f}, {0.071932653f, 0.99740949f}, + {0.078459096f, 0.99691733f}, {0.084982177f, 0.99638247f}, + {0.091501619f, 0.99580493f}, {0.098017140f, 0.99518473f}, + {0.10452846f, 0.99452190f}, {0.11103531f, 0.99381646f}, + {0.11753740f, 0.99306846f}, {0.12403445f, 0.99227791f}, + {0.13052619f, 0.99144486f}, {0.13701234f, 0.99056934f}, + {0.14349262f, 0.98965139f}, {0.14996676f, 0.98869104f}, + {0.15643447f, 0.98768834f}, {0.16289547f, 0.98664333f}, + {0.16934950f, 0.98555606f}, {0.17579628f, 0.98442657f}, + {0.18223553f, 0.98325491f}, {0.18866696f, 0.98204113f}, + {0.19509032f, 0.98078528f}, {0.20150532f, 0.97948742f}, + {0.20791169f, 0.97814760f}, {0.21430915f, 0.97676588f}, + {0.22069744f, 0.97534232f}, {0.22707626f, 0.97387698f}, + {0.23344536f, 0.97236992f}, {0.23980446f, 0.97082121f}, + {0.24615329f, 0.96923091f}, {0.25249158f, 0.96759909f}, + {0.25881905f, 0.96592583f}, {0.26513543f, 0.96421118f}, + {0.27144045f, 0.96245524f}, {0.27773385f, 0.96065806f}, + {0.28401534f, 0.95881973f}, {0.29028468f, 0.95694034f}, + {0.29654157f, 0.95501994f}, {0.30278577f, 0.95305864f}, + {0.30901699f, 0.95105652f}, {0.31523498f, 0.94901365f}, + {0.32143947f, 0.94693013f}, {0.32763018f, 0.94480605f}, + {0.33380686f, 0.94264149f}, {0.33996924f, 0.94043656f}, + {0.34611706f, 0.93819134f}, {0.35225005f, 0.93590593f}, + {0.35836795f, 0.93358043f}, {0.36447050f, 0.93121493f}, + {0.37055744f, 0.92880955f}, {0.37662850f, 0.92636438f}, + {0.38268343f, 0.92387953f}, {0.38872197f, 0.92135511f}, + {0.39474386f, 0.91879121f}, {0.40074883f, 0.91618796f}, + {0.40673664f, 0.91354546f}, {0.41270703f, 0.91086382f}, + {0.41865974f, 0.90814317f}, {0.42459451f, 0.90538362f}, + {0.43051110f, 0.90258528f}, {0.43640924f, 0.89974828f}, + {0.44228869f, 0.89687274f}, {0.44814919f, 0.89395878f}, + {0.45399050f, 0.89100652f}, {0.45981236f, 0.88801610f}, + {0.46561452f, 0.88498764f}, {0.47139674f, 0.88192126f}, + {0.47715876f, 0.87881711f}, {0.48290034f, 0.87567532f}, + {0.48862124f, 0.87249601f}, {0.49432121f, 0.86927932f}, + {0.50000000f, 0.86602540f}, {0.50565737f, 0.86273439f}, + {0.51129309f, 0.85940641f}, {0.51690690f, 0.85604162f}, + {0.52249856f, 0.85264016f}, {0.52806785f, 0.84920218f}, + {0.53361452f, 0.84572782f}, {0.53913832f, 0.84221723f}, + {0.54463904f, 0.83867057f}, {0.55011642f, 0.83508798f}, + {0.55557023f, 0.83146961f}, {0.56100025f, 0.82781563f}, + {0.56640624f, 0.82412619f}, {0.57178796f, 0.82040144f}, + {0.57714519f, 0.81664156f}, {0.58247770f, 0.81284668f}, + {0.58778525f, 0.80901699f}, {0.59306763f, 0.80515265f}, + {0.59832460f, 0.80125381f}, {0.60355594f, 0.79732065f}, + {0.60876143f, 0.79335334f}, {0.61394084f, 0.78935204f}, + {0.61909395f, 0.78531693f}, {0.62422054f, 0.78124818f}, + {0.62932039f, 0.77714596f}, {0.63439328f, 0.77301045f}, + {0.63943900f, 0.76884183f}, {0.64445733f, 0.76464028f}, + {0.64944805f, 0.76040597f}, {0.65441095f, 0.75613908f}, + {0.65934582f, 0.75183981f}, {0.66425244f, 0.74750833f}, + {0.66913061f, 0.74314483f}, {0.67398011f, 0.73874949f}, + {0.67880075f, 0.73432251f}, {0.68359230f, 0.72986407f}, + {0.68835458f, 0.72537437f}, {0.69308736f, 0.72085360f}, + {0.69779046f, 0.71630194f}, {0.70246367f, 0.71171961f}, + {0.70710678f, 0.70710678f}, {0.71171961f, 0.70246367f}, + {0.71630194f, 0.69779046f}, {0.72085360f, 0.69308736f}, + {0.72537437f, 0.68835458f}, {0.72986407f, 0.68359230f}, + {0.73432251f, 0.67880075f}, {0.73874949f, 0.67398011f}, + {0.74314483f, 0.66913061f}, {0.74750833f, 0.66425244f}, + {0.75183981f, 0.65934582f}, {0.75613908f, 0.65441095f}, + {0.76040597f, 0.64944805f}, {0.76464028f, 0.64445733f}, + {0.76884183f, 0.63943900f}, {0.77301045f, 0.63439328f}, + {0.77714596f, 0.62932039f}, {0.78124818f, 0.62422054f}, + {0.78531693f, 0.61909395f}, {0.78935204f, 0.61394084f}, + {0.79335334f, 0.60876143f}, {0.79732065f, 0.60355594f}, + {0.80125381f, 0.59832460f}, {0.80515265f, 0.59306763f}, + {0.80901699f, 0.58778525f}, {0.81284668f, 0.58247770f}, + {0.81664156f, 0.57714519f}, {0.82040144f, 0.57178796f}, + {0.82412619f, 0.56640624f}, {0.82781563f, 0.56100025f}, + {0.83146961f, 0.55557023f}, {0.83508798f, 0.55011642f}, + {0.83867057f, 0.54463904f}, {0.84221723f, 0.53913832f}, + {0.84572782f, 0.53361452f}, {0.84920218f, 0.52806785f}, + {0.85264016f, 0.52249856f}, {0.85604162f, 0.51690690f}, + {0.85940641f, 0.51129309f}, {0.86273439f, 0.50565737f}, + {0.86602540f, 0.50000000f}, {0.86927932f, 0.49432121f}, + {0.87249601f, 0.48862124f}, {0.87567532f, 0.48290034f}, + {0.87881711f, 0.47715876f}, {0.88192126f, 0.47139674f}, + {0.88498764f, 0.46561452f}, {0.88801610f, 0.45981236f}, + {0.89100652f, 0.45399050f}, {0.89395878f, 0.44814919f}, + {0.89687274f, 0.44228869f}, {0.89974828f, 0.43640924f}, + {0.90258528f, 0.43051110f}, {0.90538362f, 0.42459451f}, + {0.90814317f, 0.41865974f}, {0.91086382f, 0.41270703f}, + {0.91354546f, 0.40673664f}, {0.91618796f, 0.40074883f}, + {0.91879121f, 0.39474386f}, {0.92135511f, 0.38872197f}, + {0.92387953f, 0.38268343f}, {0.92636438f, 0.37662850f}, + {0.92880955f, 0.37055744f}, {0.93121493f, 0.36447050f}, + {0.93358043f, 0.35836795f}, {0.93590593f, 0.35225005f}, + {0.93819134f, 0.34611706f}, {0.94043656f, 0.33996924f}, + {0.94264149f, 0.33380686f}, {0.94480605f, 0.32763018f}, + {0.94693013f, 0.32143947f}, {0.94901365f, 0.31523498f}, + {0.95105652f, 0.30901699f}, {0.95305864f, 0.30278577f}, + {0.95501994f, 0.29654157f}, {0.95694034f, 0.29028468f}, + {0.95881973f, 0.28401534f}, {0.96065806f, 0.27773385f}, + {0.96245524f, 0.27144045f}, {0.96421118f, 0.26513543f}, + {0.96592583f, 0.25881905f}, {0.96759909f, 0.25249158f}, + {0.96923091f, 0.24615329f}, {0.97082121f, 0.23980446f}, + {0.97236992f, 0.23344536f}, {0.97387698f, 0.22707626f}, + {0.97534232f, 0.22069744f}, {0.97676588f, 0.21430915f}, + {0.97814760f, 0.20791169f}, {0.97948742f, 0.20150532f}, + {0.98078528f, 0.19509032f}, {0.98204113f, 0.18866696f}, + {0.98325491f, 0.18223553f}, {0.98442657f, 0.17579628f}, + {0.98555606f, 0.16934950f}, {0.98664333f, 0.16289547f}, + {0.98768834f, 0.15643447f}, {0.98869104f, 0.14996676f}, + {0.98965139f, 0.14349262f}, {0.99056934f, 0.13701234f}, + {0.99144486f, 0.13052619f}, {0.99227791f, 0.12403445f}, + {0.99306846f, 0.11753740f}, {0.99381646f, 0.11103531f}, + {0.99452190f, 0.10452846f}, {0.99518473f, 0.098017140f}, + {0.99580493f, 0.091501619f}, {0.99638247f, 0.084982177f}, + {0.99691733f, 0.078459096f}, {0.99740949f, 0.071932653f}, + {0.99785892f, 0.065403129f}, {0.99826561f, 0.058870804f}, + {0.99862953f, 0.052335956f}, {0.99895068f, 0.045798867f}, + {0.99922904f, 0.039259816f}, {0.99946459f, 0.032719083f}, + {0.99965732f, 0.026176948f}, {0.99980724f, 0.019633692f}, + {0.99991433f, 0.013089596f}, {0.99997858f, 0.0065449380f}, }; -#ifndef FFT_BITREV960 -#define FFT_BITREV960 -static const opus_int16 fft_bitrev960[960] = { -0, 192, 384, 576, 768, 64, 256, 448, 640, 832, 128, 320, 512, 704, 896, -16, 208, 400, 592, 784, 80, 272, 464, 656, 848, 144, 336, 528, 720, 912, -32, 224, 416, 608, 800, 96, 288, 480, 672, 864, 160, 352, 544, 736, 928, -48, 240, 432, 624, 816, 112, 304, 496, 688, 880, 176, 368, 560, 752, 944, -4, 196, 388, 580, 772, 68, 260, 452, 644, 836, 132, 324, 516, 708, 900, -20, 212, 404, 596, 788, 84, 276, 468, 660, 852, 148, 340, 532, 724, 916, -36, 228, 420, 612, 804, 100, 292, 484, 676, 868, 164, 356, 548, 740, 932, -52, 244, 436, 628, 820, 116, 308, 500, 692, 884, 180, 372, 564, 756, 948, -8, 200, 392, 584, 776, 72, 264, 456, 648, 840, 136, 328, 520, 712, 904, -24, 216, 408, 600, 792, 88, 280, 472, 664, 856, 152, 344, 536, 728, 920, -40, 232, 424, 616, 808, 104, 296, 488, 680, 872, 168, 360, 552, 744, 936, -56, 248, 440, 632, 824, 120, 312, 504, 696, 888, 184, 376, 568, 760, 952, -12, 204, 396, 588, 780, 76, 268, 460, 652, 844, 140, 332, 524, 716, 908, -28, 220, 412, 604, 796, 92, 284, 476, 668, 860, 156, 348, 540, 732, 924, -44, 236, 428, 620, 812, 108, 300, 492, 684, 876, 172, 364, 556, 748, 940, -60, 252, 444, 636, 828, 124, 316, 508, 700, 892, 188, 380, 572, 764, 956, -1, 193, 385, 577, 769, 65, 257, 449, 641, 833, 129, 321, 513, 705, 897, -17, 209, 401, 593, 785, 81, 273, 465, 657, 849, 145, 337, 529, 721, 913, -33, 225, 417, 609, 801, 97, 289, 481, 673, 865, 161, 353, 545, 737, 929, -49, 241, 433, 625, 817, 113, 305, 497, 689, 881, 177, 369, 561, 753, 945, -5, 197, 389, 581, 773, 69, 261, 453, 645, 837, 133, 325, 517, 709, 901, -21, 213, 405, 597, 789, 85, 277, 469, 661, 853, 149, 341, 533, 725, 917, -37, 229, 421, 613, 805, 101, 293, 485, 677, 869, 165, 357, 549, 741, 933, -53, 245, 437, 629, 821, 117, 309, 501, 693, 885, 181, 373, 565, 757, 949, -9, 201, 393, 585, 777, 73, 265, 457, 649, 841, 137, 329, 521, 713, 905, -25, 217, 409, 601, 793, 89, 281, 473, 665, 857, 153, 345, 537, 729, 921, -41, 233, 425, 617, 809, 105, 297, 489, 681, 873, 169, 361, 553, 745, 937, -57, 249, 441, 633, 825, 121, 313, 505, 697, 889, 185, 377, 569, 761, 953, -13, 205, 397, 589, 781, 77, 269, 461, 653, 845, 141, 333, 525, 717, 909, -29, 221, 413, 605, 797, 93, 285, 477, 669, 861, 157, 349, 541, 733, 925, -45, 237, 429, 621, 813, 109, 301, 493, 685, 877, 173, 365, 557, 749, 941, -61, 253, 445, 637, 829, 125, 317, 509, 701, 893, 189, 381, 573, 765, 957, -2, 194, 386, 578, 770, 66, 258, 450, 642, 834, 130, 322, 514, 706, 898, -18, 210, 402, 594, 786, 82, 274, 466, 658, 850, 146, 338, 530, 722, 914, -34, 226, 418, 610, 802, 98, 290, 482, 674, 866, 162, 354, 546, 738, 930, -50, 242, 434, 626, 818, 114, 306, 498, 690, 882, 178, 370, 562, 754, 946, -6, 198, 390, 582, 774, 70, 262, 454, 646, 838, 134, 326, 518, 710, 902, -22, 214, 406, 598, 790, 86, 278, 470, 662, 854, 150, 342, 534, 726, 918, -38, 230, 422, 614, 806, 102, 294, 486, 678, 870, 166, 358, 550, 742, 934, -54, 246, 438, 630, 822, 118, 310, 502, 694, 886, 182, 374, 566, 758, 950, -10, 202, 394, 586, 778, 74, 266, 458, 650, 842, 138, 330, 522, 714, 906, -26, 218, 410, 602, 794, 90, 282, 474, 666, 858, 154, 346, 538, 730, 922, -42, 234, 426, 618, 810, 106, 298, 490, 682, 874, 170, 362, 554, 746, 938, -58, 250, 442, 634, 826, 122, 314, 506, 698, 890, 186, 378, 570, 762, 954, -14, 206, 398, 590, 782, 78, 270, 462, 654, 846, 142, 334, 526, 718, 910, -30, 222, 414, 606, 798, 94, 286, 478, 670, 862, 158, 350, 542, 734, 926, -46, 238, 430, 622, 814, 110, 302, 494, 686, 878, 174, 366, 558, 750, 942, -62, 254, 446, 638, 830, 126, 318, 510, 702, 894, 190, 382, 574, 766, 958, -3, 195, 387, 579, 771, 67, 259, 451, 643, 835, 131, 323, 515, 707, 899, -19, 211, 403, 595, 787, 83, 275, 467, 659, 851, 147, 339, 531, 723, 915, -35, 227, 419, 611, 803, 99, 291, 483, 675, 867, 163, 355, 547, 739, 931, -51, 243, 435, 627, 819, 115, 307, 499, 691, 883, 179, 371, 563, 755, 947, -7, 199, 391, 583, 775, 71, 263, 455, 647, 839, 135, 327, 519, 711, 903, -23, 215, 407, 599, 791, 87, 279, 471, 663, 855, 151, 343, 535, 727, 919, -39, 231, 423, 615, 807, 103, 295, 487, 679, 871, 167, 359, 551, 743, 935, -55, 247, 439, 631, 823, 119, 311, 503, 695, 887, 183, 375, 567, 759, 951, -11, 203, 395, 587, 779, 75, 267, 459, 651, 843, 139, 331, 523, 715, 907, -27, 219, 411, 603, 795, 91, 283, 475, 667, 859, 155, 347, 539, 731, 923, -43, 235, 427, 619, 811, 107, 299, 491, 683, 875, 171, 363, 555, 747, 939, -59, 251, 443, 635, 827, 123, 315, 507, 699, 891, 187, 379, 571, 763, 955, -15, 207, 399, 591, 783, 79, 271, 463, 655, 847, 143, 335, 527, 719, 911, -31, 223, 415, 607, 799, 95, 287, 479, 671, 863, 159, 351, 543, 735, 927, -47, 239, 431, 623, 815, 111, 303, 495, 687, 879, 175, 367, 559, 751, 943, -63, 255, 447, 639, 831, 127, 319, 511, 703, 895, 191, 383, 575, 767, 959, +# ifndef FFT_BITREV960 +# define FFT_BITREV960 +static const oac_int16 fft_bitrev960[960] = { + 0, 192, 384, 576, 768, 64, 256, 448, 640, 832, 128, 320, 512, 704, 896, + 16, 208, 400, 592, 784, 80, 272, 464, 656, 848, 144, 336, 528, 720, 912, + 32, 224, 416, 608, 800, 96, 288, 480, 672, 864, 160, 352, 544, 736, 928, + 48, 240, 432, 624, 816, 112, 304, 496, 688, 880, 176, 368, 560, 752, 944, + 4, 196, 388, 580, 772, 68, 260, 452, 644, 836, 132, 324, 516, 708, 900, + 20, 212, 404, 596, 788, 84, 276, 468, 660, 852, 148, 340, 532, 724, 916, + 36, 228, 420, 612, 804, 100, 292, 484, 676, 868, 164, 356, 548, 740, 932, + 52, 244, 436, 628, 820, 116, 308, 500, 692, 884, 180, 372, 564, 756, 948, + 8, 200, 392, 584, 776, 72, 264, 456, 648, 840, 136, 328, 520, 712, 904, + 24, 216, 408, 600, 792, 88, 280, 472, 664, 856, 152, 344, 536, 728, 920, + 40, 232, 424, 616, 808, 104, 296, 488, 680, 872, 168, 360, 552, 744, 936, + 56, 248, 440, 632, 824, 120, 312, 504, 696, 888, 184, 376, 568, 760, 952, + 12, 204, 396, 588, 780, 76, 268, 460, 652, 844, 140, 332, 524, 716, 908, + 28, 220, 412, 604, 796, 92, 284, 476, 668, 860, 156, 348, 540, 732, 924, + 44, 236, 428, 620, 812, 108, 300, 492, 684, 876, 172, 364, 556, 748, 940, + 60, 252, 444, 636, 828, 124, 316, 508, 700, 892, 188, 380, 572, 764, 956, + 1, 193, 385, 577, 769, 65, 257, 449, 641, 833, 129, 321, 513, 705, 897, + 17, 209, 401, 593, 785, 81, 273, 465, 657, 849, 145, 337, 529, 721, 913, + 33, 225, 417, 609, 801, 97, 289, 481, 673, 865, 161, 353, 545, 737, 929, + 49, 241, 433, 625, 817, 113, 305, 497, 689, 881, 177, 369, 561, 753, 945, + 5, 197, 389, 581, 773, 69, 261, 453, 645, 837, 133, 325, 517, 709, 901, + 21, 213, 405, 597, 789, 85, 277, 469, 661, 853, 149, 341, 533, 725, 917, + 37, 229, 421, 613, 805, 101, 293, 485, 677, 869, 165, 357, 549, 741, 933, + 53, 245, 437, 629, 821, 117, 309, 501, 693, 885, 181, 373, 565, 757, 949, + 9, 201, 393, 585, 777, 73, 265, 457, 649, 841, 137, 329, 521, 713, 905, + 25, 217, 409, 601, 793, 89, 281, 473, 665, 857, 153, 345, 537, 729, 921, + 41, 233, 425, 617, 809, 105, 297, 489, 681, 873, 169, 361, 553, 745, 937, + 57, 249, 441, 633, 825, 121, 313, 505, 697, 889, 185, 377, 569, 761, 953, + 13, 205, 397, 589, 781, 77, 269, 461, 653, 845, 141, 333, 525, 717, 909, + 29, 221, 413, 605, 797, 93, 285, 477, 669, 861, 157, 349, 541, 733, 925, + 45, 237, 429, 621, 813, 109, 301, 493, 685, 877, 173, 365, 557, 749, 941, + 61, 253, 445, 637, 829, 125, 317, 509, 701, 893, 189, 381, 573, 765, 957, + 2, 194, 386, 578, 770, 66, 258, 450, 642, 834, 130, 322, 514, 706, 898, + 18, 210, 402, 594, 786, 82, 274, 466, 658, 850, 146, 338, 530, 722, 914, + 34, 226, 418, 610, 802, 98, 290, 482, 674, 866, 162, 354, 546, 738, 930, + 50, 242, 434, 626, 818, 114, 306, 498, 690, 882, 178, 370, 562, 754, 946, + 6, 198, 390, 582, 774, 70, 262, 454, 646, 838, 134, 326, 518, 710, 902, + 22, 214, 406, 598, 790, 86, 278, 470, 662, 854, 150, 342, 534, 726, 918, + 38, 230, 422, 614, 806, 102, 294, 486, 678, 870, 166, 358, 550, 742, 934, + 54, 246, 438, 630, 822, 118, 310, 502, 694, 886, 182, 374, 566, 758, 950, + 10, 202, 394, 586, 778, 74, 266, 458, 650, 842, 138, 330, 522, 714, 906, + 26, 218, 410, 602, 794, 90, 282, 474, 666, 858, 154, 346, 538, 730, 922, + 42, 234, 426, 618, 810, 106, 298, 490, 682, 874, 170, 362, 554, 746, 938, + 58, 250, 442, 634, 826, 122, 314, 506, 698, 890, 186, 378, 570, 762, 954, + 14, 206, 398, 590, 782, 78, 270, 462, 654, 846, 142, 334, 526, 718, 910, + 30, 222, 414, 606, 798, 94, 286, 478, 670, 862, 158, 350, 542, 734, 926, + 46, 238, 430, 622, 814, 110, 302, 494, 686, 878, 174, 366, 558, 750, 942, + 62, 254, 446, 638, 830, 126, 318, 510, 702, 894, 190, 382, 574, 766, 958, + 3, 195, 387, 579, 771, 67, 259, 451, 643, 835, 131, 323, 515, 707, 899, + 19, 211, 403, 595, 787, 83, 275, 467, 659, 851, 147, 339, 531, 723, 915, + 35, 227, 419, 611, 803, 99, 291, 483, 675, 867, 163, 355, 547, 739, 931, + 51, 243, 435, 627, 819, 115, 307, 499, 691, 883, 179, 371, 563, 755, 947, + 7, 199, 391, 583, 775, 71, 263, 455, 647, 839, 135, 327, 519, 711, 903, + 23, 215, 407, 599, 791, 87, 279, 471, 663, 855, 151, 343, 535, 727, 919, + 39, 231, 423, 615, 807, 103, 295, 487, 679, 871, 167, 359, 551, 743, 935, + 55, 247, 439, 631, 823, 119, 311, 503, 695, 887, 183, 375, 567, 759, 951, + 11, 203, 395, 587, 779, 75, 267, 459, 651, 843, 139, 331, 523, 715, 907, + 27, 219, 411, 603, 795, 91, 283, 475, 667, 859, 155, 347, 539, 731, 923, + 43, 235, 427, 619, 811, 107, 299, 491, 683, 875, 171, 363, 555, 747, 939, + 59, 251, 443, 635, 827, 123, 315, 507, 699, 891, 187, 379, 571, 763, 955, + 15, 207, 399, 591, 783, 79, 271, 463, 655, 847, 143, 335, 527, 719, 911, + 31, 223, 415, 607, 799, 95, 287, 479, 671, 863, 159, 351, 543, 735, 927, + 47, 239, 431, 623, 815, 111, 303, 495, 687, 879, 175, 367, 559, 751, 943, + 63, 255, 447, 639, 831, 127, 319, 511, 703, 895, 191, 383, 575, 767, 959, }; -#endif +# endif -#ifndef FFT_BITREV480 -#define FFT_BITREV480 -static const opus_int16 fft_bitrev480[480] = { -0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, -8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, -16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, -24, 120, 216, 312, 408, 56, 152, 248, 344, 440, 88, 184, 280, 376, 472, -4, 100, 196, 292, 388, 36, 132, 228, 324, 420, 68, 164, 260, 356, 452, -12, 108, 204, 300, 396, 44, 140, 236, 332, 428, 76, 172, 268, 364, 460, -20, 116, 212, 308, 404, 52, 148, 244, 340, 436, 84, 180, 276, 372, 468, -28, 124, 220, 316, 412, 60, 156, 252, 348, 444, 92, 188, 284, 380, 476, -1, 97, 193, 289, 385, 33, 129, 225, 321, 417, 65, 161, 257, 353, 449, -9, 105, 201, 297, 393, 41, 137, 233, 329, 425, 73, 169, 265, 361, 457, -17, 113, 209, 305, 401, 49, 145, 241, 337, 433, 81, 177, 273, 369, 465, -25, 121, 217, 313, 409, 57, 153, 249, 345, 441, 89, 185, 281, 377, 473, -5, 101, 197, 293, 389, 37, 133, 229, 325, 421, 69, 165, 261, 357, 453, -13, 109, 205, 301, 397, 45, 141, 237, 333, 429, 77, 173, 269, 365, 461, -21, 117, 213, 309, 405, 53, 149, 245, 341, 437, 85, 181, 277, 373, 469, -29, 125, 221, 317, 413, 61, 157, 253, 349, 445, 93, 189, 285, 381, 477, -2, 98, 194, 290, 386, 34, 130, 226, 322, 418, 66, 162, 258, 354, 450, -10, 106, 202, 298, 394, 42, 138, 234, 330, 426, 74, 170, 266, 362, 458, -18, 114, 210, 306, 402, 50, 146, 242, 338, 434, 82, 178, 274, 370, 466, -26, 122, 218, 314, 410, 58, 154, 250, 346, 442, 90, 186, 282, 378, 474, -6, 102, 198, 294, 390, 38, 134, 230, 326, 422, 70, 166, 262, 358, 454, -14, 110, 206, 302, 398, 46, 142, 238, 334, 430, 78, 174, 270, 366, 462, -22, 118, 214, 310, 406, 54, 150, 246, 342, 438, 86, 182, 278, 374, 470, -30, 126, 222, 318, 414, 62, 158, 254, 350, 446, 94, 190, 286, 382, 478, -3, 99, 195, 291, 387, 35, 131, 227, 323, 419, 67, 163, 259, 355, 451, -11, 107, 203, 299, 395, 43, 139, 235, 331, 427, 75, 171, 267, 363, 459, -19, 115, 211, 307, 403, 51, 147, 243, 339, 435, 83, 179, 275, 371, 467, -27, 123, 219, 315, 411, 59, 155, 251, 347, 443, 91, 187, 283, 379, 475, -7, 103, 199, 295, 391, 39, 135, 231, 327, 423, 71, 167, 263, 359, 455, -15, 111, 207, 303, 399, 47, 143, 239, 335, 431, 79, 175, 271, 367, 463, -23, 119, 215, 311, 407, 55, 151, 247, 343, 439, 87, 183, 279, 375, 471, -31, 127, 223, 319, 415, 63, 159, 255, 351, 447, 95, 191, 287, 383, 479, +# ifndef FFT_BITREV480 +# define FFT_BITREV480 +static const oac_int16 fft_bitrev480[480] = { + 0, 96, 192, 288, 384, 32, 128, 224, 320, 416, 64, 160, 256, 352, 448, + 8, 104, 200, 296, 392, 40, 136, 232, 328, 424, 72, 168, 264, 360, 456, + 16, 112, 208, 304, 400, 48, 144, 240, 336, 432, 80, 176, 272, 368, 464, + 24, 120, 216, 312, 408, 56, 152, 248, 344, 440, 88, 184, 280, 376, 472, + 4, 100, 196, 292, 388, 36, 132, 228, 324, 420, 68, 164, 260, 356, 452, + 12, 108, 204, 300, 396, 44, 140, 236, 332, 428, 76, 172, 268, 364, 460, + 20, 116, 212, 308, 404, 52, 148, 244, 340, 436, 84, 180, 276, 372, 468, + 28, 124, 220, 316, 412, 60, 156, 252, 348, 444, 92, 188, 284, 380, 476, + 1, 97, 193, 289, 385, 33, 129, 225, 321, 417, 65, 161, 257, 353, 449, + 9, 105, 201, 297, 393, 41, 137, 233, 329, 425, 73, 169, 265, 361, 457, + 17, 113, 209, 305, 401, 49, 145, 241, 337, 433, 81, 177, 273, 369, 465, + 25, 121, 217, 313, 409, 57, 153, 249, 345, 441, 89, 185, 281, 377, 473, + 5, 101, 197, 293, 389, 37, 133, 229, 325, 421, 69, 165, 261, 357, 453, + 13, 109, 205, 301, 397, 45, 141, 237, 333, 429, 77, 173, 269, 365, 461, + 21, 117, 213, 309, 405, 53, 149, 245, 341, 437, 85, 181, 277, 373, 469, + 29, 125, 221, 317, 413, 61, 157, 253, 349, 445, 93, 189, 285, 381, 477, + 2, 98, 194, 290, 386, 34, 130, 226, 322, 418, 66, 162, 258, 354, 450, + 10, 106, 202, 298, 394, 42, 138, 234, 330, 426, 74, 170, 266, 362, 458, + 18, 114, 210, 306, 402, 50, 146, 242, 338, 434, 82, 178, 274, 370, 466, + 26, 122, 218, 314, 410, 58, 154, 250, 346, 442, 90, 186, 282, 378, 474, + 6, 102, 198, 294, 390, 38, 134, 230, 326, 422, 70, 166, 262, 358, 454, + 14, 110, 206, 302, 398, 46, 142, 238, 334, 430, 78, 174, 270, 366, 462, + 22, 118, 214, 310, 406, 54, 150, 246, 342, 438, 86, 182, 278, 374, 470, + 30, 126, 222, 318, 414, 62, 158, 254, 350, 446, 94, 190, 286, 382, 478, + 3, 99, 195, 291, 387, 35, 131, 227, 323, 419, 67, 163, 259, 355, 451, + 11, 107, 203, 299, 395, 43, 139, 235, 331, 427, 75, 171, 267, 363, 459, + 19, 115, 211, 307, 403, 51, 147, 243, 339, 435, 83, 179, 275, 371, 467, + 27, 123, 219, 315, 411, 59, 155, 251, 347, 443, 91, 187, 283, 379, 475, + 7, 103, 199, 295, 391, 39, 135, 231, 327, 423, 71, 167, 263, 359, 455, + 15, 111, 207, 303, 399, 47, 143, 239, 335, 431, 79, 175, 271, 367, 463, + 23, 119, 215, 311, 407, 55, 151, 247, 343, 439, 87, 183, 279, 375, 471, + 31, 127, 223, 319, 415, 63, 159, 255, 351, 447, 95, 191, 287, 383, 479, }; -#endif +# endif -#ifndef FFT_BITREV240 -#define FFT_BITREV240 -static const opus_int16 fft_bitrev240[240] = { -0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, -4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, -8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, -12, 60, 108, 156, 204, 28, 76, 124, 172, 220, 44, 92, 140, 188, 236, -1, 49, 97, 145, 193, 17, 65, 113, 161, 209, 33, 81, 129, 177, 225, -5, 53, 101, 149, 197, 21, 69, 117, 165, 213, 37, 85, 133, 181, 229, -9, 57, 105, 153, 201, 25, 73, 121, 169, 217, 41, 89, 137, 185, 233, -13, 61, 109, 157, 205, 29, 77, 125, 173, 221, 45, 93, 141, 189, 237, -2, 50, 98, 146, 194, 18, 66, 114, 162, 210, 34, 82, 130, 178, 226, -6, 54, 102, 150, 198, 22, 70, 118, 166, 214, 38, 86, 134, 182, 230, -10, 58, 106, 154, 202, 26, 74, 122, 170, 218, 42, 90, 138, 186, 234, -14, 62, 110, 158, 206, 30, 78, 126, 174, 222, 46, 94, 142, 190, 238, -3, 51, 99, 147, 195, 19, 67, 115, 163, 211, 35, 83, 131, 179, 227, -7, 55, 103, 151, 199, 23, 71, 119, 167, 215, 39, 87, 135, 183, 231, -11, 59, 107, 155, 203, 27, 75, 123, 171, 219, 43, 91, 139, 187, 235, -15, 63, 111, 159, 207, 31, 79, 127, 175, 223, 47, 95, 143, 191, 239, +# ifndef FFT_BITREV240 +# define FFT_BITREV240 +static const oac_int16 fft_bitrev240[240] = { + 0, 48, 96, 144, 192, 16, 64, 112, 160, 208, 32, 80, 128, 176, 224, + 4, 52, 100, 148, 196, 20, 68, 116, 164, 212, 36, 84, 132, 180, 228, + 8, 56, 104, 152, 200, 24, 72, 120, 168, 216, 40, 88, 136, 184, 232, + 12, 60, 108, 156, 204, 28, 76, 124, 172, 220, 44, 92, 140, 188, 236, + 1, 49, 97, 145, 193, 17, 65, 113, 161, 209, 33, 81, 129, 177, 225, + 5, 53, 101, 149, 197, 21, 69, 117, 165, 213, 37, 85, 133, 181, 229, + 9, 57, 105, 153, 201, 25, 73, 121, 169, 217, 41, 89, 137, 185, 233, + 13, 61, 109, 157, 205, 29, 77, 125, 173, 221, 45, 93, 141, 189, 237, + 2, 50, 98, 146, 194, 18, 66, 114, 162, 210, 34, 82, 130, 178, 226, + 6, 54, 102, 150, 198, 22, 70, 118, 166, 214, 38, 86, 134, 182, 230, + 10, 58, 106, 154, 202, 26, 74, 122, 170, 218, 42, 90, 138, 186, 234, + 14, 62, 110, 158, 206, 30, 78, 126, 174, 222, 46, 94, 142, 190, 238, + 3, 51, 99, 147, 195, 19, 67, 115, 163, 211, 35, 83, 131, 179, 227, + 7, 55, 103, 151, 199, 23, 71, 119, 167, 215, 39, 87, 135, 183, 231, + 11, 59, 107, 155, 203, 27, 75, 123, 171, 219, 43, 91, 139, 187, 235, + 15, 63, 111, 159, 207, 31, 79, 127, 175, 223, 47, 95, 143, 191, 239, }; -#endif +# endif -#ifndef FFT_BITREV120 -#define FFT_BITREV120 -static const opus_int16 fft_bitrev120[120] = { -0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, -4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, -1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, -5, 29, 53, 77, 101, 13, 37, 61, 85, 109, 21, 45, 69, 93, 117, -2, 26, 50, 74, 98, 10, 34, 58, 82, 106, 18, 42, 66, 90, 114, -6, 30, 54, 78, 102, 14, 38, 62, 86, 110, 22, 46, 70, 94, 118, -3, 27, 51, 75, 99, 11, 35, 59, 83, 107, 19, 43, 67, 91, 115, -7, 31, 55, 79, 103, 15, 39, 63, 87, 111, 23, 47, 71, 95, 119, +# ifndef FFT_BITREV120 +# define FFT_BITREV120 +static const oac_int16 fft_bitrev120[120] = { + 0, 24, 48, 72, 96, 8, 32, 56, 80, 104, 16, 40, 64, 88, 112, + 4, 28, 52, 76, 100, 12, 36, 60, 84, 108, 20, 44, 68, 92, 116, + 1, 25, 49, 73, 97, 9, 33, 57, 81, 105, 17, 41, 65, 89, 113, + 5, 29, 53, 77, 101, 13, 37, 61, 85, 109, 21, 45, 69, 93, 117, + 2, 26, 50, 74, 98, 10, 34, 58, 82, 106, 18, 42, 66, 90, 114, + 6, 30, 54, 78, 102, 14, 38, 62, 86, 110, 22, 46, 70, 94, 118, + 3, 27, 51, 75, 99, 11, 35, 59, 83, 107, 19, 43, 67, 91, 115, + 7, 31, 55, 79, 103, 15, 39, 63, 87, 111, 23, 47, 71, 95, 119, }; -#endif +# endif -#ifndef FFT_STATE96000_1920_0 -#define FFT_STATE96000_1920_0 +# ifndef FFT_STATE96000_1920_0 +# define FFT_STATE96000_1920_0 static const kiss_fft_state fft_state96000_1920_0 = { -960, /* nfft */ -0.0010416667f, /* scale */ --1, /* shift */ -{5, 192, 3, 64, 4, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev960, /* bitrev */ -fft_twiddles96000_1920, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_960, -#else -NULL, -#endif + 960, /* nfft */ + 0.0010416667f, /* scale */ + -1, /* shift */ + {5, 192, 3, 64, 4, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev960, /* bitrev */ + fft_twiddles96000_1920, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_960, +# else + NULL, +# endif }; -#endif +# endif -#ifndef FFT_STATE96000_1920_1 -#define FFT_STATE96000_1920_1 +# ifndef FFT_STATE96000_1920_1 +# define FFT_STATE96000_1920_1 static const kiss_fft_state fft_state96000_1920_1 = { -480, /* nfft */ -0.0020833334f, /* scale */ -1, /* shift */ -{5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev480, /* bitrev */ -fft_twiddles96000_1920, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_480, -#else -NULL, -#endif + 480, /* nfft */ + 0.0020833334f, /* scale */ + 1, /* shift */ + {5, 96, 3, 32, 4, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev480, /* bitrev */ + fft_twiddles96000_1920, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_480, +# else + NULL, +# endif }; -#endif +# endif -#ifndef FFT_STATE96000_1920_2 -#define FFT_STATE96000_1920_2 +# ifndef FFT_STATE96000_1920_2 +# define FFT_STATE96000_1920_2 static const kiss_fft_state fft_state96000_1920_2 = { -240, /* nfft */ -0.0041666669f, /* scale */ -2, /* shift */ -{5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev240, /* bitrev */ -fft_twiddles96000_1920, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_240, -#else -NULL, -#endif + 240, /* nfft */ + 0.0041666669f, /* scale */ + 2, /* shift */ + {5, 48, 3, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev240, /* bitrev */ + fft_twiddles96000_1920, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_240, +# else + NULL, +# endif }; -#endif +# endif -#ifndef FFT_STATE96000_1920_3 -#define FFT_STATE96000_1920_3 +# ifndef FFT_STATE96000_1920_3 +# define FFT_STATE96000_1920_3 static const kiss_fft_state fft_state96000_1920_3 = { -120, /* nfft */ -0.0083333338f, /* scale */ -3, /* shift */ -{5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev120, /* bitrev */ -fft_twiddles96000_1920, /* bitrev */ -#ifdef OVERRIDE_FFT -(arch_fft_state *)&cfg_arch_120, -#else -NULL, -#endif + 120, /* nfft */ + 0.0083333338f, /* scale */ + 3, /* shift */ + {5, 24, 3, 8, 2, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev120, /* bitrev */ + fft_twiddles96000_1920, /* bitrev */ +# ifdef OVERRIDE_FFT + (arch_fft_state *)&cfg_arch_120, +# else + NULL, +# endif }; -#endif +# endif -#endif +# endif -#ifndef MDCT_TWIDDLES1920 -#define MDCT_TWIDDLES1920 +# ifndef MDCT_TWIDDLES1920 +# define MDCT_TWIDDLES1920 static const celt_coef mdct_twiddles1920[3600] = { -0.99999998f, 0.99999831f, 0.99999396f, 0.99998693f, 0.99997722f, -0.99996484f, 0.99994978f, 0.99993204f, 0.99991163f, 0.99988854f, -0.99986277f, 0.99983433f, 0.99980320f, 0.99976941f, 0.99973293f, -0.99969378f, 0.99965195f, 0.99960745f, 0.99956026f, 0.99951041f, -0.99945787f, 0.99940267f, 0.99934478f, 0.99928422f, 0.99922099f, -0.99915507f, 0.99908649f, 0.99901523f, 0.99894129f, 0.99886468f, -0.99878540f, 0.99870344f, 0.99861881f, 0.99853150f, 0.99844153f, -0.99834887f, 0.99825355f, 0.99815555f, 0.99805488f, 0.99795154f, -0.99784553f, 0.99773684f, 0.99762548f, 0.99751146f, 0.99739476f, -0.99727539f, 0.99715335f, 0.99702864f, 0.99690127f, 0.99677122f, -0.99663850f, 0.99650312f, 0.99636507f, 0.99622435f, 0.99608096f, -0.99593491f, 0.99578619f, 0.99563481f, 0.99548076f, 0.99532404f, -0.99516466f, 0.99500261f, 0.99483790f, 0.99467053f, 0.99450050f, -0.99432780f, 0.99415244f, 0.99397441f, 0.99379373f, 0.99361039f, -0.99342438f, 0.99323572f, 0.99304440f, 0.99285041f, 0.99265377f, -0.99245448f, 0.99225252f, 0.99204791f, 0.99184064f, 0.99163072f, -0.99141814f, 0.99120291f, 0.99098503f, 0.99076449f, 0.99054130f, -0.99031545f, 0.99008696f, 0.98985581f, 0.98962202f, 0.98938557f, -0.98914648f, 0.98890474f, 0.98866035f, 0.98841331f, 0.98816363f, -0.98791130f, 0.98765632f, 0.98739871f, 0.98713845f, 0.98687554f, -0.98660999f, 0.98634181f, 0.98607098f, 0.98579751f, 0.98552140f, -0.98524265f, 0.98496127f, 0.98467725f, 0.98439059f, 0.98410130f, -0.98380937f, 0.98351481f, 0.98321761f, 0.98291779f, 0.98261533f, -0.98231024f, 0.98200252f, 0.98169217f, 0.98137919f, 0.98106359f, -0.98074536f, 0.98042450f, 0.98010102f, 0.97977491f, 0.97944619f, -0.97911483f, 0.97878086f, 0.97844427f, 0.97810506f, 0.97776322f, -0.97741878f, 0.97707171f, 0.97672203f, 0.97636973f, 0.97601482f, -0.97565730f, 0.97529716f, 0.97493441f, 0.97456906f, 0.97420109f, -0.97383051f, 0.97345733f, 0.97308154f, 0.97270315f, 0.97232215f, -0.97193855f, 0.97155235f, 0.97116355f, 0.97077214f, 0.97037814f, -0.96998154f, 0.96958234f, 0.96918054f, 0.96877615f, 0.96836917f, -0.96795960f, 0.96754743f, 0.96713267f, 0.96671533f, 0.96629539f, -0.96587287f, 0.96544776f, 0.96502007f, 0.96458979f, 0.96415693f, -0.96372149f, 0.96328347f, 0.96284288f, 0.96239970f, 0.96195394f, -0.96150562f, 0.96105471f, 0.96060124f, 0.96014519f, 0.95968657f, -0.95922538f, 0.95876162f, 0.95829530f, 0.95782641f, 0.95735496f, -0.95688094f, 0.95640437f, 0.95592523f, 0.95544353f, 0.95495927f, -0.95447246f, 0.95398309f, 0.95349117f, 0.95299669f, 0.95249967f, -0.95200009f, 0.95149797f, 0.95099329f, 0.95048607f, 0.94997631f, -0.94946400f, 0.94894915f, 0.94843176f, 0.94791184f, 0.94738937f, -0.94686437f, 0.94633683f, 0.94580676f, 0.94527415f, 0.94473902f, -0.94420135f, 0.94366116f, 0.94311844f, 0.94257320f, 0.94202543f, -0.94147514f, 0.94092233f, 0.94036700f, 0.93980916f, 0.93924879f, -0.93868592f, 0.93812052f, 0.93755262f, 0.93698221f, 0.93640929f, -0.93583386f, 0.93525593f, 0.93467549f, 0.93409255f, 0.93350711f, -0.93291917f, 0.93232873f, 0.93173580f, 0.93114037f, 0.93054245f, -0.92994204f, 0.92933913f, 0.92873374f, 0.92812587f, 0.92751550f, -0.92690266f, 0.92628733f, 0.92566953f, 0.92504924f, 0.92442648f, -0.92380124f, 0.92317353f, 0.92254335f, 0.92191070f, 0.92127558f, -0.92063799f, 0.91999794f, 0.91935543f, 0.91871045f, 0.91806302f, -0.91741313f, 0.91676078f, 0.91610597f, 0.91544872f, 0.91478901f, -0.91412685f, 0.91346225f, 0.91279520f, 0.91212571f, 0.91145377f, -0.91077939f, 0.91010258f, 0.90942333f, 0.90874164f, 0.90805753f, -0.90737098f, 0.90668200f, 0.90599059f, 0.90529676f, 0.90460050f, -0.90390183f, 0.90320073f, 0.90249721f, 0.90179128f, 0.90108293f, -0.90037218f, 0.89965901f, 0.89894343f, 0.89822544f, 0.89750505f, -0.89678226f, 0.89605707f, 0.89532948f, 0.89459949f, 0.89386710f, -0.89313232f, 0.89239515f, 0.89165560f, 0.89091365f, 0.89016932f, -0.88942261f, 0.88867351f, 0.88792204f, 0.88716818f, 0.88641196f, -0.88565336f, 0.88489239f, 0.88412905f, 0.88336334f, 0.88259527f, -0.88182483f, 0.88105203f, 0.88027688f, 0.87949937f, 0.87871950f, -0.87793728f, 0.87715271f, 0.87636579f, 0.87557653f, 0.87478492f, -0.87399097f, 0.87319468f, 0.87239605f, 0.87159509f, 0.87079179f, -0.86998616f, 0.86917820f, 0.86836792f, 0.86755531f, 0.86674037f, -0.86592312f, 0.86510355f, 0.86428166f, 0.86345746f, 0.86263095f, -0.86180212f, 0.86097099f, 0.86013756f, 0.85930182f, 0.85846378f, -0.85762344f, 0.85678081f, 0.85593588f, 0.85508866f, 0.85423915f, -0.85338736f, 0.85253328f, 0.85167692f, 0.85081827f, 0.84995735f, -0.84909416f, 0.84822869f, 0.84736095f, 0.84649094f, 0.84561866f, -0.84474412f, 0.84386732f, 0.84298826f, 0.84210695f, 0.84122337f, -0.84033755f, 0.83944948f, 0.83855915f, 0.83766659f, 0.83677178f, -0.83587473f, 0.83497544f, 0.83407392f, 0.83317016f, 0.83226418f, -0.83135596f, 0.83044552f, 0.82953286f, 0.82861797f, 0.82770087f, -0.82678155f, 0.82586002f, 0.82493628f, 0.82401032f, 0.82308217f, -0.82215180f, 0.82121924f, 0.82028448f, 0.81934752f, 0.81840837f, -0.81746703f, 0.81652349f, 0.81557778f, 0.81462988f, 0.81367979f, -0.81272753f, 0.81177310f, 0.81081649f, 0.80985771f, 0.80889676f, -0.80793364f, 0.80696837f, 0.80600093f, 0.80503133f, 0.80405958f, -0.80308568f, 0.80210962f, 0.80113142f, 0.80015107f, 0.79916858f, -0.79818396f, 0.79719719f, 0.79620829f, 0.79521726f, 0.79422410f, -0.79322881f, 0.79223140f, 0.79123187f, 0.79023022f, 0.78922646f, -0.78822058f, 0.78721259f, 0.78620249f, 0.78519029f, 0.78417599f, -0.78315958f, 0.78214108f, 0.78112049f, 0.78009781f, 0.77907303f, -0.77804617f, 0.77701723f, 0.77598621f, 0.77495311f, 0.77391793f, -0.77288068f, 0.77184137f, 0.77079998f, 0.76975654f, 0.76871103f, -0.76766347f, 0.76661384f, 0.76556217f, 0.76450845f, 0.76345268f, -0.76239487f, 0.76133501f, 0.76027312f, 0.75920919f, 0.75814323f, -0.75707524f, 0.75600522f, 0.75493318f, 0.75385911f, 0.75278303f, -0.75170494f, 0.75062483f, 0.74954271f, 0.74845858f, 0.74737245f, -0.74628432f, 0.74519419f, 0.74410207f, 0.74300795f, 0.74191185f, -0.74081376f, 0.73971368f, 0.73861163f, 0.73750759f, 0.73640158f, -0.73529361f, 0.73418366f, 0.73307175f, 0.73195787f, 0.73084203f, -0.72972424f, 0.72860450f, 0.72748280f, 0.72635916f, 0.72523357f, -0.72410604f, 0.72297657f, 0.72184516f, 0.72071182f, 0.71957656f, -0.71843936f, 0.71730025f, 0.71615921f, 0.71501625f, 0.71387138f, -0.71272460f, 0.71157592f, 0.71042532f, 0.70927283f, 0.70811843f, -0.70696214f, 0.70580396f, 0.70464389f, 0.70348193f, 0.70231808f, -0.70115236f, 0.69998476f, 0.69881528f, 0.69764394f, 0.69647073f, -0.69529565f, 0.69411871f, 0.69293991f, 0.69175926f, 0.69057675f, -0.68939240f, 0.68820620f, 0.68701816f, 0.68582828f, 0.68463656f, -0.68344301f, 0.68224763f, 0.68105042f, 0.67985139f, 0.67865054f, -0.67744787f, 0.67624339f, 0.67503710f, 0.67382900f, 0.67261910f, -0.67140739f, 0.67019389f, 0.66897860f, 0.66776151f, 0.66654264f, -0.66532198f, 0.66409954f, 0.66287532f, 0.66164932f, 0.66042156f, -0.65919203f, 0.65796073f, 0.65672767f, 0.65549285f, 0.65425628f, -0.65301796f, 0.65177788f, 0.65053607f, 0.64929251f, 0.64804721f, -0.64680018f, 0.64555141f, 0.64430092f, 0.64304871f, 0.64179477f, -0.64053911f, 0.63928174f, 0.63802265f, 0.63676186f, 0.63549936f, -0.63423517f, 0.63296927f, 0.63170168f, 0.63043240f, 0.62916143f, -0.62788877f, 0.62661444f, 0.62533842f, 0.62406074f, 0.62278138f, -0.62150035f, 0.62021766f, 0.61893331f, 0.61764731f, 0.61635965f, -0.61507034f, 0.61377938f, 0.61248678f, 0.61119254f, 0.60989666f, -0.60859915f, 0.60730001f, 0.60599925f, 0.60469686f, 0.60339285f, -0.60208723f, 0.60078000f, 0.59947115f, 0.59816071f, 0.59684866f, -0.59553501f, 0.59421977f, 0.59290294f, 0.59158452f, 0.59026452f, -0.58894293f, 0.58761977f, 0.58629504f, 0.58496873f, 0.58364086f, -0.58231143f, 0.58098044f, 0.57964789f, 0.57831380f, 0.57697815f, -0.57564096f, 0.57430223f, 0.57296196f, 0.57162015f, 0.57027682f, -0.56893195f, 0.56758557f, 0.56623767f, 0.56488825f, 0.56353731f, -0.56218487f, 0.56083093f, 0.55947548f, 0.55811853f, 0.55676009f, -0.55540016f, 0.55403874f, 0.55267584f, 0.55131146f, 0.54994560f, -0.54857827f, 0.54720948f, 0.54583921f, 0.54446749f, 0.54309431f, -0.54171967f, 0.54034359f, 0.53896605f, 0.53758708f, 0.53620666f, -0.53482481f, 0.53344153f, 0.53205682f, 0.53067068f, 0.52928312f, -0.52789415f, 0.52650377f, 0.52511197f, 0.52371877f, 0.52232416f, -0.52092816f, 0.51953076f, 0.51813197f, 0.51673180f, 0.51533024f, -0.51392730f, 0.51252299f, 0.51111730f, 0.50971025f, 0.50830183f, -0.50689204f, 0.50548091f, 0.50406842f, 0.50265458f, 0.50123939f, -0.49982286f, 0.49840499f, 0.49698579f, 0.49556526f, 0.49414340f, -0.49272022f, 0.49129572f, 0.48986991f, 0.48844278f, 0.48701434f, -0.48558461f, 0.48415357f, 0.48272123f, 0.48128760f, 0.47985269f, -0.47841649f, 0.47697901f, 0.47554025f, 0.47410021f, 0.47265891f, -0.47121635f, 0.46977252f, 0.46832743f, 0.46688109f, 0.46543350f, -0.46398467f, 0.46253459f, 0.46108327f, 0.45963072f, 0.45817694f, -0.45672193f, 0.45526570f, 0.45380825f, 0.45234959f, 0.45088971f, -0.44942863f, 0.44796634f, 0.44650286f, 0.44503818f, 0.44357230f, -0.44210524f, 0.44063700f, 0.43916758f, 0.43769698f, 0.43622521f, -0.43475227f, 0.43327816f, 0.43180290f, 0.43032648f, 0.42884891f, -0.42737019f, 0.42589033f, 0.42440932f, 0.42292718f, 0.42144391f, -0.41995951f, 0.41847399f, 0.41698734f, 0.41549958f, 0.41401070f, -0.41252072f, 0.41102963f, 0.40953745f, 0.40804416f, 0.40654979f, -0.40505432f, 0.40355777f, 0.40206014f, 0.40056144f, 0.39906166f, -0.39756081f, 0.39605890f, 0.39455593f, 0.39305190f, 0.39154682f, -0.39004069f, 0.38853352f, 0.38702530f, 0.38551605f, 0.38400577f, -0.38249446f, 0.38098213f, 0.37946878f, 0.37795441f, 0.37643902f, -0.37492263f, 0.37340524f, 0.37188685f, 0.37036746f, 0.36884708f, -0.36732571f, 0.36580336f, 0.36428003f, 0.36275572f, 0.36123045f, -0.35970420f, 0.35817700f, 0.35664883f, 0.35511971f, 0.35358964f, -0.35205862f, 0.35052666f, 0.34899376f, 0.34745992f, 0.34592516f, -0.34438947f, 0.34285286f, 0.34131533f, 0.33977688f, 0.33823753f, -0.33669727f, 0.33515611f, 0.33361405f, 0.33207110f, 0.33052726f, -0.32898254f, 0.32743693f, 0.32589045f, 0.32434309f, 0.32279487f, -0.32124578f, 0.31969583f, 0.31814503f, 0.31659338f, 0.31504087f, -0.31348753f, 0.31193334f, 0.31037832f, 0.30882247f, 0.30726579f, -0.30570829f, 0.30414997f, 0.30259083f, 0.30103089f, 0.29947014f, -0.29790859f, 0.29634624f, 0.29478309f, 0.29321916f, 0.29165445f, -0.29008895f, 0.28852267f, 0.28695563f, 0.28538781f, 0.28381923f, -0.28224989f, 0.28067980f, 0.27910895f, 0.27753736f, 0.27596502f, -0.27439194f, 0.27281813f, 0.27124359f, 0.26966833f, 0.26809234f, -0.26651563f, 0.26493821f, 0.26336008f, 0.26178125f, 0.26020171f, -0.25862148f, 0.25704055f, 0.25545894f, 0.25387664f, 0.25229367f, -0.25071002f, 0.24912569f, 0.24754070f, 0.24595505f, 0.24436874f, -0.24278177f, 0.24119416f, 0.23960590f, 0.23801699f, 0.23642745f, -0.23483728f, 0.23324648f, 0.23165505f, 0.23006301f, 0.22847034f, -0.22687707f, 0.22528319f, 0.22368870f, 0.22209362f, 0.22049794f, -0.21890167f, 0.21730482f, 0.21570738f, 0.21410937f, 0.21251078f, -0.21091163f, 0.20931191f, 0.20771163f, 0.20611079f, 0.20450940f, -0.20290746f, 0.20130498f, 0.19970196f, 0.19809841f, 0.19649433f, -0.19488972f, 0.19328459f, 0.19167894f, 0.19007277f, 0.18846610f, -0.18685893f, 0.18525125f, 0.18364308f, 0.18203442f, 0.18042526f, -0.17881563f, 0.17720552f, 0.17559493f, 0.17398387f, 0.17237235f, -0.17076037f, 0.16914792f, 0.16753503f, 0.16592169f, 0.16430790f, -0.16269367f, 0.16107901f, 0.15946391f, 0.15784839f, 0.15623245f, -0.15461609f, 0.15299931f, 0.15138213f, 0.14976453f, 0.14814654f, -0.14652815f, 0.14490937f, 0.14329020f, 0.14167065f, 0.14005072f, -0.13843041f, 0.13680974f, 0.13518869f, 0.13356729f, 0.13194552f, -0.13032341f, 0.12870094f, 0.12707813f, 0.12545498f, 0.12383150f, -0.12220768f, 0.12058354f, 0.11895907f, 0.11733428f, 0.11570918f, -0.11408377f, 0.11245806f, 0.11083204f, 0.10920573f, 0.10757912f, -0.10595223f, 0.10432505f, 0.10269759f, 0.10106986f, 0.099441861f, -0.097813592f, 0.096185062f, 0.094556275f, 0.092927234f, 0.091297944f, -0.089668410f, 0.088038636f, 0.086408626f, 0.084778385f, 0.083147917f, -0.081517226f, 0.079886317f, 0.078255194f, 0.076623861f, 0.074992324f, -0.073360585f, 0.071728651f, 0.070096524f, 0.068464209f, 0.066831712f, -0.065199035f, 0.063566184f, 0.061933162f, 0.060299975f, 0.058666626f, -0.057033121f, 0.055399462f, 0.053765655f, 0.052131705f, 0.050497614f, -0.048863389f, 0.047229033f, 0.045594550f, 0.043959945f, 0.042325222f, -0.040690387f, 0.039055442f, 0.037420393f, 0.035785243f, 0.034149998f, -0.032514661f, 0.030879237f, 0.029243731f, 0.027608146f, 0.025972487f, -0.024336759f, 0.022700965f, 0.021065111f, 0.019429201f, 0.017793238f, -0.016157228f, 0.014521174f, 0.012885082f, 0.011248955f, 0.0096127982f, -0.0079766155f, 0.0063404114f, 0.0047041904f, 0.0030679568f, 0.0014317149f, --0.00020453077f, -0.0018407759f, -0.0034770161f, -0.0051132470f, -0.0067494642f, --0.0083856634f, -0.010021840f, -0.011657990f, -0.013294109f, -0.014930192f, --0.016566235f, -0.018202233f, -0.019838183f, -0.021474080f, -0.023109920f, --0.024745697f, -0.026381408f, -0.028017049f, -0.029652615f, -0.031288101f, --0.032923503f, -0.034558818f, -0.036194040f, -0.037829164f, -0.039464188f, --0.041099106f, -0.042733914f, -0.044368607f, -0.046003182f, -0.047637634f, --0.049271958f, -0.050906150f, -0.052540206f, -0.054174121f, -0.055807891f, --0.057441512f, -0.059074978f, -0.060708287f, -0.062341433f, -0.063974413f, --0.065607221f, -0.067239853f, -0.068872305f, -0.070504573f, -0.072136653f, --0.073768539f, -0.075400227f, -0.077031714f, -0.078662994f, -0.080294064f, --0.081924919f, -0.083555555f, -0.085185966f, -0.086816150f, -0.088446102f, --0.090075816f, -0.091705289f, -0.093334517f, -0.094963495f, -0.096592219f, --0.098220684f, -0.099848886f, -0.10147682f, -0.10310448f, -0.10473187f, --0.10635898f, -0.10798580f, -0.10961233f, -0.11123857f, -0.11286451f, --0.11449015f, -0.11611549f, -0.11774051f, -0.11936521f, -0.12098960f, --0.12261367f, -0.12423740f, -0.12586080f, -0.12748387f, -0.12910659f, --0.13072897f, -0.13235100f, -0.13397267f, -0.13559399f, -0.13721494f, --0.13883553f, -0.14045574f, -0.14207558f, -0.14369503f, -0.14531411f, --0.14693279f, -0.14855108f, -0.15016897f, -0.15178646f, -0.15340354f, --0.15502022f, -0.15663647f, -0.15825231f, -0.15986773f, -0.16148271f, --0.16309727f, -0.16471139f, -0.16632506f, -0.16793829f, -0.16955108f, --0.17116340f, -0.17277527f, -0.17438668f, -0.17599762f, -0.17760809f, --0.17921808f, -0.18082760f, -0.18243663f, -0.18404517f, -0.18565322f, --0.18726077f, -0.18886782f, -0.19047436f, -0.19208040f, -0.19368592f, --0.19529092f, -0.19689540f, -0.19849935f, -0.20010277f, -0.20170565f, --0.20330800f, -0.20490980f, -0.20651105f, -0.20811175f, -0.20971189f, --0.21131147f, -0.21291048f, -0.21450893f, -0.21610680f, -0.21770409f, --0.21930080f, -0.22089692f, -0.22249245f, -0.22408738f, -0.22568172f, --0.22727545f, -0.22886857f, -0.23046108f, -0.23205297f, -0.23364424f, --0.23523488f, -0.23682490f, -0.23841428f, -0.24000302f, -0.24159112f, --0.24317858f, -0.24476538f, -0.24635153f, -0.24793701f, -0.24952184f, --0.25110599f, -0.25268948f, -0.25427228f, -0.25585441f, -0.25743585f, --0.25901660f, -0.26059666f, -0.26217602f, -0.26375468f, -0.26533263f, --0.26690987f, -0.26848640f, -0.27006221f, -0.27163730f, -0.27321165f, --0.27478528f, -0.27635817f, -0.27793032f, -0.27950173f, -0.28107239f, --0.28264230f, -0.28421145f, -0.28577984f, -0.28734746f, -0.28891431f, --0.29048039f, -0.29204570f, -0.29361022f, -0.29517395f, -0.29673690f, --0.29829905f, -0.29986040f, -0.30142095f, -0.30298069f, -0.30453962f, --0.30609774f, -0.30765504f, -0.30921151f, -0.31076715f, -0.31232197f, --0.31387594f, -0.31542908f, -0.31698137f, -0.31853281f, -0.32008340f, --0.32163313f, -0.32318201f, -0.32473001f, -0.32627715f, -0.32782341f, --0.32936880f, -0.33091330f, -0.33245692f, -0.33399965f, -0.33554149f, --0.33708242f, -0.33862245f, -0.34016158f, -0.34169980f, -0.34323710f, --0.34477348f, -0.34630894f, -0.34784347f, -0.34937707f, -0.35090974f, --0.35244146f, -0.35397224f, -0.35550208f, -0.35703096f, -0.35855889f, --0.36008585f, -0.36161186f, -0.36313689f, -0.36466095f, -0.36618404f, --0.36770615f, -0.36922727f, -0.37074740f, -0.37226654f, -0.37378468f, --0.37530183f, -0.37681796f, -0.37833309f, -0.37984721f, -0.38136031f, --0.38287239f, -0.38438344f, -0.38589346f, -0.38740245f, -0.38891041f, --0.39041732f, -0.39192319f, -0.39342800f, -0.39493177f, -0.39643448f, --0.39793612f, -0.39943670f, -0.40093621f, -0.40243465f, -0.40393201f, --0.40542829f, -0.40692348f, -0.40841759f, -0.40991060f, -0.41140251f, --0.41289332f, -0.41438303f, -0.41587162f, -0.41735911f, -0.41884547f, --0.42033072f, -0.42181484f, -0.42329782f, -0.42477968f, -0.42626040f, --0.42773998f, -0.42921841f, -0.43069569f, -0.43217182f, -0.43364680f, --0.43512061f, -0.43659326f, -0.43806474f, -0.43953504f, -0.44100417f, --0.44247212f, -0.44393888f, -0.44540446f, -0.44686884f, -0.44833203f, --0.44979401f, -0.45125479f, -0.45271437f, -0.45417273f, -0.45562987f, --0.45708580f, -0.45854050f, -0.45999398f, -0.46144622f, -0.46289723f, --0.46434699f, -0.46579552f, -0.46724280f, -0.46868882f, -0.47013359f, --0.47157711f, -0.47301936f, -0.47446034f, -0.47590006f, -0.47733850f, --0.47877566f, -0.48021154f, -0.48164613f, -0.48307944f, -0.48451145f, --0.48594216f, -0.48737158f, -0.48879968f, -0.49022648f, -0.49165197f, --0.49307614f, -0.49449899f, -0.49592052f, -0.49734072f, -0.49875959f, --0.50017712f, -0.50159331f, -0.50300816f, -0.50442167f, -0.50583382f, --0.50724462f, -0.50865406f, -0.51006214f, -0.51146885f, -0.51287419f, --0.51427817f, -0.51568076f, -0.51708197f, -0.51848180f, -0.51988024f, --0.52127729f, -0.52267294f, -0.52406720f, -0.52546005f, -0.52685149f, --0.52824153f, -0.52963015f, -0.53101735f, -0.53240313f, -0.53378748f, --0.53517041f, -0.53655190f, -0.53793196f, -0.53931057f, -0.54068774f, --0.54206347f, -0.54343774f, -0.54481056f, -0.54618192f, -0.54755181f, --0.54892024f, -0.55028721f, -0.55165269f, -0.55301671f, -0.55437924f, --0.55574028f, -0.55709984f, -0.55845791f, -0.55981448f, -0.56116955f, --0.56252312f, -0.56387519f, -0.56522574f, -0.56657478f, -0.56792231f, --0.56926831f, -0.57061279f, -0.57195575f, -0.57329717f, -0.57463705f, --0.57597540f, -0.57731221f, -0.57864747f, -0.57998118f, -0.58131334f, --0.58264394f, -0.58397298f, -0.58530046f, -0.58662637f, -0.58795071f, --0.58927348f, -0.59059466f, -0.59191427f, -0.59323230f, -0.59454873f, --0.59586357f, -0.59717682f, -0.59848847f, -0.59979852f, -0.60110696f, --0.60241379f, -0.60371901f, -0.60502261f, -0.60632459f, -0.60762495f, --0.60892368f, -0.61022078f, -0.61151625f, -0.61281008f, -0.61410227f, --0.61539282f, -0.61668172f, -0.61796896f, -0.61925456f, -0.62053849f, --0.62182077f, -0.62310138f, -0.62438032f, -0.62565759f, -0.62693318f, --0.62820709f, -0.62947933f, -0.63074988f, -0.63201874f, -0.63328590f, --0.63455138f, -0.63581515f, -0.63707722f, -0.63833758f, -0.63959624f, --0.64085318f, -0.64210841f, -0.64336192f, -0.64461371f, -0.64586377f, --0.64711210f, -0.64835870f, -0.64960356f, -0.65084668f, -0.65208807f, --0.65332770f, -0.65456559f, -0.65580172f, -0.65703610f, -0.65826872f, --0.65949958f, -0.66072867f, -0.66195599f, -0.66318154f, -0.66440531f, --0.66562731f, -0.66684752f, -0.66806595f, -0.66928259f, -0.67049744f, --0.67171049f, -0.67292174f, -0.67413119f, -0.67533884f, -0.67654468f, --0.67774871f, -0.67895092f, -0.68015132f, -0.68134989f, -0.68254664f, --0.68374157f, -0.68493466f, -0.68612592f, -0.68731534f, -0.68850292f, --0.68968866f, -0.69087255f, -0.69205460f, -0.69323478f, -0.69441312f, --0.69558959f, -0.69676420f, -0.69793695f, -0.69910783f, -0.70027684f, --0.70144397f, -0.70260922f, -0.70377259f, -0.70493408f, -0.70609368f, --0.70725139f, -0.70840721f, -0.70956113f, -0.71071315f, -0.71186327f, --0.71301148f, -0.71415778f, -0.71530217f, -0.71644465f, -0.71758521f, --0.71872384f, -0.71986055f, -0.72099534f, -0.72212819f, -0.72325912f, --0.72438810f, -0.72551515f, -0.72664025f, -0.72776341f, -0.72888462f, --0.73000387f, -0.73112118f, -0.73223652f, -0.73334991f, -0.73446133f, --0.73557079f, -0.73667827f, -0.73778379f, -0.73888732f, -0.73998888f, --0.74108846f, -0.74218606f, -0.74328167f, -0.74437529f, -0.74546691f, --0.74655654f, -0.74764417f, -0.74872980f, -0.74981342f, -0.75089504f, --0.75197465f, -0.75305224f, -0.75412782f, -0.75520138f, -0.75627291f, --0.75734242f, -0.75840991f, -0.75947536f, -0.76053878f, -0.76160017f, --0.76265951f, -0.76371681f, -0.76477207f, -0.76582528f, -0.76687644f, --0.76792555f, -0.76897260f, -0.77001759f, -0.77106052f, -0.77210139f, --0.77314019f, -0.77417692f, -0.77521158f, -0.77624416f, -0.77727466f, --0.77830308f, -0.77932942f, -0.78035367f, -0.78137584f, -0.78239591f, --0.78341388f, -0.78442976f, -0.78544354f, -0.78645521f, -0.78746478f, --0.78847224f, -0.78947760f, -0.79048083f, -0.79148195f, -0.79248095f, --0.79347783f, -0.79447259f, -0.79546522f, -0.79645572f, -0.79744408f, --0.79843031f, -0.79941441f, -0.80039636f, -0.80137617f, -0.80235384f, --0.80332935f, -0.80430272f, -0.80527393f, -0.80624299f, -0.80720989f, --0.80817462f, -0.80913720f, -0.81009760f, -0.81105584f, -0.81201191f, --0.81296580f, -0.81391752f, -0.81486706f, -0.81581441f, -0.81675958f, --0.81770257f, -0.81864336f, -0.81958197f, -0.82051837f, -0.82145259f, --0.82238460f, -0.82331441f, -0.82424202f, -0.82516742f, -0.82609061f, --0.82701159f, -0.82793036f, -0.82884690f, -0.82976123f, -0.83067334f, --0.83158323f, -0.83249088f, -0.83339631f, -0.83429951f, -0.83520047f, --0.83609920f, -0.83699569f, -0.83788994f, -0.83878195f, -0.83967171f, --0.84055922f, -0.84144448f, -0.84232749f, -0.84320824f, -0.84408674f, --0.84496297f, -0.84583694f, -0.84670865f, -0.84757810f, -0.84844527f, --0.84931017f, -0.85017280f, -0.85103315f, -0.85189122f, -0.85274701f, --0.85360052f, -0.85445175f, -0.85530068f, -0.85614733f, -0.85699168f, --0.85783374f, -0.85867350f, -0.85951097f, -0.86034613f, -0.86117899f, --0.86200954f, -0.86283779f, -0.86366373f, -0.86448735f, -0.86530866f, --0.86612765f, -0.86694432f, -0.86775868f, -0.86857071f, -0.86938041f, --0.87018779f, -0.87099283f, -0.87179555f, -0.87259593f, -0.87339397f, --0.87418968f, -0.87498304f, -0.87577407f, -0.87656274f, -0.87734907f, --0.87813306f, -0.87891469f, -0.87969397f, -0.88047089f, -0.88124545f, --0.88201766f, -0.88278751f, -0.88355499f, -0.88432010f, -0.88508285f, --0.88584323f, -0.88660124f, -0.88735687f, -0.88811013f, -0.88886101f, --0.88960951f, -0.89035563f, -0.89109936f, -0.89184071f, -0.89257967f, --0.89331624f, -0.89405042f, -0.89478221f, -0.89551160f, -0.89623859f, --0.89696318f, -0.89768538f, -0.89840516f, -0.89912255f, -0.89983752f, --0.90055009f, -0.90126025f, -0.90196799f, -0.90267332f, -0.90337623f, --0.90407672f, -0.90477479f, -0.90547044f, -0.90616367f, -0.90685447f, --0.90754284f, -0.90822878f, -0.90891229f, -0.90959337f, -0.91027201f, --0.91094822f, -0.91162198f, -0.91229331f, -0.91296219f, -0.91362863f, --0.91429262f, -0.91495417f, -0.91561326f, -0.91626990f, -0.91692409f, --0.91757583f, -0.91822511f, -0.91887193f, -0.91951629f, -0.92015819f, --0.92079762f, -0.92143459f, -0.92206909f, -0.92270113f, -0.92333069f, --0.92395778f, -0.92458240f, -0.92520454f, -0.92582421f, -0.92644140f, --0.92705610f, -0.92766833f, -0.92827807f, -0.92888532f, -0.92949009f, --0.93009237f, -0.93069216f, -0.93128946f, -0.93188427f, -0.93247658f, --0.93306639f, -0.93365370f, -0.93423852f, -0.93482083f, -0.93540065f, --0.93597795f, -0.93655275f, -0.93712505f, -0.93769483f, -0.93826211f, --0.93882687f, -0.93938912f, -0.93994885f, -0.94050607f, -0.94106077f, --0.94161295f, -0.94216261f, -0.94270975f, -0.94325436f, -0.94379644f, --0.94433601f, -0.94487304f, -0.94540754f, -0.94593951f, -0.94646895f, --0.94699585f, -0.94752022f, -0.94804206f, -0.94856135f, -0.94907810f, --0.94959232f, -0.95010399f, -0.95061312f, -0.95111970f, -0.95162374f, --0.95212522f, -0.95262416f, -0.95312055f, -0.95361439f, -0.95410567f, --0.95459440f, -0.95508058f, -0.95556419f, -0.95604525f, -0.95652375f, --0.95699969f, -0.95747306f, -0.95794388f, -0.95841212f, -0.95887780f, --0.95934092f, -0.95980146f, -0.96025944f, -0.96071485f, -0.96116768f, --0.96161794f, -0.96206562f, -0.96251073f, -0.96295327f, -0.96339322f, --0.96383060f, -0.96426539f, -0.96469760f, -0.96512723f, -0.96555428f, --0.96597874f, -0.96640062f, -0.96681991f, -0.96723660f, -0.96765071f, --0.96806223f, -0.96847116f, -0.96887749f, -0.96928124f, -0.96968238f, --0.97008093f, -0.97047688f, -0.97087024f, -0.97126099f, -0.97164914f, --0.97203470f, -0.97241765f, -0.97279799f, -0.97317574f, -0.97355087f, --0.97392340f, -0.97429333f, -0.97466064f, -0.97502535f, -0.97538744f, --0.97574692f, -0.97610379f, -0.97645805f, -0.97680969f, -0.97715872f, --0.97750513f, -0.97784893f, -0.97819010f, -0.97852866f, -0.97886460f, --0.97919792f, -0.97952861f, -0.97985669f, -0.98018214f, -0.98050496f, --0.98082516f, -0.98114274f, -0.98145768f, -0.98177000f, -0.98207970f, --0.98238676f, -0.98269119f, -0.98299299f, -0.98329216f, -0.98358870f, --0.98388260f, -0.98417387f, -0.98446250f, -0.98474850f, -0.98503186f, --0.98531259f, -0.98559068f, -0.98586612f, -0.98613893f, -0.98640910f, --0.98667663f, -0.98694151f, -0.98720376f, -0.98746336f, -0.98772032f, --0.98797463f, -0.98822630f, -0.98847532f, -0.98872169f, -0.98896542f, --0.98920650f, -0.98944493f, -0.98968071f, -0.98991385f, -0.99014433f, --0.99037216f, -0.99059734f, -0.99081987f, -0.99103975f, -0.99125697f, --0.99147154f, -0.99168345f, -0.99189271f, -0.99209931f, -0.99230326f, --0.99250455f, -0.99270318f, -0.99289916f, -0.99309248f, -0.99328313f, --0.99347113f, -0.99365647f, -0.99383915f, -0.99401917f, -0.99419653f, --0.99437122f, -0.99454325f, -0.99471262f, -0.99487933f, -0.99504337f, --0.99520475f, -0.99536347f, -0.99551952f, -0.99567290f, -0.99582362f, --0.99597167f, -0.99611706f, -0.99625978f, -0.99639983f, -0.99653722f, --0.99667193f, -0.99680398f, -0.99693336f, -0.99706007f, -0.99718411f, --0.99730548f, -0.99742418f, -0.99754021f, -0.99765357f, -0.99776426f, --0.99787228f, -0.99797763f, -0.99808030f, -0.99818030f, -0.99827763f, --0.99837229f, -0.99846427f, -0.99855358f, -0.99864022f, -0.99872418f, --0.99880547f, -0.99888409f, -0.99896003f, -0.99903329f, -0.99910389f, --0.99917180f, -0.99923705f, -0.99929961f, -0.99935950f, -0.99941672f, --0.99947126f, -0.99952312f, -0.99957231f, -0.99961882f, -0.99966266f, --0.99970382f, -0.99974230f, -0.99977811f, -0.99981124f, -0.99984169f, --0.99986946f, -0.99989456f, -0.99991698f, -0.99993673f, -0.99995380f, --0.99996819f, -0.99997990f, -0.99998894f, -0.99999529f, -0.99999898f, -0.99999992f, 0.99999322f, 0.99997582f, 0.99994771f, 0.99990889f, -0.99985936f, 0.99979913f, 0.99972818f, 0.99964653f, 0.99955418f, -0.99945112f, 0.99933736f, 0.99921289f, 0.99907773f, 0.99893186f, -0.99877530f, 0.99860804f, 0.99843009f, 0.99824144f, 0.99804211f, -0.99783209f, 0.99761138f, 0.99737998f, 0.99713791f, 0.99688516f, -0.99662173f, 0.99634763f, 0.99606285f, 0.99576741f, 0.99546131f, -0.99514455f, 0.99481713f, 0.99447905f, 0.99413033f, 0.99377096f, -0.99340095f, 0.99302029f, 0.99262901f, 0.99222709f, 0.99181455f, -0.99139139f, 0.99095760f, 0.99051321f, 0.99005821f, 0.98959261f, -0.98911641f, 0.98862961f, 0.98813223f, 0.98762427f, 0.98710573f, -0.98657662f, 0.98603694f, 0.98548670f, 0.98492591f, 0.98435457f, -0.98377269f, 0.98318028f, 0.98257734f, 0.98196387f, 0.98133989f, -0.98070539f, 0.98006040f, 0.97940491f, 0.97873893f, 0.97806247f, -0.97737554f, 0.97667813f, 0.97597027f, 0.97525196f, 0.97452320f, -0.97378401f, 0.97303439f, 0.97227435f, 0.97150389f, 0.97072303f, -0.96993178f, 0.96913014f, 0.96831812f, 0.96749573f, 0.96666298f, -0.96581987f, 0.96496643f, 0.96410265f, 0.96322854f, 0.96234412f, -0.96144939f, 0.96054437f, 0.95962906f, 0.95870347f, 0.95776762f, -0.95682151f, 0.95586515f, 0.95489856f, 0.95392174f, 0.95293471f, -0.95193746f, 0.95093003f, 0.94991241f, 0.94888462f, 0.94784667f, -0.94679856f, 0.94574032f, 0.94467195f, 0.94359346f, 0.94250486f, -0.94140618f, 0.94029741f, 0.93917857f, 0.93804967f, 0.93691073f, -0.93576176f, 0.93460276f, 0.93343375f, 0.93225475f, 0.93106577f, -0.92986681f, 0.92865789f, 0.92743903f, 0.92621024f, 0.92497153f, -0.92372291f, 0.92246440f, 0.92119602f, 0.91991776f, 0.91862966f, -0.91733172f, 0.91602395f, 0.91470637f, 0.91337900f, 0.91204185f, -0.91069493f, 0.90933825f, 0.90797184f, 0.90659570f, 0.90520986f, -0.90381432f, 0.90240910f, 0.90099422f, 0.89956969f, 0.89813553f, -0.89669174f, 0.89523836f, 0.89377538f, 0.89230284f, 0.89082074f, -0.88932910f, 0.88782793f, 0.88631726f, 0.88479710f, 0.88326746f, -0.88172836f, 0.88017982f, 0.87862185f, 0.87705448f, 0.87547771f, -0.87389156f, 0.87229606f, 0.87069121f, 0.86907704f, 0.86745357f, -0.86582080f, 0.86417876f, 0.86252747f, 0.86086694f, 0.85919719f, -0.85751824f, 0.85583010f, 0.85413281f, 0.85242636f, 0.85071078f, -0.84898610f, 0.84725232f, 0.84550947f, 0.84375756f, 0.84199662f, -0.84022666f, 0.83844771f, 0.83665977f, 0.83486287f, 0.83305704f, -0.83124228f, 0.82941862f, 0.82758608f, 0.82574467f, 0.82389442f, -0.82203535f, 0.82016748f, 0.81829082f, 0.81640540f, 0.81451123f, -0.81260835f, 0.81069676f, 0.80877649f, 0.80684755f, 0.80490998f, -0.80296379f, 0.80100899f, 0.79904562f, 0.79707370f, 0.79509323f, -0.79310425f, 0.79110678f, 0.78910084f, 0.78708644f, 0.78506362f, -0.78303239f, 0.78099277f, 0.77894479f, 0.77688847f, 0.77482382f, -0.77275088f, 0.77066967f, 0.76858020f, 0.76648250f, 0.76437659f, -0.76226250f, 0.76014024f, 0.75800984f, 0.75587132f, 0.75372471f, -0.75157003f, 0.74940730f, 0.74723654f, 0.74505779f, 0.74287105f, -0.74067635f, 0.73847373f, 0.73626320f, 0.73404478f, 0.73181850f, -0.72958438f, 0.72734245f, 0.72509273f, 0.72283525f, 0.72057002f, -0.71829708f, 0.71601644f, 0.71372814f, 0.71143220f, 0.70912863f, -0.70681747f, 0.70449874f, 0.70217247f, 0.69983868f, 0.69749739f, -0.69514863f, 0.69279243f, 0.69042881f, 0.68805780f, 0.68567941f, -0.68329369f, 0.68090064f, 0.67850031f, 0.67609270f, 0.67367786f, -0.67125580f, 0.66882656f, 0.66639015f, 0.66394661f, 0.66149595f, -0.65903821f, 0.65657341f, 0.65410159f, 0.65162275f, 0.64913694f, -0.64664418f, 0.64414449f, 0.64163790f, 0.63912444f, 0.63660414f, -0.63407702f, 0.63154311f, 0.62900244f, 0.62645503f, 0.62390091f, -0.62134011f, 0.61877265f, 0.61619857f, 0.61361789f, 0.61103064f, -0.60843685f, 0.60583654f, 0.60322974f, 0.60061648f, 0.59799679f, -0.59537069f, 0.59273822f, 0.59009940f, 0.58745427f, 0.58480284f, -0.58214514f, 0.57948122f, 0.57681109f, 0.57413478f, 0.57145232f, -0.56876374f, 0.56606907f, 0.56336834f, 0.56066158f, 0.55794881f, -0.55523006f, 0.55250537f, 0.54977477f, 0.54703827f, 0.54429592f, -0.54154774f, 0.53879376f, 0.53603401f, 0.53326852f, 0.53049731f, -0.52772043f, 0.52493790f, 0.52214974f, 0.51935599f, 0.51655668f, -0.51375184f, 0.51094149f, 0.50812568f, 0.50530442f, 0.50247775f, -0.49964570f, 0.49680830f, 0.49396558f, 0.49111757f, 0.48826430f, -0.48540580f, 0.48254210f, 0.47967323f, 0.47679923f, 0.47392012f, -0.47103594f, 0.46814671f, 0.46525247f, 0.46235324f, 0.45944907f, -0.45653997f, 0.45362599f, 0.45070714f, 0.44778347f, 0.44485501f, -0.44192178f, 0.43898381f, 0.43604115f, 0.43309382f, 0.43014185f, -0.42718527f, 0.42422412f, 0.42125842f, 0.41828822f, 0.41531353f, -0.41233440f, 0.40935085f, 0.40636291f, 0.40337063f, 0.40037402f, -0.39737313f, 0.39436798f, 0.39135861f, 0.38834505f, 0.38532733f, -0.38230548f, 0.37927953f, 0.37624953f, 0.37321550f, 0.37017747f, -0.36713547f, 0.36408955f, 0.36103972f, 0.35798603f, 0.35492850f, -0.35186718f, 0.34880208f, 0.34573325f, 0.34266072f, 0.33958451f, -0.33650468f, 0.33342123f, 0.33033422f, 0.32724367f, 0.32414961f, -0.32105209f, 0.31795112f, 0.31484675f, 0.31173901f, 0.30862793f, -0.30551354f, 0.30239588f, 0.29927499f, 0.29615089f, 0.29302362f, -0.28989321f, 0.28675969f, 0.28362310f, 0.28048348f, 0.27734085f, -0.27419526f, 0.27104672f, 0.26789529f, 0.26474098f, 0.26158384f, -0.25842390f, 0.25526119f, 0.25209575f, 0.24892761f, 0.24575680f, -0.24258336f, 0.23940732f, 0.23622872f, 0.23304759f, 0.22986396f, -0.22667787f, 0.22348935f, 0.22029844f, 0.21710517f, 0.21390958f, -0.21071169f, 0.20751155f, 0.20430919f, 0.20110463f, 0.19789793f, -0.19468910f, 0.19147819f, 0.18826523f, 0.18505026f, 0.18183330f, -0.17861439f, 0.17539357f, 0.17217088f, 0.16894634f, 0.16571999f, -0.16249186f, 0.15926200f, 0.15603043f, 0.15279719f, 0.14956231f, -0.14632583f, 0.14308778f, 0.13984820f, 0.13660713f, 0.13336459f, -0.13012062f, 0.12687526f, 0.12362854f, 0.12038049f, 0.11713116f, -0.11388057f, 0.11062877f, 0.10737578f, 0.10412163f, 0.10086638f, -0.097610040f, 0.094352658f, 0.091094266f, 0.087834897f, 0.084574589f, -0.081313374f, 0.078051289f, 0.074788367f, 0.071524645f, 0.068260157f, -0.064994938f, 0.061729023f, 0.058462447f, 0.055195244f, 0.051927451f, -0.048659101f, 0.045390231f, 0.042120874f, 0.038851066f, 0.035580842f, -0.032310238f, 0.029039287f, 0.025768025f, 0.022496487f, 0.019224708f, -0.015952723f, 0.012680568f, 0.0094082767f, 0.0061358846f, 0.0028634269f, --0.00040906153f, -0.0036815456f, -0.0069539902f, -0.010226360f, -0.013498621f, --0.016770737f, -0.020042673f, -0.023314395f, -0.026585867f, -0.029857055f, --0.033127923f, -0.036398436f, -0.039668559f, -0.042938257f, -0.046207495f, --0.049476239f, -0.052744453f, -0.056012102f, -0.059279151f, -0.062545565f, --0.065811309f, -0.069076349f, -0.072340649f, -0.075604174f, -0.078866890f, --0.082128761f, -0.085389752f, -0.088649829f, -0.091908956f, -0.095167100f, --0.098424224f, -0.10168029f, -0.10493528f, -0.10818913f, -0.11144183f, --0.11469334f, -0.11794361f, -0.12119263f, -0.12444034f, -0.12768673f, --0.13093174f, -0.13417536f, -0.13741753f, -0.14065824f, -0.14389744f, --0.14713510f, -0.15037118f, -0.15360565f, -0.15683848f, -0.16006962f, --0.16329906f, -0.16652674f, -0.16975264f, -0.17297673f, -0.17619896f, --0.17941930f, -0.18263772f, -0.18585419f, -0.18906866f, -0.19228112f, --0.19549151f, -0.19869981f, -0.20190598f, -0.20510998f, -0.20831180f, --0.21151138f, -0.21470869f, -0.21790371f, -0.22109639f, -0.22428671f, --0.22747462f, -0.23066010f, -0.23384310f, -0.23702361f, -0.24020157f, --0.24337696f, -0.24654975f, -0.24971989f, -0.25288736f, -0.25605213f, --0.25921415f, -0.26237339f, -0.26552983f, -0.26868342f, -0.27183413f, --0.27498193f, -0.27812679f, -0.28126867f, -0.28440754f, -0.28754336f, --0.29067610f, -0.29380573f, -0.29693221f, -0.30005551f, -0.30317560f, --0.30629245f, -0.30940601f, -0.31251626f, -0.31562316f, -0.31872668f, --0.32182679f, -0.32492345f, -0.32801664f, -0.33110631f, -0.33419243f, --0.33727497f, -0.34035391f, -0.34342920f, -0.34650081f, -0.34956871f, --0.35263286f, -0.35569324f, -0.35874981f, -0.36180254f, -0.36485139f, --0.36789634f, -0.37093735f, -0.37397438f, -0.37700741f, -0.38003640f, --0.38306132f, -0.38608214f, -0.38909883f, -0.39211135f, -0.39511967f, --0.39812375f, -0.40112358f, -0.40411910f, -0.40711031f, -0.41009715f, --0.41307959f, -0.41605762f, -0.41903119f, -0.42200027f, -0.42496483f, --0.42792484f, -0.43088027f, -0.43383109f, -0.43677726f, -0.43971875f, --0.44265553f, -0.44558757f, -0.44851484f, -0.45143731f, -0.45435494f, --0.45726770f, -0.46017557f, -0.46307851f, -0.46597650f, -0.46886949f, --0.47175746f, -0.47464038f, -0.47751821f, -0.48039093f, -0.48325851f, --0.48612091f, -0.48897811f, -0.49183006f, -0.49467676f, -0.49751815f, --0.50035422f, -0.50318492f, -0.50601024f, -0.50883014f, -0.51164459f, --0.51445356f, -0.51725703f, -0.52005495f, -0.52284730f, -0.52563406f, --0.52841518f, -0.53119065f, -0.53396043f, -0.53672449f, -0.53948280f, --0.54223533f, -0.54498206f, -0.54772295f, -0.55045797f, -0.55318710f, --0.55591031f, -0.55862756f, -0.56133883f, -0.56404409f, -0.56674331f, --0.56943646f, -0.57212351f, -0.57480443f, -0.57747920f, -0.58014778f, --0.58281015f, -0.58546628f, -0.58811614f, -0.59075970f, -0.59339694f, --0.59602782f, -0.59865231f, -0.60127040f, -0.60388204f, -0.60648722f, --0.60908591f, -0.61167807f, -0.61426368f, -0.61684271f, -0.61941514f, --0.62198093f, -0.62454007f, -0.62709251f, -0.62963824f, -0.63217722f, --0.63470944f, -0.63723486f, -0.63975345f, -0.64226519f, -0.64477006f, --0.64726802f, -0.64975905f, -0.65224312f, -0.65472020f, -0.65719027f, --0.65965331f, -0.66210928f, -0.66455816f, -0.66699992f, -0.66943454f, --0.67186199f, -0.67428225f, -0.67669528f, -0.67910107f, -0.68149959f, --0.68389080f, -0.68627470f, -0.68865124f, -0.69102041f, -0.69338218f, --0.69573652f, -0.69808341f, -0.70042283f, -0.70275474f, -0.70507913f, --0.70739597f, -0.70970524f, -0.71200690f, -0.71430093f, -0.71658732f, --0.71886604f, -0.72113705f, -0.72340034f, -0.72565589f, -0.72790366f, --0.73014364f, -0.73237580f, -0.73460012f, -0.73681657f, -0.73902513f, --0.74122577f, -0.74341848f, -0.74560322f, -0.74777998f, -0.74994874f, --0.75210946f, -0.75426212f, -0.75640671f, -0.75854320f, -0.76067157f, --0.76279178f, -0.76490383f, -0.76700769f, -0.76910334f, -0.77119075f, --0.77326989f, -0.77534076f, -0.77740333f, -0.77945757f, -0.78150346f, --0.78354098f, -0.78557011f, -0.78759083f, -0.78960312f, -0.79160694f, --0.79360229f, -0.79558915f, -0.79756748f, -0.79953727f, -0.80149850f, --0.80345114f, -0.80539518f, -0.80733060f, -0.80925737f, -0.81117547f, --0.81308489f, -0.81498559f, -0.81687757f, -0.81876081f, -0.82063527f, --0.82250095f, -0.82435781f, -0.82620585f, -0.82804505f, -0.82987537f, --0.83169681f, -0.83350933f, -0.83531294f, -0.83710760f, -0.83889329f, --0.84067000f, -0.84243770f, -0.84419639f, -0.84594603f, -0.84768662f, --0.84941812f, -0.85114053f, -0.85285383f, -0.85455799f, -0.85625300f, --0.85793884f, -0.85961549f, -0.86128294f, -0.86294116f, -0.86459014f, --0.86622986f, -0.86786031f, -0.86948146f, -0.87109330f, -0.87269581f, --0.87428898f, -0.87587278f, -0.87744720f, -0.87901223f, -0.88056784f, --0.88211402f, -0.88365076f, -0.88517803f, -0.88669582f, -0.88820412f, --0.88970290f, -0.89119216f, -0.89267187f, -0.89414203f, -0.89560260f, --0.89705359f, -0.89849497f, -0.89992673f, -0.90134885f, -0.90276131f, --0.90416411f, -0.90555723f, -0.90694065f, -0.90831436f, -0.90967833f, --0.91103257f, -0.91237705f, -0.91371176f, -0.91503669f, -0.91635181f, --0.91765712f, -0.91895261f, -0.92023825f, -0.92151404f, -0.92277996f, --0.92403600f, -0.92528214f, -0.92651837f, -0.92774468f, -0.92896106f, --0.93016748f, -0.93136395f, -0.93255044f, -0.93372694f, -0.93489345f, --0.93604994f, -0.93719641f, -0.93833284f, -0.93945922f, -0.94057555f, --0.94168180f, -0.94277796f, -0.94386403f, -0.94493999f, -0.94600583f, --0.94706154f, -0.94810711f, -0.94914252f, -0.95016777f, -0.95118284f, --0.95218773f, -0.95318242f, -0.95416690f, -0.95514117f, -0.95610520f, --0.95705900f, -0.95800255f, -0.95893583f, -0.95985885f, -0.96077159f, --0.96167404f, -0.96256619f, -0.96344803f, -0.96431956f, -0.96518076f, --0.96603162f, -0.96687213f, -0.96770230f, -0.96852209f, -0.96933152f, --0.97013057f, -0.97091922f, -0.97169748f, -0.97246533f, -0.97322277f, --0.97396979f, -0.97470637f, -0.97543252f, -0.97614822f, -0.97685347f, --0.97754825f, -0.97823257f, -0.97890641f, -0.97956977f, -0.98022263f, --0.98086500f, -0.98149687f, -0.98211822f, -0.98272906f, -0.98332937f, --0.98391915f, -0.98449840f, -0.98506710f, -0.98562525f, -0.98617285f, --0.98670988f, -0.98723635f, -0.98775225f, -0.98825757f, -0.98875230f, --0.98923645f, -0.98971000f, -0.99017295f, -0.99062530f, -0.99106704f, --0.99149817f, -0.99191868f, -0.99232857f, -0.99272783f, -0.99311645f, --0.99349445f, -0.99386180f, -0.99421851f, -0.99456457f, -0.99489998f, --0.99522474f, -0.99553884f, -0.99584227f, -0.99613505f, -0.99641715f, --0.99668858f, -0.99694934f, -0.99719943f, -0.99743883f, -0.99766756f, --0.99788559f, -0.99809295f, -0.99828961f, -0.99847558f, -0.99865086f, --0.99881544f, -0.99896933f, -0.99911252f, -0.99924501f, -0.99936680f, --0.99947789f, -0.99957827f, -0.99966795f, -0.99974692f, -0.99981519f, --0.99987275f, -0.99991960f, -0.99995574f, -0.99998118f, -0.99999590f, -0.99999967f, 0.99997289f, 0.99990328f, 0.99979084f, 0.99963557f, -0.99943748f, 0.99919658f, 0.99891288f, 0.99858638f, 0.99821711f, -0.99780508f, 0.99735031f, 0.99685281f, 0.99631261f, 0.99572973f, -0.99510420f, 0.99443605f, 0.99372529f, 0.99297196f, 0.99217610f, -0.99133774f, 0.99045692f, 0.98953366f, 0.98856802f, 0.98756003f, -0.98650973f, 0.98541718f, 0.98428242f, 0.98310549f, 0.98188645f, -0.98062534f, 0.97932224f, 0.97797718f, 0.97659022f, 0.97516144f, -0.97369088f, 0.97217861f, 0.97062469f, 0.96902920f, 0.96739220f, -0.96571376f, 0.96399395f, 0.96223284f, 0.96043052f, 0.95858705f, -0.95670253f, 0.95477702f, 0.95281061f, 0.95080338f, 0.94875543f, -0.94666684f, 0.94453769f, 0.94236808f, 0.94015810f, 0.93790786f, -0.93561743f, 0.93328693f, 0.93091644f, 0.92850608f, 0.92605595f, -0.92356614f, 0.92103677f, 0.91846795f, 0.91585979f, 0.91321239f, -0.91052587f, 0.90780035f, 0.90503595f, 0.90223277f, 0.89939095f, -0.89651059f, 0.89359184f, 0.89063481f, 0.88763962f, 0.88460641f, -0.88153531f, 0.87842644f, 0.87527995f, 0.87209596f, 0.86887462f, -0.86561605f, 0.86232041f, 0.85898782f, 0.85561844f, 0.85221241f, -0.84876987f, 0.84529098f, 0.84177587f, 0.83822471f, 0.83463763f, -0.83101481f, 0.82735639f, 0.82366252f, 0.81993338f, 0.81616911f, -0.81236987f, 0.80853584f, 0.80466718f, 0.80076404f, 0.79682660f, -0.79285503f, 0.78884950f, 0.78481017f, 0.78073723f, 0.77663084f, -0.77249118f, 0.76831844f, 0.76411277f, 0.75987438f, 0.75560344f, -0.75130013f, 0.74696464f, 0.74259715f, 0.73819784f, 0.73376692f, -0.72930457f, 0.72481097f, 0.72028632f, 0.71573083f, 0.71114467f, -0.70652804f, 0.70188116f, 0.69720420f, 0.69249738f, 0.68776090f, -0.68299495f, 0.67819975f, 0.67337550f, 0.66852240f, 0.66364066f, -0.65873050f, 0.65379211f, 0.64882573f, 0.64383154f, 0.63880978f, -0.63376065f, 0.62868438f, 0.62358117f, 0.61845126f, 0.61329485f, -0.60811216f, 0.60290343f, 0.59766888f, 0.59240872f, 0.58712318f, -0.58181249f, 0.57647688f, 0.57111658f, 0.56573181f, 0.56032281f, -0.55488980f, 0.54943303f, 0.54395272f, 0.53844911f, 0.53292243f, -0.52737292f, 0.52180083f, 0.51620638f, 0.51058981f, 0.50495138f, -0.49929132f, 0.49360987f, 0.48790727f, 0.48218377f, 0.47643962f, -0.47067506f, 0.46489034f, 0.45908570f, 0.45326139f, 0.44741768f, -0.44155479f, 0.43567299f, 0.42977253f, 0.42385365f, 0.41791662f, -0.41196169f, 0.40598911f, 0.39999914f, 0.39399204f, 0.38796806f, -0.38192746f, 0.37587050f, 0.36979743f, 0.36370853f, 0.35760405f, -0.35148424f, 0.34534939f, 0.33919973f, 0.33303555f, 0.32685710f, -0.32066465f, 0.31445847f, 0.30823881f, 0.30200595f, 0.29576015f, -0.28950169f, 0.28323082f, 0.27694782f, 0.27065295f, 0.26434649f, -0.25802871f, 0.25169988f, 0.24536026f, 0.23901013f, 0.23264977f, -0.22627944f, 0.21989941f, 0.21350997f, 0.20711138f, 0.20070391f, -0.19428785f, 0.18786347f, 0.18143104f, 0.17499084f, 0.16854314f, -0.16208822f, 0.15562636f, 0.14915783f, 0.14268292f, 0.13620189f, -0.12971502f, 0.12322260f, 0.11672491f, 0.11022221f, 0.10371479f, -0.097202924f, 0.090686897f, 0.084166986f, 0.077643468f, 0.071116625f, -0.064586736f, 0.058054080f, 0.051518937f, 0.044981587f, 0.038442310f, -0.031901387f, 0.025359097f, 0.018815721f, 0.012271538f, 0.0057268303f, --0.00081812300f, -0.0073630412f, -0.013907644f, -0.020451651f, -0.026994782f, --0.033536757f, -0.040077295f, -0.046616116f, -0.053152941f, -0.059687488f, --0.066219479f, -0.072748633f, -0.079274670f, -0.085797312f, -0.092316279f, --0.098831291f, -0.10534207f, -0.11184834f, -0.11834981f, -0.12484622f, --0.13133727f, -0.13782270f, -0.14430223f, -0.15077558f, -0.15724246f, --0.16370261f, -0.17015575f, -0.17660160f, -0.18303989f, -0.18947033f, --0.19589266f, -0.20230660f, -0.20871187f, -0.21510820f, -0.22149531f, --0.22787294f, -0.23424080f, -0.24059864f, -0.24694616f, -0.25328311f, --0.25960920f, -0.26592418f, -0.27222777f, -0.27851969f, -0.28479968f, --0.29106748f, -0.29732280f, -0.30356539f, -0.30979497f, -0.31601129f, --0.32221406f, -0.32840304f, -0.33457794f, -0.34073852f, -0.34688450f, --0.35301562f, -0.35913161f, -0.36523223f, -0.37131719f, -0.37738626f, --0.38343915f, -0.38947562f, -0.39549541f, -0.40149825f, -0.40748390f, --0.41345209f, -0.41940257f, -0.42533508f, -0.43124938f, -0.43714520f, --0.44302229f, -0.44888041f, -0.45471930f, -0.46053871f, -0.46633839f, --0.47211810f, -0.47787758f, -0.48361659f, -0.48933489f, -0.49503222f, --0.50070835f, -0.50636303f, -0.51199602f, -0.51760707f, -0.52319595f, --0.52876243f, -0.53430625f, -0.53982718f, -0.54532499f, -0.55079944f, --0.55625029f, -0.56167732f, -0.56708028f, -0.57245896f, -0.57781311f, --0.58314251f, -0.58844693f, -0.59372614f, -0.59897992f, -0.60420805f, --0.60941029f, -0.61458642f, -0.61973623f, -0.62485949f, -0.62995598f, --0.63502549f, -0.64006780f, -0.64508268f, -0.65006994f, -0.65502934f, --0.65996069f, -0.66486377f, -0.66973837f, -0.67458427f, -0.67940128f, --0.68418919f, -0.68894779f, -0.69367688f, -0.69837625f, -0.70304571f, --0.70768504f, -0.71229407f, -0.71687258f, -0.72142039f, -0.72593729f, --0.73042309f, -0.73487761f, -0.73930064f, -0.74369201f, -0.74805152f, --0.75237898f, -0.75667422f, -0.76093704f, -0.76516727f, -0.76936471f, --0.77352921f, -0.77766056f, -0.78175861f, -0.78582316f, -0.78985406f, --0.79385112f, -0.79781417f, -0.80174305f, -0.80563758f, -0.80949760f, --0.81332295f, -0.81711346f, -0.82086896f, -0.82458930f, -0.82827432f, --0.83192386f, -0.83553776f, -0.83911587f, -0.84265803f, -0.84616410f, --0.84963392f, -0.85306735f, -0.85646423f, -0.85982442f, -0.86314779f, --0.86643418f, -0.86968345f, -0.87289547f, -0.87607009f, -0.87920719f, --0.88230663f, -0.88536827f, -0.88839199f, -0.89137765f, -0.89432512f, --0.89723429f, -0.90010502f, -0.90293719f, -0.90573069f, -0.90848539f, --0.91120117f, -0.91387791f, -0.91651551f, -0.91911385f, -0.92167282f, --0.92419231f, -0.92667220f, -0.92911240f, -0.93151280f, -0.93387330f, --0.93619380f, -0.93847419f, -0.94071438f, -0.94291427f, -0.94507377f, --0.94719279f, -0.94927123f, -0.95130901f, -0.95330604f, -0.95526223f, --0.95717750f, -0.95905177f, -0.96088496f, -0.96267699f, -0.96442777f, --0.96613725f, -0.96780534f, -0.96943197f, -0.97101707f, -0.97256058f, --0.97406243f, -0.97552255f, -0.97694089f, -0.97831737f, -0.97965195f, --0.98094456f, -0.98219515f, -0.98340367f, -0.98457006f, -0.98569428f, --0.98677627f, -0.98781599f, -0.98881340f, -0.98976845f, -0.99068110f, --0.99155132f, -0.99237906f, -0.99316428f, -0.99390697f, -0.99460708f, --0.99526458f, -0.99587945f, -0.99645166f, -0.99698119f, -0.99746801f, --0.99791210f, -0.99831344f, -0.99867202f, -0.99898782f, -0.99926082f, --0.99949102f, -0.99967841f, -0.99982297f, -0.99992470f, -0.99998360f, -0.99999866f, 0.99989157f, 0.99961315f, 0.99916346f, 0.99854256f, -0.99775057f, 0.99678762f, 0.99565388f, 0.99434953f, 0.99287481f, -0.99122996f, 0.98941527f, 0.98743105f, 0.98527764f, 0.98295541f, -0.98046475f, 0.97780610f, 0.97497990f, 0.97198664f, 0.96882685f, -0.96550104f, 0.96200980f, 0.95835373f, 0.95453345f, 0.95054962f, -0.94640291f, 0.94209404f, 0.93762375f, 0.93299280f, 0.92820199f, -0.92325213f, 0.91814408f, 0.91287871f, 0.90745693f, 0.90187965f, -0.89614785f, 0.89026249f, 0.88422459f, 0.87803519f, 0.87169533f, -0.86520612f, 0.85856866f, 0.85178409f, 0.84485357f, 0.83777828f, -0.83055945f, 0.82319831f, 0.81569611f, 0.80805415f, 0.80027373f, -0.79235620f, 0.78430289f, 0.77611520f, 0.76779452f, 0.75934229f, -0.75075995f, 0.74204897f, 0.73321084f, 0.72424708f, 0.71515923f, -0.70594883f, 0.69661748f, 0.68716676f, 0.67759830f, 0.66791374f, -0.65811474f, 0.64820297f, 0.63818013f, 0.62804795f, 0.61780815f, -0.60746249f, 0.59701275f, 0.58646072f, 0.57580819f, 0.56505701f, -0.55420900f, 0.54326604f, 0.53222998f, 0.52110274f, 0.50988620f, -0.49858230f, 0.48719297f, 0.47572016f, 0.46416584f, 0.45253199f, -0.44082059f, 0.42903367f, 0.41717323f, 0.40524131f, 0.39323996f, -0.38117123f, 0.36903718f, 0.35683990f, 0.34458148f, 0.33226402f, -0.31988962f, 0.30746042f, 0.29497853f, 0.28244610f, 0.26986527f, -0.25723821f, 0.24456706f, 0.23185402f, 0.21910124f, 0.20631092f, -0.19348526f, 0.18062644f, 0.16773667f, 0.15481816f, 0.14187312f, -0.12890377f, 0.11591234f, 0.10290104f, 0.089872115f, 0.076827789f, -0.063770300f, 0.050701883f, 0.037624779f, 0.024541229f, 0.011453473f, --0.0016362454f, -0.014725683f, -0.027812598f, -0.040894747f, -0.053969889f, --0.067035784f, -0.080090192f, -0.093130877f, -0.10615561f, -0.11916214f, --0.13214826f, -0.14511174f, -0.15805036f, -0.17096189f, -0.18384413f, --0.19669487f, -0.20951190f, -0.22229304f, -0.23503609f, -0.24773886f, --0.26039919f, -0.27301490f, -0.28558383f, -0.29810383f, -0.31057274f, --0.32298845f, -0.33534881f, -0.34765171f, -0.35989504f, -0.37207670f, --0.38419461f, -0.39624670f, -0.40823088f, -0.42014512f, -0.43198737f, --0.44375560f, -0.45544780f, -0.46706195f, -0.47859608f, -0.49004821f, --0.50141636f, -0.51269860f, -0.52389299f, -0.53499762f, -0.54601058f, --0.55692998f, -0.56775395f, -0.57848064f, -0.58910822f, -0.59963485f, --0.61005873f, -0.62037809f, -0.63059115f, -0.64069616f, -0.65069139f, --0.66057513f, -0.67034568f, -0.68000137f, -0.68954054f, -0.69896157f, --0.70826283f, -0.71744274f, -0.72649972f, -0.73543221f, -0.74423869f, --0.75291765f, -0.76146760f, -0.76988708f, -0.77817464f, -0.78632887f, --0.79434836f, -0.80223175f, -0.80997767f, -0.81758481f, -0.82505187f, --0.83237755f, -0.83956061f, -0.84659981f, -0.85349396f, -0.86024186f, --0.86684237f, -0.87329434f, -0.87959669f, -0.88574831f, -0.89174817f, --0.89759523f, -0.90328850f, -0.90882699f, -0.91420976f, -0.91943588f, --0.92450446f, -0.92941463f, -0.93416555f, -0.93875641f, -0.94318642f, --0.94745482f, -0.95156087f, -0.95550388f, -0.95928317f, -0.96289809f, --0.96634802f, -0.96963238f, -0.97275059f, -0.97570213f, -0.97848649f, --0.98110318f, -0.98355177f, -0.98583184f, -0.98794298f, -0.98988485f, --0.99165711f, -0.99325945f, -0.99469160f, -0.99595331f, -0.99704438f, --0.99796460f, -0.99871383f, -0.99929194f, -0.99969882f, -0.99993441f, + 0.99999998f, 0.99999831f, 0.99999396f, 0.99998693f, 0.99997722f, + 0.99996484f, 0.99994978f, 0.99993204f, 0.99991163f, 0.99988854f, + 0.99986277f, 0.99983433f, 0.99980320f, 0.99976941f, 0.99973293f, + 0.99969378f, 0.99965195f, 0.99960745f, 0.99956026f, 0.99951041f, + 0.99945787f, 0.99940267f, 0.99934478f, 0.99928422f, 0.99922099f, + 0.99915507f, 0.99908649f, 0.99901523f, 0.99894129f, 0.99886468f, + 0.99878540f, 0.99870344f, 0.99861881f, 0.99853150f, 0.99844153f, + 0.99834887f, 0.99825355f, 0.99815555f, 0.99805488f, 0.99795154f, + 0.99784553f, 0.99773684f, 0.99762548f, 0.99751146f, 0.99739476f, + 0.99727539f, 0.99715335f, 0.99702864f, 0.99690127f, 0.99677122f, + 0.99663850f, 0.99650312f, 0.99636507f, 0.99622435f, 0.99608096f, + 0.99593491f, 0.99578619f, 0.99563481f, 0.99548076f, 0.99532404f, + 0.99516466f, 0.99500261f, 0.99483790f, 0.99467053f, 0.99450050f, + 0.99432780f, 0.99415244f, 0.99397441f, 0.99379373f, 0.99361039f, + 0.99342438f, 0.99323572f, 0.99304440f, 0.99285041f, 0.99265377f, + 0.99245448f, 0.99225252f, 0.99204791f, 0.99184064f, 0.99163072f, + 0.99141814f, 0.99120291f, 0.99098503f, 0.99076449f, 0.99054130f, + 0.99031545f, 0.99008696f, 0.98985581f, 0.98962202f, 0.98938557f, + 0.98914648f, 0.98890474f, 0.98866035f, 0.98841331f, 0.98816363f, + 0.98791130f, 0.98765632f, 0.98739871f, 0.98713845f, 0.98687554f, + 0.98660999f, 0.98634181f, 0.98607098f, 0.98579751f, 0.98552140f, + 0.98524265f, 0.98496127f, 0.98467725f, 0.98439059f, 0.98410130f, + 0.98380937f, 0.98351481f, 0.98321761f, 0.98291779f, 0.98261533f, + 0.98231024f, 0.98200252f, 0.98169217f, 0.98137919f, 0.98106359f, + 0.98074536f, 0.98042450f, 0.98010102f, 0.97977491f, 0.97944619f, + 0.97911483f, 0.97878086f, 0.97844427f, 0.97810506f, 0.97776322f, + 0.97741878f, 0.97707171f, 0.97672203f, 0.97636973f, 0.97601482f, + 0.97565730f, 0.97529716f, 0.97493441f, 0.97456906f, 0.97420109f, + 0.97383051f, 0.97345733f, 0.97308154f, 0.97270315f, 0.97232215f, + 0.97193855f, 0.97155235f, 0.97116355f, 0.97077214f, 0.97037814f, + 0.96998154f, 0.96958234f, 0.96918054f, 0.96877615f, 0.96836917f, + 0.96795960f, 0.96754743f, 0.96713267f, 0.96671533f, 0.96629539f, + 0.96587287f, 0.96544776f, 0.96502007f, 0.96458979f, 0.96415693f, + 0.96372149f, 0.96328347f, 0.96284288f, 0.96239970f, 0.96195394f, + 0.96150562f, 0.96105471f, 0.96060124f, 0.96014519f, 0.95968657f, + 0.95922538f, 0.95876162f, 0.95829530f, 0.95782641f, 0.95735496f, + 0.95688094f, 0.95640437f, 0.95592523f, 0.95544353f, 0.95495927f, + 0.95447246f, 0.95398309f, 0.95349117f, 0.95299669f, 0.95249967f, + 0.95200009f, 0.95149797f, 0.95099329f, 0.95048607f, 0.94997631f, + 0.94946400f, 0.94894915f, 0.94843176f, 0.94791184f, 0.94738937f, + 0.94686437f, 0.94633683f, 0.94580676f, 0.94527415f, 0.94473902f, + 0.94420135f, 0.94366116f, 0.94311844f, 0.94257320f, 0.94202543f, + 0.94147514f, 0.94092233f, 0.94036700f, 0.93980916f, 0.93924879f, + 0.93868592f, 0.93812052f, 0.93755262f, 0.93698221f, 0.93640929f, + 0.93583386f, 0.93525593f, 0.93467549f, 0.93409255f, 0.93350711f, + 0.93291917f, 0.93232873f, 0.93173580f, 0.93114037f, 0.93054245f, + 0.92994204f, 0.92933913f, 0.92873374f, 0.92812587f, 0.92751550f, + 0.92690266f, 0.92628733f, 0.92566953f, 0.92504924f, 0.92442648f, + 0.92380124f, 0.92317353f, 0.92254335f, 0.92191070f, 0.92127558f, + 0.92063799f, 0.91999794f, 0.91935543f, 0.91871045f, 0.91806302f, + 0.91741313f, 0.91676078f, 0.91610597f, 0.91544872f, 0.91478901f, + 0.91412685f, 0.91346225f, 0.91279520f, 0.91212571f, 0.91145377f, + 0.91077939f, 0.91010258f, 0.90942333f, 0.90874164f, 0.90805753f, + 0.90737098f, 0.90668200f, 0.90599059f, 0.90529676f, 0.90460050f, + 0.90390183f, 0.90320073f, 0.90249721f, 0.90179128f, 0.90108293f, + 0.90037218f, 0.89965901f, 0.89894343f, 0.89822544f, 0.89750505f, + 0.89678226f, 0.89605707f, 0.89532948f, 0.89459949f, 0.89386710f, + 0.89313232f, 0.89239515f, 0.89165560f, 0.89091365f, 0.89016932f, + 0.88942261f, 0.88867351f, 0.88792204f, 0.88716818f, 0.88641196f, + 0.88565336f, 0.88489239f, 0.88412905f, 0.88336334f, 0.88259527f, + 0.88182483f, 0.88105203f, 0.88027688f, 0.87949937f, 0.87871950f, + 0.87793728f, 0.87715271f, 0.87636579f, 0.87557653f, 0.87478492f, + 0.87399097f, 0.87319468f, 0.87239605f, 0.87159509f, 0.87079179f, + 0.86998616f, 0.86917820f, 0.86836792f, 0.86755531f, 0.86674037f, + 0.86592312f, 0.86510355f, 0.86428166f, 0.86345746f, 0.86263095f, + 0.86180212f, 0.86097099f, 0.86013756f, 0.85930182f, 0.85846378f, + 0.85762344f, 0.85678081f, 0.85593588f, 0.85508866f, 0.85423915f, + 0.85338736f, 0.85253328f, 0.85167692f, 0.85081827f, 0.84995735f, + 0.84909416f, 0.84822869f, 0.84736095f, 0.84649094f, 0.84561866f, + 0.84474412f, 0.84386732f, 0.84298826f, 0.84210695f, 0.84122337f, + 0.84033755f, 0.83944948f, 0.83855915f, 0.83766659f, 0.83677178f, + 0.83587473f, 0.83497544f, 0.83407392f, 0.83317016f, 0.83226418f, + 0.83135596f, 0.83044552f, 0.82953286f, 0.82861797f, 0.82770087f, + 0.82678155f, 0.82586002f, 0.82493628f, 0.82401032f, 0.82308217f, + 0.82215180f, 0.82121924f, 0.82028448f, 0.81934752f, 0.81840837f, + 0.81746703f, 0.81652349f, 0.81557778f, 0.81462988f, 0.81367979f, + 0.81272753f, 0.81177310f, 0.81081649f, 0.80985771f, 0.80889676f, + 0.80793364f, 0.80696837f, 0.80600093f, 0.80503133f, 0.80405958f, + 0.80308568f, 0.80210962f, 0.80113142f, 0.80015107f, 0.79916858f, + 0.79818396f, 0.79719719f, 0.79620829f, 0.79521726f, 0.79422410f, + 0.79322881f, 0.79223140f, 0.79123187f, 0.79023022f, 0.78922646f, + 0.78822058f, 0.78721259f, 0.78620249f, 0.78519029f, 0.78417599f, + 0.78315958f, 0.78214108f, 0.78112049f, 0.78009781f, 0.77907303f, + 0.77804617f, 0.77701723f, 0.77598621f, 0.77495311f, 0.77391793f, + 0.77288068f, 0.77184137f, 0.77079998f, 0.76975654f, 0.76871103f, + 0.76766347f, 0.76661384f, 0.76556217f, 0.76450845f, 0.76345268f, + 0.76239487f, 0.76133501f, 0.76027312f, 0.75920919f, 0.75814323f, + 0.75707524f, 0.75600522f, 0.75493318f, 0.75385911f, 0.75278303f, + 0.75170494f, 0.75062483f, 0.74954271f, 0.74845858f, 0.74737245f, + 0.74628432f, 0.74519419f, 0.74410207f, 0.74300795f, 0.74191185f, + 0.74081376f, 0.73971368f, 0.73861163f, 0.73750759f, 0.73640158f, + 0.73529361f, 0.73418366f, 0.73307175f, 0.73195787f, 0.73084203f, + 0.72972424f, 0.72860450f, 0.72748280f, 0.72635916f, 0.72523357f, + 0.72410604f, 0.72297657f, 0.72184516f, 0.72071182f, 0.71957656f, + 0.71843936f, 0.71730025f, 0.71615921f, 0.71501625f, 0.71387138f, + 0.71272460f, 0.71157592f, 0.71042532f, 0.70927283f, 0.70811843f, + 0.70696214f, 0.70580396f, 0.70464389f, 0.70348193f, 0.70231808f, + 0.70115236f, 0.69998476f, 0.69881528f, 0.69764394f, 0.69647073f, + 0.69529565f, 0.69411871f, 0.69293991f, 0.69175926f, 0.69057675f, + 0.68939240f, 0.68820620f, 0.68701816f, 0.68582828f, 0.68463656f, + 0.68344301f, 0.68224763f, 0.68105042f, 0.67985139f, 0.67865054f, + 0.67744787f, 0.67624339f, 0.67503710f, 0.67382900f, 0.67261910f, + 0.67140739f, 0.67019389f, 0.66897860f, 0.66776151f, 0.66654264f, + 0.66532198f, 0.66409954f, 0.66287532f, 0.66164932f, 0.66042156f, + 0.65919203f, 0.65796073f, 0.65672767f, 0.65549285f, 0.65425628f, + 0.65301796f, 0.65177788f, 0.65053607f, 0.64929251f, 0.64804721f, + 0.64680018f, 0.64555141f, 0.64430092f, 0.64304871f, 0.64179477f, + 0.64053911f, 0.63928174f, 0.63802265f, 0.63676186f, 0.63549936f, + 0.63423517f, 0.63296927f, 0.63170168f, 0.63043240f, 0.62916143f, + 0.62788877f, 0.62661444f, 0.62533842f, 0.62406074f, 0.62278138f, + 0.62150035f, 0.62021766f, 0.61893331f, 0.61764731f, 0.61635965f, + 0.61507034f, 0.61377938f, 0.61248678f, 0.61119254f, 0.60989666f, + 0.60859915f, 0.60730001f, 0.60599925f, 0.60469686f, 0.60339285f, + 0.60208723f, 0.60078000f, 0.59947115f, 0.59816071f, 0.59684866f, + 0.59553501f, 0.59421977f, 0.59290294f, 0.59158452f, 0.59026452f, + 0.58894293f, 0.58761977f, 0.58629504f, 0.58496873f, 0.58364086f, + 0.58231143f, 0.58098044f, 0.57964789f, 0.57831380f, 0.57697815f, + 0.57564096f, 0.57430223f, 0.57296196f, 0.57162015f, 0.57027682f, + 0.56893195f, 0.56758557f, 0.56623767f, 0.56488825f, 0.56353731f, + 0.56218487f, 0.56083093f, 0.55947548f, 0.55811853f, 0.55676009f, + 0.55540016f, 0.55403874f, 0.55267584f, 0.55131146f, 0.54994560f, + 0.54857827f, 0.54720948f, 0.54583921f, 0.54446749f, 0.54309431f, + 0.54171967f, 0.54034359f, 0.53896605f, 0.53758708f, 0.53620666f, + 0.53482481f, 0.53344153f, 0.53205682f, 0.53067068f, 0.52928312f, + 0.52789415f, 0.52650377f, 0.52511197f, 0.52371877f, 0.52232416f, + 0.52092816f, 0.51953076f, 0.51813197f, 0.51673180f, 0.51533024f, + 0.51392730f, 0.51252299f, 0.51111730f, 0.50971025f, 0.50830183f, + 0.50689204f, 0.50548091f, 0.50406842f, 0.50265458f, 0.50123939f, + 0.49982286f, 0.49840499f, 0.49698579f, 0.49556526f, 0.49414340f, + 0.49272022f, 0.49129572f, 0.48986991f, 0.48844278f, 0.48701434f, + 0.48558461f, 0.48415357f, 0.48272123f, 0.48128760f, 0.47985269f, + 0.47841649f, 0.47697901f, 0.47554025f, 0.47410021f, 0.47265891f, + 0.47121635f, 0.46977252f, 0.46832743f, 0.46688109f, 0.46543350f, + 0.46398467f, 0.46253459f, 0.46108327f, 0.45963072f, 0.45817694f, + 0.45672193f, 0.45526570f, 0.45380825f, 0.45234959f, 0.45088971f, + 0.44942863f, 0.44796634f, 0.44650286f, 0.44503818f, 0.44357230f, + 0.44210524f, 0.44063700f, 0.43916758f, 0.43769698f, 0.43622521f, + 0.43475227f, 0.43327816f, 0.43180290f, 0.43032648f, 0.42884891f, + 0.42737019f, 0.42589033f, 0.42440932f, 0.42292718f, 0.42144391f, + 0.41995951f, 0.41847399f, 0.41698734f, 0.41549958f, 0.41401070f, + 0.41252072f, 0.41102963f, 0.40953745f, 0.40804416f, 0.40654979f, + 0.40505432f, 0.40355777f, 0.40206014f, 0.40056144f, 0.39906166f, + 0.39756081f, 0.39605890f, 0.39455593f, 0.39305190f, 0.39154682f, + 0.39004069f, 0.38853352f, 0.38702530f, 0.38551605f, 0.38400577f, + 0.38249446f, 0.38098213f, 0.37946878f, 0.37795441f, 0.37643902f, + 0.37492263f, 0.37340524f, 0.37188685f, 0.37036746f, 0.36884708f, + 0.36732571f, 0.36580336f, 0.36428003f, 0.36275572f, 0.36123045f, + 0.35970420f, 0.35817700f, 0.35664883f, 0.35511971f, 0.35358964f, + 0.35205862f, 0.35052666f, 0.34899376f, 0.34745992f, 0.34592516f, + 0.34438947f, 0.34285286f, 0.34131533f, 0.33977688f, 0.33823753f, + 0.33669727f, 0.33515611f, 0.33361405f, 0.33207110f, 0.33052726f, + 0.32898254f, 0.32743693f, 0.32589045f, 0.32434309f, 0.32279487f, + 0.32124578f, 0.31969583f, 0.31814503f, 0.31659338f, 0.31504087f, + 0.31348753f, 0.31193334f, 0.31037832f, 0.30882247f, 0.30726579f, + 0.30570829f, 0.30414997f, 0.30259083f, 0.30103089f, 0.29947014f, + 0.29790859f, 0.29634624f, 0.29478309f, 0.29321916f, 0.29165445f, + 0.29008895f, 0.28852267f, 0.28695563f, 0.28538781f, 0.28381923f, + 0.28224989f, 0.28067980f, 0.27910895f, 0.27753736f, 0.27596502f, + 0.27439194f, 0.27281813f, 0.27124359f, 0.26966833f, 0.26809234f, + 0.26651563f, 0.26493821f, 0.26336008f, 0.26178125f, 0.26020171f, + 0.25862148f, 0.25704055f, 0.25545894f, 0.25387664f, 0.25229367f, + 0.25071002f, 0.24912569f, 0.24754070f, 0.24595505f, 0.24436874f, + 0.24278177f, 0.24119416f, 0.23960590f, 0.23801699f, 0.23642745f, + 0.23483728f, 0.23324648f, 0.23165505f, 0.23006301f, 0.22847034f, + 0.22687707f, 0.22528319f, 0.22368870f, 0.22209362f, 0.22049794f, + 0.21890167f, 0.21730482f, 0.21570738f, 0.21410937f, 0.21251078f, + 0.21091163f, 0.20931191f, 0.20771163f, 0.20611079f, 0.20450940f, + 0.20290746f, 0.20130498f, 0.19970196f, 0.19809841f, 0.19649433f, + 0.19488972f, 0.19328459f, 0.19167894f, 0.19007277f, 0.18846610f, + 0.18685893f, 0.18525125f, 0.18364308f, 0.18203442f, 0.18042526f, + 0.17881563f, 0.17720552f, 0.17559493f, 0.17398387f, 0.17237235f, + 0.17076037f, 0.16914792f, 0.16753503f, 0.16592169f, 0.16430790f, + 0.16269367f, 0.16107901f, 0.15946391f, 0.15784839f, 0.15623245f, + 0.15461609f, 0.15299931f, 0.15138213f, 0.14976453f, 0.14814654f, + 0.14652815f, 0.14490937f, 0.14329020f, 0.14167065f, 0.14005072f, + 0.13843041f, 0.13680974f, 0.13518869f, 0.13356729f, 0.13194552f, + 0.13032341f, 0.12870094f, 0.12707813f, 0.12545498f, 0.12383150f, + 0.12220768f, 0.12058354f, 0.11895907f, 0.11733428f, 0.11570918f, + 0.11408377f, 0.11245806f, 0.11083204f, 0.10920573f, 0.10757912f, + 0.10595223f, 0.10432505f, 0.10269759f, 0.10106986f, 0.099441861f, + 0.097813592f, 0.096185062f, 0.094556275f, 0.092927234f, 0.091297944f, + 0.089668410f, 0.088038636f, 0.086408626f, 0.084778385f, 0.083147917f, + 0.081517226f, 0.079886317f, 0.078255194f, 0.076623861f, 0.074992324f, + 0.073360585f, 0.071728651f, 0.070096524f, 0.068464209f, 0.066831712f, + 0.065199035f, 0.063566184f, 0.061933162f, 0.060299975f, 0.058666626f, + 0.057033121f, 0.055399462f, 0.053765655f, 0.052131705f, 0.050497614f, + 0.048863389f, 0.047229033f, 0.045594550f, 0.043959945f, 0.042325222f, + 0.040690387f, 0.039055442f, 0.037420393f, 0.035785243f, 0.034149998f, + 0.032514661f, 0.030879237f, 0.029243731f, 0.027608146f, 0.025972487f, + 0.024336759f, 0.022700965f, 0.021065111f, 0.019429201f, 0.017793238f, + 0.016157228f, 0.014521174f, 0.012885082f, 0.011248955f, 0.0096127982f, + 0.0079766155f, 0.0063404114f, 0.0047041904f, 0.0030679568f, 0.0014317149f, + -0.00020453077f, -0.0018407759f, -0.0034770161f, -0.0051132470f, -0.0067494642f, + -0.0083856634f, -0.010021840f, -0.011657990f, -0.013294109f, -0.014930192f, + -0.016566235f, -0.018202233f, -0.019838183f, -0.021474080f, -0.023109920f, + -0.024745697f, -0.026381408f, -0.028017049f, -0.029652615f, -0.031288101f, + -0.032923503f, -0.034558818f, -0.036194040f, -0.037829164f, -0.039464188f, + -0.041099106f, -0.042733914f, -0.044368607f, -0.046003182f, -0.047637634f, + -0.049271958f, -0.050906150f, -0.052540206f, -0.054174121f, -0.055807891f, + -0.057441512f, -0.059074978f, -0.060708287f, -0.062341433f, -0.063974413f, + -0.065607221f, -0.067239853f, -0.068872305f, -0.070504573f, -0.072136653f, + -0.073768539f, -0.075400227f, -0.077031714f, -0.078662994f, -0.080294064f, + -0.081924919f, -0.083555555f, -0.085185966f, -0.086816150f, -0.088446102f, + -0.090075816f, -0.091705289f, -0.093334517f, -0.094963495f, -0.096592219f, + -0.098220684f, -0.099848886f, -0.10147682f, -0.10310448f, -0.10473187f, + -0.10635898f, -0.10798580f, -0.10961233f, -0.11123857f, -0.11286451f, + -0.11449015f, -0.11611549f, -0.11774051f, -0.11936521f, -0.12098960f, + -0.12261367f, -0.12423740f, -0.12586080f, -0.12748387f, -0.12910659f, + -0.13072897f, -0.13235100f, -0.13397267f, -0.13559399f, -0.13721494f, + -0.13883553f, -0.14045574f, -0.14207558f, -0.14369503f, -0.14531411f, + -0.14693279f, -0.14855108f, -0.15016897f, -0.15178646f, -0.15340354f, + -0.15502022f, -0.15663647f, -0.15825231f, -0.15986773f, -0.16148271f, + -0.16309727f, -0.16471139f, -0.16632506f, -0.16793829f, -0.16955108f, + -0.17116340f, -0.17277527f, -0.17438668f, -0.17599762f, -0.17760809f, + -0.17921808f, -0.18082760f, -0.18243663f, -0.18404517f, -0.18565322f, + -0.18726077f, -0.18886782f, -0.19047436f, -0.19208040f, -0.19368592f, + -0.19529092f, -0.19689540f, -0.19849935f, -0.20010277f, -0.20170565f, + -0.20330800f, -0.20490980f, -0.20651105f, -0.20811175f, -0.20971189f, + -0.21131147f, -0.21291048f, -0.21450893f, -0.21610680f, -0.21770409f, + -0.21930080f, -0.22089692f, -0.22249245f, -0.22408738f, -0.22568172f, + -0.22727545f, -0.22886857f, -0.23046108f, -0.23205297f, -0.23364424f, + -0.23523488f, -0.23682490f, -0.23841428f, -0.24000302f, -0.24159112f, + -0.24317858f, -0.24476538f, -0.24635153f, -0.24793701f, -0.24952184f, + -0.25110599f, -0.25268948f, -0.25427228f, -0.25585441f, -0.25743585f, + -0.25901660f, -0.26059666f, -0.26217602f, -0.26375468f, -0.26533263f, + -0.26690987f, -0.26848640f, -0.27006221f, -0.27163730f, -0.27321165f, + -0.27478528f, -0.27635817f, -0.27793032f, -0.27950173f, -0.28107239f, + -0.28264230f, -0.28421145f, -0.28577984f, -0.28734746f, -0.28891431f, + -0.29048039f, -0.29204570f, -0.29361022f, -0.29517395f, -0.29673690f, + -0.29829905f, -0.29986040f, -0.30142095f, -0.30298069f, -0.30453962f, + -0.30609774f, -0.30765504f, -0.30921151f, -0.31076715f, -0.31232197f, + -0.31387594f, -0.31542908f, -0.31698137f, -0.31853281f, -0.32008340f, + -0.32163313f, -0.32318201f, -0.32473001f, -0.32627715f, -0.32782341f, + -0.32936880f, -0.33091330f, -0.33245692f, -0.33399965f, -0.33554149f, + -0.33708242f, -0.33862245f, -0.34016158f, -0.34169980f, -0.34323710f, + -0.34477348f, -0.34630894f, -0.34784347f, -0.34937707f, -0.35090974f, + -0.35244146f, -0.35397224f, -0.35550208f, -0.35703096f, -0.35855889f, + -0.36008585f, -0.36161186f, -0.36313689f, -0.36466095f, -0.36618404f, + -0.36770615f, -0.36922727f, -0.37074740f, -0.37226654f, -0.37378468f, + -0.37530183f, -0.37681796f, -0.37833309f, -0.37984721f, -0.38136031f, + -0.38287239f, -0.38438344f, -0.38589346f, -0.38740245f, -0.38891041f, + -0.39041732f, -0.39192319f, -0.39342800f, -0.39493177f, -0.39643448f, + -0.39793612f, -0.39943670f, -0.40093621f, -0.40243465f, -0.40393201f, + -0.40542829f, -0.40692348f, -0.40841759f, -0.40991060f, -0.41140251f, + -0.41289332f, -0.41438303f, -0.41587162f, -0.41735911f, -0.41884547f, + -0.42033072f, -0.42181484f, -0.42329782f, -0.42477968f, -0.42626040f, + -0.42773998f, -0.42921841f, -0.43069569f, -0.43217182f, -0.43364680f, + -0.43512061f, -0.43659326f, -0.43806474f, -0.43953504f, -0.44100417f, + -0.44247212f, -0.44393888f, -0.44540446f, -0.44686884f, -0.44833203f, + -0.44979401f, -0.45125479f, -0.45271437f, -0.45417273f, -0.45562987f, + -0.45708580f, -0.45854050f, -0.45999398f, -0.46144622f, -0.46289723f, + -0.46434699f, -0.46579552f, -0.46724280f, -0.46868882f, -0.47013359f, + -0.47157711f, -0.47301936f, -0.47446034f, -0.47590006f, -0.47733850f, + -0.47877566f, -0.48021154f, -0.48164613f, -0.48307944f, -0.48451145f, + -0.48594216f, -0.48737158f, -0.48879968f, -0.49022648f, -0.49165197f, + -0.49307614f, -0.49449899f, -0.49592052f, -0.49734072f, -0.49875959f, + -0.50017712f, -0.50159331f, -0.50300816f, -0.50442167f, -0.50583382f, + -0.50724462f, -0.50865406f, -0.51006214f, -0.51146885f, -0.51287419f, + -0.51427817f, -0.51568076f, -0.51708197f, -0.51848180f, -0.51988024f, + -0.52127729f, -0.52267294f, -0.52406720f, -0.52546005f, -0.52685149f, + -0.52824153f, -0.52963015f, -0.53101735f, -0.53240313f, -0.53378748f, + -0.53517041f, -0.53655190f, -0.53793196f, -0.53931057f, -0.54068774f, + -0.54206347f, -0.54343774f, -0.54481056f, -0.54618192f, -0.54755181f, + -0.54892024f, -0.55028721f, -0.55165269f, -0.55301671f, -0.55437924f, + -0.55574028f, -0.55709984f, -0.55845791f, -0.55981448f, -0.56116955f, + -0.56252312f, -0.56387519f, -0.56522574f, -0.56657478f, -0.56792231f, + -0.56926831f, -0.57061279f, -0.57195575f, -0.57329717f, -0.57463705f, + -0.57597540f, -0.57731221f, -0.57864747f, -0.57998118f, -0.58131334f, + -0.58264394f, -0.58397298f, -0.58530046f, -0.58662637f, -0.58795071f, + -0.58927348f, -0.59059466f, -0.59191427f, -0.59323230f, -0.59454873f, + -0.59586357f, -0.59717682f, -0.59848847f, -0.59979852f, -0.60110696f, + -0.60241379f, -0.60371901f, -0.60502261f, -0.60632459f, -0.60762495f, + -0.60892368f, -0.61022078f, -0.61151625f, -0.61281008f, -0.61410227f, + -0.61539282f, -0.61668172f, -0.61796896f, -0.61925456f, -0.62053849f, + -0.62182077f, -0.62310138f, -0.62438032f, -0.62565759f, -0.62693318f, + -0.62820709f, -0.62947933f, -0.63074988f, -0.63201874f, -0.63328590f, + -0.63455138f, -0.63581515f, -0.63707722f, -0.63833758f, -0.63959624f, + -0.64085318f, -0.64210841f, -0.64336192f, -0.64461371f, -0.64586377f, + -0.64711210f, -0.64835870f, -0.64960356f, -0.65084668f, -0.65208807f, + -0.65332770f, -0.65456559f, -0.65580172f, -0.65703610f, -0.65826872f, + -0.65949958f, -0.66072867f, -0.66195599f, -0.66318154f, -0.66440531f, + -0.66562731f, -0.66684752f, -0.66806595f, -0.66928259f, -0.67049744f, + -0.67171049f, -0.67292174f, -0.67413119f, -0.67533884f, -0.67654468f, + -0.67774871f, -0.67895092f, -0.68015132f, -0.68134989f, -0.68254664f, + -0.68374157f, -0.68493466f, -0.68612592f, -0.68731534f, -0.68850292f, + -0.68968866f, -0.69087255f, -0.69205460f, -0.69323478f, -0.69441312f, + -0.69558959f, -0.69676420f, -0.69793695f, -0.69910783f, -0.70027684f, + -0.70144397f, -0.70260922f, -0.70377259f, -0.70493408f, -0.70609368f, + -0.70725139f, -0.70840721f, -0.70956113f, -0.71071315f, -0.71186327f, + -0.71301148f, -0.71415778f, -0.71530217f, -0.71644465f, -0.71758521f, + -0.71872384f, -0.71986055f, -0.72099534f, -0.72212819f, -0.72325912f, + -0.72438810f, -0.72551515f, -0.72664025f, -0.72776341f, -0.72888462f, + -0.73000387f, -0.73112118f, -0.73223652f, -0.73334991f, -0.73446133f, + -0.73557079f, -0.73667827f, -0.73778379f, -0.73888732f, -0.73998888f, + -0.74108846f, -0.74218606f, -0.74328167f, -0.74437529f, -0.74546691f, + -0.74655654f, -0.74764417f, -0.74872980f, -0.74981342f, -0.75089504f, + -0.75197465f, -0.75305224f, -0.75412782f, -0.75520138f, -0.75627291f, + -0.75734242f, -0.75840991f, -0.75947536f, -0.76053878f, -0.76160017f, + -0.76265951f, -0.76371681f, -0.76477207f, -0.76582528f, -0.76687644f, + -0.76792555f, -0.76897260f, -0.77001759f, -0.77106052f, -0.77210139f, + -0.77314019f, -0.77417692f, -0.77521158f, -0.77624416f, -0.77727466f, + -0.77830308f, -0.77932942f, -0.78035367f, -0.78137584f, -0.78239591f, + -0.78341388f, -0.78442976f, -0.78544354f, -0.78645521f, -0.78746478f, + -0.78847224f, -0.78947760f, -0.79048083f, -0.79148195f, -0.79248095f, + -0.79347783f, -0.79447259f, -0.79546522f, -0.79645572f, -0.79744408f, + -0.79843031f, -0.79941441f, -0.80039636f, -0.80137617f, -0.80235384f, + -0.80332935f, -0.80430272f, -0.80527393f, -0.80624299f, -0.80720989f, + -0.80817462f, -0.80913720f, -0.81009760f, -0.81105584f, -0.81201191f, + -0.81296580f, -0.81391752f, -0.81486706f, -0.81581441f, -0.81675958f, + -0.81770257f, -0.81864336f, -0.81958197f, -0.82051837f, -0.82145259f, + -0.82238460f, -0.82331441f, -0.82424202f, -0.82516742f, -0.82609061f, + -0.82701159f, -0.82793036f, -0.82884690f, -0.82976123f, -0.83067334f, + -0.83158323f, -0.83249088f, -0.83339631f, -0.83429951f, -0.83520047f, + -0.83609920f, -0.83699569f, -0.83788994f, -0.83878195f, -0.83967171f, + -0.84055922f, -0.84144448f, -0.84232749f, -0.84320824f, -0.84408674f, + -0.84496297f, -0.84583694f, -0.84670865f, -0.84757810f, -0.84844527f, + -0.84931017f, -0.85017280f, -0.85103315f, -0.85189122f, -0.85274701f, + -0.85360052f, -0.85445175f, -0.85530068f, -0.85614733f, -0.85699168f, + -0.85783374f, -0.85867350f, -0.85951097f, -0.86034613f, -0.86117899f, + -0.86200954f, -0.86283779f, -0.86366373f, -0.86448735f, -0.86530866f, + -0.86612765f, -0.86694432f, -0.86775868f, -0.86857071f, -0.86938041f, + -0.87018779f, -0.87099283f, -0.87179555f, -0.87259593f, -0.87339397f, + -0.87418968f, -0.87498304f, -0.87577407f, -0.87656274f, -0.87734907f, + -0.87813306f, -0.87891469f, -0.87969397f, -0.88047089f, -0.88124545f, + -0.88201766f, -0.88278751f, -0.88355499f, -0.88432010f, -0.88508285f, + -0.88584323f, -0.88660124f, -0.88735687f, -0.88811013f, -0.88886101f, + -0.88960951f, -0.89035563f, -0.89109936f, -0.89184071f, -0.89257967f, + -0.89331624f, -0.89405042f, -0.89478221f, -0.89551160f, -0.89623859f, + -0.89696318f, -0.89768538f, -0.89840516f, -0.89912255f, -0.89983752f, + -0.90055009f, -0.90126025f, -0.90196799f, -0.90267332f, -0.90337623f, + -0.90407672f, -0.90477479f, -0.90547044f, -0.90616367f, -0.90685447f, + -0.90754284f, -0.90822878f, -0.90891229f, -0.90959337f, -0.91027201f, + -0.91094822f, -0.91162198f, -0.91229331f, -0.91296219f, -0.91362863f, + -0.91429262f, -0.91495417f, -0.91561326f, -0.91626990f, -0.91692409f, + -0.91757583f, -0.91822511f, -0.91887193f, -0.91951629f, -0.92015819f, + -0.92079762f, -0.92143459f, -0.92206909f, -0.92270113f, -0.92333069f, + -0.92395778f, -0.92458240f, -0.92520454f, -0.92582421f, -0.92644140f, + -0.92705610f, -0.92766833f, -0.92827807f, -0.92888532f, -0.92949009f, + -0.93009237f, -0.93069216f, -0.93128946f, -0.93188427f, -0.93247658f, + -0.93306639f, -0.93365370f, -0.93423852f, -0.93482083f, -0.93540065f, + -0.93597795f, -0.93655275f, -0.93712505f, -0.93769483f, -0.93826211f, + -0.93882687f, -0.93938912f, -0.93994885f, -0.94050607f, -0.94106077f, + -0.94161295f, -0.94216261f, -0.94270975f, -0.94325436f, -0.94379644f, + -0.94433601f, -0.94487304f, -0.94540754f, -0.94593951f, -0.94646895f, + -0.94699585f, -0.94752022f, -0.94804206f, -0.94856135f, -0.94907810f, + -0.94959232f, -0.95010399f, -0.95061312f, -0.95111970f, -0.95162374f, + -0.95212522f, -0.95262416f, -0.95312055f, -0.95361439f, -0.95410567f, + -0.95459440f, -0.95508058f, -0.95556419f, -0.95604525f, -0.95652375f, + -0.95699969f, -0.95747306f, -0.95794388f, -0.95841212f, -0.95887780f, + -0.95934092f, -0.95980146f, -0.96025944f, -0.96071485f, -0.96116768f, + -0.96161794f, -0.96206562f, -0.96251073f, -0.96295327f, -0.96339322f, + -0.96383060f, -0.96426539f, -0.96469760f, -0.96512723f, -0.96555428f, + -0.96597874f, -0.96640062f, -0.96681991f, -0.96723660f, -0.96765071f, + -0.96806223f, -0.96847116f, -0.96887749f, -0.96928124f, -0.96968238f, + -0.97008093f, -0.97047688f, -0.97087024f, -0.97126099f, -0.97164914f, + -0.97203470f, -0.97241765f, -0.97279799f, -0.97317574f, -0.97355087f, + -0.97392340f, -0.97429333f, -0.97466064f, -0.97502535f, -0.97538744f, + -0.97574692f, -0.97610379f, -0.97645805f, -0.97680969f, -0.97715872f, + -0.97750513f, -0.97784893f, -0.97819010f, -0.97852866f, -0.97886460f, + -0.97919792f, -0.97952861f, -0.97985669f, -0.98018214f, -0.98050496f, + -0.98082516f, -0.98114274f, -0.98145768f, -0.98177000f, -0.98207970f, + -0.98238676f, -0.98269119f, -0.98299299f, -0.98329216f, -0.98358870f, + -0.98388260f, -0.98417387f, -0.98446250f, -0.98474850f, -0.98503186f, + -0.98531259f, -0.98559068f, -0.98586612f, -0.98613893f, -0.98640910f, + -0.98667663f, -0.98694151f, -0.98720376f, -0.98746336f, -0.98772032f, + -0.98797463f, -0.98822630f, -0.98847532f, -0.98872169f, -0.98896542f, + -0.98920650f, -0.98944493f, -0.98968071f, -0.98991385f, -0.99014433f, + -0.99037216f, -0.99059734f, -0.99081987f, -0.99103975f, -0.99125697f, + -0.99147154f, -0.99168345f, -0.99189271f, -0.99209931f, -0.99230326f, + -0.99250455f, -0.99270318f, -0.99289916f, -0.99309248f, -0.99328313f, + -0.99347113f, -0.99365647f, -0.99383915f, -0.99401917f, -0.99419653f, + -0.99437122f, -0.99454325f, -0.99471262f, -0.99487933f, -0.99504337f, + -0.99520475f, -0.99536347f, -0.99551952f, -0.99567290f, -0.99582362f, + -0.99597167f, -0.99611706f, -0.99625978f, -0.99639983f, -0.99653722f, + -0.99667193f, -0.99680398f, -0.99693336f, -0.99706007f, -0.99718411f, + -0.99730548f, -0.99742418f, -0.99754021f, -0.99765357f, -0.99776426f, + -0.99787228f, -0.99797763f, -0.99808030f, -0.99818030f, -0.99827763f, + -0.99837229f, -0.99846427f, -0.99855358f, -0.99864022f, -0.99872418f, + -0.99880547f, -0.99888409f, -0.99896003f, -0.99903329f, -0.99910389f, + -0.99917180f, -0.99923705f, -0.99929961f, -0.99935950f, -0.99941672f, + -0.99947126f, -0.99952312f, -0.99957231f, -0.99961882f, -0.99966266f, + -0.99970382f, -0.99974230f, -0.99977811f, -0.99981124f, -0.99984169f, + -0.99986946f, -0.99989456f, -0.99991698f, -0.99993673f, -0.99995380f, + -0.99996819f, -0.99997990f, -0.99998894f, -0.99999529f, -0.99999898f, + 0.99999992f, 0.99999322f, 0.99997582f, 0.99994771f, 0.99990889f, + 0.99985936f, 0.99979913f, 0.99972818f, 0.99964653f, 0.99955418f, + 0.99945112f, 0.99933736f, 0.99921289f, 0.99907773f, 0.99893186f, + 0.99877530f, 0.99860804f, 0.99843009f, 0.99824144f, 0.99804211f, + 0.99783209f, 0.99761138f, 0.99737998f, 0.99713791f, 0.99688516f, + 0.99662173f, 0.99634763f, 0.99606285f, 0.99576741f, 0.99546131f, + 0.99514455f, 0.99481713f, 0.99447905f, 0.99413033f, 0.99377096f, + 0.99340095f, 0.99302029f, 0.99262901f, 0.99222709f, 0.99181455f, + 0.99139139f, 0.99095760f, 0.99051321f, 0.99005821f, 0.98959261f, + 0.98911641f, 0.98862961f, 0.98813223f, 0.98762427f, 0.98710573f, + 0.98657662f, 0.98603694f, 0.98548670f, 0.98492591f, 0.98435457f, + 0.98377269f, 0.98318028f, 0.98257734f, 0.98196387f, 0.98133989f, + 0.98070539f, 0.98006040f, 0.97940491f, 0.97873893f, 0.97806247f, + 0.97737554f, 0.97667813f, 0.97597027f, 0.97525196f, 0.97452320f, + 0.97378401f, 0.97303439f, 0.97227435f, 0.97150389f, 0.97072303f, + 0.96993178f, 0.96913014f, 0.96831812f, 0.96749573f, 0.96666298f, + 0.96581987f, 0.96496643f, 0.96410265f, 0.96322854f, 0.96234412f, + 0.96144939f, 0.96054437f, 0.95962906f, 0.95870347f, 0.95776762f, + 0.95682151f, 0.95586515f, 0.95489856f, 0.95392174f, 0.95293471f, + 0.95193746f, 0.95093003f, 0.94991241f, 0.94888462f, 0.94784667f, + 0.94679856f, 0.94574032f, 0.94467195f, 0.94359346f, 0.94250486f, + 0.94140618f, 0.94029741f, 0.93917857f, 0.93804967f, 0.93691073f, + 0.93576176f, 0.93460276f, 0.93343375f, 0.93225475f, 0.93106577f, + 0.92986681f, 0.92865789f, 0.92743903f, 0.92621024f, 0.92497153f, + 0.92372291f, 0.92246440f, 0.92119602f, 0.91991776f, 0.91862966f, + 0.91733172f, 0.91602395f, 0.91470637f, 0.91337900f, 0.91204185f, + 0.91069493f, 0.90933825f, 0.90797184f, 0.90659570f, 0.90520986f, + 0.90381432f, 0.90240910f, 0.90099422f, 0.89956969f, 0.89813553f, + 0.89669174f, 0.89523836f, 0.89377538f, 0.89230284f, 0.89082074f, + 0.88932910f, 0.88782793f, 0.88631726f, 0.88479710f, 0.88326746f, + 0.88172836f, 0.88017982f, 0.87862185f, 0.87705448f, 0.87547771f, + 0.87389156f, 0.87229606f, 0.87069121f, 0.86907704f, 0.86745357f, + 0.86582080f, 0.86417876f, 0.86252747f, 0.86086694f, 0.85919719f, + 0.85751824f, 0.85583010f, 0.85413281f, 0.85242636f, 0.85071078f, + 0.84898610f, 0.84725232f, 0.84550947f, 0.84375756f, 0.84199662f, + 0.84022666f, 0.83844771f, 0.83665977f, 0.83486287f, 0.83305704f, + 0.83124228f, 0.82941862f, 0.82758608f, 0.82574467f, 0.82389442f, + 0.82203535f, 0.82016748f, 0.81829082f, 0.81640540f, 0.81451123f, + 0.81260835f, 0.81069676f, 0.80877649f, 0.80684755f, 0.80490998f, + 0.80296379f, 0.80100899f, 0.79904562f, 0.79707370f, 0.79509323f, + 0.79310425f, 0.79110678f, 0.78910084f, 0.78708644f, 0.78506362f, + 0.78303239f, 0.78099277f, 0.77894479f, 0.77688847f, 0.77482382f, + 0.77275088f, 0.77066967f, 0.76858020f, 0.76648250f, 0.76437659f, + 0.76226250f, 0.76014024f, 0.75800984f, 0.75587132f, 0.75372471f, + 0.75157003f, 0.74940730f, 0.74723654f, 0.74505779f, 0.74287105f, + 0.74067635f, 0.73847373f, 0.73626320f, 0.73404478f, 0.73181850f, + 0.72958438f, 0.72734245f, 0.72509273f, 0.72283525f, 0.72057002f, + 0.71829708f, 0.71601644f, 0.71372814f, 0.71143220f, 0.70912863f, + 0.70681747f, 0.70449874f, 0.70217247f, 0.69983868f, 0.69749739f, + 0.69514863f, 0.69279243f, 0.69042881f, 0.68805780f, 0.68567941f, + 0.68329369f, 0.68090064f, 0.67850031f, 0.67609270f, 0.67367786f, + 0.67125580f, 0.66882656f, 0.66639015f, 0.66394661f, 0.66149595f, + 0.65903821f, 0.65657341f, 0.65410159f, 0.65162275f, 0.64913694f, + 0.64664418f, 0.64414449f, 0.64163790f, 0.63912444f, 0.63660414f, + 0.63407702f, 0.63154311f, 0.62900244f, 0.62645503f, 0.62390091f, + 0.62134011f, 0.61877265f, 0.61619857f, 0.61361789f, 0.61103064f, + 0.60843685f, 0.60583654f, 0.60322974f, 0.60061648f, 0.59799679f, + 0.59537069f, 0.59273822f, 0.59009940f, 0.58745427f, 0.58480284f, + 0.58214514f, 0.57948122f, 0.57681109f, 0.57413478f, 0.57145232f, + 0.56876374f, 0.56606907f, 0.56336834f, 0.56066158f, 0.55794881f, + 0.55523006f, 0.55250537f, 0.54977477f, 0.54703827f, 0.54429592f, + 0.54154774f, 0.53879376f, 0.53603401f, 0.53326852f, 0.53049731f, + 0.52772043f, 0.52493790f, 0.52214974f, 0.51935599f, 0.51655668f, + 0.51375184f, 0.51094149f, 0.50812568f, 0.50530442f, 0.50247775f, + 0.49964570f, 0.49680830f, 0.49396558f, 0.49111757f, 0.48826430f, + 0.48540580f, 0.48254210f, 0.47967323f, 0.47679923f, 0.47392012f, + 0.47103594f, 0.46814671f, 0.46525247f, 0.46235324f, 0.45944907f, + 0.45653997f, 0.45362599f, 0.45070714f, 0.44778347f, 0.44485501f, + 0.44192178f, 0.43898381f, 0.43604115f, 0.43309382f, 0.43014185f, + 0.42718527f, 0.42422412f, 0.42125842f, 0.41828822f, 0.41531353f, + 0.41233440f, 0.40935085f, 0.40636291f, 0.40337063f, 0.40037402f, + 0.39737313f, 0.39436798f, 0.39135861f, 0.38834505f, 0.38532733f, + 0.38230548f, 0.37927953f, 0.37624953f, 0.37321550f, 0.37017747f, + 0.36713547f, 0.36408955f, 0.36103972f, 0.35798603f, 0.35492850f, + 0.35186718f, 0.34880208f, 0.34573325f, 0.34266072f, 0.33958451f, + 0.33650468f, 0.33342123f, 0.33033422f, 0.32724367f, 0.32414961f, + 0.32105209f, 0.31795112f, 0.31484675f, 0.31173901f, 0.30862793f, + 0.30551354f, 0.30239588f, 0.29927499f, 0.29615089f, 0.29302362f, + 0.28989321f, 0.28675969f, 0.28362310f, 0.28048348f, 0.27734085f, + 0.27419526f, 0.27104672f, 0.26789529f, 0.26474098f, 0.26158384f, + 0.25842390f, 0.25526119f, 0.25209575f, 0.24892761f, 0.24575680f, + 0.24258336f, 0.23940732f, 0.23622872f, 0.23304759f, 0.22986396f, + 0.22667787f, 0.22348935f, 0.22029844f, 0.21710517f, 0.21390958f, + 0.21071169f, 0.20751155f, 0.20430919f, 0.20110463f, 0.19789793f, + 0.19468910f, 0.19147819f, 0.18826523f, 0.18505026f, 0.18183330f, + 0.17861439f, 0.17539357f, 0.17217088f, 0.16894634f, 0.16571999f, + 0.16249186f, 0.15926200f, 0.15603043f, 0.15279719f, 0.14956231f, + 0.14632583f, 0.14308778f, 0.13984820f, 0.13660713f, 0.13336459f, + 0.13012062f, 0.12687526f, 0.12362854f, 0.12038049f, 0.11713116f, + 0.11388057f, 0.11062877f, 0.10737578f, 0.10412163f, 0.10086638f, + 0.097610040f, 0.094352658f, 0.091094266f, 0.087834897f, 0.084574589f, + 0.081313374f, 0.078051289f, 0.074788367f, 0.071524645f, 0.068260157f, + 0.064994938f, 0.061729023f, 0.058462447f, 0.055195244f, 0.051927451f, + 0.048659101f, 0.045390231f, 0.042120874f, 0.038851066f, 0.035580842f, + 0.032310238f, 0.029039287f, 0.025768025f, 0.022496487f, 0.019224708f, + 0.015952723f, 0.012680568f, 0.0094082767f, 0.0061358846f, 0.0028634269f, + -0.00040906153f, -0.0036815456f, -0.0069539902f, -0.010226360f, -0.013498621f, + -0.016770737f, -0.020042673f, -0.023314395f, -0.026585867f, -0.029857055f, + -0.033127923f, -0.036398436f, -0.039668559f, -0.042938257f, -0.046207495f, + -0.049476239f, -0.052744453f, -0.056012102f, -0.059279151f, -0.062545565f, + -0.065811309f, -0.069076349f, -0.072340649f, -0.075604174f, -0.078866890f, + -0.082128761f, -0.085389752f, -0.088649829f, -0.091908956f, -0.095167100f, + -0.098424224f, -0.10168029f, -0.10493528f, -0.10818913f, -0.11144183f, + -0.11469334f, -0.11794361f, -0.12119263f, -0.12444034f, -0.12768673f, + -0.13093174f, -0.13417536f, -0.13741753f, -0.14065824f, -0.14389744f, + -0.14713510f, -0.15037118f, -0.15360565f, -0.15683848f, -0.16006962f, + -0.16329906f, -0.16652674f, -0.16975264f, -0.17297673f, -0.17619896f, + -0.17941930f, -0.18263772f, -0.18585419f, -0.18906866f, -0.19228112f, + -0.19549151f, -0.19869981f, -0.20190598f, -0.20510998f, -0.20831180f, + -0.21151138f, -0.21470869f, -0.21790371f, -0.22109639f, -0.22428671f, + -0.22747462f, -0.23066010f, -0.23384310f, -0.23702361f, -0.24020157f, + -0.24337696f, -0.24654975f, -0.24971989f, -0.25288736f, -0.25605213f, + -0.25921415f, -0.26237339f, -0.26552983f, -0.26868342f, -0.27183413f, + -0.27498193f, -0.27812679f, -0.28126867f, -0.28440754f, -0.28754336f, + -0.29067610f, -0.29380573f, -0.29693221f, -0.30005551f, -0.30317560f, + -0.30629245f, -0.30940601f, -0.31251626f, -0.31562316f, -0.31872668f, + -0.32182679f, -0.32492345f, -0.32801664f, -0.33110631f, -0.33419243f, + -0.33727497f, -0.34035391f, -0.34342920f, -0.34650081f, -0.34956871f, + -0.35263286f, -0.35569324f, -0.35874981f, -0.36180254f, -0.36485139f, + -0.36789634f, -0.37093735f, -0.37397438f, -0.37700741f, -0.38003640f, + -0.38306132f, -0.38608214f, -0.38909883f, -0.39211135f, -0.39511967f, + -0.39812375f, -0.40112358f, -0.40411910f, -0.40711031f, -0.41009715f, + -0.41307959f, -0.41605762f, -0.41903119f, -0.42200027f, -0.42496483f, + -0.42792484f, -0.43088027f, -0.43383109f, -0.43677726f, -0.43971875f, + -0.44265553f, -0.44558757f, -0.44851484f, -0.45143731f, -0.45435494f, + -0.45726770f, -0.46017557f, -0.46307851f, -0.46597650f, -0.46886949f, + -0.47175746f, -0.47464038f, -0.47751821f, -0.48039093f, -0.48325851f, + -0.48612091f, -0.48897811f, -0.49183006f, -0.49467676f, -0.49751815f, + -0.50035422f, -0.50318492f, -0.50601024f, -0.50883014f, -0.51164459f, + -0.51445356f, -0.51725703f, -0.52005495f, -0.52284730f, -0.52563406f, + -0.52841518f, -0.53119065f, -0.53396043f, -0.53672449f, -0.53948280f, + -0.54223533f, -0.54498206f, -0.54772295f, -0.55045797f, -0.55318710f, + -0.55591031f, -0.55862756f, -0.56133883f, -0.56404409f, -0.56674331f, + -0.56943646f, -0.57212351f, -0.57480443f, -0.57747920f, -0.58014778f, + -0.58281015f, -0.58546628f, -0.58811614f, -0.59075970f, -0.59339694f, + -0.59602782f, -0.59865231f, -0.60127040f, -0.60388204f, -0.60648722f, + -0.60908591f, -0.61167807f, -0.61426368f, -0.61684271f, -0.61941514f, + -0.62198093f, -0.62454007f, -0.62709251f, -0.62963824f, -0.63217722f, + -0.63470944f, -0.63723486f, -0.63975345f, -0.64226519f, -0.64477006f, + -0.64726802f, -0.64975905f, -0.65224312f, -0.65472020f, -0.65719027f, + -0.65965331f, -0.66210928f, -0.66455816f, -0.66699992f, -0.66943454f, + -0.67186199f, -0.67428225f, -0.67669528f, -0.67910107f, -0.68149959f, + -0.68389080f, -0.68627470f, -0.68865124f, -0.69102041f, -0.69338218f, + -0.69573652f, -0.69808341f, -0.70042283f, -0.70275474f, -0.70507913f, + -0.70739597f, -0.70970524f, -0.71200690f, -0.71430093f, -0.71658732f, + -0.71886604f, -0.72113705f, -0.72340034f, -0.72565589f, -0.72790366f, + -0.73014364f, -0.73237580f, -0.73460012f, -0.73681657f, -0.73902513f, + -0.74122577f, -0.74341848f, -0.74560322f, -0.74777998f, -0.74994874f, + -0.75210946f, -0.75426212f, -0.75640671f, -0.75854320f, -0.76067157f, + -0.76279178f, -0.76490383f, -0.76700769f, -0.76910334f, -0.77119075f, + -0.77326989f, -0.77534076f, -0.77740333f, -0.77945757f, -0.78150346f, + -0.78354098f, -0.78557011f, -0.78759083f, -0.78960312f, -0.79160694f, + -0.79360229f, -0.79558915f, -0.79756748f, -0.79953727f, -0.80149850f, + -0.80345114f, -0.80539518f, -0.80733060f, -0.80925737f, -0.81117547f, + -0.81308489f, -0.81498559f, -0.81687757f, -0.81876081f, -0.82063527f, + -0.82250095f, -0.82435781f, -0.82620585f, -0.82804505f, -0.82987537f, + -0.83169681f, -0.83350933f, -0.83531294f, -0.83710760f, -0.83889329f, + -0.84067000f, -0.84243770f, -0.84419639f, -0.84594603f, -0.84768662f, + -0.84941812f, -0.85114053f, -0.85285383f, -0.85455799f, -0.85625300f, + -0.85793884f, -0.85961549f, -0.86128294f, -0.86294116f, -0.86459014f, + -0.86622986f, -0.86786031f, -0.86948146f, -0.87109330f, -0.87269581f, + -0.87428898f, -0.87587278f, -0.87744720f, -0.87901223f, -0.88056784f, + -0.88211402f, -0.88365076f, -0.88517803f, -0.88669582f, -0.88820412f, + -0.88970290f, -0.89119216f, -0.89267187f, -0.89414203f, -0.89560260f, + -0.89705359f, -0.89849497f, -0.89992673f, -0.90134885f, -0.90276131f, + -0.90416411f, -0.90555723f, -0.90694065f, -0.90831436f, -0.90967833f, + -0.91103257f, -0.91237705f, -0.91371176f, -0.91503669f, -0.91635181f, + -0.91765712f, -0.91895261f, -0.92023825f, -0.92151404f, -0.92277996f, + -0.92403600f, -0.92528214f, -0.92651837f, -0.92774468f, -0.92896106f, + -0.93016748f, -0.93136395f, -0.93255044f, -0.93372694f, -0.93489345f, + -0.93604994f, -0.93719641f, -0.93833284f, -0.93945922f, -0.94057555f, + -0.94168180f, -0.94277796f, -0.94386403f, -0.94493999f, -0.94600583f, + -0.94706154f, -0.94810711f, -0.94914252f, -0.95016777f, -0.95118284f, + -0.95218773f, -0.95318242f, -0.95416690f, -0.95514117f, -0.95610520f, + -0.95705900f, -0.95800255f, -0.95893583f, -0.95985885f, -0.96077159f, + -0.96167404f, -0.96256619f, -0.96344803f, -0.96431956f, -0.96518076f, + -0.96603162f, -0.96687213f, -0.96770230f, -0.96852209f, -0.96933152f, + -0.97013057f, -0.97091922f, -0.97169748f, -0.97246533f, -0.97322277f, + -0.97396979f, -0.97470637f, -0.97543252f, -0.97614822f, -0.97685347f, + -0.97754825f, -0.97823257f, -0.97890641f, -0.97956977f, -0.98022263f, + -0.98086500f, -0.98149687f, -0.98211822f, -0.98272906f, -0.98332937f, + -0.98391915f, -0.98449840f, -0.98506710f, -0.98562525f, -0.98617285f, + -0.98670988f, -0.98723635f, -0.98775225f, -0.98825757f, -0.98875230f, + -0.98923645f, -0.98971000f, -0.99017295f, -0.99062530f, -0.99106704f, + -0.99149817f, -0.99191868f, -0.99232857f, -0.99272783f, -0.99311645f, + -0.99349445f, -0.99386180f, -0.99421851f, -0.99456457f, -0.99489998f, + -0.99522474f, -0.99553884f, -0.99584227f, -0.99613505f, -0.99641715f, + -0.99668858f, -0.99694934f, -0.99719943f, -0.99743883f, -0.99766756f, + -0.99788559f, -0.99809295f, -0.99828961f, -0.99847558f, -0.99865086f, + -0.99881544f, -0.99896933f, -0.99911252f, -0.99924501f, -0.99936680f, + -0.99947789f, -0.99957827f, -0.99966795f, -0.99974692f, -0.99981519f, + -0.99987275f, -0.99991960f, -0.99995574f, -0.99998118f, -0.99999590f, + 0.99999967f, 0.99997289f, 0.99990328f, 0.99979084f, 0.99963557f, + 0.99943748f, 0.99919658f, 0.99891288f, 0.99858638f, 0.99821711f, + 0.99780508f, 0.99735031f, 0.99685281f, 0.99631261f, 0.99572973f, + 0.99510420f, 0.99443605f, 0.99372529f, 0.99297196f, 0.99217610f, + 0.99133774f, 0.99045692f, 0.98953366f, 0.98856802f, 0.98756003f, + 0.98650973f, 0.98541718f, 0.98428242f, 0.98310549f, 0.98188645f, + 0.98062534f, 0.97932224f, 0.97797718f, 0.97659022f, 0.97516144f, + 0.97369088f, 0.97217861f, 0.97062469f, 0.96902920f, 0.96739220f, + 0.96571376f, 0.96399395f, 0.96223284f, 0.96043052f, 0.95858705f, + 0.95670253f, 0.95477702f, 0.95281061f, 0.95080338f, 0.94875543f, + 0.94666684f, 0.94453769f, 0.94236808f, 0.94015810f, 0.93790786f, + 0.93561743f, 0.93328693f, 0.93091644f, 0.92850608f, 0.92605595f, + 0.92356614f, 0.92103677f, 0.91846795f, 0.91585979f, 0.91321239f, + 0.91052587f, 0.90780035f, 0.90503595f, 0.90223277f, 0.89939095f, + 0.89651059f, 0.89359184f, 0.89063481f, 0.88763962f, 0.88460641f, + 0.88153531f, 0.87842644f, 0.87527995f, 0.87209596f, 0.86887462f, + 0.86561605f, 0.86232041f, 0.85898782f, 0.85561844f, 0.85221241f, + 0.84876987f, 0.84529098f, 0.84177587f, 0.83822471f, 0.83463763f, + 0.83101481f, 0.82735639f, 0.82366252f, 0.81993338f, 0.81616911f, + 0.81236987f, 0.80853584f, 0.80466718f, 0.80076404f, 0.79682660f, + 0.79285503f, 0.78884950f, 0.78481017f, 0.78073723f, 0.77663084f, + 0.77249118f, 0.76831844f, 0.76411277f, 0.75987438f, 0.75560344f, + 0.75130013f, 0.74696464f, 0.74259715f, 0.73819784f, 0.73376692f, + 0.72930457f, 0.72481097f, 0.72028632f, 0.71573083f, 0.71114467f, + 0.70652804f, 0.70188116f, 0.69720420f, 0.69249738f, 0.68776090f, + 0.68299495f, 0.67819975f, 0.67337550f, 0.66852240f, 0.66364066f, + 0.65873050f, 0.65379211f, 0.64882573f, 0.64383154f, 0.63880978f, + 0.63376065f, 0.62868438f, 0.62358117f, 0.61845126f, 0.61329485f, + 0.60811216f, 0.60290343f, 0.59766888f, 0.59240872f, 0.58712318f, + 0.58181249f, 0.57647688f, 0.57111658f, 0.56573181f, 0.56032281f, + 0.55488980f, 0.54943303f, 0.54395272f, 0.53844911f, 0.53292243f, + 0.52737292f, 0.52180083f, 0.51620638f, 0.51058981f, 0.50495138f, + 0.49929132f, 0.49360987f, 0.48790727f, 0.48218377f, 0.47643962f, + 0.47067506f, 0.46489034f, 0.45908570f, 0.45326139f, 0.44741768f, + 0.44155479f, 0.43567299f, 0.42977253f, 0.42385365f, 0.41791662f, + 0.41196169f, 0.40598911f, 0.39999914f, 0.39399204f, 0.38796806f, + 0.38192746f, 0.37587050f, 0.36979743f, 0.36370853f, 0.35760405f, + 0.35148424f, 0.34534939f, 0.33919973f, 0.33303555f, 0.32685710f, + 0.32066465f, 0.31445847f, 0.30823881f, 0.30200595f, 0.29576015f, + 0.28950169f, 0.28323082f, 0.27694782f, 0.27065295f, 0.26434649f, + 0.25802871f, 0.25169988f, 0.24536026f, 0.23901013f, 0.23264977f, + 0.22627944f, 0.21989941f, 0.21350997f, 0.20711138f, 0.20070391f, + 0.19428785f, 0.18786347f, 0.18143104f, 0.17499084f, 0.16854314f, + 0.16208822f, 0.15562636f, 0.14915783f, 0.14268292f, 0.13620189f, + 0.12971502f, 0.12322260f, 0.11672491f, 0.11022221f, 0.10371479f, + 0.097202924f, 0.090686897f, 0.084166986f, 0.077643468f, 0.071116625f, + 0.064586736f, 0.058054080f, 0.051518937f, 0.044981587f, 0.038442310f, + 0.031901387f, 0.025359097f, 0.018815721f, 0.012271538f, 0.0057268303f, + -0.00081812300f, -0.0073630412f, -0.013907644f, -0.020451651f, -0.026994782f, + -0.033536757f, -0.040077295f, -0.046616116f, -0.053152941f, -0.059687488f, + -0.066219479f, -0.072748633f, -0.079274670f, -0.085797312f, -0.092316279f, + -0.098831291f, -0.10534207f, -0.11184834f, -0.11834981f, -0.12484622f, + -0.13133727f, -0.13782270f, -0.14430223f, -0.15077558f, -0.15724246f, + -0.16370261f, -0.17015575f, -0.17660160f, -0.18303989f, -0.18947033f, + -0.19589266f, -0.20230660f, -0.20871187f, -0.21510820f, -0.22149531f, + -0.22787294f, -0.23424080f, -0.24059864f, -0.24694616f, -0.25328311f, + -0.25960920f, -0.26592418f, -0.27222777f, -0.27851969f, -0.28479968f, + -0.29106748f, -0.29732280f, -0.30356539f, -0.30979497f, -0.31601129f, + -0.32221406f, -0.32840304f, -0.33457794f, -0.34073852f, -0.34688450f, + -0.35301562f, -0.35913161f, -0.36523223f, -0.37131719f, -0.37738626f, + -0.38343915f, -0.38947562f, -0.39549541f, -0.40149825f, -0.40748390f, + -0.41345209f, -0.41940257f, -0.42533508f, -0.43124938f, -0.43714520f, + -0.44302229f, -0.44888041f, -0.45471930f, -0.46053871f, -0.46633839f, + -0.47211810f, -0.47787758f, -0.48361659f, -0.48933489f, -0.49503222f, + -0.50070835f, -0.50636303f, -0.51199602f, -0.51760707f, -0.52319595f, + -0.52876243f, -0.53430625f, -0.53982718f, -0.54532499f, -0.55079944f, + -0.55625029f, -0.56167732f, -0.56708028f, -0.57245896f, -0.57781311f, + -0.58314251f, -0.58844693f, -0.59372614f, -0.59897992f, -0.60420805f, + -0.60941029f, -0.61458642f, -0.61973623f, -0.62485949f, -0.62995598f, + -0.63502549f, -0.64006780f, -0.64508268f, -0.65006994f, -0.65502934f, + -0.65996069f, -0.66486377f, -0.66973837f, -0.67458427f, -0.67940128f, + -0.68418919f, -0.68894779f, -0.69367688f, -0.69837625f, -0.70304571f, + -0.70768504f, -0.71229407f, -0.71687258f, -0.72142039f, -0.72593729f, + -0.73042309f, -0.73487761f, -0.73930064f, -0.74369201f, -0.74805152f, + -0.75237898f, -0.75667422f, -0.76093704f, -0.76516727f, -0.76936471f, + -0.77352921f, -0.77766056f, -0.78175861f, -0.78582316f, -0.78985406f, + -0.79385112f, -0.79781417f, -0.80174305f, -0.80563758f, -0.80949760f, + -0.81332295f, -0.81711346f, -0.82086896f, -0.82458930f, -0.82827432f, + -0.83192386f, -0.83553776f, -0.83911587f, -0.84265803f, -0.84616410f, + -0.84963392f, -0.85306735f, -0.85646423f, -0.85982442f, -0.86314779f, + -0.86643418f, -0.86968345f, -0.87289547f, -0.87607009f, -0.87920719f, + -0.88230663f, -0.88536827f, -0.88839199f, -0.89137765f, -0.89432512f, + -0.89723429f, -0.90010502f, -0.90293719f, -0.90573069f, -0.90848539f, + -0.91120117f, -0.91387791f, -0.91651551f, -0.91911385f, -0.92167282f, + -0.92419231f, -0.92667220f, -0.92911240f, -0.93151280f, -0.93387330f, + -0.93619380f, -0.93847419f, -0.94071438f, -0.94291427f, -0.94507377f, + -0.94719279f, -0.94927123f, -0.95130901f, -0.95330604f, -0.95526223f, + -0.95717750f, -0.95905177f, -0.96088496f, -0.96267699f, -0.96442777f, + -0.96613725f, -0.96780534f, -0.96943197f, -0.97101707f, -0.97256058f, + -0.97406243f, -0.97552255f, -0.97694089f, -0.97831737f, -0.97965195f, + -0.98094456f, -0.98219515f, -0.98340367f, -0.98457006f, -0.98569428f, + -0.98677627f, -0.98781599f, -0.98881340f, -0.98976845f, -0.99068110f, + -0.99155132f, -0.99237906f, -0.99316428f, -0.99390697f, -0.99460708f, + -0.99526458f, -0.99587945f, -0.99645166f, -0.99698119f, -0.99746801f, + -0.99791210f, -0.99831344f, -0.99867202f, -0.99898782f, -0.99926082f, + -0.99949102f, -0.99967841f, -0.99982297f, -0.99992470f, -0.99998360f, + 0.99999866f, 0.99989157f, 0.99961315f, 0.99916346f, 0.99854256f, + 0.99775057f, 0.99678762f, 0.99565388f, 0.99434953f, 0.99287481f, + 0.99122996f, 0.98941527f, 0.98743105f, 0.98527764f, 0.98295541f, + 0.98046475f, 0.97780610f, 0.97497990f, 0.97198664f, 0.96882685f, + 0.96550104f, 0.96200980f, 0.95835373f, 0.95453345f, 0.95054962f, + 0.94640291f, 0.94209404f, 0.93762375f, 0.93299280f, 0.92820199f, + 0.92325213f, 0.91814408f, 0.91287871f, 0.90745693f, 0.90187965f, + 0.89614785f, 0.89026249f, 0.88422459f, 0.87803519f, 0.87169533f, + 0.86520612f, 0.85856866f, 0.85178409f, 0.84485357f, 0.83777828f, + 0.83055945f, 0.82319831f, 0.81569611f, 0.80805415f, 0.80027373f, + 0.79235620f, 0.78430289f, 0.77611520f, 0.76779452f, 0.75934229f, + 0.75075995f, 0.74204897f, 0.73321084f, 0.72424708f, 0.71515923f, + 0.70594883f, 0.69661748f, 0.68716676f, 0.67759830f, 0.66791374f, + 0.65811474f, 0.64820297f, 0.63818013f, 0.62804795f, 0.61780815f, + 0.60746249f, 0.59701275f, 0.58646072f, 0.57580819f, 0.56505701f, + 0.55420900f, 0.54326604f, 0.53222998f, 0.52110274f, 0.50988620f, + 0.49858230f, 0.48719297f, 0.47572016f, 0.46416584f, 0.45253199f, + 0.44082059f, 0.42903367f, 0.41717323f, 0.40524131f, 0.39323996f, + 0.38117123f, 0.36903718f, 0.35683990f, 0.34458148f, 0.33226402f, + 0.31988962f, 0.30746042f, 0.29497853f, 0.28244610f, 0.26986527f, + 0.25723821f, 0.24456706f, 0.23185402f, 0.21910124f, 0.20631092f, + 0.19348526f, 0.18062644f, 0.16773667f, 0.15481816f, 0.14187312f, + 0.12890377f, 0.11591234f, 0.10290104f, 0.089872115f, 0.076827789f, + 0.063770300f, 0.050701883f, 0.037624779f, 0.024541229f, 0.011453473f, + -0.0016362454f, -0.014725683f, -0.027812598f, -0.040894747f, -0.053969889f, + -0.067035784f, -0.080090192f, -0.093130877f, -0.10615561f, -0.11916214f, + -0.13214826f, -0.14511174f, -0.15805036f, -0.17096189f, -0.18384413f, + -0.19669487f, -0.20951190f, -0.22229304f, -0.23503609f, -0.24773886f, + -0.26039919f, -0.27301490f, -0.28558383f, -0.29810383f, -0.31057274f, + -0.32298845f, -0.33534881f, -0.34765171f, -0.35989504f, -0.37207670f, + -0.38419461f, -0.39624670f, -0.40823088f, -0.42014512f, -0.43198737f, + -0.44375560f, -0.45544780f, -0.46706195f, -0.47859608f, -0.49004821f, + -0.50141636f, -0.51269860f, -0.52389299f, -0.53499762f, -0.54601058f, + -0.55692998f, -0.56775395f, -0.57848064f, -0.58910822f, -0.59963485f, + -0.61005873f, -0.62037809f, -0.63059115f, -0.64069616f, -0.65069139f, + -0.66057513f, -0.67034568f, -0.68000137f, -0.68954054f, -0.69896157f, + -0.70826283f, -0.71744274f, -0.72649972f, -0.73543221f, -0.74423869f, + -0.75291765f, -0.76146760f, -0.76988708f, -0.77817464f, -0.78632887f, + -0.79434836f, -0.80223175f, -0.80997767f, -0.81758481f, -0.82505187f, + -0.83237755f, -0.83956061f, -0.84659981f, -0.85349396f, -0.86024186f, + -0.86684237f, -0.87329434f, -0.87959669f, -0.88574831f, -0.89174817f, + -0.89759523f, -0.90328850f, -0.90882699f, -0.91420976f, -0.91943588f, + -0.92450446f, -0.92941463f, -0.93416555f, -0.93875641f, -0.94318642f, + -0.94745482f, -0.95156087f, -0.95550388f, -0.95928317f, -0.96289809f, + -0.96634802f, -0.96963238f, -0.97275059f, -0.97570213f, -0.97848649f, + -0.98110318f, -0.98355177f, -0.98583184f, -0.98794298f, -0.98988485f, + -0.99165711f, -0.99325945f, -0.99469160f, -0.99595331f, -0.99704438f, + -0.99796460f, -0.99871383f, -0.99929194f, -0.99969882f, -0.99993441f, }; -#endif +# endif static const CELTMode mode96000_1920_240 = { -96000, /* Fs */ -240, /* overlap */ -21, /* nbEBands */ -21, /* effEBands */ -{0.92300415f, 0.22000122f, 1.5128347f, 0.66101074f, }, /* preemph */ -eband5ms, /* eBands */ -3, /* maxLM */ -8, /* nbShortMdcts */ -240, /* shortMdctSize */ -11, /* nbAllocVectors */ -band_allocation, /* allocVectors */ -logN400, /* logN */ -window240, /* window */ -{3840, 3, {&fft_state96000_1920_0, &fft_state96000_1920_1, &fft_state96000_1920_2, &fft_state96000_1920_3, }, mdct_twiddles1920}, /* mdct */ -{392, cache_index50, cache_bits50, cache_caps50}, /* cache */ -#ifdef ENABLE_QEXT -{86, qext_cache_index50, qext_cache_bits50, qext_cache_caps50}, /* qext_cache */ -#endif + 96000, /* Fs */ + 240, /* overlap */ + 21, /* nbEBands */ + 21, /* effEBands */ + {0.92300415f, 0.22000122f, 1.5128347f, 0.66101074f, }, /* preemph */ + eband5ms, /* eBands */ + 3, /* maxLM */ + 8, /* nbShortMdcts */ + 240, /* shortMdctSize */ + 11, /* nbAllocVectors */ + band_allocation, /* allocVectors */ + logN400, /* logN */ + window240, /* window */ + {3840, 3, {&fft_state96000_1920_0, &fft_state96000_1920_1, &fft_state96000_1920_2, &fft_state96000_1920_3, }, + mdct_twiddles1920}, /* mdct */ + {392, cache_index50, cache_bits50, cache_caps50}, /* cache */ }; #endif /* ENABLE_QEXT */ /* List of all the available modes */ #ifdef ENABLE_QEXT -#define TOTAL_MODES 2 +# define TOTAL_MODES 2 static const CELTMode * const static_mode_list[TOTAL_MODES] = { -&mode48000_960_120, -&mode96000_1920_240, + &mode48000_960_120, + &mode96000_1920_240, }; #else -#define TOTAL_MODES 1 +# define TOTAL_MODES 1 static const CELTMode * const static_mode_list[TOTAL_MODES] = { -&mode48000_960_120, + &mode48000_960_120, }; #endif diff --git a/celt/static_modes_float_arm_ne10.h b/celt/static_modes_float_arm_ne10.h index 66e1abb10..6b9b7241a 100644 --- a/celt/static_modes_float_arm_ne10.h +++ b/celt/static_modes_float_arm_ne10.h @@ -4,401 +4,401 @@ #include #ifndef NE10_FFT_PARAMS48000_960 -#define NE10_FFT_PARAMS48000_960 +# define NE10_FFT_PARAMS48000_960 static const ne10_int32_t ne10_factors_480[64] = { -4, 40, 4, 30, 2, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, }; + 4, 40, 4, 30, 2, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, }; static const ne10_int32_t ne10_factors_240[64] = { -3, 20, 4, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, }; + 3, 20, 4, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, }; static const ne10_int32_t ne10_factors_120[64] = { -3, 10, 2, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, }; + 3, 10, 2, 15, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, }; static const ne10_int32_t ne10_factors_60[64] = { -2, 5, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0, 0, 0, 0, }; + 2, 5, 5, 3, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, }; static const ne10_fft_cpx_float32_t ne10_twiddles_480[480] = { -{1.0000000f,0.0000000f}, {1.0000000f,-0.0000000f}, {1.0000000f,-0.0000000f}, -{1.0000000f,-0.0000000f}, {0.91354543f,-0.40673664f}, {0.66913056f,-0.74314487f}, -{1.0000000f,-0.0000000f}, {0.66913056f,-0.74314487f}, {-0.10452851f,-0.99452192f}, -{1.0000000f,-0.0000000f}, {0.30901697f,-0.95105654f}, {-0.80901700f,-0.58778518f}, -{1.0000000f,-0.0000000f}, {-0.10452851f,-0.99452192f}, {-0.97814757f,0.20791179f}, -{1.0000000f,-0.0000000f}, {0.97814763f,-0.20791170f}, {0.91354543f,-0.40673664f}, -{0.80901700f,-0.58778524f}, {0.66913056f,-0.74314487f}, {0.49999997f,-0.86602545f}, -{0.30901697f,-0.95105654f}, {0.10452842f,-0.99452192f}, {-0.10452851f,-0.99452192f}, -{-0.30901703f,-0.95105648f}, {-0.50000006f,-0.86602533f}, {-0.66913068f,-0.74314475f}, -{-0.80901700f,-0.58778518f}, {-0.91354549f,-0.40673658f}, {-0.97814763f,-0.20791161f}, -{1.0000000f,-0.0000000f}, {0.99862951f,-0.052335959f}, {0.99452192f,-0.10452846f}, -{0.98768836f,-0.15643448f}, {0.97814763f,-0.20791170f}, {0.96592581f,-0.25881904f}, -{0.95105648f,-0.30901700f}, {0.93358040f,-0.35836795f}, {0.91354543f,-0.40673664f}, -{0.89100653f,-0.45399052f}, {0.86602545f,-0.50000000f}, {0.83867055f,-0.54463905f}, -{0.80901700f,-0.58778524f}, {0.77714598f,-0.62932038f}, {0.74314475f,-0.66913062f}, -{0.70710677f,-0.70710683f}, {0.66913056f,-0.74314487f}, {0.62932038f,-0.77714598f}, -{0.58778524f,-0.80901700f}, {0.54463899f,-0.83867055f}, {0.49999997f,-0.86602545f}, -{0.45399052f,-0.89100653f}, {0.40673661f,-0.91354549f}, {0.35836786f,-0.93358046f}, -{0.30901697f,-0.95105654f}, {0.25881907f,-0.96592581f}, {0.20791166f,-0.97814763f}, -{0.15643437f,-0.98768836f}, {0.10452842f,-0.99452192f}, {0.052335974f,-0.99862951f}, -{1.0000000f,-0.0000000f}, {0.99452192f,-0.10452846f}, {0.97814763f,-0.20791170f}, -{0.95105648f,-0.30901700f}, {0.91354543f,-0.40673664f}, {0.86602545f,-0.50000000f}, -{0.80901700f,-0.58778524f}, {0.74314475f,-0.66913062f}, {0.66913056f,-0.74314487f}, -{0.58778524f,-0.80901700f}, {0.49999997f,-0.86602545f}, {0.40673661f,-0.91354549f}, -{0.30901697f,-0.95105654f}, {0.20791166f,-0.97814763f}, {0.10452842f,-0.99452192f}, -{-4.3711388e-08f,-1.0000000f}, {-0.10452851f,-0.99452192f}, {-0.20791174f,-0.97814757f}, -{-0.30901703f,-0.95105648f}, {-0.40673670f,-0.91354543f}, {-0.50000006f,-0.86602533f}, -{-0.58778518f,-0.80901700f}, {-0.66913068f,-0.74314475f}, {-0.74314493f,-0.66913044f}, -{-0.80901700f,-0.58778518f}, {-0.86602539f,-0.50000006f}, {-0.91354549f,-0.40673658f}, -{-0.95105654f,-0.30901679f}, {-0.97814763f,-0.20791161f}, {-0.99452192f,-0.10452849f}, -{1.0000000f,-0.0000000f}, {0.98768836f,-0.15643448f}, {0.95105648f,-0.30901700f}, -{0.89100653f,-0.45399052f}, {0.80901700f,-0.58778524f}, {0.70710677f,-0.70710683f}, -{0.58778524f,-0.80901700f}, {0.45399052f,-0.89100653f}, {0.30901697f,-0.95105654f}, -{0.15643437f,-0.98768836f}, {-4.3711388e-08f,-1.0000000f}, {-0.15643445f,-0.98768836f}, -{-0.30901703f,-0.95105648f}, {-0.45399061f,-0.89100647f}, {-0.58778518f,-0.80901700f}, -{-0.70710677f,-0.70710677f}, {-0.80901700f,-0.58778518f}, {-0.89100659f,-0.45399037f}, -{-0.95105654f,-0.30901679f}, {-0.98768836f,-0.15643445f}, {-1.0000000f,8.7422777e-08f}, -{-0.98768830f,0.15643461f}, {-0.95105654f,0.30901697f}, {-0.89100653f,0.45399055f}, -{-0.80901694f,0.58778536f}, {-0.70710665f,0.70710689f}, {-0.58778507f,0.80901712f}, -{-0.45399022f,0.89100665f}, {-0.30901709f,0.95105648f}, {-0.15643452f,0.98768830f}, -{1.0000000f,-0.0000000f}, {0.99991435f,-0.013089596f}, {0.99965733f,-0.026176950f}, -{0.99922901f,-0.039259817f}, {0.99862951f,-0.052335959f}, {0.99785894f,-0.065403134f}, -{0.99691731f,-0.078459099f}, {0.99580491f,-0.091501623f}, {0.99452192f,-0.10452846f}, -{0.99306846f,-0.11753740f}, {0.99144489f,-0.13052620f}, {0.98965138f,-0.14349262f}, -{0.98768836f,-0.15643448f}, {0.98555607f,-0.16934951f}, {0.98325491f,-0.18223552f}, -{0.98078525f,-0.19509032f}, {0.97814763f,-0.20791170f}, {0.97534233f,-0.22069745f}, -{0.97236991f,-0.23344538f}, {0.96923089f,-0.24615330f}, {0.96592581f,-0.25881904f}, -{0.96245521f,-0.27144045f}, {0.95881975f,-0.28401536f}, {0.95501995f,-0.29654160f}, -{0.95105648f,-0.30901700f}, {0.94693011f,-0.32143945f}, {0.94264150f,-0.33380687f}, -{0.93819129f,-0.34611708f}, {0.93358040f,-0.35836795f}, {0.92880952f,-0.37055743f}, -{0.92387956f,-0.38268346f}, {0.91879117f,-0.39474389f}, {0.91354543f,-0.40673664f}, -{0.90814316f,-0.41865975f}, {0.90258527f,-0.43051112f}, {0.89687270f,-0.44228873f}, -{0.89100653f,-0.45399052f}, {0.88498765f,-0.46561453f}, {0.87881708f,-0.47715878f}, -{0.87249601f,-0.48862126f}, {0.86602545f,-0.50000000f}, {0.85940641f,-0.51129311f}, -{0.85264015f,-0.52249855f}, {0.84572786f,-0.53361452f}, {0.83867055f,-0.54463905f}, -{0.83146960f,-0.55557024f}, {0.82412618f,-0.56640625f}, {0.81664151f,-0.57714522f}, -{0.80901700f,-0.58778524f}, {0.80125380f,-0.59832460f}, {0.79335332f,-0.60876143f}, -{0.78531694f,-0.61909395f}, {0.77714598f,-0.62932038f}, {0.76884180f,-0.63943899f}, -{0.76040596f,-0.64944810f}, {0.75183982f,-0.65934587f}, {0.74314475f,-0.66913062f}, -{0.73432249f,-0.67880076f}, {0.72537434f,-0.68835455f}, {0.71630192f,-0.69779050f}, -{0.70710677f,-0.70710683f}, {0.69779044f,-0.71630198f}, {0.68835455f,-0.72537440f}, -{0.67880070f,-0.73432255f}, {0.66913056f,-0.74314487f}, {0.65934581f,-0.75183982f}, -{0.64944804f,-0.76040596f}, {0.63943899f,-0.76884186f}, {0.62932038f,-0.77714598f}, -{0.61909395f,-0.78531694f}, {0.60876137f,-0.79335338f}, {0.59832460f,-0.80125386f}, -{0.58778524f,-0.80901700f}, {0.57714516f,-0.81664151f}, {0.56640625f,-0.82412618f}, -{0.55557019f,-0.83146960f}, {0.54463899f,-0.83867055f}, {0.53361452f,-0.84572786f}, -{0.52249849f,-0.85264015f}, {0.51129311f,-0.85940641f}, {0.49999997f,-0.86602545f}, -{0.48862118f,-0.87249601f}, {0.47715876f,-0.87881708f}, {0.46561447f,-0.88498765f}, -{0.45399052f,-0.89100653f}, {0.44228867f,-0.89687276f}, {0.43051103f,-0.90258533f}, -{0.41865975f,-0.90814316f}, {0.40673661f,-0.91354549f}, {0.39474380f,-0.91879129f}, -{0.38268343f,-0.92387956f}, {0.37055740f,-0.92880958f}, {0.35836786f,-0.93358046f}, -{0.34611705f,-0.93819135f}, {0.33380681f,-0.94264150f}, {0.32143947f,-0.94693011f}, -{0.30901697f,-0.95105654f}, {0.29654151f,-0.95501995f}, {0.28401533f,-0.95881975f}, -{0.27144039f,-0.96245527f}, {0.25881907f,-0.96592581f}, {0.24615327f,-0.96923089f}, -{0.23344530f,-0.97236991f}, {0.22069745f,-0.97534233f}, {0.20791166f,-0.97814763f}, -{0.19509023f,-0.98078531f}, {0.18223552f,-0.98325491f}, {0.16934945f,-0.98555607f}, -{0.15643437f,-0.98768836f}, {0.14349259f,-0.98965138f}, {0.13052613f,-0.99144489f}, -{0.11753740f,-0.99306846f}, {0.10452842f,-0.99452192f}, {0.091501534f,-0.99580491f}, -{0.078459084f,-0.99691731f}, {0.065403074f,-0.99785894f}, {0.052335974f,-0.99862951f}, -{0.039259788f,-0.99922901f}, {0.026176875f,-0.99965733f}, {0.013089597f,-0.99991435f}, -{1.0000000f,-0.0000000f}, {0.99965733f,-0.026176950f}, {0.99862951f,-0.052335959f}, -{0.99691731f,-0.078459099f}, {0.99452192f,-0.10452846f}, {0.99144489f,-0.13052620f}, -{0.98768836f,-0.15643448f}, {0.98325491f,-0.18223552f}, {0.97814763f,-0.20791170f}, -{0.97236991f,-0.23344538f}, {0.96592581f,-0.25881904f}, {0.95881975f,-0.28401536f}, -{0.95105648f,-0.30901700f}, {0.94264150f,-0.33380687f}, {0.93358040f,-0.35836795f}, -{0.92387956f,-0.38268346f}, {0.91354543f,-0.40673664f}, {0.90258527f,-0.43051112f}, -{0.89100653f,-0.45399052f}, {0.87881708f,-0.47715878f}, {0.86602545f,-0.50000000f}, -{0.85264015f,-0.52249855f}, {0.83867055f,-0.54463905f}, {0.82412618f,-0.56640625f}, -{0.80901700f,-0.58778524f}, {0.79335332f,-0.60876143f}, {0.77714598f,-0.62932038f}, -{0.76040596f,-0.64944810f}, {0.74314475f,-0.66913062f}, {0.72537434f,-0.68835455f}, -{0.70710677f,-0.70710683f}, {0.68835455f,-0.72537440f}, {0.66913056f,-0.74314487f}, -{0.64944804f,-0.76040596f}, {0.62932038f,-0.77714598f}, {0.60876137f,-0.79335338f}, -{0.58778524f,-0.80901700f}, {0.56640625f,-0.82412618f}, {0.54463899f,-0.83867055f}, -{0.52249849f,-0.85264015f}, {0.49999997f,-0.86602545f}, {0.47715876f,-0.87881708f}, -{0.45399052f,-0.89100653f}, {0.43051103f,-0.90258533f}, {0.40673661f,-0.91354549f}, -{0.38268343f,-0.92387956f}, {0.35836786f,-0.93358046f}, {0.33380681f,-0.94264150f}, -{0.30901697f,-0.95105654f}, {0.28401533f,-0.95881975f}, {0.25881907f,-0.96592581f}, -{0.23344530f,-0.97236991f}, {0.20791166f,-0.97814763f}, {0.18223552f,-0.98325491f}, -{0.15643437f,-0.98768836f}, {0.13052613f,-0.99144489f}, {0.10452842f,-0.99452192f}, -{0.078459084f,-0.99691731f}, {0.052335974f,-0.99862951f}, {0.026176875f,-0.99965733f}, -{-4.3711388e-08f,-1.0000000f}, {-0.026176963f,-0.99965733f}, {-0.052336060f,-0.99862951f}, -{-0.078459173f,-0.99691731f}, {-0.10452851f,-0.99452192f}, {-0.13052621f,-0.99144489f}, -{-0.15643445f,-0.98768836f}, {-0.18223560f,-0.98325491f}, {-0.20791174f,-0.97814757f}, -{-0.23344538f,-0.97236991f}, {-0.25881916f,-0.96592581f}, {-0.28401542f,-0.95881969f}, -{-0.30901703f,-0.95105648f}, {-0.33380687f,-0.94264150f}, {-0.35836795f,-0.93358040f}, -{-0.38268352f,-0.92387950f}, {-0.40673670f,-0.91354543f}, {-0.43051112f,-0.90258527f}, -{-0.45399061f,-0.89100647f}, {-0.47715873f,-0.87881708f}, {-0.50000006f,-0.86602533f}, -{-0.52249867f,-0.85264009f}, {-0.54463905f,-0.83867055f}, {-0.56640631f,-0.82412612f}, -{-0.58778518f,-0.80901700f}, {-0.60876143f,-0.79335332f}, {-0.62932050f,-0.77714586f}, -{-0.64944804f,-0.76040596f}, {-0.66913068f,-0.74314475f}, {-0.68835467f,-0.72537428f}, -{-0.70710677f,-0.70710677f}, {-0.72537446f,-0.68835449f}, {-0.74314493f,-0.66913044f}, -{-0.76040596f,-0.64944804f}, {-0.77714604f,-0.62932026f}, {-0.79335332f,-0.60876143f}, -{-0.80901700f,-0.58778518f}, {-0.82412624f,-0.56640613f}, {-0.83867055f,-0.54463899f}, -{-0.85264021f,-0.52249849f}, {-0.86602539f,-0.50000006f}, {-0.87881714f,-0.47715873f}, -{-0.89100659f,-0.45399037f}, {-0.90258527f,-0.43051112f}, {-0.91354549f,-0.40673658f}, -{-0.92387956f,-0.38268328f}, {-0.93358040f,-0.35836792f}, {-0.94264150f,-0.33380675f}, -{-0.95105654f,-0.30901679f}, {-0.95881975f,-0.28401530f}, {-0.96592587f,-0.25881892f}, -{-0.97236991f,-0.23344538f}, {-0.97814763f,-0.20791161f}, {-0.98325491f,-0.18223536f}, -{-0.98768836f,-0.15643445f}, {-0.99144489f,-0.13052608f}, {-0.99452192f,-0.10452849f}, -{-0.99691737f,-0.078459039f}, {-0.99862957f,-0.052335810f}, {-0.99965733f,-0.026176952f}, -{1.0000000f,-0.0000000f}, {0.99922901f,-0.039259817f}, {0.99691731f,-0.078459099f}, -{0.99306846f,-0.11753740f}, {0.98768836f,-0.15643448f}, {0.98078525f,-0.19509032f}, -{0.97236991f,-0.23344538f}, {0.96245521f,-0.27144045f}, {0.95105648f,-0.30901700f}, -{0.93819129f,-0.34611708f}, {0.92387956f,-0.38268346f}, {0.90814316f,-0.41865975f}, -{0.89100653f,-0.45399052f}, {0.87249601f,-0.48862126f}, {0.85264015f,-0.52249855f}, -{0.83146960f,-0.55557024f}, {0.80901700f,-0.58778524f}, {0.78531694f,-0.61909395f}, -{0.76040596f,-0.64944810f}, {0.73432249f,-0.67880076f}, {0.70710677f,-0.70710683f}, -{0.67880070f,-0.73432255f}, {0.64944804f,-0.76040596f}, {0.61909395f,-0.78531694f}, -{0.58778524f,-0.80901700f}, {0.55557019f,-0.83146960f}, {0.52249849f,-0.85264015f}, -{0.48862118f,-0.87249601f}, {0.45399052f,-0.89100653f}, {0.41865975f,-0.90814316f}, -{0.38268343f,-0.92387956f}, {0.34611705f,-0.93819135f}, {0.30901697f,-0.95105654f}, -{0.27144039f,-0.96245527f}, {0.23344530f,-0.97236991f}, {0.19509023f,-0.98078531f}, -{0.15643437f,-0.98768836f}, {0.11753740f,-0.99306846f}, {0.078459084f,-0.99691731f}, -{0.039259788f,-0.99922901f}, {-4.3711388e-08f,-1.0000000f}, {-0.039259877f,-0.99922901f}, -{-0.078459173f,-0.99691731f}, {-0.11753749f,-0.99306846f}, {-0.15643445f,-0.98768836f}, -{-0.19509032f,-0.98078525f}, {-0.23344538f,-0.97236991f}, {-0.27144048f,-0.96245521f}, -{-0.30901703f,-0.95105648f}, {-0.34611711f,-0.93819129f}, {-0.38268352f,-0.92387950f}, -{-0.41865984f,-0.90814310f}, {-0.45399061f,-0.89100647f}, {-0.48862135f,-0.87249595f}, -{-0.52249867f,-0.85264009f}, {-0.55557036f,-0.83146954f}, {-0.58778518f,-0.80901700f}, -{-0.61909389f,-0.78531694f}, {-0.64944804f,-0.76040596f}, {-0.67880076f,-0.73432249f}, -{-0.70710677f,-0.70710677f}, {-0.73432249f,-0.67880070f}, {-0.76040596f,-0.64944804f}, -{-0.78531694f,-0.61909389f}, {-0.80901700f,-0.58778518f}, {-0.83146966f,-0.55557019f}, -{-0.85264021f,-0.52249849f}, {-0.87249607f,-0.48862115f}, {-0.89100659f,-0.45399037f}, -{-0.90814322f,-0.41865960f}, {-0.92387956f,-0.38268328f}, {-0.93819135f,-0.34611690f}, -{-0.95105654f,-0.30901679f}, {-0.96245521f,-0.27144048f}, {-0.97236991f,-0.23344538f}, -{-0.98078531f,-0.19509031f}, {-0.98768836f,-0.15643445f}, {-0.99306846f,-0.11753736f}, -{-0.99691737f,-0.078459039f}, {-0.99922901f,-0.039259743f}, {-1.0000000f,8.7422777e-08f}, -{-0.99922901f,0.039259918f}, {-0.99691731f,0.078459218f}, {-0.99306846f,0.11753753f}, -{-0.98768830f,0.15643461f}, {-0.98078525f,0.19509049f}, {-0.97236985f,0.23344554f}, -{-0.96245515f,0.27144065f}, {-0.95105654f,0.30901697f}, {-0.93819135f,0.34611705f}, -{-0.92387956f,0.38268346f}, {-0.90814316f,0.41865975f}, {-0.89100653f,0.45399055f}, -{-0.87249601f,0.48862129f}, {-0.85264015f,0.52249861f}, {-0.83146960f,0.55557030f}, -{-0.80901694f,0.58778536f}, {-0.78531688f,0.61909401f}, {-0.76040590f,0.64944816f}, -{-0.73432243f,0.67880082f}, {-0.70710665f,0.70710689f}, {-0.67880058f,0.73432261f}, -{-0.64944792f,0.76040608f}, {-0.61909378f,0.78531706f}, {-0.58778507f,0.80901712f}, -{-0.55557001f,0.83146977f}, {-0.52249837f,0.85264033f}, {-0.48862100f,0.87249613f}, -{-0.45399022f,0.89100665f}, {-0.41865945f,0.90814328f}, {-0.38268313f,0.92387968f}, -{-0.34611672f,0.93819147f}, {-0.30901709f,0.95105648f}, {-0.27144054f,0.96245521f}, -{-0.23344545f,0.97236991f}, {-0.19509038f,0.98078525f}, {-0.15643452f,0.98768830f}, -{-0.11753743f,0.99306846f}, {-0.078459114f,0.99691731f}, {-0.039259821f,0.99922901f}, + {1.0000000f, 0.0000000f}, {1.0000000f, -0.0000000f}, {1.0000000f, -0.0000000f}, + {1.0000000f, -0.0000000f}, {0.91354543f, -0.40673664f}, {0.66913056f, -0.74314487f}, + {1.0000000f, -0.0000000f}, {0.66913056f, -0.74314487f}, {-0.10452851f, -0.99452192f}, + {1.0000000f, -0.0000000f}, {0.30901697f, -0.95105654f}, {-0.80901700f, -0.58778518f}, + {1.0000000f, -0.0000000f}, {-0.10452851f, -0.99452192f}, {-0.97814757f, 0.20791179f}, + {1.0000000f, -0.0000000f}, {0.97814763f, -0.20791170f}, {0.91354543f, -0.40673664f}, + {0.80901700f, -0.58778524f}, {0.66913056f, -0.74314487f}, {0.49999997f, -0.86602545f}, + {0.30901697f, -0.95105654f}, {0.10452842f, -0.99452192f}, {-0.10452851f, -0.99452192f}, + {-0.30901703f, -0.95105648f}, {-0.50000006f, -0.86602533f}, {-0.66913068f, -0.74314475f}, + {-0.80901700f, -0.58778518f}, {-0.91354549f, -0.40673658f}, {-0.97814763f, -0.20791161f}, + {1.0000000f, -0.0000000f}, {0.99862951f, -0.052335959f}, {0.99452192f, -0.10452846f}, + {0.98768836f, -0.15643448f}, {0.97814763f, -0.20791170f}, {0.96592581f, -0.25881904f}, + {0.95105648f, -0.30901700f}, {0.93358040f, -0.35836795f}, {0.91354543f, -0.40673664f}, + {0.89100653f, -0.45399052f}, {0.86602545f, -0.50000000f}, {0.83867055f, -0.54463905f}, + {0.80901700f, -0.58778524f}, {0.77714598f, -0.62932038f}, {0.74314475f, -0.66913062f}, + {0.70710677f, -0.70710683f}, {0.66913056f, -0.74314487f}, {0.62932038f, -0.77714598f}, + {0.58778524f, -0.80901700f}, {0.54463899f, -0.83867055f}, {0.49999997f, -0.86602545f}, + {0.45399052f, -0.89100653f}, {0.40673661f, -0.91354549f}, {0.35836786f, -0.93358046f}, + {0.30901697f, -0.95105654f}, {0.25881907f, -0.96592581f}, {0.20791166f, -0.97814763f}, + {0.15643437f, -0.98768836f}, {0.10452842f, -0.99452192f}, {0.052335974f, -0.99862951f}, + {1.0000000f, -0.0000000f}, {0.99452192f, -0.10452846f}, {0.97814763f, -0.20791170f}, + {0.95105648f, -0.30901700f}, {0.91354543f, -0.40673664f}, {0.86602545f, -0.50000000f}, + {0.80901700f, -0.58778524f}, {0.74314475f, -0.66913062f}, {0.66913056f, -0.74314487f}, + {0.58778524f, -0.80901700f}, {0.49999997f, -0.86602545f}, {0.40673661f, -0.91354549f}, + {0.30901697f, -0.95105654f}, {0.20791166f, -0.97814763f}, {0.10452842f, -0.99452192f}, + {-4.3711388e-08f, -1.0000000f}, {-0.10452851f, -0.99452192f}, {-0.20791174f, -0.97814757f}, + {-0.30901703f, -0.95105648f}, {-0.40673670f, -0.91354543f}, {-0.50000006f, -0.86602533f}, + {-0.58778518f, -0.80901700f}, {-0.66913068f, -0.74314475f}, {-0.74314493f, -0.66913044f}, + {-0.80901700f, -0.58778518f}, {-0.86602539f, -0.50000006f}, {-0.91354549f, -0.40673658f}, + {-0.95105654f, -0.30901679f}, {-0.97814763f, -0.20791161f}, {-0.99452192f, -0.10452849f}, + {1.0000000f, -0.0000000f}, {0.98768836f, -0.15643448f}, {0.95105648f, -0.30901700f}, + {0.89100653f, -0.45399052f}, {0.80901700f, -0.58778524f}, {0.70710677f, -0.70710683f}, + {0.58778524f, -0.80901700f}, {0.45399052f, -0.89100653f}, {0.30901697f, -0.95105654f}, + {0.15643437f, -0.98768836f}, {-4.3711388e-08f, -1.0000000f}, {-0.15643445f, -0.98768836f}, + {-0.30901703f, -0.95105648f}, {-0.45399061f, -0.89100647f}, {-0.58778518f, -0.80901700f}, + {-0.70710677f, -0.70710677f}, {-0.80901700f, -0.58778518f}, {-0.89100659f, -0.45399037f}, + {-0.95105654f, -0.30901679f}, {-0.98768836f, -0.15643445f}, {-1.0000000f, 8.7422777e-08f}, + {-0.98768830f, 0.15643461f}, {-0.95105654f, 0.30901697f}, {-0.89100653f, 0.45399055f}, + {-0.80901694f, 0.58778536f}, {-0.70710665f, 0.70710689f}, {-0.58778507f, 0.80901712f}, + {-0.45399022f, 0.89100665f}, {-0.30901709f, 0.95105648f}, {-0.15643452f, 0.98768830f}, + {1.0000000f, -0.0000000f}, {0.99991435f, -0.013089596f}, {0.99965733f, -0.026176950f}, + {0.99922901f, -0.039259817f}, {0.99862951f, -0.052335959f}, {0.99785894f, -0.065403134f}, + {0.99691731f, -0.078459099f}, {0.99580491f, -0.091501623f}, {0.99452192f, -0.10452846f}, + {0.99306846f, -0.11753740f}, {0.99144489f, -0.13052620f}, {0.98965138f, -0.14349262f}, + {0.98768836f, -0.15643448f}, {0.98555607f, -0.16934951f}, {0.98325491f, -0.18223552f}, + {0.98078525f, -0.19509032f}, {0.97814763f, -0.20791170f}, {0.97534233f, -0.22069745f}, + {0.97236991f, -0.23344538f}, {0.96923089f, -0.24615330f}, {0.96592581f, -0.25881904f}, + {0.96245521f, -0.27144045f}, {0.95881975f, -0.28401536f}, {0.95501995f, -0.29654160f}, + {0.95105648f, -0.30901700f}, {0.94693011f, -0.32143945f}, {0.94264150f, -0.33380687f}, + {0.93819129f, -0.34611708f}, {0.93358040f, -0.35836795f}, {0.92880952f, -0.37055743f}, + {0.92387956f, -0.38268346f}, {0.91879117f, -0.39474389f}, {0.91354543f, -0.40673664f}, + {0.90814316f, -0.41865975f}, {0.90258527f, -0.43051112f}, {0.89687270f, -0.44228873f}, + {0.89100653f, -0.45399052f}, {0.88498765f, -0.46561453f}, {0.87881708f, -0.47715878f}, + {0.87249601f, -0.48862126f}, {0.86602545f, -0.50000000f}, {0.85940641f, -0.51129311f}, + {0.85264015f, -0.52249855f}, {0.84572786f, -0.53361452f}, {0.83867055f, -0.54463905f}, + {0.83146960f, -0.55557024f}, {0.82412618f, -0.56640625f}, {0.81664151f, -0.57714522f}, + {0.80901700f, -0.58778524f}, {0.80125380f, -0.59832460f}, {0.79335332f, -0.60876143f}, + {0.78531694f, -0.61909395f}, {0.77714598f, -0.62932038f}, {0.76884180f, -0.63943899f}, + {0.76040596f, -0.64944810f}, {0.75183982f, -0.65934587f}, {0.74314475f, -0.66913062f}, + {0.73432249f, -0.67880076f}, {0.72537434f, -0.68835455f}, {0.71630192f, -0.69779050f}, + {0.70710677f, -0.70710683f}, {0.69779044f, -0.71630198f}, {0.68835455f, -0.72537440f}, + {0.67880070f, -0.73432255f}, {0.66913056f, -0.74314487f}, {0.65934581f, -0.75183982f}, + {0.64944804f, -0.76040596f}, {0.63943899f, -0.76884186f}, {0.62932038f, -0.77714598f}, + {0.61909395f, -0.78531694f}, {0.60876137f, -0.79335338f}, {0.59832460f, -0.80125386f}, + {0.58778524f, -0.80901700f}, {0.57714516f, -0.81664151f}, {0.56640625f, -0.82412618f}, + {0.55557019f, -0.83146960f}, {0.54463899f, -0.83867055f}, {0.53361452f, -0.84572786f}, + {0.52249849f, -0.85264015f}, {0.51129311f, -0.85940641f}, {0.49999997f, -0.86602545f}, + {0.48862118f, -0.87249601f}, {0.47715876f, -0.87881708f}, {0.46561447f, -0.88498765f}, + {0.45399052f, -0.89100653f}, {0.44228867f, -0.89687276f}, {0.43051103f, -0.90258533f}, + {0.41865975f, -0.90814316f}, {0.40673661f, -0.91354549f}, {0.39474380f, -0.91879129f}, + {0.38268343f, -0.92387956f}, {0.37055740f, -0.92880958f}, {0.35836786f, -0.93358046f}, + {0.34611705f, -0.93819135f}, {0.33380681f, -0.94264150f}, {0.32143947f, -0.94693011f}, + {0.30901697f, -0.95105654f}, {0.29654151f, -0.95501995f}, {0.28401533f, -0.95881975f}, + {0.27144039f, -0.96245527f}, {0.25881907f, -0.96592581f}, {0.24615327f, -0.96923089f}, + {0.23344530f, -0.97236991f}, {0.22069745f, -0.97534233f}, {0.20791166f, -0.97814763f}, + {0.19509023f, -0.98078531f}, {0.18223552f, -0.98325491f}, {0.16934945f, -0.98555607f}, + {0.15643437f, -0.98768836f}, {0.14349259f, -0.98965138f}, {0.13052613f, -0.99144489f}, + {0.11753740f, -0.99306846f}, {0.10452842f, -0.99452192f}, {0.091501534f, -0.99580491f}, + {0.078459084f, -0.99691731f}, {0.065403074f, -0.99785894f}, {0.052335974f, -0.99862951f}, + {0.039259788f, -0.99922901f}, {0.026176875f, -0.99965733f}, {0.013089597f, -0.99991435f}, + {1.0000000f, -0.0000000f}, {0.99965733f, -0.026176950f}, {0.99862951f, -0.052335959f}, + {0.99691731f, -0.078459099f}, {0.99452192f, -0.10452846f}, {0.99144489f, -0.13052620f}, + {0.98768836f, -0.15643448f}, {0.98325491f, -0.18223552f}, {0.97814763f, -0.20791170f}, + {0.97236991f, -0.23344538f}, {0.96592581f, -0.25881904f}, {0.95881975f, -0.28401536f}, + {0.95105648f, -0.30901700f}, {0.94264150f, -0.33380687f}, {0.93358040f, -0.35836795f}, + {0.92387956f, -0.38268346f}, {0.91354543f, -0.40673664f}, {0.90258527f, -0.43051112f}, + {0.89100653f, -0.45399052f}, {0.87881708f, -0.47715878f}, {0.86602545f, -0.50000000f}, + {0.85264015f, -0.52249855f}, {0.83867055f, -0.54463905f}, {0.82412618f, -0.56640625f}, + {0.80901700f, -0.58778524f}, {0.79335332f, -0.60876143f}, {0.77714598f, -0.62932038f}, + {0.76040596f, -0.64944810f}, {0.74314475f, -0.66913062f}, {0.72537434f, -0.68835455f}, + {0.70710677f, -0.70710683f}, {0.68835455f, -0.72537440f}, {0.66913056f, -0.74314487f}, + {0.64944804f, -0.76040596f}, {0.62932038f, -0.77714598f}, {0.60876137f, -0.79335338f}, + {0.58778524f, -0.80901700f}, {0.56640625f, -0.82412618f}, {0.54463899f, -0.83867055f}, + {0.52249849f, -0.85264015f}, {0.49999997f, -0.86602545f}, {0.47715876f, -0.87881708f}, + {0.45399052f, -0.89100653f}, {0.43051103f, -0.90258533f}, {0.40673661f, -0.91354549f}, + {0.38268343f, -0.92387956f}, {0.35836786f, -0.93358046f}, {0.33380681f, -0.94264150f}, + {0.30901697f, -0.95105654f}, {0.28401533f, -0.95881975f}, {0.25881907f, -0.96592581f}, + {0.23344530f, -0.97236991f}, {0.20791166f, -0.97814763f}, {0.18223552f, -0.98325491f}, + {0.15643437f, -0.98768836f}, {0.13052613f, -0.99144489f}, {0.10452842f, -0.99452192f}, + {0.078459084f, -0.99691731f}, {0.052335974f, -0.99862951f}, {0.026176875f, -0.99965733f}, + {-4.3711388e-08f, -1.0000000f}, {-0.026176963f, -0.99965733f}, {-0.052336060f, -0.99862951f}, + {-0.078459173f, -0.99691731f}, {-0.10452851f, -0.99452192f}, {-0.13052621f, -0.99144489f}, + {-0.15643445f, -0.98768836f}, {-0.18223560f, -0.98325491f}, {-0.20791174f, -0.97814757f}, + {-0.23344538f, -0.97236991f}, {-0.25881916f, -0.96592581f}, {-0.28401542f, -0.95881969f}, + {-0.30901703f, -0.95105648f}, {-0.33380687f, -0.94264150f}, {-0.35836795f, -0.93358040f}, + {-0.38268352f, -0.92387950f}, {-0.40673670f, -0.91354543f}, {-0.43051112f, -0.90258527f}, + {-0.45399061f, -0.89100647f}, {-0.47715873f, -0.87881708f}, {-0.50000006f, -0.86602533f}, + {-0.52249867f, -0.85264009f}, {-0.54463905f, -0.83867055f}, {-0.56640631f, -0.82412612f}, + {-0.58778518f, -0.80901700f}, {-0.60876143f, -0.79335332f}, {-0.62932050f, -0.77714586f}, + {-0.64944804f, -0.76040596f}, {-0.66913068f, -0.74314475f}, {-0.68835467f, -0.72537428f}, + {-0.70710677f, -0.70710677f}, {-0.72537446f, -0.68835449f}, {-0.74314493f, -0.66913044f}, + {-0.76040596f, -0.64944804f}, {-0.77714604f, -0.62932026f}, {-0.79335332f, -0.60876143f}, + {-0.80901700f, -0.58778518f}, {-0.82412624f, -0.56640613f}, {-0.83867055f, -0.54463899f}, + {-0.85264021f, -0.52249849f}, {-0.86602539f, -0.50000006f}, {-0.87881714f, -0.47715873f}, + {-0.89100659f, -0.45399037f}, {-0.90258527f, -0.43051112f}, {-0.91354549f, -0.40673658f}, + {-0.92387956f, -0.38268328f}, {-0.93358040f, -0.35836792f}, {-0.94264150f, -0.33380675f}, + {-0.95105654f, -0.30901679f}, {-0.95881975f, -0.28401530f}, {-0.96592587f, -0.25881892f}, + {-0.97236991f, -0.23344538f}, {-0.97814763f, -0.20791161f}, {-0.98325491f, -0.18223536f}, + {-0.98768836f, -0.15643445f}, {-0.99144489f, -0.13052608f}, {-0.99452192f, -0.10452849f}, + {-0.99691737f, -0.078459039f}, {-0.99862957f, -0.052335810f}, {-0.99965733f, -0.026176952f}, + {1.0000000f, -0.0000000f}, {0.99922901f, -0.039259817f}, {0.99691731f, -0.078459099f}, + {0.99306846f, -0.11753740f}, {0.98768836f, -0.15643448f}, {0.98078525f, -0.19509032f}, + {0.97236991f, -0.23344538f}, {0.96245521f, -0.27144045f}, {0.95105648f, -0.30901700f}, + {0.93819129f, -0.34611708f}, {0.92387956f, -0.38268346f}, {0.90814316f, -0.41865975f}, + {0.89100653f, -0.45399052f}, {0.87249601f, -0.48862126f}, {0.85264015f, -0.52249855f}, + {0.83146960f, -0.55557024f}, {0.80901700f, -0.58778524f}, {0.78531694f, -0.61909395f}, + {0.76040596f, -0.64944810f}, {0.73432249f, -0.67880076f}, {0.70710677f, -0.70710683f}, + {0.67880070f, -0.73432255f}, {0.64944804f, -0.76040596f}, {0.61909395f, -0.78531694f}, + {0.58778524f, -0.80901700f}, {0.55557019f, -0.83146960f}, {0.52249849f, -0.85264015f}, + {0.48862118f, -0.87249601f}, {0.45399052f, -0.89100653f}, {0.41865975f, -0.90814316f}, + {0.38268343f, -0.92387956f}, {0.34611705f, -0.93819135f}, {0.30901697f, -0.95105654f}, + {0.27144039f, -0.96245527f}, {0.23344530f, -0.97236991f}, {0.19509023f, -0.98078531f}, + {0.15643437f, -0.98768836f}, {0.11753740f, -0.99306846f}, {0.078459084f, -0.99691731f}, + {0.039259788f, -0.99922901f}, {-4.3711388e-08f, -1.0000000f}, {-0.039259877f, -0.99922901f}, + {-0.078459173f, -0.99691731f}, {-0.11753749f, -0.99306846f}, {-0.15643445f, -0.98768836f}, + {-0.19509032f, -0.98078525f}, {-0.23344538f, -0.97236991f}, {-0.27144048f, -0.96245521f}, + {-0.30901703f, -0.95105648f}, {-0.34611711f, -0.93819129f}, {-0.38268352f, -0.92387950f}, + {-0.41865984f, -0.90814310f}, {-0.45399061f, -0.89100647f}, {-0.48862135f, -0.87249595f}, + {-0.52249867f, -0.85264009f}, {-0.55557036f, -0.83146954f}, {-0.58778518f, -0.80901700f}, + {-0.61909389f, -0.78531694f}, {-0.64944804f, -0.76040596f}, {-0.67880076f, -0.73432249f}, + {-0.70710677f, -0.70710677f}, {-0.73432249f, -0.67880070f}, {-0.76040596f, -0.64944804f}, + {-0.78531694f, -0.61909389f}, {-0.80901700f, -0.58778518f}, {-0.83146966f, -0.55557019f}, + {-0.85264021f, -0.52249849f}, {-0.87249607f, -0.48862115f}, {-0.89100659f, -0.45399037f}, + {-0.90814322f, -0.41865960f}, {-0.92387956f, -0.38268328f}, {-0.93819135f, -0.34611690f}, + {-0.95105654f, -0.30901679f}, {-0.96245521f, -0.27144048f}, {-0.97236991f, -0.23344538f}, + {-0.98078531f, -0.19509031f}, {-0.98768836f, -0.15643445f}, {-0.99306846f, -0.11753736f}, + {-0.99691737f, -0.078459039f}, {-0.99922901f, -0.039259743f}, {-1.0000000f, 8.7422777e-08f}, + {-0.99922901f, 0.039259918f}, {-0.99691731f, 0.078459218f}, {-0.99306846f, 0.11753753f}, + {-0.98768830f, 0.15643461f}, {-0.98078525f, 0.19509049f}, {-0.97236985f, 0.23344554f}, + {-0.96245515f, 0.27144065f}, {-0.95105654f, 0.30901697f}, {-0.93819135f, 0.34611705f}, + {-0.92387956f, 0.38268346f}, {-0.90814316f, 0.41865975f}, {-0.89100653f, 0.45399055f}, + {-0.87249601f, 0.48862129f}, {-0.85264015f, 0.52249861f}, {-0.83146960f, 0.55557030f}, + {-0.80901694f, 0.58778536f}, {-0.78531688f, 0.61909401f}, {-0.76040590f, 0.64944816f}, + {-0.73432243f, 0.67880082f}, {-0.70710665f, 0.70710689f}, {-0.67880058f, 0.73432261f}, + {-0.64944792f, 0.76040608f}, {-0.61909378f, 0.78531706f}, {-0.58778507f, 0.80901712f}, + {-0.55557001f, 0.83146977f}, {-0.52249837f, 0.85264033f}, {-0.48862100f, 0.87249613f}, + {-0.45399022f, 0.89100665f}, {-0.41865945f, 0.90814328f}, {-0.38268313f, 0.92387968f}, + {-0.34611672f, 0.93819147f}, {-0.30901709f, 0.95105648f}, {-0.27144054f, 0.96245521f}, + {-0.23344545f, 0.97236991f}, {-0.19509038f, 0.98078525f}, {-0.15643452f, 0.98768830f}, + {-0.11753743f, 0.99306846f}, {-0.078459114f, 0.99691731f}, {-0.039259821f, 0.99922901f}, }; static const ne10_fft_cpx_float32_t ne10_twiddles_240[240] = { -{1.0000000f,0.0000000f}, {1.0000000f,-0.0000000f}, {1.0000000f,-0.0000000f}, -{1.0000000f,-0.0000000f}, {0.91354543f,-0.40673664f}, {0.66913056f,-0.74314487f}, -{1.0000000f,-0.0000000f}, {0.66913056f,-0.74314487f}, {-0.10452851f,-0.99452192f}, -{1.0000000f,-0.0000000f}, {0.30901697f,-0.95105654f}, {-0.80901700f,-0.58778518f}, -{1.0000000f,-0.0000000f}, {-0.10452851f,-0.99452192f}, {-0.97814757f,0.20791179f}, -{1.0000000f,-0.0000000f}, {0.99452192f,-0.10452846f}, {0.97814763f,-0.20791170f}, -{0.95105648f,-0.30901700f}, {0.91354543f,-0.40673664f}, {0.86602545f,-0.50000000f}, -{0.80901700f,-0.58778524f}, {0.74314475f,-0.66913062f}, {0.66913056f,-0.74314487f}, -{0.58778524f,-0.80901700f}, {0.49999997f,-0.86602545f}, {0.40673661f,-0.91354549f}, -{0.30901697f,-0.95105654f}, {0.20791166f,-0.97814763f}, {0.10452842f,-0.99452192f}, -{1.0000000f,-0.0000000f}, {0.97814763f,-0.20791170f}, {0.91354543f,-0.40673664f}, -{0.80901700f,-0.58778524f}, {0.66913056f,-0.74314487f}, {0.49999997f,-0.86602545f}, -{0.30901697f,-0.95105654f}, {0.10452842f,-0.99452192f}, {-0.10452851f,-0.99452192f}, -{-0.30901703f,-0.95105648f}, {-0.50000006f,-0.86602533f}, {-0.66913068f,-0.74314475f}, -{-0.80901700f,-0.58778518f}, {-0.91354549f,-0.40673658f}, {-0.97814763f,-0.20791161f}, -{1.0000000f,-0.0000000f}, {0.95105648f,-0.30901700f}, {0.80901700f,-0.58778524f}, -{0.58778524f,-0.80901700f}, {0.30901697f,-0.95105654f}, {-4.3711388e-08f,-1.0000000f}, -{-0.30901703f,-0.95105648f}, {-0.58778518f,-0.80901700f}, {-0.80901700f,-0.58778518f}, -{-0.95105654f,-0.30901679f}, {-1.0000000f,8.7422777e-08f}, {-0.95105654f,0.30901697f}, -{-0.80901694f,0.58778536f}, {-0.58778507f,0.80901712f}, {-0.30901709f,0.95105648f}, -{1.0000000f,-0.0000000f}, {0.99965733f,-0.026176950f}, {0.99862951f,-0.052335959f}, -{0.99691731f,-0.078459099f}, {0.99452192f,-0.10452846f}, {0.99144489f,-0.13052620f}, -{0.98768836f,-0.15643448f}, {0.98325491f,-0.18223552f}, {0.97814763f,-0.20791170f}, -{0.97236991f,-0.23344538f}, {0.96592581f,-0.25881904f}, {0.95881975f,-0.28401536f}, -{0.95105648f,-0.30901700f}, {0.94264150f,-0.33380687f}, {0.93358040f,-0.35836795f}, -{0.92387956f,-0.38268346f}, {0.91354543f,-0.40673664f}, {0.90258527f,-0.43051112f}, -{0.89100653f,-0.45399052f}, {0.87881708f,-0.47715878f}, {0.86602545f,-0.50000000f}, -{0.85264015f,-0.52249855f}, {0.83867055f,-0.54463905f}, {0.82412618f,-0.56640625f}, -{0.80901700f,-0.58778524f}, {0.79335332f,-0.60876143f}, {0.77714598f,-0.62932038f}, -{0.76040596f,-0.64944810f}, {0.74314475f,-0.66913062f}, {0.72537434f,-0.68835455f}, -{0.70710677f,-0.70710683f}, {0.68835455f,-0.72537440f}, {0.66913056f,-0.74314487f}, -{0.64944804f,-0.76040596f}, {0.62932038f,-0.77714598f}, {0.60876137f,-0.79335338f}, -{0.58778524f,-0.80901700f}, {0.56640625f,-0.82412618f}, {0.54463899f,-0.83867055f}, -{0.52249849f,-0.85264015f}, {0.49999997f,-0.86602545f}, {0.47715876f,-0.87881708f}, -{0.45399052f,-0.89100653f}, {0.43051103f,-0.90258533f}, {0.40673661f,-0.91354549f}, -{0.38268343f,-0.92387956f}, {0.35836786f,-0.93358046f}, {0.33380681f,-0.94264150f}, -{0.30901697f,-0.95105654f}, {0.28401533f,-0.95881975f}, {0.25881907f,-0.96592581f}, -{0.23344530f,-0.97236991f}, {0.20791166f,-0.97814763f}, {0.18223552f,-0.98325491f}, -{0.15643437f,-0.98768836f}, {0.13052613f,-0.99144489f}, {0.10452842f,-0.99452192f}, -{0.078459084f,-0.99691731f}, {0.052335974f,-0.99862951f}, {0.026176875f,-0.99965733f}, -{1.0000000f,-0.0000000f}, {0.99862951f,-0.052335959f}, {0.99452192f,-0.10452846f}, -{0.98768836f,-0.15643448f}, {0.97814763f,-0.20791170f}, {0.96592581f,-0.25881904f}, -{0.95105648f,-0.30901700f}, {0.93358040f,-0.35836795f}, {0.91354543f,-0.40673664f}, -{0.89100653f,-0.45399052f}, {0.86602545f,-0.50000000f}, {0.83867055f,-0.54463905f}, -{0.80901700f,-0.58778524f}, {0.77714598f,-0.62932038f}, {0.74314475f,-0.66913062f}, -{0.70710677f,-0.70710683f}, {0.66913056f,-0.74314487f}, {0.62932038f,-0.77714598f}, -{0.58778524f,-0.80901700f}, {0.54463899f,-0.83867055f}, {0.49999997f,-0.86602545f}, -{0.45399052f,-0.89100653f}, {0.40673661f,-0.91354549f}, {0.35836786f,-0.93358046f}, -{0.30901697f,-0.95105654f}, {0.25881907f,-0.96592581f}, {0.20791166f,-0.97814763f}, -{0.15643437f,-0.98768836f}, {0.10452842f,-0.99452192f}, {0.052335974f,-0.99862951f}, -{-4.3711388e-08f,-1.0000000f}, {-0.052336060f,-0.99862951f}, {-0.10452851f,-0.99452192f}, -{-0.15643445f,-0.98768836f}, {-0.20791174f,-0.97814757f}, {-0.25881916f,-0.96592581f}, -{-0.30901703f,-0.95105648f}, {-0.35836795f,-0.93358040f}, {-0.40673670f,-0.91354543f}, -{-0.45399061f,-0.89100647f}, {-0.50000006f,-0.86602533f}, {-0.54463905f,-0.83867055f}, -{-0.58778518f,-0.80901700f}, {-0.62932050f,-0.77714586f}, {-0.66913068f,-0.74314475f}, -{-0.70710677f,-0.70710677f}, {-0.74314493f,-0.66913044f}, {-0.77714604f,-0.62932026f}, -{-0.80901700f,-0.58778518f}, {-0.83867055f,-0.54463899f}, {-0.86602539f,-0.50000006f}, -{-0.89100659f,-0.45399037f}, {-0.91354549f,-0.40673658f}, {-0.93358040f,-0.35836792f}, -{-0.95105654f,-0.30901679f}, {-0.96592587f,-0.25881892f}, {-0.97814763f,-0.20791161f}, -{-0.98768836f,-0.15643445f}, {-0.99452192f,-0.10452849f}, {-0.99862957f,-0.052335810f}, -{1.0000000f,-0.0000000f}, {0.99691731f,-0.078459099f}, {0.98768836f,-0.15643448f}, -{0.97236991f,-0.23344538f}, {0.95105648f,-0.30901700f}, {0.92387956f,-0.38268346f}, -{0.89100653f,-0.45399052f}, {0.85264015f,-0.52249855f}, {0.80901700f,-0.58778524f}, -{0.76040596f,-0.64944810f}, {0.70710677f,-0.70710683f}, {0.64944804f,-0.76040596f}, -{0.58778524f,-0.80901700f}, {0.52249849f,-0.85264015f}, {0.45399052f,-0.89100653f}, -{0.38268343f,-0.92387956f}, {0.30901697f,-0.95105654f}, {0.23344530f,-0.97236991f}, -{0.15643437f,-0.98768836f}, {0.078459084f,-0.99691731f}, {-4.3711388e-08f,-1.0000000f}, -{-0.078459173f,-0.99691731f}, {-0.15643445f,-0.98768836f}, {-0.23344538f,-0.97236991f}, -{-0.30901703f,-0.95105648f}, {-0.38268352f,-0.92387950f}, {-0.45399061f,-0.89100647f}, -{-0.52249867f,-0.85264009f}, {-0.58778518f,-0.80901700f}, {-0.64944804f,-0.76040596f}, -{-0.70710677f,-0.70710677f}, {-0.76040596f,-0.64944804f}, {-0.80901700f,-0.58778518f}, -{-0.85264021f,-0.52249849f}, {-0.89100659f,-0.45399037f}, {-0.92387956f,-0.38268328f}, -{-0.95105654f,-0.30901679f}, {-0.97236991f,-0.23344538f}, {-0.98768836f,-0.15643445f}, -{-0.99691737f,-0.078459039f}, {-1.0000000f,8.7422777e-08f}, {-0.99691731f,0.078459218f}, -{-0.98768830f,0.15643461f}, {-0.97236985f,0.23344554f}, {-0.95105654f,0.30901697f}, -{-0.92387956f,0.38268346f}, {-0.89100653f,0.45399055f}, {-0.85264015f,0.52249861f}, -{-0.80901694f,0.58778536f}, {-0.76040590f,0.64944816f}, {-0.70710665f,0.70710689f}, -{-0.64944792f,0.76040608f}, {-0.58778507f,0.80901712f}, {-0.52249837f,0.85264033f}, -{-0.45399022f,0.89100665f}, {-0.38268313f,0.92387968f}, {-0.30901709f,0.95105648f}, -{-0.23344545f,0.97236991f}, {-0.15643452f,0.98768830f}, {-0.078459114f,0.99691731f}, + {1.0000000f, 0.0000000f}, {1.0000000f, -0.0000000f}, {1.0000000f, -0.0000000f}, + {1.0000000f, -0.0000000f}, {0.91354543f, -0.40673664f}, {0.66913056f, -0.74314487f}, + {1.0000000f, -0.0000000f}, {0.66913056f, -0.74314487f}, {-0.10452851f, -0.99452192f}, + {1.0000000f, -0.0000000f}, {0.30901697f, -0.95105654f}, {-0.80901700f, -0.58778518f}, + {1.0000000f, -0.0000000f}, {-0.10452851f, -0.99452192f}, {-0.97814757f, 0.20791179f}, + {1.0000000f, -0.0000000f}, {0.99452192f, -0.10452846f}, {0.97814763f, -0.20791170f}, + {0.95105648f, -0.30901700f}, {0.91354543f, -0.40673664f}, {0.86602545f, -0.50000000f}, + {0.80901700f, -0.58778524f}, {0.74314475f, -0.66913062f}, {0.66913056f, -0.74314487f}, + {0.58778524f, -0.80901700f}, {0.49999997f, -0.86602545f}, {0.40673661f, -0.91354549f}, + {0.30901697f, -0.95105654f}, {0.20791166f, -0.97814763f}, {0.10452842f, -0.99452192f}, + {1.0000000f, -0.0000000f}, {0.97814763f, -0.20791170f}, {0.91354543f, -0.40673664f}, + {0.80901700f, -0.58778524f}, {0.66913056f, -0.74314487f}, {0.49999997f, -0.86602545f}, + {0.30901697f, -0.95105654f}, {0.10452842f, -0.99452192f}, {-0.10452851f, -0.99452192f}, + {-0.30901703f, -0.95105648f}, {-0.50000006f, -0.86602533f}, {-0.66913068f, -0.74314475f}, + {-0.80901700f, -0.58778518f}, {-0.91354549f, -0.40673658f}, {-0.97814763f, -0.20791161f}, + {1.0000000f, -0.0000000f}, {0.95105648f, -0.30901700f}, {0.80901700f, -0.58778524f}, + {0.58778524f, -0.80901700f}, {0.30901697f, -0.95105654f}, {-4.3711388e-08f, -1.0000000f}, + {-0.30901703f, -0.95105648f}, {-0.58778518f, -0.80901700f}, {-0.80901700f, -0.58778518f}, + {-0.95105654f, -0.30901679f}, {-1.0000000f, 8.7422777e-08f}, {-0.95105654f, 0.30901697f}, + {-0.80901694f, 0.58778536f}, {-0.58778507f, 0.80901712f}, {-0.30901709f, 0.95105648f}, + {1.0000000f, -0.0000000f}, {0.99965733f, -0.026176950f}, {0.99862951f, -0.052335959f}, + {0.99691731f, -0.078459099f}, {0.99452192f, -0.10452846f}, {0.99144489f, -0.13052620f}, + {0.98768836f, -0.15643448f}, {0.98325491f, -0.18223552f}, {0.97814763f, -0.20791170f}, + {0.97236991f, -0.23344538f}, {0.96592581f, -0.25881904f}, {0.95881975f, -0.28401536f}, + {0.95105648f, -0.30901700f}, {0.94264150f, -0.33380687f}, {0.93358040f, -0.35836795f}, + {0.92387956f, -0.38268346f}, {0.91354543f, -0.40673664f}, {0.90258527f, -0.43051112f}, + {0.89100653f, -0.45399052f}, {0.87881708f, -0.47715878f}, {0.86602545f, -0.50000000f}, + {0.85264015f, -0.52249855f}, {0.83867055f, -0.54463905f}, {0.82412618f, -0.56640625f}, + {0.80901700f, -0.58778524f}, {0.79335332f, -0.60876143f}, {0.77714598f, -0.62932038f}, + {0.76040596f, -0.64944810f}, {0.74314475f, -0.66913062f}, {0.72537434f, -0.68835455f}, + {0.70710677f, -0.70710683f}, {0.68835455f, -0.72537440f}, {0.66913056f, -0.74314487f}, + {0.64944804f, -0.76040596f}, {0.62932038f, -0.77714598f}, {0.60876137f, -0.79335338f}, + {0.58778524f, -0.80901700f}, {0.56640625f, -0.82412618f}, {0.54463899f, -0.83867055f}, + {0.52249849f, -0.85264015f}, {0.49999997f, -0.86602545f}, {0.47715876f, -0.87881708f}, + {0.45399052f, -0.89100653f}, {0.43051103f, -0.90258533f}, {0.40673661f, -0.91354549f}, + {0.38268343f, -0.92387956f}, {0.35836786f, -0.93358046f}, {0.33380681f, -0.94264150f}, + {0.30901697f, -0.95105654f}, {0.28401533f, -0.95881975f}, {0.25881907f, -0.96592581f}, + {0.23344530f, -0.97236991f}, {0.20791166f, -0.97814763f}, {0.18223552f, -0.98325491f}, + {0.15643437f, -0.98768836f}, {0.13052613f, -0.99144489f}, {0.10452842f, -0.99452192f}, + {0.078459084f, -0.99691731f}, {0.052335974f, -0.99862951f}, {0.026176875f, -0.99965733f}, + {1.0000000f, -0.0000000f}, {0.99862951f, -0.052335959f}, {0.99452192f, -0.10452846f}, + {0.98768836f, -0.15643448f}, {0.97814763f, -0.20791170f}, {0.96592581f, -0.25881904f}, + {0.95105648f, -0.30901700f}, {0.93358040f, -0.35836795f}, {0.91354543f, -0.40673664f}, + {0.89100653f, -0.45399052f}, {0.86602545f, -0.50000000f}, {0.83867055f, -0.54463905f}, + {0.80901700f, -0.58778524f}, {0.77714598f, -0.62932038f}, {0.74314475f, -0.66913062f}, + {0.70710677f, -0.70710683f}, {0.66913056f, -0.74314487f}, {0.62932038f, -0.77714598f}, + {0.58778524f, -0.80901700f}, {0.54463899f, -0.83867055f}, {0.49999997f, -0.86602545f}, + {0.45399052f, -0.89100653f}, {0.40673661f, -0.91354549f}, {0.35836786f, -0.93358046f}, + {0.30901697f, -0.95105654f}, {0.25881907f, -0.96592581f}, {0.20791166f, -0.97814763f}, + {0.15643437f, -0.98768836f}, {0.10452842f, -0.99452192f}, {0.052335974f, -0.99862951f}, + {-4.3711388e-08f, -1.0000000f}, {-0.052336060f, -0.99862951f}, {-0.10452851f, -0.99452192f}, + {-0.15643445f, -0.98768836f}, {-0.20791174f, -0.97814757f}, {-0.25881916f, -0.96592581f}, + {-0.30901703f, -0.95105648f}, {-0.35836795f, -0.93358040f}, {-0.40673670f, -0.91354543f}, + {-0.45399061f, -0.89100647f}, {-0.50000006f, -0.86602533f}, {-0.54463905f, -0.83867055f}, + {-0.58778518f, -0.80901700f}, {-0.62932050f, -0.77714586f}, {-0.66913068f, -0.74314475f}, + {-0.70710677f, -0.70710677f}, {-0.74314493f, -0.66913044f}, {-0.77714604f, -0.62932026f}, + {-0.80901700f, -0.58778518f}, {-0.83867055f, -0.54463899f}, {-0.86602539f, -0.50000006f}, + {-0.89100659f, -0.45399037f}, {-0.91354549f, -0.40673658f}, {-0.93358040f, -0.35836792f}, + {-0.95105654f, -0.30901679f}, {-0.96592587f, -0.25881892f}, {-0.97814763f, -0.20791161f}, + {-0.98768836f, -0.15643445f}, {-0.99452192f, -0.10452849f}, {-0.99862957f, -0.052335810f}, + {1.0000000f, -0.0000000f}, {0.99691731f, -0.078459099f}, {0.98768836f, -0.15643448f}, + {0.97236991f, -0.23344538f}, {0.95105648f, -0.30901700f}, {0.92387956f, -0.38268346f}, + {0.89100653f, -0.45399052f}, {0.85264015f, -0.52249855f}, {0.80901700f, -0.58778524f}, + {0.76040596f, -0.64944810f}, {0.70710677f, -0.70710683f}, {0.64944804f, -0.76040596f}, + {0.58778524f, -0.80901700f}, {0.52249849f, -0.85264015f}, {0.45399052f, -0.89100653f}, + {0.38268343f, -0.92387956f}, {0.30901697f, -0.95105654f}, {0.23344530f, -0.97236991f}, + {0.15643437f, -0.98768836f}, {0.078459084f, -0.99691731f}, {-4.3711388e-08f, -1.0000000f}, + {-0.078459173f, -0.99691731f}, {-0.15643445f, -0.98768836f}, {-0.23344538f, -0.97236991f}, + {-0.30901703f, -0.95105648f}, {-0.38268352f, -0.92387950f}, {-0.45399061f, -0.89100647f}, + {-0.52249867f, -0.85264009f}, {-0.58778518f, -0.80901700f}, {-0.64944804f, -0.76040596f}, + {-0.70710677f, -0.70710677f}, {-0.76040596f, -0.64944804f}, {-0.80901700f, -0.58778518f}, + {-0.85264021f, -0.52249849f}, {-0.89100659f, -0.45399037f}, {-0.92387956f, -0.38268328f}, + {-0.95105654f, -0.30901679f}, {-0.97236991f, -0.23344538f}, {-0.98768836f, -0.15643445f}, + {-0.99691737f, -0.078459039f}, {-1.0000000f, 8.7422777e-08f}, {-0.99691731f, 0.078459218f}, + {-0.98768830f, 0.15643461f}, {-0.97236985f, 0.23344554f}, {-0.95105654f, 0.30901697f}, + {-0.92387956f, 0.38268346f}, {-0.89100653f, 0.45399055f}, {-0.85264015f, 0.52249861f}, + {-0.80901694f, 0.58778536f}, {-0.76040590f, 0.64944816f}, {-0.70710665f, 0.70710689f}, + {-0.64944792f, 0.76040608f}, {-0.58778507f, 0.80901712f}, {-0.52249837f, 0.85264033f}, + {-0.45399022f, 0.89100665f}, {-0.38268313f, 0.92387968f}, {-0.30901709f, 0.95105648f}, + {-0.23344545f, 0.97236991f}, {-0.15643452f, 0.98768830f}, {-0.078459114f, 0.99691731f}, }; static const ne10_fft_cpx_float32_t ne10_twiddles_120[120] = { -{1.0000000f,0.0000000f}, {1.0000000f,-0.0000000f}, {1.0000000f,-0.0000000f}, -{1.0000000f,-0.0000000f}, {0.91354543f,-0.40673664f}, {0.66913056f,-0.74314487f}, -{1.0000000f,-0.0000000f}, {0.66913056f,-0.74314487f}, {-0.10452851f,-0.99452192f}, -{1.0000000f,-0.0000000f}, {0.30901697f,-0.95105654f}, {-0.80901700f,-0.58778518f}, -{1.0000000f,-0.0000000f}, {-0.10452851f,-0.99452192f}, {-0.97814757f,0.20791179f}, -{1.0000000f,-0.0000000f}, {0.97814763f,-0.20791170f}, {0.91354543f,-0.40673664f}, -{0.80901700f,-0.58778524f}, {0.66913056f,-0.74314487f}, {0.49999997f,-0.86602545f}, -{0.30901697f,-0.95105654f}, {0.10452842f,-0.99452192f}, {-0.10452851f,-0.99452192f}, -{-0.30901703f,-0.95105648f}, {-0.50000006f,-0.86602533f}, {-0.66913068f,-0.74314475f}, -{-0.80901700f,-0.58778518f}, {-0.91354549f,-0.40673658f}, {-0.97814763f,-0.20791161f}, -{1.0000000f,-0.0000000f}, {0.99862951f,-0.052335959f}, {0.99452192f,-0.10452846f}, -{0.98768836f,-0.15643448f}, {0.97814763f,-0.20791170f}, {0.96592581f,-0.25881904f}, -{0.95105648f,-0.30901700f}, {0.93358040f,-0.35836795f}, {0.91354543f,-0.40673664f}, -{0.89100653f,-0.45399052f}, {0.86602545f,-0.50000000f}, {0.83867055f,-0.54463905f}, -{0.80901700f,-0.58778524f}, {0.77714598f,-0.62932038f}, {0.74314475f,-0.66913062f}, -{0.70710677f,-0.70710683f}, {0.66913056f,-0.74314487f}, {0.62932038f,-0.77714598f}, -{0.58778524f,-0.80901700f}, {0.54463899f,-0.83867055f}, {0.49999997f,-0.86602545f}, -{0.45399052f,-0.89100653f}, {0.40673661f,-0.91354549f}, {0.35836786f,-0.93358046f}, -{0.30901697f,-0.95105654f}, {0.25881907f,-0.96592581f}, {0.20791166f,-0.97814763f}, -{0.15643437f,-0.98768836f}, {0.10452842f,-0.99452192f}, {0.052335974f,-0.99862951f}, -{1.0000000f,-0.0000000f}, {0.99452192f,-0.10452846f}, {0.97814763f,-0.20791170f}, -{0.95105648f,-0.30901700f}, {0.91354543f,-0.40673664f}, {0.86602545f,-0.50000000f}, -{0.80901700f,-0.58778524f}, {0.74314475f,-0.66913062f}, {0.66913056f,-0.74314487f}, -{0.58778524f,-0.80901700f}, {0.49999997f,-0.86602545f}, {0.40673661f,-0.91354549f}, -{0.30901697f,-0.95105654f}, {0.20791166f,-0.97814763f}, {0.10452842f,-0.99452192f}, -{-4.3711388e-08f,-1.0000000f}, {-0.10452851f,-0.99452192f}, {-0.20791174f,-0.97814757f}, -{-0.30901703f,-0.95105648f}, {-0.40673670f,-0.91354543f}, {-0.50000006f,-0.86602533f}, -{-0.58778518f,-0.80901700f}, {-0.66913068f,-0.74314475f}, {-0.74314493f,-0.66913044f}, -{-0.80901700f,-0.58778518f}, {-0.86602539f,-0.50000006f}, {-0.91354549f,-0.40673658f}, -{-0.95105654f,-0.30901679f}, {-0.97814763f,-0.20791161f}, {-0.99452192f,-0.10452849f}, -{1.0000000f,-0.0000000f}, {0.98768836f,-0.15643448f}, {0.95105648f,-0.30901700f}, -{0.89100653f,-0.45399052f}, {0.80901700f,-0.58778524f}, {0.70710677f,-0.70710683f}, -{0.58778524f,-0.80901700f}, {0.45399052f,-0.89100653f}, {0.30901697f,-0.95105654f}, -{0.15643437f,-0.98768836f}, {-4.3711388e-08f,-1.0000000f}, {-0.15643445f,-0.98768836f}, -{-0.30901703f,-0.95105648f}, {-0.45399061f,-0.89100647f}, {-0.58778518f,-0.80901700f}, -{-0.70710677f,-0.70710677f}, {-0.80901700f,-0.58778518f}, {-0.89100659f,-0.45399037f}, -{-0.95105654f,-0.30901679f}, {-0.98768836f,-0.15643445f}, {-1.0000000f,8.7422777e-08f}, -{-0.98768830f,0.15643461f}, {-0.95105654f,0.30901697f}, {-0.89100653f,0.45399055f}, -{-0.80901694f,0.58778536f}, {-0.70710665f,0.70710689f}, {-0.58778507f,0.80901712f}, -{-0.45399022f,0.89100665f}, {-0.30901709f,0.95105648f}, {-0.15643452f,0.98768830f}, + {1.0000000f, 0.0000000f}, {1.0000000f, -0.0000000f}, {1.0000000f, -0.0000000f}, + {1.0000000f, -0.0000000f}, {0.91354543f, -0.40673664f}, {0.66913056f, -0.74314487f}, + {1.0000000f, -0.0000000f}, {0.66913056f, -0.74314487f}, {-0.10452851f, -0.99452192f}, + {1.0000000f, -0.0000000f}, {0.30901697f, -0.95105654f}, {-0.80901700f, -0.58778518f}, + {1.0000000f, -0.0000000f}, {-0.10452851f, -0.99452192f}, {-0.97814757f, 0.20791179f}, + {1.0000000f, -0.0000000f}, {0.97814763f, -0.20791170f}, {0.91354543f, -0.40673664f}, + {0.80901700f, -0.58778524f}, {0.66913056f, -0.74314487f}, {0.49999997f, -0.86602545f}, + {0.30901697f, -0.95105654f}, {0.10452842f, -0.99452192f}, {-0.10452851f, -0.99452192f}, + {-0.30901703f, -0.95105648f}, {-0.50000006f, -0.86602533f}, {-0.66913068f, -0.74314475f}, + {-0.80901700f, -0.58778518f}, {-0.91354549f, -0.40673658f}, {-0.97814763f, -0.20791161f}, + {1.0000000f, -0.0000000f}, {0.99862951f, -0.052335959f}, {0.99452192f, -0.10452846f}, + {0.98768836f, -0.15643448f}, {0.97814763f, -0.20791170f}, {0.96592581f, -0.25881904f}, + {0.95105648f, -0.30901700f}, {0.93358040f, -0.35836795f}, {0.91354543f, -0.40673664f}, + {0.89100653f, -0.45399052f}, {0.86602545f, -0.50000000f}, {0.83867055f, -0.54463905f}, + {0.80901700f, -0.58778524f}, {0.77714598f, -0.62932038f}, {0.74314475f, -0.66913062f}, + {0.70710677f, -0.70710683f}, {0.66913056f, -0.74314487f}, {0.62932038f, -0.77714598f}, + {0.58778524f, -0.80901700f}, {0.54463899f, -0.83867055f}, {0.49999997f, -0.86602545f}, + {0.45399052f, -0.89100653f}, {0.40673661f, -0.91354549f}, {0.35836786f, -0.93358046f}, + {0.30901697f, -0.95105654f}, {0.25881907f, -0.96592581f}, {0.20791166f, -0.97814763f}, + {0.15643437f, -0.98768836f}, {0.10452842f, -0.99452192f}, {0.052335974f, -0.99862951f}, + {1.0000000f, -0.0000000f}, {0.99452192f, -0.10452846f}, {0.97814763f, -0.20791170f}, + {0.95105648f, -0.30901700f}, {0.91354543f, -0.40673664f}, {0.86602545f, -0.50000000f}, + {0.80901700f, -0.58778524f}, {0.74314475f, -0.66913062f}, {0.66913056f, -0.74314487f}, + {0.58778524f, -0.80901700f}, {0.49999997f, -0.86602545f}, {0.40673661f, -0.91354549f}, + {0.30901697f, -0.95105654f}, {0.20791166f, -0.97814763f}, {0.10452842f, -0.99452192f}, + {-4.3711388e-08f, -1.0000000f}, {-0.10452851f, -0.99452192f}, {-0.20791174f, -0.97814757f}, + {-0.30901703f, -0.95105648f}, {-0.40673670f, -0.91354543f}, {-0.50000006f, -0.86602533f}, + {-0.58778518f, -0.80901700f}, {-0.66913068f, -0.74314475f}, {-0.74314493f, -0.66913044f}, + {-0.80901700f, -0.58778518f}, {-0.86602539f, -0.50000006f}, {-0.91354549f, -0.40673658f}, + {-0.95105654f, -0.30901679f}, {-0.97814763f, -0.20791161f}, {-0.99452192f, -0.10452849f}, + {1.0000000f, -0.0000000f}, {0.98768836f, -0.15643448f}, {0.95105648f, -0.30901700f}, + {0.89100653f, -0.45399052f}, {0.80901700f, -0.58778524f}, {0.70710677f, -0.70710683f}, + {0.58778524f, -0.80901700f}, {0.45399052f, -0.89100653f}, {0.30901697f, -0.95105654f}, + {0.15643437f, -0.98768836f}, {-4.3711388e-08f, -1.0000000f}, {-0.15643445f, -0.98768836f}, + {-0.30901703f, -0.95105648f}, {-0.45399061f, -0.89100647f}, {-0.58778518f, -0.80901700f}, + {-0.70710677f, -0.70710677f}, {-0.80901700f, -0.58778518f}, {-0.89100659f, -0.45399037f}, + {-0.95105654f, -0.30901679f}, {-0.98768836f, -0.15643445f}, {-1.0000000f, 8.7422777e-08f}, + {-0.98768830f, 0.15643461f}, {-0.95105654f, 0.30901697f}, {-0.89100653f, 0.45399055f}, + {-0.80901694f, 0.58778536f}, {-0.70710665f, 0.70710689f}, {-0.58778507f, 0.80901712f}, + {-0.45399022f, 0.89100665f}, {-0.30901709f, 0.95105648f}, {-0.15643452f, 0.98768830f}, }; static const ne10_fft_cpx_float32_t ne10_twiddles_60[60] = { -{1.0000000f,0.0000000f}, {1.0000000f,-0.0000000f}, {1.0000000f,-0.0000000f}, -{1.0000000f,-0.0000000f}, {0.91354543f,-0.40673664f}, {0.66913056f,-0.74314487f}, -{1.0000000f,-0.0000000f}, {0.66913056f,-0.74314487f}, {-0.10452851f,-0.99452192f}, -{1.0000000f,-0.0000000f}, {0.30901697f,-0.95105654f}, {-0.80901700f,-0.58778518f}, -{1.0000000f,-0.0000000f}, {-0.10452851f,-0.99452192f}, {-0.97814757f,0.20791179f}, -{1.0000000f,-0.0000000f}, {0.99452192f,-0.10452846f}, {0.97814763f,-0.20791170f}, -{0.95105648f,-0.30901700f}, {0.91354543f,-0.40673664f}, {0.86602545f,-0.50000000f}, -{0.80901700f,-0.58778524f}, {0.74314475f,-0.66913062f}, {0.66913056f,-0.74314487f}, -{0.58778524f,-0.80901700f}, {0.49999997f,-0.86602545f}, {0.40673661f,-0.91354549f}, -{0.30901697f,-0.95105654f}, {0.20791166f,-0.97814763f}, {0.10452842f,-0.99452192f}, -{1.0000000f,-0.0000000f}, {0.97814763f,-0.20791170f}, {0.91354543f,-0.40673664f}, -{0.80901700f,-0.58778524f}, {0.66913056f,-0.74314487f}, {0.49999997f,-0.86602545f}, -{0.30901697f,-0.95105654f}, {0.10452842f,-0.99452192f}, {-0.10452851f,-0.99452192f}, -{-0.30901703f,-0.95105648f}, {-0.50000006f,-0.86602533f}, {-0.66913068f,-0.74314475f}, -{-0.80901700f,-0.58778518f}, {-0.91354549f,-0.40673658f}, {-0.97814763f,-0.20791161f}, -{1.0000000f,-0.0000000f}, {0.95105648f,-0.30901700f}, {0.80901700f,-0.58778524f}, -{0.58778524f,-0.80901700f}, {0.30901697f,-0.95105654f}, {-4.3711388e-08f,-1.0000000f}, -{-0.30901703f,-0.95105648f}, {-0.58778518f,-0.80901700f}, {-0.80901700f,-0.58778518f}, -{-0.95105654f,-0.30901679f}, {-1.0000000f,8.7422777e-08f}, {-0.95105654f,0.30901697f}, -{-0.80901694f,0.58778536f}, {-0.58778507f,0.80901712f}, {-0.30901709f,0.95105648f}, + {1.0000000f, 0.0000000f}, {1.0000000f, -0.0000000f}, {1.0000000f, -0.0000000f}, + {1.0000000f, -0.0000000f}, {0.91354543f, -0.40673664f}, {0.66913056f, -0.74314487f}, + {1.0000000f, -0.0000000f}, {0.66913056f, -0.74314487f}, {-0.10452851f, -0.99452192f}, + {1.0000000f, -0.0000000f}, {0.30901697f, -0.95105654f}, {-0.80901700f, -0.58778518f}, + {1.0000000f, -0.0000000f}, {-0.10452851f, -0.99452192f}, {-0.97814757f, 0.20791179f}, + {1.0000000f, -0.0000000f}, {0.99452192f, -0.10452846f}, {0.97814763f, -0.20791170f}, + {0.95105648f, -0.30901700f}, {0.91354543f, -0.40673664f}, {0.86602545f, -0.50000000f}, + {0.80901700f, -0.58778524f}, {0.74314475f, -0.66913062f}, {0.66913056f, -0.74314487f}, + {0.58778524f, -0.80901700f}, {0.49999997f, -0.86602545f}, {0.40673661f, -0.91354549f}, + {0.30901697f, -0.95105654f}, {0.20791166f, -0.97814763f}, {0.10452842f, -0.99452192f}, + {1.0000000f, -0.0000000f}, {0.97814763f, -0.20791170f}, {0.91354543f, -0.40673664f}, + {0.80901700f, -0.58778524f}, {0.66913056f, -0.74314487f}, {0.49999997f, -0.86602545f}, + {0.30901697f, -0.95105654f}, {0.10452842f, -0.99452192f}, {-0.10452851f, -0.99452192f}, + {-0.30901703f, -0.95105648f}, {-0.50000006f, -0.86602533f}, {-0.66913068f, -0.74314475f}, + {-0.80901700f, -0.58778518f}, {-0.91354549f, -0.40673658f}, {-0.97814763f, -0.20791161f}, + {1.0000000f, -0.0000000f}, {0.95105648f, -0.30901700f}, {0.80901700f, -0.58778524f}, + {0.58778524f, -0.80901700f}, {0.30901697f, -0.95105654f}, {-4.3711388e-08f, -1.0000000f}, + {-0.30901703f, -0.95105648f}, {-0.58778518f, -0.80901700f}, {-0.80901700f, -0.58778518f}, + {-0.95105654f, -0.30901679f}, {-1.0000000f, 8.7422777e-08f}, {-0.95105654f, 0.30901697f}, + {-0.80901694f, 0.58778536f}, {-0.58778507f, 0.80901712f}, {-0.30901709f, 0.95105648f}, }; static const ne10_fft_state_float32_t ne10_fft_state_float32_t_480 = { -120, -(ne10_int32_t *)ne10_factors_480, -(ne10_fft_cpx_float32_t *)ne10_twiddles_480, -NULL, -(ne10_fft_cpx_float32_t *)&ne10_twiddles_480[120], + 120, + (ne10_int32_t *)ne10_factors_480, + (ne10_fft_cpx_float32_t *)ne10_twiddles_480, + NULL, + (ne10_fft_cpx_float32_t *)&ne10_twiddles_480[120], /* is_forward_scaled = true */ -(ne10_int32_t) 1, + (ne10_int32_t) 1, /* is_backward_scaled = false */ -(ne10_int32_t) 0, + (ne10_int32_t) 0, }; static const arch_fft_state cfg_arch_480 = { -1, -(void *)&ne10_fft_state_float32_t_480, + 1, + (void *)&ne10_fft_state_float32_t_480, }; static const ne10_fft_state_float32_t ne10_fft_state_float32_t_240 = { -60, -(ne10_int32_t *)ne10_factors_240, -(ne10_fft_cpx_float32_t *)ne10_twiddles_240, -NULL, -(ne10_fft_cpx_float32_t *)&ne10_twiddles_240[60], + 60, + (ne10_int32_t *)ne10_factors_240, + (ne10_fft_cpx_float32_t *)ne10_twiddles_240, + NULL, + (ne10_fft_cpx_float32_t *)&ne10_twiddles_240[60], /* is_forward_scaled = true */ -(ne10_int32_t) 1, + (ne10_int32_t) 1, /* is_backward_scaled = false */ -(ne10_int32_t) 0, + (ne10_int32_t) 0, }; static const arch_fft_state cfg_arch_240 = { -1, -(void *)&ne10_fft_state_float32_t_240, + 1, + (void *)&ne10_fft_state_float32_t_240, }; static const ne10_fft_state_float32_t ne10_fft_state_float32_t_120 = { -30, -(ne10_int32_t *)ne10_factors_120, -(ne10_fft_cpx_float32_t *)ne10_twiddles_120, -NULL, -(ne10_fft_cpx_float32_t *)&ne10_twiddles_120[30], + 30, + (ne10_int32_t *)ne10_factors_120, + (ne10_fft_cpx_float32_t *)ne10_twiddles_120, + NULL, + (ne10_fft_cpx_float32_t *)&ne10_twiddles_120[30], /* is_forward_scaled = true */ -(ne10_int32_t) 1, + (ne10_int32_t) 1, /* is_backward_scaled = false */ -(ne10_int32_t) 0, + (ne10_int32_t) 0, }; static const arch_fft_state cfg_arch_120 = { -1, -(void *)&ne10_fft_state_float32_t_120, + 1, + (void *)&ne10_fft_state_float32_t_120, }; static const ne10_fft_state_float32_t ne10_fft_state_float32_t_60 = { -15, -(ne10_int32_t *)ne10_factors_60, -(ne10_fft_cpx_float32_t *)ne10_twiddles_60, -NULL, -(ne10_fft_cpx_float32_t *)&ne10_twiddles_60[15], + 15, + (ne10_int32_t *)ne10_factors_60, + (ne10_fft_cpx_float32_t *)ne10_twiddles_60, + NULL, + (ne10_fft_cpx_float32_t *)&ne10_twiddles_60[15], /* is_forward_scaled = true */ -(ne10_int32_t) 1, + (ne10_int32_t) 1, /* is_backward_scaled = false */ -(ne10_int32_t) 0, + (ne10_int32_t) 0, }; static const arch_fft_state cfg_arch_60 = { -1, -(void *)&ne10_fft_state_float32_t_60, + 1, + (void *)&ne10_fft_state_float32_t_60, }; #endif /* end NE10_FFT_PARAMS48000_960 */ diff --git a/celt/tests/meson.build b/celt/tests/meson.build index 0e6d2e627..747a0d5d2 100644 --- a/celt/tests/meson.build +++ b/celt/tests/meson.build @@ -11,7 +11,7 @@ tests = [ foreach test_name : tests exe = executable(test_name, '@0@.c'.format(test_name), - include_directories : opus_includes, + include_directories : oac_includes, link_with : [celt_lib, celt_static_libs], dependencies : libm, install : false) diff --git a/celt/tests/test_unit_cwrs32.c b/celt/tests/test_unit_cwrs32.c index f6b8ac4b0..cba7918c0 100644 --- a/celt/tests/test_unit_cwrs32.c +++ b/celt/tests/test_unit_cwrs32.c @@ -24,19 +24,19 @@ 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" +# include "config.h" #endif #include #include #ifndef CUSTOM_MODES -#define CUSTOM_MODES +# define CUSTOM_MODES #else -#define TEST_CUSTOM_MODES +# define TEST_CUSTOM_MODES #endif #define CELT_C @@ -53,110 +53,109 @@ #ifdef TEST_CUSTOM_MODES -#define NDIMS (44) -static const int pn[NDIMS]={ - 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 18, 20, 22, - 24, 26, 28, 30, 32, 36, 40, 44, 48, - 52, 56, 60, 64, 72, 80, 88, 96, 104, - 112, 120, 128, 144, 160, 176, 192, 208 +# define NDIMS (44) +static const int pn[NDIMS] = { + 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 18, 20, 22, + 24, 26, 28, 30, 32, 36, 40, 44, 48, + 52, 56, 60, 64, 72, 80, 88, 96, 104, + 112, 120, 128, 144, 160, 176, 192, 208 }; -static const int pkmax[NDIMS]={ - 128, 128, 128, 128, 88, 52, 36, 26, 22, - 18, 16, 15, 13, 12, 12, 11, 10, 9, - 9, 8, 8, 7, 7, 7, 7, 6, 6, - 6, 6, 6, 5, 5, 5, 5, 5, 5, - 4, 4, 4, 4, 4, 4, 4, 4 +static const int pkmax[NDIMS] = { + 128, 128, 128, 128, 88, 52, 36, 26, 22, + 18, 16, 15, 13, 12, 12, 11, 10, 9, + 9, 8, 8, 7, 7, 7, 7, 6, 6, + 6, 6, 6, 5, 5, 5, 5, 5, 5, + 4, 4, 4, 4, 4, 4, 4, 4 }; #else /* TEST_CUSTOM_MODES */ -#define NDIMS (22) -static const int pn[NDIMS]={ - 2, 3, 4, 6, 8, 9, 11, 12, 16, - 18, 22, 24, 32, 36, 44, 48, 64, 72, - 88, 96, 144, 176 +# define NDIMS (22) +static const int pn[NDIMS] = { + 2, 3, 4, 6, 8, 9, 11, 12, 16, + 18, 22, 24, 32, 36, 44, 48, 64, 72, + 88, 96, 144, 176 }; -static const int pkmax[NDIMS]={ - 128, 128, 128, 88, 36, 26, 18, 16, 12, - 11, 9, 9, 7, 7, 6, 6, 5, 5, - 5, 5, 4, 4 +static const int pkmax[NDIMS] = { + 128, 128, 128, 88, 36, 26, 18, 16, 12, + 11, 9, 9, 7, 7, 6, 6, 5, 5, + 5, 5, 4, 4 }; #endif -int main(void){ - int t; - int n; - ALLOC_STACK; - for(t=0;tpkmax[t])break; - printf("Testing CWRS with N=%i, K=%i...\n",n,k); + oac_uint32 inc; + oac_uint32 nc; + oac_uint32 i; + k = oaci_get_pulses(pseudo); + if (k > pkmax[t]) break; + printf("Testing CWRS with N=%i, K=%i...\n", n, k); #if defined(SMALL_FOOTPRINT) - nc=ncwrs_urow(n,k,uu); + nc = oaci_ncwrs_urow(n, k, uu); #else - nc=CELT_PVQ_V(n,k); + nc = CELT_PVQ_V(n, k); #endif - inc=nc/20000; - if(inc<1)inc=1; - for(i=0;i");*/ + sy = 0; + for (j = 0; j < n; j++) sy += abs(y[j]); + if (sy != k) { + fprintf(stderr, "N=%d Pulse count mismatch in oaci_cwrsi (%d!=%d).\n", + n, sy, k); + return 99; + } + /*printf("%6u of %u:",i,nc); + for(j=0;j");*/ #if defined(SMALL_FOOTPRINT) - ii=icwrs(n,k,&v,y,u); + ii = oaci_icwrs(n, k, &v, y, u); #else - ii=icwrs(n,y); - v=CELT_PVQ_V(n,k); + ii = oaci_icwrs(n, y); + v = CELT_PVQ_V(n, k); #endif - if(ii!=i){ - fprintf(stderr,"Combination-index mismatch (%lu!=%lu).\n", - (long)ii,(long)i); - return 1; - } - if(v!=nc){ - fprintf(stderr,"Combination count mismatch (%lu!=%lu).\n", - (long)v,(long)nc); - return 2; + if (ii != i) { + fprintf(stderr, "Combination-index mismatch (%lu!=%lu).\n", + (long)ii, (long)i); + return 1; + } + if (v != nc) { + fprintf(stderr, "Combination count mismatch (%lu!=%lu).\n", + (long)v, (long)nc); + return 2; + } + /*printf(" %6u\n",i);*/ + } + /*printf("\n");*/ } - /*printf(" %6u\n",i);*/ - } - /*printf("\n");*/ } - } - RESTORE_STACK; - return 0; + RESTORE_STACK; + return 0; } diff --git a/celt/tests/test_unit_dft.c b/celt/tests/test_unit_dft.c index ad6c60a03..919ad3da3 100644 --- a/celt/tests/test_unit_dft.c +++ b/celt/tests/test_unit_dft.c @@ -23,10 +23,10 @@ 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" +# include "config.h" #endif #include @@ -37,64 +37,61 @@ #include "modes.h" #ifndef M_PI -#define M_PI 3.141592653 +# define M_PI 3.141592653 #endif int ret = 0; -void check(kiss_fft_cpx * in,kiss_fft_cpx * out,int nfft,int isinverse) -{ - int bin,k; - double errpow=0,sigpow=0, snr; +void check(kiss_fft_cpx * in, kiss_fft_cpx * out, int nfft, int isinverse) { + int bin, k; + double errpow = 0, sigpow = 0, snr; - for (bin=0;bin1) { + if (argc > 1) { int k; - for (k=1;k @@ -50,334 +50,333 @@ #define DATA_SIZE 10000000 #define DATA_SIZE2 10000 -int main(int _argc,char **_argv){ - ec_enc enc; - ec_dec dec; - long nbits; - long nbits2; - double entropy; - int ft; - int ftb; - int sz; - int i; - int ret; - unsigned int sym; - unsigned int seed; - unsigned char *ptr; - const char *env_seed; - ret=0; - entropy=0; - if (_argc > 2) { - fprintf(stderr, "Usage: %s []\n", _argv[0]); - return 1; - } - env_seed = getenv("SEED"); - if (_argc > 1) - seed = atoi(_argv[1]); - else if (env_seed) - seed = atoi(env_seed); - else - seed = time(NULL); - /*Testing encoding of raw bit values.*/ - ptr = (unsigned char *)malloc(DATA_SIZE); - ec_enc_init(&enc,ptr, DATA_SIZE); - for(ft=2;ft<1024;ft++){ - for(i=0;i 2) { + fprintf(stderr, "Usage: %s []\n", _argv[0]); + return 1; } - } - /*Testing encoding of raw bit values.*/ - for(ftb=1;ftb<16;ftb++){ - for(i=0;i<(1< 1) + seed = atoi(_argv[1]); + else if (env_seed) + seed = atoi(env_seed); + else + seed = time(NULL); + /*Testing encoding of raw bit values.*/ + ptr = (unsigned char *)malloc(DATA_SIZE); + oaci_ec_enc_init(&enc, ptr, DATA_SIZE); + for (ft = 2; ft < 1024; ft++) { + for (i = 0; i < ft; i++) { + entropy += log(ft)*M_LOG2E; + oaci_ec_enc_uint(&enc, i, ft); + } } - } - nbits=ec_tell_frac(&enc); - ec_enc_done(&enc); - fprintf(stderr, + /*Testing encoding of raw bit values.*/ + for (ftb = 1; ftb < 16; ftb++) { + for (i = 0; i < (1<>(rand()%11U))+1U)+10; - sz=rand()/((RAND_MAX>>(rand()%9U))+1U); - data=(unsigned *)malloc(sz*sizeof(*data)); - tell=(unsigned *)malloc((sz+1)*sizeof(*tell)); - ec_enc_init(&enc,ptr,DATA_SIZE2); - zeros = rand()%13==0; - tell[0]=ec_tell_frac(&enc); - for(j=0;j>(rand()%11U)) + 1U) + 10; + sz = rand()/((RAND_MAX>>(rand()%9U)) + 1U); + data = (unsigned *)malloc(sz*sizeof(*data)); + tell = (unsigned *)malloc((sz + 1)*sizeof(*tell)); + oaci_ec_enc_init(&enc, ptr, DATA_SIZE2); + zeros = rand()%13 == 0; + tell[0] = oaci_ec_tell_frac(&enc); + for (j = 0; j < sz; j++) { + if (zeros) + data[j] = 0; + else + data[j] = rand()%ft; + oaci_ec_enc_uint(&enc, data[j], ft); + tell[j + 1] = oaci_ec_tell_frac(&enc); + } + if (rand()%2 == 0) + while (oaci_ec_tell(&enc)%8 != 0) + oaci_ec_enc_uint(&enc, rand()%2, 2); + tell_bits = oaci_ec_tell(&enc); + oaci_ec_enc_done(&enc); + if (tell_bits != (unsigned)oaci_ec_tell(&enc)) { + fprintf(stderr, "oaci_ec_tell() changed after oaci_ec_enc_done(): %i instead of %i (Random seed: %u)\n", + oaci_ec_tell(&enc), tell_bits, seed); + ret = -1; + } + if ((tell_bits + 7)/8 < oaci_ec_range_bytes(&enc)) { + fprintf (stderr, "oaci_ec_tell() lied, there's %i bytes instead of %d (Random seed: %u)\n", + oaci_ec_range_bytes(&enc), (tell_bits + 7)/8, seed); + ret = -1; + } + oaci_ec_dec_init(&dec, ptr, DATA_SIZE2); + if (oaci_ec_tell_frac(&dec) != tell[0]) { + fprintf(stderr, "Tell mismatch between encoder and decoder at symbol %i: %i instead of %i (Random seed: %u).\n", - 0,ec_tell_frac(&dec),tell[0],seed); - } - for(j=0;j>(rand()%9U))+1U); - logp1=(unsigned *)malloc(sz*sizeof(*logp1)); - data=(unsigned *)malloc(sz*sizeof(*data)); - tell=(unsigned *)malloc((sz+1)*sizeof(*tell)); - enc_method=(unsigned *)malloc(sz*sizeof(*enc_method)); - ec_enc_init(&enc,ptr,DATA_SIZE2); - tell[0]=ec_tell_frac(&enc); - for(j=0;j>1)+1); - logp1[j]=(rand()%15)+1; - enc_method[j]=rand()/((RAND_MAX>>2)+1); - switch(enc_method[j]){ - case 0:{ - ec_encode(&enc,data[j]?(1<>(rand()%9U)) + 1U); + logp1 = (unsigned *)malloc(sz*sizeof(*logp1)); + data = (unsigned *)malloc(sz*sizeof(*data)); + tell = (unsigned *)malloc((sz + 1)*sizeof(*tell)); + enc_method = (unsigned *)malloc(sz*sizeof(*enc_method)); + oaci_ec_enc_init(&enc, ptr, DATA_SIZE2); + tell[0] = oaci_ec_tell_frac(&enc); + for (j = 0; j < sz; j++) { + data[j] = rand()/((RAND_MAX>>1) + 1); + logp1[j] = (rand()%15) + 1; + enc_method[j] = rand()/((RAND_MAX>>2) + 1); + switch (enc_method[j]) { + case 0: { + oaci_ec_encode(&enc, data[j]?(1<>2)+1); - switch(dec_method){ - case 0:{ - fs=ec_decode(&dec,1<=(1<=(1<>2) + 1); + switch (dec_method) { + case 0: { + fs = oaci_ec_decode(&dec, 1<= (1<= (1< @@ -42,53 +42,48 @@ #define DATA_SIZE 40000 -int ec_laplace_get_start_freq(int decay) -{ - opus_uint32 ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN+1); - int fs = (ft*(16384-decay))/(16384+decay); - return fs+LAPLACE_MINP; +int ec_laplace_get_start_freq(int decay) { + oac_uint32 ft = 32768 - LAPLACE_MINP*(2*LAPLACE_NMIN + 1); + int fs = (ft*(16384 - decay))/(16384 + decay); + return fs + LAPLACE_MINP; } -int main(void) -{ - int i; - int ret = 0; - ec_enc enc; - ec_dec dec; - unsigned char *ptr; - int val[10000], decay[10000]; - ALLOC_STACK; - ptr = (unsigned char *)malloc(DATA_SIZE); - ec_enc_init(&enc,ptr,DATA_SIZE); +int main(void) { + int i; + int ret = 0; + ec_enc enc; + ec_dec dec; + unsigned char *ptr; + int val[10000], decay[10000]; + ALLOC_STACK; + ptr = (unsigned char *)malloc(DATA_SIZE); + oaci_ec_enc_init(&enc, ptr, DATA_SIZE); - val[0] = 3; decay[0] = 6000; - val[1] = 0; decay[1] = 5800; - val[2] = -1; decay[2] = 5600; - for (i=3;i<10000;i++) - { - val[i] = rand()%15-7; - decay[i] = rand()%11000+5000; - } - for (i=0;i<10000;i++) - ec_laplace_encode(&enc, &val[i], + val[0] = 3; decay[0] = 6000; + val[1] = 0; decay[1] = 5800; + val[2] = -1; decay[2] = 5600; + for (i = 3; i < 10000; i++) { + val[i] = rand()%15 - 7; + decay[i] = rand()%11000 + 5000; + } + for (i = 0; i < 10000; i++) + oaci_ec_laplace_encode(&enc, &val[i], ec_laplace_get_start_freq(decay[i]), decay[i]); - ec_enc_done(&enc); + oaci_ec_enc_done(&enc); - ec_dec_init(&dec,ec_get_buffer(&enc),ec_range_bytes(&enc)); + oaci_ec_dec_init(&dec, oaci_ec_get_buffer(&enc), oaci_ec_range_bytes(&enc)); - for (i=0;i<10000;i++) - { - int d = ec_laplace_decode(&dec, + for (i = 0; i < 10000; i++) { + int d = oaci_ec_laplace_decode(&dec, ec_laplace_get_start_freq(decay[i]), decay[i]); - if (d != val[i]) - { - fprintf (stderr, "Got %d instead of %d\n", d, val[i]); - ret = 1; - } - } + if (d != val[i]) { + fprintf (stderr, "Got %d instead of %d\n", d, val[i]); + ret = 1; + } + } - free(ptr); - RESTORE_STACK; - return ret; + free(ptr); + RESTORE_STACK; + return ret; } diff --git a/celt/tests/test_unit_mathops.c b/celt/tests/test_unit_mathops.c index c3adb3f4c..7d35e1535 100644 --- a/celt/tests/test_unit_mathops.c +++ b/celt/tests/test_unit_mathops.c @@ -26,14 +26,14 @@ 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" +# include "config.h" #endif #ifndef CUSTOM_MODES -#define CUSTOM_MODES +# define CUSTOM_MODES #endif #include @@ -44,773 +44,681 @@ #include "mathops.h" #ifdef FIXED_POINT -#define WORD "%d" -#define FIX_INT_TO_DOUBLE(x,q) (ldexp((double)(x), -(q))) -#define DOUBLE_TO_FIX_INT(x,q) (ldexp((double)(x), (q))) +# define WORD "%d" +# define FIX_INT_TO_DOUBLE(x, q) (ldexp((double)(x), -(q))) +# define DOUBLE_TO_FIX_INT(x, q) (ldexp((double)(x), (q))) #else -#define WORD "%f" +# define WORD "%f" #endif int ret = 0; -void testdiv(void) -{ - opus_int32 i; - for (i=1;i<=327670;i++) - { - double prod; - opus_val32 val; - val = celt_rcp(i); +void testdiv(void) { + oac_int32 i; + for (i = 1; i <= 327670; i++) { + double prod; + oac_val32 val; + val = oaci_celt_rcp(i); #ifdef FIXED_POINT - prod = (1./32768./65526.)*val*i; + prod = (1./32768./65526.)*val*i; #else - prod = val*i; + prod = val*i; #endif - if (fabs(prod-1) > .00025) - { - fprintf (stderr, "div failed: 1/%d=" WORD " (product = %f)\n", i, val, prod); - ret = 1; - } - } + if (fabs(prod - 1) > .00025) { + fprintf (stderr, "div failed: 1/%d=" WORD " (product = %f)\n", i, val, prod); + ret = 1; + } + } } -void testsqrt(void) -{ - opus_int32 i; - for (i=1;i<=1000000000;i++) - { - double ratio; - opus_val16 val; - val = celt_sqrt(i); - ratio = val/sqrt(i); - if (fabs(ratio - 1) > .0005 && fabs(val-sqrt(i)) > 2) - { - fprintf (stderr, "sqrt failed: sqrt(%d)=" WORD " (ratio = %f)\n", i, val, ratio); - ret = 1; - } - i+= i>>10; - } +void testsqrt(void) { + oac_int32 i; + for (i = 1; i <= 1000000000; i++) { + double ratio; + oac_val16 val; + val = oaci_celt_sqrt(i); + ratio = val/sqrt(i); + if (fabs(ratio - 1) > .0005 && fabs(val - sqrt(i)) > 2) { + fprintf (stderr, "sqrt failed: sqrt(%d)=" WORD " (ratio = %f)\n", i, val, ratio); + ret = 1; + } + i += i>>10; + } } -void testbitexactcos(void) -{ - int i; - opus_int32 min_d,max_d,last,chk; - chk=max_d=0; - last=min_d=32767; - for(i=64;i<=16320;i++) - { - opus_int32 d; - opus_int32 q=bitexact_cos(i); - chk ^= q*i; - d = last - q; - if (d>max_d)max_d=d; - if (d max_d) max_d = d; + if (d < min_d) min_d = d; + last = q; + } + if ((chk != 89408644) || (max_d != 5) || (min_d != 0) || (oaci_bitexact_cos(64) != 32767) + || (oaci_bitexact_cos(16320) != 200) || (oaci_bitexact_cos(8192) != 23171)) { + fprintf (stderr, "oaci_bitexact_cos failed\n"); + ret = 1; + } } -void testbitexactlog2tan(void) -{ - int i,fail; - opus_int32 min_d,max_d,last,chk; - fail=chk=max_d=0; - last=min_d=15059; - for(i=64;i<8193;i++) - { - opus_int32 d; - opus_int32 mid=bitexact_cos(i); - opus_int32 side=bitexact_cos(16384-i); - opus_int32 q=bitexact_log2tan(mid,side); - chk ^= q*i; - d = last - q; - if (q!=-1*bitexact_log2tan(side,mid)) - fail = 1; - if (d>max_d)max_d=d; - if (d max_d) max_d = d; + if (d < min_d) min_d = d; + last = q; + } + if ((chk != 15821257) || (max_d != 61) || (min_d != -2) || fail + || (oaci_bitexact_log2tan(32767, 200) != 15059) || (oaci_bitexact_log2tan(30274, 12540) != 2611) + || (oaci_bitexact_log2tan(23171, 23171) != 0)) { + fprintf (stderr, "oaci_bitexact_log2tan failed\n"); + ret = 1; + } } #ifndef FIXED_POINT -void testlog2(void) -{ - float x; - float error_threshold = 2.2e-06; - float max_error = 0; - for (x=0.001f;x<1677700.0;x+=(x/8.0)) - { - float error = fabs((1.442695040888963387*log(x))-celt_log2(x)); - if (max_error < error) - { - max_error = error; - } - - if (error > error_threshold) - { - fprintf (stderr, - "celt_log2 failed: " - "fabs((1.442695040888963387*log(x))-celt_log2(x))>%15.25e " - "(x = %f, error = %15.25e)\n", error_threshold, x, error); - ret = 1; - } - } - fprintf (stdout, "celt_log2 max_error: %15.25e\n", max_error); -} +void testlog2(void) { + float x; + float error_threshold = 2.2e-06; + float max_error = 0; + for (x = 0.001f; x < 1677700.0; x += (x/8.0)) { + float error = fabs((1.442695040888963387*log(x)) - oaci_celt_log2(x)); + if (max_error < error) { + max_error = error; + } -void testexp2(void) -{ - float x; - float error_threshold = 2.3e-07; - float max_error = 0; - for (x=-11.0;x<24.0;x+=0.0007f) - { - float error = fabs(x-(1.442695040888963387*log((double)celt_exp2(x)))); - if (max_error < error) - { - max_error = error; - } - - if (error > error_threshold) - { - fprintf (stderr, - "celt_exp2 failed: " - "fabs(x-(1.442695040888963387*log(celt_exp2(x))))>%15.25e " + if (error > error_threshold) { + fprintf (stderr, + "oaci_celt_log2 failed: " + "fabs((1.442695040888963387*log(x))-oaci_celt_log2(x))>%15.25e " "(x = %f, error = %15.25e)\n", error_threshold, x, error); - ret = 1; - } - } - fprintf (stdout, "celt_exp2 max_error: %15.25e\n", max_error); + ret = 1; + } + } + fprintf (stdout, "oaci_celt_log2 max_error: %15.25e\n", max_error); } -void testexp2log2(void) -{ - float x; - float error_threshold = 2.0e-06; - float max_error = 0; - for (x=-11.0;x<24.0;x+=0.0007f) - { - float error = fabs(x-(celt_log2(celt_exp2(x)))); - if (max_error < error) - { - max_error = error; - } - - if (error > error_threshold) - { - fprintf (stderr, - "celt_log2/celt_exp2 failed: " - "fabs(x-(celt_log2(celt_exp2(x))))>%15.25e " +void testexp2(void) { + float x; + float error_threshold = 2.3e-07; + float max_error = 0; + for (x = -11.0; x < 24.0; x += 0.0007f) { + float error = fabs(x - (1.442695040888963387*log((double)oaci_celt_exp2(x)))); + if (max_error < error) { + max_error = error; + } + + if (error > error_threshold) { + fprintf (stderr, + "oaci_celt_exp2 failed: " + "fabs(x-(1.442695040888963387*log(oaci_celt_exp2(x))))>%15.25e " "(x = %f, error = %15.25e)\n", error_threshold, x, error); - ret = 1; - } - } - fprintf (stdout, "celt_exp2, celt_log2 max_error: %15.25e\n", max_error); + ret = 1; + } + } + fprintf (stdout, "oaci_celt_exp2 max_error: %15.25e\n", max_error); } -void test_cos(void) -{ - float x; - float error_threshold = 6.0e-07; - float max_error = 0; - for (x = -4.0f; x < 4.0f; x += 0.0007f) - { - float error = fabs((float)cos((.5f*PI)*(x)) - celt_cos_norm2(x)); - if (max_error < error) - { - max_error = error; - } - - if (error > error_threshold) - { - fprintf (stderr, - "celt_cos_norm2 failed: " - "fabs(ref_x-(celt_cos_norm2(x)))>%15.25e " +void testexp2log2(void) { + float x; + float error_threshold = 2.0e-06; + float max_error = 0; + for (x = -11.0; x < 24.0; x += 0.0007f) { + float error = fabs(x - (oaci_celt_log2(oaci_celt_exp2(x)))); + if (max_error < error) { + max_error = error; + } + + if (error > error_threshold) { + fprintf (stderr, + "oaci_celt_log2/oaci_celt_exp2 failed: " + "fabs(x-(oaci_celt_log2(oaci_celt_exp2(x))))>%15.25e " "(x = %f, error = %15.25e)\n", error_threshold, x, error); - ret = 1; - } - } - fprintf (stdout, "celt_cos_norm2 max_error: %15.25e\n", max_error); + ret = 1; + } + } + fprintf (stdout, "oaci_celt_exp2, oaci_celt_log2 max_error: %15.25e\n", max_error); } -void test_atan2(void) { - float x, y; - float error_threshold = 1.5e-07; - float max_error = 0; - for (x = 0.0f; x < 1.0f; x += 0.007f) - { - for (y = 0.0f; y <1.0f; y += 0.007f) - { - if (x==0 && y==0) - { - /* atan2(0,0) is undefined behavior. */ - continue; - } - float error = fabs(0.636619772367581f*(float)atan2((double)y, (double)x) - celt_atan2p_norm(y, x)); - if (max_error < error) - { +void test_cos(void) { + float x; + float error_threshold = 6.0e-07; + float max_error = 0; + for (x = -4.0f; x < 4.0f; x += 0.0007f) { + float error = fabs((float)cos((.5f*PI)*(x)) - oaci_celt_cos_norm2(x)); + if (max_error < error) { max_error = error; - } + } - if (error > error_threshold) - { + if (error > error_threshold) { fprintf (stderr, - "celt_atan2p_norm failed: " - "(fabs)(2/pi*atan2(y,x) - celt_atan2p_norm(y,x))>%15.25e " + "oaci_celt_cos_norm2 failed: " + "fabs(ref_x-(oaci_celt_cos_norm2(x)))>%15.25e " + "(x = %f, error = %15.25e)\n", error_threshold, x, error); + ret = 1; + } + } + fprintf (stdout, "oaci_celt_cos_norm2 max_error: %15.25e\n", max_error); +} + +void test_atan2(void) { + float x, y; + float error_threshold = 1.5e-07; + float max_error = 0; + for (x = 0.0f; x < 1.0f; x += 0.007f) { + for (y = 0.0f; y < 1.0f; y += 0.007f) { + if (x == 0 && y == 0) { + /* atan2(0,0) is undefined behavior. */ + continue; + } + float error = fabs(0.636619772367581f*(float)atan2((double)y, (double)x) - oaci_celt_atan2p_norm(y, x)); + if (max_error < error) { + max_error = error; + } + + if (error > error_threshold) { + fprintf (stderr, + "oaci_celt_atan2p_norm failed: " + "(fabs)(2/pi*atan2(y,x) - oaci_celt_atan2p_norm(y,x))>%15.25e " "(x = %f, y = %f, error = %15.25e)\n", error_threshold, x, y, error); - ret = 1; - } - } - } - fprintf (stdout, "celt_atan2p_norm max_error: %15.25e\n", max_error); + ret = 1; + } + } + } + fprintf (stdout, "oaci_celt_atan2p_norm max_error: %15.25e\n", max_error); } #else -void testlog2_db(void) -{ -#if defined(ENABLE_QEXT) - /* celt_log2_db test */ - float error = -1; - float max_error = -2; - float error_threshold = 2.e-07; - opus_int32 x = 0; - int q_input = 14; - for (x = 8; x < 1073741824; x += (x >> 3)) - { - error = fabs((1.442695040888963387*log(FIX_INT_TO_DOUBLE(x, q_input))) - - FIX_INT_TO_DOUBLE(celt_log2_db(x), DB_SHIFT)); - if (error > max_error) - { - max_error = error; - } - if (error > error_threshold) - { - fprintf(stderr, "celt_log2_db failed: error: [%.5e > %.5e] (x = %f)\n", +void testlog2_db(void) { + /* oaci_celt_log2_db test */ + float error = -1; + float max_error = -2; + float error_threshold = 2.e-07; + oac_int32 x = 0; + int q_input = 14; + for (x = 8; x < 1073741824; x += (x>>3)) { + error = fabs((1.442695040888963387*log(FIX_INT_TO_DOUBLE(x, q_input))) + - FIX_INT_TO_DOUBLE(oaci_celt_log2_db(x), DB_SHIFT)); + if (error > max_error) { + max_error = error; + } + if (error > error_threshold) { + fprintf(stderr, "oaci_celt_log2_db failed: error: [%.5e > %.5e] (x = %f)\n", error, error_threshold, FIX_INT_TO_DOUBLE(x, DB_SHIFT)); - ret = 1; - } - } - fprintf(stdout, "celt_log2_db max_error: %.7e\n", max_error); -#endif /* defined(ENABLE_QEXT) */ + ret = 1; + } + } + fprintf(stdout, "oaci_celt_log2_db max_error: %.7e\n", max_error); } -void testlog2(void) -{ - opus_val32 x; - for (x=8;x<1073741824;x+=(x>>3)) - { - float error = fabs((1.442695040888963387*log(x/16384.0))-celt_log2(x)/1024.0); - if (error>0.003) - { - fprintf (stderr, "celt_log2 failed: x = %ld, error = %f\n", (long)x,error); - ret = 1; - } - } +void testlog2(void) { + oac_val32 x; + for (x = 8; x < 1073741824; x += (x>>3)) { + float error = fabs((1.442695040888963387*log(x/16384.0)) - oaci_celt_log2(x)/1024.0); + if (error > 0.003) { + fprintf (stderr, "oaci_celt_log2 failed: x = %ld, error = %f\n", (long)x, error); + ret = 1; + } + } } -void testexp2(void) -{ - opus_val16 x; - for (x=-32768;x<15360;x++) - { - float error1 = fabs(x/1024.0-(1.442695040888963387*log(celt_exp2(x)/65536.0))); - float error2 = fabs(exp(0.6931471805599453094*x/1024.0)-celt_exp2(x)/65536.0); - if (error1>0.0002&&error2>0.00004) - { - fprintf (stderr, "celt_exp2 failed: x = " WORD ", error1 = %f, error2 = %f\n", x,error1,error2); - ret = 1; - } - } +void testexp2(void) { + oac_val16 x; + for (x = -32768; x < 15360; x++) { + float error1 = fabs(x/1024.0 - (1.442695040888963387*log(oaci_celt_exp2(x)/65536.0))); + float error2 = fabs(exp(0.6931471805599453094*x/1024.0) - oaci_celt_exp2(x)/65536.0); + if (error1 > 0.0002 && error2 > 0.00004) { + fprintf (stderr, "oaci_celt_exp2 failed: x = " WORD ", error1 = %f, error2 = %f\n", x, error1, error2); + ret = 1; + } + } } -void testexp2_db(void) -{ -#if defined(ENABLE_QEXT) - float absolute_error = -1; - float absolute_error_threshold = FIX_INT_TO_DOUBLE(2, 16); - float relative_error_threshold = -2; - float fx; - float quantized_fx; - opus_val32 x_32; - - for (fx = -32.0; fx < 15.0; fx += 0.0007) - { - double ground_truth; - x_32 = DOUBLE_TO_FIX_INT(fx, DB_SHIFT); - quantized_fx = FIX_INT_TO_DOUBLE(x_32, DB_SHIFT); - - ground_truth = (exp(0.6931471805599453094 * quantized_fx)); - absolute_error = fabs(ground_truth - - FIX_INT_TO_DOUBLE(celt_exp2_db(x_32), 16)); - - relative_error_threshold = 1.24e-7 * ground_truth; - if (absolute_error > absolute_error_threshold && - absolute_error > relative_error_threshold) - { - fprintf(stderr, +void testexp2_db(void) { + float absolute_error = -1; + float absolute_error_threshold = FIX_INT_TO_DOUBLE(2, 16); + float relative_error_threshold = -2; + float fx; + float quantized_fx; + oac_val32 x_32; + + for (fx = -32.0; fx < 15.0; fx += 0.0007) { + double ground_truth; + x_32 = DOUBLE_TO_FIX_INT(fx, DB_SHIFT); + quantized_fx = FIX_INT_TO_DOUBLE(x_32, DB_SHIFT); + + ground_truth = (exp(0.6931471805599453094*quantized_fx)); + absolute_error = fabs(ground_truth + - FIX_INT_TO_DOUBLE(celt_exp2_db(x_32), 16)); + + relative_error_threshold = 1.24e-7*ground_truth; + if (absolute_error > absolute_error_threshold + && absolute_error > relative_error_threshold) { + fprintf(stderr, "celt_exp2_db failed: " "absolute_error: [%.5e > %.5e] " "relative_error: [%.5e > %.5e] (x = %f)\n", absolute_error, absolute_error_threshold, absolute_error, relative_error_threshold, quantized_fx); - ret = 1; - } - } -#endif /* defined(ENABLE_QEXT) */ + ret = 1; + } + } } -void testexp2log2(void) -{ - opus_val32 x; - for (x=8;x<65536;x+=(x>>3)) - { - float error = fabs(x-0.25*celt_exp2(celt_log2(x)))/16384; - if (error>0.004) - { - fprintf (stderr, "celt_log2/celt_exp2 failed: fabs(x-(celt_exp2(celt_log2(x))))>0.001 (x = %ld, error = %f)\n", (long)x,error); - ret = 1; - } - } +void testexp2log2(void) { + oac_val32 x; + for (x = 8; x < 65536; x += (x>>3)) { + float error = fabs(x - 0.25*oaci_celt_exp2(oaci_celt_log2(x)))/16384; + if (error > 0.004) { + fprintf (stderr, + "oaci_celt_log2/oaci_celt_exp2 failed: fabs(x-(oaci_celt_exp2(oaci_celt_log2(x))))>0.001 (x = %ld, error = %f)\n", (long)x, + error); + ret = 1; + } + } } -void testilog2(void) -{ - opus_val32 x; - for (x=1;x<=268435455;x+=127) - { - opus_val32 lg; - opus_val32 y; - - lg = celt_ilog2(x); - if (lg<0 || lg>=31) - { - printf("celt_ilog2 failed: 0<=celt_ilog2(x)<31 (x = %d, celt_ilog2(x) = %d)\n",x,lg); - ret = 1; - } - y = 1<>1)>=y) - { - printf("celt_ilog2 failed: 2**celt_ilog2(x)<=x<2**(celt_ilog2(x)+1) (x = %d, 2**celt_ilog2(x) = %d)\n",x,y); - ret = 1; - } - } +void testilog2(void) { + oac_val32 x; + for (x = 1; x <= 268435455; x += 127) { + oac_val32 lg; + oac_val32 y; + + lg = oaci_celt_ilog2(x); + if (lg < 0 || lg >= 31) { + printf("oaci_celt_ilog2 failed: 0<=oaci_celt_ilog2(x)<31 (x = %d, oaci_celt_ilog2(x) = %d)\n", x, lg); + ret = 1; + } + y = 1<>1) >= y) { + printf("oaci_celt_ilog2 failed: 2**oaci_celt_ilog2(x)<=x<2**(oaci_celt_ilog2(x)+1) (x = %d, 2**oaci_celt_ilog2(x) = %d)\n", x, + y); + ret = 1; + } + } } -void testrsqrt(void) -{ - float error_threshold = 6.e-08; - float error = 0; - float max_error = 0; - float fx = 0; - float quantized_fx; - opus_int32 x; - for (fx = 0.25; fx < 1.0f; fx += 0.007f) - { - x = DOUBLE_TO_FIX_INT(fx, 31); - quantized_fx = FIX_INT_TO_DOUBLE(x, 31); - error = fabs(FIX_INT_TO_DOUBLE(celt_rsqrt_norm32(x), 29) - - 1/sqrt((double)quantized_fx)); - if (max_error < error) - { - max_error = error; - } - if (error > error_threshold) - { - fprintf (stderr, - "celt_rsqrt_norm32 failed: " - "fabs((1/sqrt(x))-celt_rsqrt_norm32(x))>%15.25e " +void testrsqrt(void) { + float error_threshold = 6.e-08; + float error = 0; + float max_error = 0; + float fx = 0; + float quantized_fx; + oac_int32 x; + for (fx = 0.25; fx < 1.0f; fx += 0.007f) { + x = DOUBLE_TO_FIX_INT(fx, 31); + quantized_fx = FIX_INT_TO_DOUBLE(x, 31); + error = fabs(FIX_INT_TO_DOUBLE(oaci_celt_rsqrt_norm32(x), 29) + - 1/sqrt((double)quantized_fx)); + if (max_error < error) { + max_error = error; + } + if (error > error_threshold) { + fprintf (stderr, + "oaci_celt_rsqrt_norm32 failed: " + "fabs((1/sqrt(x))-oaci_celt_rsqrt_norm32(x))>%15.25e " "(x = %f, error = %15.25e)\n", error_threshold, quantized_fx, error); - ret = 1; - } - } - fprintf (stdout, "celt_rsqrt_norm32 max_error: %.7e\n", max_error); + ret = 1; + } + } + fprintf (stdout, "oaci_celt_rsqrt_norm32 max_error: %.7e\n", max_error); } -void testsqrt32(void) -{ - opus_int32 i; - float absolute_error; - float two_LSBs = FIX_INT_TO_DOUBLE(2, 16); - float relative_error_threshold; - for (i = 0; i <= 1073741824+64; i++) - { - absolute_error = fabs(sqrt(i) - FIX_INT_TO_DOUBLE(celt_sqrt32(i), 16)); - relative_error_threshold = 8e-8 * sqrt(i); - if (absolute_error > two_LSBs && - absolute_error > relative_error_threshold) - { - fprintf(stderr, - "celt_sqrt32 failed: " +void testsqrt32(void) { + oac_int32 i; + float absolute_error; + float two_LSBs = FIX_INT_TO_DOUBLE(2, 16); + float relative_error_threshold; + for (i = 0; i <= 1073741824 + 64; i++) { + absolute_error = fabs(sqrt(i) - FIX_INT_TO_DOUBLE(oaci_celt_sqrt32(i), 16)); + relative_error_threshold = 8e-8*sqrt(i); + if (absolute_error > two_LSBs + && absolute_error > relative_error_threshold) { + fprintf(stderr, + "oaci_celt_sqrt32 failed: " "absolute_error: [%.5e > %.5e] " "relative_error: [%.5e > %.5e] (x = %d)\n", absolute_error, two_LSBs, absolute_error, relative_error_threshold, i); - ret = 1; - } - i+= i>>25; - } + ret = 1; + } + i += i>>25; + } } -void testatan_norm(void) -{ -#if defined(ENABLE_QEXT) - float error = -1; - float max_error = -2; - float error_threshold = 5.97e-08; - float fx = 0; - opus_int32 x = 0; - int q_input = 30; - int q_output = 30; - #define ATAN2_2_OVER_PI 0.636619772367581f - for (fx = -1.0f; fx <= 1.0f; fx += 0.007f) - { - x = DOUBLE_TO_FIX_INT(fx, q_input); - error = fabs(atan(FIX_INT_TO_DOUBLE(x, q_input)) * ATAN2_2_OVER_PI - - FIX_INT_TO_DOUBLE(celt_atan_norm(x), q_output)); - if (error > max_error) - { - max_error = error; - } - if (error > error_threshold) - { - fprintf(stderr, - "celt_atan_norm failed: error: [%.5e > %.5e] (x = %f)\n", +void testatan_norm(void) { + float error = -1; + float max_error = -2; + float error_threshold = 5.97e-08; + float fx = 0; + oac_int32 x = 0; + int q_input = 30; + int q_output = 30; +# define ATAN2_2_OVER_PI 0.636619772367581f + for (fx = -1.0f; fx <= 1.0f; fx += 0.007f) { + x = DOUBLE_TO_FIX_INT(fx, q_input); + error = fabs(atan(FIX_INT_TO_DOUBLE(x, q_input))*ATAN2_2_OVER_PI + - FIX_INT_TO_DOUBLE(oaci_celt_atan_norm(x), q_output)); + if (error > max_error) { + max_error = error; + } + if (error > error_threshold) { + fprintf(stderr, + "oaci_celt_atan_norm failed: error: [%.5e > %.5e] (x = %f)\n", error, error_threshold, FIX_INT_TO_DOUBLE(x, DB_SHIFT)); - ret = 1; - } - } - fprintf(stdout, "celt_atan_norm max_error: %.7e\n", max_error); -#endif /* defined(ENABLE_QEXT) */ + ret = 1; + } + } + fprintf(stdout, "oaci_celt_atan_norm max_error: %.7e\n", max_error); } -void testatan2p_norm(void) -{ -#if defined(ENABLE_QEXT) - float error = -1; - float max_error = -2; - float error_threshold = 1.2e-07; - float fx = 0; - float fy = 0; - opus_int32 x = 0; - opus_int32 y = 0; - int q_input = 30; - int q_output = 30; - #define ATAN2_2_OVER_PI 0.636619772367581f - for (fx = 0.0f; fx <= 1.0f; fx += 0.007f) - { - x = DOUBLE_TO_FIX_INT(fx, q_input); - for (fy = 0.0f; fy <= 1.0f; fy += 0.007f) - { - y = DOUBLE_TO_FIX_INT(fy, q_input); - if (x == 0 && x == 0) - continue; - - error = fabs(atan2(FIX_INT_TO_DOUBLE(y, q_input), - FIX_INT_TO_DOUBLE(x, q_input)) * ATAN2_2_OVER_PI - - FIX_INT_TO_DOUBLE(celt_atan2p_norm(y, x), q_output)); - if (error > max_error) - { - max_error = error; - } - if (error > error_threshold) - { - fprintf(stderr, - "celt_atan2p_norm failed: error: [%.5e > %.5e] (x = %f)\n", +void testatan2p_norm(void) { + float error = -1; + float max_error = -2; + float error_threshold = 1.2e-07; + float fx = 0; + float fy = 0; + oac_int32 x = 0; + oac_int32 y = 0; + int q_input = 30; + int q_output = 30; +# define ATAN2_2_OVER_PI 0.636619772367581f + for (fx = 0.0f; fx <= 1.0f; fx += 0.007f) { + x = DOUBLE_TO_FIX_INT(fx, q_input); + for (fy = 0.0f; fy <= 1.0f; fy += 0.007f) { + y = DOUBLE_TO_FIX_INT(fy, q_input); + if (x == 0 && x == 0) + continue; + + error = fabs(atan2(FIX_INT_TO_DOUBLE(y, q_input), + FIX_INT_TO_DOUBLE(x, q_input))*ATAN2_2_OVER_PI + - FIX_INT_TO_DOUBLE(oaci_celt_atan2p_norm(y, x), q_output)); + if (error > max_error) { + max_error = error; + } + if (error > error_threshold) { + fprintf(stderr, + "oaci_celt_atan2p_norm failed: error: [%.5e > %.5e] (x = %f)\n", error, error_threshold, FIX_INT_TO_DOUBLE(x, DB_SHIFT)); - ret = 1; - } - } - } - fprintf(stdout, "celt_atan2p_norm max_error: %.7e\n", max_error); -#endif /* defined(ENABLE_QEXT) */ + ret = 1; + } + } + } + fprintf(stdout, "oaci_celt_atan2p_norm max_error: %.7e\n", max_error); } -void testatan(void) -{ - testatan_norm(); - testatan2p_norm(); +void testatan(void) { + testatan_norm(); + testatan2p_norm(); } -void test_cos_norm32(void) -{ - float error = -1; - float max_error = -2; - float error_threshold = 1e-07; - float fx = 0; - opus_int32 x = 0; - int q_input = 30; - int q_output = 31; - for (fx = -1.0f; fx <= 1.0f; fx += 0.007f) - { - x = DOUBLE_TO_FIX_INT(fx, q_input); - error = fabs(cos(1.5707963267948966 * FIX_INT_TO_DOUBLE(x, q_input)) - - FIX_INT_TO_DOUBLE(celt_cos_norm32(x), q_output)); - if (error > max_error) - { - max_error = error; - } - if (error > error_threshold) - { - fprintf(stderr, - "celt_cos_norm32 failed: error: [%.5e > %.5e] (x = %f)\n", +void test_cos_norm32(void) { + float error = -1; + float max_error = -2; + float error_threshold = 1e-07; + float fx = 0; + oac_int32 x = 0; + int q_input = 30; + int q_output = 31; + for (fx = -1.0f; fx <= 1.0f; fx += 0.007f) { + x = DOUBLE_TO_FIX_INT(fx, q_input); + error = fabs(cos(1.5707963267948966*FIX_INT_TO_DOUBLE(x, q_input)) + - FIX_INT_TO_DOUBLE(oaci_celt_cos_norm32(x), q_output)); + if (error > max_error) { + max_error = error; + } + if (error > error_threshold) { + fprintf(stderr, + "oaci_celt_cos_norm32 failed: error: [%.5e > %.5e] (x = %f)\n", error, error_threshold, FIX_INT_TO_DOUBLE(x, DB_SHIFT)); - ret = 1; - } - } - fprintf(stdout, "celt_cos_norm32 max_error: %.7e\n", max_error); + ret = 1; + } + } + fprintf(stdout, "oaci_celt_cos_norm32 max_error: %.7e\n", max_error); } -void test_cos(void) -{ - test_cos_norm32(); +void test_cos(void) { + test_cos_norm32(); } -void test_rcp_norm32(void) -{ - double ground_truth; - float absolute_error = -1; - float relative_error = -1; - float two_LSBs = FIX_INT_TO_DOUBLE(2, 29); /* absolute error threshold */ - float relative_error_threshold = 6.51e-08; - float max_relative_error = -1; - float fx; - float quantized_fx; - opus_val32 x; - int q_input = 31; - - for (fx = 0.5; fx <= 1.0; fx += 0.0000007) - { - x = DOUBLE_TO_FIX_INT(fx, q_input); - quantized_fx = FIX_INT_TO_DOUBLE(x, q_input); - ground_truth = 1 / quantized_fx; - absolute_error = fabs(ground_truth - - FIX_INT_TO_DOUBLE(celt_rcp_norm32(x), 30)); - relative_error = absolute_error/ground_truth; - if (max_relative_error < relative_error) { - max_relative_error = relative_error; - } - if (absolute_error > two_LSBs && - absolute_error > relative_error_threshold * ground_truth) { - fprintf(stderr, - "celt_rcp_norm32 failed: " +void test_rcp_norm32(void) { + double ground_truth; + float absolute_error = -1; + float relative_error = -1; + float two_LSBs = FIX_INT_TO_DOUBLE(2, 29); /* absolute error threshold */ + float relative_error_threshold = 6.51e-08; + float max_relative_error = -1; + float fx; + float quantized_fx; + oac_val32 x; + int q_input = 31; + + for (fx = 0.5; fx <= 1.0; fx += 0.0000007) { + x = DOUBLE_TO_FIX_INT(fx, q_input); + quantized_fx = FIX_INT_TO_DOUBLE(x, q_input); + ground_truth = 1/quantized_fx; + absolute_error = fabs(ground_truth + - FIX_INT_TO_DOUBLE(oaci_celt_rcp_norm32(x), 30)); + relative_error = absolute_error/ground_truth; + if (max_relative_error < relative_error) { + max_relative_error = relative_error; + } + if (absolute_error > two_LSBs + && absolute_error > relative_error_threshold*ground_truth) { + fprintf(stderr, + "oaci_celt_rcp_norm32 failed: " "absolute_error: [%.5e > %.5e] " "relative_error: [%.5e > %.5e] (x = %f)\n", absolute_error, two_LSBs, relative_error, relative_error_threshold, quantized_fx); - ret = 1; - } - } - fprintf(stdout, "celt_rcp_norm32 max_rel_error: %.7e\n", max_relative_error); + ret = 1; + } + } + fprintf(stdout, "oaci_celt_rcp_norm32 max_rel_error: %.7e\n", max_relative_error); } #endif #ifndef DISABLE_FLOAT_API -void testcelt_float2int16(int use_ref_impl, int buffer_size) -{ - -#define MAX_BUFFER_SIZE 2080 - int i, cnt; - float floatsToConvert[MAX_BUFFER_SIZE]; - short results[MAX_BUFFER_SIZE] = { 0 }; - float scaleInt16RangeTo01; - - celt_assert(buffer_size <= MAX_BUFFER_SIZE); - - scaleInt16RangeTo01 = 1.f / 32768.f; - cnt = 0; - - while (cnt + 15 < buffer_size && cnt < buffer_size / 2) - { - floatsToConvert[cnt++] = 77777.0f * scaleInt16RangeTo01; - floatsToConvert[cnt++] = 33000.0f * scaleInt16RangeTo01; - floatsToConvert[cnt++] = 32768.0f * scaleInt16RangeTo01; - floatsToConvert[cnt++] = 32767.4f * scaleInt16RangeTo01; - floatsToConvert[cnt++] = 32766.6f * scaleInt16RangeTo01; - floatsToConvert[cnt++] = .501 * scaleInt16RangeTo01; - floatsToConvert[cnt++] = .499f * scaleInt16RangeTo01; - floatsToConvert[cnt++] = .0f; - floatsToConvert[cnt++] = -.499f * scaleInt16RangeTo01; - floatsToConvert[cnt++] = -.501f * scaleInt16RangeTo01; - floatsToConvert[cnt++] = -32767.6f * scaleInt16RangeTo01; - floatsToConvert[cnt++] = -32768.4f * scaleInt16RangeTo01; - floatsToConvert[cnt++] = -32769.0f * scaleInt16RangeTo01; - floatsToConvert[cnt++] = -33000.0f * scaleInt16RangeTo01; - floatsToConvert[cnt++] = -77777.0f * scaleInt16RangeTo01; - - celt_assert(cnt < buffer_size); - } - - while (cnt < buffer_size) - { - float inInt16Range = cnt * 7 + .5; - inInt16Range += (cnt & 0x01) ? .1 : -.1; - inInt16Range *= (cnt & 0x02) ? 1 : -1; - floatsToConvert[cnt++] = inInt16Range * scaleInt16RangeTo01; - } - - for (i = 0; i < MAX_BUFFER_SIZE; ++i) - { - results[i] = 42; - } - - if (use_ref_impl) - { - celt_float2int16_c(floatsToConvert, results, cnt); - } else { - celt_float2int16(floatsToConvert, results, cnt, opus_select_arch()); - } - - for (i = 0; i < cnt; ++i) - { - const float expected = FLOAT2INT16(floatsToConvert[i]); - if (results[i] != expected) - { - fprintf (stderr, "testcelt_float2int16 failed: celt_float2int16 converted %f (index: %d) to %d (x*32768=%f, expected: %d, cnt: %d, ref: %d)\n", - floatsToConvert[i], i, (int)results[i], floatsToConvert[i] * 32768.0f, (int)expected, buffer_size, use_ref_impl); - ret = 1; - } - } - - for (i = cnt; i < MAX_BUFFER_SIZE; ++i) - { - if (results[i] != 42) - { - fprintf (stderr, "testcelt_float2int16 failed: buffer overflow (cnt: %d, ref: %d)\n", buffer_size, use_ref_impl); - ret = 1; - break; - } - } -#undef MAX_BUFFER_SIZE +void testcelt_float2int16(int use_ref_impl, int buffer_size) { + +# define MAX_BUFFER_SIZE 2080 + int i, cnt; + float floatsToConvert[MAX_BUFFER_SIZE]; + short results[MAX_BUFFER_SIZE] = { 0 }; + float scaleInt16RangeTo01; + + celt_assert(buffer_size <= MAX_BUFFER_SIZE); + + scaleInt16RangeTo01 = 1.f/32768.f; + cnt = 0; + + while (cnt + 15 < buffer_size && cnt < buffer_size/2) { + floatsToConvert[cnt++] = 77777.0f*scaleInt16RangeTo01; + floatsToConvert[cnt++] = 33000.0f*scaleInt16RangeTo01; + floatsToConvert[cnt++] = 32768.0f*scaleInt16RangeTo01; + floatsToConvert[cnt++] = 32767.4f*scaleInt16RangeTo01; + floatsToConvert[cnt++] = 32766.6f*scaleInt16RangeTo01; + floatsToConvert[cnt++] = .501*scaleInt16RangeTo01; + floatsToConvert[cnt++] = .499f*scaleInt16RangeTo01; + floatsToConvert[cnt++] = .0f; + floatsToConvert[cnt++] = -.499f*scaleInt16RangeTo01; + floatsToConvert[cnt++] = -.501f*scaleInt16RangeTo01; + floatsToConvert[cnt++] = -32767.6f*scaleInt16RangeTo01; + floatsToConvert[cnt++] = -32768.4f*scaleInt16RangeTo01; + floatsToConvert[cnt++] = -32769.0f*scaleInt16RangeTo01; + floatsToConvert[cnt++] = -33000.0f*scaleInt16RangeTo01; + floatsToConvert[cnt++] = -77777.0f*scaleInt16RangeTo01; + + celt_assert(cnt < buffer_size); + } + + while (cnt < buffer_size) { + float inInt16Range = cnt*7 + .5; + inInt16Range += (cnt&0x01) ? .1 : -.1; + inInt16Range *= (cnt&0x02) ? 1 : -1; + floatsToConvert[cnt++] = inInt16Range*scaleInt16RangeTo01; + } + + for (i = 0; i < MAX_BUFFER_SIZE; ++i) { + results[i] = 42; + } + + if (use_ref_impl) { + oaci_celt_float2int16_c(floatsToConvert, results, cnt); + } else { + oaci_celt_float2int16(floatsToConvert, results, cnt, oac_select_arch()); + } + + for (i = 0; i < cnt; ++i) { + const float expected = FLOAT2INT16(floatsToConvert[i]); + if (results[i] != expected) { + fprintf (stderr, + "testcelt_float2int16 failed: oaci_celt_float2int16 converted %f (index: %d) to %d (x*32768=%f, expected: %d, cnt: %d, ref: %d)\n", + floatsToConvert[i], i, (int)results[i], floatsToConvert[i]*32768.0f, (int)expected, buffer_size, + use_ref_impl); + ret = 1; + } + } + + for (i = cnt; i < MAX_BUFFER_SIZE; ++i) { + if (results[i] != 42) { + fprintf (stderr, "testcelt_float2int16 failed: buffer overflow (cnt: %d, ref: %d)\n", buffer_size, + use_ref_impl); + ret = 1; + break; + } + } +# undef MAX_BUFFER_SIZE } -void testopus_limit2_checkwithin1(int use_ref_impl) -{ -#define BUFFER_SIZE 37 /* strange float count to trigger residue loop of SIMD implementation */ -#define BYTE_COUNT (BUFFER_SIZE * sizeof(float)) - int i, within1; - const int arch = opus_select_arch(); - - float pattern[BUFFER_SIZE], buffer[BUFFER_SIZE]; - - for (i = 0; i < BUFFER_SIZE; ++i) - { - pattern[i] = i % 2 ? -1.f : 1.f; - } - - /* All values within -1..1: - Nothing changed. Return value is implementation-dependent (not expected to recognise nothing exceeds -1..1) */ - memcpy(buffer, pattern, BYTE_COUNT); - within1 = use_ref_impl ? opus_limit2_checkwithin1_c(buffer, BUFFER_SIZE) : opus_limit2_checkwithin1(buffer, BUFFER_SIZE, arch); - if (memcmp(buffer, pattern, BYTE_COUNT) != 0) - { - fprintf (stderr, "opus_limit2_checkwithin1() modified values not exceeding -1..1 (ref=%d)\n", use_ref_impl); - ret = 1; - } - - /* One value exceeds -1..1, within -2..2: - Values unchanged. Return value says not all values are within -1..1 */ - for (i = 0; i < BUFFER_SIZE; ++i) - { - const float replace_value = pattern[i] * 1.001f; - - memcpy(buffer, pattern, BYTE_COUNT); - buffer[i] = replace_value; - within1 = use_ref_impl ? opus_limit2_checkwithin1_c(buffer, BUFFER_SIZE) : opus_limit2_checkwithin1(buffer, BUFFER_SIZE, arch); - if (within1 || buffer[i] != replace_value) - { - fprintf (stderr, "opus_limit2_checkwithin1() handled value exceeding -1..1 erroneously (ref=%d, i=%d)\n", use_ref_impl, i); - ret = 1; - } - buffer[i] = pattern[i]; - if (memcmp(buffer, pattern, BYTE_COUNT) != 0) - { - fprintf (stderr, "opus_limit2_checkwithin1() modified value within -2..2 (ref=%d, i=%d)\n", use_ref_impl, i); - ret = 1; - } - } - - /* One value exceeds -2..2: - One value is hardclipped, others are unchanged. Return value says not all values are within -1..1 */ - for (i = 0; i < BUFFER_SIZE; ++i) - { - const float replace_value = pattern[i] * 2.1; - - memcpy(buffer, pattern, BYTE_COUNT); - buffer[i] = replace_value; - within1 = use_ref_impl ? opus_limit2_checkwithin1_c(buffer, BUFFER_SIZE) : opus_limit2_checkwithin1(buffer, BUFFER_SIZE, arch); - if (within1 || buffer[i] != (replace_value > 0.f ? 2.f : -2.f)) - { - fprintf (stderr, "opus_limit2_checkwithin1() handled value exceeding -2..2 erroneously (ref=%d, i=%d)\n", use_ref_impl, i); - ret = 1; - } - buffer[i] = pattern[i]; - if (memcmp(buffer, pattern, BYTE_COUNT) != 0) - { - fprintf (stderr, "opus_limit2_checkwithin1() modified value within -2..2 (ref=%d, i=%d)\n", use_ref_impl, i); - ret = 1; - } - } -#undef BUFFER_SIZE -#undef BYTE_COUNT +void testoac_limit2_checkwithin1(int use_ref_impl) { +# define BUFFER_SIZE 37 /* strange float count to trigger residue loop of SIMD implementation */ +# define BYTE_COUNT (BUFFER_SIZE*sizeof(float)) + int i, within1; + const int arch = oac_select_arch(); + + float pattern[BUFFER_SIZE], buffer[BUFFER_SIZE]; + + for (i = 0; i < BUFFER_SIZE; ++i) { + pattern[i] = i%2 ? -1.f : 1.f; + } + + /* All values within -1..1: + Nothing changed. Return value is implementation-dependent (not expected to recognise nothing exceeds -1..1) */ + memcpy(buffer, pattern, BYTE_COUNT); + within1 = use_ref_impl ? oac_limit2_checkwithin1_c(buffer, BUFFER_SIZE) : oac_limit2_checkwithin1(buffer, + BUFFER_SIZE, arch); + if (memcmp(buffer, pattern, BYTE_COUNT) != 0) { + fprintf (stderr, "oac_limit2_checkwithin1() modified values not exceeding -1..1 (ref=%d)\n", use_ref_impl); + ret = 1; + } + + /* One value exceeds -1..1, within -2..2: + Values unchanged. Return value says not all values are within -1..1 */ + for (i = 0; i < BUFFER_SIZE; ++i) { + const float replace_value = pattern[i]*1.001f; + + memcpy(buffer, pattern, BYTE_COUNT); + buffer[i] = replace_value; + within1 = use_ref_impl ? oac_limit2_checkwithin1_c(buffer, BUFFER_SIZE) : oac_limit2_checkwithin1(buffer, + BUFFER_SIZE, arch); + if (within1 || buffer[i] != replace_value) { + fprintf (stderr, "oac_limit2_checkwithin1() handled value exceeding -1..1 erroneously (ref=%d, i=%d)\n", + use_ref_impl, i); + ret = 1; + } + buffer[i] = pattern[i]; + if (memcmp(buffer, pattern, BYTE_COUNT) != 0) { + fprintf (stderr, "oac_limit2_checkwithin1() modified value within -2..2 (ref=%d, i=%d)\n", use_ref_impl, + i); + ret = 1; + } + } + + /* One value exceeds -2..2: + One value is hardclipped, others are unchanged. Return value says not all values are within -1..1 */ + for (i = 0; i < BUFFER_SIZE; ++i) { + const float replace_value = pattern[i]*2.1; + + memcpy(buffer, pattern, BYTE_COUNT); + buffer[i] = replace_value; + within1 = use_ref_impl ? oac_limit2_checkwithin1_c(buffer, BUFFER_SIZE) : oac_limit2_checkwithin1(buffer, + BUFFER_SIZE, arch); + if (within1 || buffer[i] != (replace_value > 0.f ? 2.f : -2.f)) { + fprintf (stderr, "oac_limit2_checkwithin1() handled value exceeding -2..2 erroneously (ref=%d, i=%d)\n", + use_ref_impl, i); + ret = 1; + } + buffer[i] = pattern[i]; + if (memcmp(buffer, pattern, BYTE_COUNT) != 0) { + fprintf (stderr, "oac_limit2_checkwithin1() modified value within -2..2 (ref=%d, i=%d)\n", use_ref_impl, + i); + ret = 1; + } + } +# undef BUFFER_SIZE +# undef BYTE_COUNT } #endif -int main(void) -{ - int i; - int use_ref_impl[2] = { 0, 1 }; - - testbitexactcos(); - testbitexactlog2tan(); - testdiv(); - testsqrt(); - testlog2(); - testexp2(); - testexp2log2(); - test_cos(); +int main(void) { + int i; + int use_ref_impl[2] = { 0, 1 }; + + testbitexactcos(); + testbitexactlog2tan(); + testdiv(); + testsqrt(); + testlog2(); + testexp2(); + testexp2log2(); + test_cos(); #ifdef FIXED_POINT - testilog2(); - testlog2_db(); - testexp2_db(); - testrsqrt(); - testsqrt32(); - testatan(); - test_rcp_norm32(); + testilog2(); + testlog2_db(); + testexp2_db(); + testrsqrt(); + testsqrt32(); + testatan(); + test_rcp_norm32(); #else - test_atan2(); + test_atan2(); #endif #ifndef DISABLE_FLOAT_API - for (i = 0; i <= 1; ++i) - { - testcelt_float2int16(use_ref_impl[i], 1); - testcelt_float2int16(use_ref_impl[i], 32); - testcelt_float2int16(use_ref_impl[i], 127); - testcelt_float2int16(use_ref_impl[i], 1031); - testopus_limit2_checkwithin1(use_ref_impl[i]); - } + for (i = 0; i <= 1; ++i) { + testcelt_float2int16(use_ref_impl[i], 1); + testcelt_float2int16(use_ref_impl[i], 32); + testcelt_float2int16(use_ref_impl[i], 127); + testcelt_float2int16(use_ref_impl[i], 1031); + testoac_limit2_checkwithin1(use_ref_impl[i]); + } #else - (void)i; - (void)use_ref_impl; + (void)i; + (void)use_ref_impl; #endif - return ret; + return ret; } diff --git a/celt/tests/test_unit_mdct.c b/celt/tests/test_unit_mdct.c index 00b3840de..b7877a50c 100644 --- a/celt/tests/test_unit_mdct.c +++ b/celt/tests/test_unit_mdct.c @@ -23,10 +23,10 @@ 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" +# include "config.h" #endif #include @@ -38,26 +38,25 @@ #include "modes.h" #ifndef M_PI -#define M_PI 3.141592653 +# define M_PI 3.141592653 #endif int ret = 0; -void check(kiss_fft_scalar * in,kiss_fft_scalar * out,int nfft,int isinverse) -{ - int bin,k; - double errpow=0,sigpow=0; +void check(kiss_fft_scalar * in, kiss_fft_scalar * out, int nfft, int isinverse) { + int bin, k; + double errpow = 0, sigpow = 0; double snr; - for (bin=0;bin1) { + if (argc > 1) { int k; - for (k=1;k @@ -34,94 +34,90 @@ #include "mini_kfft.c" #ifndef M_PI -#define M_PI 3.141592653 +# define M_PI 3.141592653 #endif int ret = 0; -void check(mini_kiss_fft_cpx * in,mini_kiss_fft_cpx * out,int nfft,int isinverse) -{ - int bin,k; - double errpow=0,sigpow=0, snr; +void check(mini_kiss_fft_cpx * in, mini_kiss_fft_cpx * out, int nfft, int isinverse) { + int bin, k; + double errpow = 0, sigpow = 0, snr; - for (bin=0;bin1) { +int main(int argc, char ** argv) { + if (argc > 1) { int k; - for (k=1;k @@ -43,45 +43,40 @@ #define MAX_SIZE 100 -int ret=0; -void test_rotation(int N, int K) -{ - int i; - double err = 0, ener = 0, snr, snr0; - celt_norm x0[MAX_SIZE]; - celt_norm x1[MAX_SIZE]; - for (i=0;i 20) - { - fprintf(stderr, "FAIL!\n"); - ret = 1; - } +int ret = 0; +void test_rotation(int N, int K) { + int i; + double err = 0, ener = 0, snr, snr0; + celt_norm x0[MAX_SIZE]; + celt_norm x1[MAX_SIZE]; + for (i = 0; i < N; i++) + x1[i] = x0[i] = rand()%16777215 - 8388608; + oaci_exp_rotation(x1, N, 1, 1, K, SPREAD_NORMAL); + for (i = 0; i < N; i++) { + err += (x0[i] - (double)x1[i])*(x0[i] - (double)x1[i]); + ener += x0[i]*(double)x0[i]; + } + snr0 = 20*log10(ener/err); + err = ener = 0; + oaci_exp_rotation(x1, N, -1, 1, K, SPREAD_NORMAL); + for (i = 0; i < N; i++) { + err += (x0[i] - (double)x1[i])*(x0[i] - (double)x1[i]); + ener += x0[i]*(double)x0[i]; + } + snr = 20*log10(ener/err); + printf ("SNR for size %d (%d pulses) is %f (was %f without inverse)\n", N, K, snr, snr0); + if (snr < 60 || snr0 > 20) { + fprintf(stderr, "FAIL!\n"); + ret = 1; + } } -int main(void) -{ - ALLOC_STACK; - test_rotation(15, 3); - test_rotation(23, 5); - test_rotation(50, 3); - test_rotation(80, 1); - RESTORE_STACK; - return ret; +int main(void) { + ALLOC_STACK; + test_rotation(15, 3); + test_rotation(23, 5); + test_rotation(50, 3); + test_rotation(80, 1); + RESTORE_STACK; + return ret; } diff --git a/celt/tests/test_unit_types.c b/celt/tests/test_unit_types.c index 67a0fb8ed..ba28fa25d 100644 --- a/celt/tests/test_unit_types.c +++ b/celt/tests/test_unit_types.c @@ -23,28 +23,25 @@ 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" +# include "config.h" #endif -#include "opus_types.h" +#include "oac_types.h" #include -int main(void) -{ - opus_int16 i = 1; - i <<= 14; - if (i>>14 != 1) - { - fprintf(stderr, "opus_int16 isn't 16 bits\n"); - return 1; - } - if (sizeof(opus_int16)*2 != sizeof(opus_int32)) - { - fprintf(stderr, "16*2 != 32\n"); - return 1; - } - return 0; +int main(void) { + oac_int16 i = 1; + i <<= 14; + if (i>>14 != 1) { + fprintf(stderr, "oac_int16 isn't 16 bits\n"); + return 1; + } + if (sizeof(oac_int16)*2 != sizeof(oac_int32)) { + fprintf(stderr, "16*2 != 32\n"); + return 1; + } + return 0; } diff --git a/celt/vq.c b/celt/vq.c index fbe652fe8..c3d16dde0 100644 --- a/celt/vq.c +++ b/celt/vq.c @@ -24,10 +24,10 @@ 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" +# include "config.h" #endif #include "mathops.h" @@ -38,830 +38,542 @@ #include "bands.h" #include "rate.h" #include "pitch.h" -#include "SigProc_FIX.h" #if defined(FIXED_POINT) -void norm_scaleup(celt_norm *X, int N, int shift) { - int i; - celt_assert(shift >= 0); - if (shift <= 0) return; - for (i=0;i= 0); + if (shift <= 0) return; + for (i = 0; i < N; i++) X[i] = SHL32(X[i], shift); } -void norm_scaledown(celt_norm *X, int N, int shift) { - int i; - celt_assert(shift >= 0); - if (shift <= 0) return; - for (i=0;i= 0); + if (shift <= 0) return; + for (i = 0; i < N; i++) X[i] = PSHR32(X[i], shift); } -opus_val32 celt_inner_prod_norm(const celt_norm *x, const celt_norm *y, int len, int arch) { - int i; - opus_val32 sum = 0; - (void)arch; - for (i=0;i>2*(NORM_SHIFT-14); +oac_val32 oaci_celt_inner_prod_norm_shift(const celt_norm *x, const celt_norm *y, int len, int arch) { + int i; + oac_val64 sum = 0; + (void)arch; + for (i = 0; i < len; i++) sum += x[i]*(oac_val64)y[i]; + return sum>>2*(NORM_SHIFT - 14); } #endif #ifndef OVERRIDE_vq_exp_rotation1 -static void exp_rotation1(celt_norm *X, int len, int stride, opus_val16 c, opus_val16 s) -{ - int i; - opus_val16 ms; - celt_norm *Xptr; - Xptr = X; - ms = NEG16(s); - norm_scaledown(X, len, NORM_SHIFT-14); - for (i=0;i=0;i--) - { - celt_norm x1, x2; - x1 = Xptr[0]; - x2 = Xptr[stride]; - Xptr[stride] = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x2), s, x1), 15)); - *Xptr-- = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x1), ms, x2), 15)); - } - norm_scaleup(X, len, NORM_SHIFT-14); +static void oaci_exp_rotation1(celt_norm *X, int len, int stride, oac_val16 c, oac_val16 s) { + int i; + oac_val16 ms; + celt_norm *Xptr; + Xptr = X; + ms = NEG16(s); + oaci_norm_scaledown(X, len, NORM_SHIFT - 14); + for (i = 0; i < len - stride; i++) { + celt_norm x1, x2; + x1 = Xptr[0]; + x2 = Xptr[stride]; + Xptr[stride] = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x2), s, x1), 15)); + *Xptr++ = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x1), ms, x2), 15)); + } + Xptr = &X[len - 2*stride - 1]; + for (i = len - 2*stride - 1; i >= 0; i--) { + celt_norm x1, x2; + x1 = Xptr[0]; + x2 = Xptr[stride]; + Xptr[stride] = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x2), s, x1), 15)); + *Xptr-- = EXTRACT16(PSHR32(MAC16_16(MULT16_16(c, x1), ms, x2), 15)); + } + oaci_norm_scaleup(X, len, NORM_SHIFT - 14); } #endif /* OVERRIDE_vq_exp_rotation1 */ -void exp_rotation(celt_norm *X, int len, int dir, int stride, int K, int spread) -{ - static const int SPREAD_FACTOR[3]={15,10,5}; - int i; - opus_val16 c, s; - opus_val16 gain, theta; - int stride2=0; - int factor; - - if (2*K>=len || spread==SPREAD_NONE) - return; - factor = SPREAD_FACTOR[spread-1]; - - gain = celt_div((opus_val32)MULT16_16(Q15_ONE,len),(opus_val32)(len+factor*K)); - theta = HALF16(MULT16_16_Q15(gain,gain)); - - c = celt_cos_norm(EXTEND32(theta)); - s = celt_cos_norm(EXTEND32(SUB16(Q15ONE,theta))); /* sin(theta) */ - - if (len>=8*stride) - { - stride2 = 1; - /* This is just a simple (equivalent) way of computing sqrt(len/stride) with rounding. - It's basically incrementing long as (stride2+0.5)^2 < len/stride. */ - while ((stride2*stride2+stride2)*stride + (stride>>2) < len) - stride2++; - } - /*NOTE: As a minor optimization, we could be passing around log2(B), not B, for both this and for - extract_collapse_mask().*/ - len = celt_udiv(len, stride); - for (i=0;i= len || spread == SPREAD_NONE) + return; + factor = SPREAD_FACTOR[spread - 1]; + + gain = oaci_celt_div((oac_val32)MULT16_16(Q15_ONE, len), (oac_val32)(len + factor*K)); + theta = HALF16(MULT16_16_Q15(gain, gain)); + + c = oaci_celt_cos_norm(EXTEND32(theta)); + s = oaci_celt_cos_norm(EXTEND32(SUB16(Q15ONE, theta))); /* sin(theta) */ + + if (len >= 8*stride) { + stride2 = 1; + /* This is just a simple (equivalent) way of computing sqrt(len/stride) with rounding. + It's basically incrementing long as (stride2+0.5)^2 < len/stride. */ + while ((stride2*stride2 + stride2)*stride + (stride>>2) < len) + stride2++; + } + /*NOTE: As a minor optimization, we could be passing around log2(B), not B, for both this and for + oaci_extract_collapse_mask().*/ + len = oaci_celt_udiv(len, stride); + for (i = 0; i < stride; i++) { + if (dir < 0) { + if (stride2) + oaci_exp_rotation1(X + i*len, len, stride2, s, c); + oaci_exp_rotation1(X + i*len, len, 1, c, s); + } else { + oaci_exp_rotation1(X + i*len, len, 1, c, -s); + if (stride2) + oaci_exp_rotation1(X + i*len, len, stride2, s, -c); + } + } } /** Normalizes the decoded integer pvq codeword to unit norm. */ -static void normalise_residual(int * OPUS_RESTRICT iy, celt_norm * OPUS_RESTRICT X, - int N, opus_val32 Ryy, opus_val32 gain, int shift) -{ - int i; +static void oaci_normalise_residual(int * OAC_RESTRICT iy, celt_norm * OAC_RESTRICT X, + int N, oac_val32 Ryy, oac_val32 gain, int shift) { + int i; #ifdef FIXED_POINT - int k; + int k; #endif - opus_val32 t; - opus_val32 g; + oac_val32 t; + oac_val32 g; #ifdef FIXED_POINT - k = celt_ilog2(Ryy)>>1; + k = oaci_celt_ilog2(Ryy)>>1; #endif - t = VSHR32(Ryy, 2*(k-7)-15); - g = MULT32_32_Q31(celt_rsqrt_norm32(t),gain); - i=0; - (void)shift; -#if defined(FIXED_POINT) && defined(ENABLE_QEXT) - if (shift>0) { - int tot_shift = NORM_SHIFT+1-k-shift; - if (tot_shift >= 0) { - do X[i] = MULT32_32_Q31(g, SHL32(iy[i], tot_shift)); - while (++i < N); - } else { - do X[i] = MULT32_32_Q31(g, PSHR32(iy[i], -tot_shift)); - while (++i < N); - } - } else -#endif - do X[i] = VSHR32(MULT16_32_Q15(iy[i], g), k+15-NORM_SHIFT); - while (++i < N); + t = VSHR32(Ryy, 2*(k - 7) - 15); + g = MULT32_32_Q31(oaci_celt_rsqrt_norm32(t), gain); + i = 0; + (void)shift; +#if defined(FIXED_POINT) + if (shift > 0) { + int tot_shift = NORM_SHIFT + 1 - k - shift; + if (tot_shift >= 0) { + do X[i] = MULT32_32_Q31(g, SHL32(iy[i], tot_shift)); + while (++i < N); + } else { + do X[i] = MULT32_32_Q31(g, PSHR32(iy[i], -tot_shift)); + while (++i < N); + } + } else +#endif + do X[i] = VSHR32(MULT16_32_Q15(iy[i], g), k + 15 - NORM_SHIFT); + while (++i < N); } -static unsigned extract_collapse_mask(int *iy, int N, int B) -{ - unsigned collapse_mask; - int N0; - int i; - if (B<=1) - return 1; - /*NOTE: As a minor optimization, we could be passing around log2(B), not B, for both this and for - exp_rotation().*/ - N0 = celt_udiv(N, B); - collapse_mask = 0; - i=0; do { - int j; - unsigned tmp=0; - j=0; do { - tmp |= iy[i*N0+j]; - } while (++j (N>>1)) - { - opus_val16 rcp; - j=0; do { - sum += X[j]; - } while (++j (N>>1)) { + oac_val16 rcp; + j = 0; do { + sum += X[j]; + } while (++j < N); + + /* If X is too small, just replace it with a pulse at 0 */ #ifdef FIXED_POINT - if (sum <= K) + if (sum <= K) #else - /* Prevents infinities and NaNs from causing too many pulses - to be allocated. 64 is an approximation of infinity here. */ - if (!(sum > EPSILON && sum < 64)) -#endif - { - X[0] = QCONST16(1.f,14); - j=1; do - X[j]=0; - while (++j EPSILON && sum < 64)) +#endif + { + X[0] = QCONST16(1.f, 14); + j = 1; do + X[j] = 0; + while (++j < N); + sum = QCONST16(1.f, 14); + } #ifdef FIXED_POINT - rcp = EXTRACT16(MULT16_32_Q16(K, celt_rcp(sum))); + rcp = EXTRACT16(MULT16_32_Q16(K, oaci_celt_rcp(sum))); #else - /* Using K+e with e < 1 guarantees we cannot get more than K pulses. */ - rcp = EXTRACT16(MULT16_32_Q16(K+0.8f, celt_rcp(sum))); + /* Using K+e with e < 1 guarantees we cannot get more than K pulses. */ + rcp = EXTRACT16(MULT16_32_Q16(K + 0.8f, oaci_celt_rcp(sum))); #endif - j=0; do { + j = 0; do { #ifdef FIXED_POINT - /* It's really important to round *towards zero* here */ - iy[j] = MULT16_16_Q15(X[j],rcp); + /* It's really important to round *towards zero* here */ + iy[j] = MULT16_16_Q15(X[j], rcp); #else - iy[j] = (int)floor(rcp*X[j]); -#endif - y[j] = (celt_norm)iy[j]; - yy = MAC16_16(yy, y[j],y[j]); - xy = MAC16_16(xy, X[j],y[j]); - y[j] *= 2; - pulsesLeft -= iy[j]; - } while (++j=0); - - /* This should never happen, but just in case it does (e.g. on silence) - we fill the first bin with pulses. */ + iy[j] = (int)floor(rcp*X[j]); +#endif + y[j] = (celt_norm)iy[j]; + yy = MAC16_16(yy, y[j], y[j]); + xy = MAC16_16(xy, X[j], y[j]); + y[j] *= 2; + pulsesLeft -= iy[j]; + } while (++j < N); + } + celt_sig_assert(pulsesLeft >= 0); + + /* This should never happen, but just in case it does (e.g. on silence) + we fill the first bin with pulses. */ #ifdef FIXED_POINT_DEBUG - celt_sig_assert(pulsesLeft<=N+3); -#endif - if (pulsesLeft > N+3) - { - opus_val16 tmp = (opus_val16)pulsesLeft; - yy = MAC16_16(yy, tmp, tmp); - yy = MAC16_16(yy, tmp, y[0]); - iy[0] += pulsesLeft; - pulsesLeft=0; - } - - for (i=0;i N + 3) { + oac_val16 tmp = (oac_val16)pulsesLeft; + yy = MAC16_16(yy, tmp, tmp); + yy = MAC16_16(yy, tmp, y[0]); + iy[0] += pulsesLeft; + pulsesLeft = 0; + } + + for (i = 0; i < pulsesLeft; i++) { + oac_val16 Rxy, Ryy; + int best_id; + oac_val32 best_num; + oac_val16 best_den; #ifdef FIXED_POINT - int rshift; + int rshift; #endif #ifdef FIXED_POINT - rshift = 1+celt_ilog2(K-pulsesLeft+i+1); -#endif - best_id = 0; - /* The squared magnitude term gets added anyway, so we might as well - add it outside the loop */ - yy = ADD16(yy, 1); - - /* Calculations for position 0 are out of the loop, in part to reduce - mispredicted branches (since the if condition is usually false) - in the loop. */ - /* Temporary sums of the new pulse(s) */ - Rxy = EXTRACT16(SHR32(ADD32(xy, EXTEND32(X[0])),rshift)); - /* We're multiplying y[j] by two so we don't have to do it here */ - Ryy = ADD16(yy, y[0]); - - /* Approximate score: we maximise Rxy/sqrt(Ryy) (we're guaranteed that - Rxy is positive because the sign is pre-computed) */ - Rxy = MULT16_16_Q15(Rxy,Rxy); - best_den = Ryy; - best_num = Rxy; - j=1; - do { - /* Temporary sums of the new pulse(s) */ - Rxy = EXTRACT16(SHR32(ADD32(xy, EXTEND32(X[j])),rshift)); - /* We're multiplying y[j] by two so we don't have to do it here */ - Ryy = ADD16(yy, y[j]); - - /* Approximate score: we maximise Rxy/sqrt(Ryy) (we're guaranteed that - Rxy is positive because the sign is pre-computed) */ - Rxy = MULT16_16_Q15(Rxy,Rxy); - /* The idea is to check for num/den >= best_num/best_den, but that way - we can do it without any division */ - /* OPT: It's not clear whether a cmov is faster than a branch here - since the condition is more often false than true and using - a cmov introduces data dependencies across iterations. The optimal - choice may be architecture-dependent. */ - if (opus_unlikely(MULT16_16(best_den, Rxy) > MULT16_16(Ryy, best_num))) - { - best_den = Ryy; - best_num = Rxy; - best_id = j; - } - } while (++j= best_num/best_den, but that way + we can do it without any division */ + /* OPT: It's not clear whether a cmov is faster than a branch here + since the condition is more often false than true and using + a cmov introduces data dependencies across iterations. The optimal + choice may be architecture-dependent. */ + if (oac_unlikely(MULT16_16(best_den, Rxy) > MULT16_16(Ryy, best_num))) { + best_den = Ryy; + best_num = Rxy; + best_id = j; + } + } while (++j < N); + + /* Updating the sums of the new pulse(s) */ + xy = ADD32(xy, EXTEND32(X[best_id])); + /* We're multiplying y[j] by two so we don't have to do it here */ + yy = ADD16(yy, y[best_id]); + + /* Only now that we've made the final choice, update y/iy */ + /* Multiplying y[j] by 2 so we don't have to do it everywhere else */ + y[best_id] += 2; + iy[best_id]++; + } + + /* Put the original sign back */ + j = 0; + do { + /*iy[j] = signx[j] ? -iy[j] : iy[j];*/ + /* OPT: The is more likely to be compiled without a branch than the code above + but has the same performance otherwise. */ + iy[j] = (iy[j]^-signx[j]) + signx[j]; + } while (++j < N); + RESTORE_STACK; + return yy; } -#ifdef ENABLE_QEXT -#include "macros.h" - -static opus_val32 op_pvq_search_N2(const celt_norm *X, int *iy, int *up_iy, int K, int up, int *refine, int shift) { - opus_val32 sum; - opus_val32 rcp_sum; - int offset; - sum = ABS32(X[0]) + ABS32(X[1]); - if (sum < EPSILON) { - iy[0] = K; - up_iy[0] = up*K; - iy[1]=up_iy[1]=0; - *refine=0; -#ifdef FIXED_POINT - return (opus_val64)K*K*up*up>>2*shift; -#else - (void)shift; - return K*(float)K*up*up; -#endif - } -#ifdef FIXED_POINT - int sum_shift; - opus_val32 X0; - sum_shift = 30-celt_ilog2(sum); - rcp_sum = celt_rcp_norm32(SHL32(sum, sum_shift)); - X0 = MULT32_32_Q31(SHL32(X[0], sum_shift), rcp_sum); - iy[0] = PSHR32(MULT32_32_Q31(SHL32(K, 8), X0), 7); - up_iy[0] = PSHR32(MULT32_32_Q31(SHL32(up*K, 8), X0), 7); -#else - rcp_sum = 1.f/sum; - iy[0] = (int)floor(.5f+K*X[0]*rcp_sum); - up_iy[0] = (int)floor(.5f+up*K*X[0]*rcp_sum); -#endif - up_iy[0] = IMAX(up*iy[0] - (up-1)/2, IMIN(up*iy[0] + (up-1)/2, up_iy[0])); - offset = up_iy[0] - up*iy[0]; - iy[1] = K-abs(iy[0]); - up_iy[1] = up*K-abs(up_iy[0]); - if (X[1] < 0) { - iy[1] = -iy[1]; - up_iy[1] = -up_iy[1]; - offset = -offset; - } - *refine = offset; -#ifdef FIXED_POINT - return (up_iy[0]*(opus_val64)up_iy[0] + up_iy[1]*(opus_val64)up_iy[1] + (1<<2*shift>>1))>>2*shift; -#else - return up_iy[0]*(opus_val64)up_iy[0] + up_iy[1]*(opus_val64)up_iy[1]; -#endif -} +RESTORE_STACK; +RESTORE_STACK; +RESTORE_STACK; +unsigned oaci_alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc, + oac_val32 gain, int resynth, int arch) { + VARDECL(int, iy); + oac_val32 yy; + unsigned collapse_mask; + SAVE_STACK; -static int op_pvq_refine(const opus_val32 *Xn, int *iy, int *iy0, int K, int up, int margin, int N) { - int i; - int dir; - VARDECL(opus_val32, rounding); - int iysum = 0; - SAVE_STACK; - ALLOC(rounding, N, opus_val32); - for (i=0;i> 7; -#else - iy[i] = (int)floor(.5+tmp); -#endif - rounding[i] = tmp - SHL32(iy[i], 7); - } - if (iy != iy0) { - for (i=0;i 32) { - RESTORE_STACK; - return 1; - } - dir = iysum < K ? 1 : -1; - while (iysum != K) { - opus_val32 roundval=-1000000*dir; - int roundpos=0; - for (i=0;i 0 && abs(iy[i]-up*iy0[i]) < (margin-1) && !(dir==-1 && iy[i] == 0)) { - roundval = rounding[i]; - roundpos = i; - } - } - iy[roundpos] += dir; - rounding[roundpos] -= SHL32(dir, 15); - iysum+=dir; - } - RESTORE_STACK; - return 0; -} + celt_assert2(K > 0, "oaci_alg_quant() needs at least one pulse"); + celt_assert2(N > 1, "oaci_alg_quant() needs at least two dimensions"); -static opus_val32 op_pvq_search_extra(const celt_norm *X, int *iy, int *up_iy, int K, int up, int *refine, int N, int shift) { - opus_val32 rcp_sum; - opus_val32 sum=0; - int i; - int failed=0; - opus_val64 yy=0; - VARDECL(opus_val32, Xn); - SAVE_STACK; - for (i=0;i>1))>>2*shift; -#else - (void)shift; - return yy; -#endif -} -#endif + /* Covers vectorization by up to 4. */ + ALLOC(iy, N + 3, int); -#ifdef ENABLE_QEXT -/* Take advantage of the fact that "large" refine values are much less likely - than smaller ones. */ -static void ec_enc_refine(ec_enc *enc, opus_int32 refine, opus_int32 up, int extra_bits, int use_entropy) { - int large; - large = abs(refine)>up/2; - ec_enc_bit_logp(enc, large, use_entropy ? 3 : 1); - if (large) { - ec_enc_bits(enc, refine < 0, 1); - ec_enc_bits(enc, abs(refine)-up/2-1, extra_bits-1); - } else { - ec_enc_bits(enc, refine+up/2, extra_bits); - } -} + oaci_exp_rotation(X, N, 1, B, K, spread); -static int ec_dec_refine(ec_enc *dec, opus_int32 up, int extra_bits, int use_entropy) { - int large, refine; - large = ec_dec_bit_logp(dec, use_entropy ? 3 : 1); - if (large) { - int sign = ec_dec_bits(dec, 1); - refine = ec_dec_bits(dec, extra_bits-1) + up/2+1; - if (sign) refine = -refine; - } else { - refine = (opus_int32)ec_dec_bits(dec, extra_bits)-up/2; - } - return refine; -} -#endif + yy = oaci_op_pvq_search(X, iy, K, N, arch); + collapse_mask = oaci_extract_collapse_mask(iy, N, B); + oaci_encode_pulses(iy, N, K, enc); + if (resynth) oaci_normalise_residual(iy, X, N, yy, gain, 0); -unsigned alg_quant(celt_norm *X, int N, int K, int spread, int B, ec_enc *enc, - opus_val32 gain, int resynth - ARG_QEXT(ec_enc *ext_enc) ARG_QEXT(int extra_bits), int arch) -{ - VARDECL(int, iy); - opus_val32 yy; - unsigned collapse_mask; -#ifdef ENABLE_QEXT - int yy_shift = 0; -#endif - SAVE_STACK; - - celt_assert2(K>0, "alg_quant() needs at least one pulse"); - celt_assert2(N>1, "alg_quant() needs at least two dimensions"); - - /* Covers vectorization by up to 4. */ - ALLOC(iy, N+3, int); - - exp_rotation(X, N, 1, B, K, spread); - -#ifdef ENABLE_QEXT - if (N==2 && extra_bits >= 2) { - int refine; - int up_iy[2]; - int up; - yy_shift = IMAX(0, extra_bits-7); - up = (1<= 2) { - int i; - VARDECL(int, up_iy); - VARDECL(int, refine); - int up, use_entropy; - ALLOC(up_iy, N, int); - ALLOC(refine, N, int); - yy_shift = IMAX(0, extra_bits-7); - up = (1<storage*8 - ec_tell(ext_enc)) > (unsigned)(N-1)*(extra_bits+3)+1; - for (i=0;i0, "alg_unquant() needs at least one pulse"); - celt_assert2(N>1, "alg_unquant() needs at least two dimensions"); - ALLOC(iy, N, int); - Ryy = decode_pulses(iy, N, K, dec); -#ifdef ENABLE_QEXT - if (N==2 && extra_bits >= 2) { - int up; - int refine; - yy_shift = IMAX(0, extra_bits-7); - up = (1< 0) ? -refine : refine; - iy[0] += (refine*(opus_int64)iy[0] > 0) ? -refine : refine; - } else if (iy[1] > 0) { - iy[0] += refine; - iy[1] -= refine*(iy[0]>0?1:-1); - } else { - iy[0] -= refine; - iy[1] -= refine*(iy[0]>0?1:-1); - } -#ifdef FIXED_POINT - Ryy = (iy[0]*(opus_val64)iy[0] + iy[1]*(opus_val64)iy[1] + (1<<2*yy_shift>>1)) >> 2*yy_shift; -#else - Ryy = iy[0]*(opus_val64)iy[0] + iy[1]*(opus_val64)iy[1]; -#endif - } else if (extra_bits >= 2) { - int i; - opus_val64 yy64; - VARDECL(int, refine); - int up, use_entropy; - int sign=0; - ALLOC(refine, N, int); - yy_shift = IMAX(0, extra_bits-7); - up = (1<storage*8 - ec_tell(ext_dec)) > (unsigned)(N-1)*(extra_bits+3)+1; - for (i=0;i>1)) >> 2*yy_shift; -#else - Ryy = yy64; -#endif - } -#endif - normalise_residual(iy, X, N, Ryy, gain, yy_shift); - exp_rotation(X, N, -1, B, K, spread); - collapse_mask = extract_collapse_mask(iy, N, B); - RESTORE_STACK; - return collapse_mask; +unsigned oaci_alg_unquant(celt_norm *X, int N, int K, int spread, int B, + ec_dec *dec, oac_val32 gain) { + oac_val32 Ryy; + unsigned collapse_mask; + VARDECL(int, iy); + int yy_shift = 0; + SAVE_STACK; + + celt_assert2(K > 0, "oaci_alg_unquant() needs at least one pulse"); + celt_assert2(N > 1, "oaci_alg_unquant() needs at least two dimensions"); + ALLOC(iy, N, int); + Ryy = oaci_decode_pulses(iy, N, K, dec); + oaci_normalise_residual(iy, X, N, Ryy, gain, yy_shift); + oaci_exp_rotation(X, N, -1, B, K, spread); + collapse_mask = oaci_extract_collapse_mask(iy, N, B); + RESTORE_STACK; + return collapse_mask; } -#ifndef OVERRIDE_renormalise_vector -void renormalise_vector(celt_norm *X, int N, opus_val32 gain, int arch) -{ - int i; -#ifdef FIXED_POINT - int k; -#endif - opus_val32 E; - opus_val16 g; - opus_val32 t; - celt_norm *xptr; - norm_scaledown(X, N, NORM_SHIFT-14); - E = EPSILON + celt_inner_prod_norm(X, X, N, arch); -#ifdef FIXED_POINT - k = celt_ilog2(E)>>1; -#endif - t = VSHR32(E, 2*(k-7)); - g = MULT32_32_Q31(celt_rsqrt_norm(t),gain); - - xptr = X; - for (i=0;i>1; +# endif + t = VSHR32(E, 2*(k - 7)); + g = MULT32_32_Q31(oaci_celt_rsqrt_norm(t), gain); + + xptr = X; + for (i = 0; i < N; i++) { + *xptr = EXTRACT16(PSHR32(MULT16_16(g, *xptr), k + 15 - 14)); + xptr++; + } + oaci_norm_scaleup(X, N, NORM_SHIFT - 14); + /*return oaci_celt_sqrt(E);*/ } -#endif /* OVERRIDE_renormalise_vector */ - -opus_int32 stereo_itheta(const celt_norm *X, const celt_norm *Y, int stereo, int N, int arch) -{ - int i; - int itheta; - opus_val32 mid, side; - opus_val32 Emid, Eside; - - Emid = Eside = 0; - if (stereo) - { - for (i=0;i>1; - mag = celt_rsqrt_norm32(SHL32(sum, 2*sum_shift+1)); - for (i=0;i>1; + mag = oaci_celt_rsqrt_norm32(SHL32(sum, 2*sum_shift + 1)); + for (i = 0; i < N; i++) { + X[i] = VSHR32(MULT16_32_Q15(X[i], MULT32_32_Q31(mag, gain)), shift - sum_shift + 29 - NORM_SHIFT); + } #else - mag = 1.f/sqrt(sum); - for (i=0;i faceval) { - faceval = ABS32(X[i]); - face = i; - } - } - sign = X[face]<0; - ec_enc_uint(enc, face, N); - ec_enc_bits(enc, sign, 1); +unsigned oaci_cubic_quant(celt_norm *X, int N, int res, int B, ec_enc *enc, oac_val32 gain, int resynth) { + int i; + int face = 0; + int K; + VARDECL(int, iy); + celt_norm faceval = -1; + oac_val32 norm; + int sign; + SAVE_STACK; + ALLOC(iy, N, int); + K = 1< faceval) { + faceval = ABS32(X[i]); + face = i; + } + } + sign = X[face] < 0; + oaci_ec_enc_uint(enc, face, N); + oaci_ec_enc_bits(enc, sign, 1); #ifdef FIXED_POINT - if (faceval != 0) { - int face_shift = 30-celt_ilog2(faceval); - norm = celt_rcp_norm32(SHL32(faceval, face_shift)); - norm = MULT16_32_Q15(K, norm); - for (i=0;i> 15); - } - } else { - OPUS_CLEAR(iy, N); - } + if (faceval != 0) { + int face_shift = 30 - oaci_celt_ilog2(faceval); + norm = oaci_celt_rcp_norm32(SHL32(faceval, face_shift)); + norm = MULT16_32_Q15(K, norm); + for (i = 0; i < N; i++) { + /* By computing X[i]+faceval inside the shift, the result is guaranteed non-negative. */ + iy[i] = IMIN(K - 1, (MULT32_32_Q31(SHL32(X[i] + faceval, face_shift - 1), norm))>>15); + } + } else { + OAC_CLEAR(iy, N); + } #else - norm = .5f*K/(faceval+EPSILON); - for (i=0;i @@ -40,57 +40,54 @@ #if defined(FIXED_POINT) -void celt_fir_sse4_1(const opus_val16 *x, - const opus_val16 *num, - opus_val16 *y, - int N, - int ord, - int arch) -{ - int i,j; - VARDECL(opus_val16, rnum); +void oaci_celt_fir_sse4_1(const oac_val16 *x, + const oac_val16 *num, + oac_val16 *y, + int N, + int ord, + int arch) { + int i, j; + VARDECL(oac_val16, rnum); __m128i vecNoA; - opus_int32 noA ; + oac_int32 noA; SAVE_STACK; - ALLOC(rnum, ord, opus_val16); - for(i=0;i> 1; - vecNoA = _mm_set_epi32(noA, noA, noA, noA); + ALLOC(rnum, ord, oac_val16); + for (i = 0; i < ord; i++) + rnum[i] = num[ord - i - 1]; + noA = EXTEND32(1)<>1; + vecNoA = _mm_set_epi32(noA, noA, noA, noA); - for (i=0;i0); - (void)arch; - for (i=0;i 0); + (void)arch; + for (i = 0; i < max_pitch - 7; i += 8) { + oaci_xcorr_kernel_avx(_x, _y + i, &xcorr[i], len); + } + for (; i < max_pitch; i++) { + xcorr[i] = oaci_celt_inner_prod(_x, _y + i, len, arch); + } } #endif diff --git a/celt/x86/pitch_sse.c b/celt/x86/pitch_sse.c index 20e73126b..103949956 100644 --- a/celt/x86/pitch_sse.c +++ b/celt/x86/pitch_sse.c @@ -23,10 +23,10 @@ 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" +# include "config.h" #endif #include "macros.h" @@ -35,150 +35,136 @@ #include "mathops.h" #include "pitch.h" -#if defined(OPUS_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT) - -#include -#include "arch.h" - -void xcorr_kernel_sse(const opus_val16 *x, const opus_val16 *y, opus_val32 sum[4], int len) -{ - int j; - __m128 xsum1, xsum2; - xsum1 = _mm_loadu_ps(sum); - xsum2 = _mm_setzero_ps(); - - for (j = 0; j < len-3; j += 4) - { - __m128 x0 = _mm_loadu_ps(x+j); - __m128 yj = _mm_loadu_ps(y+j); - __m128 y3 = _mm_loadu_ps(y+j+3); - - xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(_mm_shuffle_ps(x0,x0,0x00),yj)); - xsum2 = _mm_add_ps(xsum2,_mm_mul_ps(_mm_shuffle_ps(x0,x0,0x55), - _mm_shuffle_ps(yj,y3,0x49))); - xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(_mm_shuffle_ps(x0,x0,0xaa), - _mm_shuffle_ps(yj,y3,0x9e))); - xsum2 = _mm_add_ps(xsum2,_mm_mul_ps(_mm_shuffle_ps(x0,x0,0xff),y3)); - } - if (j < len) - { - xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(_mm_load1_ps(x+j),_mm_loadu_ps(y+j))); - if (++j < len) - { - xsum2 = _mm_add_ps(xsum2,_mm_mul_ps(_mm_load1_ps(x+j),_mm_loadu_ps(y+j))); - if (++j < len) - { - xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(_mm_load1_ps(x+j),_mm_loadu_ps(y+j))); - } - } - } - _mm_storeu_ps(sum,_mm_add_ps(xsum1,xsum2)); +#if defined(OAC_X86_MAY_HAVE_SSE) && !defined(FIXED_POINT) + +# include +# include "arch.h" + +void oaci_xcorr_kernel_sse(const oac_val16 *x, const oac_val16 *y, oac_val32 sum[4], int len) { + int j; + __m128 xsum1, xsum2; + xsum1 = _mm_loadu_ps(sum); + xsum2 = _mm_setzero_ps(); + + for (j = 0; j < len - 3; j += 4) { + __m128 x0 = _mm_loadu_ps(x + j); + __m128 yj = _mm_loadu_ps(y + j); + __m128 y3 = _mm_loadu_ps(y + j + 3); + + xsum1 = _mm_add_ps(xsum1, _mm_mul_ps(_mm_shuffle_ps(x0, x0, 0x00), yj)); + xsum2 = _mm_add_ps(xsum2, _mm_mul_ps(_mm_shuffle_ps(x0, x0, 0x55), + _mm_shuffle_ps(yj, y3, 0x49))); + xsum1 = _mm_add_ps(xsum1, _mm_mul_ps(_mm_shuffle_ps(x0, x0, 0xaa), + _mm_shuffle_ps(yj, y3, 0x9e))); + xsum2 = _mm_add_ps(xsum2, _mm_mul_ps(_mm_shuffle_ps(x0, x0, 0xff), y3)); + } + if (j < len) { + xsum1 = _mm_add_ps(xsum1, _mm_mul_ps(_mm_load1_ps(x + j), _mm_loadu_ps(y + j))); + if (++j < len) { + xsum2 = _mm_add_ps(xsum2, _mm_mul_ps(_mm_load1_ps(x + j), _mm_loadu_ps(y + j))); + if (++j < len) { + xsum1 = _mm_add_ps(xsum1, _mm_mul_ps(_mm_load1_ps(x + j), _mm_loadu_ps(y + j))); + } + } + } + _mm_storeu_ps(sum, _mm_add_ps(xsum1, xsum2)); } -void dual_inner_prod_sse(const opus_val16 *x, const opus_val16 *y01, const opus_val16 *y02, - int N, opus_val32 *xy1, opus_val32 *xy2) -{ - int i; - __m128 xsum1, xsum2; - xsum1 = _mm_setzero_ps(); - xsum2 = _mm_setzero_ps(); - for (i=0;i @@ -38,24 +38,22 @@ #include "mathops.h" #include "pitch.h" -#if defined(OPUS_X86_MAY_HAVE_SSE2) && defined(FIXED_POINT) -opus_val32 celt_inner_prod_sse2(const opus_val16 *x, const opus_val16 *y, - int N) -{ - opus_int i, dataSize16; - opus_int32 sum; +#if defined(OAC_X86_MAY_HAVE_SSE2) && defined(FIXED_POINT) +oac_val32 oaci_celt_inner_prod_sse2(const oac_val16 *x, const oac_val16 *y, + int N) { + oac_int i, dataSize16; + oac_int32 sum; __m128i inVec1_76543210, inVec1_FEDCBA98, acc1; __m128i inVec2_76543210, inVec2_FEDCBA98, acc2; sum = 0; - dataSize16 = N & ~15; + dataSize16 = N&~15; acc1 = _mm_setzero_si128(); acc2 = _mm_setzero_si128(); - for (i=0;i= 8) - { + if (N - i >= 8) { inVec1_76543210 = _mm_loadu_si128((__m128i *)(void*)(&x[i + 0])); inVec2_76543210 = _mm_loadu_si128((__m128i *)(void*)(&y[i + 0])); @@ -86,7 +83,7 @@ opus_val32 celt_inner_prod_sse2(const opus_val16 *x, const opus_val16 *y, acc1 = _mm_add_epi32(acc1, _mm_shufflelo_epi16( acc1, 0x0E)); sum += _mm_cvtsi128_si32(acc1); - for (;i @@ -38,26 +38,25 @@ #include "mathops.h" #include "pitch.h" -#if defined(OPUS_X86_MAY_HAVE_SSE4_1) && defined(FIXED_POINT) -#include -#include "x86cpu.h" +#if defined(OAC_X86_MAY_HAVE_SSE4_1) && defined(FIXED_POINT) +# include +# include "x86cpu.h" -opus_val32 celt_inner_prod_sse4_1(const opus_val16 *x, const opus_val16 *y, - int N) -{ - opus_int i, dataSize16; - opus_int32 sum; +oac_val32 oaci_celt_inner_prod_sse4_1(const oac_val16 *x, const oac_val16 *y, + int N) { + oac_int i, dataSize16; + oac_int32 sum; __m128i inVec1_76543210, inVec1_FEDCBA98, acc1; __m128i inVec2_76543210, inVec2_FEDCBA98, acc2; __m128i inVec1_3210, inVec2_3210; sum = 0; - dataSize16 = N & ~15; + dataSize16 = N&~15; acc1 = _mm_setzero_si128(); acc2 = _mm_setzero_si128(); - for (i=0;i= 8) - { + if (N - i >= 8) { inVec1_76543210 = _mm_loadu_si128((__m128i *)(void*)(&x[i + 0])); inVec2_76543210 = _mm_loadu_si128((__m128i *)(void*)(&y[i + 0])); @@ -84,8 +82,7 @@ opus_val32 celt_inner_prod_sse4_1(const opus_val16 *x, const opus_val16 *y, i += 8; } - if (N - i >= 4) - { + if (N - i >= 4) { inVec1_3210 = OP_CVTEPI16_EPI32_M64(&x[i + 0]); inVec2_3210 = OP_CVTEPI16_EPI32_M64(&y[i + 0]); @@ -100,16 +97,14 @@ opus_val32 celt_inner_prod_sse4_1(const opus_val16 *x, const opus_val16 *y, sum += _mm_cvtsi128_si32(acc1); - for (;i= 3); @@ -132,8 +127,7 @@ void xcorr_kernel_sse4_1(const opus_val16 * x, const opus_val16 * y, opus_val32 sum2 = _mm_setzero_si128(); sum3 = _mm_setzero_si128(); - for (j=0;j<(len-7);j+=8) - { + for (j = 0; j < (len - 7); j += 8) { vecX = _mm_loadu_si128((__m128i *)(void*)(&x[j + 0])); vecY0 = _mm_loadu_si128((__m128i *)(void*)(&y[j + 0])); vecY1 = _mm_loadu_si128((__m128i *)(void*)(&y[j + 1])); @@ -161,8 +155,7 @@ void xcorr_kernel_sse4_1(const opus_val16 * x, const opus_val16 * y, opus_val32 vecSum = _mm_unpacklo_epi64(_mm_unpacklo_epi32(sum0, sum1), _mm_unpacklo_epi32(sum2, sum3)); - for (;j<(len-3);j+=4) - { + for (; j < (len - 3); j += 4) { vecX = OP_CVTEPI16_EPI32_M64(&x[j + 0]); vecX0 = _mm_shuffle_epi32(vecX, 0x00); vecX1 = _mm_shuffle_epi32(vecX, 0x55); @@ -186,8 +179,7 @@ void xcorr_kernel_sse4_1(const opus_val16 * x, const opus_val16 * y, opus_val32 } vecX = OP_CVTEPI16_EPI32_M64(&x[len - 4]); - if (len - j == 3) - { + if (len - j == 3) { vecX0 = _mm_shuffle_epi32(vecX, 0x55); vecX1 = _mm_shuffle_epi32(vecX, 0xaa); vecX2 = _mm_shuffle_epi32(vecX, 0xff); @@ -203,9 +195,7 @@ void xcorr_kernel_sse4_1(const opus_val16 * x, const opus_val16 * y, opus_val32 vecSum = _mm_add_epi32(vecSum, sum0); vecSum = _mm_add_epi32(vecSum, sum1); vecSum = _mm_add_epi32(vecSum, sum2); - } - else if (len - j == 2) - { + } else if (len - j == 2) { vecX0 = _mm_shuffle_epi32(vecX, 0xaa); vecX1 = _mm_shuffle_epi32(vecX, 0xff); @@ -217,9 +207,7 @@ void xcorr_kernel_sse4_1(const opus_val16 * x, const opus_val16 * y, opus_val32 vecSum = _mm_add_epi32(vecSum, sum0); vecSum = _mm_add_epi32(vecSum, sum1); - } - else if (len - j == 1) - { + } else if (len - j == 1) { vecX0 = _mm_shuffle_epi32(vecX, 0xff); vecY0 = OP_CVTEPI16_EPI32_M64(&y[j + 0]); @@ -233,8 +221,8 @@ void xcorr_kernel_sse4_1(const opus_val16 * x, const opus_val16 * y, opus_val32 initSum = _mm_add_epi32(initSum, vecSum); _mm_storeu_si128((__m128i *)(void*)sum, initSum); -#ifdef OPUS_CHECK_ASM +# ifdef OAC_CHECK_ASM celt_assert(!memcmp(sum_c, sum, sizeof(sum_c))); -#endif +# endif } #endif diff --git a/celt/x86/vq_sse.h b/celt/x86/vq_sse.h index 444503b63..5a418ec05 100644 --- a/celt/x86/vq_sse.h +++ b/celt/x86/vq_sse.h @@ -22,31 +22,31 @@ 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. -*/ + */ #ifndef VQ_SSE_H #define VQ_SSE_H -#if defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(FIXED_POINT) +#if defined(OAC_X86_MAY_HAVE_SSE2) && !defined(FIXED_POINT) -opus_val16 op_pvq_search_sse2(celt_norm *_X, int *iy, int K, int N, int arch); +oac_val16 oaci_op_pvq_search_sse2(celt_norm *_X, int *iy, int K, int N, int arch); -#if defined(OPUS_X86_PRESUME_SSE2) +# if defined(OAC_X86_PRESUME_SSE2) -#define OVERRIDE_OP_PVQ_SEARCH -#define op_pvq_search(x, iy, K, N, arch) \ - (op_pvq_search_sse2(x, iy, K, N, arch)) +# define OVERRIDE_OP_PVQ_SEARCH +# define oaci_op_pvq_search(x, iy, K, N, arch) \ + (oaci_op_pvq_search_sse2(x, iy, K, N, arch)) -#elif defined(OPUS_HAVE_RTCD) +# elif defined(OAC_HAVE_RTCD) -#define OVERRIDE_OP_PVQ_SEARCH -extern opus_val16 (*const OP_PVQ_SEARCH_IMPL[OPUS_ARCHMASK + 1])( +# define OVERRIDE_OP_PVQ_SEARCH +extern oac_val16 (*const OP_PVQ_SEARCH_IMPL[OAC_ARCHMASK + 1])( celt_norm *_X, int *iy, int K, int N, int arch); -# define op_pvq_search(X, iy, K, N, arch) \ - ((*OP_PVQ_SEARCH_IMPL[(arch) & OPUS_ARCHMASK])(X, iy, K, N, arch)) +# define oaci_op_pvq_search(X, iy, K, N, arch) \ + ((*OP_PVQ_SEARCH_IMPL[(arch)&OAC_ARCHMASK])(X, iy, K, N, arch)) -#endif +# endif #endif #endif diff --git a/celt/x86/vq_sse2.c b/celt/x86/vq_sse2.c index 4c4ebf8e2..6e52b1dba 100644 --- a/celt/x86/vq_sse2.c +++ b/celt/x86/vq_sse2.c @@ -24,10 +24,10 @@ 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" +# include "config.h" #endif #include @@ -41,177 +41,168 @@ #ifndef FIXED_POINT -opus_val16 op_pvq_search_sse2(celt_norm *_X, int *iy, int K, int N, int arch) -{ - int i, j; - int pulsesLeft; - float xy, yy; - VARDECL(celt_norm, y); - VARDECL(celt_norm, X); - VARDECL(float, signy); - __m128 signmask; - __m128 sums; - __m128i fours; - SAVE_STACK; - - (void)arch; - /* All bits set to zero, except for the sign bit. */ - signmask = _mm_set_ps1(-0.f); - fours = _mm_set_epi32(4, 4, 4, 4); - ALLOC(y, N+3, celt_norm); - ALLOC(X, N+3, celt_norm); - ALLOC(signy, N+3, float); - - OPUS_COPY(X, _X, N); - X[N] = X[N+1] = X[N+2] = 0; - sums = _mm_setzero_ps(); - for (j=0;j (N>>1)) - { - __m128i pulses_sum; - __m128 yy4, xy4; - __m128 rcp4; - opus_val32 sum = _mm_cvtss_f32(sums); - /* If X is too small, just replace it with a pulse at 0 */ - /* Prevents infinities and NaNs from causing too many pulses - to be allocated. 64 is an approximation of infinity here. */ - if (!(sum > EPSILON && sum < 64)) - { - X[0] = QCONST16(1.f,14); - j=1; do - X[j]=0; - while (++j=0); - - /* This should never happen, but just in case it does (e.g. on silence) - we fill the first bin with pulses. */ - if (pulsesLeft > N+3) - { - opus_val16 tmp = (opus_val16)pulsesLeft; - yy = MAC16_16(yy, tmp, tmp); - yy = MAC16_16(yy, tmp, y[0]); - iy[0] += pulsesLeft; - pulsesLeft=0; - } - - for (i=0;i (N>>1)) { + __m128i pulses_sum; + __m128 yy4, xy4; + __m128 rcp4; + oac_val32 sum = _mm_cvtss_f32(sums); + /* If X is too small, just replace it with a pulse at 0 */ + /* Prevents infinities and NaNs from causing too many pulses + to be allocated. 64 is an approximation of infinity here. */ + if (!(sum > EPSILON && sum < 64)) { + X[0] = QCONST16(1.f, 14); + j = 1; do + X[j] = 0; + while (++j < N); + sums = _mm_set_ps1(1.f); + } + /* Using K+e with e < 1 guarantees we cannot get more than K pulses. */ + rcp4 = _mm_mul_ps(_mm_set_ps1((float)(K + .8)), _mm_rcp_ps(sums)); + xy4 = yy4 = _mm_setzero_ps(); + pulses_sum = _mm_setzero_si128(); + for (j = 0; j < N; j += 4) { + __m128 rx4, x4, y4; + __m128i iy4; + x4 = _mm_loadu_ps(&X[j]); + rx4 = _mm_mul_ps(x4, rcp4); + iy4 = _mm_cvttps_epi32(rx4); + pulses_sum = _mm_add_epi32(pulses_sum, iy4); + _mm_storeu_si128((__m128i*)(void*)&iy[j], iy4); + y4 = _mm_cvtepi32_ps(iy4); + xy4 = _mm_add_ps(xy4, _mm_mul_ps(x4, y4)); + yy4 = _mm_add_ps(yy4, _mm_mul_ps(y4, y4)); + /* double the y[] vector so we don't have to do it in the search loop. */ + _mm_storeu_ps(&y[j], _mm_add_ps(y4, y4)); + } + pulses_sum = _mm_add_epi32(pulses_sum, _mm_shuffle_epi32(pulses_sum, _MM_SHUFFLE(1, 0, 3, 2))); + pulses_sum = _mm_add_epi32(pulses_sum, _mm_shuffle_epi32(pulses_sum, _MM_SHUFFLE(2, 3, 0, 1))); + pulsesLeft -= _mm_cvtsi128_si32(pulses_sum); + xy4 = _mm_add_ps(xy4, _mm_shuffle_ps(xy4, xy4, _MM_SHUFFLE(1, 0, 3, 2))); + xy4 = _mm_add_ps(xy4, _mm_shuffle_ps(xy4, xy4, _MM_SHUFFLE(2, 3, 0, 1))); + xy = _mm_cvtss_f32(xy4); + yy4 = _mm_add_ps(yy4, _mm_shuffle_ps(yy4, yy4, _MM_SHUFFLE(1, 0, 3, 2))); + yy4 = _mm_add_ps(yy4, _mm_shuffle_ps(yy4, yy4, _MM_SHUFFLE(2, 3, 0, 1))); + yy = _mm_cvtss_f32(yy4); + } + X[N] = X[N + 1] = X[N + 2] = -100; + y[N] = y[N + 1] = y[N + 2] = 100; + celt_sig_assert(pulsesLeft >= 0); + + /* This should never happen, but just in case it does (e.g. on silence) + we fill the first bin with pulses. */ + if (pulsesLeft > N + 3) { + oac_val16 tmp = (oac_val16)pulsesLeft; + yy = MAC16_16(yy, tmp, tmp); + yy = MAC16_16(yy, tmp, y[0]); + iy[0] += pulsesLeft; + pulsesLeft = 0; + } + + for (i = 0; i < pulsesLeft; i++) { + int best_id; + __m128 xy4, yy4; + __m128 max, max2; + __m128i count; + __m128i pos; + /* The squared magnitude term gets added anyway, so we might as well + add it outside the loop */ + yy = ADD16(yy, 1); + xy4 = _mm_load1_ps(&xy); + yy4 = _mm_load1_ps(&yy); + max = _mm_setzero_ps(); + pos = _mm_setzero_si128(); + count = _mm_set_epi32(3, 2, 1, 0); + for (j = 0; j < N; j += 4) { + __m128 x4, y4, r4; + x4 = _mm_loadu_ps(&X[j]); + y4 = _mm_loadu_ps(&y[j]); + x4 = _mm_add_ps(x4, xy4); + y4 = _mm_add_ps(y4, yy4); + y4 = _mm_rsqrt_ps(y4); + r4 = _mm_mul_ps(x4, y4); + /* Update the index of the max. */ + pos = _mm_max_epi16(pos, _mm_and_si128(count, _mm_castps_si128(_mm_cmpgt_ps(r4, max)))); + /* Update the max. */ + max = _mm_max_ps(max, r4); + /* Update the indices (+4) */ + count = _mm_add_epi32(count, fours); + } + /* Horizontal max */ + max2 = _mm_max_ps(max, _mm_shuffle_ps(max, max, _MM_SHUFFLE(1, 0, 3, 2))); + max2 = _mm_max_ps(max2, _mm_shuffle_ps(max2, max2, _MM_SHUFFLE(2, 3, 0, 1))); + /* Now that max2 contains the max at all positions, look at which value(s) of the + partial max is equal to the global max. */ + pos = _mm_and_si128(pos, _mm_castps_si128(_mm_cmpeq_ps(max, max2))); + pos = _mm_max_epi16(pos, _mm_unpackhi_epi64(pos, pos)); + pos = _mm_max_epi16(pos, _mm_shufflelo_epi16(pos, _MM_SHUFFLE(1, 0, 3, 2))); + best_id = _mm_cvtsi128_si32(pos); + + /* Updating the sums of the new pulse(s) */ + xy = ADD32(xy, EXTEND32(X[best_id])); + /* We're multiplying y[j] by two so we don't have to do it here */ + yy = ADD16(yy, y[best_id]); + + /* Only now that we've made the final choice, update y/iy */ + /* Multiplying y[j] by 2 so we don't have to do it everywhere else */ + y[best_id] += 2; + iy[best_id]++; + } + + /* Put the original sign back */ + for (j = 0; j < N; j += 4) { + __m128i y4; + __m128i s4; + y4 = _mm_loadu_si128((__m128i*)(void*)&iy[j]); + s4 = _mm_castps_si128(_mm_loadu_ps(&signy[j])); + y4 = _mm_xor_si128(_mm_add_epi32(y4, s4), s4); + _mm_storeu_si128((__m128i*)(void*)&iy[j], y4); + } + RESTORE_STACK; + return yy; } #endif diff --git a/celt/x86/x86_arch_macros.h b/celt/x86/x86_arch_macros.h index 975b443e9..3d9bd181b 100644 --- a/celt/x86/x86_arch_macros.h +++ b/celt/x86/x86_arch_macros.h @@ -22,26 +22,26 @@ 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 _MSC_VER -# ifdef OPUS_X86_MAY_HAVE_SSE -# ifndef __SSE__ -# define __SSE__ -# endif +#ifdef OAC_X86_MAY_HAVE_SSE +# ifndef __SSE__ +# define __SSE__ # endif +#endif -# ifdef OPUS_X86_MAY_HAVE_SSE2 -# ifndef __SSE2__ -# define __SSE2__ -# endif +#ifdef OAC_X86_MAY_HAVE_SSE2 +# ifndef __SSE2__ +# define __SSE2__ # endif +#endif -# ifdef OPUS_X86_MAY_HAVE_SSE4_1 -# ifndef __SSE4_1__ -# define __SSE4_1__ -# endif +#ifdef OAC_X86_MAY_HAVE_SSE4_1 +# ifndef __SSE4_1__ +# define __SSE4_1__ # endif +#endif #endif diff --git a/celt/x86/x86_celt_map.c b/celt/x86/x86_celt_map.c index ba8eafe6a..34199de70 100644 --- a/celt/x86/x86_celt_map.c +++ b/celt/x86/x86_celt_map.c @@ -23,10 +23,10 @@ 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. -*/ + */ #if defined(HAVE_CONFIG_H) -#include "config.h" +# include "config.h" #endif #include "x86/x86cpu.h" @@ -35,153 +35,153 @@ #include "pitch_sse.h" #include "vq.h" -#if defined(OPUS_HAVE_RTCD) +#if defined(OAC_HAVE_RTCD) # if defined(FIXED_POINT) -#if defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1) - -void (*const CELT_FIR_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *num, - opus_val16 *y, - int N, - int ord, - int arch -) = { - celt_fir_c, /* non-sse */ - celt_fir_c, - celt_fir_c, - MAY_HAVE_SSE4_1(celt_fir), /* sse4.1 */ - MAY_HAVE_SSE4_1(celt_fir) /* avx */ -}; +# if defined(OAC_X86_MAY_HAVE_SSE4_1) && !defined(OAC_X86_PRESUME_SSE4_1) -void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y, - opus_val32 sum[4], - int len -) = { - xcorr_kernel_c, /* non-sse */ - xcorr_kernel_c, - xcorr_kernel_c, - MAY_HAVE_SSE4_1(xcorr_kernel), /* sse4.1 */ - MAY_HAVE_SSE4_1(xcorr_kernel) /* avx */ +void (*const oaci_CELT_FIR_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *num, + oac_val16 *y, + int N, + int ord, + int arch + ) = { + oaci_celt_fir_c, /* non-sse */ + oaci_celt_fir_c, + oaci_celt_fir_c, + MAY_HAVE_SSE4_1(oaci_celt_fir), /* sse4.1 */ + MAY_HAVE_SSE4_1(oaci_celt_fir) /* avx */ }; -#endif +void (*const oaci_XCORR_KERNEL_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y, + oac_val32 sum[4], + int len + ) = { + oaci_xcorr_kernel_c, /* non-sse */ + oaci_xcorr_kernel_c, + oaci_xcorr_kernel_c, + MAY_HAVE_SSE4_1(oaci_xcorr_kernel), /* sse4.1 */ + MAY_HAVE_SSE4_1(oaci_xcorr_kernel) /* avx */ +}; -#if (defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_PRESUME_SSE4_1)) || \ - (!defined(OPUS_X86_MAY_HAVE_SSE_4_1) && defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2)) - -opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y, - int N -) = { - celt_inner_prod_c, /* non-sse */ - celt_inner_prod_c, - MAY_HAVE_SSE2(celt_inner_prod), - MAY_HAVE_SSE4_1(celt_inner_prod), /* sse4.1 */ - MAY_HAVE_SSE4_1(celt_inner_prod) /* avx */ +# endif + +# if (defined(OAC_X86_MAY_HAVE_SSE4_1) && !defined(OAC_X86_PRESUME_SSE4_1)) || \ + (!defined(OAC_X86_MAY_HAVE_SSE_4_1) && defined(OAC_X86_MAY_HAVE_SSE2) && !defined(OAC_X86_PRESUME_SSE2)) + +oac_val32 (*const oaci_CELT_INNER_PROD_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y, + int N + ) = { + oaci_celt_inner_prod_c, /* non-sse */ + oaci_celt_inner_prod_c, + MAY_HAVE_SSE2(oaci_celt_inner_prod), + MAY_HAVE_SSE4_1(oaci_celt_inner_prod), /* sse4.1 */ + MAY_HAVE_SSE4_1(oaci_celt_inner_prod) /* avx */ }; -#endif +# endif # else -#if defined(OPUS_X86_MAY_HAVE_AVX2) && !defined(OPUS_X86_PRESUME_AVX2) +# if defined(OAC_X86_MAY_HAVE_AVX2) && !defined(OAC_X86_PRESUME_AVX2) -void (*const PITCH_XCORR_IMPL[OPUS_ARCHMASK + 1])( +void (*const oaci_PITCH_XCORR_IMPL[OAC_ARCHMASK + 1])( const float *_x, const float *_y, float *xcorr, int len, int max_pitch, int arch -) = { - celt_pitch_xcorr_c, /* non-sse */ - celt_pitch_xcorr_c, - celt_pitch_xcorr_c, - celt_pitch_xcorr_c, - MAY_HAVE_AVX2(celt_pitch_xcorr) + ) = { + oaci_celt_pitch_xcorr_c, /* non-sse */ + oaci_celt_pitch_xcorr_c, + oaci_celt_pitch_xcorr_c, + oaci_celt_pitch_xcorr_c, + MAY_HAVE_AVX2(oaci_celt_pitch_xcorr) }; -#endif +# endif -#if defined(OPUS_X86_MAY_HAVE_SSE) && !defined(OPUS_X86_PRESUME_SSE) +# if defined(OAC_X86_MAY_HAVE_SSE) && !defined(OAC_X86_PRESUME_SSE) -void (*const XCORR_KERNEL_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y, - opus_val32 sum[4], - int len -) = { - xcorr_kernel_c, /* non-sse */ - MAY_HAVE_SSE(xcorr_kernel), - MAY_HAVE_SSE(xcorr_kernel), - MAY_HAVE_SSE(xcorr_kernel), - MAY_HAVE_SSE(xcorr_kernel) +void (*const oaci_XCORR_KERNEL_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y, + oac_val32 sum[4], + int len + ) = { + oaci_xcorr_kernel_c, /* non-sse */ + MAY_HAVE_SSE(oaci_xcorr_kernel), + MAY_HAVE_SSE(oaci_xcorr_kernel), + MAY_HAVE_SSE(oaci_xcorr_kernel), + MAY_HAVE_SSE(oaci_xcorr_kernel) }; -opus_val32 (*const CELT_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y, - int N -) = { - celt_inner_prod_c, /* non-sse */ - MAY_HAVE_SSE(celt_inner_prod), - MAY_HAVE_SSE(celt_inner_prod), - MAY_HAVE_SSE(celt_inner_prod), - MAY_HAVE_SSE(celt_inner_prod) +oac_val32 (*const oaci_CELT_INNER_PROD_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y, + int N + ) = { + oaci_celt_inner_prod_c, /* non-sse */ + MAY_HAVE_SSE(oaci_celt_inner_prod), + MAY_HAVE_SSE(oaci_celt_inner_prod), + MAY_HAVE_SSE(oaci_celt_inner_prod), + MAY_HAVE_SSE(oaci_celt_inner_prod) }; -void (*const DUAL_INNER_PROD_IMPL[OPUS_ARCHMASK + 1])( - const opus_val16 *x, - const opus_val16 *y01, - const opus_val16 *y02, - int N, - opus_val32 *xy1, - opus_val32 *xy2 -) = { - dual_inner_prod_c, /* non-sse */ - MAY_HAVE_SSE(dual_inner_prod), - MAY_HAVE_SSE(dual_inner_prod), - MAY_HAVE_SSE(dual_inner_prod), - MAY_HAVE_SSE(dual_inner_prod) +void (*const DUAL_INNER_PROD_IMPL[OAC_ARCHMASK + 1])( + const oac_val16 *x, + const oac_val16 *y01, + const oac_val16 *y02, + int N, + oac_val32 *xy1, + oac_val32 *xy2 + ) = { + oaci_dual_inner_prod_c, /* non-sse */ + MAY_HAVE_SSE(oaci_dual_inner_prod), + MAY_HAVE_SSE(oaci_dual_inner_prod), + MAY_HAVE_SSE(oaci_dual_inner_prod), + MAY_HAVE_SSE(oaci_dual_inner_prod) }; -void (*const COMB_FILTER_CONST_IMPL[OPUS_ARCHMASK + 1])( - opus_val32 *y, - opus_val32 *x, - int T, - int N, - opus_val16 g10, - opus_val16 g11, - opus_val16 g12 -) = { - comb_filter_const_c, /* non-sse */ - MAY_HAVE_SSE(comb_filter_const), - MAY_HAVE_SSE(comb_filter_const), - MAY_HAVE_SSE(comb_filter_const), - MAY_HAVE_SSE(comb_filter_const) +void (*const COMB_FILTER_CONST_IMPL[OAC_ARCHMASK + 1])( + oac_val32 *y, + oac_val32 *x, + int T, + int N, + oac_val16 g10, + oac_val16 g11, + oac_val16 g12 + ) = { + oaci_comb_filter_const_c, /* non-sse */ + MAY_HAVE_SSE(oaci_comb_filter_const), + MAY_HAVE_SSE(oaci_comb_filter_const), + MAY_HAVE_SSE(oaci_comb_filter_const), + MAY_HAVE_SSE(oaci_comb_filter_const) }; -#endif +# endif -#if defined(OPUS_X86_MAY_HAVE_SSE2) && !defined(OPUS_X86_PRESUME_SSE2) -opus_val16 (*const OP_PVQ_SEARCH_IMPL[OPUS_ARCHMASK + 1])( +# if defined(OAC_X86_MAY_HAVE_SSE2) && !defined(OAC_X86_PRESUME_SSE2) +oac_val16 (*const OP_PVQ_SEARCH_IMPL[OAC_ARCHMASK + 1])( celt_norm *_X, int *iy, int K, int N, int arch -) = { - op_pvq_search_c, /* non-sse */ - op_pvq_search_c, - MAY_HAVE_SSE2(op_pvq_search), - MAY_HAVE_SSE2(op_pvq_search), - MAY_HAVE_SSE2(op_pvq_search) + ) = { + oaci_op_pvq_search_c, /* non-sse */ + oaci_op_pvq_search_c, + MAY_HAVE_SSE2(oaci_op_pvq_search), + MAY_HAVE_SSE2(oaci_op_pvq_search), + MAY_HAVE_SSE2(oaci_op_pvq_search) }; -#endif +# endif -#endif +# endif #endif diff --git a/celt/x86/x86cpu.c b/celt/x86/x86cpu.c index 2e7c32aee..4d9514b5b 100644 --- a/celt/x86/x86cpu.c +++ b/celt/x86/x86cpu.c @@ -23,10 +23,10 @@ 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" +# include "config.h" #endif #include "cpu_support.h" @@ -35,54 +35,52 @@ #include "pitch.h" #include "x86cpu.h" -#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_AVX2) && !defined(OPUS_X86_PRESUME_AVX2))) +#if defined(OAC_HAVE_RTCD) && \ + ((defined(OAC_X86_MAY_HAVE_SSE) && !defined(OAC_X86_PRESUME_SSE)) || \ + (defined(OAC_X86_MAY_HAVE_SSE2) && !defined(OAC_X86_PRESUME_SSE2)) || \ + (defined(OAC_X86_MAY_HAVE_SSE4_1) && !defined(OAC_X86_PRESUME_SSE4_1)) || \ + (defined(OAC_X86_MAY_HAVE_AVX2) && !defined(OAC_X86_PRESUME_AVX2))) -#if defined(_MSC_VER) +# if defined(_MSC_VER) -#include -static _inline void cpuid(unsigned int CPUInfo[4], unsigned int InfoType) -{ +# include +static _inline void oaci_cpuid(unsigned int CPUInfo[4], unsigned int InfoType) { __cpuid((int*)CPUInfo, InfoType); } -#else +# else -#if defined(CPU_INFO_BY_C) -#include -#endif +# if defined(CPU_INFO_BY_C) +# include +# endif -static void cpuid(unsigned int CPUInfo[4], unsigned int InfoType) -{ -#if defined(CPU_INFO_BY_ASM) -#if defined(__i386__) && defined(__PIC__) +static void oaci_cpuid(unsigned int CPUInfo[4], unsigned int InfoType) { +# if defined(CPU_INFO_BY_ASM) +# 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": + "xchg %%ebx, %1\n" : "=a" (CPUInfo[0]), "=r" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3]) : /* We clear ECX to avoid a valgrind false-positive prior to v3.17.0. */ "0" (InfoType), "2" (0) - ); -#else + ); +# else __asm__ __volatile__ ( - "cpuid": + "cpuid" : "=a" (CPUInfo[0]), "=b" (CPUInfo[1]), "=c" (CPUInfo[2]), "=d" (CPUInfo[3]) : /* 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) + ); +# endif +# elif defined(CPU_INFO_BY_C) /* 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]))) { @@ -91,15 +89,15 @@ static void cpuid(unsigned int CPUInfo[4], unsigned int InfoType) 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 +# else +# error "Configured to use x86 RTCD, but no CPU detection method available. " \ + "Reconfigure with --disable-rtcd (or send patches)." +# endif } -#endif +# endif -typedef struct CPU_Feature{ +typedef struct CPU_Feature { /* SIMD: 128-bit */ int HW_SSE; int HW_SSE2; @@ -108,28 +106,26 @@ typedef struct CPU_Feature{ int HW_AVX2; } CPU_Feature; -static void opus_cpu_feature_check(CPU_Feature *cpu_feature) -{ +static void oac_cpu_feature_check(CPU_Feature *cpu_feature) { unsigned int info[4]; unsigned int nIds = 0; - cpuid(info, 0); + oaci_cpuid(info, 0); nIds = info[0]; - if (nIds >= 1){ - cpuid(info, 1); - cpu_feature->HW_SSE = (info[3] & (1 << 25)) != 0; - cpu_feature->HW_SSE2 = (info[3] & (1 << 26)) != 0; - cpu_feature->HW_SSE41 = (info[2] & (1 << 19)) != 0; - cpu_feature->HW_AVX2 = (info[2] & (1 << 28)) != 0 && (info[2] & (1 << 12)) != 0; + if (nIds >= 1) { + oaci_cpuid(info, 1); + cpu_feature->HW_SSE = (info[3]&(1<<25)) != 0; + cpu_feature->HW_SSE2 = (info[3]&(1<<26)) != 0; + cpu_feature->HW_SSE41 = (info[2]&(1<<19)) != 0; + cpu_feature->HW_AVX2 = (info[2]&(1<<28)) != 0 && (info[2]&(1<<12)) != 0; if (cpu_feature->HW_AVX2 && nIds >= 7) { - cpuid(info, 7); - cpu_feature->HW_AVX2 = cpu_feature->HW_AVX2 && (info[1] & (1 << 5)) != 0; + oaci_cpuid(info, 7); + cpu_feature->HW_AVX2 = cpu_feature->HW_AVX2 && (info[1]&(1<<5)) != 0; } else { cpu_feature->HW_AVX2 = 0; } - } - else { + } else { cpu_feature->HW_SSE = 0; cpu_feature->HW_SSE2 = 0; cpu_feature->HW_SSE41 = 0; @@ -137,34 +133,29 @@ static void opus_cpu_feature_check(CPU_Feature *cpu_feature) } } -static int opus_select_arch_impl(void) -{ +static int oac_select_arch_impl(void) { CPU_Feature cpu_feature; int arch; - opus_cpu_feature_check(&cpu_feature); + oac_cpu_feature_check(&cpu_feature); arch = 0; - if (!cpu_feature.HW_SSE) - { - return arch; + if (!cpu_feature.HW_SSE) { + return arch; } arch++; - if (!cpu_feature.HW_SSE2) - { - return arch; + if (!cpu_feature.HW_SSE2) { + return arch; } arch++; - if (!cpu_feature.HW_SSE41) - { + if (!cpu_feature.HW_SSE41) { return arch; } arch++; - if (!cpu_feature.HW_AVX2) - { + if (!cpu_feature.HW_AVX2) { return arch; } arch++; @@ -172,12 +163,12 @@ static int opus_select_arch_impl(void) return arch; } -int opus_select_arch(void) { - int arch = opus_select_arch_impl(); -#ifdef FUZZING +int oac_select_arch(void) { + int arch = oac_select_arch_impl(); +# ifdef FUZZING /* Randomly downgrade the architecture. */ - arch = rand()%(arch+1); -#endif + arch = rand()%(arch + 1); +# endif return arch; } diff --git a/celt/x86/x86cpu.h b/celt/x86/x86cpu.h index 1e5b6a4cb..f37b6bdf8 100644 --- a/celt/x86/x86cpu.h +++ b/celt/x86/x86cpu.h @@ -23,90 +23,90 @@ 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. -*/ + */ #if !defined(X86CPU_H) -# define X86CPU_H +#define X86CPU_H -# if defined(OPUS_X86_MAY_HAVE_SSE) -# define MAY_HAVE_SSE(name) name ## _sse -# else -# define MAY_HAVE_SSE(name) name ## _c -# endif +#if defined(OAC_X86_MAY_HAVE_SSE) +# define MAY_HAVE_SSE(name) name ## _sse +#else +# define MAY_HAVE_SSE(name) name ## _c +#endif -# if defined(OPUS_X86_MAY_HAVE_SSE2) -# define MAY_HAVE_SSE2(name) name ## _sse2 -# else -# define MAY_HAVE_SSE2(name) name ## _c -# endif +#if defined(OAC_X86_MAY_HAVE_SSE2) +# define MAY_HAVE_SSE2(name) name ## _sse2 +#else +# define MAY_HAVE_SSE2(name) name ## _c +#endif -# if defined(OPUS_X86_MAY_HAVE_SSE4_1) -# define MAY_HAVE_SSE4_1(name) name ## _sse4_1 -# else -# define MAY_HAVE_SSE4_1(name) name ## _c -# endif +#if defined(OAC_X86_MAY_HAVE_SSE4_1) +# define MAY_HAVE_SSE4_1(name) name ## _sse4_1 +#else +# define MAY_HAVE_SSE4_1(name) name ## _c +#endif -# if defined(OPUS_X86_MAY_HAVE_AVX2) -# define MAY_HAVE_AVX2(name) name ## _avx2 -# else -# define MAY_HAVE_AVX2(name) name ## _c -# endif +#if defined(OAC_X86_MAY_HAVE_AVX2) +# define MAY_HAVE_AVX2(name) name ## _avx2 +#else +# define MAY_HAVE_AVX2(name) name ## _c +#endif -# 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_AVX2) && !defined(OPUS_X86_PRESUME_AVX2))) -int opus_select_arch(void); -# endif +#if defined(OAC_HAVE_RTCD) && \ + ((defined(OAC_X86_MAY_HAVE_SSE) && !defined(OAC_X86_PRESUME_SSE)) || \ + (defined(OAC_X86_MAY_HAVE_SSE2) && !defined(OAC_X86_PRESUME_SSE2)) || \ + (defined(OAC_X86_MAY_HAVE_SSE4_1) && !defined(OAC_X86_PRESUME_SSE4_1)) || \ + (defined(OAC_X86_MAY_HAVE_AVX2) && !defined(OAC_X86_PRESUME_AVX2))) +int oac_select_arch(void); +#endif -# if defined(OPUS_X86_MAY_HAVE_SSE2) -# include "opus_defines.h" +#if defined(OAC_X86_MAY_HAVE_SSE2) +# include "oac_defines.h" /*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 + Use this to work around those restrictions (which should hopefully all get optimized to a single MOVD instruction). - GCC implemented _mm_loadu_si32() since GCC 11; HOWEVER, there is a bug! - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99754 - LLVM implemented _mm_loadu_si32() since Clang 8.0, however the + GCC implemented _mm_loadu_si32() since GCC 11; HOWEVER, there is a bug! + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99754 + LLVM implemented _mm_loadu_si32() since Clang 8.0, however the __clang_major__ version number macro is unreliable, as vendors (specifically, Apple) will use different numbering schemes than upstream. - Clang's advice is "use feature detection", but they do not provide feature + Clang's advice is "use feature detection", but they do not provide feature detection support for specific SIMD functions. - We follow the approach from the SIMDe project and instead detect unrelated + We follow the approach from the SIMDe project and instead detect unrelated features that should be available in the version we want (see ).*/ -# if defined(__clang__) -# if __has_warning("-Wextra-semi-stmt") || \ - __has_builtin(__builtin_rotateleft32) -# define OPUS_CLANG_8 (1) -# endif +# if defined(__clang__) +# if __has_warning("-Wextra-semi-stmt") || \ + __has_builtin(__builtin_rotateleft32) +# define OAC_CLANG_8 (1) +# endif +# endif +# if !defined(_MSC_VER) && !OAC_GNUC_PREREQ(11, 3) && !defined(OAC_CLANG_8) +# include +# include + +# ifdef _mm_loadu_si32 +# undef _mm_loadu_si32 # endif -# if !defined(_MSC_VER) && !OPUS_GNUC_PREREQ(11,3) && !defined(OPUS_CLANG_8) -# include -# include - -# ifdef _mm_loadu_si32 -# undef _mm_loadu_si32 -# endif -# define _mm_loadu_si32 WORKAROUND_mm_loadu_si32 +# define _mm_loadu_si32 WORKAROUND_mm_loadu_si32 static inline __m128i WORKAROUND_mm_loadu_si32(void const* mem_addr) { - int val; - memcpy(&val, mem_addr, sizeof(val)); - return _mm_cvtsi32_si128(val); + int val; + memcpy(&val, mem_addr, sizeof(val)); + return _mm_cvtsi32_si128(val); } -# elif defined(_MSC_VER) - /* MSVC needs this for _mm_loadu_si32 */ -# include -# endif +# elif defined(_MSC_VER) +/* MSVC needs this for _mm_loadu_si32 */ +# include +# endif -# define OP_CVTEPI8_EPI32_M32(x) \ - (_mm_cvtepi8_epi32(_mm_loadu_si32(x))) +# define OP_CVTEPI8_EPI32_M32(x) \ + (_mm_cvtepi8_epi32(_mm_loadu_si32(x))) -# define OP_CVTEPI16_EPI32_M64(x) \ - (_mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(void*)(x)))) +# define OP_CVTEPI16_EPI32_M64(x) \ + (_mm_cvtepi16_epi32(_mm_loadl_epi64((__m128i *)(void*)(x)))) -# endif +#endif #endif diff --git a/celt_headers.mk b/celt_headers.mk index 7a3047f90..704bb1885 100644 --- a/celt_headers.mk +++ b/celt_headers.mk @@ -3,9 +3,9 @@ celt/arch.h \ celt/bands.h \ celt/celt.h \ celt/cpu_support.h \ -include/opus_types.h \ -include/opus_defines.h \ -include/opus_custom.h \ +include/oac_types.h \ +include/oac_defines.h \ +include/oac_custom.h \ celt/cwrs.h \ celt/ecintrin.h \ celt/entcode.h \ @@ -43,10 +43,7 @@ celt/arm/mathops_arm.h \ celt/arm/pitch_arm.h \ celt/arm/fft_arm.h \ celt/arm/mdct_arm.h \ -celt/mips/celt_mipsr1.h \ celt/mips/fixed_generic_mipsr1.h \ -celt/mips/kiss_fft_mipsr1.h \ -celt/mips/mdct_mipsr1.h \ celt/mips/pitch_mipsr1.h \ celt/x86/pitch_sse.h \ celt/x86/vq_sse.h \ diff --git a/cmake/OpusBuildtype.cmake b/cmake/OacBuildtype.cmake similarity index 93% rename from cmake/OpusBuildtype.cmake rename to cmake/OacBuildtype.cmake index 557cc89b3..4846d84e6 100644 --- a/cmake/OpusBuildtype.cmake +++ b/cmake/OacBuildtype.cmake @@ -1,8 +1,8 @@ # Set a default build type if none was specified -if(__opus_buildtype) +if(__oac_buildtype) return() endif() -set(__opus_buildtype INCLUDED) +set(__oac_buildtype INCLUDED) if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if(CMAKE_C_FLAGS) diff --git a/cmake/OpusConfig.cmake b/cmake/OacConfig.cmake similarity index 78% rename from cmake/OpusConfig.cmake rename to cmake/OacConfig.cmake index e9319fbad..8c559fe4b 100644 --- a/cmake/OpusConfig.cmake +++ b/cmake/OacConfig.cmake @@ -1,9 +1,9 @@ -if(__opus_config) +if(__oac_config) return() endif() -set(__opus_config INCLUDED) +set(__oac_config INCLUDED) -include(OpusFunctions) +include(OacFunctions) configure_file(cmake/config.h.cmake.in config.h @ONLY) add_definitions(-DHAVE_CONFIG_H) @@ -42,7 +42,7 @@ cmake_push_check_state(RESET) include(CheckLibraryExists) check_library_exists(m floor "" HAVE_LIBM) if(HAVE_LIBM) - list(APPEND OPUS_REQUIRED_LIBRARIES m) + list(APPEND OAC_REQUIRED_LIBRARIES m) set(CMAKE_REQUIRED_LIBRARIES m) endif() @@ -53,30 +53,30 @@ 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) + set(OAC_CPU_X64 1) else() - set(OPUS_CPU_X86 1) + set(OAC_CPU_X86 1) endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64|ARM)") - set(OPUS_CPU_ARM 1) + set(OAC_CPU_ARM 1) endif() -if(NOT OPUS_DISABLE_INTRINSICS) - opus_supports_cpu_detection(RUNTIME_CPU_CAPABILITY_DETECTION) +if(NOT OAC_DISABLE_INTRINSICS) + oac_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(OAC_CPU_X86 OR OAC_CPU_X64 AND NOT OAC_DISABLE_INTRINSICS) + oac_detect_sse(COMPILER_SUPPORT_SIMD) +elseif(OAC_CPU_ARM AND NOT OAC_DISABLE_INTRINSICS) + oac_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) + option(OAC_USE_NEON "Option to enable NEON" ON) + option(OAC_MAY_HAVE_NEON "Does runtime check for neon support" ON) + option(OAC_PRESUME_NEON "Assume target CPU has NEON support" OFF) if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") - set(OPUS_PRESUME_NEON ON) + set(OAC_PRESUME_NEON ON) elseif(CMAKE_SYSTEM_NAME MATCHES "iOS") - set(OPUS_PRESUME_NEON ON) + set(OAC_PRESUME_NEON ON) endif() endif() endif() diff --git a/cmake/OacConfig.cmake.in b/cmake/OacConfig.cmake.in new file mode 100644 index 000000000..ae49eeb21 --- /dev/null +++ b/cmake/OacConfig.cmake.in @@ -0,0 +1,20 @@ +set(OAC_VERSION @PROJECT_VERSION@) +set(OAC_VERSION_STRING @PROJECT_VERSION@) +set(OAC_VERSION_MAJOR @PROJECT_VERSION_MAJOR@) +set(OAC_VERSION_MINOR @PROJECT_VERSION_MINOR@) +set(OAC_VERSION_PATCH @PROJECT_VERSION_PATCH@) + +@PACKAGE_INIT@ + +set_and_check(OAC_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") +set(OAC_INCLUDE_DIR ${OAC_INCLUDE_DIR};${OAC_INCLUDE_DIR}/oac) +set(OAC_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@;@PACKAGE_INCLUDE_INSTALL_DIR@/oac") + +include(${CMAKE_CURRENT_LIST_DIR}/OacTargets.cmake) + +set(OAC_LIBRARY Oac::oac) +set(OAC_LIBRARIES Oac::oac) + +check_required_components(Oac) + +set(OAC_FOUND 1) diff --git a/cmake/OpusFunctions.cmake b/cmake/OacFunctions.cmake similarity index 75% rename from cmake/OpusFunctions.cmake rename to cmake/OacFunctions.cmake index 2db77d7f8..4c4130f18 100644 --- a/cmake/OpusFunctions.cmake +++ b/cmake/OacFunctions.cmake @@ -1,44 +1,44 @@ -if(__opus_functions) +if(__oac_functions) return() endif() -set(__opus_functions INCLUDED) +set(__oac_functions INCLUDED) -function(get_library_version OPUS_LIBRARY_VERSION OPUS_LIBRARY_VERSION_MAJOR) - file(STRINGS configure.ac opus_lt_current_string +function(get_library_version OAC_LIBRARY_VERSION OAC_LIBRARY_VERSION_MAJOR) + file(STRINGS configure.ac oac_lt_current_string LIMIT_COUNT 1 - REGEX "OPUS_LT_CURRENT=") + REGEX "OAC_LT_CURRENT=") string(REGEX MATCH - "OPUS_LT_CURRENT=([0-9]*)" + "OAC_LT_CURRENT=([0-9]*)" _ - ${opus_lt_current_string}) - set(OPUS_LT_CURRENT ${CMAKE_MATCH_1}) + ${oac_lt_current_string}) + set(OAC_LT_CURRENT ${CMAKE_MATCH_1}) - file(STRINGS configure.ac opus_lt_revision_string + file(STRINGS configure.ac oac_lt_revision_string LIMIT_COUNT 1 - REGEX "OPUS_LT_REVISION=") + REGEX "OAC_LT_REVISION=") string(REGEX MATCH - "OPUS_LT_REVISION=([0-9]*)" + "OAC_LT_REVISION=([0-9]*)" _ - ${opus_lt_revision_string}) - set(OPUS_LT_REVISION ${CMAKE_MATCH_1}) + ${oac_lt_revision_string}) + set(OAC_LT_REVISION ${CMAKE_MATCH_1}) - file(STRINGS configure.ac opus_lt_age_string + file(STRINGS configure.ac oac_lt_age_string LIMIT_COUNT 1 - REGEX "OPUS_LT_AGE=") + REGEX "OAC_LT_AGE=") string(REGEX MATCH - "OPUS_LT_AGE=([0-9]*)" + "OAC_LT_AGE=([0-9]*)" _ - ${opus_lt_age_string}) - set(OPUS_LT_AGE ${CMAKE_MATCH_1}) + ${oac_lt_age_string}) + set(OAC_LT_AGE ${CMAKE_MATCH_1}) - math(EXPR OPUS_LIBRARY_VERSION_MAJOR "${OPUS_LT_CURRENT} - ${OPUS_LT_AGE}") - set(OPUS_LIBRARY_VERSION_MINOR ${OPUS_LT_AGE}) - set(OPUS_LIBRARY_VERSION_PATCH ${OPUS_LT_REVISION}) + math(EXPR OAC_LIBRARY_VERSION_MAJOR "${OAC_LT_CURRENT} - ${OAC_LT_AGE}") + set(OAC_LIBRARY_VERSION_MINOR ${OAC_LT_AGE}) + set(OAC_LIBRARY_VERSION_PATCH ${OAC_LT_REVISION}) set( - OPUS_LIBRARY_VERSION - "${OPUS_LIBRARY_VERSION_MAJOR}.${OPUS_LIBRARY_VERSION_MINOR}.${OPUS_LIBRARY_VERSION_PATCH}" + OAC_LIBRARY_VERSION + "${OAC_LIBRARY_VERSION_MAJOR}.${OAC_LIBRARY_VERSION_MINOR}.${OAC_LIBRARY_VERSION_PATCH}" PARENT_SCOPE) - set(OPUS_LIBRARY_VERSION_MAJOR ${OPUS_LIBRARY_VERSION_MAJOR} PARENT_SCOPE) + set(OAC_LIBRARY_VERSION_MAJOR ${OAC_LIBRARY_VERSION_MAJOR} PARENT_SCOPE) endfunction() function(check_flag NAME FLAG) @@ -50,10 +50,10 @@ include(CheckIncludeFile) # This function determines if the compiler has support for SSE, SSE2, SSE4.1, AVX, # AVX2 and FMA. Should the target systems potentially lack SSE support, the -# OPUS_MAY_HAVE_SSE option is recommended for use. If, however, the target system is -# assured to support SSE, the OPUS_PRESUME_SSE option can be employed, thus +# OAC_MAY_HAVE_SSE option is recommended for use. If, however, the target system is +# assured to support SSE, the OAC_PRESUME_SSE option can be employed, thus # eliminating the necessity for an SSE runtime check. -function(opus_detect_sse COMPILER_SUPPORT_SIMD) +function(oac_detect_sse COMPILER_SUPPORT_SIMD) message(STATUS "Check SIMD support by compiler") check_include_file(xmmintrin.h HAVE_XMMINTRIN_H) # SSE1 if(HAVE_XMMINTRIN_H) @@ -133,7 +133,7 @@ function(opus_detect_sse COMPILER_SUPPORT_SIMD) endif() endfunction() -function(opus_detect_neon COMPILER_SUPPORT_NEON) +function(oac_detect_neon COMPILER_SUPPORT_NEON) if(CMAKE_SYSTEM_PROCESSOR MATCHES "(arm|aarch64|ARM)") message(STATUS "Check NEON support by compiler") check_include_file(arm_neon.h HAVE_ARM_NEON_H) @@ -143,9 +143,9 @@ function(opus_detect_neon COMPILER_SUPPORT_NEON) endif() endfunction() -function(opus_supports_cpu_detection RUNTIME_CPU_CAPABILITY_DETECTION) +function(oac_supports_cpu_detection RUNTIME_CPU_CAPABILITY_DETECTION) set(RUNTIME_CPU_CAPABILITY_DETECTION 0 PARENT_SCOPE) - if(OPUS_CPU_X86 OR OPUS_CPU_X64) + if(OAC_CPU_X86 OR OAC_CPU_X64) if(MSVC) check_include_file(intrin.h HAVE_INTRIN_H) if(HAVE_INTRIN_H) @@ -165,7 +165,7 @@ function(opus_supports_cpu_detection RUNTIME_CPU_CAPABILITY_DETECTION) set(RUNTIME_CPU_CAPABILITY_DETECTION 1 PARENT_SCOPE) endif() endif() - elseif(OPUS_CPU_ARM) + elseif(OAC_CPU_ARM) # ARM cpu detection is implemented for Windows, Linux, Android, FreeBSD # and OpenBSD. if (CMAKE_SYSTEM_NAME MATCHES "(Windows|Linux|Android|FreeBSD|OpenBSD)") @@ -181,15 +181,15 @@ function(add_sources_group target group) source_group(${group} FILES ${ARGN}) endfunction() -function(get_opus_sources SOURCE_GROUP MAKE_FILE SOURCES) +function(get_oac_sources SOURCE_GROUP MAKE_FILE SOURCES) # read file, each item in list is one group - file(STRINGS ${MAKE_FILE} opus_sources) + file(STRINGS ${MAKE_FILE} oac_sources) # add wildcard for regex match string(CONCAT SOURCE_GROUP ${SOURCE_GROUP} ".*$") # find group - foreach(val IN LISTS opus_sources) + foreach(val IN LISTS oac_sources) if(val MATCHES ${SOURCE_GROUP}) list(LENGTH val list_length) if(${list_length} EQUAL 1) diff --git a/cmake/OacPackageVersion.cmake b/cmake/OacPackageVersion.cmake new file mode 100644 index 000000000..70a79a6f7 --- /dev/null +++ b/cmake/OacPackageVersion.cmake @@ -0,0 +1,70 @@ +if(__oac_version) + return() +endif() +set(__oac_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 OAC_PACKAGE_VERSION) + if(OAC_PACKAGE_VERSION) + string(STRIP ${OAC_PACKAGE_VERSION}, OAC_PACKAGE_VERSION) + string(REPLACE \n + "" + OAC_PACKAGE_VERSION + ${OAC_PACKAGE_VERSION}) + string(REPLACE , + "" + OAC_PACKAGE_VERSION + ${OAC_PACKAGE_VERSION}) + + string(SUBSTRING ${OAC_PACKAGE_VERSION} + 1 + -1 + OAC_PACKAGE_VERSION) + message(STATUS "Oac package version from git repo: ${OAC_PACKAGE_VERSION}") + endif() + + elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/package_version" + AND NOT OAC_PACKAGE_VERSION) + # Not a git repo, lets' try to parse it from package_version file if exists + file(STRINGS package_version OAC_PACKAGE_VERSION + LIMIT_COUNT 1 + REGEX "PACKAGE_VERSION=") + string(REPLACE "PACKAGE_VERSION=" + "" + OAC_PACKAGE_VERSION + ${OAC_PACKAGE_VERSION}) + string(REPLACE "\"" + "" + OAC_PACKAGE_VERSION + ${OAC_PACKAGE_VERSION}) + # In case we have a unknown dist here we just replace it with 0 + string(REPLACE "unknown" + "0" + OAC_PACKAGE_VERSION + ${OAC_PACKAGE_VERSION}) + message(STATUS "Oac package version from package_version file: ${OAC_PACKAGE_VERSION}") + endif() + + if(OAC_PACKAGE_VERSION) + string(REGEX + REPLACE "^([0-9]+.[0-9]+\\.?([0-9]+)?).*" + "\\1" + OAC_PROJECT_VERSION + ${OAC_PACKAGE_VERSION}) + else() + # fail to parse version from git and package version + message(WARNING "Could not get package version.") + set(OAC_PACKAGE_VERSION 0) + set(OAC_PROJECT_VERSION 0) + endif() + + message(STATUS "Oac project version: ${OAC_PROJECT_VERSION}") + + set(PACKAGE_VERSION ${OAC_PACKAGE_VERSION} PARENT_SCOPE) + set(PROJECT_VERSION ${OAC_PROJECT_VERSION} PARENT_SCOPE) +endfunction() diff --git a/cmake/OacSources.cmake b/cmake/OacSources.cmake new file mode 100644 index 000000000..25b2bafa2 --- /dev/null +++ b/cmake/OacSources.cmake @@ -0,0 +1,72 @@ +if(__oac_sources) + return() +endif() +set(__oac_sources INCLUDED) + +include(OacFunctions) + +get_oac_sources(SILK_HEAD silk_headers.mk silk_headers) +get_oac_sources(SILK_SOURCES silk_sources.mk silk_sources) +get_oac_sources(SILK_SOURCES_FLOAT silk_sources.mk silk_sources_float) +get_oac_sources(SILK_SOURCES_FIXED silk_sources.mk silk_sources_fixed) +get_oac_sources(SILK_SOURCES_X86_RTCD silk_sources.mk silk_sources_x86_rtcd) +get_oac_sources(SILK_SOURCES_SSE4_1 silk_sources.mk silk_sources_sse4_1) +get_oac_sources(SILK_SOURCES_FIXED_SSE4_1 silk_sources.mk + silk_sources_fixed_sse4_1) +get_oac_sources(SILK_SOURCES_AVX2 silk_sources.mk silk_sources_avx2) +get_oac_sources(SILK_SOURCES_FLOAT_AVX2 silk_sources.mk silk_sources_float_avx2) +get_oac_sources(SILK_SOURCES_ARM_RTCD silk_sources.mk silk_sources_arm_rtcd) +get_oac_sources(SILK_SOURCES_ARM_NEON_INTR silk_sources.mk + silk_sources_arm_neon_intr) +get_oac_sources(SILK_SOURCES_FIXED_ARM_NEON_INTR silk_sources.mk + silk_sources_fixed_arm_neon_intr) + +get_oac_sources(OAC_HEAD oac_headers.mk oac_headers) +get_oac_sources(OAC_SOURCES oac_sources.mk oac_sources) +get_oac_sources(OAC_SOURCES_FLOAT oac_sources.mk oac_sources_float) + +get_oac_sources(CELT_HEAD celt_headers.mk celt_headers) +get_oac_sources(CELT_SOURCES celt_sources.mk celt_sources) +get_oac_sources(CELT_SOURCES_X86_RTCD celt_sources.mk celt_sources_x86_rtcd) +get_oac_sources(CELT_SOURCES_SSE celt_sources.mk celt_sources_sse) +get_oac_sources(CELT_SOURCES_SSE2 celt_sources.mk celt_sources_sse2) +get_oac_sources(CELT_SOURCES_SSE4_1 celt_sources.mk celt_sources_sse4_1) +get_oac_sources(CELT_SOURCES_AVX2 celt_sources.mk celt_sources_avx2) +get_oac_sources(CELT_SOURCES_ARM_RTCD celt_sources.mk celt_sources_arm_rtcd) +get_oac_sources(CELT_SOURCES_ARM_ASM celt_sources.mk celt_sources_arm_asm) +get_oac_sources(CELT_AM_SOURCES_ARM_ASM celt_sources.mk + celt_am_sources_arm_asm) +get_oac_sources(CELT_SOURCES_ARM_NEON_INTR celt_sources.mk + celt_sources_arm_neon_intr) +get_oac_sources(CELT_SOURCES_ARM_NE10 celt_sources.mk celt_sources_arm_ne10) + +get_oac_sources(DEEP_PLC_HEAD lpcnet_headers.mk deep_plc_headers) +get_oac_sources(DRED_HEAD lpcnet_headers.mk dred_headers) +get_oac_sources(OSCE_HEAD lpcnet_headers.mk osce_headers) +get_oac_sources(DEEP_PLC_SOURCES lpcnet_sources.mk deep_plc_sources) +get_oac_sources(DRED_SOURCES lpcnet_sources.mk dred_sources) +get_oac_sources(OSCE_SOURCES lpcnet_sources.mk osce_sources) +get_oac_sources(DNN_SOURCES_X86_RTCD lpcnet_sources.mk dnn_sources_x86_rtcd) +get_oac_sources(DNN_SOURCES_SSE2 lpcnet_sources.mk dnn_sources_sse2) +get_oac_sources(DNN_SOURCES_SSE4_1 lpcnet_sources.mk dnn_sources_sse4_1) +get_oac_sources(DNN_SOURCES_AVX2 lpcnet_sources.mk dnn_sources_avx2) +get_oac_sources(DNN_SOURCES_NEON lpcnet_sources.mk dnn_sources_arm_neon) +get_oac_sources(DNN_SOURCES_DOTPROD lpcnet_sources.mk dnn_sources_arm_dotprod) +get_oac_sources(DNN_SOURCES_ARM_RTCD lpcnet_sources.mk dnn_sources_arm_rtcd) + +get_oac_sources(oac_demo_SOURCES Makefile.am oac_demo_sources) +get_oac_sources(oac_custom_demo_SOURCES Makefile.am oac_custom_demo_sources) +get_oac_sources(oac_compare_SOURCES Makefile.am oac_compare_sources) +get_oac_sources(tests_test_oac_api_SOURCES Makefile.am test_oac_api_sources) +get_oac_sources(tests_test_oac_encode_SOURCES Makefile.am + test_oac_encode_sources) +get_oac_sources(tests_test_oac_extensions_SOURCES Makefile.am + test_oac_extensions_sources) +get_oac_sources(tests_test_oac_decode_SOURCES Makefile.am + test_oac_decode_sources) +get_oac_sources(tests_test_oac_padding_SOURCES Makefile.am + test_oac_padding_sources) +get_oac_sources(tests_test_oac_dred_SOURCES Makefile.am + test_oac_dred_sources) +get_oac_sources(tests_test_oac_custom_SOURCES Makefile.am + test_oac_custom_sources) diff --git a/cmake/OpusConfig.cmake.in b/cmake/OpusConfig.cmake.in deleted file mode 100644 index 0b21231d4..000000000 --- a/cmake/OpusConfig.cmake.in +++ /dev/null @@ -1,20 +0,0 @@ -set(OPUS_VERSION @PROJECT_VERSION@) -set(OPUS_VERSION_STRING @PROJECT_VERSION@) -set(OPUS_VERSION_MAJOR @PROJECT_VERSION_MAJOR@) -set(OPUS_VERSION_MINOR @PROJECT_VERSION_MINOR@) -set(OPUS_VERSION_PATCH @PROJECT_VERSION_PATCH@) - -@PACKAGE_INIT@ - -set_and_check(OPUS_INCLUDE_DIR "@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) - -set(OPUS_LIBRARY Opus::opus) -set(OPUS_LIBRARIES Opus::opus) - -check_required_components(Opus) - -set(OPUS_FOUND 1) diff --git a/cmake/OpusPackageVersion.cmake b/cmake/OpusPackageVersion.cmake deleted file mode 100644 index 447ce3b17..000000000 --- a/cmake/OpusPackageVersion.cmake +++ /dev/null @@ -1,70 +0,0 @@ -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() diff --git a/cmake/OpusSources.cmake b/cmake/OpusSources.cmake deleted file mode 100644 index 06cb0d4fa..000000000 --- a/cmake/OpusSources.cmake +++ /dev/null @@ -1,72 +0,0 @@ -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_AVX2 silk_sources.mk silk_sources_avx2) -get_opus_sources(SILK_SOURCES_FLOAT_AVX2 silk_sources.mk silk_sources_float_avx2) -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_AVX2 celt_sources.mk celt_sources_avx2) -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) -get_opus_sources(CELT_SOURCES_ARM_NEON_INTR celt_sources.mk - celt_sources_arm_neon_intr) -get_opus_sources(CELT_SOURCES_ARM_NE10 celt_sources.mk celt_sources_arm_ne10) - -get_opus_sources(DEEP_PLC_HEAD lpcnet_headers.mk deep_plc_headers) -get_opus_sources(DRED_HEAD lpcnet_headers.mk dred_headers) -get_opus_sources(OSCE_HEAD lpcnet_headers.mk osce_headers) -get_opus_sources(DEEP_PLC_SOURCES lpcnet_sources.mk deep_plc_sources) -get_opus_sources(DRED_SOURCES lpcnet_sources.mk dred_sources) -get_opus_sources(OSCE_SOURCES lpcnet_sources.mk osce_sources) -get_opus_sources(DNN_SOURCES_X86_RTCD lpcnet_sources.mk dnn_sources_x86_rtcd) -get_opus_sources(DNN_SOURCES_SSE2 lpcnet_sources.mk dnn_sources_sse2) -get_opus_sources(DNN_SOURCES_SSE4_1 lpcnet_sources.mk dnn_sources_sse4_1) -get_opus_sources(DNN_SOURCES_AVX2 lpcnet_sources.mk dnn_sources_avx2) -get_opus_sources(DNN_SOURCES_NEON lpcnet_sources.mk dnn_sources_arm_neon) -get_opus_sources(DNN_SOURCES_DOTPROD lpcnet_sources.mk dnn_sources_arm_dotprod) -get_opus_sources(DNN_SOURCES_ARM_RTCD lpcnet_sources.mk dnn_sources_arm_rtcd) - -get_opus_sources(opus_demo_SOURCES Makefile.am opus_demo_sources) -get_opus_sources(opus_custom_demo_SOURCES Makefile.am opus_custom_demo_sources) -get_opus_sources(opus_compare_SOURCES Makefile.am opus_compare_sources) -get_opus_sources(tests_test_opus_api_SOURCES Makefile.am test_opus_api_sources) -get_opus_sources(tests_test_opus_encode_SOURCES Makefile.am - test_opus_encode_sources) -get_opus_sources(tests_test_opus_extensions_SOURCES Makefile.am - test_opus_extensions_sources) -get_opus_sources(tests_test_opus_decode_SOURCES Makefile.am - test_opus_decode_sources) -get_opus_sources(tests_test_opus_padding_SOURCES Makefile.am - test_opus_padding_sources) -get_opus_sources(tests_test_opus_dred_SOURCES Makefile.am - test_opus_dred_sources) -get_opus_sources(tests_test_opus_custom_SOURCES Makefile.am - test_opus_custom_sources) diff --git a/cmake/README.md b/cmake/README.md index d8e4978f6..1fee11524 100644 --- a/cmake/README.md +++ b/cmake/README.md @@ -1,6 +1,6 @@ -# Using CMake for the Opus Project +# Using CMake for the Oac 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. +This guide provides instructions for using CMake to build the Oac 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/). @@ -14,48 +14,48 @@ Before proceeding, make sure you have the following prerequisites installed: ## Build Instructions -Follow the steps below to build the Opus project using CMake: +Follow the steps below to build the Oac project using CMake: -1. Clone the Opus repository using Git: +1. Clone the Oac repository using Git: ```shell - git clone https://gitlab.xiph.org/xiph/opus + git clone https://github.com/AOMediaCodec/oac.git ``` -2. Create a build directory within the Opus repository: +2. Create a build directory within the Oac repository: ```shell - cd opus + cd oac 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. + - `OAC_BUILD_SHARED_LIBRARY`: build shared library. + - `OAC_BUILD_TESTING`: build tests. + - `OAC_BUILD_PROGRAMS`: build programs. + - `OAC_CUSTOM_MODES`, enable non-Oac 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 + cmake .. -DOAC_BUILD_PROGRAMS=ON -DOAC_BUILD_TESTING=ON ``` -4. Build the Opus project: +4. Build the Oac project: ```shell cmake --build . ``` -5. After a successful build, you can find the compiled Opus library and associated files in the build directory. +5. After a successful build, you can find the compiled Oac 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. +Oac 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: +To run the Oac tests using CTest, follow these steps: 1. Navigate to the build directory after configuring and building the project with CMake: @@ -77,7 +77,7 @@ 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: +CMake aims to provide broad platform support, allowing the Oac project to be built and used on major operating systems and platforms. The supported platforms include: - Windows - macOS @@ -85,9 +85,9 @@ CMake aims to provide broad platform support, allowing the Opus project to be bu - 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. +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 Oac 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). +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 Oac project, we encourage you to file an issue in the [project's issue tracker](https://github.com/AOMediaCodec/oac/issues). When reporting an issue, please provide the following information to help us understand and reproduce the configuration problem effectively: @@ -98,9 +98,9 @@ When reporting an issue, please provide the following information to help us und 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. +By providing thorough information when reporting configuration issues, you contribute to improving the Oac 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. +We appreciate your help in identifying and addressing any configuration-related problems, ensuring a better experience for all users of the Oac project. ## Platform Specific Examples diff --git a/cmake/cpu_info_by_asm.c b/cmake/cpu_info_by_asm.c index 1a70a815a..11bcda50c 100644 --- a/cmake/cpu_info_by_asm.c +++ b/cmake/cpu_info_by_asm.c @@ -10,22 +10,22 @@ int main() { __asm__ __volatile__ ( "xchg %%ebx, %1\n" "cpuid\n" - "xchg %%ebx, %1\n": + "xchg %%ebx, %1\n" : "=a" (CPUInfo0), "=r" (CPUInfo1), "=c" (CPUInfo2), "=d" (CPUInfo3) : "0" (InfoType), "2" (0) - ); + ); #else __asm__ __volatile__ ( - "cpuid": + "cpuid" : "=a" (CPUInfo0), "=b" (CPUInfo1), "=c" (CPUInfo2), "=d" (CPUInfo3) : "0" (InfoType), "2" (0) - ); + ); #endif return 0; } diff --git a/configure.ac b/configure.ac index 3d7e816b8..c2de9f3c9 100644 --- a/configure.ac +++ b/configure.ac @@ -12,9 +12,9 @@ m4_define([CURRENT_VERSION], printf "unknown" fi ])) -AC_INIT([opus],[CURRENT_VERSION],[opus@xiph.org]) +AC_INIT([oac],[CURRENT_VERSION],[oac@xiph.org]) -AC_CONFIG_SRCDIR(src/opus_encoder.c) +AC_CONFIG_SRCDIR(src/oac_encoder.c) AC_CONFIG_MACRO_DIR([m4]) dnl enable silent rules on automake 1.11 and later @@ -22,13 +22,13 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # For libtool. dnl Please update these for releases. -OPUS_LT_CURRENT=11 -OPUS_LT_REVISION=1 -OPUS_LT_AGE=11 +OAC_LT_CURRENT=0 +OAC_LT_REVISION=0 +OAC_LT_AGE=0 -AC_SUBST(OPUS_LT_CURRENT) -AC_SUBST(OPUS_LT_REVISION) -AC_SUBST(OPUS_LT_AGE) +AC_SUBST(OAC_LT_CURRENT) +AC_SUBST(OAC_LT_REVISION) +AC_SUBST(OAC_LT_AGE) AM_INIT_AUTOMAKE([no-define]) AM_MAINTAINER_MODE([enable]) @@ -42,7 +42,7 @@ AC_C_INLINE AM_PROG_AS -AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS]) +AC_DEFINE([OAC_BUILD], [], [This is a build of OAC]) #Use a hacked up version of autoconf's AC_C_RESTRICT because it's not #strong enough a test to detect old buggy versions of GCC (e.g. 2.95.3) @@ -147,14 +147,6 @@ AS_IF([test "$enable_float_api" = "no"],[ AC_DEFINE([DISABLE_FLOAT_API], [1], [Do not build the float API]) ]) -AC_ARG_ENABLE([fixed-res24], - [AS_HELP_STRING([--disable-fixed-res24], [use 16-bit (instead of 24-bit) internal resolution for fixed-point implementation])],, - [enable_fixed_res24=yes]) - -AS_IF([test "$enable_fixed_res24" = "yes"],[ - AC_DEFINE([ENABLE_RES24], [1], [24-bit internal resolution for fixed-point]) -]) - AC_ARG_ENABLE([qext], [AS_HELP_STRING([--enable-qext], [enable scalable quality extension])],, [enable_qext=no]) @@ -165,7 +157,7 @@ AS_IF([test "$enable_qext" = "yes"],[ AM_CONDITIONAL([ENABLE_QEXT], [test "$enable_qext" = "yes"]) AC_ARG_ENABLE([custom-modes], - [AS_HELP_STRING([--enable-custom-modes], [enable non-Opus modes, e.g. 44.1 kHz & 2^n frames])],, + [AS_HELP_STRING([--enable-custom-modes], [enable non-Oac modes, e.g. 44.1 kHz & 2^n frames])],, [enable_custom_modes=no]) AS_IF([test "$enable_custom_modes" = "yes"],[ @@ -173,16 +165,16 @@ AS_IF([test "$enable_custom_modes" = "yes"],[ PC_BUILD="$PC_BUILD, custom modes" ]) -AC_ARG_ENABLE([opus-custom-api], - [AS_HELP_STRING([--enable-opus-custom-api], [enable Opus custom API])],, - [enable_opus_custom_api=no]) +AC_ARG_ENABLE([oac-custom-api], + [AS_HELP_STRING([--enable-oac-custom-api], [enable Oac custom API])],, + [enable_oac_custom_api=no]) -AS_IF([test "$enable_opus_custom_api" = "yes"],[ - AC_DEFINE([ENABLE_OPUS_CUSTOM_API], [1], [Opus custom API]) - PC_BUILD="$PC_BUILD, Opus custom API" +AS_IF([test "$enable_oac_custom_api" = "yes"],[ + AC_DEFINE([ENABLE_OAC_CUSTOM_API], [1], [Oac custom API]) + PC_BUILD="$PC_BUILD, Oac custom API" ]) -AM_CONDITIONAL([CUSTOM_MODES], [test "$enable_custom_modes" = "yes" || test "$enable_opus_custom_api" = "yes"]) +AM_CONDITIONAL([CUSTOM_MODES], [test "$enable_custom_modes" = "yes" || test "$enable_oac_custom_api" = "yes"]) AC_ARG_ENABLE([dred], [AS_HELP_STRING([--enable-dred], [use Deep REDundancy (DRED)])],, @@ -203,7 +195,7 @@ AS_IF([test "$enable_deep_plc" = "yes" || test "$enable_dred" = "yes" || test "$ AM_CONDITIONAL([ENABLE_DEEP_PLC], [test "$enable_deep_plc" = "yes" || test "$enable_dred" = "yes" || test "$enable_osce" = "yes" || test "$enable_osce_training_data" = "yes"]) AC_ARG_ENABLE([lossgen], - [AS_HELP_STRING([--enable-lossgen], [build opus_demo with packet loss simulator])],, + [AS_HELP_STRING([--enable-lossgen], [build oac_demo with packet loss simulator])],, [enable_lossgen=no]) AS_IF([test "$enable_lossgen" = "yes"],[ @@ -253,31 +245,31 @@ AS_IF([test x"${enable_asm}" = x"yes"],[ dnl Currently we only have asm for fixed-point #AS_IF([test "$enable_float" != "yes"],[ cpu_arm=yes - AC_DEFINE([OPUS_ARM_ASM], [], [Make use of ARM asm optimization]) + AC_DEFINE([OAC_ARM_ASM], [], [Make use of ARM asm optimization]) AS_GCC_INLINE_ASSEMBLY( [inline_optimization="ARM"], [inline_optimization="disabled"] ) - AS_ASM_ARM_EDSP([OPUS_ARM_INLINE_EDSP=1],[OPUS_ARM_INLINE_EDSP=0]) - AS_ASM_ARM_MEDIA([OPUS_ARM_INLINE_MEDIA=1], - [OPUS_ARM_INLINE_MEDIA=0]) - AS_ASM_ARM_NEON([OPUS_ARM_INLINE_NEON=1],[OPUS_ARM_INLINE_NEON=0]) + AS_ASM_ARM_EDSP([OAC_ARM_INLINE_EDSP=1],[OAC_ARM_INLINE_EDSP=0]) + AS_ASM_ARM_MEDIA([OAC_ARM_INLINE_MEDIA=1], + [OAC_ARM_INLINE_MEDIA=0]) + AS_ASM_ARM_NEON([OAC_ARM_INLINE_NEON=1],[OAC_ARM_INLINE_NEON=0]) AS_IF([test x"$inline_optimization" = x"ARM"],[ - AM_CONDITIONAL([OPUS_ARM_INLINE_ASM],[true]) - AC_DEFINE([OPUS_ARM_INLINE_ASM], 1, + AM_CONDITIONAL([OAC_ARM_INLINE_ASM],[true]) + AC_DEFINE([OAC_ARM_INLINE_ASM], 1, [Use generic ARMv4 inline asm optimizations]) - AS_IF([test x"$OPUS_ARM_INLINE_EDSP" = x"1"],[ - AC_DEFINE([OPUS_ARM_INLINE_EDSP], [1], + AS_IF([test x"$OAC_ARM_INLINE_EDSP" = x"1"],[ + AC_DEFINE([OAC_ARM_INLINE_EDSP], [1], [Use ARMv5E inline asm optimizations]) inline_optimization="$inline_optimization (EDSP)" ]) - AS_IF([test x"$OPUS_ARM_INLINE_MEDIA" = x"1"],[ - AC_DEFINE([OPUS_ARM_INLINE_MEDIA], [1], + AS_IF([test x"$OAC_ARM_INLINE_MEDIA" = x"1"],[ + AC_DEFINE([OAC_ARM_INLINE_MEDIA], [1], [Use ARMv6 inline asm optimizations]) inline_optimization="$inline_optimization (Media)" ]) - AS_IF([test x"$OPUS_ARM_INLINE_NEON" = x"1"],[ - AC_DEFINE([OPUS_ARM_INLINE_NEON], 1, + AS_IF([test x"$OAC_ARM_INLINE_NEON" = x"1"],[ + AC_DEFINE([OAC_ARM_INLINE_NEON], 1, [Use ARM NEON inline asm optimizations]) inline_optimization="$inline_optimization (NEON)" ]) @@ -285,98 +277,98 @@ AS_IF([test x"${enable_asm}" = x"yes"],[ dnl We need Perl to translate RVCT-syntax asm to gas syntax. AC_CHECK_PROG([HAVE_PERL], perl, yes, no) AS_IF([test x"$HAVE_PERL" = x"yes"],[ - AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM],[true]) + AM_CONDITIONAL([OAC_ARM_EXTERNAL_ASM],[true]) asm_optimization="ARM" - AS_IF([test x"$OPUS_ARM_INLINE_EDSP" = x"1"], [ - OPUS_ARM_PRESUME_EDSP=1 - OPUS_ARM_MAY_HAVE_EDSP=1 + AS_IF([test x"$OAC_ARM_INLINE_EDSP" = x"1"], [ + OAC_ARM_PRESUME_EDSP=1 + OAC_ARM_MAY_HAVE_EDSP=1 ], [ - OPUS_ARM_PRESUME_EDSP=0 - OPUS_ARM_MAY_HAVE_EDSP=0 + OAC_ARM_PRESUME_EDSP=0 + OAC_ARM_MAY_HAVE_EDSP=0 ]) - AS_IF([test x"$OPUS_ARM_INLINE_MEDIA" = x"1"], [ - OPUS_ARM_PRESUME_MEDIA=1 - OPUS_ARM_MAY_HAVE_MEDIA=1 + AS_IF([test x"$OAC_ARM_INLINE_MEDIA" = x"1"], [ + OAC_ARM_PRESUME_MEDIA=1 + OAC_ARM_MAY_HAVE_MEDIA=1 ], [ - OPUS_ARM_PRESUME_MEDIA=0 - OPUS_ARM_MAY_HAVE_MEDIA=0 + OAC_ARM_PRESUME_MEDIA=0 + OAC_ARM_MAY_HAVE_MEDIA=0 ]) - AS_IF([test x"$OPUS_ARM_INLINE_NEON" = x"1"], [ - OPUS_ARM_PRESUME_NEON=1 - OPUS_ARM_MAY_HAVE_NEON=1 + AS_IF([test x"$OAC_ARM_INLINE_NEON" = x"1"], [ + OAC_ARM_PRESUME_NEON=1 + OAC_ARM_MAY_HAVE_NEON=1 ], [ - OPUS_ARM_PRESUME_NEON=0 - OPUS_ARM_MAY_HAVE_NEON=0 + OAC_ARM_PRESUME_NEON=0 + OAC_ARM_MAY_HAVE_NEON=0 ]) AS_IF([test x"$enable_rtcd" = x"yes"],[ - AS_IF([test x"$OPUS_ARM_MAY_HAVE_EDSP" != x"1"],[ + AS_IF([test x"$OAC_ARM_MAY_HAVE_EDSP" != x"1"],[ AC_MSG_NOTICE( [Trying to force-enable armv5e EDSP instructions...]) - AS_ASM_ARM_EDSP_FORCE([OPUS_ARM_MAY_HAVE_EDSP=1]) + AS_ASM_ARM_EDSP_FORCE([OAC_ARM_MAY_HAVE_EDSP=1]) ]) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_MEDIA" != x"1"],[ + AS_IF([test x"$OAC_ARM_MAY_HAVE_MEDIA" != x"1"],[ AC_MSG_NOTICE( [Trying to force-enable ARMv6 media instructions...]) - AS_ASM_ARM_MEDIA_FORCE([OPUS_ARM_MAY_HAVE_MEDIA=1]) + AS_ASM_ARM_MEDIA_FORCE([OAC_ARM_MAY_HAVE_MEDIA=1]) ]) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON" != x"1"],[ + AS_IF([test x"$OAC_ARM_MAY_HAVE_NEON" != x"1"],[ AC_MSG_NOTICE( [Trying to force-enable NEON instructions...]) - AS_ASM_ARM_NEON_FORCE([OPUS_ARM_MAY_HAVE_NEON=1]) + AS_ASM_ARM_NEON_FORCE([OAC_ARM_MAY_HAVE_NEON=1]) ]) ]) rtcd_support= - AS_IF([test x"$OPUS_ARM_MAY_HAVE_EDSP" = x"1"],[ - AC_DEFINE(OPUS_ARM_MAY_HAVE_EDSP, 1, + AS_IF([test x"$OAC_ARM_MAY_HAVE_EDSP" = x"1"],[ + AC_DEFINE(OAC_ARM_MAY_HAVE_EDSP, 1, [Define if assembler supports EDSP instructions]) - AS_IF([test x"$OPUS_ARM_PRESUME_EDSP" = x"1"],[ - AC_DEFINE(OPUS_ARM_PRESUME_EDSP, 1, + AS_IF([test x"$OAC_ARM_PRESUME_EDSP" = x"1"],[ + AC_DEFINE(OAC_ARM_PRESUME_EDSP, 1, [Define if binary requires EDSP instruction support]) asm_optimization="$asm_optimization (EDSP)" ], [rtcd_support="$rtcd_support (EDSP)"] ) ]) - AC_SUBST(OPUS_ARM_MAY_HAVE_EDSP) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_MEDIA" = x"1"],[ - AC_DEFINE(OPUS_ARM_MAY_HAVE_MEDIA, 1, + AC_SUBST(OAC_ARM_MAY_HAVE_EDSP) + AS_IF([test x"$OAC_ARM_MAY_HAVE_MEDIA" = x"1"],[ + AC_DEFINE(OAC_ARM_MAY_HAVE_MEDIA, 1, [Define if assembler supports ARMv6 media instructions]) - AS_IF([test x"$OPUS_ARM_PRESUME_MEDIA" = x"1"],[ - AC_DEFINE(OPUS_ARM_PRESUME_MEDIA, 1, + AS_IF([test x"$OAC_ARM_PRESUME_MEDIA" = x"1"],[ + AC_DEFINE(OAC_ARM_PRESUME_MEDIA, 1, [Define if binary requires ARMv6 media instruction support]) asm_optimization="$asm_optimization (Media)" ], [rtcd_support="$rtcd_support (Media)"] ) ]) - AC_SUBST(OPUS_ARM_MAY_HAVE_MEDIA) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON" = x"1"],[ - AC_DEFINE(OPUS_ARM_MAY_HAVE_NEON, 1, + AC_SUBST(OAC_ARM_MAY_HAVE_MEDIA) + AS_IF([test x"$OAC_ARM_MAY_HAVE_NEON" = x"1"],[ + AC_DEFINE(OAC_ARM_MAY_HAVE_NEON, 1, [Define if compiler supports NEON instructions]) - AS_IF([test x"$OPUS_ARM_PRESUME_NEON" = x"1"], [ - AC_DEFINE(OPUS_ARM_PRESUME_NEON, 1, + AS_IF([test x"$OAC_ARM_PRESUME_NEON" = x"1"], [ + AC_DEFINE(OAC_ARM_PRESUME_NEON, 1, [Define if binary requires NEON instruction support]) asm_optimization="$asm_optimization (NEON)" ], [rtcd_support="$rtcd_support (NEON)"] ) ]) - AC_SUBST(OPUS_ARM_MAY_HAVE_NEON) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_DOTPROD" = x"1"],[ - AC_DEFINE(OPUS_ARM_MAY_HAVE_DOTPROD, 1, + AC_SUBST(OAC_ARM_MAY_HAVE_NEON) + AS_IF([test x"$OAC_ARM_MAY_HAVE_DOTPROD" = x"1"],[ + AC_DEFINE(OAC_ARM_MAY_HAVE_DOTPROD, 1, [Define if compiler supports DOTPROD instructions]) - AS_IF([test x"$OPUS_ARM_PRESUME_DOTPROD" = x"1"], [ - AC_DEFINE(OPUS_ARM_PRESUME_DOTPROD, 1, + AS_IF([test x"$OAC_ARM_PRESUME_DOTPROD" = x"1"], [ + AC_DEFINE(OAC_ARM_PRESUME_DOTPROD, 1, [Define if binary requires DOTPROD instruction support]) asm_optimization="$asm_optimization (DOTPROD)" ], [rtcd_support="$rtcd_support (DOTPROD)"] ) ]) - AC_SUBST(OPUS_ARM_MAY_HAVE_DOTPROD) + AC_SUBST(OAC_ARM_MAY_HAVE_DOTPROD) dnl Make sure turning on RTCD gets us at least one dnl instruction set. AS_IF([test x"$rtcd_support" != x""], @@ -405,9 +397,9 @@ AS_IF([test x"${enable_asm}" = x"yes"],[ asm_optimization="disabled" ]) -AM_CONDITIONAL([OPUS_ARM_INLINE_ASM], +AM_CONDITIONAL([OAC_ARM_INLINE_ASM], [test x"${inline_optimization%% *}" = x"ARM"]) -AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM], +AM_CONDITIONAL([OAC_ARM_EXTERNAL_ASM], [test x"${asm_optimization%% *}" = x"ARM"]) AM_CONDITIONAL([HAVE_SSE], [false]) @@ -447,7 +439,7 @@ AS_VAR_SET_IF([X86_AVX2_CFLAGS], [], [AS_VAR_SET([X86_AVX2_CFLAGS], "DEFAULT_X86 AS_VAR_SET_IF([ARM_NEON_INTR_CFLAGS], [], [AS_VAR_SET([ARM_NEON_INTR_CFLAGS], ["$RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS"])]) AS_VAR_SET_IF([ARM_DOTPROD_INTR_CFLAGS], [], [AS_VAR_SET([ARM_DOTPROD_INTR_CFLAGS], ["DEFAULT_ARM_DOTPROD_INTR_CFLAGS"])]) -AC_DEFUN([OPUS_PATH_NE10], +AC_DEFUN([OAC_PATH_NE10], [ AC_ARG_WITH(NE10, AS_HELP_STRING([--with-NE10=PFX],[prefix where libNE10 is installed (optional)]), @@ -527,11 +519,11 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ [arm*|aarch64*], [ cpu_arm=yes - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [ARM Neon], [$ARM_NEON_INTR_CFLAGS], - [OPUS_ARM_MAY_HAVE_NEON_INTR], - [OPUS_ARM_PRESUME_NEON_INTR], + [OAC_ARM_MAY_HAVE_NEON_INTR], + [OAC_ARM_PRESUME_NEON_INTR], [[#include ]], [[ @@ -540,40 +532,40 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ return (int)vgetq_lane_f32(SUMM, 0); ]] ) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"], + AS_IF([test x"$OAC_ARM_MAY_HAVE_NEON_INTR" = x"1" && test x"$OAC_ARM_PRESUME_NEON_INTR" != x"1"], [ - OPUS_ARM_NEON_INTR_CFLAGS="$ARM_NEON_INTR_CFLAGS" - AC_SUBST([OPUS_ARM_NEON_INTR_CFLAGS]) + OAC_ARM_NEON_INTR_CFLAGS="$ARM_NEON_INTR_CFLAGS" + AC_SUBST([OAC_ARM_NEON_INTR_CFLAGS]) ] ) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"], + AS_IF([test x"$OAC_ARM_MAY_HAVE_NEON_INTR" = x"1"], [ - AC_DEFINE([OPUS_ARM_MAY_HAVE_NEON_INTR], 1, [Compiler supports ARMv7/Aarch64 Neon Intrinsics]) + AC_DEFINE([OAC_ARM_MAY_HAVE_NEON_INTR], 1, [Compiler supports ARMv7/Aarch64 Neon Intrinsics]) intrinsics_support="$intrinsics_support (NEON)" - AS_IF([test x"$enable_rtcd" != x"no" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"], + AS_IF([test x"$enable_rtcd" != x"no" && test x"$OAC_ARM_PRESUME_NEON_INTR" != x"1"], [AS_IF([test x"$rtcd_support" = x"no"], [rtcd_support="ARM (NEON Intrinsics)"], [rtcd_support="$rtcd_support (NEON Intrinsics)"])]) - AS_IF([test x"$OPUS_ARM_PRESUME_NEON_INTR" = x"1"], - [AC_DEFINE([OPUS_ARM_PRESUME_NEON_INTR], 1, [Define if binary requires NEON intrinsics support])]) + AS_IF([test x"$OAC_ARM_PRESUME_NEON_INTR" = x"1"], + [AC_DEFINE([OAC_ARM_PRESUME_NEON_INTR], 1, [Define if binary requires NEON intrinsics support])]) - OPUS_PATH_NE10() + OAC_PATH_NE10() AS_IF([test x"$NE10_LIBS" != x""], [ intrinsics_support="$intrinsics_support (NE10)" AS_IF([test x"enable_rtcd" != x"" \ - && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"], + && test x"$OAC_ARM_PRESUME_NEON_INTR" != x"1"], [rtcd_support="$rtcd_support (NE10)"]) ]) - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [Aarch64 Neon], [$ARM_NEON_INTR_CFLAGS], - [OPUS_ARM_MAY_HAVE_AARCH64_NEON_INTR], - [OPUS_ARM_PRESUME_AARCH64_NEON_INTR], + [OAC_ARM_MAY_HAVE_AARCH64_NEON_INTR], + [OAC_ARM_PRESUME_AARCH64_NEON_INTR], [[#include ]], [[ @@ -583,17 +575,17 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ ]] ) - AS_IF([test x"$OPUS_ARM_PRESUME_AARCH64_NEON_INTR" = x"1"], + AS_IF([test x"$OAC_ARM_PRESUME_AARCH64_NEON_INTR" = x"1"], [ - AC_DEFINE([OPUS_ARM_PRESUME_AARCH64_NEON_INTR], 1, [Define if binary requires Aarch64 Neon Intrinsics]) + AC_DEFINE([OAC_ARM_PRESUME_AARCH64_NEON_INTR], 1, [Define if binary requires Aarch64 Neon Intrinsics]) intrinsics_support="$intrinsics_support (NEON [Aarch64])" ]) - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [Aarch64 dotprod], [$ARM_DOTPROD_INTR_CFLAGS], - [OPUS_ARM_MAY_HAVE_DOTPROD], - [OPUS_ARM_PRESUME_DOTPROD], + [OAC_ARM_MAY_HAVE_DOTPROD], + [OAC_ARM_PRESUME_DOTPROD], [[#include ]], [[ @@ -602,25 +594,25 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ acc = vdotq_s32(acc, a, b); ]] ) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_DOTPROD" = x"1" && test x"$OPUS_ARM_PRESUME_DOTPROD" != x"1"], + AS_IF([test x"$OAC_ARM_MAY_HAVE_DOTPROD" = x"1" && test x"$OAC_ARM_PRESUME_DOTPROD" != x"1"], [ - OPUS_ARM_DOTPROD_INTR_CFLAGS="$ARM_NEON_DOTPROD_CFLAGS" - AC_SUBST([OPUS_ARM_DOTPROD_INTR_CFLAGS]) + OAC_ARM_DOTPROD_INTR_CFLAGS="$ARM_NEON_DOTPROD_CFLAGS" + AC_SUBST([OAC_ARM_DOTPROD_INTR_CFLAGS]) ] ) - AS_IF([test x"$OPUS_ARM_MAY_HAVE_DOTPROD" = x"1"], + AS_IF([test x"$OAC_ARM_MAY_HAVE_DOTPROD" = x"1"], [ - AC_DEFINE([OPUS_ARM_MAY_HAVE_DOTPROD], 1, [Compiler supports Aarch64 DOTPROD Intrinsics]) + AC_DEFINE([OAC_ARM_MAY_HAVE_DOTPROD], 1, [Compiler supports Aarch64 DOTPROD Intrinsics]) intrinsics_support="$intrinsics_support (DOTPROD)" - AS_IF([test x"$OPUS_ARM_PRESUME_DOTPROD" = x"1"], + AS_IF([test x"$OAC_ARM_PRESUME_DOTPROD" = x"1"], [ - AC_DEFINE([OPUS_ARM_PRESUME_DOTPROD], 1, [Define if binary requires Aarch64 dotprod Intrinsics]) + AC_DEFINE([OAC_ARM_PRESUME_DOTPROD], 1, [Define if binary requires Aarch64 dotprod Intrinsics]) intrinsics_support="$intrinsics_support (DOTPROD [Aarch64])" ]) - AS_IF([test x"$enable_rtcd" != x"no" && test x"$OPUS_ARM_PRESUME_DOTPROD" != x"1"], + AS_IF([test x"$enable_rtcd" != x"no" && test x"$OAC_ARM_PRESUME_DOTPROD" != x"1"], [AS_IF([test x"$rtcd_support" = x"no"], [rtcd_support="ARM (DOTPROD Intrinsics)"], [rtcd_support="$rtcd_support (DOTPROD Intrinsics)"])]) @@ -641,11 +633,11 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ [i?86|x86_64], [ cpu_x86=yes - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [SSE], [$X86_SSE_CFLAGS], - [OPUS_X86_MAY_HAVE_SSE], - [OPUS_X86_PRESUME_SSE], + [OAC_X86_MAY_HAVE_SSE], + [OAC_X86_PRESUME_SSE], [[#include #include ]], @@ -656,17 +648,17 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ return _mm_cvtss_si32(mtest); ]] ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1" && test x"$OPUS_X86_PRESUME_SSE" != x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_SSE" = x"1" && test x"$OAC_X86_PRESUME_SSE" != x"1"], [ - OPUS_X86_SSE_CFLAGS="$X86_SSE_CFLAGS" - AC_SUBST([OPUS_X86_SSE_CFLAGS]) + OAC_X86_SSE_CFLAGS="$X86_SSE_CFLAGS" + AC_SUBST([OAC_X86_SSE_CFLAGS]) ] ) - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [SSE2], [$X86_SSE2_CFLAGS], - [OPUS_X86_MAY_HAVE_SSE2], - [OPUS_X86_PRESUME_SSE2], + [OAC_X86_MAY_HAVE_SSE2], + [OAC_X86_PRESUME_SSE2], [[#include #include ]], @@ -677,17 +669,17 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ return _mm_cvtsi128_si32(mtest); ]] ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1" && test x"$OPUS_X86_PRESUME_SSE2" != x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_SSE2" = x"1" && test x"$OAC_X86_PRESUME_SSE2" != x"1"], [ - OPUS_X86_SSE2_CFLAGS="$X86_SSE2_CFLAGS" - AC_SUBST([OPUS_X86_SSE2_CFLAGS]) + OAC_X86_SSE2_CFLAGS="$X86_SSE2_CFLAGS" + AC_SUBST([OAC_X86_SSE2_CFLAGS]) ] ) - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [SSE4.1], [$X86_SSE4_1_CFLAGS], - [OPUS_X86_MAY_HAVE_SSE4_1], - [OPUS_X86_PRESUME_SSE4_1], + [OAC_X86_MAY_HAVE_SSE4_1], + [OAC_X86_PRESUME_SSE4_1], [[#include #include ]], @@ -698,17 +690,17 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ return _mm_cvtsi128_si32(mtest); ]] ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1" && test x"$OPUS_X86_PRESUME_SSE4_1" != x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_SSE4_1" = x"1" && test x"$OAC_X86_PRESUME_SSE4_1" != x"1"], [ - OPUS_X86_SSE4_1_CFLAGS="$X86_SSE4_1_CFLAGS" - AC_SUBST([OPUS_X86_SSE4_1_CFLAGS]) + OAC_X86_SSE4_1_CFLAGS="$X86_SSE4_1_CFLAGS" + AC_SUBST([OAC_X86_SSE4_1_CFLAGS]) ] ) - OPUS_CHECK_INTRINSICS( + OAC_CHECK_INTRINSICS( [AVX2], [$X86_AVX2_CFLAGS], - [OPUS_X86_MAY_HAVE_AVX2], - [OPUS_X86_PRESUME_AVX2], + [OAC_X86_MAY_HAVE_AVX2], + [OAC_X86_PRESUME_AVX2], [[#include #include ]], @@ -726,58 +718,58 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ _mm256_xor_si256(mtest1, mtest2), _mm256_cvttps_epi32(mtest)), 0); ]] ) - AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX2" = x"1" && test x"$OPUS_X86_PRESUME_AVX2" != x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_AVX2" = x"1" && test x"$OAC_X86_PRESUME_AVX2" != x"1"], [ - OPUS_X86_AVX2_CFLAGS="$X86_AVX2_CFLAGS" - AC_SUBST([OPUS_X86_AVX2_CFLAGS]) + OAC_X86_AVX2_CFLAGS="$X86_AVX2_CFLAGS" + AC_SUBST([OAC_X86_AVX2_CFLAGS]) ] ) AS_IF([test x"$rtcd_support" = x"no"], [rtcd_support=""]) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_SSE" = x"1"], [ - AC_DEFINE([OPUS_X86_MAY_HAVE_SSE], 1, [Compiler supports X86 SSE Intrinsics]) + AC_DEFINE([OAC_X86_MAY_HAVE_SSE], 1, [Compiler supports X86 SSE Intrinsics]) intrinsics_support="$intrinsics_support SSE" - AS_IF([test x"$OPUS_X86_PRESUME_SSE" = x"1"], - [AC_DEFINE([OPUS_X86_PRESUME_SSE], 1, [Define if binary requires SSE intrinsics support])], + AS_IF([test x"$OAC_X86_PRESUME_SSE" = x"1"], + [AC_DEFINE([OAC_X86_PRESUME_SSE], 1, [Define if binary requires SSE intrinsics support])], [rtcd_support="$rtcd_support SSE"]) ], [ AC_MSG_WARN([Compiler does not support SSE intrinsics]) ]) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_SSE2" = x"1"], [ - AC_DEFINE([OPUS_X86_MAY_HAVE_SSE2], 1, [Compiler supports X86 SSE2 Intrinsics]) + AC_DEFINE([OAC_X86_MAY_HAVE_SSE2], 1, [Compiler supports X86 SSE2 Intrinsics]) intrinsics_support="$intrinsics_support SSE2" - AS_IF([test x"$OPUS_X86_PRESUME_SSE2" = x"1"], - [AC_DEFINE([OPUS_X86_PRESUME_SSE2], 1, [Define if binary requires SSE2 intrinsics support])], + AS_IF([test x"$OAC_X86_PRESUME_SSE2" = x"1"], + [AC_DEFINE([OAC_X86_PRESUME_SSE2], 1, [Define if binary requires SSE2 intrinsics support])], [rtcd_support="$rtcd_support SSE2"]) ], [ AC_MSG_WARN([Compiler does not support SSE2 intrinsics]) ]) - AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_SSE4_1" = x"1"], [ - AC_DEFINE([OPUS_X86_MAY_HAVE_SSE4_1], 1, [Compiler supports X86 SSE4.1 Intrinsics]) + AC_DEFINE([OAC_X86_MAY_HAVE_SSE4_1], 1, [Compiler supports X86 SSE4.1 Intrinsics]) intrinsics_support="$intrinsics_support SSE4.1" - AS_IF([test x"$OPUS_X86_PRESUME_SSE4_1" = x"1"], - [AC_DEFINE([OPUS_X86_PRESUME_SSE4_1], 1, [Define if binary requires SSE4.1 intrinsics support])], + AS_IF([test x"$OAC_X86_PRESUME_SSE4_1" = x"1"], + [AC_DEFINE([OAC_X86_PRESUME_SSE4_1], 1, [Define if binary requires SSE4.1 intrinsics support])], [rtcd_support="$rtcd_support SSE4.1"]) ], [ AC_MSG_WARN([Compiler does not support SSE4.1 intrinsics]) ]) - AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX2" = x"1"], + AS_IF([test x"$OAC_X86_MAY_HAVE_AVX2" = x"1"], [ - AC_DEFINE([OPUS_X86_MAY_HAVE_AVX2], 1, [Compiler supports X86 AVX2 Intrinsics]) + AC_DEFINE([OAC_X86_MAY_HAVE_AVX2], 1, [Compiler supports X86 AVX2 Intrinsics]) intrinsics_support="$intrinsics_support AVX2" - AS_IF([test x"$OPUS_X86_PRESUME_AVX2" = x"1"], - [AC_DEFINE([OPUS_X86_PRESUME_AVX2], 1, [Define if binary requires AVX2 intrinsics support])], + AS_IF([test x"$OAC_X86_PRESUME_AVX2" = x"1"], + [AC_DEFINE([OAC_X86_PRESUME_AVX2], 1, [Define if binary requires AVX2 intrinsics support])], [rtcd_support="$rtcd_support AVX2"]) ], [ @@ -854,29 +846,29 @@ AS_IF([test x"$enable_intrinsics" = x"yes"],[ AM_CONDITIONAL([CPU_ARM], [test "$cpu_arm" = "yes"]) AM_CONDITIONAL([HAVE_ARM_DOTPROD], - [test x"$OPUS_ARM_MAY_HAVE_DOTPROD" = x"1"]) + [test x"$OAC_ARM_MAY_HAVE_DOTPROD" = x"1"]) AM_CONDITIONAL([HAVE_ARM_NEON_INTR], - [test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"]) + [test x"$OAC_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"]) + [test x"$OAC_X86_MAY_HAVE_SSE" = x"1"]) AM_CONDITIONAL([HAVE_SSE2], - [test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"]) + [test x"$OAC_X86_MAY_HAVE_SSE2" = x"1"]) AM_CONDITIONAL([HAVE_SSE4_1], - [test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"]) + [test x"$OAC_X86_MAY_HAVE_SSE4_1" = x"1"]) AM_CONDITIONAL([HAVE_AVX2], - [test x"$OPUS_X86_MAY_HAVE_AVX2" = x"1"]) + [test x"$OAC_X86_MAY_HAVE_AVX2" = x"1"]) AM_CONDITIONAL([HAVE_RTCD], [test x"$enable_rtcd" = x"yes" && test 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], + AC_DEFINE([OAC_HAVE_RTCD], [1], [Use run-time CPU capabilities detection]) - OPUS_HAVE_RTCD=1 - AC_SUBST(OPUS_HAVE_RTCD) + OAC_HAVE_RTCD=1 + AC_SUBST(OAC_HAVE_RTCD) ]) ],[ rtcd_support="disabled" @@ -912,7 +904,7 @@ AC_ARG_ENABLE([check-asm], [enable_check_asm=no]) AS_IF([test "$enable_check_asm" = "yes"], [ - AC_DEFINE([OPUS_CHECK_ASM], [1], [Run bit-exactness checks between optimized and C implementations]) + AC_DEFINE([OAC_CHECK_ASM], [1], [Run bit-exactness checks between optimized and C implementations]) ]) AC_ARG_ENABLE([doc], @@ -962,8 +954,8 @@ AC_ARG_ENABLE([osce], ) AS_IF([test "$enable_osce" = "yes" || test "$enable_osce_training_data" = "yes"], [ - AC_DEFINE([ENABLE_OSCE], [1], [Enable Opus Speech Coding Enhancement]) - AC_DEFINE([ENABLE_OSCE_BWE], [1], [Enable Opus Speech Coding Enhancement Blind BWE]) + AC_DEFINE([ENABLE_OSCE], [1], [Enable Oac Speech Coding Enhancement]) + AC_DEFINE([ENABLE_OSCE_BWE], [1], [Enable Oac Speech Coding Enhancement Blind BWE]) ]) AM_CONDITIONAL([ENABLE_OSCE], [test "$enable_osce" = "yes" || test "$enable_osce_training_data" = "yes"]) @@ -983,15 +975,6 @@ AC_ARG_ENABLE([extra-programs], AM_CONDITIONAL([EXTRA_PROGRAMS], [test "$enable_extra_programs" = "yes"]) -AC_ARG_ENABLE([rfc8251], - AS_HELP_STRING([--disable-rfc8251], [disable bitstream fixes from RFC 8251]),, - [enable_rfc8251=yes]) - -AS_IF([test "$enable_rfc8251" = "no"], [ - AC_DEFINE([DISABLE_UPDATE_DRAFT], [1], [Disable bitstream fixes from RFC 8251]) -]) - - saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden" AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden]) @@ -1067,8 +1050,8 @@ AC_SUBST([PC_BUILD]) AC_CONFIG_FILES([ Makefile - opus.pc - opus-uninstalled.pc + oac.pc + oac-uninstalled.pc celt/arm/armopts.s doc/Makefile doc/Doxyfile diff --git a/dnn/adaconvtest.c b/dnn/adaconvtest.c index 722e4affd..72d282bf5 100644 --- a/dnn/adaconvtest.c +++ b/dnn/adaconvtest.c @@ -9,8 +9,8 @@ #include -extern const WeightArray lacelayers_arrays[]; -extern const WeightArray nolacelayers_arrays[]; +extern const WeightArray oaci_lacelayers_arrays[]; +extern const WeightArray oaci_nolacelayers_arrays[]; void adaconv_compare( const char * prefix, @@ -27,9 +27,7 @@ void adaconv_compare( int left_padding, float filter_gain_a, float filter_gain_b, - float shape_gain -) -{ + float shape_gain) { char feature_file[256]; char x_in_file[256]; char x_out_file[256]; @@ -42,16 +40,15 @@ void adaconv_compare( float x_out[512]; float window[40]; - init_adaconv_state(hAdaConv); - compute_overlap_window(window, 40); + oaci_init_adaconv_state(hAdaConv); + oaci_compute_overlap_window(window, 40); FILE *f_features, *f_x_in, *f_x_out; strcpy(feature_file, prefix); strcat(feature_file, "_features.f32"); f_features = fopen(feature_file, "r"); - if (f_features == NULL) - { + if (f_features == NULL) { sprintf(message, "could not open file %s", feature_file); perror(message); exit(1); @@ -60,8 +57,7 @@ void adaconv_compare( strcpy(x_in_file, prefix); strcat(x_in_file, "_x_in.f32"); f_x_in = fopen(x_in_file, "r"); - if (f_x_in == NULL) - { + if (f_x_in == NULL) { sprintf(message, "could not open file %s", x_in_file); perror(message); exit(1); @@ -70,43 +66,37 @@ void adaconv_compare( strcpy(x_out_file, prefix); strcat(x_out_file, "_x_out.f32"); f_x_out = fopen(x_out_file, "r"); - if (f_x_out == NULL) - { + if (f_x_out == NULL) { sprintf(message, "could not open file %s", x_out_file); perror(message); exit(1); } - for (i_frame = 0; i_frame < num_frames; i_frame ++) - { - if (fread(features, sizeof(float), feature_dim, f_features) != feature_dim) - { + for (i_frame = 0; i_frame < num_frames; i_frame++) { + if (fread(features, sizeof(float), feature_dim, f_features) != feature_dim) { fprintf(stderr, "could not read frame %d from %s\n", i_frame, feature_file); exit(1); } - if (fread(x_in, sizeof(float), frame_size * in_channels, f_x_in) != frame_size * in_channels) - { + if (fread(x_in, sizeof(float), frame_size*in_channels, f_x_in) != frame_size*in_channels) { fprintf(stderr, "could not read frame %d from %s\n", i_frame, x_in_file); exit(1); } - if (fread(x_out_ref, sizeof(float), frame_size * out_channels, f_x_out) != frame_size * out_channels) - { + if (fread(x_out_ref, sizeof(float), frame_size*out_channels, f_x_out) != frame_size*out_channels) { fprintf(stderr, "could not read frame %d from %s\n", i_frame, x_out_file); exit(1); } - adaconv_process_frame(hAdaConv, x_out, x_in, features, kernel_layer, gain_layer, feature_dim, + oaci_adaconv_process_frame(hAdaConv, x_out, x_in, features, kernel_layer, gain_layer, feature_dim, frame_size, overlap_size, in_channels, out_channels, kernel_size, left_padding, filter_gain_a, filter_gain_b, shape_gain, window, 0); mse = 0; - for (i_sample = 0; i_sample < frame_size * out_channels; i_sample ++) - { + for (i_sample = 0; i_sample < frame_size*out_channels; i_sample++) { mse += pow(x_out_ref[i_sample] - x_out[i_sample], 2); } - mse = sqrt(mse / (frame_size * out_channels)); + mse = sqrt(mse/(frame_size*out_channels)); printf("rmse[%d] %f\n", i_frame, mse); } @@ -127,9 +117,7 @@ void adacomb_compare( int left_padding, float filter_gain_a, float filter_gain_b, - float log_gain_limit -) -{ + float log_gain_limit) { char feature_file[256]; char x_in_file[256]; char p_in_file[256]; @@ -144,16 +132,15 @@ void adacomb_compare( int pitch_lag; float window[40]; - init_adacomb_state(hAdaComb); - compute_overlap_window(window, 40); + oaci_init_adacomb_state(hAdaComb); + oaci_compute_overlap_window(window, 40); FILE *f_features, *f_x_in, *f_p_in, *f_x_out; strcpy(feature_file, prefix); strcat(feature_file, "_features.f32"); f_features = fopen(feature_file, "r"); - if (f_features == NULL) - { + if (f_features == NULL) { sprintf(message, "could not open file %s", feature_file); perror(message); exit(1); @@ -162,8 +149,7 @@ void adacomb_compare( strcpy(x_in_file, prefix); strcat(x_in_file, "_x_in.f32"); f_x_in = fopen(x_in_file, "r"); - if (f_x_in == NULL) - { + if (f_x_in == NULL) { sprintf(message, "could not open file %s", x_in_file); perror(message); exit(1); @@ -172,8 +158,7 @@ void adacomb_compare( strcpy(p_in_file, prefix); strcat(p_in_file, "_p_in.s32"); f_p_in = fopen(p_in_file, "r"); - if (f_p_in == NULL) - { + if (f_p_in == NULL) { sprintf(message, "could not open file %s", p_in_file); perror(message); exit(1); @@ -182,49 +167,43 @@ void adacomb_compare( strcpy(x_out_file, prefix); strcat(x_out_file, "_x_out.f32"); f_x_out = fopen(x_out_file, "r"); - if (f_x_out == NULL) - { + if (f_x_out == NULL) { sprintf(message, "could not open file %s", x_out_file); perror(message); exit(1); } - for (i_frame = 0; i_frame < num_frames; i_frame ++) - { - if (fread(features, sizeof(float), feature_dim, f_features) != feature_dim) - { + for (i_frame = 0; i_frame < num_frames; i_frame++) { + if (fread(features, sizeof(float), feature_dim, f_features) != feature_dim) { fprintf(stderr, "could not read frame %d from %s\n", i_frame, feature_file); exit(1); } - if (fread(x_in, sizeof(float), frame_size, f_x_in) != frame_size) - { + if (fread(x_in, sizeof(float), frame_size, f_x_in) != frame_size) { fprintf(stderr, "could not read frame %d from %s\n", i_frame, x_in_file); exit(1); } - if (fread(&pitch_lag, sizeof(int), 1, f_p_in) != 1) - { + if (fread(&pitch_lag, sizeof(int), 1, f_p_in) != 1) { fprintf(stderr, "could not read frame %d from %s\n", i_frame, p_in_file); exit(1); } - if (fread(x_out_ref, sizeof(float), frame_size, f_x_out) != frame_size) - { + if (fread(x_out_ref, sizeof(float), frame_size, f_x_out) != frame_size) { fprintf(stderr, "could not read frame %d from %s\n", i_frame, x_out_file); exit(1); } - adacomb_process_frame(hAdaComb, x_out, x_in, features, kernel_layer, gain_layer, global_gain_layer, - pitch_lag, feature_dim, frame_size, overlap_size, kernel_size, left_padding, filter_gain_a, filter_gain_b, log_gain_limit, window, 0); + oaci_adacomb_process_frame(hAdaComb, x_out, x_in, features, kernel_layer, gain_layer, global_gain_layer, + pitch_lag, feature_dim, frame_size, overlap_size, kernel_size, left_padding, filter_gain_a, filter_gain_b, + log_gain_limit, window, 0); mse = 0; - for (i_sample = 0; i_sample < frame_size; i_sample ++) - { + for (i_sample = 0; i_sample < frame_size; i_sample++) { mse += pow(x_out_ref[i_sample] - x_out[i_sample], 2); } - mse = sqrt(mse / (frame_size)); + mse = sqrt(mse/(frame_size)); printf("rmse[%d] %f\n", i_frame, mse); } @@ -238,9 +217,7 @@ void adashape_compare( LinearLayer *alpha2, int feature_dim, int frame_size, - int avg_pool_k -) -{ + int avg_pool_k) { char feature_file[256]; char x_in_file[256]; char x_out_file[256]; @@ -252,15 +229,14 @@ void adashape_compare( float x_out_ref[512]; float x_out[512]; - init_adashape_state(hAdaShape); + oaci_init_adashape_state(hAdaShape); FILE *f_features, *f_x_in, *f_x_out; strcpy(feature_file, prefix); strcat(feature_file, "_features.f32"); f_features = fopen(feature_file, "r"); - if (f_features == NULL) - { + if (f_features == NULL) { sprintf(message, "could not open file %s", feature_file); perror(message); exit(1); @@ -269,8 +245,7 @@ void adashape_compare( strcpy(x_in_file, prefix); strcat(x_in_file, "_x_in.f32"); f_x_in = fopen(x_in_file, "r"); - if (f_x_in == NULL) - { + if (f_x_in == NULL) { sprintf(message, "could not open file %s", x_in_file); perror(message); exit(1); @@ -279,50 +254,43 @@ void adashape_compare( strcpy(x_out_file, prefix); strcat(x_out_file, "_x_out.f32"); f_x_out = fopen(x_out_file, "r"); - if (f_x_out == NULL) - { + if (f_x_out == NULL) { sprintf(message, "could not open file %s", x_out_file); perror(message); exit(1); } - for (i_frame = 0; i_frame < num_frames; i_frame ++) - { - if (fread(features, sizeof(float), feature_dim, f_features) != feature_dim) - { + for (i_frame = 0; i_frame < num_frames; i_frame++) { + if (fread(features, sizeof(float), feature_dim, f_features) != feature_dim) { fprintf(stderr, "could not read frame %d from %s\n", i_frame, feature_file); exit(1); } - if (fread(x_in, sizeof(float), frame_size, f_x_in) != frame_size) - { + if (fread(x_in, sizeof(float), frame_size, f_x_in) != frame_size) { fprintf(stderr, "could not read frame %d from %s\n", i_frame, x_in_file); exit(1); } - if (fread(x_out_ref, sizeof(float), frame_size, f_x_out) != frame_size) - { + if (fread(x_out_ref, sizeof(float), frame_size, f_x_out) != frame_size) { fprintf(stderr, "could not read frame %d from %s\n", i_frame, x_out_file); exit(1); } - adashape_process_frame(hAdaShape, x_out, x_in, features, alpha1, alpha2, feature_dim, + oaci_adashape_process_frame(hAdaShape, x_out, x_in, features, alpha1, alpha2, feature_dim, frame_size, avg_pool_k, 0); mse = 0; - for (i_sample = 0; i_sample < frame_size; i_sample ++) - { + for (i_sample = 0; i_sample < frame_size; i_sample++) { mse += pow(x_out_ref[i_sample] - x_out[i_sample], 2); } - mse = sqrt(mse / (frame_size)); + mse = sqrt(mse/(frame_size)); printf("rmse[%d] %f\n", i_frame, mse); } } -int main() -{ +int main() { LACELayers hLACE; NOLACELayers hNoLACE; @@ -330,10 +298,10 @@ int main() AdaCombState hAdaComb; AdaShapeState hAdaShape; - init_adaconv_state(&hAdaConv); + oaci_init_adaconv_state(&hAdaConv); - init_lacelayers(&hLACE, lacelayers_arrays); - init_nolacelayers(&hNoLACE, nolacelayers_arrays); + oaci_init_lacelayers(&hLACE, oaci_lacelayers_arrays); + oaci_init_nolacelayers(&hNoLACE, oaci_nolacelayers_arrays); printf("\ntesting lace.af1 (1 in, 1 out)...\n"); adaconv_compare( @@ -352,7 +320,7 @@ int main() LACE_AF1_FILTER_GAIN_A, LACE_AF1_FILTER_GAIN_B, LACE_AF1_SHAPE_GAIN - ); + ); printf("\ntesting nolace.af1 (1 in, 2 out)...\n"); @@ -372,7 +340,7 @@ int main() NOLACE_AF1_FILTER_GAIN_A, NOLACE_AF1_FILTER_GAIN_B, NOLACE_AF1_SHAPE_GAIN - ); + ); printf("testing nolace.af4 (2 in, 1 out)...\n"); @@ -392,7 +360,7 @@ int main() NOLACE_AF4_FILTER_GAIN_A, NOLACE_AF4_FILTER_GAIN_B, NOLACE_AF4_SHAPE_GAIN - ); + ); printf("\ntesting nolace.af2 (2 in, 2 out)...\n"); adaconv_compare( @@ -411,7 +379,7 @@ int main() NOLACE_AF2_FILTER_GAIN_A, NOLACE_AF2_FILTER_GAIN_B, NOLACE_AF2_SHAPE_GAIN - ); + ); printf("\ntesting lace.cf1...\n"); adacomb_compare( @@ -429,7 +397,7 @@ int main() LACE_CF1_FILTER_GAIN_A, LACE_CF1_FILTER_GAIN_B, LACE_CF1_LOG_GAIN_LIMIT - ); + ); printf("\ntesting nolace.tdshape1...\n"); adashape_compare( @@ -441,7 +409,7 @@ int main() NOLACE_TDSHAPE1_FEATURE_DIM, NOLACE_TDSHAPE1_FRAME_SIZE, NOLACE_TDSHAPE1_AVG_POOL_K - ); + ); return 0; } diff --git a/dnn/arm/arm_dnn_map.c b/dnn/arm/arm_dnn_map.c index 98a2a3125..ea48a6eb2 100644 --- a/dnn/arm/arm_dnn_map.c +++ b/dnn/arm/arm_dnn_map.c @@ -23,49 +23,49 @@ 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" +# include "config.h" #endif #include "arm/armcpu.h" #include "nnet.h" -#if defined(OPUS_HAVE_RTCD) +#if defined(OAC_HAVE_RTCD) -#if (defined(OPUS_ARM_MAY_HAVE_DOTPROD) && !defined(OPUS_ARM_PRESUME_DOTPROD)) +# if (defined(OAC_ARM_MAY_HAVE_DOTPROD) && !defined(OAC_ARM_PRESUME_DOTPROD)) -void (*const DNN_COMPUTE_LINEAR_IMPL[OPUS_ARCHMASK + 1])( +void (*const oaci_DNN_COMPUTE_LINEAR_IMPL[OAC_ARCHMASK + 1])( const LinearLayer *linear, float *out, const float *in -) = { - compute_linear_c, /* default */ - compute_linear_c, - compute_linear_c, - MAY_HAVE_NEON(compute_linear), /* neon */ - MAY_HAVE_DOTPROD(compute_linear) /* dotprod */ + ) = { + oaci_compute_linear_c, /* default */ + oaci_compute_linear_c, + oaci_compute_linear_c, + MAY_HAVE_NEON(oaci_compute_linear), /* neon */ + MAY_HAVE_DOTPROD(oaci_compute_linear) /* dotprod */ }; -#endif +# endif -#if (defined(OPUS_ARM_MAY_HAVE_DOTPROD) || defined(OPUS_ARM_MAY_HAVE_NEON)) && !defined(OPUS_ARM_PRESUME_NEON) +# if (defined(OAC_ARM_MAY_HAVE_DOTPROD) || defined(OAC_ARM_MAY_HAVE_NEON)) && !defined(OAC_ARM_PRESUME_NEON) -void (*const DNN_COMPUTE_ACTIVATION_IMPL[OPUS_ARCHMASK + 1])( +void (*const oaci_DNN_COMPUTE_ACTIVATION_IMPL[OAC_ARCHMASK + 1])( float *output, const float *input, int N, int activation -) = { - compute_activation_c, /* default */ - compute_activation_c, - compute_activation_c, - MAY_HAVE_NEON(compute_activation), /* neon */ - MAY_HAVE_DOTPROD(compute_activation) /* dotprod */ + ) = { + oaci_compute_activation_c, /* default */ + oaci_compute_activation_c, + oaci_compute_activation_c, + MAY_HAVE_NEON(oaci_compute_activation), /* neon */ + MAY_HAVE_DOTPROD(oaci_compute_activation) /* dotprod */ }; -void (*const DNN_COMPUTE_CONV2D_IMPL[OPUS_ARCHMASK + 1])( +void (*const oaci_DNN_COMPUTE_CONV2D_IMPL[OAC_ARCHMASK + 1])( const Conv2dLayer *conv, float *out, float *mem, @@ -73,16 +73,16 @@ void (*const DNN_COMPUTE_CONV2D_IMPL[OPUS_ARCHMASK + 1])( int height, int hstride, int activation -) = { - compute_conv2d_c, /* default */ - compute_conv2d_c, - compute_conv2d_c, - MAY_HAVE_NEON(compute_conv2d), /* neon */ - MAY_HAVE_DOTPROD(compute_conv2d) /* dotprod */ + ) = { + oaci_compute_conv2d_c, /* default */ + oaci_compute_conv2d_c, + oaci_compute_conv2d_c, + MAY_HAVE_NEON(oaci_compute_conv2d), /* neon */ + MAY_HAVE_DOTPROD(oaci_compute_conv2d) /* dotprod */ }; -#endif +# endif #endif diff --git a/dnn/arm/dnn_arm.h b/dnn/arm/dnn_arm.h index d7ac74526..28a61d7f7 100644 --- a/dnn/arm/dnn_arm.h +++ b/dnn/arm/dnn_arm.h @@ -23,68 +23,73 @@ 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. -*/ + */ #ifndef DNN_ARM_H #define DNN_ARM_H #include "cpu_support.h" -#include "opus_types.h" +#include "oac_types.h" -void compute_linear_dotprod(const LinearLayer *linear, float *out, const float *in); -void compute_linear_neon(const LinearLayer *linear, float *out, const float *in); +void oaci_compute_linear_dotprod(const LinearLayer *linear, float *out, const float *in); +void oaci_compute_linear_neon(const LinearLayer *linear, float *out, const float *in); -void compute_activation_neon(float *output, const float *input, int N, int activation); -void compute_activation_dotprod(float *output, const float *input, int N, int activation); +void oaci_compute_activation_neon(float *output, const float *input, int N, int activation); +void oaci_compute_activation_dotprod(float *output, const float *input, int N, int activation); -void compute_conv2d_neon(const Conv2dLayer *conv, float *out, float *mem, const float *in, int height, int hstride, int activation); -void compute_conv2d_dotprod(const Conv2dLayer *conv, float *out, float *mem, const float *in, int height, int hstride, int activation); +void oaci_compute_conv2d_neon(const Conv2dLayer *conv, float *out, float *mem, const float *in, int height, int hstride, + int activation); +void oaci_compute_conv2d_dotprod(const Conv2dLayer *conv, float *out, float *mem, const float *in, int height, int hstride, + int activation); -#if defined(OPUS_ARM_PRESUME_DOTPROD) +#if defined(OAC_ARM_PRESUME_DOTPROD) -#define OVERRIDE_COMPUTE_LINEAR -#define compute_linear(linear, out, in, arch) ((void)(arch),compute_linear_dotprod(linear, out, in)) +# define OVERRIDE_COMPUTE_LINEAR +# define oaci_compute_linear(linear, out, in, arch) ((void)(arch), oaci_compute_linear_dotprod(linear, out, in)) -#elif defined(OPUS_ARM_PRESUME_NEON_INTR) && !defined(OPUS_ARM_MAY_HAVE_DOTPROD) +#elif defined(OAC_ARM_PRESUME_NEON_INTR) && !defined(OAC_ARM_MAY_HAVE_DOTPROD) -#define OVERRIDE_COMPUTE_LINEAR -#define compute_linear(linear, out, in, arch) ((void)(arch),compute_linear_neon(linear, out, in)) +# define OVERRIDE_COMPUTE_LINEAR +# define oaci_compute_linear(linear, out, in, arch) ((void)(arch), oaci_compute_linear_neon(linear, out, in)) -#elif defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_MAY_HAVE_DOTPROD) || defined(OPUS_ARM_MAY_HAVE_NEON)) +#elif defined(OAC_HAVE_RTCD) && (defined(OAC_ARM_MAY_HAVE_DOTPROD) || defined(OAC_ARM_MAY_HAVE_NEON)) -extern void (*const DNN_COMPUTE_LINEAR_IMPL[OPUS_ARCHMASK + 1])( +extern void (*const oaci_DNN_COMPUTE_LINEAR_IMPL[OAC_ARCHMASK + 1])( const LinearLayer *linear, float *out, const float *in - ); -#define OVERRIDE_COMPUTE_LINEAR -#define compute_linear(linear, out, in, arch) \ - ((*DNN_COMPUTE_LINEAR_IMPL[(arch) & OPUS_ARCHMASK])(linear, out, in)) + ); +# define OVERRIDE_COMPUTE_LINEAR +# define oaci_compute_linear(linear, out, in, arch) \ + ((*oaci_DNN_COMPUTE_LINEAR_IMPL[(arch)&OAC_ARCHMASK])(linear, out, in)) #endif -#if defined(OPUS_ARM_PRESUME_NEON) +#if defined(OAC_ARM_PRESUME_NEON) -#define OVERRIDE_COMPUTE_ACTIVATION -#define compute_activation(output, input, N, activation, arch) ((void)(arch),compute_activation_neon(output, input, N, activation)) -#define OVERRIDE_COMPUTE_CONV2D -#define compute_conv2d(conv, out, mem, in, height, hstride, activation, arch) ((void)(arch),compute_conv2d_neon(conv, out, mem, in, height, hstride, activation)) +# define OVERRIDE_COMPUTE_ACTIVATION +# define oaci_compute_activation(output, input, N, activation, arch) ((void)(arch), \ + oaci_compute_activation_neon(output, input, N, activation)) +# define OVERRIDE_COMPUTE_CONV2D +# define oaci_compute_conv2d(conv, out, mem, in, height, hstride, activation, arch) ((void)(arch), \ + oaci_compute_conv2d_neon(conv, out, mem, in, \ + height, hstride, activation)) -#elif defined(OPUS_HAVE_RTCD) && (defined(OPUS_ARM_MAY_HAVE_DOTPROD) || defined(OPUS_ARM_MAY_HAVE_NEON)) +#elif defined(OAC_HAVE_RTCD) && (defined(OAC_ARM_MAY_HAVE_DOTPROD) || defined(OAC_ARM_MAY_HAVE_NEON)) -extern void (*const DNN_COMPUTE_ACTIVATION_IMPL[OPUS_ARCHMASK + 1])( +extern void (*const oaci_DNN_COMPUTE_ACTIVATION_IMPL[OAC_ARCHMASK + 1])( float *output, const float *input, int N, int activation - ); -#define OVERRIDE_COMPUTE_ACTIVATION -#define compute_activation(output, input, N, activation, arch) \ - ((*DNN_COMPUTE_ACTIVATION_IMPL[(arch) & OPUS_ARCHMASK])(output, input, N, activation)) + ); +# define OVERRIDE_COMPUTE_ACTIVATION +# define oaci_compute_activation(output, input, N, activation, arch) \ + ((*oaci_DNN_COMPUTE_ACTIVATION_IMPL[(arch)&OAC_ARCHMASK])(output, input, N, activation)) -extern void (*const DNN_COMPUTE_CONV2D_IMPL[OPUS_ARCHMASK + 1])( +extern void (*const oaci_DNN_COMPUTE_CONV2D_IMPL[OAC_ARCHMASK + 1])( const Conv2dLayer *conv, float *out, float *mem, @@ -92,10 +97,10 @@ extern void (*const DNN_COMPUTE_CONV2D_IMPL[OPUS_ARCHMASK + 1])( int height, int hstride, int activation - ); -#define OVERRIDE_COMPUTE_CONV2D -#define compute_conv2d(conv, out, mem, in, height, hstride, activation, arch) \ - ((*DNN_COMPUTE_CONV2D_IMPL[(arch) & OPUS_ARCHMASK])(conv, out, mem, in, height, hstride, activation)) + ); +# define OVERRIDE_COMPUTE_CONV2D +# define oaci_compute_conv2d(conv, out, mem, in, height, hstride, activation, arch) \ + ((*oaci_DNN_COMPUTE_CONV2D_IMPL[(arch)&OAC_ARCHMASK])(conv, out, mem, in, height, hstride, activation)) #endif diff --git a/dnn/arm/nnet_dotprod.c b/dnn/arm/nnet_dotprod.c index 1354ed334..b10e01714 100644 --- a/dnn/arm/nnet_dotprod.c +++ b/dnn/arm/nnet_dotprod.c @@ -23,14 +23,14 @@ 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" +# include "config.h" #endif #ifndef __ARM_FEATURE_DOTPROD -#error nnet_dotprod.c is being compiled without DOTPROD enabled +# error nnet_dotprod.c is being compiled without DOTPROD enabled #endif #define RTCD_ARCH dotprod diff --git a/dnn/arm/nnet_neon.c b/dnn/arm/nnet_neon.c index fb636f85b..6ad29641c 100644 --- a/dnn/arm/nnet_neon.c +++ b/dnn/arm/nnet_neon.c @@ -23,14 +23,14 @@ 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" +# include "config.h" #endif #if !(defined(__ARM_NEON__) || defined(__ARM_NEON)) -#error nnet_neon.c is being compiled without Neon enabled +# error nnet_neon.c is being compiled without Neon enabled #endif #define RTCD_ARCH neon diff --git a/dnn/burg.c b/dnn/burg.c index 3d6b23b03..327d1d9f3 100644 --- a/dnn/burg.c +++ b/dnn/burg.c @@ -1,32 +1,32 @@ /*********************************************************************** -Copyright (c) 2006-2011, Skype Limited. All rights reserved. -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. -- Neither the name of Internet Society, IETF or IETF Trust, nor the -names of specific contributors, may be used to endorse or promote -products derived from this software without specific prior written -permission. -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. + Copyright (c) 2006-2011, Skype Limited. All rights reserved. + 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. + - Neither the name of Internet Society, IETF or IETF Trust, nor the + names of specific contributors, may be used to endorse or promote + products derived from this software without specific prior written + permission. + 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" +# include "config.h" #endif #include @@ -41,26 +41,24 @@ POSSIBILITY OF SUCH DAMAGE. #define FIND_LPC_COND_FAC 1e-5f /* sum of squares of a silk_float array, with result as double */ -static double silk_energy_FLP( +static double oaci_silk_energy_FLP( const float *data, - int dataSize -) -{ + int dataSize) { int i; - double result; + double result; /* 4x unrolled loop */ result = 0.0; - for( i = 0; i < dataSize - 3; i += 4 ) { - result += data[ i + 0 ] * (double)data[ i + 0 ] + - data[ i + 1 ] * (double)data[ i + 1 ] + - data[ i + 2 ] * (double)data[ i + 2 ] + - data[ i + 3 ] * (double)data[ i + 3 ]; + for (i = 0; i < dataSize - 3; i += 4) { + result += data[ i + 0 ]*(double)data[ i + 0 ] + + data[ i + 1 ]*(double)data[ i + 1 ] + + data[ i + 2 ]*(double)data[ i + 2 ] + + data[ i + 3 ]*(double)data[ i + 3 ]; } /* add any remaining products */ - for( ; i < dataSize; i++ ) { - result += data[ i ] * (double)data[ i ]; + for ( ; i < dataSize; i++) { + result += data[ i ]*(double)data[ i ]; } assert( result >= 0.0 ); @@ -68,27 +66,25 @@ static double silk_energy_FLP( } /* inner product of two silk_float arrays, with result as double */ -static double silk_inner_product_FLP( +static double oaci_silk_inner_product_FLP( const float *data1, const float *data2, - int dataSize -) -{ + int dataSize) { int i; - double result; + double result; /* 4x unrolled loop */ result = 0.0; - for( i = 0; i < dataSize - 3; i += 4 ) { - result += data1[ i + 0 ] * (double)data2[ i + 0 ] + - data1[ i + 1 ] * (double)data2[ i + 1 ] + - data1[ i + 2 ] * (double)data2[ i + 2 ] + - data1[ i + 3 ] * (double)data2[ i + 3 ]; + for (i = 0; i < dataSize - 3; i += 4) { + result += data1[ i + 0 ]*(double)data2[ i + 0 ] + + data1[ i + 1 ]*(double)data2[ i + 1 ] + + data1[ i + 2 ]*(double)data2[ i + 2 ] + + data1[ i + 3 ]*(double)data2[ i + 3 ]; } /* add any remaining products */ - for( ; i < dataSize; i++ ) { - result += data1[ i ] * (double)data2[ i ]; + for ( ; i < dataSize; i++) { + result += data1[ i ]*(double)data2[ i ]; } return result; @@ -96,66 +92,65 @@ static double silk_inner_product_FLP( /* Compute reflection coefficients from input signal */ -float silk_burg_analysis( /* O returns residual energy */ - float A[], /* O prediction coefficients (length order) */ - const float x[], /* I input signal, length: nb_subfr*(D+L_sub) */ - const float minInvGain, /* I minimum inverse prediction gain */ - const int subfr_length, /* I input signal subframe length (incl. D preceding samples) */ - const int nb_subfr, /* I number of subframes stacked in x */ - const int D /* I order */ -) -{ - int k, n, s, reached_max_gain; - double C0, invGain, num, nrg_f, nrg_b, rc, Atmp, tmp1, tmp2; +float oaci_silk_burg_analysis( /* O returns residual energy */ + float A[], /* O prediction coefficients (length order) */ + const float x[], /* I input signal, length: nb_subfr*(D+L_sub) */ + const float minInvGain, /* I minimum inverse prediction gain */ + const int subfr_length, /* I input signal subframe length (incl. D preceding samples) */ + const int nb_subfr, /* I number of subframes stacked in x */ + const int D /* I order */ + ) { + int k, n, s, reached_max_gain; + double C0, invGain, num, nrg_f, nrg_b, rc, Atmp, tmp1, tmp2; const float *x_ptr; - double C_first_row[ SILK_MAX_ORDER_LPC ], C_last_row[ SILK_MAX_ORDER_LPC ]; - double CAf[ SILK_MAX_ORDER_LPC + 1 ], CAb[ SILK_MAX_ORDER_LPC + 1 ]; - double Af[ SILK_MAX_ORDER_LPC ]; + double C_first_row[ SILK_MAX_ORDER_LPC ], C_last_row[ SILK_MAX_ORDER_LPC ]; + double CAf[ SILK_MAX_ORDER_LPC + 1 ], CAb[ SILK_MAX_ORDER_LPC + 1 ]; + double Af[ SILK_MAX_ORDER_LPC ]; - assert( subfr_length * nb_subfr <= MAX_FRAME_SIZE ); + assert( subfr_length*nb_subfr <= MAX_FRAME_SIZE ); /* Compute autocorrelations, added over subframes */ - C0 = silk_energy_FLP( x, nb_subfr * subfr_length ); - memset( C_first_row, 0, SILK_MAX_ORDER_LPC * sizeof( double ) ); - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x + s * subfr_length; - for( n = 1; n < D + 1; n++ ) { - C_first_row[ n - 1 ] += silk_inner_product_FLP( x_ptr, x_ptr + n, subfr_length - n ); + C0 = oaci_silk_energy_FLP( x, nb_subfr*subfr_length ); + memset( C_first_row, 0, SILK_MAX_ORDER_LPC*sizeof(double)); + for (s = 0; s < nb_subfr; s++) { + x_ptr = x + s*subfr_length; + for (n = 1; n < D + 1; n++) { + C_first_row[ n - 1 ] += oaci_silk_inner_product_FLP( x_ptr, x_ptr + n, subfr_length - n ); } } - memcpy( C_last_row, C_first_row, SILK_MAX_ORDER_LPC * sizeof( double ) ); + memcpy( C_last_row, C_first_row, SILK_MAX_ORDER_LPC*sizeof(double)); /* Initialize */ - CAb[ 0 ] = CAf[ 0 ] = C0 + FIND_LPC_COND_FAC * C0 + 1e-9f; + CAb[ 0 ] = CAf[ 0 ] = C0 + FIND_LPC_COND_FAC*C0 + 1e-9f; invGain = 1.0f; reached_max_gain = 0; - for( n = 0; n < D; n++ ) { + for (n = 0; n < D; n++) { /* Update first row of correlation matrix (without first element) */ /* Update last row of correlation matrix (without last element, stored in reversed order) */ /* Update C * Af */ /* Update C * flipud(Af) (stored in reversed order) */ - for( s = 0; s < nb_subfr; s++ ) { - x_ptr = x + s * subfr_length; + for (s = 0; s < nb_subfr; s++) { + x_ptr = x + s*subfr_length; tmp1 = x_ptr[ n ]; tmp2 = x_ptr[ subfr_length - n - 1 ]; - for( k = 0; k < n; k++ ) { - C_first_row[ k ] -= x_ptr[ n ] * x_ptr[ n - k - 1 ]; - C_last_row[ k ] -= x_ptr[ subfr_length - n - 1 ] * x_ptr[ subfr_length - n + k ]; + for (k = 0; k < n; k++) { + C_first_row[ k ] -= x_ptr[ n ]*x_ptr[ n - k - 1 ]; + C_last_row[ k ] -= x_ptr[ subfr_length - n - 1 ]*x_ptr[ subfr_length - n + k ]; Atmp = Af[ k ]; - tmp1 += x_ptr[ n - k - 1 ] * Atmp; - tmp2 += x_ptr[ subfr_length - n + k ] * Atmp; + tmp1 += x_ptr[ n - k - 1 ]*Atmp; + tmp2 += x_ptr[ subfr_length - n + k ]*Atmp; } - for( k = 0; k <= n; k++ ) { - CAf[ k ] -= tmp1 * x_ptr[ n - k ]; - CAb[ k ] -= tmp2 * x_ptr[ subfr_length - n + k - 1 ]; + for (k = 0; k <= n; k++) { + CAf[ k ] -= tmp1*x_ptr[ n - k ]; + CAb[ k ] -= tmp2*x_ptr[ subfr_length - n + k - 1 ]; } } tmp1 = C_first_row[ n ]; tmp2 = C_last_row[ n ]; - for( k = 0; k < n; k++ ) { + for (k = 0; k < n; k++) { Atmp = Af[ k ]; - tmp1 += C_last_row[ n - k - 1 ] * Atmp; - tmp2 += C_first_row[ n - k - 1 ] * Atmp; + tmp1 += C_last_row[ n - k - 1 ]*Atmp; + tmp2 += C_first_row[ n - k - 1 ]*Atmp; } CAf[ n + 1 ] = tmp1; CAb[ n + 1 ] = tmp2; @@ -164,25 +159,25 @@ float silk_burg_analysis( /* O returns residual energy num = CAb[ n + 1 ]; nrg_b = CAb[ 0 ]; nrg_f = CAf[ 0 ]; - for( k = 0; k < n; k++ ) { + for (k = 0; k < n; k++) { Atmp = Af[ k ]; - num += CAb[ n - k ] * Atmp; - nrg_b += CAb[ k + 1 ] * Atmp; - nrg_f += CAf[ k + 1 ] * Atmp; + num += CAb[ n - k ]*Atmp; + nrg_b += CAb[ k + 1 ]*Atmp; + nrg_f += CAf[ k + 1 ]*Atmp; } assert( nrg_f > 0.0 ); assert( nrg_b > 0.0 ); /* Calculate the next order reflection (parcor) coefficient */ - rc = -2.0 * num / ( nrg_f + nrg_b ); + rc = -2.0*num/(nrg_f + nrg_b); assert( rc > -1.0 && rc < 1.0 ); /* Update inverse prediction gain */ - tmp1 = invGain * ( 1.0 - rc * rc ); - if( tmp1 <= minInvGain ) { + tmp1 = invGain*(1.0 - rc*rc); + if (tmp1 <= minInvGain) { /* Max prediction gain exceeded; set reflection coefficient such that max prediction gain is exactly hit */ - rc = sqrt( 1.0 - minInvGain / invGain ); - if( num > 0 ) { + rc = sqrt( 1.0 - minInvGain/invGain ); + if (num > 0) { /* Ensure adjusted reflection coefficients has the original sign */ rc = -rc; } @@ -193,52 +188,52 @@ float silk_burg_analysis( /* O returns residual energy } /* Update the AR coefficients */ - for( k = 0; k < (n + 1) >> 1; k++ ) { + for (k = 0; k < (n + 1)>>1; k++) { tmp1 = Af[ k ]; tmp2 = Af[ n - k - 1 ]; - Af[ k ] = tmp1 + rc * tmp2; - Af[ n - k - 1 ] = tmp2 + rc * tmp1; + Af[ k ] = tmp1 + rc*tmp2; + Af[ n - k - 1 ] = tmp2 + rc*tmp1; } Af[ n ] = rc; - if( reached_max_gain ) { + if (reached_max_gain) { /* Reached max prediction gain; set remaining coefficients to zero and exit loop */ - for( k = n + 1; k < D; k++ ) { + for (k = n + 1; k < D; k++) { Af[ k ] = 0.0; } break; } /* Update C * Af and C * Ab */ - for( k = 0; k <= n + 1; k++ ) { + for (k = 0; k <= n + 1; k++) { tmp1 = CAf[ k ]; - CAf[ k ] += rc * CAb[ n - k + 1 ]; - CAb[ n - k + 1 ] += rc * tmp1; + CAf[ k ] += rc*CAb[ n - k + 1 ]; + CAb[ n - k + 1 ] += rc*tmp1; } } - if( reached_max_gain ) { + if (reached_max_gain) { /* Convert to float */ - for( k = 0; k < D; k++ ) { - A[ k ] = (float)( -Af[ k ] ); + for (k = 0; k < D; k++) { + A[ k ] = (float)(-Af[ k ]); } /* Subtract energy of preceding samples from C0 */ - for( s = 0; s < nb_subfr; s++ ) { - C0 -= silk_energy_FLP( x + s * subfr_length, D ); + for (s = 0; s < nb_subfr; s++) { + C0 -= oaci_silk_energy_FLP( x + s*subfr_length, D ); } /* Approximate residual energy */ - nrg_f = C0 * invGain; + nrg_f = C0*invGain; } else { /* Compute residual energy and store coefficients as float */ nrg_f = CAf[ 0 ]; tmp1 = 1.0; - for( k = 0; k < D; k++ ) { + for (k = 0; k < D; k++) { Atmp = Af[ k ]; - nrg_f += CAf[ k + 1 ] * Atmp; - tmp1 += Atmp * Atmp; + nrg_f += CAf[ k + 1 ]*Atmp; + tmp1 += Atmp*Atmp; A[ k ] = (float)(-Atmp); } - nrg_f -= FIND_LPC_COND_FAC * C0 * tmp1; + nrg_f -= FIND_LPC_COND_FAC*C0*tmp1; } /* Return residual energy */ diff --git a/dnn/burg.h b/dnn/burg.h index f5998d2f7..b80e9871a 100644 --- a/dnn/burg.h +++ b/dnn/burg.h @@ -1,41 +1,41 @@ /*********************************************************************** -Copyright (c) 2006-2011, Skype Limited. All rights reserved. -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. -- Neither the name of Internet Society, IETF or IETF Trust, nor the -names of specific contributors, may be used to endorse or promote -products derived from this software without specific prior written -permission. -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. + Copyright (c) 2006-2011, Skype Limited. All rights reserved. + 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. + - Neither the name of Internet Society, IETF or IETF Trust, nor the + names of specific contributors, may be used to endorse or promote + products derived from this software without specific prior written + permission. + 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. ***********************************************************************/ #ifndef BURG_H #define BURG_H -float silk_burg_analysis( /* O returns residual energy */ - float A[], /* O prediction coefficients (length order) */ - const float x[], /* I input signal, length: nb_subfr*(D+L_sub) */ - const float minInvGain, /* I minimum inverse prediction gain */ - const int subfr_length, /* I input signal subframe length (incl. D preceding samples) */ - const int nb_subfr, /* I number of subframes stacked in x */ - const int D /* I order */ -); +float oaci_silk_burg_analysis( /* O returns residual energy */ + float A[], /* O prediction coefficients (length order) */ + const float x[], /* I input signal, length: nb_subfr*(D+L_sub) */ + const float minInvGain, /* I minimum inverse prediction gain */ + const int subfr_length, /* I input signal subframe length (incl. D preceding samples) */ + const int nb_subfr, /* I number of subframes stacked in x */ + const int D /* I order */ + ); #endif diff --git a/dnn/bwe_demo.c b/dnn/bwe_demo.c index 530ff605a..81f5afb50 100644 --- a/dnn/bwe_demo.c +++ b/dnn/bwe_demo.c @@ -22,10 +22,10 @@ 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" +# include "config.h" #endif #include @@ -56,11 +56,11 @@ int main(int argc, char **argv) { OSCEModel *osce; - arch = opus_select_arch(); + arch = oac_select_arch(); hOSCEBWE = (silk_OSCE_BWE_struct *)calloc(1, sizeof(*hOSCEBWE)); osce = (OSCEModel *)calloc(1, sizeof(*osce)); - osce_load_models(osce, NULL, arch); - osce_bwe_reset(hOSCEBWE); + oaci_osce_load_models(osce, NULL, arch); + oaci_osce_bwe_reset(hOSCEBWE); if (argc != 3) usage(); fin = fopen(argv[1], "rb"); @@ -76,20 +76,20 @@ int main(int argc, char **argv) { } int16_t x_in[BWE_FRAME_SIZE]; - int16_t x_out[3 * BWE_FRAME_SIZE]; + int16_t x_out[3*BWE_FRAME_SIZE]; - while(fread(x_in, sizeof(x_in[0]), BWE_FRAME_SIZE, fin) == BWE_FRAME_SIZE) { - osce_bwe( + while (fread(x_in, sizeof(x_in[0]), BWE_FRAME_SIZE, fin) == BWE_FRAME_SIZE) { + oaci_osce_bwe( osce, hOSCEBWE, x_out, x_in, BWE_FRAME_SIZE, arch - ); + ); - fwrite(x_out, sizeof(x_out[0]), 3 * BWE_FRAME_SIZE, fout); + fwrite(x_out, sizeof(x_out[0]), 3*BWE_FRAME_SIZE, fout); } free(hOSCEBWE); diff --git a/dnn/common.h b/dnn/common.h index b3bec7300..4995af38d 100644 --- a/dnn/common.h +++ b/dnn/common.h @@ -6,45 +6,42 @@ #include #include #include -#include "opus_defines.h" +#include "oac_defines.h" #define LOG256 5.5451774445f -static OPUS_INLINE float log2_approx(float x) -{ - int integer; - float frac; - union { - float f; - int i; - } in; - in.f = x; - integer = (in.i>>23)-127; - in.i -= integer<<23; - frac = in.f - 1.5f; - frac = -0.41445418f + frac*(0.95909232f - + frac*(-0.33951290f + frac*0.16541097f)); - return 1+integer+frac; +static OAC_INLINE float log2_approx(float x) { + int integer; + float frac; + union { + float f; + int i; + } in; + in.f = x; + integer = (in.i>>23) - 127; + in.i -= integer<<23; + frac = in.f - 1.5f; + frac = -0.41445418f + frac*(0.95909232f + + frac*(-0.33951290f + frac*0.16541097f)); + return 1 + integer + frac; } #define log_approx(x) (0.69315f*log2_approx(x)) -static OPUS_INLINE float ulaw2lin(float u) -{ +static OAC_INLINE float ulaw2lin(float u) { float s; float scale_1 = 32768.f/255.f; u = u - 128.f; s = u >= 0.f ? 1.f : -1.f; u = fabs(u); - return s*scale_1*(exp(u/128.*LOG256)-1); + return s*scale_1*(exp(u/128.*LOG256) - 1); } -static OPUS_INLINE int lin2ulaw(float x) -{ +static OAC_INLINE int lin2ulaw(float x) { float u; float scale = 255.f/32768.f; int s = x >= 0 ? 1 : -1; x = fabs(x); - u = (s*(128*log_approx(1+scale*x)/LOG256)); + u = (s*(128*log_approx(1 + scale*x)/LOG256)); u = 128 + u; if (u < 0) u = 0; if (u > 255) u = 255; diff --git a/dnn/download_model.bat b/dnn/download_model.bat index f49eaa59d..c4522ff4e 100644 --- a/dnn/download_model.bat +++ b/dnn/download_model.bat @@ -7,3 +7,5 @@ if not exist %model% ( ) tar -xvzf %model% + +call dnn\rename_downloads.bat diff --git a/dnn/download_model.sh b/dnn/download_model.sh index 807efa623..ce7985f24 100755 --- a/dnn/download_model.sh +++ b/dnn/download_model.sh @@ -38,3 +38,4 @@ else fi tar xvzomf $model +dnn/rename_downloads.sh diff --git a/dnn/dred_coding.c b/dnn/dred_coding.c index 669ddc413..9b7b597b6 100644 --- a/dnn/dred_coding.c +++ b/dnn/dred_coding.c @@ -23,10 +23,10 @@ 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" +# include "config.h" #endif #include @@ -36,9 +36,9 @@ #include "dred_config.h" #include "dred_coding.h" -int compute_quantizer(int q0, int dQ, int qmax, int i) { - int quant; - static const int dQ_table[8] = {0, 2, 3, 4, 6, 8, 12, 16}; - quant = q0 + (dQ_table[dQ]*i + 8)/16; - return quant > qmax ? qmax : quant; +int oaci_compute_quantizer(int q0, int dQ, int qmax, int i) { + int quant; + static const int dQ_table[8] = {0, 2, 3, 4, 6, 8, 12, 16}; + quant = q0 + (dQ_table[dQ]*i + 8)/16; + return quant > qmax ? qmax : quant; } diff --git a/dnn/dred_coding.h b/dnn/dred_coding.h index 1ce040c23..791787c70 100644 --- a/dnn/dred_coding.h +++ b/dnn/dred_coding.h @@ -23,14 +23,14 @@ 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. -*/ + */ #ifndef DRED_CODING_H #define DRED_CODING_H -#include "opus_types.h" +#include "oac_types.h" #include "entcode.h" -int compute_quantizer(int q0, int dQ, int qmax, int i); +int oaci_compute_quantizer(int q0, int dQ, int qmax, int i); #endif diff --git a/dnn/dred_compare.c b/dnn/dred_compare.c index 478cc2166..dc93dbfd9 100644 --- a/dnn/dred_compare.c +++ b/dnn/dred_compare.c @@ -1,29 +1,29 @@ /* Copyright (c) 2011-2012 Xiph.Org Foundation, Mozilla Corporation Written by Jean-Marc Valin and Timothy B. Terriberry */ /* -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. -*/ + 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. + */ #include #include @@ -31,26 +31,26 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "mini_kfft.c" -#define MAX(a,b) ((a)>(b) ? (a) : (b)) -#define OPUS_PI (3.14159265F) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#define OAC_PI (3.14159265F) -#define OPUS_COSF(_x) ((float)cos(_x)) -#define OPUS_SINF(_x) ((float)sin(_x)) +#define OAC_COSF(_x) ((float)cos(_x)) +#define OAC_SINF(_x) ((float)sin(_x)) -static void *check_alloc(void *_ptr){ - if(_ptr==NULL){ - fprintf(stderr,"Out of memory.\n"); - exit(EXIT_FAILURE); - } - return _ptr; +static void *check_alloc(void *_ptr) { + if (_ptr == NULL) { + fprintf(stderr, "Out of memory.\n"); + exit(EXIT_FAILURE); + } + return _ptr; } -static void *opus_malloc(size_t _size){ - return check_alloc(malloc(_size)); +static void *oac_malloc(size_t _size) { + return check_alloc(malloc(_size)); } -static void *opus_realloc(void *_ptr,size_t _size){ - return check_alloc(realloc(_ptr,_size)); +static void *oac_realloc(void *_ptr, size_t _size) { + return check_alloc(realloc(_ptr, _size)); } #define FORMAT_S16_LE 0 @@ -68,184 +68,182 @@ typedef union { float f; } float_bits; -static void biquad(float *y, float mem[2], const float *x, +static void oaci_biquad(float *y, float mem[2], const float *x, const float *b, const float *a, int N) { - int i; - for (i=0;icsamples){ - do csamples=csamples<<1|1; - while(nsamples+nread>csamples); - samples=(float *)opus_realloc(samples, +static size_t read_pcm(float **_samples, FILE *_fin, int _nchannels, + int format) { + unsigned char buf[1024]; + float *samples; + size_t nsamples; + size_t csamples; + size_t xi; + size_t nread; + static const float a_hp[2] = {-1.97354f, 0.97417f}; + static const float b_hp[2] = {-2.f, 1.f}; + float mem[2] = {0}; + samples = NULL; + nsamples = csamples = 0; + int size = format_size[format]; + + for (;;) { + nread = fread(buf, size*_nchannels, 1024/(size*_nchannels), _fin); + if (nread <= 0) break; + if (nsamples + nread > csamples) { + do csamples = csamples<<1|1; + while (nsamples + nread > csamples); + samples = (float *)oac_realloc(samples, _nchannels*csamples*sizeof(*samples)); - } - if (format==FORMAT_S16_LE) { - for(xi=0;xi \n", _argv0); - fprintf(stderr," %s -features" + fprintf(stderr, " %s -features" " [-thresholds tot max pitch]" " \n", _argv0); } /* Taken from ancient CELT code */ -void psydecay_init(float *decayL, float *decayR, int len, int Fs) -{ - int i; - for (i=0;iBark function. */ - deriv = (8.288e-8 * f)/(3.4225e-16 *f*f*f*f + 1) - + .009694/(5.476e-7 *f*f + 1) + 1e-4; - /* Back to FFT bin units */ - deriv *= Fs*(1/(2.f*len)); - /* decay corresponding to -10dB/Bark */ - decayR[i] = pow(.1f, deriv); - /* decay corresponding to -25dB/Bark */ - decayL[i] = pow(0.0031623f, deriv); - /*printf ("%f %f\n", decayL[i], decayR[i]);*/ - } +void psydecay_init(float *decayL, float *decayR, int len, int Fs) { + int i; + for (i = 0; i < len; i++) { + float f; + float deriv; + /* Real frequency (in Hz) */ + f = Fs*i*(1/(2.f*len)); + /* This is the derivative of the Vorbis freq->Bark function. */ + deriv = (8.288e-8*f)/(3.4225e-16*f*f*f*f + 1) + + .009694/(5.476e-7*f*f + 1) + 1e-4; + /* Back to FFT bin units */ + deriv *= Fs*(1/(2.f*len)); + /* decay corresponding to -10dB/Bark */ + decayR[i] = pow(.1f, deriv); + /* decay corresponding to -25dB/Bark */ + decayL[i] = pow(0.0031623f, deriv); + /*printf ("%f %f\n", decayL[i], decayR[i]);*/ + } } #define PITCH_MIN 32 @@ -253,402 +251,402 @@ void psydecay_init(float *decayL, float *decayR, int len, int Fs) #define PITCH_FRAME 320 static float inner_prod(const float *x, const float *y, int len) { - float sum=0; - int i; - for (i=0;i 3) { - if(strcmp(_argv[1],"-s16")==0){ - format=FORMAT_S16_LE; - _argv++; - _argc--; - } else if(strcmp(_argv[1],"-s24")==0){ - format=FORMAT_S24_LE; - _argv++; - _argc--; - } else if(strcmp(_argv[1],"-f32")==0){ - format=FORMAT_F32_LE; - _argv++; - _argc--; - } else if(strcmp(_argv[1],"-skip")==0){ - skip=atoi(_argv[2]); - _argv+=2; - _argc-=2; - } else if(strcmp(_argv[1],"-thresholds")==0){ - if (_argc < 7) { +int compare_audio(int _argc, const char **_argv, const char *argv0) { + FILE *fin1; + FILE *fin2; + float *x; + float *y; + float *X; + float *Y; + double err4; + double err16; + double T2; + size_t xlength; + size_t ylength; + size_t nframes; + size_t xi; + int ci; + int xj; + int bi; + int nchannels; + int downsample; + int nbands; + int ybands; + int nfreqs; + int yfreqs; + size_t test_win_size; + size_t test_win_step; + int max_compare; + int format; + int skip = 0; + double err4_threshold = -1, err16_threshold = -1, pitch_threshold = -1; + int compare_thresholds = 0; + float decayL[NFREQS], decayR[NFREQS]; + float norm[NFREQS]; + float pitch_error = 0; + int pitch_count = 0; + psydecay_init(decayL, decayR, NFREQS, 16000); + if (_argc < 3) { usage(argv0); return EXIT_FAILURE; - } - err4_threshold=atof(_argv[2]); - err16_threshold=atof(_argv[3]); - pitch_threshold=atof(_argv[4]); - compare_thresholds=1; - _argv+=4; - _argc-=4; - } else { - usage(argv0); - return EXIT_FAILURE; } - } - if(_argc!=3){ - usage(argv0); - return EXIT_FAILURE; - } - downsample=1; - yfreqs=nfreqs/downsample; - fin1=fopen(_argv[1],"rb"); - if(fin1==NULL){ - fprintf(stderr,"Error opening '%s'.\n",_argv[1]); - return EXIT_FAILURE; - } - fin2=fopen(_argv[2],"rb"); - if(fin2==NULL){ - fprintf(stderr,"Error opening '%s'.\n",_argv[2]); + nchannels = 1; + ybands = nbands = NBANDS; + nfreqs = NFREQS; + test_win_size = TEST_WIN_SIZE; + test_win_step = TEST_WIN_STEP; + downsample = 1; + format = FORMAT_S16_LE; + while (_argc > 3) { + if (strcmp(_argv[1], "-s16") == 0) { + format = FORMAT_S16_LE; + _argv++; + _argc--; + } else if (strcmp(_argv[1], "-s24") == 0) { + format = FORMAT_S24_LE; + _argv++; + _argc--; + } else if (strcmp(_argv[1], "-f32") == 0) { + format = FORMAT_F32_LE; + _argv++; + _argc--; + } else if (strcmp(_argv[1], "-skip") == 0) { + skip = atoi(_argv[2]); + _argv += 2; + _argc -= 2; + } else if (strcmp(_argv[1], "-thresholds") == 0) { + if (_argc < 7) { + usage(argv0); + return EXIT_FAILURE; + } + err4_threshold = atof(_argv[2]); + err16_threshold = atof(_argv[3]); + pitch_threshold = atof(_argv[4]); + compare_thresholds = 1; + _argv += 4; + _argc -= 4; + } else { + usage(argv0); + return EXIT_FAILURE; + } + } + if (_argc != 3) { + usage(argv0); + return EXIT_FAILURE; + } + downsample = 1; + yfreqs = nfreqs/downsample; + fin1 = fopen(_argv[1], "rb"); + if (fin1 == NULL) { + fprintf(stderr, "Error opening '%s'.\n", _argv[1]); + return EXIT_FAILURE; + } + fin2 = fopen(_argv[2], "rb"); + if (fin2 == NULL) { + fprintf(stderr, "Error opening '%s'.\n", _argv[2]); + fclose(fin1); + return EXIT_FAILURE; + } + /*Read in the data and allocate scratch space.*/ + xlength = read_pcm(&x, fin1, 1, format); fclose(fin1); - return EXIT_FAILURE; - } - /*Read in the data and allocate scratch space.*/ - xlength=read_pcm(&x,fin1,1,format); - fclose(fin1); - ylength=read_pcm(&y,fin2,nchannels,format); - fclose(fin2); - skip *= nchannels; - y += skip/downsample; - ylength -= skip/downsample; - if (ylength*downsample > xlength) ylength = xlength/downsample; - if(xlength!=ylength*downsample){ - fprintf(stderr,"Sample counts do not match (%lu!=%lu).\n", - (unsigned long)xlength,(unsigned long)ylength*downsample); - return EXIT_FAILURE; - } - if(xlength xlength) ylength = xlength/downsample; + if (xlength != ylength*downsample) { + fprintf(stderr, "Sample counts do not match (%lu!=%lu).\n", + (unsigned long)xlength, (unsigned long)ylength*downsample); + return EXIT_FAILURE; + } + if (xlength < test_win_size) { + fprintf(stderr, "Insufficient sample data (%lu<%lu).\n", + (unsigned long)xlength, (unsigned long)test_win_size); + return EXIT_FAILURE; + } + nframes = (xlength - test_win_size + test_win_step)/test_win_step; + X = (float *)oac_malloc(nframes*nfreqs*nchannels*sizeof(*X)); + Y = (float *)oac_malloc(nframes*yfreqs*nchannels*sizeof(*Y)); + + for (xi = 2; xi < nframes - 2; xi++) { + float xcorr[PITCH_MAX + 1], ycorr[PITCH_MAX + 1]; + int i; + float maxcorr = -1; + int pitch = 0; + compute_xcorr(&x[xi*TEST_WIN_STEP], xcorr); + compute_xcorr(&y[xi*TEST_WIN_STEP], ycorr); + for (i = PITCH_MIN; i <= PITCH_MAX; i++) { + if (xcorr[i] > maxcorr) { + maxcorr = xcorr[i]; + pitch = i; + } + } + if (xcorr[pitch] > .7) { + pitch_error += fabs(xcorr[pitch] - ycorr[pitch]); + pitch_count++; + } + } + pitch_error /= pitch_count; + + /*Compute the per-band spectral energy of the original signal + and the error.*/ + spectrum(X, BANDS, nbands, x, nchannels, nframes, + test_win_size, test_win_step, 1); + free(x); + spectrum(Y, BANDS, ybands, y, nchannels, nframes, + test_win_size/downsample, test_win_step/downsample, downsample); + free(y - skip/downsample); + + norm[0] = 1; + for (xj = 1; xj < NFREQS; xj++) { + norm[xj] = 1 + decayR[xj]*norm[xj - 1]; + } + for (xj = NFREQS - 2; xj >= 0; xj--) { + norm[xj] = norm[xj] + decayL[xj]*norm[xj + 1]; + } + for (xj = 0; xj < NFREQS; xj++) norm[xj] = 1.f/norm[xj]; + for (xi = 0; xi < nframes; xi++) { + for (xj = 1; xj < NFREQS; xj++) { + X[xi*nfreqs + xj] = X[xi*nfreqs + xj] + decayR[xj]*X[xi*nfreqs + xj - 1]; + Y[xi*nfreqs + xj] = Y[xi*nfreqs + xj] + decayR[xj]*Y[xi*nfreqs + xj - 1]; + } + for (xj = NFREQS - 2; xj >= 0; xj--) { + X[xi*nfreqs + xj] = X[xi*nfreqs + xj] + decayL[xj]*X[xi*nfreqs + xj + 1]; + Y[xi*nfreqs + xj] = Y[xi*nfreqs + xj] + decayL[xj]*Y[xi*nfreqs + xj + 1]; + } + for (xj = 0; xj < NFREQS; xj++) { + X[xi*nfreqs + xj] *= norm[xj]; + Y[xi*nfreqs + xj] *= norm[xj]; + } + } - for(xi=2;xi maxcorr) { - maxcorr = xcorr[i]; - pitch = i; - } - } - if (xcorr[pitch] > .7) { - pitch_error += fabs(xcorr[pitch]-ycorr[pitch]); - pitch_count++; - } - } - pitch_error /= pitch_count; - - /*Compute the per-band spectral energy of the original signal - and the error.*/ - spectrum(X,BANDS,nbands,x,nchannels,nframes, - test_win_size,test_win_step,1); - free(x); - spectrum(Y,BANDS,ybands,y,nchannels,nframes, - test_win_size/downsample,test_win_step/downsample,downsample); - free(y-skip/downsample); - - norm[0]=1; - for(xj=1;xj=0;xj--){ - norm[xj] = norm[xj] + decayL[xj]*norm[xj+1]; - } - for(xj=0;xj=0;xj--){ - X[xi*nfreqs+xj] = X[xi*nfreqs+xj]+decayL[xj]*X[xi*nfreqs+xj+1]; - Y[xi*nfreqs+xj] = Y[xi*nfreqs+xj]+decayL[xj]*Y[xi*nfreqs+xj+1]; - } - for(xj=0;xj0){ - for(xj=0;xj0;){ - for(xj=0;xj 0) { + for (xj = 0; xj < NFREQS; xj++) { + X[xi*nfreqs + xj] += .5f*X[(xi - 1)*nfreqs + xj]; + Y[xi*nfreqs + xj] += .5f*Y[(xi - 1)*nfreqs + xj]; + } + } + } + + /*Backward temporal masking: -10 dB/2.5ms slope.*/ + for (xi = nframes - 2; xi-- > 0;) { + for (xj = 0; xj < NFREQS; xj++) { + X[xi*nfreqs + xj] += .1f*X[(xi + 1)*nfreqs + xj]; + Y[xi*nfreqs + xj] += .1f*Y[(xi + 1)*nfreqs + xj]; + } + } + + max_compare = BANDS[nbands]; + err4 = 0; + err16 = 0; + T2 = 0; + for (xi = 0; xi < nframes; xi++) { + double Ef2, Ef4, Tf2; + Ef2 = 0; + Ef4 = 0; + Tf2 = 0; + for (bi = 0; bi < ybands; bi++) { + double Eb2, Eb4, Tb2; + double w; + Tb2 = Eb2 = Eb4 = 0; + w = 1.f/(BANDS[bi + 1] - BANDS[bi]); + for (xj = BANDS[bi]; xj < BANDS[bi + 1] && xj < max_compare; xj++) { + float f, thresh; + f = xj*OAC_PI/960; + /* Shape the lower threshold similar to 1/(1 - 0.85*z^-1) + oaci_deemphasis filter at 48 kHz. */ + thresh = .1/(.15*.15 + f*f); + for (ci = 0; ci < nchannels; ci++) { + float re; + float im; + re = pow(Y[(xi*yfreqs + xj)*nchannels + ci] + thresh, LOUDNESS) + - pow(X[(xi*nfreqs + xj)*nchannels + ci] + thresh, LOUDNESS); + im = re*re; + Tb2 += w*pow(X[(xi*nfreqs + xj)*nchannels + ci] + thresh, 2*LOUDNESS); - /* Per-band error weighting. */ - im *= w; - Eb2+=im; - /* Same for 4th power, but make it less sensitive to - very low energies. */ - re = pow(Y[(xi*yfreqs+xj)*nchannels+ci]+10*thresh,LOUDNESS) - - pow(X[(xi*nfreqs+xj)*nchannels+ci]+10*thresh,LOUDNESS); - im = re*re; - /* Per-band error weighting. */ - im *= w; - Eb4+=im; + /* Per-band error weighting. */ + im *= w; + Eb2 += im; + /* Same for 4th power, but make it less sensitive to + very low energies. */ + re = pow(Y[(xi*yfreqs + xj)*nchannels + ci] + 10*thresh, LOUDNESS) + - pow(X[(xi*nfreqs + xj)*nchannels + ci] + 10*thresh, LOUDNESS); + im = re*re; + /* Per-band error weighting. */ + im *= w; + Eb4 += im; + } + } + Eb2 /= (BANDS[bi + 1] - BANDS[bi])*nchannels; + Eb4 /= (BANDS[bi + 1] - BANDS[bi])*nchannels; + Tb2 /= (BANDS[bi + 1] - BANDS[bi])*nchannels; + Ef2 += Eb2; + Ef4 += Eb4*Eb4; + Tf2 += Tb2; } - } - Eb2 /= (BANDS[bi+1]-BANDS[bi])*nchannels; - Eb4 /= (BANDS[bi+1]-BANDS[bi])*nchannels; - Tb2 /= (BANDS[bi+1]-BANDS[bi])*nchannels; - Ef2 += Eb2; - Ef4 += Eb4*Eb4; - Tf2 += Tb2; - } - Ef2/=nbands; - Ef4/=nbands; - Ef4*=Ef4; - Tf2/=nbands; - err4+=Ef2*Ef2; - err16+=Ef4*Ef4; - T2 += Tf2; - } - free(X); - free(Y); - err4=100*pow(err4/nframes,1.0/4)/sqrt(T2); - err16=100*pow(err16/nframes,1.0/16)/sqrt(T2); - fprintf(stderr, "err4 = %f, err16 = %f, pitch = %f\n", + Ef2 /= nbands; + Ef4 /= nbands; + Ef4 *= Ef4; + Tf2 /= nbands; + err4 += Ef2*Ef2; + err16 += Ef4*Ef4; + T2 += Tf2; + } + free(X); + free(Y); + err4 = 100*pow(err4/nframes, 1.0/4)/sqrt(T2); + err16 = 100*pow(err16/nframes, 1.0/16)/sqrt(T2); + fprintf(stderr, "err4 = %f, err16 = %f, pitch = %f\n", err4, err16, pitch_error); - if (compare_thresholds) { - if (err4 <= err4_threshold && err16 <= err16_threshold && pitch_error <= pitch_threshold) { - fprintf(stderr, "Comparison PASSED\n"); - } else { - fprintf(stderr, "*** Comparison FAILED ***" + if (compare_thresholds) { + if (err4 <= err4_threshold && err16 <= err16_threshold && pitch_error <= pitch_threshold) { + fprintf(stderr, "Comparison PASSED\n"); + } else { + fprintf(stderr, "*** Comparison FAILED ***" " (thresholds were %f %f %f)\n", err4_threshold, err16_threshold, pitch_threshold); - return EXIT_FAILURE; + return EXIT_FAILURE; + } } - } - return EXIT_SUCCESS; + return EXIT_SUCCESS; } #define NB_FEATURES 20 -int compare_features(int _argc,const char **_argv, const char *argv0){ - FILE *fin1=NULL; - FILE *fin2=NULL; - int i; - float mse[NB_FEATURES]={0}; - int count=0; - int pitch_count=0; - float pitch_error=0; - float tot_error=0, max_error=0; - float tot_threshold=-1, max_threshold=-1, pitch_threshold=-1; - int compare_thresholds=0; - if(strcmp(_argv[1],"-thresholds")==0){ - if (_argc < 7) { - usage(argv0); - return EXIT_FAILURE; - } - tot_threshold=atof(_argv[2]); - max_threshold=atof(_argv[3]); - pitch_threshold=atof(_argv[4]); - compare_thresholds=1; - _argv+=4; - _argc-=4; - } - if(_argc!=3) { - usage(argv0); - return EXIT_FAILURE; - } - fin1=fopen(_argv[1],"rb"); - if(fin1==NULL){ - fprintf(stderr,"Error opening '%s'.\n",_argv[1]); - return EXIT_FAILURE; - } - fin2=fopen(_argv[2],"rb"); - if(fin2==NULL){ - fprintf(stderr,"Error opening '%s'.\n",_argv[2]); - fclose(fin1); - return EXIT_FAILURE; - } - while (1) { - int ret; - float x[NB_FEATURES], y[NB_FEATURES]; - unsigned char buf[NB_FEATURES*4]; - ret = fread(buf, NB_FEATURES*4, 1, fin1); - if (ret != 1) break; - buf_to_float(buf, x, NB_FEATURES); - ret = fread(buf, NB_FEATURES*4, 1, fin2); - if (ret != 1) { - fprintf(stderr, "Error: truncated test file\n"); - return EXIT_FAILURE; - } - buf_to_float(buf, y, NB_FEATURES); - for (i=0;i .2) { - pitch_error += fabs(x[NB_FEATURES-2]-y[NB_FEATURES-2]); - pitch_count++; - } - count++; - } - pitch_error /= pitch_count; - for(i=0;i .2) { + pitch_error += fabs(x[NB_FEATURES - 2] - y[NB_FEATURES - 2]); + pitch_count++; + } + count++; + } + pitch_error /= pitch_count; + for (i = 0; i < NB_FEATURES; i++) { + mse[i] /= count; + if (i != NB_FEATURES - 2) { + tot_error += mse[i]; + max_error = MAX(max_error, mse[i]); + } + } + tot_error = sqrt(tot_error); + max_error = sqrt(max_error); + fprintf(stderr, "total = %f, max = %f, pitch = %f\n", tot_error, max_error, pitch_error); + if (compare_thresholds) { + if (tot_error <= tot_threshold && max_error <= max_threshold && pitch_error <= pitch_threshold) { + fprintf(stderr, "Comparison PASSED\n"); + } else { + fprintf(stderr, "*** Comparison FAILED ***" " (thresholds were %f %f %f)\n", tot_threshold, max_threshold, pitch_threshold); - return EXIT_FAILURE; - } - } - if (fin1) fclose(fin1); - if (fin2) fclose(fin2); - return EXIT_SUCCESS; + return EXIT_FAILURE; + } + } + if (fin1) fclose(fin1); + if (fin2) fclose(fin2); + return EXIT_SUCCESS; } -int main(int _argc,const char **_argv){ - if (_argc<3) { - usage(_argv[0]); - } else if (strcmp(_argv[1], "-audio")==0) { - return compare_audio(_argc-1, _argv+1, _argv[0]); - } else if (strcmp(_argv[1], "-features")==0) { - return compare_features(_argc-1, _argv+1, _argv[0]); - } else { - fprintf(stderr, "%s: First argument must be either -audio or -features\n\n", _argv[0]); - usage(_argv[0]); - } - return EXIT_FAILURE; +int main(int _argc, const char **_argv) { + if (_argc < 3) { + usage(_argv[0]); + } else if (strcmp(_argv[1], "-audio") == 0) { + return compare_audio(_argc - 1, _argv + 1, _argv[0]); + } else if (strcmp(_argv[1], "-features") == 0) { + return compare_features(_argc - 1, _argv + 1, _argv[0]); + } else { + fprintf(stderr, "%s: First argument must be either -audio or -features\n\n", _argv[0]); + usage(_argv[0]); + } + return EXIT_FAILURE; } diff --git a/dnn/dred_config.h b/dnn/dred_config.h index d84f89658..000e728f0 100644 --- a/dnn/dred_config.h +++ b/dnn/dred_config.h @@ -23,7 +23,7 @@ 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. -*/ + */ #ifndef DRED_CONFIG_H #define DRED_CONFIG_H @@ -39,9 +39,9 @@ #define DRED_MIN_BYTES 8 /* these are inpart duplicates to the values defined in dred_rdovae_constants.h */ -#define DRED_SILK_ENCODER_DELAY (79+12-80) +#define DRED_SILK_ENCODER_DELAY (79 + 12 - 80) #define DRED_FRAME_SIZE 160 -#define DRED_DFRAME_SIZE (2 * (DRED_FRAME_SIZE)) +#define DRED_DFRAME_SIZE (2*(DRED_FRAME_SIZE)) #define DRED_MAX_DATA_SIZE 1000 #define DRED_ENC_Q0 6 #define DRED_ENC_Q1 15 diff --git a/dnn/dred_decoder.c b/dnn/dred_decoder.c index a45a76468..e2325e967 100644 --- a/dnn/dred_decoder.c +++ b/dnn/dred_decoder.c @@ -23,12 +23,12 @@ 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. -*/ + */ #include #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif #include "os_support.h" @@ -39,91 +39,89 @@ #include "dred_rdovae_stats_data.h" #include "dred_rdovae_constants.h" -void dred_decode_latents(ec_dec *dec, float *x, const opus_uint8 *scale, const opus_uint8 *r, const opus_uint8 *p0, int dim) { +void oaci_dred_decode_latents(ec_dec *dec, float *x, const oac_uint8 *scale, const oac_uint8 *r, const oac_uint8 *p0, + int dim) { int i; - for (i=0;idred_offset = 16 - ec_dec_uint(&ec, 32) - extra_offset + dred_frame_offset; - /*printf("%d %d %d\n", dred_offset, q0, dQ);*/ - qmax = 15; - if (q0 < 14 && dQ > 0) { - int nvals; - int ft; - int s; - /* The distribution for the dQmax symbol is split evenly between zero - (which implies qmax == 15) and larger values, with the probability of - all larger values being uniform. - This is equivalent to coding 1 bit to decide if the maximum is less than - 15 followed by a uint to decide the actual value if it is less than - 15, but combined into a single symbol. */ - nvals = 15 - (q0 + 1); - ft = 2*nvals; - s = ec_decode(&ec, ft); - if (s >= nvals) { - qmax = q0 + (s - nvals) + 1; - ec_dec_update(&ec, s, s + 1, ft); - } - else { - ec_dec_update(&ec, 0, nvals, ft); + /* decode initial state and initialize RDOVAE decoder */ + oaci_ec_dec_init(&ec, (unsigned char*)bytes, num_bytes); + q0 = oaci_ec_dec_uint(&ec, 16); + dQ = oaci_ec_dec_uint(&ec, 8); + if (oaci_ec_dec_uint(&ec, 2)) extra_offset = 32*oaci_ec_dec_uint(&ec, 256); + else extra_offset = 0; + /* Compute total offset, including DRED position in a multiframe packet. */ + dec->dred_offset = 16 - oaci_ec_dec_uint(&ec, 32) - extra_offset + dred_frame_offset; + /*printf("%d %d %d\n", dred_offset, q0, dQ);*/ + qmax = 15; + if (q0 < 14 && dQ > 0) { + int nvals; + int ft; + int s; + /* The distribution for the dQmax symbol is split evenly between zero + (which implies qmax == 15) and larger values, with the probability of + all larger values being uniform. + This is equivalent to coding 1 bit to decide if the maximum is less than + 15 followed by a uint to decide the actual value if it is less than + 15, but combined into a single symbol. */ + nvals = 15 - (q0 + 1); + ft = 2*nvals; + s = oaci_ec_decode(&ec, ft); + if (s >= nvals) { + qmax = q0 + (s - nvals) + 1; + oaci_ec_dec_update(&ec, s, s + 1, ft); + } else { + oaci_ec_dec_update(&ec, 0, nvals, ft); + } } - } - state_qoffset = q0*DRED_STATE_DIM; - dred_decode_latents( + state_qoffset = q0*DRED_STATE_DIM; + oaci_dred_decode_latents( &ec, dec->state, - dred_state_quant_scales_q8 + state_qoffset, - dred_state_r_q8 + state_qoffset, - dred_state_p0_q8 + state_qoffset, + oaci_dred_state_quant_scales_q8 + state_qoffset, + oaci_dred_state_r_q8 + state_qoffset, + oaci_dred_state_p0_q8 + state_qoffset, DRED_STATE_DIM); - /* decode newest to oldest and store oldest to newest */ - for (i = 0; i < IMIN(DRED_NUM_REDUNDANCY_FRAMES, (min_feature_frames+1)/2); i += 2) - { - /* FIXME: Figure out how to avoid missing a last frame that would take up < 8 bits. */ - if (8*num_bytes - ec_tell(&ec) <= 7) - break; - q_level = compute_quantizer(q0, dQ, qmax, i/2); - offset = q_level*DRED_LATENT_DIM; - dred_decode_latents( + /* decode newest to oldest and store oldest to newest */ + for (i = 0; i < IMIN(DRED_NUM_REDUNDANCY_FRAMES, (min_feature_frames + 1)/2); i += 2) { + /* FIXME: Figure out how to avoid missing a last frame that would take up < 8 bits. */ + if (8*num_bytes - oaci_ec_tell(&ec) <= 7) + break; + q_level = oaci_compute_quantizer(q0, dQ, qmax, i/2); + offset = q_level*DRED_LATENT_DIM; + oaci_dred_decode_latents( &ec, - &dec->latents[(i/2)*(DRED_LATENT_DIM+1)], - dred_latent_quant_scales_q8 + offset, - dred_latent_r_q8 + offset, - dred_latent_p0_q8 + offset, + &dec->latents[(i/2)*(DRED_LATENT_DIM + 1)], + oaci_dred_latent_quant_scales_q8 + offset, + oaci_dred_latent_r_q8 + offset, + oaci_dred_latent_p0_q8 + offset, DRED_LATENT_DIM - ); - dec->latents[(i/2)*(DRED_LATENT_DIM+1)+DRED_LATENT_DIM] = q_level*.125-1; - offset = 2 * i * DRED_NUM_FEATURES; - } - dec->process_stage = 1; - dec->nb_latents = i/2; - return i/2; + ); + dec->latents[(i/2)*(DRED_LATENT_DIM + 1) + DRED_LATENT_DIM] = q_level*.125 - 1; + offset = 2*i*DRED_NUM_FEATURES; + } + dec->process_stage = 1; + dec->nb_latents = i/2; + return i/2; } diff --git a/dnn/dred_decoder.h b/dnn/dred_decoder.h index 74d1dfcd9..38fb53c32 100644 --- a/dnn/dred_decoder.h +++ b/dnn/dred_decoder.h @@ -23,27 +23,27 @@ 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. -*/ + */ #ifndef DRED_DECODER_H #define DRED_DECODER_H -#include "opus.h" +#include "oac.h" #include "dred_config.h" #include "dred_rdovae.h" #include "entcode.h" #include "dred_rdovae_constants.h" -struct OpusDRED { - float fec_features[2*DRED_NUM_REDUNDANCY_FRAMES*DRED_NUM_FEATURES]; - float state[DRED_STATE_DIM]; - float latents[(DRED_NUM_REDUNDANCY_FRAMES/2)*(DRED_LATENT_DIM+1)]; - int nb_latents; - int process_stage; - int dred_offset; +struct OacDRED { + float fec_features[2*DRED_NUM_REDUNDANCY_FRAMES*DRED_NUM_FEATURES]; + float state[DRED_STATE_DIM]; + float latents[(DRED_NUM_REDUNDANCY_FRAMES/2)*(DRED_LATENT_DIM + 1)]; + int nb_latents; + int process_stage; + int dred_offset; }; -int dred_ec_decode(OpusDRED *dec, const opus_uint8 *bytes, int num_bytes, int min_feature_frames, int dred_frame_offset); +int oaci_dred_ec_decode(OacDRED *dec, const oac_uint8 *bytes, int num_bytes, int min_feature_frames, int dred_frame_offset); #endif diff --git a/dnn/dred_encoder.c b/dnn/dred_encoder.c index aa65e4fb5..def50561f 100644 --- a/dnn/dred_encoder.c +++ b/dnn/dred_encoder.c @@ -23,17 +23,17 @@ 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" +# include "config.h" #endif #include #if 0 -#include -#include +# include +# include #endif #include "dred_encoder.h" @@ -47,81 +47,77 @@ #include "dred_rdovae_stats_data.h" -static void DRED_rdovae_init_encoder(RDOVAEEncState *enc_state) -{ +static void oaci_DRED_rdovae_init_encoder(RDOVAEEncState *enc_state) { memset(enc_state, 0, sizeof(*enc_state)); } -int dred_encoder_load_model(DREDEnc* enc, const void *data, int len) -{ +int oaci_dred_encoder_load_model(DREDEnc* enc, const void *data, int len) { WeightArray *list; int ret; - parse_weights(&list, data, len); - ret = init_rdovaeenc(&enc->model, list); - opus_free(list); + oaci_parse_weights(&list, data, len); + ret = oaci_init_rdovaeenc(&enc->model, list); + oac_free(list); if (ret == 0) { - ret = lpcnet_encoder_load_model(&enc->lpcnet_enc_state, data, len); + ret = oaci_lpcnet_encoder_load_model(&enc->lpcnet_enc_state, data, len); } if (ret == 0) enc->loaded = 1; - return (ret == 0) ? OPUS_OK : OPUS_BAD_ARG; + return (ret == 0) ? OAC_OK : OAC_BAD_ARG; } -void dred_encoder_reset(DREDEnc* enc) -{ - OPUS_CLEAR((char*)&enc->DREDENC_RESET_START, - sizeof(DREDEnc)- - ((char*)&enc->DREDENC_RESET_START - (char*)enc)); +void oaci_dred_encoder_reset(DREDEnc* enc) { + OAC_CLEAR((char*)&enc->DREDENC_RESET_START, + sizeof(DREDEnc) + - ((char*)&enc->DREDENC_RESET_START - (char*)enc)); enc->input_buffer_fill = DRED_SILK_ENCODER_DELAY; - lpcnet_encoder_init(&enc->lpcnet_enc_state); - DRED_rdovae_init_encoder(&enc->rdovae_enc); + oaci_lpcnet_encoder_init(&enc->lpcnet_enc_state); + oaci_DRED_rdovae_init_encoder(&enc->rdovae_enc); } -void dred_encoder_init(DREDEnc* enc, opus_int32 Fs, int channels) -{ +void oaci_dred_encoder_init(DREDEnc* enc, oac_int32 Fs, int channels) { enc->Fs = Fs; enc->channels = channels; enc->loaded = 0; #ifndef USE_WEIGHTS_FILE - if (init_rdovaeenc(&enc->model, rdovaeenc_arrays) == 0) enc->loaded = 1; + if (oaci_init_rdovaeenc(&enc->model, oaci_rdovaeenc_arrays) == 0) enc->loaded = 1; #endif - dred_encoder_reset(enc); + oaci_dred_encoder_reset(enc); } -static void dred_process_frame(DREDEnc *enc, int arch) -{ - float feature_buffer[2 * 36]; +static void oaci_dred_process_frame(DREDEnc *enc, int arch) { + float feature_buffer[2*36]; float input_buffer[2*DRED_NUM_FEATURES] = {0}; celt_assert(enc->loaded); /* shift latents buffer */ - OPUS_MOVE(enc->latents_buffer + DRED_LATENT_DIM, enc->latents_buffer, (DRED_MAX_FRAMES - 1) * DRED_LATENT_DIM); - OPUS_MOVE(enc->state_buffer + DRED_STATE_DIM, enc->state_buffer, (DRED_MAX_FRAMES - 1) * DRED_STATE_DIM); + OAC_MOVE(enc->latents_buffer + DRED_LATENT_DIM, enc->latents_buffer, (DRED_MAX_FRAMES - 1)*DRED_LATENT_DIM); + OAC_MOVE(enc->state_buffer + DRED_STATE_DIM, enc->state_buffer, (DRED_MAX_FRAMES - 1)*DRED_STATE_DIM); /* calculate LPCNet features */ - lpcnet_compute_single_frame_features_float(&enc->lpcnet_enc_state, enc->input_buffer, feature_buffer, arch); - lpcnet_compute_single_frame_features_float(&enc->lpcnet_enc_state, enc->input_buffer + DRED_FRAME_SIZE, feature_buffer + 36, arch); + oaci_lpcnet_compute_single_frame_features_float(&enc->lpcnet_enc_state, enc->input_buffer, feature_buffer, arch); + oaci_lpcnet_compute_single_frame_features_float(&enc->lpcnet_enc_state, enc->input_buffer + DRED_FRAME_SIZE, + feature_buffer + 36, arch); /* prepare input buffer (discard LPC coefficients) */ - OPUS_COPY(input_buffer, feature_buffer, DRED_NUM_FEATURES); - OPUS_COPY(input_buffer + DRED_NUM_FEATURES, feature_buffer + 36, DRED_NUM_FEATURES); + OAC_COPY(input_buffer, feature_buffer, DRED_NUM_FEATURES); + OAC_COPY(input_buffer + DRED_NUM_FEATURES, feature_buffer + 36, DRED_NUM_FEATURES); /* run RDOVAE encoder */ - dred_rdovae_encode_dframe(&enc->rdovae_enc, &enc->model, enc->latents_buffer, enc->state_buffer, input_buffer, arch); - enc->latents_buffer_fill = IMIN(enc->latents_buffer_fill+1, DRED_NUM_REDUNDANCY_FRAMES); + oaci_dred_rdovae_encode_dframe(&enc->rdovae_enc, &enc->model, enc->latents_buffer, enc->state_buffer, input_buffer, + arch); + enc->latents_buffer_fill = IMIN(enc->latents_buffer_fill + 1, DRED_NUM_REDUNDANCY_FRAMES); } -void filter_df2t(const float *in, float *out, int len, float b0, const float *b, const float *a, int order, float *mem) -{ +void oaci_filter_df2t(const float *in, float *out, int len, float b0, const float *b, const float *a, int order, + float *mem) { int i; - for (i=0;ichannels*in_len <= MAX_DOWNMIX_BUFFER); - celt_assert(in_len * (opus_int32)16000 == out_len * enc->Fs); - switch(enc->Fs) { + celt_assert(in_len*(oac_int32)16000 == out_len*enc->Fs); + switch (enc->Fs) { case 8000: up = 2; break; @@ -165,70 +160,76 @@ static void dred_convert_to_16k(DREDEnc *enc, const float *in, int in_len, float celt_assert(0); } celt_assert(up*in_len <= MAX_DOWNMIX_BUFFER); - OPUS_CLEAR(downmix, up*in_len); + OAC_CLEAR(oaci_downmix, up*in_len); if (enc->channels == 1) { - for (i=0;iFs == 16000) { - OPUS_COPY(out, downmix, out_len); + OAC_COPY(out, oaci_downmix, out_len); } else if (enc->Fs == 48000 || enc->Fs == 24000) { /* ellip(7, .2, 70, 7750/24000) */ - static const float filter_b[8] = { 0.005873358047f, 0.012980854831f, 0.014531340042f, 0.014531340042f, 0.012980854831f, 0.005873358047f, 0.004523418224f, 0.f}; - static const float filter_a[8] = {-3.878718597768f, 7.748834257468f, -9.653651699533f, 8.007342726666f, -4.379450178552f, 1.463182111810f, -0.231720677804f, 0.f}; + static const float filter_b[8] = { 0.005873358047f, 0.012980854831f, 0.014531340042f, 0.014531340042f, + 0.012980854831f, 0.005873358047f, 0.004523418224f, 0.f}; + static const float filter_a[8] = {-3.878718597768f, 7.748834257468f, -9.653651699533f, 8.007342726666f, + -4.379450178552f, 1.463182111810f, -0.231720677804f, 0.f}; float b0 = 0.004523418224f; - filter_df2t(downmix, downmix, up*in_len, b0, filter_b, filter_a, RESAMPLING_ORDER, enc->resample_mem); - for (i=0;iresample_mem); + for (i = 0; i < out_len; i++)out[i] = oaci_downmix[3*i]; } else if (enc->Fs == 12000) { /* ellip(7, .2, 70, 5800/24000) */ - static const float filter_b[8] = {-0.001017101081f, 0.003673127243f, 0.001009165267f, 0.001009165267f, 0.003673127243f, -0.001017101081f, 0.002033596776f, 0.f}; - static const float filter_a[8] = {-4.930414411612f, 11.291643096504f, -15.322037343815f, 13.216403930898f, -7.220409219553f, 2.310550142771f, -0.334338618782f, 0.f}; + static const float filter_b[8] = {-0.001017101081f, 0.003673127243f, 0.001009165267f, 0.001009165267f, + 0.003673127243f, -0.001017101081f, 0.002033596776f, 0.f}; + static const float filter_a[8] = {-4.930414411612f, 11.291643096504f, -15.322037343815f, 13.216403930898f, + -7.220409219553f, 2.310550142771f, -0.334338618782f, 0.f}; float b0 = 0.002033596776f; - filter_df2t(downmix, downmix, up*in_len, b0, filter_b, filter_a, RESAMPLING_ORDER, enc->resample_mem); - for (i=0;iresample_mem); + for (i = 0; i < out_len; i++)out[i] = oaci_downmix[3*i]; } else if (enc->Fs == 8000) { /* ellip(7, .2, 70, 3900/8000) */ - static const float filter_b[8] = { 0.081670120929f, 0.180401598565f, 0.259391051971f, 0.259391051971f, 0.180401598565f, 0.081670120929f, 0.020109185709f, 0.f}; - static const float filter_a[8] = {-1.393651933659f, 2.609789872676f, -2.403541968806f, 2.056814957331f, -1.148908574570f, 0.473001413788f, -0.110359852412f, 0.f}; + static const float filter_b[8] = { 0.081670120929f, 0.180401598565f, 0.259391051971f, 0.259391051971f, + 0.180401598565f, 0.081670120929f, 0.020109185709f, 0.f}; + static const float filter_a[8] = {-1.393651933659f, 2.609789872676f, -2.403541968806f, 2.056814957331f, + -1.148908574570f, 0.473001413788f, -0.110359852412f, 0.f}; float b0 = 0.020109185709f; - filter_df2t(downmix, out, out_len, b0, filter_b, filter_a, RESAMPLING_ORDER, enc->resample_mem); + oaci_filter_df2t(oaci_downmix, out, out_len, b0, filter_b, filter_a, RESAMPLING_ORDER, enc->resample_mem); #ifdef ENABLE_QEXT } else if (enc->Fs == 96000) { /* ellip(7, .2, 70, 7750/48000) */ - static const float filter_b[8] = { -0.002160290245f, 0.002887088080f, -0.001214921271f, -0.001214921271f, 0.002887088080f, -0.002160290245f, 0.000880286074f, 0.f}; - static const float filter_a[8] = {-5.813483928050f, 14.932091805554f, -21.900933283269f, 19.774128964756f, -10.978028462771f, 3.467650469467f, -0.480641240411f, 0.f}; + static const float filter_b[8] = { -0.002160290245f, 0.002887088080f, -0.001214921271f, -0.001214921271f, + 0.002887088080f, -0.002160290245f, 0.000880286074f, 0.f}; + static const float filter_a[8] = {-5.813483928050f, 14.932091805554f, -21.900933283269f, 19.774128964756f, + -10.978028462771f, 3.467650469467f, -0.480641240411f, 0.f}; float b0 = 0.000880286074f; - filter_df2t(downmix, downmix, up*in_len, b0, filter_b, filter_a, RESAMPLING_ORDER, enc->resample_mem); - for (i=0;iresample_mem); + for (i = 0; i < out_len; i++)out[i] = oaci_downmix[6*i]; #endif } else { celt_assert(0); } } -void dred_compute_latents(DREDEnc *enc, const float *pcm, int frame_size, int extra_delay, int arch) -{ +void oaci_dred_compute_latents(DREDEnc *enc, const float *pcm, int frame_size, int extra_delay, int arch) { int curr_offset16k; - int frame_size16k = frame_size * 16000 / enc->Fs; + int frame_size16k = frame_size*16000/enc->Fs; celt_assert(enc->loaded); curr_offset16k = 40 + extra_delay*16000/enc->Fs - enc->input_buffer_fill; - enc->dred_offset = (int)floor((curr_offset16k+20.f)/40.f); + enc->dred_offset = (int)floor((curr_offset16k + 20.f)/40.f); enc->latent_offset = 0; while (frame_size16k > 0) { int process_size16k; int process_size; process_size16k = IMIN(2*DRED_FRAME_SIZE, frame_size16k); - process_size = process_size16k * enc->Fs / 16000; - dred_convert_to_16k(enc, pcm, process_size, &enc->input_buffer[enc->input_buffer_fill], process_size16k); + process_size = process_size16k*enc->Fs/16000; + oaci_dred_convert_to_16k(enc, pcm, process_size, &enc->input_buffer[enc->input_buffer_fill], process_size16k); enc->input_buffer_fill += process_size16k; - if (enc->input_buffer_fill >= 2*DRED_FRAME_SIZE) - { + if (enc->input_buffer_fill >= 2*DRED_FRAME_SIZE) { curr_offset16k += 320; - dred_process_frame(enc, arch); + oaci_dred_process_frame(enc, arch); enc->input_buffer_fill -= 2*DRED_FRAME_SIZE; - OPUS_MOVE(&enc->input_buffer[0], &enc->input_buffer[2*DRED_FRAME_SIZE], enc->input_buffer_fill); + OAC_MOVE(&enc->input_buffer[0], &enc->input_buffer[2*DRED_FRAME_SIZE], enc->input_buffer_fill); /* 15 ms (6*2.5 ms) is the ideal offset for DRED because it corresponds to our vocoder look-ahead. */ if (enc->dred_offset < 6) { enc->dred_offset += 8; @@ -242,41 +243,43 @@ void dred_compute_latents(DREDEnc *enc, const float *pcm, int frame_size, int ex } } -static void dred_encode_latents(ec_enc *enc, const float *x, const opus_uint8 *scale, const opus_uint8 *dzone, const opus_uint8 *r, const opus_uint8 *p0, int dim, int arch) { +static void oaci_dred_encode_latents(ec_enc *enc, const float *x, const oac_uint8 *scale, const oac_uint8 *dzone, + const oac_uint8 *r, const oac_uint8 *p0, int dim, int arch) { int i; - int q[IMAX(DRED_LATENT_DIM,DRED_STATE_DIM)]; - float xq[IMAX(DRED_LATENT_DIM,DRED_STATE_DIM)]; - float delta[IMAX(DRED_LATENT_DIM,DRED_STATE_DIM)]; - float deadzone[IMAX(DRED_LATENT_DIM,DRED_STATE_DIM)]; + int q[IMAX(DRED_LATENT_DIM, DRED_STATE_DIM)]; + float xq[IMAX(DRED_LATENT_DIM, DRED_STATE_DIM)]; + float delta[IMAX(DRED_LATENT_DIM, DRED_STATE_DIM)]; + float deadzone[IMAX(DRED_LATENT_DIM, DRED_STATE_DIM)]; float eps = .1f; /* This is split into multiple loops (with temporary arrays) so that the compiler can vectorize all of it, and so we can call the vector tanh(). */ - for (i=0;ilatent_offset; /* Delaying new DRED data when just out of silence because we already have the - main Opus payload for that frame. */ - if (activity_mem[0] && enc->last_extra_dred_offset>0) { + main Oac payload for that frame. */ + if (activity_mem[0] && enc->last_extra_dred_offset > 0) { latent_offset = enc->last_extra_dred_offset; delayed_dred = 1; enc->last_extra_dred_offset = 0; } - while (latent_offset < enc->latents_buffer_fill && !dred_voice_active(activity_mem, latent_offset)) { - latent_offset++; - extra_dred_offset++; + while (latent_offset < enc->latents_buffer_fill && !oaci_dred_voice_active(activity_mem, latent_offset)) { + latent_offset++; + extra_dred_offset++; } if (!delayed_dred) enc->last_extra_dred_offset = extra_dred_offset; /* entropy coding of state and latents */ - ec_enc_init(&ec_encoder, buf, max_bytes); - ec_enc_uint(&ec_encoder, q0, 16); - ec_enc_uint(&ec_encoder, dQ, 8); + oaci_ec_enc_init(&ec_encoder, buf, max_bytes); + oaci_ec_enc_uint(&ec_encoder, q0, 16); + oaci_ec_enc_uint(&ec_encoder, dQ, 8); total_offset = 16 - (enc->dred_offset - extra_dred_offset*8); - celt_assert(total_offset>=0); + celt_assert(total_offset >= 0); if (total_offset > 31) { - ec_enc_uint(&ec_encoder, 1, 2); - ec_enc_uint(&ec_encoder, total_offset>>5, 256); - ec_enc_uint(&ec_encoder, total_offset&31, 32); + oaci_ec_enc_uint(&ec_encoder, 1, 2); + oaci_ec_enc_uint(&ec_encoder, total_offset>>5, 256); + oaci_ec_enc_uint(&ec_encoder, total_offset&31, 32); } else { - ec_enc_uint(&ec_encoder, 0, 2); - ec_enc_uint(&ec_encoder, total_offset, 32); + oaci_ec_enc_uint(&ec_encoder, 0, 2); + oaci_ec_enc_uint(&ec_encoder, total_offset, 32); } celt_assert(qmax >= q0); if (q0 < 14 && dQ > 0) { - int nvals; - /* If you want to use qmax == q0, you should have set dQ = 0. */ - celt_assert(qmax > q0); - nvals = 15 - (q0 + 1); - ec_encode(&ec_encoder, qmax >= 15 ? 0 : nvals + qmax - (q0 + 1), + int nvals; + /* If you want to use qmax == q0, you should have set dQ = 0. */ + celt_assert(qmax > q0); + nvals = 15 - (q0 + 1); + oaci_ec_encode(&ec_encoder, qmax >= 15 ? 0 : nvals + qmax - (q0 + 1), qmax >= 15 ? nvals : nvals + qmax - q0, 2*nvals); } state_qoffset = q0*DRED_STATE_DIM; - dred_encode_latents( + oaci_dred_encode_latents( &ec_encoder, &enc->state_buffer[latent_offset*DRED_STATE_DIM], - dred_state_quant_scales_q8 + state_qoffset, - dred_state_dead_zone_q8 + state_qoffset, - dred_state_r_q8 + state_qoffset, - dred_state_p0_q8 + state_qoffset, + oaci_dred_state_quant_scales_q8 + state_qoffset, + oaci_dred_state_dead_zone_q8 + state_qoffset, + oaci_dred_state_r_q8 + state_qoffset, + oaci_dred_state_p0_q8 + state_qoffset, DRED_STATE_DIM, arch); - if (ec_tell(&ec_encoder) > 8*max_bytes) { - return 0; + if (oaci_ec_tell(&ec_encoder) > 8*max_bytes) { + return 0; } ec_bak = ec_encoder; - for (i = 0; i < IMIN(2*max_chunks, enc->latents_buffer_fill-latent_offset-1); i += 2) - { + for (i = 0; i < IMIN(2*max_chunks, enc->latents_buffer_fill - latent_offset - 1); i += 2) { int active; - q_level = compute_quantizer(q0, dQ, qmax, i/2); - offset = q_level * DRED_LATENT_DIM; + q_level = oaci_compute_quantizer(q0, dQ, qmax, i/2); + offset = q_level*DRED_LATENT_DIM; - dred_encode_latents( + oaci_dred_encode_latents( &ec_encoder, - enc->latents_buffer + (i+latent_offset) * DRED_LATENT_DIM, - dred_latent_quant_scales_q8 + offset, - dred_latent_dead_zone_q8 + offset, - dred_latent_r_q8 + offset, - dred_latent_p0_q8 + offset, + enc->latents_buffer + (i + latent_offset)*DRED_LATENT_DIM, + oaci_dred_latent_quant_scales_q8 + offset, + oaci_dred_latent_dead_zone_q8 + offset, + oaci_dred_latent_r_q8 + offset, + oaci_dred_latent_p0_q8 + offset, DRED_LATENT_DIM, arch - ); - if (ec_tell(&ec_encoder) > 8*max_bytes) { - /* If we haven't been able to code one chunk, give up on DRED completely. */ - if (i==0) return 0; - break; + ); + if (oaci_ec_tell(&ec_encoder) > 8*max_bytes) { + /* If we haven't been able to code one chunk, give up on DRED completely. */ + if (i == 0) return 0; + break; } - active = dred_voice_active(activity_mem, i+latent_offset); + active = oaci_dred_voice_active(activity_mem, i + latent_offset); if (active || prev_active) { - ec_bak = ec_encoder; - dred_encoded = i+2; + ec_bak = ec_encoder; + dred_encoded = i + 2; } prev_active = active; } /* Avoid sending empty DRED packets. */ - if (dred_encoded==0 || (dred_encoded<=2 && extra_dred_offset)) return 0; + if (dred_encoded == 0 || (dred_encoded <= 2 && extra_dred_offset))return 0; ec_encoder = ec_bak; - ec_buffer_fill = (ec_tell(&ec_encoder)+7)/8; - ec_enc_shrink(&ec_encoder, ec_buffer_fill); - ec_enc_done(&ec_encoder); + ec_buffer_fill = (oaci_ec_tell(&ec_encoder) + 7)/8; + oaci_ec_enc_shrink(&ec_encoder, ec_buffer_fill); + oaci_ec_enc_done(&ec_encoder); return ec_buffer_fill; } diff --git a/dnn/dred_encoder.h b/dnn/dred_encoder.h index 6987222c8..03b977915 100644 --- a/dnn/dred_encoder.h +++ b/dnn/dred_encoder.h @@ -23,7 +23,7 @@ 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. -*/ + */ #ifndef DRED_ENCODER_H #define DRED_ENCODER_H @@ -43,7 +43,7 @@ typedef struct { LPCNetEncState lpcnet_enc_state; RDOVAEEncState rdovae_enc; int loaded; - opus_int32 Fs; + oac_int32 Fs; int channels; #define DREDENC_RESET_START input_buffer @@ -52,20 +52,21 @@ typedef struct { int dred_offset; int latent_offset; int last_extra_dred_offset; - float latents_buffer[DRED_MAX_FRAMES * DRED_LATENT_DIM]; + float latents_buffer[DRED_MAX_FRAMES*DRED_LATENT_DIM]; int latents_buffer_fill; - float state_buffer[DRED_MAX_FRAMES * DRED_STATE_DIM]; + float state_buffer[DRED_MAX_FRAMES*DRED_STATE_DIM]; float resample_mem[RESAMPLING_ORDER + 1]; } DREDEnc; -int dred_encoder_load_model(DREDEnc* enc, const void *data, int len); -void dred_encoder_init(DREDEnc* enc, opus_int32 Fs, int channels); -void dred_encoder_reset(DREDEnc* enc); +int oaci_dred_encoder_load_model(DREDEnc* enc, const void *data, int len); +void oaci_dred_encoder_init(DREDEnc* enc, oac_int32 Fs, int channels); +void oaci_dred_encoder_reset(DREDEnc* enc); void dred_deinit_encoder(DREDEnc *enc); -void dred_compute_latents(DREDEnc *enc, const float *pcm, int frame_size, int extra_delay, int arch); +void oaci_dred_compute_latents(DREDEnc *enc, const float *pcm, int frame_size, int extra_delay, int arch); -int dred_encode_silk_frame(DREDEnc *enc, unsigned char *buf, int max_chunks, int max_bytes, int q0, int dQ, int qmax, unsigned char *activity_mem, int arch); +int oaci_dred_encode_silk_frame(DREDEnc *enc, unsigned char *buf, int max_chunks, int max_bytes, int q0, int dQ, int qmax, + unsigned char *activity_mem, int arch); #endif diff --git a/dnn/dred_rdovae.h b/dnn/dred_rdovae.h index 89ea39acf..e3e5523b9 100644 --- a/dnn/dred_rdovae.h +++ b/dnn/dred_rdovae.h @@ -23,14 +23,14 @@ 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. -*/ + */ #ifndef DRED_RDOVAE_H #define DRED_RDOVAE_H #include -#include "opus_types.h" +#include "oac_types.h" typedef struct RDOVAEDec RDOVAEDec; typedef struct RDOVAEEnc RDOVAEEnc; diff --git a/dnn/dred_rdovae_dec.c b/dnn/dred_rdovae_dec.c index 0c01a3bfc..de1695b2a 100644 --- a/dnn/dred_rdovae_dec.c +++ b/dnn/dred_rdovae_dec.c @@ -23,123 +23,125 @@ 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" +# include "config.h" #endif #include "dred_rdovae_dec.h" #include "dred_rdovae_constants.h" #include "os_support.h" -static void conv1_cond_init(float *mem, int len, int dilation, int *init) -{ +static void oaci_conv1_cond_init(float *mem, int len, int dilation, int *init) { if (!*init) { int i; - for (i=0;idec_hidden_init, hidden, initial_state, ACTIVATION_TANH, arch); - compute_generic_dense(&model->dec_gru_init, state_init, hidden, ACTIVATION_TANH, arch); - OPUS_COPY(h->gru1_state, state_init, DEC_GRU1_STATE_SIZE); + float state_init[DEC_GRU1_STATE_SIZE + DEC_GRU2_STATE_SIZE + DEC_GRU3_STATE_SIZE + DEC_GRU4_STATE_SIZE + + DEC_GRU5_STATE_SIZE]; + int counter = 0; + oaci_compute_generic_dense(&model->dec_hidden_init, hidden, initial_state, ACTIVATION_TANH, arch); + oaci_compute_generic_dense(&model->dec_gru_init, state_init, hidden, ACTIVATION_TANH, arch); + OAC_COPY(h->gru1_state, state_init, DEC_GRU1_STATE_SIZE); counter += DEC_GRU1_STATE_SIZE; - OPUS_COPY(h->gru2_state, &state_init[counter], DEC_GRU2_STATE_SIZE); + OAC_COPY(h->gru2_state, &state_init[counter], DEC_GRU2_STATE_SIZE); counter += DEC_GRU2_STATE_SIZE; - OPUS_COPY(h->gru3_state, &state_init[counter], DEC_GRU3_STATE_SIZE); + OAC_COPY(h->gru3_state, &state_init[counter], DEC_GRU3_STATE_SIZE); counter += DEC_GRU3_STATE_SIZE; - OPUS_COPY(h->gru4_state, &state_init[counter], DEC_GRU4_STATE_SIZE); + OAC_COPY(h->gru4_state, &state_init[counter], DEC_GRU4_STATE_SIZE); counter += DEC_GRU4_STATE_SIZE; - OPUS_COPY(h->gru5_state, &state_init[counter], DEC_GRU5_STATE_SIZE); + OAC_COPY(h->gru5_state, &state_init[counter], DEC_GRU5_STATE_SIZE); h->initialized = 0; } -void dred_rdovae_decode_qframe( +void oaci_dred_rdovae_decode_qframe( RDOVAEDecState *dec_state, /* io: state buffer handle */ const RDOVAEDec *model, float *qframe, /* o: quadruple feature frame (four concatenated frames in reverse order) */ const float *input, /* i: latent vector */ - int arch - ) -{ - float buffer[DEC_DENSE1_OUT_SIZE + DEC_GRU1_OUT_SIZE + DEC_GRU2_OUT_SIZE + DEC_GRU3_OUT_SIZE + DEC_GRU4_OUT_SIZE + DEC_GRU5_OUT_SIZE - + DEC_CONV1_OUT_SIZE + DEC_CONV2_OUT_SIZE + DEC_CONV3_OUT_SIZE + DEC_CONV4_OUT_SIZE + DEC_CONV5_OUT_SIZE]; + int arch) { + float buffer[DEC_DENSE1_OUT_SIZE + DEC_GRU1_OUT_SIZE + DEC_GRU2_OUT_SIZE + DEC_GRU3_OUT_SIZE + DEC_GRU4_OUT_SIZE + + DEC_GRU5_OUT_SIZE + + DEC_CONV1_OUT_SIZE + DEC_CONV2_OUT_SIZE + DEC_CONV3_OUT_SIZE + DEC_CONV4_OUT_SIZE + + DEC_CONV5_OUT_SIZE]; float conv_tmp[DRED_MAX_CONV_INPUTS]; int output_index = 0; /* run encoder stack and concatenate output in buffer*/ - compute_generic_dense(&model->dec_dense1, &buffer[output_index], input, ACTIVATION_TANH, arch); + oaci_compute_generic_dense(&model->dec_dense1, &buffer[output_index], input, ACTIVATION_TANH, arch); output_index += DEC_DENSE1_OUT_SIZE; - compute_generic_gru(&model->dec_gru1_input, &model->dec_gru1_recurrent, dec_state->gru1_state, buffer, arch); - compute_glu(&model->dec_glu1, &buffer[output_index], dec_state->gru1_state, arch); + oaci_compute_generic_gru(&model->dec_gru1_input, &model->dec_gru1_recurrent, dec_state->gru1_state, buffer, arch); + oaci_compute_glu(&model->dec_glu1, &buffer[output_index], dec_state->gru1_state, arch); output_index += DEC_GRU1_OUT_SIZE; - conv1_cond_init(dec_state->conv1_state, DEC_CONV1_IN_SIZE, 1, &dec_state->initialized); - compute_generic_dense(&model->dec_conv_dense1, conv_tmp, buffer, ACTIVATION_TANH, arch); - compute_generic_conv1d(&model->dec_conv1, &buffer[output_index], dec_state->conv1_state, conv_tmp, DEC_CONV1_OUT_SIZE, ACTIVATION_TANH, arch); + oaci_conv1_cond_init(dec_state->conv1_state, DEC_CONV1_IN_SIZE, 1, &dec_state->initialized); + oaci_compute_generic_dense(&model->dec_conv_dense1, conv_tmp, buffer, ACTIVATION_TANH, arch); + oaci_compute_generic_conv1d(&model->dec_conv1, &buffer[output_index], dec_state->conv1_state, conv_tmp, + DEC_CONV1_OUT_SIZE, ACTIVATION_TANH, arch); output_index += DEC_CONV1_OUT_SIZE; - compute_generic_gru(&model->dec_gru2_input, &model->dec_gru2_recurrent, dec_state->gru2_state, buffer, arch); - compute_glu(&model->dec_glu2, &buffer[output_index], dec_state->gru2_state, arch); + oaci_compute_generic_gru(&model->dec_gru2_input, &model->dec_gru2_recurrent, dec_state->gru2_state, buffer, arch); + oaci_compute_glu(&model->dec_glu2, &buffer[output_index], dec_state->gru2_state, arch); output_index += DEC_GRU2_OUT_SIZE; - conv1_cond_init(dec_state->conv2_state, DEC_CONV2_IN_SIZE, 1, &dec_state->initialized); - compute_generic_dense(&model->dec_conv_dense2, conv_tmp, buffer, ACTIVATION_TANH, arch); - compute_generic_conv1d(&model->dec_conv2, &buffer[output_index], dec_state->conv2_state, conv_tmp, DEC_CONV2_OUT_SIZE, ACTIVATION_TANH, arch); + oaci_conv1_cond_init(dec_state->conv2_state, DEC_CONV2_IN_SIZE, 1, &dec_state->initialized); + oaci_compute_generic_dense(&model->dec_conv_dense2, conv_tmp, buffer, ACTIVATION_TANH, arch); + oaci_compute_generic_conv1d(&model->dec_conv2, &buffer[output_index], dec_state->conv2_state, conv_tmp, + DEC_CONV2_OUT_SIZE, ACTIVATION_TANH, arch); output_index += DEC_CONV2_OUT_SIZE; - compute_generic_gru(&model->dec_gru3_input, &model->dec_gru3_recurrent, dec_state->gru3_state, buffer, arch); - compute_glu(&model->dec_glu3, &buffer[output_index], dec_state->gru3_state, arch); + oaci_compute_generic_gru(&model->dec_gru3_input, &model->dec_gru3_recurrent, dec_state->gru3_state, buffer, arch); + oaci_compute_glu(&model->dec_glu3, &buffer[output_index], dec_state->gru3_state, arch); output_index += DEC_GRU3_OUT_SIZE; - conv1_cond_init(dec_state->conv3_state, DEC_CONV3_IN_SIZE, 1, &dec_state->initialized); - compute_generic_dense(&model->dec_conv_dense3, conv_tmp, buffer, ACTIVATION_TANH, arch); - compute_generic_conv1d(&model->dec_conv3, &buffer[output_index], dec_state->conv3_state, conv_tmp, DEC_CONV3_OUT_SIZE, ACTIVATION_TANH, arch); + oaci_conv1_cond_init(dec_state->conv3_state, DEC_CONV3_IN_SIZE, 1, &dec_state->initialized); + oaci_compute_generic_dense(&model->dec_conv_dense3, conv_tmp, buffer, ACTIVATION_TANH, arch); + oaci_compute_generic_conv1d(&model->dec_conv3, &buffer[output_index], dec_state->conv3_state, conv_tmp, + DEC_CONV3_OUT_SIZE, ACTIVATION_TANH, arch); output_index += DEC_CONV3_OUT_SIZE; - compute_generic_gru(&model->dec_gru4_input, &model->dec_gru4_recurrent, dec_state->gru4_state, buffer, arch); - compute_glu(&model->dec_glu4, &buffer[output_index], dec_state->gru4_state, arch); + oaci_compute_generic_gru(&model->dec_gru4_input, &model->dec_gru4_recurrent, dec_state->gru4_state, buffer, arch); + oaci_compute_glu(&model->dec_glu4, &buffer[output_index], dec_state->gru4_state, arch); output_index += DEC_GRU4_OUT_SIZE; - conv1_cond_init(dec_state->conv4_state, DEC_CONV4_IN_SIZE, 1, &dec_state->initialized); - compute_generic_dense(&model->dec_conv_dense4, conv_tmp, buffer, ACTIVATION_TANH, arch); - compute_generic_conv1d(&model->dec_conv4, &buffer[output_index], dec_state->conv4_state, conv_tmp, DEC_CONV4_OUT_SIZE, ACTIVATION_TANH, arch); + oaci_conv1_cond_init(dec_state->conv4_state, DEC_CONV4_IN_SIZE, 1, &dec_state->initialized); + oaci_compute_generic_dense(&model->dec_conv_dense4, conv_tmp, buffer, ACTIVATION_TANH, arch); + oaci_compute_generic_conv1d(&model->dec_conv4, &buffer[output_index], dec_state->conv4_state, conv_tmp, + DEC_CONV4_OUT_SIZE, ACTIVATION_TANH, arch); output_index += DEC_CONV4_OUT_SIZE; - compute_generic_gru(&model->dec_gru5_input, &model->dec_gru5_recurrent, dec_state->gru5_state, buffer, arch); - compute_glu(&model->dec_glu5, &buffer[output_index], dec_state->gru5_state, arch); + oaci_compute_generic_gru(&model->dec_gru5_input, &model->dec_gru5_recurrent, dec_state->gru5_state, buffer, arch); + oaci_compute_glu(&model->dec_glu5, &buffer[output_index], dec_state->gru5_state, arch); output_index += DEC_GRU5_OUT_SIZE; - conv1_cond_init(dec_state->conv5_state, DEC_CONV5_IN_SIZE, 1, &dec_state->initialized); - compute_generic_dense(&model->dec_conv_dense5, conv_tmp, buffer, ACTIVATION_TANH, arch); - compute_generic_conv1d(&model->dec_conv5, &buffer[output_index], dec_state->conv5_state, conv_tmp, DEC_CONV5_OUT_SIZE, ACTIVATION_TANH, arch); + oaci_conv1_cond_init(dec_state->conv5_state, DEC_CONV5_IN_SIZE, 1, &dec_state->initialized); + oaci_compute_generic_dense(&model->dec_conv_dense5, conv_tmp, buffer, ACTIVATION_TANH, arch); + oaci_compute_generic_conv1d(&model->dec_conv5, &buffer[output_index], dec_state->conv5_state, conv_tmp, + DEC_CONV5_OUT_SIZE, ACTIVATION_TANH, arch); output_index += DEC_CONV5_OUT_SIZE; - compute_generic_dense(&model->dec_output, qframe, buffer, ACTIVATION_LINEAR, arch); + oaci_compute_generic_dense(&model->dec_output, qframe, buffer, ACTIVATION_LINEAR, arch); } diff --git a/dnn/dred_rdovae_dec.h b/dnn/dred_rdovae_dec.h index 4e66911c6..05f173523 100644 --- a/dnn/dred_rdovae_dec.h +++ b/dnn/dred_rdovae_dec.h @@ -23,7 +23,7 @@ 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. -*/ + */ #ifndef DRED_RDOVAE_DEC_H #define DRED_RDOVAE_DEC_H @@ -33,21 +33,22 @@ #include "dred_rdovae_stats_data.h" struct RDOVAEDecStruct { - int initialized; - float gru1_state[DEC_GRU1_STATE_SIZE]; - float gru2_state[DEC_GRU2_STATE_SIZE]; - float gru3_state[DEC_GRU3_STATE_SIZE]; - float gru4_state[DEC_GRU4_STATE_SIZE]; - float gru5_state[DEC_GRU5_STATE_SIZE]; - float conv1_state[DEC_CONV1_STATE_SIZE]; - float conv2_state[DEC_CONV2_STATE_SIZE]; - float conv3_state[DEC_CONV3_STATE_SIZE]; - float conv4_state[DEC_CONV4_STATE_SIZE]; - float conv5_state[DEC_CONV5_STATE_SIZE]; + int initialized; + float gru1_state[DEC_GRU1_STATE_SIZE]; + float gru2_state[DEC_GRU2_STATE_SIZE]; + float gru3_state[DEC_GRU3_STATE_SIZE]; + float gru4_state[DEC_GRU4_STATE_SIZE]; + float gru5_state[DEC_GRU5_STATE_SIZE]; + float conv1_state[DEC_CONV1_STATE_SIZE]; + float conv2_state[DEC_CONV2_STATE_SIZE]; + float conv3_state[DEC_CONV3_STATE_SIZE]; + float conv4_state[DEC_CONV4_STATE_SIZE]; + float conv5_state[DEC_CONV5_STATE_SIZE]; }; -void dred_rdovae_dec_init_states(RDOVAEDecState *h, const RDOVAEDec *model, const float * initial_state, int arch); -void dred_rdovae_decode_qframe(RDOVAEDecState *h, const RDOVAEDec *model, float *qframe, const float * z, int arch); -void DRED_rdovae_decode_all(const RDOVAEDec *model, float *features, const float *state, const float *latents, int nb_latents, int arch); +void oaci_dred_rdovae_dec_init_states(RDOVAEDecState *h, const RDOVAEDec *model, const float * initial_state, int arch); +void oaci_dred_rdovae_decode_qframe(RDOVAEDecState *h, const RDOVAEDec *model, float *qframe, const float * z, int arch); +void oaci_DRED_rdovae_decode_all(const RDOVAEDec *model, float *features, const float *state, const float *latents, + int nb_latents, int arch); #endif diff --git a/dnn/dred_rdovae_enc.c b/dnn/dred_rdovae_enc.c index 22b0f90f7..a6645e4b4 100644 --- a/dnn/dred_rdovae_enc.c +++ b/dnn/dred_rdovae_enc.c @@ -23,12 +23,12 @@ 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. -*/ + */ #include #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif @@ -36,81 +36,85 @@ #include "os_support.h" #include "dred_rdovae_constants.h" -static void conv1_cond_init(float *mem, int len, int dilation, int *init) -{ +static void oaci_conv1_cond_init(float *mem, int len, int dilation, int *init) { if (!*init) { int i; - for (i=0;ienc_dense1, &buffer[output_index], input, ACTIVATION_TANH, arch); + oaci_compute_generic_dense(&model->enc_dense1, &buffer[output_index], input, ACTIVATION_TANH, arch); output_index += ENC_DENSE1_OUT_SIZE; - compute_generic_gru(&model->enc_gru1_input, &model->enc_gru1_recurrent, enc_state->gru1_state, buffer, arch); - OPUS_COPY(&buffer[output_index], enc_state->gru1_state, ENC_GRU1_OUT_SIZE); + oaci_compute_generic_gru(&model->enc_gru1_input, &model->enc_gru1_recurrent, enc_state->gru1_state, buffer, arch); + OAC_COPY(&buffer[output_index], enc_state->gru1_state, ENC_GRU1_OUT_SIZE); output_index += ENC_GRU1_OUT_SIZE; - conv1_cond_init(enc_state->conv1_state, ENC_CONV1_IN_SIZE, 1, &enc_state->initialized); - compute_generic_dense(&model->enc_conv_dense1, conv_tmp, buffer, ACTIVATION_TANH, arch); - compute_generic_conv1d(&model->enc_conv1, &buffer[output_index], enc_state->conv1_state, conv_tmp, ENC_CONV1_OUT_SIZE, ACTIVATION_TANH, arch); + oaci_conv1_cond_init(enc_state->conv1_state, ENC_CONV1_IN_SIZE, 1, &enc_state->initialized); + oaci_compute_generic_dense(&model->enc_conv_dense1, conv_tmp, buffer, ACTIVATION_TANH, arch); + oaci_compute_generic_conv1d(&model->enc_conv1, &buffer[output_index], enc_state->conv1_state, conv_tmp, + ENC_CONV1_OUT_SIZE, ACTIVATION_TANH, arch); output_index += ENC_CONV1_OUT_SIZE; - compute_generic_gru(&model->enc_gru2_input, &model->enc_gru2_recurrent, enc_state->gru2_state, buffer, arch); - OPUS_COPY(&buffer[output_index], enc_state->gru2_state, ENC_GRU2_OUT_SIZE); + oaci_compute_generic_gru(&model->enc_gru2_input, &model->enc_gru2_recurrent, enc_state->gru2_state, buffer, arch); + OAC_COPY(&buffer[output_index], enc_state->gru2_state, ENC_GRU2_OUT_SIZE); output_index += ENC_GRU2_OUT_SIZE; - conv1_cond_init(enc_state->conv2_state, ENC_CONV2_IN_SIZE, 2, &enc_state->initialized); - compute_generic_dense(&model->enc_conv_dense2, conv_tmp, buffer, ACTIVATION_TANH, arch); - compute_generic_conv1d_dilation(&model->enc_conv2, &buffer[output_index], enc_state->conv2_state, conv_tmp, ENC_CONV2_OUT_SIZE, 2, ACTIVATION_TANH, arch); + oaci_conv1_cond_init(enc_state->conv2_state, ENC_CONV2_IN_SIZE, 2, &enc_state->initialized); + oaci_compute_generic_dense(&model->enc_conv_dense2, conv_tmp, buffer, ACTIVATION_TANH, arch); + oaci_compute_generic_conv1d_dilation(&model->enc_conv2, &buffer[output_index], enc_state->conv2_state, conv_tmp, + ENC_CONV2_OUT_SIZE, 2, ACTIVATION_TANH, arch); output_index += ENC_CONV2_OUT_SIZE; - compute_generic_gru(&model->enc_gru3_input, &model->enc_gru3_recurrent, enc_state->gru3_state, buffer, arch); - OPUS_COPY(&buffer[output_index], enc_state->gru3_state, ENC_GRU3_OUT_SIZE); + oaci_compute_generic_gru(&model->enc_gru3_input, &model->enc_gru3_recurrent, enc_state->gru3_state, buffer, arch); + OAC_COPY(&buffer[output_index], enc_state->gru3_state, ENC_GRU3_OUT_SIZE); output_index += ENC_GRU3_OUT_SIZE; - conv1_cond_init(enc_state->conv3_state, ENC_CONV3_IN_SIZE, 2, &enc_state->initialized); - compute_generic_dense(&model->enc_conv_dense3, conv_tmp, buffer, ACTIVATION_TANH, arch); - compute_generic_conv1d_dilation(&model->enc_conv3, &buffer[output_index], enc_state->conv3_state, conv_tmp, ENC_CONV3_OUT_SIZE, 2, ACTIVATION_TANH, arch); + oaci_conv1_cond_init(enc_state->conv3_state, ENC_CONV3_IN_SIZE, 2, &enc_state->initialized); + oaci_compute_generic_dense(&model->enc_conv_dense3, conv_tmp, buffer, ACTIVATION_TANH, arch); + oaci_compute_generic_conv1d_dilation(&model->enc_conv3, &buffer[output_index], enc_state->conv3_state, conv_tmp, + ENC_CONV3_OUT_SIZE, 2, ACTIVATION_TANH, arch); output_index += ENC_CONV3_OUT_SIZE; - compute_generic_gru(&model->enc_gru4_input, &model->enc_gru4_recurrent, enc_state->gru4_state, buffer, arch); - OPUS_COPY(&buffer[output_index], enc_state->gru4_state, ENC_GRU4_OUT_SIZE); + oaci_compute_generic_gru(&model->enc_gru4_input, &model->enc_gru4_recurrent, enc_state->gru4_state, buffer, arch); + OAC_COPY(&buffer[output_index], enc_state->gru4_state, ENC_GRU4_OUT_SIZE); output_index += ENC_GRU4_OUT_SIZE; - conv1_cond_init(enc_state->conv4_state, ENC_CONV4_IN_SIZE, 2, &enc_state->initialized); - compute_generic_dense(&model->enc_conv_dense4, conv_tmp, buffer, ACTIVATION_TANH, arch); - compute_generic_conv1d_dilation(&model->enc_conv4, &buffer[output_index], enc_state->conv4_state, conv_tmp, ENC_CONV4_OUT_SIZE, 2, ACTIVATION_TANH, arch); + oaci_conv1_cond_init(enc_state->conv4_state, ENC_CONV4_IN_SIZE, 2, &enc_state->initialized); + oaci_compute_generic_dense(&model->enc_conv_dense4, conv_tmp, buffer, ACTIVATION_TANH, arch); + oaci_compute_generic_conv1d_dilation(&model->enc_conv4, &buffer[output_index], enc_state->conv4_state, conv_tmp, + ENC_CONV4_OUT_SIZE, 2, ACTIVATION_TANH, arch); output_index += ENC_CONV4_OUT_SIZE; - compute_generic_gru(&model->enc_gru5_input, &model->enc_gru5_recurrent, enc_state->gru5_state, buffer, arch); - OPUS_COPY(&buffer[output_index], enc_state->gru5_state, ENC_GRU5_OUT_SIZE); + oaci_compute_generic_gru(&model->enc_gru5_input, &model->enc_gru5_recurrent, enc_state->gru5_state, buffer, arch); + OAC_COPY(&buffer[output_index], enc_state->gru5_state, ENC_GRU5_OUT_SIZE); output_index += ENC_GRU5_OUT_SIZE; - conv1_cond_init(enc_state->conv5_state, ENC_CONV5_IN_SIZE, 2, &enc_state->initialized); - compute_generic_dense(&model->enc_conv_dense5, conv_tmp, buffer, ACTIVATION_TANH, arch); - compute_generic_conv1d_dilation(&model->enc_conv5, &buffer[output_index], enc_state->conv5_state, conv_tmp, ENC_CONV5_OUT_SIZE, 2, ACTIVATION_TANH, arch); + oaci_conv1_cond_init(enc_state->conv5_state, ENC_CONV5_IN_SIZE, 2, &enc_state->initialized); + oaci_compute_generic_dense(&model->enc_conv_dense5, conv_tmp, buffer, ACTIVATION_TANH, arch); + oaci_compute_generic_conv1d_dilation(&model->enc_conv5, &buffer[output_index], enc_state->conv5_state, conv_tmp, + ENC_CONV5_OUT_SIZE, 2, ACTIVATION_TANH, arch); output_index += ENC_CONV5_OUT_SIZE; - compute_generic_dense(&model->enc_zdense, padded_latents, buffer, ACTIVATION_LINEAR, arch); - OPUS_COPY(latents, padded_latents, DRED_LATENT_DIM); + oaci_compute_generic_dense(&model->enc_zdense, padded_latents, buffer, ACTIVATION_LINEAR, arch); + OAC_COPY(latents, padded_latents, DRED_LATENT_DIM); /* next, calculate initial state */ - compute_generic_dense(&model->gdense1, state_hidden, buffer, ACTIVATION_TANH, arch); - compute_generic_dense(&model->gdense2, padded_state, state_hidden, ACTIVATION_LINEAR, arch); - OPUS_COPY(initial_state, padded_state, DRED_STATE_DIM); + oaci_compute_generic_dense(&model->gdense1, state_hidden, buffer, ACTIVATION_TANH, arch); + oaci_compute_generic_dense(&model->gdense2, padded_state, state_hidden, ACTIVATION_LINEAR, arch); + OAC_COPY(initial_state, padded_state, DRED_STATE_DIM); } diff --git a/dnn/dred_rdovae_enc.h b/dnn/dred_rdovae_enc.h index 6fe537ee7..bb311a22c 100644 --- a/dnn/dred_rdovae_enc.h +++ b/dnn/dred_rdovae_enc.h @@ -23,7 +23,7 @@ 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. -*/ + */ #ifndef DRED_RDOVAE_ENC_H #define DRED_RDOVAE_ENC_H @@ -46,7 +46,8 @@ struct RDOVAEEncStruct { float conv5_state[2*ENC_CONV5_STATE_SIZE]; }; -void dred_rdovae_encode_dframe(RDOVAEEncState *enc_state, const RDOVAEEnc *model, float *latents, float *initial_state, const float *input, int arch); +void oaci_dred_rdovae_encode_dframe(RDOVAEEncState *enc_state, const RDOVAEEnc *model, float *latents, float *initial_state, + const float *input, int arch); #endif diff --git a/dnn/dump_data.c b/dnn/dump_data.c index 6d1607ba1..1e389528a 100644 --- a/dnn/dump_data.c +++ b/dnn/dump_data.c @@ -22,10 +22,10 @@ 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" +# include "config.h" #endif #include @@ -47,7 +47,7 @@ #include "mini_kfft.c" #ifndef M_PI -#define M_PI 3.141592653589793f +# define M_PI 3.141592653589793f #endif #define SEQUENCE_LENGTH 2000 @@ -57,173 +57,171 @@ #ifdef ENABLE_RIR -#define RIR_FFT_SIZE 32000 -#define RIR_MAX_DURATION (RIR_FFT_SIZE/2) -#define FILENAME_MAX_SIZE 1000 +# define RIR_FFT_SIZE 32000 +# define RIR_MAX_DURATION (RIR_FFT_SIZE/2) +# define FILENAME_MAX_SIZE 1000 struct rir_list { - int nb_rirs; - int block_size; - mini_kiss_fft_state *fft; - mini_kiss_fft_state *ifft; - mini_kiss_fft_cpx **rir; - mini_kiss_fft_cpx **early; + int nb_rirs; + int block_size; + mini_kiss_fft_state *fft; + mini_kiss_fft_state *ifft; + mini_kiss_fft_cpx **rir; + mini_kiss_fft_cpx **early; }; mini_kiss_fft_cpx *load_rir(const char *rir_file, mini_kiss_fft_state *fft, int early) { - mini_kiss_fft_cpx *x, *X; - float rir[RIR_MAX_DURATION]; - int len; - int i; - FILE *f; - f = fopen(rir_file, "rb"); - if (f==NULL) { - fprintf(stderr, "cannot open RIR file %s: %s\n", rir_file, strerror(errno)); - exit(1); - } - x = (mini_kiss_fft_cpx*)calloc(fft->nfft, sizeof(*x)); - X = (mini_kiss_fft_cpx*)calloc(fft->nfft, sizeof(*X)); - len = fread(rir, sizeof(*rir), RIR_MAX_DURATION, f); - if (early) { - for (i=0;i<240;i++) { - rir[480+i] *= (1 - i/240.f); + mini_kiss_fft_cpx *x, *X; + float rir[RIR_MAX_DURATION]; + int len; + int i; + FILE *f; + f = fopen(rir_file, "rb"); + if (f == NULL) { + fprintf(stderr, "cannot open RIR file %s: %s\n", rir_file, strerror(errno)); + exit(1); + } + x = (mini_kiss_fft_cpx*)calloc(fft->nfft, sizeof(*x)); + X = (mini_kiss_fft_cpx*)calloc(fft->nfft, sizeof(*X)); + len = fread(rir, sizeof(*rir), RIR_MAX_DURATION, f); + if (early) { + for (i = 0; i < 240; i++) { + rir[480 + i] *= (1 - i/240.f); + } + OAC_CLEAR(&rir[240 + 480], RIR_MAX_DURATION - 240 - 480); } - OPUS_CLEAR(&rir[240+480], RIR_MAX_DURATION-240-480); - } - for (i=0;inb_rirs = 0; - allocated = 2; - rirs->fft = mini_kiss_fft_alloc(RIR_FFT_SIZE, 0, NULL, NULL); - rirs->ifft = mini_kiss_fft_alloc(RIR_FFT_SIZE, 1, NULL, NULL); - rirs->rir = (mini_kiss_fft_cpx**)malloc(allocated*sizeof(rirs->rir[0])); - rirs->early = (mini_kiss_fft_cpx**)malloc(allocated*sizeof(rirs->early[0])); - while (fgets(rir_filename, FILENAME_MAX_SIZE, f) != NULL) { - /* Chop trailing newline. */ - rir_filename[strcspn(rir_filename, "\n")] = 0; - if (rirs->nb_rirs+1 > allocated) { - allocated *= 2; - rirs->rir = (mini_kiss_fft_cpx**)realloc(rirs->rir, allocated*sizeof(rirs->rir[0])); - rirs->early = (mini_kiss_fft_cpx**)realloc(rirs->early, allocated*sizeof(rirs->early[0])); + int allocated; + char rir_filename[FILENAME_MAX_SIZE]; + FILE *f; + f = fopen(list_file, "rb"); + if (f == NULL) { + fprintf(stderr, "cannot open %s: %s\n", list_file, strerror(errno)); + exit(1); } - rirs->rir[rirs->nb_rirs] = load_rir(rir_filename, rirs->fft, 0); - rirs->early[rirs->nb_rirs] = load_rir(rir_filename, rirs->fft, 1); - rirs->nb_rirs++; - } - fclose(f); + rirs->nb_rirs = 0; + allocated = 2; + rirs->fft = mini_kiss_fft_alloc(RIR_FFT_SIZE, 0, NULL, NULL); + rirs->ifft = mini_kiss_fft_alloc(RIR_FFT_SIZE, 1, NULL, NULL); + rirs->rir = (mini_kiss_fft_cpx**)malloc(allocated*sizeof(rirs->rir[0])); + rirs->early = (mini_kiss_fft_cpx**)malloc(allocated*sizeof(rirs->early[0])); + while (fgets(rir_filename, FILENAME_MAX_SIZE, f) != NULL) { + /* Chop trailing newline. */ + rir_filename[strcspn(rir_filename, "\n")] = 0; + if (rirs->nb_rirs + 1 > allocated) { + allocated *= 2; + rirs->rir = (mini_kiss_fft_cpx**)realloc(rirs->rir, allocated*sizeof(rirs->rir[0])); + rirs->early = (mini_kiss_fft_cpx**)realloc(rirs->early, allocated*sizeof(rirs->early[0])); + } + rirs->rir[rirs->nb_rirs] = load_rir(rir_filename, rirs->fft, 0); + rirs->early[rirs->nb_rirs] = load_rir(rir_filename, rirs->fft, 1); + rirs->nb_rirs++; + } + fclose(f); } void rir_filter_sequence(const struct rir_list *rirs, float *audio, int rir_id, int early) { - int i; - mini_kiss_fft_cpx x[RIR_FFT_SIZE] = {{0,0}}; - mini_kiss_fft_cpx y[RIR_FFT_SIZE] = {{0,0}}; - mini_kiss_fft_cpx X[RIR_FFT_SIZE] = {{0,0}}; - const mini_kiss_fft_cpx *Y; - if (early) Y = rirs->early[rir_id]; - else Y = rirs->rir[rir_id]; - i=0; - while (ifft, x, X); - for (j=0;jearly[rir_id]; + else Y = rirs->rir[rir_id]; + i = 0; + while (i < SEQUENCE_SAMPLES) { + int j; + OAC_COPY(&x[0], &x[RIR_FFT_SIZE/2], RIR_FFT_SIZE/2); + for (j = 0; j < IMIN(SEQUENCE_SAMPLES - i, RIR_FFT_SIZE/2); j++) x[RIR_FFT_SIZE/2 + j].r = audio[i + j]; + for (; j < RIR_FFT_SIZE/2; j++) x[RIR_FFT_SIZE/2 + j].r = 0; + mini_kiss_fft(rirs->fft, x, X); + for (j = 0; j < RIR_FFT_SIZE; j++) { + mini_kiss_fft_cpx tmp; + C_MUL(tmp, X[j], Y[j]); + X[j].r = tmp.r*(1.f/(2.f*RIR_FFT_SIZE)); + X[j].i = tmp.i*(1.f/(2.f*RIR_FFT_SIZE)); + } + mini_kiss_fft(rirs->ifft, X, y); + for (j = 0; j < IMIN(SEQUENCE_SAMPLES - i, RIR_FFT_SIZE/2); j++) audio[i + j] = y[RIR_FFT_SIZE/2 + j].r; + i += RIR_FFT_SIZE/2; } - mini_kiss_fft(rirs->ifft, X, y); - for (j=0;j0) { - float r, theta; - r = rand()/(double)RAND_MAX; - r = .7*r*r; - theta = rand()/(double)RAND_MAX; - theta = M_PI*theta*theta; - a[0] = -2*r*cos(theta); - a[1] = r*r; - } else { - float r0,r1; - r0 = 1.4*uni_rand(); - r1 = 1.4*uni_rand(); - a[0] = -r0-r1; - a[1] = r0*r1; - } + if (rand()%3 != 0) { + a[0] = a[1] = 0; + } else if (uni_rand() > 0) { + float r, theta; + r = rand()/(double)RAND_MAX; + r = .7*r*r; + theta = rand()/(double)RAND_MAX; + theta = M_PI*theta*theta; + a[0] = -2*r*cos(theta); + a[1] = r*r; + } else { + float r0, r1; + r0 = 1.4*uni_rand(); + r1 = 1.4*uni_rand(); + a[0] = -r0 - r1; + a[1] = r0*r1; + } } static void rand_resp(float *a, float *b) { - rand_filt(a); - rand_filt(b); + rand_filt(a); + rand_filt(b); } -static opus_int16 float2short(float x) -{ - int i; - i = (int)floor(.5+x); - return IMAX(-32767, IMIN(32767, i)); +static oac_int16 float2short(float x) { + int i; + i = (int)floor(.5 + x); + return IMAX(-32767, IMIN(32767, i)); } static float weighted_rms(float *x) { - int i; - float tmp[SEQUENCE_SAMPLES]; - float weighting_b[2] = {-2.f, 1.f}; - float weighting_a[2] = {-1.89f, .895f}; - float mem[2] = {0}; - float mse = 1e-15f; - biquad(tmp, mem, x, weighting_b, weighting_a, SEQUENCE_SAMPLES); - for (i=0;i \n", argv0); - fprintf(stderr, " %s -ptrain \n", argv0); - fprintf(stderr, " %s -test \n", argv0); - return 1; - } - f1 = fopen(argv[2], "r"); - if (f1 == NULL) { - fprintf(stderr,"Error opening input .s16 16kHz speech input file: %s\n", argv[2]); - exit(1); - } - if (noise_filename != NULL) { - f2 = fopen(noise_filename, "r"); - if (f2 == NULL) { - fprintf(stderr,"Error opening input .s16 16kHz speech input file: %s\n", noise_filename); + srand(getpid()); + arch = oac_select_arch(); + st = oaci_lpcnet_encoder_create(); + argv0 = argv[0]; + if (argc == 5 && strcmp(argv[1], "-btrain") == 0) { + burg = 1; + training = 1; + } else if (argc == 4 && strcmp(argv[1], "-btest") == 0) { + burg = 1; + training = 0; + } else if (argc == 5 && strcmp(argv[1], "-ptrain") == 0) { + pitch = 1; + training = 1; + noise_filename = argv[2]; + argv++; + } else if (argc == 4 && strcmp(argv[1], "-ptest") == 0) { + pitch = 1; + training = 0; + } else if (argc == 7 && strcmp(argv[1], "-train") == 0) { + training = 1; + noise_filename = argv[2]; + rir_filename = argv[3]; + argv += 2; + } else if (argc == 4 && strcmp(argv[1], "-test") == 0) training = 0; + if (training == -1) { + fprintf(stderr, "usage: %s -train \n", argv0); + fprintf(stderr, " %s -ptrain \n", argv0); + fprintf(stderr, " %s -test \n", argv0); + return 1; + } + f1 = fopen(argv[2], "r"); + if (f1 == NULL) { + fprintf(stderr, "Error opening input .s16 16kHz speech input file: %s\n", argv[2]); + exit(1); + } + if (noise_filename != NULL) { + f2 = fopen(noise_filename, "r"); + if (f2 == NULL) { + fprintf(stderr, "Error opening input .s16 16kHz speech input file: %s\n", noise_filename); + exit(1); + } + fseek(f2, 0, SEEK_END); + noise_length = ftell(f2); + fseek(f2, 0, SEEK_SET); + } + ffeat = fopen(argv[3], "wb"); + if (ffeat == NULL) { + fprintf(stderr, "Error opening output feature file: %s\n", argv[3]); exit(1); - } - fseek(f2, 0, SEEK_END); - noise_length = ftell(f2); - fseek(f2, 0, SEEK_SET); - } - ffeat = fopen(argv[3], "wb"); - if (ffeat == NULL) { - fprintf(stderr,"Error opening output feature file: %s\n", argv[3]); - exit(1); - } - if (training && !pitch) { - fpcm = fopen(argv[4], "wb"); - if (fpcm == NULL) { - fprintf(stderr,"Error opening output PCM file: %s\n", argv[4]); - exit(1); } - } + if (training && !pitch) { + fpcm = fopen(argv[4], "wb"); + if (fpcm == NULL) { + fprintf(stderr, "Error opening output PCM file: %s\n", argv[4]); + exit(1); + } + } #ifdef ENABLE_RIR - if (rir_filename != NULL) { - load_rir_list(rir_filename, &rirs); - } + if (rir_filename != NULL) { + load_rir_list(rir_filename, &rirs); + } #endif - seed = getpid(); - srand(seed); + seed = getpid(); + srand(seed); - fseek(f1, 0, SEEK_END); - speech_length = ftell(f1); - fseek(f1, 0, SEEK_SET); + fseek(f1, 0, SEEK_END); + speech_length = ftell(f1); + fseek(f1, 0, SEEK_SET); #ifndef ENABLE_RIR - fprintf(stderr, "WARNING: dump_data was built without RIR support\n"); + fprintf(stderr, "WARNING: dump_data was built without RIR support\n"); #endif - maxCount = 20000; - for (count=0;count speech_length-(long)sizeof(speech16)) speech_pos = speech_length-sizeof(speech16); - speech_pos -= speech_pos&1; - fseek(f1, speech_pos, SEEK_SET); - ret = fread(speech16, sizeof(speech16), 1, f1); - if (ret != 1) { - fprintf(stderr, "reading speech failed\n"); - return 1; - } - if (f2!=NULL) { - noise_pos = (rand_lcg(&seed)*2.3283e-10)*noise_length; - if (noise_pos > noise_length-(long)sizeof(noise16)) noise_pos = noise_length-sizeof(noise16); - noise_pos -= noise_pos&1; - fseek(f2, noise_pos, SEEK_SET); - ret = fread(noise16, sizeof(noise16), 1, f2); - if (ret != 1) { - fprintf(stderr, "reading noise failed\n"); - return 1; - } - } - if (rand()%4) start_pos = 0; - else start_pos = -(int)(1000*log(rand()/(float)RAND_MAX)); - start_pos = IMIN(start_pos, SEQUENCE_LENGTH*FRAME_SIZE); - - speech_gain = pow(10., (-30+(rand()%40))/20.); - if (rand()&1) speech_gain = -speech_gain; - if (rand()%20==0) speech_gain *= .01; - if (!pitch && rand()%100==0) speech_gain = 0; - - noise_gain = pow(10., (-40+randf(25.f)+randf(15.f))/20.); - if (rand()%2!=0) noise_gain = 0; - if (rand()%12==0) { - noise_gain *= 0.03; - } - noise_gain *= speech_gain; - rand_resp(a_noise, b_noise); - rand_resp(a_sig, b_sig); - - for (frame=0;frame speech_length - (long)sizeof(speech16)) speech_pos = speech_length - sizeof(speech16); + speech_pos -= speech_pos&1; + fseek(f1, speech_pos, SEEK_SET); + ret = fread(speech16, sizeof(speech16), 1, f1); + if (ret != 1) { + fprintf(stderr, "reading speech failed\n"); + return 1; + } + if (f2 != NULL) { + noise_pos = (rand_lcg(&seed)*2.3283e-10)*noise_length; + if (noise_pos > noise_length - (long)sizeof(noise16)) noise_pos = noise_length - sizeof(noise16); + noise_pos -= noise_pos&1; + fseek(f2, noise_pos, SEEK_SET); + ret = fread(noise16, sizeof(noise16), 1, f2); + if (ret != 1) { + fprintf(stderr, "reading noise failed\n"); + return 1; + } + } + if (rand()%4) start_pos = 0; + else start_pos = -(int)(1000*log(rand()/(float)RAND_MAX)); + start_pos = IMIN(start_pos, SEQUENCE_LENGTH*FRAME_SIZE); + + speech_gain = pow(10., (-30 + (rand()%40))/20.); + if (rand()&1) speech_gain = -speech_gain; + if (rand()%20 == 0) speech_gain *= .01; + if (!pitch && rand()%100 == 0) speech_gain = 0; + + noise_gain = pow(10., (-40 + randf(25.f) + randf(15.f))/20.); + if (rand()%2 != 0) noise_gain = 0; + if (rand()%12 == 0) { + noise_gain *= 0.03; + } + noise_gain *= speech_gain; + rand_resp(a_noise, b_noise); + rand_resp(a_sig, b_sig); + + for (frame = 0; frame < SEQUENCE_LENGTH; frame++) { + E[frame] = 0; + for (j = 0; j < FRAME_SIZE; j++) { + float s = speech16[frame*FRAME_SIZE + j]; + E[frame] += s*s; + x[frame*FRAME_SIZE + j] = speech16[frame*FRAME_SIZE + j]; + n[frame*FRAME_SIZE + j] = noise16[frame*FRAME_SIZE + j]; + } + } + + OAC_CLEAR(mem, 2); + oaci_biquad(x, mem, x, b_hp, a_hp, SEQUENCE_LENGTH*FRAME_SIZE); + OAC_CLEAR(mem, 2); + oaci_biquad(x, mem, x, b_sig, a_sig, SEQUENCE_LENGTH*FRAME_SIZE); + OAC_CLEAR(mem, 2); + oaci_biquad(n, mem, n, b_hp, a_hp, SEQUENCE_LENGTH*FRAME_SIZE); + OAC_CLEAR(mem, 2); + oaci_biquad(n, mem, n, b_noise, a_noise, SEQUENCE_LENGTH*FRAME_SIZE); + + speech_rms = weighted_rms(x); + noise_rms = weighted_rms(n); + + speech_gain *= 3000.f/(1 + speech_rms); + noise_gain *= 3000.f/(1 + noise_rms); + for (j = 0; j < SEQUENCE_SAMPLES; j++) { + x[j] *= speech_gain; + n[j] *= noise_gain; + xn[j] = x[j] + n[j]; + } #ifdef ENABLE_RIR - if (rir_filename!=NULL && rand()%3==0) { - rir_id = rand()%rirs.nb_rirs; - rir_filter_sequence(&rirs, x, rir_id, 1); - rir_filter_sequence(&rirs, xn, rir_id, 0); - } + if (rir_filename != NULL && rand()%3 == 0) { + rir_id = rand()%rirs.nb_rirs; + rir_filter_sequence(&rirs, x, rir_id, 1); + rir_filter_sequence(&rirs, xn, rir_id, 0); + } #endif - if (rand()%4==0) { - /* Apply input clipping to 0 dBFS (don't clip target). */ - for (j=0;jxcorr_features[i]); - } - for (i=0;iif_features[i]); - } - fwrite(pitch_features, PITCH_MAX_PERIOD-PITCH_MIN_PERIOD+PITCH_IF_FEATURES, 1, ffeat); - } else { - fwrite(st->features, sizeof(float), NB_TOTAL_FEATURES, ffeat); - } - /*if(pitch) fwrite(pcm, FRAME_SIZE, 2, stdout);*/ - if (fpcm) fwrite(pcm, FRAME_SIZE, 2, fpcm); - for (i=0;ixcorr_features[i]); + } + for (i = 0; i < PITCH_IF_FEATURES; i++) { + pitch_features[i + PITCH_MAX_PERIOD - PITCH_MIN_PERIOD] = (int)floor(.5f + 127.f + *st->if_features[i]); + } + fwrite(pitch_features, PITCH_MAX_PERIOD - PITCH_MIN_PERIOD + PITCH_IF_FEATURES, 1, ffeat); + } else { + fwrite(st->features, sizeof(float), NB_TOTAL_FEATURES, ffeat); + } + /*if(pitch) fwrite(pcm, FRAME_SIZE, 2, stdout);*/ + if (fpcm) fwrite(pcm, FRAME_SIZE, 2, fpcm); + for (i = 0; i < TRAINING_OFFSET; i++) pcm[i] = float2short(xf[i + FRAME_SIZE - TRAINING_OFFSET]); + } } - } - - fclose(f1); - fclose(f2); - fclose(ffeat); - if (fpcm) fclose(fpcm); - lpcnet_encoder_destroy(st); - return 0; + + fclose(f1); + fclose(f2); + fclose(ffeat); + if (fpcm) fclose(fpcm); + oaci_lpcnet_encoder_destroy(st); + return 0; } diff --git a/dnn/dump_lpcnet_tables.c b/dnn/dump_lpcnet_tables.c index 95084d6e1..6f0481cda 100644 --- a/dnn/dump_lpcnet_tables.c +++ b/dnn/dump_lpcnet_tables.c @@ -23,10 +23,10 @@ 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" +# include "config.h" #endif #include @@ -36,69 +36,69 @@ int main(void) { - int i; - FILE *file; - kiss_fft_state *kfft; - float half_window[OVERLAP_SIZE]; - float dct_table[NB_BANDS*NB_BANDS]; - - file=fopen("lpcnet_tables.c", "wb"); - fprintf(file, "/* The contents of this file was automatically generated by dump_lpcnet_tables.c*/\n\n"); - fprintf(file, "#ifdef HAVE_CONFIG_H\n"); - fprintf(file, "#include \"config.h\"\n"); - fprintf(file, "#endif\n"); - - fprintf(file, "#include \"kiss_fft.h\"\n\n"); - - kfft = opus_fft_alloc_twiddles(WINDOW_SIZE, NULL, NULL, NULL, 0); - - fprintf(file, "static const arch_fft_state arch_fft = {0, NULL};\n\n"); - - fprintf (file, "static const opus_int16 fft_bitrev[%d] = {\n", kfft->nfft); - for (i=0;infft;i++) - fprintf (file, "%d,%c", kfft->bitrev[i],(i+16)%15==0?'\n':' '); - fprintf (file, "};\n\n"); - - fprintf (file, "static const kiss_twiddle_cpx fft_twiddles[%d] = {\n", kfft->nfft); - for (i=0;infft;i++) - fprintf (file, "{%#0.9gf, %#0.9gf},%c", kfft->twiddles[i].r, kfft->twiddles[i].i,(i+3)%2==0?'\n':' '); - fprintf (file, "};\n\n"); - - - fprintf(file, "const kiss_fft_state kfft = {\n"); - fprintf(file, "%d, /* nfft */\n", kfft->nfft); - fprintf(file, "%#0.8gf, /* scale */\n", kfft->scale); - fprintf(file, "%d, /* shift */\n", kfft->shift); - fprintf(file, "{"); - for (i=0;i<2*MAXFACTORS;i++) { - fprintf(file, "%d, ", kfft->factors[i]); - } - fprintf(file, "}, /* factors */\n"); - fprintf(file, "fft_bitrev, /* bitrev*/\n"); - fprintf(file, "fft_twiddles, /* twiddles*/\n"); - fprintf(file, "(arch_fft_state *)&arch_fft, /* arch_fft*/\n"); - - fprintf(file, "};\n\n"); - - for (i=0;infft); + for (i = 0; i < oaci_kfft->nfft; i++) + fprintf (file, "%d,%c", oaci_kfft->bitrev[i], (i + 16)%15 == 0?'\n':' '); + fprintf (file, "};\n\n"); + + fprintf (file, "static const kiss_twiddle_cpx fft_twiddles[%d] = {\n", oaci_kfft->nfft); + for (i = 0; i < oaci_kfft->nfft; i++) + fprintf (file, "{%#0.9gf, %#0.9gf},%c", oaci_kfft->twiddles[i].r, oaci_kfft->twiddles[i].i, (i + 3)%2 == 0?'\n':' '); + fprintf (file, "};\n\n"); + + + fprintf(file, "const kiss_fft_state oaci_kfft = {\n"); + fprintf(file, "%d, /* nfft */\n", oaci_kfft->nfft); + fprintf(file, "%#0.8gf, /* scale */\n", oaci_kfft->scale); + fprintf(file, "%d, /* shift */\n", oaci_kfft->shift); + fprintf(file, "{"); + for (i = 0; i < 2*MAXFACTORS; i++) { + fprintf(file, "%d, ", oaci_kfft->factors[i]); } - } - fprintf(file, "const float dct_table[] = {\n"); - for (i=0;imodel; - celt_assert(FARGAN_FEATURES+COND_NET_PEMBED_OUT_SIZE == model->cond_net_fdense1.nb_inputs); - celt_assert(COND_NET_FCONV1_IN_SIZE == model->cond_net_fdense1.nb_outputs); - celt_assert(COND_NET_FCONV1_OUT_SIZE == model->cond_net_fconv1.nb_outputs); - OPUS_COPY(&dense_in[NB_FEATURES], &model->cond_net_pembed.float_weights[IMAX(0,IMIN(period-32, 223))*COND_NET_PEMBED_OUT_SIZE], COND_NET_PEMBED_OUT_SIZE); - OPUS_COPY(dense_in, features, NB_FEATURES); - - compute_generic_dense(&model->cond_net_fdense1, conv1_in, dense_in, ACTIVATION_TANH, st->arch); - compute_generic_conv1d(&model->cond_net_fconv1, fdense2_in, st->cond_conv1_state, conv1_in, COND_NET_FCONV1_IN_SIZE, ACTIVATION_TANH, st->arch); - compute_generic_dense(&model->cond_net_fdense2, cond, fdense2_in, ACTIVATION_TANH, st->arch); +static void oaci_compute_fargan_cond(FARGANState *st, float *cond, const float *features, int period) { + FARGAN *model; + float dense_in[NB_FEATURES + COND_NET_PEMBED_OUT_SIZE]; + float conv1_in[COND_NET_FCONV1_IN_SIZE]; + float fdense2_in[COND_NET_FCONV1_OUT_SIZE]; + model = &st->model; + celt_assert(FARGAN_FEATURES + COND_NET_PEMBED_OUT_SIZE == model->cond_net_fdense1.nb_inputs); + celt_assert(COND_NET_FCONV1_IN_SIZE == model->cond_net_fdense1.nb_outputs); + celt_assert(COND_NET_FCONV1_OUT_SIZE == model->cond_net_fconv1.nb_outputs); + OAC_COPY(&dense_in[NB_FEATURES], + &model->cond_net_pembed.float_weights[IMAX(0, IMIN(period - 32, 223))*COND_NET_PEMBED_OUT_SIZE], + COND_NET_PEMBED_OUT_SIZE); + OAC_COPY(dense_in, features, NB_FEATURES); + + oaci_compute_generic_dense(&model->cond_net_fdense1, conv1_in, dense_in, ACTIVATION_TANH, st->arch); + oaci_compute_generic_conv1d(&model->cond_net_fconv1, fdense2_in, st->cond_conv1_state, conv1_in, COND_NET_FCONV1_IN_SIZE, + ACTIVATION_TANH, st->arch); + oaci_compute_generic_dense(&model->cond_net_fdense2, cond, fdense2_in, ACTIVATION_TANH, st->arch); } -static void fargan_deemphasis(float *pcm, float *deemph_mem) { - int i; - for (i=0;icont_initialized); - model = &st->model; - - compute_generic_dense(&model->sig_net_cond_gain_dense, &gain, cond, ACTIVATION_LINEAR, st->arch); - gain = exp(gain); - gain_1 = 1.f/(1e-5f + gain); - - pos = PITCH_MAX_PERIOD-period-2; - for (i=0;ipitch_buf[IMAX(0, pos)])); - pos++; - if (pos == PITCH_MAX_PERIOD) pos -= period; - } - for (i=0;ipitch_buf[PITCH_MAX_PERIOD-FARGAN_SUBFRAME_SIZE+i])); - - OPUS_COPY(&fwc0_in[0], &cond[0], FARGAN_COND_SIZE); - OPUS_COPY(&fwc0_in[FARGAN_COND_SIZE], pred, FARGAN_SUBFRAME_SIZE+4); - OPUS_COPY(&fwc0_in[FARGAN_COND_SIZE+FARGAN_SUBFRAME_SIZE+4], prev, FARGAN_SUBFRAME_SIZE); - - compute_generic_conv1d(&model->sig_net_fwc0_conv, gru1_in, st->fwc0_mem, fwc0_in, SIG_NET_INPUT_SIZE, ACTIVATION_TANH, st->arch); - celt_assert(SIG_NET_FWC0_GLU_GATE_OUT_SIZE == model->sig_net_fwc0_glu_gate.nb_outputs); - compute_glu(&model->sig_net_fwc0_glu_gate, gru1_in, gru1_in, st->arch); - - compute_generic_dense(&model->sig_net_gain_dense_out, pitch_gate, gru1_in, ACTIVATION_SIGMOID, st->arch); - - for (i=0;isig_net_gru1_input, &model->sig_net_gru1_recurrent, st->gru1_state, gru1_in, st->arch); - compute_glu(&model->sig_net_gru1_glu_gate, gru2_in, st->gru1_state, st->arch); - - for (i=0;isig_net_gru2_input, &model->sig_net_gru2_recurrent, st->gru2_state, gru2_in, st->arch); - compute_glu(&model->sig_net_gru2_glu_gate, gru3_in, st->gru2_state, st->arch); - - for (i=0;isig_net_gru3_input, &model->sig_net_gru3_recurrent, st->gru3_state, gru3_in, st->arch); - compute_glu(&model->sig_net_gru3_glu_gate, &skip_cat[SIG_NET_GRU1_OUT_SIZE+SIG_NET_GRU2_OUT_SIZE], st->gru3_state, st->arch); - - OPUS_COPY(skip_cat, gru2_in, SIG_NET_GRU1_OUT_SIZE); - OPUS_COPY(&skip_cat[SIG_NET_GRU1_OUT_SIZE], gru3_in, SIG_NET_GRU2_OUT_SIZE); - OPUS_COPY(&skip_cat[SIG_NET_GRU1_OUT_SIZE+SIG_NET_GRU2_OUT_SIZE+SIG_NET_GRU3_OUT_SIZE], gru1_in, SIG_NET_FWC0_CONV_OUT_SIZE); - for (i=0;isig_net_skip_dense, skip_out, skip_cat, ACTIVATION_TANH, st->arch); - compute_glu(&model->sig_net_skip_glu_gate, skip_out, skip_out, st->arch); - - compute_generic_dense(&model->sig_net_sig_dense_out, pcm, skip_out, ACTIVATION_TANH, st->arch); - for (i=0;ipitch_buf, &st->pitch_buf[FARGAN_SUBFRAME_SIZE], PITCH_MAX_PERIOD-FARGAN_SUBFRAME_SIZE); - OPUS_COPY(&st->pitch_buf[PITCH_MAX_PERIOD-FARGAN_SUBFRAME_SIZE], pcm, FARGAN_SUBFRAME_SIZE); - fargan_deemphasis(pcm, &st->deemph_mem); +static void oaci_run_fargan_subframe(FARGANState *st, float *pcm, const float *cond, int period) { + int i, pos; + float fwc0_in[SIG_NET_INPUT_SIZE]; + float gru1_in[SIG_NET_FWC0_CONV_OUT_SIZE + 2*FARGAN_SUBFRAME_SIZE]; + float gru2_in[SIG_NET_GRU1_OUT_SIZE + 2*FARGAN_SUBFRAME_SIZE]; + float gru3_in[SIG_NET_GRU2_OUT_SIZE + 2*FARGAN_SUBFRAME_SIZE]; + float pred[FARGAN_SUBFRAME_SIZE + 4]; + float prev[FARGAN_SUBFRAME_SIZE]; + float pitch_gate[4]; + float gain; + float gain_1; + float skip_cat[10000]; + float skip_out[SIG_NET_SKIP_DENSE_OUT_SIZE]; + FARGAN *model; + + celt_assert(st->cont_initialized); + model = &st->model; + + oaci_compute_generic_dense(&model->sig_net_cond_gain_dense, &gain, cond, ACTIVATION_LINEAR, st->arch); + gain = exp(gain); + gain_1 = 1.f/(1e-5f + gain); + + pos = PITCH_MAX_PERIOD - period - 2; + for (i = 0; i < FARGAN_SUBFRAME_SIZE + 4; i++) { + pred[i] = MIN32(1.f, MAX32(-1.f, gain_1*st->pitch_buf[IMAX(0, pos)])); + pos++; + if (pos == PITCH_MAX_PERIOD) pos -= period; + } + for (i = 0; i < FARGAN_SUBFRAME_SIZE; + i++) prev[i] = MAX32(-1.f, MIN16(1.f, gain_1*st->pitch_buf[PITCH_MAX_PERIOD - FARGAN_SUBFRAME_SIZE + i])); + + OAC_COPY(&fwc0_in[0], &cond[0], FARGAN_COND_SIZE); + OAC_COPY(&fwc0_in[FARGAN_COND_SIZE], pred, FARGAN_SUBFRAME_SIZE + 4); + OAC_COPY(&fwc0_in[FARGAN_COND_SIZE + FARGAN_SUBFRAME_SIZE + 4], prev, FARGAN_SUBFRAME_SIZE); + + oaci_compute_generic_conv1d(&model->sig_net_fwc0_conv, gru1_in, st->fwc0_mem, fwc0_in, SIG_NET_INPUT_SIZE, + ACTIVATION_TANH, st->arch); + celt_assert(SIG_NET_FWC0_GLU_GATE_OUT_SIZE == model->sig_net_fwc0_glu_gate.nb_outputs); + oaci_compute_glu(&model->sig_net_fwc0_glu_gate, gru1_in, gru1_in, st->arch); + + oaci_compute_generic_dense(&model->sig_net_gain_dense_out, pitch_gate, gru1_in, ACTIVATION_SIGMOID, st->arch); + + for (i = 0; i < FARGAN_SUBFRAME_SIZE; i++) gru1_in[SIG_NET_FWC0_GLU_GATE_OUT_SIZE + i] = pitch_gate[0]*pred[i + 2]; + OAC_COPY(&gru1_in[SIG_NET_FWC0_GLU_GATE_OUT_SIZE + FARGAN_SUBFRAME_SIZE], prev, FARGAN_SUBFRAME_SIZE); + oaci_compute_generic_gru(&model->sig_net_gru1_input, &model->sig_net_gru1_recurrent, st->gru1_state, gru1_in, st->arch); + oaci_compute_glu(&model->sig_net_gru1_glu_gate, gru2_in, st->gru1_state, st->arch); + + for (i = 0; i < FARGAN_SUBFRAME_SIZE; i++) gru2_in[SIG_NET_GRU1_OUT_SIZE + i] = pitch_gate[1]*pred[i + 2]; + OAC_COPY(&gru2_in[SIG_NET_GRU1_OUT_SIZE + FARGAN_SUBFRAME_SIZE], prev, FARGAN_SUBFRAME_SIZE); + oaci_compute_generic_gru(&model->sig_net_gru2_input, &model->sig_net_gru2_recurrent, st->gru2_state, gru2_in, st->arch); + oaci_compute_glu(&model->sig_net_gru2_glu_gate, gru3_in, st->gru2_state, st->arch); + + for (i = 0; i < FARGAN_SUBFRAME_SIZE; i++) gru3_in[SIG_NET_GRU2_OUT_SIZE + i] = pitch_gate[2]*pred[i + 2]; + OAC_COPY(&gru3_in[SIG_NET_GRU2_OUT_SIZE + FARGAN_SUBFRAME_SIZE], prev, FARGAN_SUBFRAME_SIZE); + oaci_compute_generic_gru(&model->sig_net_gru3_input, &model->sig_net_gru3_recurrent, st->gru3_state, gru3_in, st->arch); + oaci_compute_glu(&model->sig_net_gru3_glu_gate, &skip_cat[SIG_NET_GRU1_OUT_SIZE + SIG_NET_GRU2_OUT_SIZE], st->gru3_state, + st->arch); + + OAC_COPY(skip_cat, gru2_in, SIG_NET_GRU1_OUT_SIZE); + OAC_COPY(&skip_cat[SIG_NET_GRU1_OUT_SIZE], gru3_in, SIG_NET_GRU2_OUT_SIZE); + OAC_COPY(&skip_cat[SIG_NET_GRU1_OUT_SIZE + SIG_NET_GRU2_OUT_SIZE + SIG_NET_GRU3_OUT_SIZE], gru1_in, + SIG_NET_FWC0_CONV_OUT_SIZE); + for (i = 0; i < FARGAN_SUBFRAME_SIZE; + i++) skip_cat[SIG_NET_GRU1_OUT_SIZE + SIG_NET_GRU2_OUT_SIZE + SIG_NET_GRU3_OUT_SIZE + + SIG_NET_FWC0_CONV_OUT_SIZE + i] = pitch_gate[3]*pred[i + 2]; + OAC_COPY(&skip_cat[SIG_NET_GRU1_OUT_SIZE + SIG_NET_GRU2_OUT_SIZE + SIG_NET_GRU3_OUT_SIZE + + SIG_NET_FWC0_CONV_OUT_SIZE + FARGAN_SUBFRAME_SIZE], prev, FARGAN_SUBFRAME_SIZE); + + oaci_compute_generic_dense(&model->sig_net_skip_dense, skip_out, skip_cat, ACTIVATION_TANH, st->arch); + oaci_compute_glu(&model->sig_net_skip_glu_gate, skip_out, skip_out, st->arch); + + oaci_compute_generic_dense(&model->sig_net_sig_dense_out, pcm, skip_out, ACTIVATION_TANH, st->arch); + for (i = 0; i < FARGAN_SUBFRAME_SIZE; i++) pcm[i] *= gain; + + OAC_MOVE(st->pitch_buf, &st->pitch_buf[FARGAN_SUBFRAME_SIZE], PITCH_MAX_PERIOD - FARGAN_SUBFRAME_SIZE); + OAC_COPY(&st->pitch_buf[PITCH_MAX_PERIOD - FARGAN_SUBFRAME_SIZE], pcm, FARGAN_SUBFRAME_SIZE); + oaci_fargan_deemphasis(pcm, &st->deemph_mem); } -void fargan_cont(FARGANState *st, const float *pcm0, const float *features0) -{ - int i; - float cond[COND_NET_FDENSE2_OUT_SIZE]; - float x0[FARGAN_CONT_SAMPLES]; - float dummy[FARGAN_SUBFRAME_SIZE]; - int period=0; - - /* Pre-load features. */ - for (i=0;i<5;i++) { - const float *features = &features0[i*NB_FEATURES]; - st->last_period = period; - period = (int)floor(.5+256./pow(2.f,((1./60.)*((features[NB_BANDS]+1.5)*60)))); - compute_fargan_cond(st, cond, features, period); - } - - x0[0] = 0; - for (i=1;ipitch_buf[PITCH_MAX_PERIOD-FARGAN_FRAME_SIZE], x0, FARGAN_FRAME_SIZE); - st->cont_initialized = 1; - - for (i=0;ilast_period); - OPUS_COPY(&st->pitch_buf[PITCH_MAX_PERIOD-FARGAN_SUBFRAME_SIZE], &x0[FARGAN_FRAME_SIZE+i*FARGAN_SUBFRAME_SIZE], FARGAN_SUBFRAME_SIZE); - } - st->deemph_mem = pcm0[FARGAN_CONT_SAMPLES-1]; +void oaci_fargan_cont(FARGANState *st, const float *pcm0, const float *features0) { + int i; + float cond[COND_NET_FDENSE2_OUT_SIZE]; + float x0[FARGAN_CONT_SAMPLES]; + float dummy[FARGAN_SUBFRAME_SIZE]; + int period = 0; + + /* Pre-load features. */ + for (i = 0; i < 5; i++) { + const float *features = &features0[i*NB_FEATURES]; + st->last_period = period; + period = (int)floor(.5 + 256./pow(2.f, ((1./60.)*((features[NB_BANDS] + 1.5)*60)))); + oaci_compute_fargan_cond(st, cond, features, period); + } + + x0[0] = 0; + for (i = 1; i < FARGAN_CONT_SAMPLES; i++) { + x0[i] = pcm0[i] - FARGAN_DEEMPHASIS*pcm0[i - 1]; + } + + OAC_COPY(&st->pitch_buf[PITCH_MAX_PERIOD - FARGAN_FRAME_SIZE], x0, FARGAN_FRAME_SIZE); + st->cont_initialized = 1; + + for (i = 0; i < FARGAN_NB_SUBFRAMES; i++) { + oaci_run_fargan_subframe(st, dummy, &cond[i*FARGAN_COND_SIZE], st->last_period); + OAC_COPY(&st->pitch_buf[PITCH_MAX_PERIOD - FARGAN_SUBFRAME_SIZE], + &x0[FARGAN_FRAME_SIZE + i*FARGAN_SUBFRAME_SIZE], FARGAN_SUBFRAME_SIZE); + } + st->deemph_mem = pcm0[FARGAN_CONT_SAMPLES - 1]; } -void fargan_init(FARGANState *st) -{ - int ret; - OPUS_CLEAR(st, 1); - st->arch = opus_select_arch(); +void oaci_fargan_init(FARGANState *st) { + int ret; + OAC_CLEAR(st, 1); + st->arch = oac_select_arch(); #ifndef USE_WEIGHTS_FILE - ret = init_fargan(&st->model, fargan_arrays); + ret = oaci_init_fargan(&st->model, oaci_fargan_arrays); #else - ret = 0; + ret = 0; #endif - celt_assert(ret == 0); + celt_assert(ret == 0); } -int fargan_load_model(FARGANState *st, const void *data, int len) { - WeightArray *list; - int ret; - parse_weights(&list, data, len); - ret = init_fargan(&st->model, list); - opus_free(list); - if (ret == 0) return 0; - else return -1; +int oaci_fargan_load_model(FARGANState *st, const void *data, int len) { + WeightArray *list; + int ret; + oaci_parse_weights(&list, data, len); + ret = oaci_init_fargan(&st->model, list); + oac_free(list); + if (ret == 0) return 0; + else return -1; } -static void fargan_synthesize_impl(FARGANState *st, float *pcm, const float *features) -{ - int subframe; - float cond[COND_NET_FDENSE2_OUT_SIZE]; - int period; - celt_assert(st->cont_initialized); - - period = (int)floor(.5+256./pow(2.f,((1./60.)*((features[NB_BANDS]+1.5)*60)))); - compute_fargan_cond(st, cond, features, period); - for (subframe=0;subframelast_period); - } - st->last_period = period; +static void oaci_fargan_synthesize_impl(FARGANState *st, float *pcm, const float *features) { + int subframe; + float cond[COND_NET_FDENSE2_OUT_SIZE]; + int period; + celt_assert(st->cont_initialized); + + period = (int)floor(.5 + 256./pow(2.f, ((1./60.)*((features[NB_BANDS] + 1.5)*60)))); + oaci_compute_fargan_cond(st, cond, features, period); + for (subframe = 0; subframe < FARGAN_NB_SUBFRAMES; subframe++) { + float *sub_cond; + sub_cond = &cond[subframe*FARGAN_COND_SIZE]; + oaci_run_fargan_subframe(st, &pcm[subframe*FARGAN_SUBFRAME_SIZE], sub_cond, st->last_period); + } + st->last_period = period; } -void fargan_synthesize(FARGANState *st, float *pcm, const float *features) -{ - fargan_synthesize_impl(st, pcm, features); +void oaci_fargan_synthesize(FARGANState *st, float *pcm, const float *features) { + oaci_fargan_synthesize_impl(st, pcm, features); } -void fargan_synthesize_int(FARGANState *st, opus_int16 *pcm, const float *features) -{ - int i; - float fpcm[FARGAN_FRAME_SIZE]; - fargan_synthesize(st, fpcm, features); - for (i=0;i @@ -53,59 +53,58 @@ better resource utilization, especially if multiple processes are using the same file (mapping will be shared in cache). */ void *load_blob(const char *filename, int *len) { - int fd; - void *data; - struct stat st; - if (stat(filename, &st)) { - *len = 0; - return NULL; - } - *len = st.st_size; - fd = open(filename, O_RDONLY); - if (fd<0) { - *len = 0; - return NULL; - } - data = mmap(NULL, *len, PROT_READ, MAP_SHARED, fd, 0); - if (data == MAP_FAILED) { - *len = 0; - data = NULL; - } - close(fd); - return data; + int fd; + void *data; + struct stat st; + if (stat(filename, &st)) { + *len = 0; + return NULL; + } + *len = st.st_size; + fd = open(filename, O_RDONLY); + if (fd < 0) { + *len = 0; + return NULL; + } + data = mmap(NULL, *len, PROT_READ, MAP_SHARED, fd, 0); + if (data == MAP_FAILED) { + *len = 0; + data = NULL; + } + close(fd); + return data; } void free_blob(void *blob, int len) { - if (blob) munmap(blob, len); + if (blob) munmap(blob, len); } # else void *load_blob(const char *filename, int *len) { - FILE *file; - void *data; - file = fopen(filename, "r"); - if (file == NULL) - { - perror("could not open blob file"); - *len = 0; - return NULL; - } - fseek(file, 0L, SEEK_END); - *len = ftell(file); - fseek(file, 0L, SEEK_SET); - if (*len <= 0) { - *len = 0; - return NULL; - } - data = malloc(*len); - if (!data) { - *len = 0; - return NULL; - } - *len = fread(data, 1, *len, file); - return data; + FILE *file; + void *data; + file = fopen(filename, "r"); + if (file == NULL) { + perror("could not open blob file"); + *len = 0; + return NULL; + } + fseek(file, 0L, SEEK_END); + *len = ftell(file); + fseek(file, 0L, SEEK_SET); + if (*len <= 0) { + *len = 0; + return NULL; + } + data = malloc(*len); + if (!data) { + *len = 0; + return NULL; + } + *len = fread(data, 1, *len, file); + return data; } void free_blob(void *blob, int len) { - free(blob); - (void)len; + free(blob); + (void)len; } # endif #endif @@ -131,17 +130,17 @@ void usage(void) { } #ifdef ENABLE_DRED -void dred_decode_latents(ec_dec *dec, float *x, const opus_uint8 *scale, const opus_uint8 *r, const opus_uint8 *p0, int dim); +void oaci_dred_decode_latents(ec_dec *dec, float *x, const oac_uint8 *scale, const oac_uint8 *r, const oac_uint8 *p0, + int dim); -static opus_uint32 char_to_int(unsigned char ch[4]) -{ - return ((opus_uint32)ch[0]<<24) | ((opus_uint32)ch[1]<<16) - | ((opus_uint32)ch[2]<< 8) | (opus_uint32)ch[3]; +static oac_uint32 char_to_int(unsigned char ch[4]) { + return ((oac_uint32)ch[0]<<24)|((oac_uint32)ch[1]<<16) + |((oac_uint32)ch[2]<<8)|(oac_uint32)ch[3]; } #endif int main(int argc, char **argv) { - int mode=0; + int mode = 0; int arch; FILE *fin, *fout; #ifdef USE_WEIGHTS_FILE @@ -149,12 +148,12 @@ int main(int argc, char **argv) { void *data; const char *filename = "weights_blob.bin"; #endif - arch = opus_select_arch(); + arch = oac_select_arch(); if (argc < 4) usage(); - if (strcmp(argv[1], "-features") == 0) mode=MODE_FEATURES; - else if (strcmp(argv[1], "-fargan-synthesis") == 0) mode=MODE_FARGAN_SYNTHESIS; + if (strcmp(argv[1], "-features") == 0) mode = MODE_FEATURES; + else if (strcmp(argv[1], "-fargan-synthesis") == 0) mode = MODE_FARGAN_SYNTHESIS; else if (strcmp(argv[1], "-dred-decoding") == 0) { - mode=MODE_DRED_DECODING; + mode = MODE_DRED_DECODING; } else { usage(); } @@ -172,140 +171,141 @@ int main(int argc, char **argv) { } #ifdef USE_WEIGHTS_FILE data = load_blob(filename, &len); - if (data==NULL) { + if (data == NULL) { fprintf(stderr, "Can't open blob file %s\n", filename); - exit(1); + exit(1); } #endif if (mode == MODE_FEATURES) { LPCNetEncState *net; - net = lpcnet_encoder_create(); + net = oaci_lpcnet_encoder_create(); while (1) { float features[NB_TOTAL_FEATURES]; - opus_int16 pcm[LPCNET_FRAME_SIZE]; + oac_int16 pcm[LPCNET_FRAME_SIZE]; size_t ret; ret = fread(pcm, sizeof(pcm[0]), LPCNET_FRAME_SIZE, fin); if (feof(fin) || ret != LPCNET_FRAME_SIZE) break; - lpcnet_compute_single_frame_features(net, pcm, features, arch); + oaci_lpcnet_compute_single_frame_features(net, pcm, features, arch); fwrite(features, sizeof(float), NB_FEATURES, fout); } - lpcnet_encoder_destroy(net); + oaci_lpcnet_encoder_destroy(net); } else if (mode == MODE_FARGAN_SYNTHESIS) { FARGANState fargan; size_t ret, i; int skip = LPCNET_FRAME_SIZE/2; - int stop=0; + int stop = 0; float in_features[5*NB_FEATURES]; float zeros[320] = {0}; - fargan_init(&fargan); + oaci_fargan_init(&fargan); #ifdef USE_WEIGHTS_FILE - fargan_load_model(&fargan, data, len); + oaci_fargan_load_model(&fargan, data, len); #endif - /* uncomment the following to align with Python code */ + /* uncomment the following to oaci_align with Python code */ ret = fread(&in_features[0], sizeof(in_features[0]), NB_FEATURES, fin); - for (i=1;i<5;i++) { - OPUS_COPY(&in_features[i*NB_FEATURES], &in_features[0], NB_FEATURES); + for (i = 1; i < 5; i++) { + OAC_COPY(&in_features[i*NB_FEATURES], &in_features[0], NB_FEATURES); } - fargan_cont(&fargan, zeros, in_features); + oaci_fargan_cont(&fargan, zeros, in_features); while (1) { float features[NB_FEATURES]; float fpcm[LPCNET_FRAME_SIZE]; - opus_int16 pcm[LPCNET_FRAME_SIZE]; + oac_int16 pcm[LPCNET_FRAME_SIZE]; ret = fread(in_features, sizeof(features[0]), NB_FEATURES, fin); if (stop || feof(fin) || ret != NB_FEATURES) { - stop++; + stop++; } else { - OPUS_COPY(features, in_features, NB_FEATURES); + OAC_COPY(features, in_features, NB_FEATURES); } - fargan_synthesize(&fargan, fpcm, features); - for (i=0;i MAX_DRED_PACKET) { - fprintf(stderr, "packet too big: %d\n", nb_bytes); - exit(1); - } + unsigned char ch[4]; + int nb_bytes; + int nb_chunks; + int state_qoffset; + ret = fread(ch, 4, 1, fin); + if (feof(fin) || ret != 1) break; + q0 = char_to_int(ch); + state_qoffset = q0*DRED_STATE_DIM; + ret = fread(ch, 4, 1, fin); + if (feof(fin) || ret != 1) break; + nb_chunks = char_to_int(ch); + ret = fread(ch, 4, 1, fin); + if (feof(fin) || ret != 1) break; + nb_bytes = char_to_int(ch); + if (nb_bytes > MAX_DRED_PACKET) { + fprintf(stderr, "packet too big: %d\n", nb_bytes); + exit(1); + } - ret = fread(bits, 1, nb_bytes, fin); - if (feof(fin) || (int)ret != nb_bytes) break; + ret = fread(bits, 1, nb_bytes, fin); + if (feof(fin) || (int)ret != nb_bytes) break; - ec_dec_init(&dec, bits, nb_bytes); - memset(&rdovae_dec, 0, sizeof(rdovae_dec)); - dred_decode_latents( + oaci_ec_dec_init(&dec, bits, nb_bytes); + memset(&rdovae_dec, 0, sizeof(rdovae_dec)); + oaci_dred_decode_latents( &dec, initial_state, - dred_state_quant_scales_q8 + state_qoffset, - dred_state_r_q8 + state_qoffset, - dred_state_p0_q8 + state_qoffset, + oaci_dred_state_quant_scales_q8 + state_qoffset, + oaci_dred_state_r_q8 + state_qoffset, + oaci_dred_state_p0_q8 + state_qoffset, DRED_STATE_DIM); - dred_rdovae_dec_init_states(&rdovae_dec, &rdovae_dec_model, initial_state, arch); - for (i=nb_chunks-1;i>=0;i-=2) { - int k; - float dec_tmp[4*DRED_NUM_FEATURES]; - int offset = q0 * DRED_LATENT_DIM; + oaci_dred_rdovae_dec_init_states(&rdovae_dec, &rdovae_dec_model, initial_state, arch); + for (i = nb_chunks - 1; i >= 0; i -= 2) { + int k; + float dec_tmp[4*DRED_NUM_FEATURES]; + int offset = q0*DRED_LATENT_DIM; - dred_decode_latents( + oaci_dred_decode_latents( &dec, - &latents[i*(DRED_LATENT_DIM+1)], - dred_latent_quant_scales_q8 + offset, - dred_latent_r_q8 + offset, - dred_latent_p0_q8 + offset, + &latents[i*(DRED_LATENT_DIM + 1)], + oaci_dred_latent_quant_scales_q8 + offset, + oaci_dred_latent_r_q8 + offset, + oaci_dred_latent_p0_q8 + offset, DRED_LATENT_DIM - ); - latents[i*(DRED_LATENT_DIM+1)+DRED_LATENT_DIM] = q0*.125-1; + ); + latents[i*(DRED_LATENT_DIM + 1) + DRED_LATENT_DIM] = q0*.125 - 1; - dred_rdovae_decode_qframe( + oaci_dred_rdovae_decode_qframe( &rdovae_dec, &rdovae_dec_model, dec_tmp, - &latents[i*(DRED_LATENT_DIM+1)], + &latents[i*(DRED_LATENT_DIM + 1)], arch); - for (k=0;k<4;k++) { - OPUS_COPY(&features[(2*i-2+k)*DRED_NUM_FEATURES], &dec_tmp[(3-k)*DRED_NUM_FEATURES], DRED_NUM_FEATURES); - } - } - for (i=0;i @@ -42,282 +42,270 @@ #define SQUARE(x) ((x)*(x)) -static const opus_int16 eband5ms[] = { +static const oac_int16 eband5ms[] = { /*0 200 400 600 800 1k 1.2 1.4 1.6 2k 2.4 2.8 3.2 4k 4.8 5.6 6.8 8k*/ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 34, 40 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 34, 40 }; static const float compensation[] = { - 0.8f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.666667f, 0.5f, 0.5f, 0.5f, 0.333333f, 0.25f, 0.25f, 0.2f, 0.166667f, 0.173913f + 0.8f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 0.666667f, 0.5f, 0.5f, 0.5f, 0.333333f, 0.25f, 0.25f, 0.2f, 0.166667f, + 0.173913f }; -static void compute_band_energy_inverse(float *bandE, const kiss_fft_cpx *X) { - int i; - float sum[NB_BANDS] = {0}; - for (i=0;i>1; j++) - { - opus_val32 tmp1, tmp2; - tmp1 = lpc[j]; - tmp2 = lpc[i-1-j]; - lpc[j] = tmp1 + MULT32_32_Q31(r,tmp2); - lpc[i-1-j] = tmp2 + MULT32_32_Q31(r,tmp1); - } + OAC_CLEAR(lpc, p); + OAC_CLEAR(rc, p); + if (ac[0] != 0) { + for (i = 0; i < p; i++) { + /* Sum up this iteration's reflection coefficient */ + oac_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 = -SHL32(rr, 3)/error; + rc[i] = r; + /* Update LPC coefficients and total error */ + lpc[i] = SHR32(r, 3); + for (j = 0; j < (i + 1)>>1; j++) { + oac_val32 tmp1, tmp2; + tmp1 = lpc[j]; + tmp2 = lpc[i - 1 - j]; + lpc[j] = tmp1 + MULT32_32_Q31(r, tmp2); + lpc[i - 1 - j] = tmp2 + MULT32_32_Q31(r, tmp1); + } - error = error - MULT32_32_Q31(MULT32_32_Q31(r,r),error); - /* Bail out once we get 30 dB gain */ - if (error<.001f*ac[0]) - break; - } - } - return error; + error = error - MULT32_32_Q31(MULT32_32_Q31(r, r), error); + /* Bail out once we get 30 dB gain */ + if (error < .001f*ac[0]) + break; + } + } + return error; } -void lpcn_compute_band_energy(float *bandE, const kiss_fft_cpx *X) { - int i; - float sum[NB_BANDS] = {0}; - for (i=0;imodel; - celt_assert(FWGAN_FEATURES == model->bfcc_with_corr_upsampler_fc.nb_inputs); - celt_assert(BFCC_WITH_CORR_UPSAMPLER_FC_OUT_SIZE == model->bfcc_with_corr_upsampler_fc.nb_outputs); - compute_generic_dense(&model->bfcc_with_corr_upsampler_fc, cond, features, ACTIVATION_TANH); +static void run_fwgan_upsampler(FWGANState *st, float *cond, const float *features) { + FWGAN *model; + model = &st->model; + celt_assert(FWGAN_FEATURES == model->bfcc_with_corr_upsampler_fc.nb_inputs); + celt_assert(BFCC_WITH_CORR_UPSAMPLER_FC_OUT_SIZE == model->bfcc_with_corr_upsampler_fc.nb_outputs); + oaci_compute_generic_dense(&model->bfcc_with_corr_upsampler_fc, cond, features, ACTIVATION_TANH); } static void fwgan_synthesize_impl(FWGANState *st, float *pcm, const float *lpc, const float *features); -void fwgan_cont(FWGANState *st, const float *pcm0, const float *features0) -{ - int i; - float norm2, norm_1; - float wpcm0[CONT_PCM_INPUTS]; - float cont_inputs[CONT_PCM_INPUTS+1]; - float tmp1[MAX_CONT_SIZE]; - float tmp2[MAX_CONT_SIZE]; - float lpc[LPC_ORDER]; - float new_pcm[FWGAN_FRAME_SIZE]; - FWGAN *model; - st->embed_phase[0] = 1; - model = &st->model; - compute_wlpc(lpc, features0); - /* Deemphasis memory is just the last continuation sample. */ - st->deemph_mem = pcm0[CONT_PCM_INPUTS-1]; - - /* Apply analysis filter, considering that the preemphasis and deemphasis filter - cancel each other in this case since the LPC filter is constant across that boundary. +void fwgan_cont(FWGANState *st, const float *pcm0, const float *features0) { + int i; + float norm2, norm_1; + float wpcm0[CONT_PCM_INPUTS]; + float cont_inputs[CONT_PCM_INPUTS + 1]; + float tmp1[MAX_CONT_SIZE]; + float tmp2[MAX_CONT_SIZE]; + float lpc[LPC_ORDER]; + float new_pcm[FWGAN_FRAME_SIZE]; + FWGAN *model; + st->embed_phase[0] = 1; + model = &st->model; + compute_wlpc(lpc, features0); + /* Deemphasis memory is just the last continuation sample. */ + st->deemph_mem = pcm0[CONT_PCM_INPUTS - 1]; + + /* Apply analysis filter, considering that the oaci_preemphasis and oaci_deemphasis filter + cancel each other in this case since the LPC filter is constant across that boundary. */ - for (i=LPC_ORDER;ipreemph_mem = wpcm0[CONT_PCM_INPUTS-1]; - /* The memory of the synthesis filter is the pre-emphasized continuation. */ - for (i=0;isyn_mem[i] = pcm0[CONT_PCM_INPUTS-1-i] - FWGAN_DEEMPHASIS*pcm0[CONT_PCM_INPUTS-2-i]; - - norm2 = celt_inner_prod(wpcm0, wpcm0, CONT_PCM_INPUTS, st->arch); - norm_1 = 1.f/sqrt(1e-8f + norm2); - for (i=0;icont_net_0, tmp1, cont_inputs, ACTIVATION_TANH); - compute_generic_dense(&model->cont_net_2, tmp2, tmp1, ACTIVATION_TANH); - compute_generic_dense(&model->cont_net_4, tmp1, tmp2, ACTIVATION_TANH); - compute_generic_dense(&model->cont_net_6, tmp2, tmp1, ACTIVATION_TANH); - compute_generic_dense(&model->cont_net_8, tmp1, tmp2, ACTIVATION_TANH); - celt_assert(CONT_NET_10_OUT_SIZE == model->cont_net_10.nb_outputs); - compute_generic_dense(&model->cont_net_10, st->cont, tmp1, ACTIVATION_TANH); - - /* Computing continuation for each layer. */ - celt_assert(RNN_GRU_STATE_SIZE == model->rnn_cont_fc_0.nb_outputs); - compute_generic_dense(&model->rnn_cont_fc_0, st->rnn_state, st->cont, ACTIVATION_TANH); - - celt_assert(FWC1_STATE_SIZE == model->fwc1_cont_fc_0.nb_outputs); - compute_generic_dense(&model->fwc1_cont_fc_0, st->fwc1_state, st->cont, ACTIVATION_TANH); - celt_assert(FWC2_STATE_SIZE == model->fwc2_cont_fc_0.nb_outputs); - compute_generic_dense(&model->fwc2_cont_fc_0, st->fwc2_state, st->cont, ACTIVATION_TANH); - celt_assert(FWC3_STATE_SIZE == model->fwc3_cont_fc_0.nb_outputs); - compute_generic_dense(&model->fwc3_cont_fc_0, st->fwc3_state, st->cont, ACTIVATION_TANH); - celt_assert(FWC4_STATE_SIZE == model->fwc4_cont_fc_0.nb_outputs); - compute_generic_dense(&model->fwc4_cont_fc_0, st->fwc4_state, st->cont, ACTIVATION_TANH); - celt_assert(FWC5_STATE_SIZE == model->fwc5_cont_fc_0.nb_outputs); - compute_generic_dense(&model->fwc5_cont_fc_0, st->fwc5_state, st->cont, ACTIVATION_TANH); - celt_assert(FWC6_STATE_SIZE == model->fwc6_cont_fc_0.nb_outputs); - compute_generic_dense(&model->fwc6_cont_fc_0, st->fwc6_state, st->cont, ACTIVATION_TANH); - celt_assert(FWC7_STATE_SIZE == model->fwc7_cont_fc_0.nb_outputs); - compute_generic_dense(&model->fwc7_cont_fc_0, st->fwc7_state, st->cont, ACTIVATION_TANH); - - st->cont_initialized = 1; - /* Process the first frame, discard the first subframe, and keep the rest for the first - synthesis call. */ - fwgan_synthesize_impl(st, new_pcm, lpc, features0); - OPUS_COPY(st->pcm_buf, &new_pcm[SUBFRAME_SIZE], FWGAN_FRAME_SIZE-SUBFRAME_SIZE); + for (i = LPC_ORDER; i < CONT_PCM_INPUTS; i++) { + int j; + wpcm0[i] = pcm0[i]; + for (j = 0; j < LPC_ORDER; j++) wpcm0[i] += lpc[j]*pcm0[i - j - 1]; + } + /* FIXME: Make this less stupid. */ + for (i = 0; i < LPC_ORDER; i++) wpcm0[i] = wpcm0[LPC_ORDER]; + + /* The memory of the pre-empahsis is the last sample of the weighted signal + (ignoring oaci_preemphasis+oaci_deemphasis combination). */ + st->preemph_mem = wpcm0[CONT_PCM_INPUTS - 1]; + /* The memory of the synthesis filter is the pre-emphasized continuation. */ + for (i = 0; i < LPC_ORDER; + i++) st->syn_mem[i] = pcm0[CONT_PCM_INPUTS - 1 - i] - FWGAN_DEEMPHASIS*pcm0[CONT_PCM_INPUTS - 2 - i]; + + norm2 = oaci_celt_inner_prod(wpcm0, wpcm0, CONT_PCM_INPUTS, st->arch); + norm_1 = 1.f/sqrt(1e-8f + norm2); + for (i = 0; i < CONT_PCM_INPUTS; i++) cont_inputs[i + 1] = norm_1*wpcm0[i]; + cont_inputs[0] = log(sqrt(norm2) + 1e-7f); + + /* Continuation network */ + oaci_compute_generic_dense(&model->cont_net_0, tmp1, cont_inputs, ACTIVATION_TANH); + oaci_compute_generic_dense(&model->cont_net_2, tmp2, tmp1, ACTIVATION_TANH); + oaci_compute_generic_dense(&model->cont_net_4, tmp1, tmp2, ACTIVATION_TANH); + oaci_compute_generic_dense(&model->cont_net_6, tmp2, tmp1, ACTIVATION_TANH); + oaci_compute_generic_dense(&model->cont_net_8, tmp1, tmp2, ACTIVATION_TANH); + celt_assert(CONT_NET_10_OUT_SIZE == model->cont_net_10.nb_outputs); + oaci_compute_generic_dense(&model->cont_net_10, st->cont, tmp1, ACTIVATION_TANH); + + /* Computing continuation for each layer. */ + celt_assert(RNN_GRU_STATE_SIZE == model->rnn_cont_fc_0.nb_outputs); + oaci_compute_generic_dense(&model->rnn_cont_fc_0, st->rnn_state, st->cont, ACTIVATION_TANH); + + celt_assert(FWC1_STATE_SIZE == model->fwc1_cont_fc_0.nb_outputs); + oaci_compute_generic_dense(&model->fwc1_cont_fc_0, st->fwc1_state, st->cont, ACTIVATION_TANH); + celt_assert(FWC2_STATE_SIZE == model->fwc2_cont_fc_0.nb_outputs); + oaci_compute_generic_dense(&model->fwc2_cont_fc_0, st->fwc2_state, st->cont, ACTIVATION_TANH); + celt_assert(FWC3_STATE_SIZE == model->fwc3_cont_fc_0.nb_outputs); + oaci_compute_generic_dense(&model->fwc3_cont_fc_0, st->fwc3_state, st->cont, ACTIVATION_TANH); + celt_assert(FWC4_STATE_SIZE == model->fwc4_cont_fc_0.nb_outputs); + oaci_compute_generic_dense(&model->fwc4_cont_fc_0, st->fwc4_state, st->cont, ACTIVATION_TANH); + celt_assert(FWC5_STATE_SIZE == model->fwc5_cont_fc_0.nb_outputs); + oaci_compute_generic_dense(&model->fwc5_cont_fc_0, st->fwc5_state, st->cont, ACTIVATION_TANH); + celt_assert(FWC6_STATE_SIZE == model->fwc6_cont_fc_0.nb_outputs); + oaci_compute_generic_dense(&model->fwc6_cont_fc_0, st->fwc6_state, st->cont, ACTIVATION_TANH); + celt_assert(FWC7_STATE_SIZE == model->fwc7_cont_fc_0.nb_outputs); + oaci_compute_generic_dense(&model->fwc7_cont_fc_0, st->fwc7_state, st->cont, ACTIVATION_TANH); + + st->cont_initialized = 1; + /* Process the first frame, discard the first subframe, and keep the rest for the first + synthesis call. */ + fwgan_synthesize_impl(st, new_pcm, lpc, features0); + OAC_COPY(st->pcm_buf, &new_pcm[SUBFRAME_SIZE], FWGAN_FRAME_SIZE - SUBFRAME_SIZE); } static void apply_gain(float *pcm, float c0, float *last_gain) { - int i; - float gain = pow(10.f, (0.5f*c0/sqrt(18.f))); - for (i=0;imodel; - - pitch_embeddings(pembed, st->embed_phase, w0); - /* Interleave bfcc_cond and pembed for each subframe in feat_in. */ - OPUS_COPY(&feat_in[BFCC_WITH_CORR_UPSAMPLER_FC_OUT_SIZE/4], &cond[0], BFCC_WITH_CORR_UPSAMPLER_FC_OUT_SIZE/4); - OPUS_COPY(&feat_in[0], &pembed[0], FWGAN_FRAME_SIZE/2); - - compute_generic_conv1d(&model->feat_in_conv1_conv, rnn_in, st->cont_conv1_mem, feat_in, FEAT_IN_CONV1_CONV_IN_SIZE, ACTIVATION_LINEAR); - celt_assert(FEAT_IN_NL1_GATE_OUT_SIZE == model->feat_in_nl1_gate.nb_outputs); - compute_gated_activation(&model->feat_in_nl1_gate, rnn_in, rnn_in, ACTIVATION_TANH); - - if (st->cont_initialized == 1) { - /* On the very first subframe we stop here. We only want to run the feat_in layer since the - others are initialized via the continuation network. */ - OPUS_CLEAR(pcm, SUBFRAME_SIZE); - st->cont_initialized = 2; - apply_gain(pcm, c0, &st->last_gain); - OPUS_COPY(st->last_lpc, lpc, LPC_ORDER); - return; - } +static void run_fwgan_subframe(FWGANState *st, float *pcm, const float *cond, double w0, const float *lpc, float c0) { + float tmp1[FWC1_FC_0_OUT_SIZE]; + float tmp2[IMAX(RNN_GRU_STATE_SIZE, FWC2_FC_0_OUT_SIZE)]; + float feat_in[FEAT_IN_SIZE]; + float rnn_in[FEAT_IN_CONV1_CONV_OUT_SIZE]; + float pembed[FWGAN_FRAME_SIZE/2]; + FWGAN *model; + model = &st->model; + + pitch_embeddings(pembed, st->embed_phase, w0); + /* Interleave bfcc_cond and pembed for each subframe in feat_in. */ + OAC_COPY(&feat_in[BFCC_WITH_CORR_UPSAMPLER_FC_OUT_SIZE/4], &cond[0], BFCC_WITH_CORR_UPSAMPLER_FC_OUT_SIZE/4); + OAC_COPY(&feat_in[0], &pembed[0], FWGAN_FRAME_SIZE/2); + + oaci_compute_generic_conv1d(&model->feat_in_conv1_conv, rnn_in, st->cont_conv1_mem, feat_in, FEAT_IN_CONV1_CONV_IN_SIZE, + ACTIVATION_LINEAR); + celt_assert(FEAT_IN_NL1_GATE_OUT_SIZE == model->feat_in_nl1_gate.nb_outputs); + compute_gated_activation(&model->feat_in_nl1_gate, rnn_in, rnn_in, ACTIVATION_TANH); - compute_generic_gru(&model->rnn_gru_input, &model->rnn_gru_recurrent, st->rnn_state, rnn_in); - celt_assert(IMAX(RNN_GRU_STATE_SIZE, FWC2_FC_0_OUT_SIZE) >= model->rnn_nl_gate.nb_outputs); - compute_gated_activation(&model->rnn_nl_gate, tmp2, st->rnn_state, ACTIVATION_TANH); + if (st->cont_initialized == 1) { + /* On the very first subframe we stop here. We only want to run the feat_in layer since the + others are initialized via the continuation network. */ + OAC_CLEAR(pcm, SUBFRAME_SIZE); + st->cont_initialized = 2; + apply_gain(pcm, c0, &st->last_gain); + OAC_COPY(st->last_lpc, lpc, LPC_ORDER); + return; + } - compute_generic_conv1d(&model->fwc1_fc_0, tmp1, st->fwc1_state, tmp2, RNN_GRU_STATE_SIZE, ACTIVATION_LINEAR); - compute_gated_activation(&model->fwc1_fc_1_gate, tmp1, tmp1, ACTIVATION_TANH); + oaci_compute_generic_gru(&model->rnn_gru_input, &model->rnn_gru_recurrent, st->rnn_state, rnn_in); + celt_assert(IMAX(RNN_GRU_STATE_SIZE, FWC2_FC_0_OUT_SIZE) >= model->rnn_nl_gate.nb_outputs); + compute_gated_activation(&model->rnn_nl_gate, tmp2, st->rnn_state, ACTIVATION_TANH); - compute_generic_conv1d(&model->fwc2_fc_0, tmp2, st->fwc2_state, tmp1, FWC1_FC_0_OUT_SIZE, ACTIVATION_LINEAR); - compute_gated_activation(&model->fwc2_fc_1_gate, tmp2, tmp2, ACTIVATION_TANH); + oaci_compute_generic_conv1d(&model->fwc1_fc_0, tmp1, st->fwc1_state, tmp2, RNN_GRU_STATE_SIZE, ACTIVATION_LINEAR); + compute_gated_activation(&model->fwc1_fc_1_gate, tmp1, tmp1, ACTIVATION_TANH); - compute_generic_conv1d(&model->fwc3_fc_0, tmp1, st->fwc3_state, tmp2, FWC2_FC_0_OUT_SIZE, ACTIVATION_LINEAR); - compute_gated_activation(&model->fwc3_fc_1_gate, tmp1, tmp1, ACTIVATION_TANH); + oaci_compute_generic_conv1d(&model->fwc2_fc_0, tmp2, st->fwc2_state, tmp1, FWC1_FC_0_OUT_SIZE, ACTIVATION_LINEAR); + compute_gated_activation(&model->fwc2_fc_1_gate, tmp2, tmp2, ACTIVATION_TANH); - compute_generic_conv1d(&model->fwc4_fc_0, tmp2, st->fwc4_state, tmp1, FWC3_FC_0_OUT_SIZE, ACTIVATION_LINEAR); - compute_gated_activation(&model->fwc4_fc_1_gate, tmp2, tmp2, ACTIVATION_TANH); + oaci_compute_generic_conv1d(&model->fwc3_fc_0, tmp1, st->fwc3_state, tmp2, FWC2_FC_0_OUT_SIZE, ACTIVATION_LINEAR); + compute_gated_activation(&model->fwc3_fc_1_gate, tmp1, tmp1, ACTIVATION_TANH); - compute_generic_conv1d(&model->fwc5_fc_0, tmp1, st->fwc5_state, tmp2, FWC4_FC_0_OUT_SIZE, ACTIVATION_LINEAR); - compute_gated_activation(&model->fwc5_fc_1_gate, tmp1, tmp1, ACTIVATION_TANH); + oaci_compute_generic_conv1d(&model->fwc4_fc_0, tmp2, st->fwc4_state, tmp1, FWC3_FC_0_OUT_SIZE, ACTIVATION_LINEAR); + compute_gated_activation(&model->fwc4_fc_1_gate, tmp2, tmp2, ACTIVATION_TANH); - compute_generic_conv1d(&model->fwc6_fc_0, tmp2, st->fwc6_state, tmp1, FWC5_FC_0_OUT_SIZE, ACTIVATION_LINEAR); - compute_gated_activation(&model->fwc6_fc_1_gate, tmp2, tmp2, ACTIVATION_TANH); + oaci_compute_generic_conv1d(&model->fwc5_fc_0, tmp1, st->fwc5_state, tmp2, FWC4_FC_0_OUT_SIZE, ACTIVATION_LINEAR); + compute_gated_activation(&model->fwc5_fc_1_gate, tmp1, tmp1, ACTIVATION_TANH); - compute_generic_conv1d(&model->fwc7_fc_0, tmp1, st->fwc7_state, tmp2, FWC6_FC_0_OUT_SIZE, ACTIVATION_LINEAR); - compute_gated_activation(&model->fwc7_fc_1_gate, pcm, tmp1, ACTIVATION_TANH); + oaci_compute_generic_conv1d(&model->fwc6_fc_0, tmp2, st->fwc6_state, tmp1, FWC5_FC_0_OUT_SIZE, ACTIVATION_LINEAR); + compute_gated_activation(&model->fwc6_fc_1_gate, tmp2, tmp2, ACTIVATION_TANH); - apply_gain(pcm, c0, &st->last_gain); - fwgan_preemphasis(pcm, &st->preemph_mem); - fwgan_lpc_syn(pcm, st->syn_mem, lpc, st->last_lpc); - fwgan_deemphasis(pcm, &st->deemph_mem); + oaci_compute_generic_conv1d(&model->fwc7_fc_0, tmp1, st->fwc7_state, tmp2, FWC6_FC_0_OUT_SIZE, ACTIVATION_LINEAR); + compute_gated_activation(&model->fwc7_fc_1_gate, pcm, tmp1, ACTIVATION_TANH); + + apply_gain(pcm, c0, &st->last_gain); + fwgan_preemphasis(pcm, &st->preemph_mem); + fwgan_lpc_syn(pcm, st->syn_mem, lpc, st->last_lpc); + fwgan_deemphasis(pcm, &st->deemph_mem); } -void fwgan_init(FWGANState *st) -{ - int ret; - OPUS_CLEAR(st, 1); - ret = init_fwgan(&st->model, fwgan_arrays); - celt_assert(ret == 0); - /* FIXME: perform arch detection. */ +void fwgan_init(FWGANState *st) { + int ret; + OAC_CLEAR(st, 1); + ret = init_fwgan(&st->model, fwgan_arrays); + celt_assert(ret == 0); + /* FIXME: perform arch detection. */ } int fwgan_load_model(FWGANState *st, const unsigned char *data, int len) { - WeightArray *list; - int ret; - parse_weights(&list, data, len); - ret = init_fwgan(&st->model, list); - opus_free(list); - if (ret == 0) return 0; - else return -1; + WeightArray *list; + int ret; + oaci_parse_weights(&list, data, len); + ret = init_fwgan(&st->model, list); + oac_free(list); + if (ret == 0) return 0; + else return -1; } -static void fwgan_synthesize_impl(FWGANState *st, float *pcm, const float *lpc, const float *features) -{ - int subframe; - float cond[BFCC_WITH_CORR_UPSAMPLER_FC_OUT_SIZE]; - double w0; - int period; - float fwgan_features[NB_FEATURES-1]; - celt_assert(st->cont_initialized); - OPUS_COPY(fwgan_features, features, NB_FEATURES-2); - fwgan_features[NB_FEATURES-2] = features[NB_FEATURES-1]+.5; - - period = (int)floor(.1 + 50*features[NB_BANDS]+100); - w0 = 2*M_PI/period; - run_fwgan_upsampler(st, cond, fwgan_features); - for (subframe=0;subframecont_initialized); + OAC_COPY(fwgan_features, features, NB_FEATURES - 2); + fwgan_features[NB_FEATURES - 2] = features[NB_FEATURES - 1] + .5; + + period = (int)floor(.1 + 50*features[NB_BANDS] + 100); + w0 = 2*M_PI/period; + run_fwgan_upsampler(st, cond, fwgan_features); + for (subframe = 0; subframe < NB_SUBFRAMES; subframe++) { + float *sub_cond; + sub_cond = &cond[subframe*BFCC_WITH_CORR_UPSAMPLER_FC_OUT_SIZE/4]; + run_fwgan_subframe(st, &pcm[subframe*SUBFRAME_SIZE], sub_cond, w0, lpc, features[0]); + } } -void fwgan_synthesize(FWGANState *st, float *pcm, const float *features) -{ - float lpc[LPC_ORDER]; - float new_pcm[FWGAN_FRAME_SIZE]; - compute_wlpc(lpc, features); - fwgan_synthesize_impl(st, new_pcm, lpc, features); - /* Handle buffering. */ - OPUS_COPY(pcm, st->pcm_buf, FWGAN_FRAME_SIZE-SUBFRAME_SIZE); - OPUS_COPY(&pcm[FWGAN_FRAME_SIZE-SUBFRAME_SIZE], new_pcm, SUBFRAME_SIZE); - OPUS_COPY(st->pcm_buf, &new_pcm[SUBFRAME_SIZE], FWGAN_FRAME_SIZE-SUBFRAME_SIZE); +void fwgan_synthesize(FWGANState *st, float *pcm, const float *features) { + float lpc[LPC_ORDER]; + float new_pcm[FWGAN_FRAME_SIZE]; + compute_wlpc(lpc, features); + fwgan_synthesize_impl(st, new_pcm, lpc, features); + /* Handle buffering. */ + OAC_COPY(pcm, st->pcm_buf, FWGAN_FRAME_SIZE - SUBFRAME_SIZE); + OAC_COPY(&pcm[FWGAN_FRAME_SIZE - SUBFRAME_SIZE], new_pcm, SUBFRAME_SIZE); + OAC_COPY(st->pcm_buf, &new_pcm[SUBFRAME_SIZE], FWGAN_FRAME_SIZE - SUBFRAME_SIZE); } -void fwgan_synthesize_int(FWGANState *st, opus_int16 *pcm, const float *features) -{ - int i; - float fpcm[FWGAN_FRAME_SIZE]; - fwgan_synthesize(st, fpcm, features); - for (i=0;iz=362436069; - _this->w=521288629; - _this->jsr=123456789; - _this->jcong=380116160; - for(i=3;i<_ndata;i+=4){ - _this->z^=_data[i-3]; - _this->w^=_data[i-2]; - _this->jsr^=_data[i-1]; - _this->jcong^=_data[i]; - kiss99_rand(_this); - } - if(i-3<_ndata)_this->z^=_data[i-3]; - if(i-2<_ndata)_this->w^=_data[i-2]; - if(i-1<_ndata)_this->jsr^=_data[i-1]; - /*Fix any potential short cycles that show up. - These are not too likely, given the way we initialize the state, but they - are technically possible, so let us go ahead and eliminate that - possibility. - See Gregory G. Rose: "KISS: A Bit Too Simple", Cryptographic Communications - No. 10, pp. 123---137, 2018.*/ - if(_this->z==0||_this->z==0x9068FFFF)_this->z++; - if(_this->w==0||_this->w==0x464FFFFF)_this->w++; - if(_this->jsr==0)_this->jsr++; +void kiss99_srand(kiss99_ctx *_this, const unsigned char *_data, int _ndata) { + int i; + _this->z = 362436069; + _this->w = 521288629; + _this->jsr = 123456789; + _this->jcong = 380116160; + for (i = 3; i < _ndata; i += 4) { + _this->z ^= _data[i - 3]; + _this->w ^= _data[i - 2]; + _this->jsr ^= _data[i - 1]; + _this->jcong ^= _data[i]; + kiss99_rand(_this); + } + if (i - 3 < _ndata) _this->z ^= _data[i - 3]; + if (i - 2 < _ndata) _this->w ^= _data[i - 2]; + if (i - 1 < _ndata) _this->jsr ^= _data[i - 1]; + /*Fix any potential short cycles that show up. + These are not too likely, given the way we initialize the state, but they + are technically possible, so let us go ahead and eliminate that + possibility. + See Gregory G. Rose: "KISS: A Bit Too Simple", Cryptographic Communications + No. 10, pp. 123---137, 2018.*/ + if (_this->z == 0 || _this->z == 0x9068FFFF) _this->z++; + if (_this->w == 0 || _this->w == 0x464FFFFF) _this->w++; + if (_this->jsr == 0) _this->jsr++; } -uint32_t kiss99_rand(kiss99_ctx *_this){ - uint32_t znew; - uint32_t wnew; - uint32_t mwc; - uint32_t shr3; - uint32_t cong; - znew=36969*(_this->z&0xFFFF)+(_this->z>>16); - wnew=18000*(_this->w&0xFFFF)+(_this->w>>16); - mwc=(znew<<16)+wnew; - /*We swap the 13 and 17 from the original 1999 algorithm to produce a single - cycle of maximal length, matching KISS11. - We are not actually using KISS11 because of the impractically large (16 MB) - internal state of the full algorithm.*/ - shr3=_this->jsr^(_this->jsr<<13); - shr3^=shr3>>17; - shr3^=shr3<<5; - cong=69069*_this->jcong+1234567; - _this->z=znew; - _this->w=wnew; - _this->jsr=shr3; - _this->jcong=cong; - return (mwc^cong)+shr3; +uint32_t kiss99_rand(kiss99_ctx *_this) { + uint32_t znew; + uint32_t wnew; + uint32_t mwc; + uint32_t shr3; + uint32_t cong; + znew = 36969*(_this->z&0xFFFF) + (_this->z>>16); + wnew = 18000*(_this->w&0xFFFF) + (_this->w>>16); + mwc = (znew<<16) + wnew; + /*We swap the 13 and 17 from the original 1999 algorithm to produce a single + cycle of maximal length, matching KISS11. + We are not actually using KISS11 because of the impractically large (16 MB) + internal state of the full algorithm.*/ + shr3 = _this->jsr^(_this->jsr<<13); + shr3 ^= shr3>>17; + shr3 ^= shr3<<5; + cong = 69069*_this->jcong + 1234567; + _this->z = znew; + _this->w = wnew; + _this->jsr = shr3; + _this->jcong = cong; + return (mwc^cong) + shr3; } diff --git a/dnn/kiss99.h b/dnn/kiss99.h index c1416d109..33862b022 100644 --- a/dnn/kiss99.h +++ b/dnn/kiss99.h @@ -1,46 +1,46 @@ /*Daala video codec -Copyright (c) 2012 Daala project contributors. All rights reserved. -Author: Timothy B. Terriberry - -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.*/ + Copyright (c) 2012 Daala project contributors. All rights reserved. + Author: Timothy B. Terriberry + + 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.*/ #if !defined(_kiss99_H) -# define _kiss99_H (1) -# include +#define _kiss99_H (1) +#include /*KISS PRNG from George Marsaglia (1999 version). - See https://en.wikipedia.org/wiki/KISS_(algorithm) for details. - This is suitable for simulations, but not for use in cryptographic contexts.*/ + See https://en.wikipedia.org/wiki/KISS_(algorithm) for details. + This is suitable for simulations, but not for use in cryptographic contexts.*/ typedef struct kiss99_ctx kiss99_ctx; -struct kiss99_ctx{ - uint32_t z; - uint32_t w; - uint32_t jsr; - uint32_t jcong; +struct kiss99_ctx { + uint32_t z; + uint32_t w; + uint32_t jsr; + uint32_t jcong; }; -void kiss99_srand(kiss99_ctx *_this,const unsigned char *_data,int _ndata); +void kiss99_srand(kiss99_ctx *_this, const unsigned char *_data, int _ndata); uint32_t kiss99_rand(kiss99_ctx *_this); #endif diff --git a/dnn/lossgen.c b/dnn/lossgen.c index 52b5029bb..5b2a412a0 100644 --- a/dnn/lossgen.c +++ b/dnn/lossgen.c @@ -22,9 +22,9 @@ 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. -*/ + */ -/* This packet loss simulator can be used independently of the Opus codebase. +/* This packet loss simulator can be used independently of the Oac codebase. To do that, you need to compile the following files: dnn/lossgen.c dnn/lossgen_data.c @@ -40,15 +40,15 @@ celt/os_support.h celt/arch.h celt/x86/x86_arch_macros.h - include/opus_defines.h - include/opus_types.h + include/oac_defines.h + include/oac_types.h Additionally, the code in dnn/lossgen_demo.c can be used to generate losses from the command line. -*/ + */ #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif #include "arch.h" @@ -70,123 +70,122 @@ #include "parse_lpcnet_weights.c" #include "nnet_arch.h" -#undef compute_linear -#undef compute_activation +#undef oaci_compute_linear +#undef oaci_compute_activation /* Force the C version since the SIMD versions may be hidden. */ -#define compute_linear(linear, out, in, arch) ((void)(arch),compute_linear_c(linear, out, in)) -#define compute_activation(output, input, N, activation, arch) ((void)(arch),compute_activation_c(output, input, N, activation)) +#define oaci_compute_linear(linear, out, in, arch) ((void)(arch), oaci_compute_linear_c(linear, out, in)) +#define oaci_compute_activation(output, input, N, activation, arch) ((void)(arch), \ + oaci_compute_activation_c(output, input, N, activation)) #define MAX_RNN_NEURONS_ALL IMAX(LOSSGEN_GRU1_STATE_SIZE, LOSSGEN_GRU2_STATE_SIZE) /* These two functions are copied from nnet.c to make sure we don't have linking issues. */ -void compute_generic_gru_lossgen(const LinearLayer *input_weights, const LinearLayer *recurrent_weights, float *state, const float *in, int arch) -{ - int i; - int N; - float zrh[3*MAX_RNN_NEURONS_ALL]; - float recur[3*MAX_RNN_NEURONS_ALL]; - float *z; - float *r; - float *h; - celt_assert(3*recurrent_weights->nb_inputs == recurrent_weights->nb_outputs); - celt_assert(input_weights->nb_outputs == recurrent_weights->nb_outputs); - N = recurrent_weights->nb_inputs; - z = zrh; - r = &zrh[N]; - h = &zrh[2*N]; - celt_assert(recurrent_weights->nb_outputs <= 3*MAX_RNN_NEURONS_ALL); - celt_assert(in != state); - compute_linear(input_weights, zrh, in, arch); - compute_linear(recurrent_weights, recur, state, arch); - for (i=0;i<2*N;i++) - zrh[i] += recur[i]; - compute_activation(zrh, zrh, 2*N, ACTIVATION_SIGMOID, arch); - for (i=0;inb_inputs == recurrent_weights->nb_outputs); + celt_assert(input_weights->nb_outputs == recurrent_weights->nb_outputs); + N = recurrent_weights->nb_inputs; + z = zrh; + r = &zrh[N]; + h = &zrh[2*N]; + celt_assert(recurrent_weights->nb_outputs <= 3*MAX_RNN_NEURONS_ALL); + celt_assert(in != state); + oaci_compute_linear(input_weights, zrh, in, arch); + oaci_compute_linear(recurrent_weights, recur, state, arch); + for (i = 0; i < 2*N; i++) + zrh[i] += recur[i]; + oaci_compute_activation(zrh, zrh, 2*N, ACTIVATION_SIGMOID, arch); + for (i = 0; i < N; i++) + h[i] += recur[2*N + i]*r[i]; + oaci_compute_activation(h, h, N, ACTIVATION_TANH, arch); + for (i = 0; i < N; i++) + h[i] = z[i]*state[i] + (1 - z[i])*h[i]; + for (i = 0; i < N; i++) + state[i] = h[i]; } -void compute_generic_dense_lossgen(const LinearLayer *layer, float *output, const float *input, int activation, int arch) -{ - compute_linear(layer, output, input, arch); - compute_activation(output, output, layer->nb_outputs, activation, arch); +void compute_generic_dense_lossgen(const LinearLayer *layer, float *output, const float *input, int activation, + int arch) { + oaci_compute_linear(layer, output, input, arch); + oaci_compute_activation(output, output, layer->nb_outputs, activation, arch); } static int sample_loss_impl( LossGenState *st, - float percent_loss) -{ - float input[2]; - float tmp[LOSSGEN_DENSE_IN_OUT_SIZE]; - float out; - int loss; - LossGen *model = &st->model; - input[0] = st->last_loss; - input[1] = percent_loss; - compute_generic_dense_lossgen(&model->lossgen_dense_in, tmp, input, ACTIVATION_TANH, 0); - compute_generic_gru_lossgen(&model->lossgen_gru1_input, &model->lossgen_gru1_recurrent, st->gru1_state, tmp, 0); - compute_generic_gru_lossgen(&model->lossgen_gru2_input, &model->lossgen_gru2_recurrent, st->gru2_state, st->gru1_state, 0); - compute_generic_dense_lossgen(&model->lossgen_dense_out, &out, st->gru2_state, ACTIVATION_SIGMOID, 0); - loss = (float)rand()/(float)RAND_MAX < out; - st->last_loss = loss; - return loss; + float percent_loss) { + float input[2]; + float tmp[LOSSGEN_DENSE_IN_OUT_SIZE]; + float out; + int loss; + LossGen *model = &st->model; + input[0] = st->last_loss; + input[1] = percent_loss; + compute_generic_dense_lossgen(&model->lossgen_dense_in, tmp, input, ACTIVATION_TANH, 0); + compute_generic_gru_lossgen(&model->lossgen_gru1_input, &model->lossgen_gru1_recurrent, st->gru1_state, tmp, 0); + compute_generic_gru_lossgen(&model->lossgen_gru2_input, &model->lossgen_gru2_recurrent, st->gru2_state, + st->gru1_state, 0); + compute_generic_dense_lossgen(&model->lossgen_dense_out, &out, st->gru2_state, ACTIVATION_SIGMOID, 0); + loss = (float)rand()/(float)RAND_MAX < out; + st->last_loss = loss; + return loss; } int sample_loss( LossGenState *st, - float percent_loss) -{ - /* Due to GRU being initialized with zeros, the first packets aren't quite random, - so we skip them. */ - if (!st->used) { - int i; - for (i=0;i<1000;i++) sample_loss_impl(st, percent_loss); - st->used = 1; - } - return sample_loss_impl(st, percent_loss); + float percent_loss) { + /* Due to GRU being initialized with zeros, the first packets aren't quite random, + so we skip them. */ + if (!st->used) { + int i; + for (i = 0; i < 1000; i++) sample_loss_impl(st, percent_loss); + st->used = 1; + } + return sample_loss_impl(st, percent_loss); } -void lossgen_init(LossGenState *st) -{ - int ret; - OPUS_CLEAR(st, 1); - ret = init_lossgen(&st->model, lossgen_arrays); - celt_assert(ret == 0); - (void)ret; +void lossgen_init(LossGenState *st) { + int ret; + OAC_CLEAR(st, 1); + ret = oaci_init_lossgen(&st->model, oaci_lossgen_arrays); + celt_assert(ret == 0); + (void)ret; } int lossgen_load_model(LossGenState *st, const void *data, int len) { - WeightArray *list; - int ret; - parse_weights(&list, data, len); - ret = init_lossgen(&st->model, list); - opus_free(list); - if (ret == 0) return 0; - else return -1; + WeightArray *list; + int ret; + oaci_parse_weights(&list, data, len); + ret = oaci_init_lossgen(&st->model, list); + oac_free(list); + if (ret == 0) return 0; + else return -1; } #if 0 -#include +# include int main(int argc, char **argv) { - int i, N; - float p; - LossGenState st; - if (argc!=3) { - fprintf(stderr, "usage: lossgen \n"); - return 1; - } - lossgen_init(&st); - p = atof(argv[1]); - N = atoi(argv[2]); - for (i=0;i \n"); + return 1; + } + lossgen_init(&st); + p = atof(argv[1]); + N = atoi(argv[2]); + for (i = 0; i < N; i++) { + printf("%d\n", sample_loss(&st, p)); + } } #endif diff --git a/dnn/lossgen.h b/dnn/lossgen.h index 78253e688..60c35d9bd 100644 --- a/dnn/lossgen.h +++ b/dnn/lossgen.h @@ -22,7 +22,7 @@ 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. -*/ + */ #ifndef LOSSGEN_H #define LOSSGEN_H @@ -34,15 +34,15 @@ #define PITCH_MIN_PERIOD 32 #define PITCH_MAX_PERIOD 256 -#define NB_XCORR_FEATURES (PITCH_MAX_PERIOD-PITCH_MIN_PERIOD) +#define NB_XCORR_FEATURES (PITCH_MAX_PERIOD - PITCH_MIN_PERIOD) typedef struct { - LossGen model; - float gru1_state[LOSSGEN_GRU1_STATE_SIZE]; - float gru2_state[LOSSGEN_GRU2_STATE_SIZE]; - int last_loss; - int used; + LossGen model; + float gru1_state[LOSSGEN_GRU1_STATE_SIZE]; + float gru2_state[LOSSGEN_GRU2_STATE_SIZE]; + int last_loss; + int used; } LossGenState; diff --git a/dnn/lossgen_demo.c b/dnn/lossgen_demo.c index bad7bdc32..97a25dd8c 100644 --- a/dnn/lossgen_demo.c +++ b/dnn/lossgen_demo.c @@ -1,22 +1,21 @@ #include #include #include "lossgen.h" -int main(int argc, char **argv) -{ - LossGenState st; - long num_packets; - long i; - float percent; - if (argc != 3) { - fprintf(stderr, "usage: %s \n", argv[0]); - return 1; - } - lossgen_init(&st); - percent = atof(argv[1]); - num_packets = atol(argv[2]); - /*printf("loss: %f %d\n", percent, num_packets);*/ - for (i=0;i \n", argv[0]); + return 1; + } + lossgen_init(&st); + percent = atof(argv[1]); + num_packets = atol(argv[2]); + /*printf("loss: %f %d\n", percent, num_packets);*/ + for (i = 0; i < num_packets; i++) { + printf("%d\n", sample_loss(&st, percent*0.01f)); + } + return 0; } diff --git a/dnn/lpcnet.c b/dnn/lpcnet.c index 52e81b074..8a80bd63b 100644 --- a/dnn/lpcnet.c +++ b/dnn/lpcnet.c @@ -22,10 +22,10 @@ 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" +# include "config.h" #endif #include @@ -46,42 +46,36 @@ #if 0 -static void print_vector(float *x, int N) -{ +static void print_vector(float *x, int N) { int i; - for (i=0;innet; - OPUS_COPY(in, features, NB_FEATURES); + OAC_COPY(in, features, NB_FEATURES); compute_embedding(&lpcnet->model.embed_pitch, &in[NB_FEATURES], pitch); compute_conv1d(&lpcnet->model.feature_conv1, conv1_out, net->feature_conv1_state, in); - if (lpcnet->frame_count < FEATURE_CONV1_DELAY) OPUS_CLEAR(conv1_out, FEATURE_CONV1_OUT_SIZE); + if (lpcnet->frame_count < FEATURE_CONV1_DELAY) OAC_CLEAR(conv1_out, FEATURE_CONV1_OUT_SIZE); compute_conv1d(&lpcnet->model.feature_conv2, conv2_out, net->feature_conv2_state, conv1_out); - if (lpcnet->frame_count < FEATURES_DELAY) OPUS_CLEAR(conv2_out, FEATURE_CONV2_OUT_SIZE); + if (lpcnet->frame_count < FEATURES_DELAY) OAC_CLEAR(conv2_out, FEATURE_CONV2_OUT_SIZE); _lpcnet_compute_dense(&lpcnet->model.feature_dense1, dense1_out, conv2_out); _lpcnet_compute_dense(&lpcnet->model.feature_dense2, condition, dense1_out); - OPUS_COPY(rc, condition, LPC_ORDER); + OAC_COPY(rc, condition, LPC_ORDER); _lpcnet_compute_dense(&lpcnet->model.gru_a_dense_feature, gru_a_condition, condition); _lpcnet_compute_dense(&lpcnet->model.gru_b_dense_feature, gru_b_condition, condition); #ifdef END2END rc2lpc(lpc, rc); -#elif FEATURES_DELAY>0 - memcpy(lpc, lpcnet->old_lpc[FEATURES_DELAY-1], LPC_ORDER*sizeof(lpc[0])); - memmove(lpcnet->old_lpc[1], lpcnet->old_lpc[0], (FEATURES_DELAY-1)*LPC_ORDER*sizeof(lpc[0])); - lpc_from_cepstrum(lpcnet->old_lpc[0], features); +#elif FEATURES_DELAY > 0 + memcpy(lpc, lpcnet->old_lpc[FEATURES_DELAY - 1], LPC_ORDER*sizeof(lpc[0])); + memmove(lpcnet->old_lpc[1], lpcnet->old_lpc[0], (FEATURES_DELAY - 1)*LPC_ORDER*sizeof(lpc[0])); + oaci_lpc_from_cepstrum(lpcnet->old_lpc[0], features); #else - lpc_from_cepstrum(lpc, features); + oaci_lpc_from_cepstrum(lpc, features); #endif #ifdef LPC_GAMMA - lpc_weighting(lpc, LPC_GAMMA); + oaci_lpc_weighting(lpc, LPC_GAMMA); #endif if (lpcnet->frame_count < 1000) lpcnet->frame_count++; } -void run_frame_network_deferred(LPCNetState *lpcnet, const float *features) -{ +void run_frame_network_deferred(LPCNetState *lpcnet, const float *features) { int max_buffer_size = lpcnet->model.feature_conv1.kernel_size + lpcnet->model.feature_conv2.kernel_size - 2; celt_assert(max_buffer_size <= MAX_FEATURE_BUFFER_SIZE); if (lpcnet->feature_buffer_fill == max_buffer_size) { - OPUS_MOVE(lpcnet->feature_buffer, &lpcnet->feature_buffer[NB_FEATURES], (max_buffer_size-1)*NB_FEATURES); + OAC_MOVE(lpcnet->feature_buffer, &lpcnet->feature_buffer[NB_FEATURES], (max_buffer_size - 1)*NB_FEATURES); } else { - lpcnet->feature_buffer_fill++; + lpcnet->feature_buffer_fill++; } - OPUS_COPY(&lpcnet->feature_buffer[(lpcnet->feature_buffer_fill-1)*NB_FEATURES], features, NB_FEATURES); + OAC_COPY(&lpcnet->feature_buffer[(lpcnet->feature_buffer_fill - 1)*NB_FEATURES], features, NB_FEATURES); } -void run_frame_network_flush(LPCNetState *lpcnet) -{ +void run_frame_network_flush(LPCNetState *lpcnet) { int i; - for (i=0;ifeature_buffer_fill;i++) { + for (i = 0; i < lpcnet->feature_buffer_fill; i++) { float lpc[LPC_ORDER]; float gru_a_condition[3*GRU_A_STATE_SIZE]; float gru_b_condition[3*GRU_B_STATE_SIZE]; @@ -144,51 +136,49 @@ void run_frame_network_flush(LPCNetState *lpcnet) lpcnet->feature_buffer_fill = 0; } -int run_sample_network(LPCNetState *lpcnet, const float *gru_a_condition, const float *gru_b_condition, int last_exc, int last_sig, int pred, const float *sampling_logit_table, kiss99_ctx *rng) -{ +int run_sample_network(LPCNetState *lpcnet, const float *gru_a_condition, const float *gru_b_condition, int last_exc, + int last_sig, int pred, const float *sampling_logit_table, kiss99_ctx *rng) { NNetState *net; float gru_a_input[3*GRU_A_STATE_SIZE]; - float in_b[GRU_A_STATE_SIZE+FEATURE_DENSE2_OUT_SIZE]; + float in_b[GRU_A_STATE_SIZE + FEATURE_DENSE2_OUT_SIZE]; float gru_b_input[3*GRU_B_STATE_SIZE]; net = &lpcnet->nnet; #if 1 - compute_gru_a_input(gru_a_input, gru_a_condition, GRU_A_STATE_SIZE, &lpcnet->model.gru_a_embed_sig, last_sig, &lpcnet->model.gru_a_embed_pred, pred, &lpcnet->model.gru_a_embed_exc, last_exc); + compute_gru_a_input(gru_a_input, gru_a_condition, GRU_A_STATE_SIZE, &lpcnet->model.gru_a_embed_sig, last_sig, + &lpcnet->model.gru_a_embed_pred, pred, &lpcnet->model.gru_a_embed_exc, last_exc); #else - OPUS_COPY(gru_a_input, gru_a_condition, 3*GRU_A_STATE_SIZE); + OAC_COPY(gru_a_input, gru_a_condition, 3*GRU_A_STATE_SIZE); accum_embedding(&lpcnet->model.gru_a_embed_sig, gru_a_input, last_sig); accum_embedding(&lpcnet->model.gru_a_embed_pred, gru_a_input, pred); accum_embedding(&lpcnet->model.gru_a_embed_exc, gru_a_input, last_exc); #endif /*compute_gru3(&gru_a, net->gru_a_state, gru_a_input);*/ compute_sparse_gru(&lpcnet->model.sparse_gru_a, net->gru_a_state, gru_a_input); - OPUS_COPY(in_b, net->gru_a_state, GRU_A_STATE_SIZE); - OPUS_COPY(gru_b_input, gru_b_condition, 3*GRU_B_STATE_SIZE); + OAC_COPY(in_b, net->gru_a_state, GRU_A_STATE_SIZE); + OAC_COPY(gru_b_input, gru_b_condition, 3*GRU_B_STATE_SIZE); compute_gruB(&lpcnet->model.gru_b, gru_b_input, net->gru_b_state, in_b); return sample_mdense(&lpcnet->model.dual_fc, net->gru_b_state, sampling_logit_table, rng); } -int lpcnet_get_size() -{ +int lpcnet_get_size() { return sizeof(LPCNetState); } -void lpcnet_reset(LPCNetState *lpcnet) -{ - const char* rng_string="LPCNet"; - OPUS_CLEAR((char*)&lpcnet->LPCNET_RESET_START, - sizeof(LPCNetState)- - ((char*)&lpcnet->LPCNET_RESET_START - (char*)lpcnet)); +void lpcnet_reset(LPCNetState *lpcnet) { + const char* rng_string = "LPCNet"; + OAC_CLEAR((char*)&lpcnet->LPCNET_RESET_START, + sizeof(LPCNetState) + - ((char*)&lpcnet->LPCNET_RESET_START - (char*)lpcnet)); lpcnet->last_exc = lin2ulaw(0.f); kiss99_srand(&lpcnet->rng, (const unsigned char *)rng_string, strlen(rng_string)); } -int lpcnet_init(LPCNetState *lpcnet) -{ +int lpcnet_init(LPCNetState *lpcnet) { int i; int ret; - for (i=0;i<256;i++) { - float prob = .025f+.95f*i/255.f; - lpcnet->sampling_logit_table[i] = -log((1-prob)/prob); + for (i = 0; i < 256; i++) { + float prob = .025f + .95f*i/255.f; + lpcnet->sampling_logit_table[i] = -log((1 - prob)/prob); } #ifndef USE_WEIGHTS_FILE ret = init_lpcnet_model(&lpcnet->model, lpcnet_arrays); @@ -201,83 +191,77 @@ int lpcnet_init(LPCNetState *lpcnet) } int lpcnet_load_model(LPCNetState *st, const unsigned char *data, int len) { - WeightArray *list; - int ret; - parse_weights(&list, data, len); - ret = init_lpcnet_model(&st->model, list); - opus_free(list); - if (ret == 0) return 0; - else return -1; + WeightArray *list; + int ret; + oaci_parse_weights(&list, data, len); + ret = init_lpcnet_model(&st->model, list); + oac_free(list); + if (ret == 0) return 0; + else return -1; } -LPCNetState *lpcnet_create() -{ +LPCNetState *lpcnet_create() { LPCNetState *lpcnet; - lpcnet = (LPCNetState *)opus_alloc(lpcnet_get_size(), 1); - OPUS_CLEAR(lpcnet, 1); + lpcnet = (LPCNetState *)oac_alloc(lpcnet_get_size(), 1); + OAC_CLEAR(lpcnet, 1); lpcnet_init(lpcnet); return lpcnet; } -void lpcnet_destroy(LPCNetState *lpcnet) -{ - opus_free(lpcnet); +void lpcnet_destroy(LPCNetState *lpcnet) { + oac_free(lpcnet); } -void lpcnet_reset_signal(LPCNetState *lpcnet) -{ +void lpcnet_reset_signal(LPCNetState *lpcnet) { lpcnet->deemph_mem = 0; lpcnet->last_exc = lin2ulaw(0.f); - OPUS_CLEAR(lpcnet->last_sig, LPC_ORDER); - OPUS_CLEAR(lpcnet->nnet.gru_a_state, GRU_A_STATE_SIZE); - OPUS_CLEAR(lpcnet->nnet.gru_b_state, GRU_B_STATE_SIZE); + OAC_CLEAR(lpcnet->last_sig, LPC_ORDER); + OAC_CLEAR(lpcnet->nnet.gru_a_state, GRU_A_STATE_SIZE); + OAC_CLEAR(lpcnet->nnet.gru_b_state, GRU_B_STATE_SIZE); } -void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, opus_int16 *output, int N, int preload) -{ +void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, oac_int16 *output, int N, int preload) { int i; - if (lpcnet->frame_count <= FEATURES_DELAY) - { - OPUS_CLEAR(output, N); + if (lpcnet->frame_count <= FEATURES_DELAY) { + OAC_CLEAR(output, N); return; } - for (i=0;ilast_sig[j]*lpcnet->lpc[j]; + for (j = 0; j < LPC_ORDER; j++)pred -= lpcnet->last_sig[j]*lpcnet->lpc[j]; last_sig_ulaw = lin2ulaw(lpcnet->last_sig[0]); pred_ulaw = lin2ulaw(pred); - exc = run_sample_network(lpcnet, lpcnet->gru_a_condition, lpcnet->gru_b_condition, lpcnet->last_exc, last_sig_ulaw, pred_ulaw, lpcnet->sampling_logit_table, &lpcnet->rng); + exc = run_sample_network(lpcnet, lpcnet->gru_a_condition, lpcnet->gru_b_condition, lpcnet->last_exc, + last_sig_ulaw, pred_ulaw, lpcnet->sampling_logit_table, &lpcnet->rng); if (i < preload) { - exc = lin2ulaw(output[i]-PREEMPH*lpcnet->deemph_mem - pred); - pcm = output[i]-PREEMPH*lpcnet->deemph_mem; + exc = lin2ulaw(output[i] - PREEMPH*lpcnet->deemph_mem - pred); + pcm = output[i] - PREEMPH*lpcnet->deemph_mem; } else { - pcm = pred + ulaw2lin(exc); + pcm = pred + ulaw2lin(exc); } - OPUS_MOVE(&lpcnet->last_sig[1], &lpcnet->last_sig[0], LPC_ORDER-1); + OAC_MOVE(&lpcnet->last_sig[1], &lpcnet->last_sig[0], LPC_ORDER - 1); lpcnet->last_sig[0] = pcm; lpcnet->last_exc = exc; pcm += PREEMPH*lpcnet->deemph_mem; lpcnet->deemph_mem = pcm; - if (pcm<-32767) pcm = -32767; - if (pcm>32767) pcm = 32767; + if (pcm < -32767)pcm = -32767; + if (pcm > 32767)pcm = 32767; if (i >= preload) output[i] = (int)floor(.5 + pcm); } } -void lpcnet_synthesize_impl(LPCNetState *lpcnet, const float *features, opus_int16 *output, int N, int preload) -{ +void lpcnet_synthesize_impl(LPCNetState *lpcnet, const float *features, oac_int16 *output, int N, int preload) { run_frame_network(lpcnet, lpcnet->gru_a_condition, lpcnet->gru_b_condition, lpcnet->lpc, features); lpcnet_synthesize_tail_impl(lpcnet, output, N, preload); } -void lpcnet_synthesize(LPCNetState *lpcnet, const float *features, opus_int16 *output, int N) { +void lpcnet_synthesize(LPCNetState *lpcnet, const float *features, oac_int16 *output, int N) { lpcnet_synthesize_impl(lpcnet, features, output, N, 0); } diff --git a/dnn/lpcnet.h b/dnn/lpcnet.h index 4a9812466..bd9d6f9a3 100644 --- a/dnn/lpcnet.h +++ b/dnn/lpcnet.h @@ -22,12 +22,12 @@ 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. -*/ + */ #ifndef LPCNET_H_ #define LPCNET_H_ -#include "opus_types.h" +#include "oac_types.h" #define NB_FEATURES 20 #define NB_TOTAL_FEATURES 36 @@ -45,139 +45,141 @@ typedef struct LPCNetPLCState LPCNetPLCState; /** Gets the size of an LPCNetDecState structure. - * @returns The size in bytes. - */ + * @returns The size in bytes. + */ int lpcnet_decoder_get_size(void); /** Initializes a previously allocated decoder state - * The memory pointed to by st must be at least the size returned by lpcnet_decoder_get_size(). - * This is intended for applications which use their own allocator instead of malloc. - * @see lpcnet_decoder_create(),lpcnet_decoder_get_size() - * @param [in] st LPCNetDecState*: Decoder state - * @retval 0 Success - */ + * The memory pointed to by st must be at least the size returned by lpcnet_decoder_get_size(). + * This is intended for applications which use their own allocator instead of malloc. + * @see lpcnet_decoder_create(),lpcnet_decoder_get_size() + * @param [in] st LPCNetDecState*: Decoder state + * @retval 0 Success + */ int lpcnet_decoder_init(LPCNetDecState *st); void lpcnet_reset(LPCNetState *lpcnet); /** Allocates and initializes a decoder state. - * @returns The newly created state - */ + * @returns The newly created state + */ LPCNetDecState *lpcnet_decoder_create(void); /** Frees an LPCNetDecState allocated by lpcnet_decoder_create(). - * @param[in] st LPCNetDecState*: State to be freed. - */ + * @param[in] st LPCNetDecState*: State to be freed. + */ void lpcnet_decoder_destroy(LPCNetDecState *st); /** Decodes a packet of LPCNET_COMPRESSED_SIZE bytes (currently 8) into LPCNET_PACKET_SAMPLES samples (currently 640). - * @param [in] st LPCNetDecState*: Decoder state - * @param [in] buf const unsigned char *: Compressed packet - * @param [out] pcm opus_int16 *: Decoded audio - * @retval 0 Success - */ -int lpcnet_decode(LPCNetDecState *st, const unsigned char *buf, opus_int16 *pcm); + * @param [in] st LPCNetDecState*: Decoder state + * @param [in] buf const unsigned char *: Compressed packet + * @param [out] pcm oac_int16 *: Decoded audio + * @retval 0 Success + */ +int lpcnet_decode(LPCNetDecState *st, const unsigned char *buf, oac_int16 *pcm); /** Gets the size of an LPCNetEncState structure. - * @returns The size in bytes. - */ -int lpcnet_encoder_get_size(void); + * @returns The size in bytes. + */ +int oaci_lpcnet_encoder_get_size(void); /** Initializes a previously allocated encoder state - * The memory pointed to by st must be at least the size returned by lpcnet_encoder_get_size(). - * This is intended for applications which use their own allocator instead of malloc. - * @see lpcnet_encoder_create(),lpcnet_encoder_get_size() - * @param [in] st LPCNetEncState*: Encoder state - * @retval 0 Success - */ -int lpcnet_encoder_init(LPCNetEncState *st); + * The memory pointed to by st must be at least the size returned by oaci_lpcnet_encoder_get_size(). + * This is intended for applications which use their own allocator instead of malloc. + * @see oaci_lpcnet_encoder_create(),oaci_lpcnet_encoder_get_size() + * @param [in] st LPCNetEncState*: Encoder state + * @retval 0 Success + */ +int oaci_lpcnet_encoder_init(LPCNetEncState *st); -int lpcnet_encoder_load_model(LPCNetEncState *st, const void *data, int len); +int oaci_lpcnet_encoder_load_model(LPCNetEncState *st, const void *data, int len); /** Allocates and initializes an encoder state. - * @returns The newly created state - */ -LPCNetEncState *lpcnet_encoder_create(void); + * @returns The newly created state + */ +LPCNetEncState *oaci_lpcnet_encoder_create(void); -/** Frees an LPCNetEncState allocated by lpcnet_encoder_create(). - * @param[in] st LPCNetEncState*: State to be freed. - */ -void lpcnet_encoder_destroy(LPCNetEncState *st); +/** Frees an LPCNetEncState allocated by oaci_lpcnet_encoder_create(). + * @param[in] st LPCNetEncState*: State to be freed. + */ +void oaci_lpcnet_encoder_destroy(LPCNetEncState *st); /** Encodes LPCNET_PACKET_SAMPLES speech samples (currently 640) into a packet of LPCNET_COMPRESSED_SIZE bytes (currently 8). - * @param [in] st LPCNetDecState*: Encoder state - * @param [in] pcm opus_int16 *: Input speech to be encoded - * @param [out] buf const unsigned char *: Compressed packet - * @retval 0 Success - */ -int lpcnet_encode(LPCNetEncState *st, const opus_int16 *pcm, unsigned char *buf); + * @param [in] st LPCNetDecState*: Encoder state + * @param [in] pcm oac_int16 *: Input speech to be encoded + * @param [out] buf const unsigned char *: Compressed packet + * @retval 0 Success + */ +int lpcnet_encode(LPCNetEncState *st, const oac_int16 *pcm, unsigned char *buf); /** Compute features on LPCNET_FRAME_SIZE speech samples (currently 160) and output features for one 10-ms frame. - * @param [in] st LPCNetDecState*: Encoder state - * @param [in] pcm opus_int16 *: Input speech to be analyzed - * @param [out] features float[NB_TOTAL_FEATURES]: Four feature vectors - * @retval 0 Success - */ -int lpcnet_compute_single_frame_features(LPCNetEncState *st, const opus_int16 *pcm, float features[NB_TOTAL_FEATURES], int arch); + * @param [in] st LPCNetDecState*: Encoder state + * @param [in] pcm oac_int16 *: Input speech to be analyzed + * @param [out] features float[NB_TOTAL_FEATURES]: Four feature vectors + * @retval 0 Success + */ +int oaci_lpcnet_compute_single_frame_features(LPCNetEncState *st, const oac_int16 *pcm, float features[NB_TOTAL_FEATURES], + int arch); /** Compute features on LPCNET_FRAME_SIZE speech samples (currently 160) and output features for one 10-ms frame. - * @param [in] st LPCNetDecState*: Encoder state - * @param [in] pcm float *: Input speech to be analyzed - * @param [out] features float[NB_TOTAL_FEATURES]: Four feature vectors - * @retval 0 Success - */ -int lpcnet_compute_single_frame_features_float(LPCNetEncState *st, const float *pcm, float features[NB_TOTAL_FEATURES], int arch); + * @param [in] st LPCNetDecState*: Encoder state + * @param [in] pcm float *: Input speech to be analyzed + * @param [out] features float[NB_TOTAL_FEATURES]: Four feature vectors + * @retval 0 Success + */ +int oaci_lpcnet_compute_single_frame_features_float(LPCNetEncState *st, const float *pcm, float features[NB_TOTAL_FEATURES], + int arch); /** Gets the size of an LPCNetState structure. - * @returns The size in bytes. - */ + * @returns The size in bytes. + */ int lpcnet_get_size(void); /** Initializes a previously allocated synthesis state - * The memory pointed to by st must be at least the size returned by lpcnet_get_size(). - * This is intended for applications which use their own allocator instead of malloc. - * @see lpcnet_create(),lpcnet_get_size() - * @param [in] st LPCNetState*: Synthesis state - * @retval 0 Success - */ + * The memory pointed to by st must be at least the size returned by lpcnet_get_size(). + * This is intended for applications which use their own allocator instead of malloc. + * @see lpcnet_create(),lpcnet_get_size() + * @param [in] st LPCNetState*: Synthesis state + * @retval 0 Success + */ int lpcnet_init(LPCNetState *st); /** Allocates and initializes a synthesis state. - * @returns The newly created state - */ + * @returns The newly created state + */ LPCNetState *lpcnet_create(void); /** Frees an LPCNetState allocated by lpcnet_create(). - * @param[in] st LPCNetState*: State to be freed. - */ + * @param[in] st LPCNetState*: State to be freed. + */ void lpcnet_destroy(LPCNetState *st); /** Synthesizes speech from an LPCNet feature vector. - * @param [in] st LPCNetState*: Synthesis state - * @param [in] features const float *: Compressed packet - * @param [out] output opus_int16 **: Synthesized speech - * @param [in] N int: Number of samples to generate - * @retval 0 Success - */ -void lpcnet_synthesize(LPCNetState *st, const float *features, opus_int16 *output, int N); + * @param [in] st LPCNetState*: Synthesis state + * @param [in] features const float *: Compressed packet + * @param [out] output oac_int16 **: Synthesized speech + * @param [in] N int: Number of samples to generate + * @retval 0 Success + */ +void lpcnet_synthesize(LPCNetState *st, const float *features, oac_int16 *output, int N); -int lpcnet_plc_init(LPCNetPLCState *st); -void lpcnet_plc_reset(LPCNetPLCState *st); +int oaci_lpcnet_plc_init(LPCNetPLCState *st); +void oaci_lpcnet_plc_reset(LPCNetPLCState *st); -int lpcnet_plc_update(LPCNetPLCState *st, opus_int16 *pcm); +int oaci_lpcnet_plc_update(LPCNetPLCState *st, oac_int16 *pcm); -int lpcnet_plc_conceal(LPCNetPLCState *st, opus_int16 *pcm); +int oaci_lpcnet_plc_conceal(LPCNetPLCState *st, oac_int16 *pcm); -void lpcnet_plc_fec_add(LPCNetPLCState *st, const float *features); +void oaci_lpcnet_plc_fec_add(LPCNetPLCState *st, const float *features); -void lpcnet_plc_fec_clear(LPCNetPLCState *st); +void oaci_lpcnet_plc_fec_clear(LPCNetPLCState *st); int lpcnet_load_model(LPCNetState *st, const void *data, int len); -int lpcnet_plc_load_model(LPCNetPLCState *st, const void *data, int len); +int oaci_lpcnet_plc_load_model(LPCNetPLCState *st, const void *data, int len); #endif diff --git a/dnn/lpcnet_enc.c b/dnn/lpcnet_enc.c index 1acd1bf62..950c5b421 100644 --- a/dnn/lpcnet_enc.c +++ b/dnn/lpcnet_enc.c @@ -22,10 +22,10 @@ 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" +# include "config.h" #endif #include @@ -46,185 +46,190 @@ #include "mathops.h" -int lpcnet_encoder_get_size(void) { - return sizeof(LPCNetEncState); +int oaci_lpcnet_encoder_get_size(void) { + return sizeof(LPCNetEncState); } -int lpcnet_encoder_init(LPCNetEncState *st) { - memset(st, 0, sizeof(*st)); - pitchdnn_init(&st->pitchdnn); - return 0; +int oaci_lpcnet_encoder_init(LPCNetEncState *st) { + memset(st, 0, sizeof(*st)); + oaci_pitchdnn_init(&st->pitchdnn); + return 0; } -int lpcnet_encoder_load_model(LPCNetEncState *st, const void *data, int len) { - return pitchdnn_load_model(&st->pitchdnn, data, len); +int oaci_lpcnet_encoder_load_model(LPCNetEncState *st, const void *data, int len) { + return oaci_pitchdnn_load_model(&st->pitchdnn, data, len); } -LPCNetEncState *lpcnet_encoder_create(void) { - LPCNetEncState *st; - st = (LPCNetEncState*)opus_alloc(lpcnet_encoder_get_size()); - lpcnet_encoder_init(st); - return st; +LPCNetEncState *oaci_lpcnet_encoder_create(void) { + LPCNetEncState *st; + st = (LPCNetEncState*)oac_alloc(oaci_lpcnet_encoder_get_size()); + oaci_lpcnet_encoder_init(st); + return st; } -void lpcnet_encoder_destroy(LPCNetEncState *st) { - opus_free(st); +void oaci_lpcnet_encoder_destroy(LPCNetEncState *st) { + oac_free(st); } -static void frame_analysis(LPCNetEncState *st, kiss_fft_cpx *X, float *Ex, const float *in) { - float x[WINDOW_SIZE]; - OPUS_COPY(x, st->analysis_mem, OVERLAP_SIZE); - OPUS_COPY(&x[OVERLAP_SIZE], in, FRAME_SIZE); - OPUS_COPY(st->analysis_mem, &in[FRAME_SIZE-OVERLAP_SIZE], OVERLAP_SIZE); - apply_window(x); - forward_transform(X, x); - lpcn_compute_band_energy(Ex, X); +static void oaci_frame_analysis(LPCNetEncState *st, kiss_fft_cpx *X, float *Ex, const float *in) { + float x[WINDOW_SIZE]; + OAC_COPY(x, st->analysis_mem, OVERLAP_SIZE); + OAC_COPY(&x[OVERLAP_SIZE], in, FRAME_SIZE); + OAC_COPY(st->analysis_mem, &in[FRAME_SIZE - OVERLAP_SIZE], OVERLAP_SIZE); + oaci_apply_window(x); + oaci_forward_transform(X, x); + oaci_lpcn_compute_band_energy(Ex, X); } -static void biquad(float *y, float mem[2], const float *x, const float *b, const float *a, int N) { - int i; - float mem0, mem1; - mem0 = mem[0]; - mem1 = mem[1]; - for (i=0;ianalysis_mem[OVERLAP_SIZE-TRAINING_OFFSET], TRAINING_OFFSET); - frame_analysis(st, X, Ex, in); - st->if_features[0] = MAX16(-1.f, MIN16(1.f, (1.f/64)*(10.f*celt_log10(1e-15f + X[0].r*X[0].r)-6.f))); - for (i=1;iprev_if[i]); - norm_1 = 1.f/sqrt(1e-15f + prod.r*prod.r + prod.i*prod.i); - C_MULBYSCALAR(prod, norm_1); - st->if_features[3*i-2] = prod.r; - st->if_features[3*i-1] = prod.i; - st->if_features[3*i] = MAX16(-1.f, MIN16(1.f, (1.f/64)*(10.f*celt_log10(1e-15f + X[i].r*X[i].r + X[i].i*X[i].i)-6.f))); - } - OPUS_COPY(st->prev_if, X, PITCH_IF_MAX_FREQ); - /*for (i=0;i<88;i++) printf("%f ", st->if_features[i]);printf("\n");*/ - logMax = -2; - follow = -2; - for (i=0;ifeatures, Ly); - st->features[0] -= 4; - lpc_from_cepstrum(st->lpc, st->features); - for (i=0;ifeatures[NB_BANDS+2+i] = st->lpc[i]; - OPUS_MOVE(st->exc_buf, &st->exc_buf[FRAME_SIZE], PITCH_MAX_PERIOD); - OPUS_MOVE(st->lp_buf, &st->lp_buf[FRAME_SIZE], PITCH_MAX_PERIOD); - OPUS_COPY(&aligned_in[TRAINING_OFFSET], in, FRAME_SIZE-TRAINING_OFFSET); - OPUS_COPY(&x[0], st->pitch_mem, LPC_ORDER); - OPUS_COPY(&x[LPC_ORDER], aligned_in, FRAME_SIZE); - OPUS_COPY(st->pitch_mem, &aligned_in[FRAME_SIZE-LPC_ORDER], LPC_ORDER); - celt_fir(&x[LPC_ORDER], st->lpc, &st->lp_buf[PITCH_MAX_PERIOD], FRAME_SIZE, LPC_ORDER, arch); - for (i=0;iexc_buf[PITCH_MAX_PERIOD+i] = st->lp_buf[PITCH_MAX_PERIOD+i] + .7f*st->pitch_filt; - st->pitch_filt = st->lp_buf[PITCH_MAX_PERIOD+i]; - /*printf("%f\n", st->exc_buf[PITCH_MAX_PERIOD+i]);*/ - } - biquad(&st->lp_buf[PITCH_MAX_PERIOD], st->lp_mem, &st->lp_buf[PITCH_MAX_PERIOD], lp_b, lp_a, FRAME_SIZE); - { - double ener1; - float *buf = st->exc_buf; - celt_pitch_xcorr(&buf[PITCH_MAX_PERIOD], buf, xcorr, FRAME_SIZE, PITCH_MAX_PERIOD-PITCH_MIN_PERIOD, arch); - ener0 = celt_inner_prod(&buf[PITCH_MAX_PERIOD], &buf[PITCH_MAX_PERIOD], FRAME_SIZE, arch); - ener1 = celt_inner_prod(&buf[0], &buf[0], FRAME_SIZE, arch); - /*printf("%f\n", st->frame_weight[sub]);*/ - for (i=0;ixcorr_features[i] = 2*xcorr[i]; - ener_norm[i] = ener; - ener1 += buf[i+FRAME_SIZE]*(double)buf[i+FRAME_SIZE] - buf[i]*(double)buf[i]; - /*printf("%f ", st->xcorr_features[i]);*/ +#define celt_log10(x) (0.3010299957f*oaci_celt_log2(x)) + +void oaci_compute_frame_features(LPCNetEncState *st, const float *in, int arch) { + float aligned_in[FRAME_SIZE]; + int i; + float Ly[NB_BANDS]; + float follow, logMax; + kiss_fft_cpx X[FREQ_SIZE]; + float Ex[NB_BANDS]; + float xcorr[PITCH_MAX_PERIOD]; + float ener0; + float ener; + float x[FRAME_SIZE + LPC_ORDER]; + float frame_corr; + float xy, xx, yy; + int pitch; + float ener_norm[PITCH_MAX_PERIOD - PITCH_MIN_PERIOD]; + /* [b,a]=ellip(2, 2, 20, 1200/8000); */ + static const float lp_b[2] = {-0.84946f, 1.f}; + static const float lp_a[2] = {-1.54220f, 0.70781f}; + OAC_COPY(aligned_in, &st->analysis_mem[OVERLAP_SIZE - TRAINING_OFFSET], TRAINING_OFFSET); + oaci_frame_analysis(st, X, Ex, in); + st->if_features[0] = MAX16(-1.f, MIN16(1.f, (1.f/64)*(10.f*celt_log10(1e-15f + X[0].r*X[0].r) - 6.f))); + for (i = 1; i < PITCH_IF_MAX_FREQ; i++) { + kiss_fft_cpx prod; + float norm_1; + C_MULC(prod, X[i], st->prev_if[i]); + norm_1 = 1.f/sqrt(1e-15f + prod.r*prod.r + prod.i*prod.i); + C_MULBYSCALAR(prod, norm_1); + st->if_features[3*i - 2] = prod.r; + st->if_features[3*i - 1] = prod.i; + st->if_features[3*i] = MAX16(-1.f, + MIN16(1.f, (1.f/64)*(10.f*celt_log10(1e-15f + X[i].r*X[i].r + X[i].i*X[i].i) - 6.f))); + } + OAC_COPY(st->prev_if, X, PITCH_IF_MAX_FREQ); + /*for (i=0;i<88;i++) printf("%f ", st->if_features[i]);printf("\n");*/ + logMax = -2; + follow = -2; + for (i = 0; i < NB_BANDS; i++) { + Ly[i] = celt_log10(1e-2f + Ex[i]); + Ly[i] = MAX16(logMax - 8, MAX16(follow - 2.5f, Ly[i])); + logMax = MAX16(logMax, Ly[i]); + follow = MAX16(follow - 2.5f, Ly[i]); } - /* Split in a separate loop so the compiler can vectorize it */ - for (i=0;ixcorr_features[i] /= ener_norm[i]; + oaci_dct(st->features, Ly); + st->features[0] -= 4; + oaci_lpc_from_cepstrum(st->lpc, st->features); + for (i = 0; i < LPC_ORDER; i++) st->features[NB_BANDS + 2 + i] = st->lpc[i]; + OAC_MOVE(st->exc_buf, &st->exc_buf[FRAME_SIZE], PITCH_MAX_PERIOD); + OAC_MOVE(st->lp_buf, &st->lp_buf[FRAME_SIZE], PITCH_MAX_PERIOD); + OAC_COPY(&aligned_in[TRAINING_OFFSET], in, FRAME_SIZE - TRAINING_OFFSET); + OAC_COPY(&x[0], st->pitch_mem, LPC_ORDER); + OAC_COPY(&x[LPC_ORDER], aligned_in, FRAME_SIZE); + OAC_COPY(st->pitch_mem, &aligned_in[FRAME_SIZE - LPC_ORDER], LPC_ORDER); + oaci_celt_fir(&x[LPC_ORDER], st->lpc, &st->lp_buf[PITCH_MAX_PERIOD], FRAME_SIZE, LPC_ORDER, arch); + for (i = 0; i < FRAME_SIZE; i++) { + st->exc_buf[PITCH_MAX_PERIOD + i] = st->lp_buf[PITCH_MAX_PERIOD + i] + .7f*st->pitch_filt; + st->pitch_filt = st->lp_buf[PITCH_MAX_PERIOD + i]; + /*printf("%f\n", st->exc_buf[PITCH_MAX_PERIOD+i]);*/ } - /*printf("\n");*/ - } - st->dnn_pitch = compute_pitchdnn(&st->pitchdnn, st->if_features, st->xcorr_features, arch); - pitch = (int)floor(.5+256./pow(2.f,((1./60.)*((st->dnn_pitch+1.5)*60)))); - xx = celt_inner_prod(&st->lp_buf[PITCH_MAX_PERIOD], &st->lp_buf[PITCH_MAX_PERIOD], FRAME_SIZE, arch); - yy = celt_inner_prod(&st->lp_buf[PITCH_MAX_PERIOD-pitch], &st->lp_buf[PITCH_MAX_PERIOD-pitch], FRAME_SIZE, arch); - xy = celt_inner_prod(&st->lp_buf[PITCH_MAX_PERIOD], &st->lp_buf[PITCH_MAX_PERIOD-pitch], FRAME_SIZE, arch); - /*printf("%f %f\n", frame_corr, xy/sqrt(1e-15+xx*yy));*/ - frame_corr = xy/sqrt(1+xx*yy); - frame_corr = log(1.f+exp(5.f*frame_corr))/log(1+exp(5.f)); - st->features[NB_BANDS] = st->dnn_pitch; - st->features[NB_BANDS + 1] = frame_corr-.5f; + oaci_biquad(&st->lp_buf[PITCH_MAX_PERIOD], st->lp_mem, &st->lp_buf[PITCH_MAX_PERIOD], lp_b, lp_a, FRAME_SIZE); + { + double ener1; + float *buf = st->exc_buf; + oaci_celt_pitch_xcorr(&buf[PITCH_MAX_PERIOD], buf, xcorr, FRAME_SIZE, PITCH_MAX_PERIOD - PITCH_MIN_PERIOD, arch); + ener0 = oaci_celt_inner_prod(&buf[PITCH_MAX_PERIOD], &buf[PITCH_MAX_PERIOD], FRAME_SIZE, arch); + ener1 = oaci_celt_inner_prod(&buf[0], &buf[0], FRAME_SIZE, arch); + /*printf("%f\n", st->frame_weight[sub]);*/ + for (i = 0; i < PITCH_MAX_PERIOD - PITCH_MIN_PERIOD; i++) { + ener = 1 + ener0 + ener1; + st->xcorr_features[i] = 2*xcorr[i]; + ener_norm[i] = ener; + ener1 += buf[i + FRAME_SIZE]*(double)buf[i + FRAME_SIZE] - buf[i]*(double)buf[i]; + /*printf("%f ", st->xcorr_features[i]);*/ + } + /* Split in a separate loop so the compiler can vectorize it */ + for (i = 0; i < PITCH_MAX_PERIOD - PITCH_MIN_PERIOD; i++) { + st->xcorr_features[i] /= ener_norm[i]; + } + /*printf("\n");*/ + } + st->dnn_pitch = oaci_compute_pitchdnn(&st->pitchdnn, st->if_features, st->xcorr_features, arch); + pitch = (int)floor(.5 + 256./pow(2.f, ((1./60.)*((st->dnn_pitch + 1.5)*60)))); + xx = oaci_celt_inner_prod(&st->lp_buf[PITCH_MAX_PERIOD], &st->lp_buf[PITCH_MAX_PERIOD], FRAME_SIZE, arch); + yy = oaci_celt_inner_prod(&st->lp_buf[PITCH_MAX_PERIOD - pitch], &st->lp_buf[PITCH_MAX_PERIOD - pitch], FRAME_SIZE, + arch); + xy = oaci_celt_inner_prod(&st->lp_buf[PITCH_MAX_PERIOD], &st->lp_buf[PITCH_MAX_PERIOD - pitch], FRAME_SIZE, arch); + /*printf("%f %f\n", frame_corr, xy/sqrt(1e-15+xx*yy));*/ + frame_corr = xy/sqrt(1 + xx*yy); + frame_corr = log(1.f + exp(5.f*frame_corr))/log(1 + exp(5.f)); + st->features[NB_BANDS] = st->dnn_pitch; + st->features[NB_BANDS + 1] = frame_corr - .5f; } -void preemphasis(float *y, float *mem, const float *x, float coef, int N) { - int i; - for (i=0;imem_preemph, x, PREEMPHASIS, FRAME_SIZE); - compute_frame_features(st, x, arch); - OPUS_COPY(features, &st->features[0], NB_TOTAL_FEATURES); - return 0; +static int oaci_lpcnet_compute_single_frame_features_impl(LPCNetEncState *st, float *x, float features[NB_TOTAL_FEATURES], + int arch) { + oaci_preemphasis(x, &st->mem_preemph, x, PREEMPHASIS, FRAME_SIZE); + oaci_compute_frame_features(st, x, arch); + OAC_COPY(features, &st->features[0], NB_TOTAL_FEATURES); + return 0; } -int lpcnet_compute_single_frame_features(LPCNetEncState *st, const opus_int16 *pcm, float features[NB_TOTAL_FEATURES], int arch) { - int i; - float x[FRAME_SIZE]; - for (i=0;iLPCNET_PLC_RESET_START, - sizeof(LPCNetPLCState)- - ((char*)&st->LPCNET_PLC_RESET_START - (char*)st)); - lpcnet_encoder_init(&st->enc); - OPUS_CLEAR(st->pcm, PLC_BUF_SIZE); - st->blend = 0; - st->loss_count = 0; - st->analysis_gap = 1; - st->analysis_pos = PLC_BUF_SIZE; - st->predict_pos = PLC_BUF_SIZE; +void oaci_lpcnet_plc_reset(LPCNetPLCState *st) { + OAC_CLEAR((char*)&st->LPCNET_PLC_RESET_START, + sizeof(LPCNetPLCState) + - ((char*)&st->LPCNET_PLC_RESET_START - (char*)st)); + oaci_lpcnet_encoder_init(&st->enc); + OAC_CLEAR(st->pcm, PLC_BUF_SIZE); + st->blend = 0; + st->loss_count = 0; + st->analysis_gap = 1; + st->analysis_pos = PLC_BUF_SIZE; + st->predict_pos = PLC_BUF_SIZE; } -int lpcnet_plc_init(LPCNetPLCState *st) { - int ret; - st->arch = opus_select_arch(); - fargan_init(&st->fargan); - lpcnet_encoder_init(&st->enc); - st->loaded = 0; +int oaci_lpcnet_plc_init(LPCNetPLCState *st) { + int ret; + st->arch = oac_select_arch(); + oaci_fargan_init(&st->fargan); + oaci_lpcnet_encoder_init(&st->enc); + st->loaded = 0; #ifndef USE_WEIGHTS_FILE - ret = init_plcmodel(&st->model, plcmodel_arrays); - if (ret == 0) st->loaded = 1; + ret = oaci_init_plcmodel(&st->model, oaci_plcmodel_arrays); + if (ret == 0) st->loaded = 1; #else - ret = 0; + ret = 0; #endif - celt_assert(ret == 0); - lpcnet_plc_reset(st); - return ret; + celt_assert(ret == 0); + oaci_lpcnet_plc_reset(st); + return ret; } -int lpcnet_plc_load_model(LPCNetPLCState *st, const void *data, int len) { - WeightArray *list; - int ret; - parse_weights(&list, data, len); - ret = init_plcmodel(&st->model, list); - opus_free(list); - if (ret == 0) { - ret = lpcnet_encoder_load_model(&st->enc, data, len); - } - if (ret == 0) { - ret = fargan_load_model(&st->fargan, data, len); - } - if (ret == 0) st->loaded = 1; - return ret; +int oaci_lpcnet_plc_load_model(LPCNetPLCState *st, const void *data, int len) { + WeightArray *list; + int ret; + oaci_parse_weights(&list, data, len); + ret = oaci_init_plcmodel(&st->model, list); + oac_free(list); + if (ret == 0) { + ret = oaci_lpcnet_encoder_load_model(&st->enc, data, len); + } + if (ret == 0) { + ret = oaci_fargan_load_model(&st->fargan, data, len); + } + if (ret == 0) st->loaded = 1; + return ret; } -void lpcnet_plc_fec_add(LPCNetPLCState *st, const float *features) { - if (features == NULL) { - st->fec_skip++; - return; - } - celt_assert(st->fec_fill_pos < PLC_MAX_FEC); - OPUS_COPY(&st->fec[st->fec_fill_pos][0], features, NB_FEATURES); - st->fec_fill_pos++; +void oaci_lpcnet_plc_fec_add(LPCNetPLCState *st, const float *features) { + if (features == NULL) { + st->fec_skip++; + return; + } + celt_assert(st->fec_fill_pos < PLC_MAX_FEC); + OAC_COPY(&st->fec[st->fec_fill_pos][0], features, NB_FEATURES); + st->fec_fill_pos++; } -void lpcnet_plc_fec_clear(LPCNetPLCState *st) { - st->fec_read_pos = st->fec_fill_pos = st->fec_skip = 0; +void oaci_lpcnet_plc_fec_clear(LPCNetPLCState *st) { + st->fec_read_pos = st->fec_fill_pos = st->fec_skip = 0; } -static void compute_plc_pred(LPCNetPLCState *st, float *out, const float *in) { - float tmp[PLC_DENSE_IN_OUT_SIZE]; - PLCModel *model = &st->model; - PLCNetState *net = &st->plc_net; - celt_assert(st->loaded); - compute_generic_dense(&model->plc_dense_in, tmp, in, ACTIVATION_TANH, st->arch); - compute_generic_gru(&model->plc_gru1_input, &model->plc_gru1_recurrent, net->gru1_state, tmp, st->arch); - compute_generic_gru(&model->plc_gru2_input, &model->plc_gru2_recurrent, net->gru2_state, net->gru1_state, st->arch); - compute_generic_dense(&model->plc_dense_out, out, net->gru2_state, ACTIVATION_LINEAR, st->arch); +static void oaci_compute_plc_pred(LPCNetPLCState *st, float *out, const float *in) { + float tmp[PLC_DENSE_IN_OUT_SIZE]; + PLCModel *model = &st->model; + PLCNetState *net = &st->plc_net; + celt_assert(st->loaded); + oaci_compute_generic_dense(&model->plc_dense_in, tmp, in, ACTIVATION_TANH, st->arch); + oaci_compute_generic_gru(&model->plc_gru1_input, &model->plc_gru1_recurrent, net->gru1_state, tmp, st->arch); + oaci_compute_generic_gru(&model->plc_gru2_input, &model->plc_gru2_recurrent, net->gru2_state, net->gru1_state, st->arch); + oaci_compute_generic_dense(&model->plc_dense_out, out, net->gru2_state, ACTIVATION_LINEAR, st->arch); } -static int get_fec_or_pred(LPCNetPLCState *st, float *out) { - if (st->fec_read_pos != st->fec_fill_pos && st->fec_skip==0) { - float plc_features[2*NB_BANDS+NB_FEATURES+1] = {0}; - float discard[NB_FEATURES]; - OPUS_COPY(out, &st->fec[st->fec_read_pos][0], NB_FEATURES); - st->fec_read_pos++; - /* Update PLC state using FEC, so without Burg features. */ - OPUS_COPY(&plc_features[2*NB_BANDS], out, NB_FEATURES); - plc_features[2*NB_BANDS+NB_FEATURES] = -1; - compute_plc_pred(st, discard, plc_features); - return 1; - } else { - float zeros[2*NB_BANDS+NB_FEATURES+1] = {0}; - compute_plc_pred(st, out, zeros); - if (st->fec_skip > 0) st->fec_skip--; - return 0; - } +static int oaci_get_fec_or_pred(LPCNetPLCState *st, float *out) { + if (st->fec_read_pos != st->fec_fill_pos && st->fec_skip == 0) { + float plc_features[2*NB_BANDS + NB_FEATURES + 1] = {0}; + float discard[NB_FEATURES]; + OAC_COPY(out, &st->fec[st->fec_read_pos][0], NB_FEATURES); + st->fec_read_pos++; + /* Update PLC state using FEC, so without Burg features. */ + OAC_COPY(&plc_features[2*NB_BANDS], out, NB_FEATURES); + plc_features[2*NB_BANDS + NB_FEATURES] = -1; + oaci_compute_plc_pred(st, discard, plc_features); + return 1; + } else { + float zeros[2*NB_BANDS + NB_FEATURES + 1] = {0}; + oaci_compute_plc_pred(st, out, zeros); + if (st->fec_skip > 0) st->fec_skip--; + return 0; + } } -static void queue_features(LPCNetPLCState *st, const float *features) { - OPUS_MOVE(&st->cont_features[0], &st->cont_features[NB_FEATURES], (CONT_VECTORS-1)*NB_FEATURES); - OPUS_COPY(&st->cont_features[(CONT_VECTORS-1)*NB_FEATURES], features, NB_FEATURES); +static void oaci_queue_features(LPCNetPLCState *st, const float *features) { + OAC_MOVE(&st->cont_features[0], &st->cont_features[NB_FEATURES], (CONT_VECTORS - 1)*NB_FEATURES); + OAC_COPY(&st->cont_features[(CONT_VECTORS - 1)*NB_FEATURES], features, NB_FEATURES); } -/* In this causal version of the code, the DNN model implemented by compute_plc_pred() +/* In this causal version of the code, the DNN model implemented by oaci_compute_plc_pred() needs to generate two feature vectors to conceal the first lost packet.*/ -int lpcnet_plc_update(LPCNetPLCState *st, opus_int16 *pcm) { - int i; - if (st->analysis_pos - FRAME_SIZE >= 0) st->analysis_pos -= FRAME_SIZE; - else st->analysis_gap = 1; - if (st->predict_pos - FRAME_SIZE >= 0) st->predict_pos -= FRAME_SIZE; - OPUS_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE-FRAME_SIZE); - for (i=0;ipcm[PLC_BUF_SIZE-FRAME_SIZE+i] = (1.f/32768.f)*pcm[i]; - st->loss_count = 0; - st->blend = 0; - return 0; +int oaci_lpcnet_plc_update(LPCNetPLCState *st, oac_int16 *pcm) { + int i; + if (st->analysis_pos - FRAME_SIZE >= 0) st->analysis_pos -= FRAME_SIZE; + else st->analysis_gap = 1; + if (st->predict_pos - FRAME_SIZE >= 0) st->predict_pos -= FRAME_SIZE; + OAC_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE - FRAME_SIZE); + for (i = 0; i < FRAME_SIZE; i++) st->pcm[PLC_BUF_SIZE - FRAME_SIZE + i] = (1.f/32768.f)*pcm[i]; + st->loss_count = 0; + st->blend = 0; + return 0; } static const float att_table[10] = {0, 0, -.2, -.2, -.4, -.4, -.8, -.8, -1.6, -1.6}; -int lpcnet_plc_conceal(LPCNetPLCState *st, opus_int16 *pcm) { - int i; - celt_assert(st->loaded); - if (st->blend == 0) { - int count = 0; - st->plc_net = st->plc_bak[0]; - while (st->analysis_pos + FRAME_SIZE <= PLC_BUF_SIZE) { - float x[FRAME_SIZE]; - float plc_features[2*NB_BANDS+NB_FEATURES+1]; - celt_assert(st->analysis_pos >= 0); - for (i=0;ipcm[st->analysis_pos+i]; - burg_cepstral_analysis(plc_features, x); - lpcnet_compute_single_frame_features_float(&st->enc, x, st->features, st->arch); - if ((!st->analysis_gap || count>0) && st->analysis_pos >= st->predict_pos) { - queue_features(st, st->features); - OPUS_COPY(&plc_features[2*NB_BANDS], st->features, NB_FEATURES); - plc_features[2*NB_BANDS+NB_FEATURES] = 1; +int oaci_lpcnet_plc_conceal(LPCNetPLCState *st, oac_int16 *pcm) { + int i; + celt_assert(st->loaded); + if (st->blend == 0) { + int count = 0; + st->plc_net = st->plc_bak[0]; + while (st->analysis_pos + FRAME_SIZE <= PLC_BUF_SIZE) { + float x[FRAME_SIZE]; + float plc_features[2*NB_BANDS + NB_FEATURES + 1]; + celt_assert(st->analysis_pos >= 0); + for (i = 0; i < FRAME_SIZE; i++) x[i] = 32768.f*st->pcm[st->analysis_pos + i]; + oaci_burg_cepstral_analysis(plc_features, x); + oaci_lpcnet_compute_single_frame_features_float(&st->enc, x, st->features, st->arch); + if ((!st->analysis_gap || count > 0) && st->analysis_pos >= st->predict_pos) { + oaci_queue_features(st, st->features); + OAC_COPY(&plc_features[2*NB_BANDS], st->features, NB_FEATURES); + plc_features[2*NB_BANDS + NB_FEATURES] = 1; + st->plc_bak[0] = st->plc_bak[1]; + st->plc_bak[1] = st->plc_net; + oaci_compute_plc_pred(st, st->features, plc_features); + } + st->analysis_pos += FRAME_SIZE; + count++; + } st->plc_bak[0] = st->plc_bak[1]; st->plc_bak[1] = st->plc_net; - compute_plc_pred(st, st->features, plc_features); - } - st->analysis_pos += FRAME_SIZE; - count++; + oaci_get_fec_or_pred(st, st->features); + oaci_queue_features(st, st->features); + st->plc_bak[0] = st->plc_bak[1]; + st->plc_bak[1] = st->plc_net; + oaci_get_fec_or_pred(st, st->features); + oaci_queue_features(st, st->features); + oaci_fargan_cont(&st->fargan, &st->pcm[PLC_BUF_SIZE - FARGAN_CONT_SAMPLES], st->cont_features); + st->analysis_gap = 0; } st->plc_bak[0] = st->plc_bak[1]; st->plc_bak[1] = st->plc_net; - get_fec_or_pred(st, st->features); - queue_features(st, st->features); - st->plc_bak[0] = st->plc_bak[1]; - st->plc_bak[1] = st->plc_net; - get_fec_or_pred(st, st->features); - queue_features(st, st->features); - fargan_cont(&st->fargan, &st->pcm[PLC_BUF_SIZE-FARGAN_CONT_SAMPLES], st->cont_features); - st->analysis_gap = 0; - } - st->plc_bak[0] = st->plc_bak[1]; - st->plc_bak[1] = st->plc_net; - if (get_fec_or_pred(st, st->features)) st->loss_count = 0; - else st->loss_count++; - if (st->loss_count >= 10) st->features[0] = MAX16(-15, st->features[0]+att_table[9] - 2*(st->loss_count-9)); - else st->features[0] = MAX16(-15, st->features[0]+att_table[st->loss_count]); - fargan_synthesize_int(&st->fargan, pcm, &st->features[0]); - queue_features(st, st->features); - if (st->analysis_pos - FRAME_SIZE >= 0) st->analysis_pos -= FRAME_SIZE; - else st->analysis_gap = 1; - st->predict_pos = PLC_BUF_SIZE; - OPUS_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE-FRAME_SIZE); - for (i=0;ipcm[PLC_BUF_SIZE-FRAME_SIZE+i] = (1.f/32768.f)*pcm[i]; - st->blend = 1; - return 0; + if (oaci_get_fec_or_pred(st, st->features)) st->loss_count = 0; + else st->loss_count++; + if (st->loss_count >= 10) st->features[0] = MAX16(-15, st->features[0] + att_table[9] - 2*(st->loss_count - 9)); + else st->features[0] = MAX16(-15, st->features[0] + att_table[st->loss_count]); + oaci_fargan_synthesize_int(&st->fargan, pcm, &st->features[0]); + oaci_queue_features(st, st->features); + if (st->analysis_pos - FRAME_SIZE >= 0) st->analysis_pos -= FRAME_SIZE; + else st->analysis_gap = 1; + st->predict_pos = PLC_BUF_SIZE; + OAC_MOVE(st->pcm, &st->pcm[FRAME_SIZE], PLC_BUF_SIZE - FRAME_SIZE); + for (i = 0; i < FRAME_SIZE; i++) st->pcm[PLC_BUF_SIZE - FRAME_SIZE + i] = (1.f/32768.f)*pcm[i]; + st->blend = 1; + return 0; } diff --git a/dnn/lpcnet_private.h b/dnn/lpcnet_private.h index 69ba12bd0..ec7963d7d 100644 --- a/dnn/lpcnet_private.h +++ b/dnn/lpcnet_private.h @@ -10,7 +10,7 @@ #define PITCH_FRAME_SIZE 320 -#define PITCH_BUF_SIZE (PITCH_MAX_PERIOD+PITCH_FRAME_SIZE) +#define PITCH_BUF_SIZE (PITCH_MAX_PERIOD + PITCH_FRAME_SIZE) #define PLC_MAX_FEC 104 #define MAX_FEATURE_BUFFER_SIZE 4 @@ -22,69 +22,71 @@ #define FEATURES_DELAY 1 -struct LPCNetEncState{ - PitchDNNState pitchdnn; - float analysis_mem[OVERLAP_SIZE]; - float mem_preemph; - kiss_fft_cpx prev_if[PITCH_IF_MAX_FREQ]; - float if_features[PITCH_IF_FEATURES]; - float xcorr_features[PITCH_MAX_PERIOD - PITCH_MIN_PERIOD]; - float dnn_pitch; - float pitch_mem[LPC_ORDER]; - float pitch_filt; - float exc_buf[PITCH_BUF_SIZE]; - float lp_buf[PITCH_BUF_SIZE]; - float lp_mem[4]; - float lpc[LPC_ORDER]; - float features[NB_TOTAL_FEATURES]; - float sig_mem[LPC_ORDER]; - float burg_cepstrum[2*NB_BANDS]; +struct LPCNetEncState { + PitchDNNState pitchdnn; + float analysis_mem[OVERLAP_SIZE]; + float mem_preemph; + kiss_fft_cpx prev_if[PITCH_IF_MAX_FREQ]; + float if_features[PITCH_IF_FEATURES]; + float xcorr_features[PITCH_MAX_PERIOD - PITCH_MIN_PERIOD]; + float dnn_pitch; + float pitch_mem[LPC_ORDER]; + float pitch_filt; + float exc_buf[PITCH_BUF_SIZE]; + float lp_buf[PITCH_BUF_SIZE]; + float lp_mem[4]; + float lpc[LPC_ORDER]; + float features[NB_TOTAL_FEATURES]; + float sig_mem[LPC_ORDER]; + float burg_cepstrum[2*NB_BANDS]; }; typedef struct { - float gru1_state[PLC_GRU1_STATE_SIZE]; - float gru2_state[PLC_GRU2_STATE_SIZE]; + float gru1_state[PLC_GRU1_STATE_SIZE]; + float gru2_state[PLC_GRU2_STATE_SIZE]; } PLCNetState; -#define PLC_BUF_SIZE ((CONT_VECTORS+10)*FRAME_SIZE) +#define PLC_BUF_SIZE ((CONT_VECTORS + 10)*FRAME_SIZE) struct LPCNetPLCState { - PLCModel model; - FARGANState fargan; - LPCNetEncState enc; - int loaded; - int arch; + PLCModel model; + FARGANState fargan; + LPCNetEncState enc; + int loaded; + int arch; #define LPCNET_PLC_RESET_START fec - float fec[PLC_MAX_FEC][NB_FEATURES]; - int analysis_gap; - int fec_read_pos; - int fec_fill_pos; - int fec_skip; - int analysis_pos; - int predict_pos; - float pcm[PLC_BUF_SIZE]; - int blend; - float features[NB_TOTAL_FEATURES]; - float cont_features[CONT_VECTORS*NB_FEATURES]; - int loss_count; - PLCNetState plc_net; - PLCNetState plc_bak[2]; + float fec[PLC_MAX_FEC][NB_FEATURES]; + int analysis_gap; + int fec_read_pos; + int fec_fill_pos; + int fec_skip; + int analysis_pos; + int predict_pos; + float pcm[PLC_BUF_SIZE]; + int blend; + float features[NB_TOTAL_FEATURES]; + float cont_features[CONT_VECTORS*NB_FEATURES]; + int loss_count; + PLCNetState plc_net; + PLCNetState plc_bak[2]; }; -void preemphasis(float *y, float *mem, const float *x, float coef, int N); +void oaci_preemphasis(float *y, float *mem, const float *x, float coef, int N); -void compute_frame_features(LPCNetEncState *st, const float *in, int arch); +void oaci_compute_frame_features(LPCNetEncState *st, const float *in, int arch); void lpcnet_reset_signal(LPCNetState *lpcnet); -void run_frame_network(LPCNetState *lpcnet, float *gru_a_condition, float *gru_b_condition, float *lpc, const float *features); +void run_frame_network(LPCNetState *lpcnet, float *gru_a_condition, float *gru_b_condition, float *lpc, + const float *features); void run_frame_network_deferred(LPCNetState *lpcnet, const float *features); void run_frame_network_flush(LPCNetState *lpcnet); -void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, opus_int16 *output, int N, int preload); -void lpcnet_synthesize_impl(LPCNetState *lpcnet, const float *features, opus_int16 *output, int N, int preload); -void lpcnet_synthesize_blend_impl(LPCNetState *lpcnet, const opus_int16 *pcm_in, opus_int16 *output, int N); +void lpcnet_synthesize_tail_impl(LPCNetState *lpcnet, oac_int16 *output, int N, int preload); +void lpcnet_synthesize_impl(LPCNetState *lpcnet, const float *features, oac_int16 *output, int N, int preload); +void lpcnet_synthesize_blend_impl(LPCNetState *lpcnet, const oac_int16 *pcm_in, oac_int16 *output, int N); -void run_frame_network(LPCNetState *lpcnet, float *gru_a_condition, float *gru_b_condition, float *lpc, const float *features); +void run_frame_network(LPCNetState *lpcnet, float *gru_a_condition, float *gru_b_condition, float *lpc, + const float *features); #endif diff --git a/dnn/lpcnet_tables.c b/dnn/lpcnet_tables.c index 71ab37834..1cf0fb9cc 100644 --- a/dnn/lpcnet_tables.c +++ b/dnn/lpcnet_tables.c @@ -1,308 +1,310 @@ /* The contents of this file was automatically generated by dump_lpcnet_tables.c*/ #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif #include "kiss_fft.h" #include "freq.h" static const arch_fft_state arch_fft = {0, NULL}; -static const opus_int16 fft_bitrev[320] = { -0, 64, 128, 192, 256, 16, 80, 144, 208, 272, 32, 96, 160, 224, 288, -48, 112, 176, 240, 304, 4, 68, 132, 196, 260, 20, 84, 148, 212, 276, -36, 100, 164, 228, 292, 52, 116, 180, 244, 308, 8, 72, 136, 200, 264, -24, 88, 152, 216, 280, 40, 104, 168, 232, 296, 56, 120, 184, 248, 312, -12, 76, 140, 204, 268, 28, 92, 156, 220, 284, 44, 108, 172, 236, 300, -60, 124, 188, 252, 316, 1, 65, 129, 193, 257, 17, 81, 145, 209, 273, -33, 97, 161, 225, 289, 49, 113, 177, 241, 305, 5, 69, 133, 197, 261, -21, 85, 149, 213, 277, 37, 101, 165, 229, 293, 53, 117, 181, 245, 309, -9, 73, 137, 201, 265, 25, 89, 153, 217, 281, 41, 105, 169, 233, 297, -57, 121, 185, 249, 313, 13, 77, 141, 205, 269, 29, 93, 157, 221, 285, -45, 109, 173, 237, 301, 61, 125, 189, 253, 317, 2, 66, 130, 194, 258, -18, 82, 146, 210, 274, 34, 98, 162, 226, 290, 50, 114, 178, 242, 306, -6, 70, 134, 198, 262, 22, 86, 150, 214, 278, 38, 102, 166, 230, 294, -54, 118, 182, 246, 310, 10, 74, 138, 202, 266, 26, 90, 154, 218, 282, -42, 106, 170, 234, 298, 58, 122, 186, 250, 314, 14, 78, 142, 206, 270, -30, 94, 158, 222, 286, 46, 110, 174, 238, 302, 62, 126, 190, 254, 318, -3, 67, 131, 195, 259, 19, 83, 147, 211, 275, 35, 99, 163, 227, 291, -51, 115, 179, 243, 307, 7, 71, 135, 199, 263, 23, 87, 151, 215, 279, -39, 103, 167, 231, 295, 55, 119, 183, 247, 311, 11, 75, 139, 203, 267, -27, 91, 155, 219, 283, 43, 107, 171, 235, 299, 59, 123, 187, 251, 315, -15, 79, 143, 207, 271, 31, 95, 159, 223, 287, 47, 111, 175, 239, 303, -63, 127, 191, 255, 319, }; +static const oac_int16 fft_bitrev[320] = { + 0, 64, 128, 192, 256, 16, 80, 144, 208, 272, 32, 96, 160, 224, 288, + 48, 112, 176, 240, 304, 4, 68, 132, 196, 260, 20, 84, 148, 212, 276, + 36, 100, 164, 228, 292, 52, 116, 180, 244, 308, 8, 72, 136, 200, 264, + 24, 88, 152, 216, 280, 40, 104, 168, 232, 296, 56, 120, 184, 248, 312, + 12, 76, 140, 204, 268, 28, 92, 156, 220, 284, 44, 108, 172, 236, 300, + 60, 124, 188, 252, 316, 1, 65, 129, 193, 257, 17, 81, 145, 209, 273, + 33, 97, 161, 225, 289, 49, 113, 177, 241, 305, 5, 69, 133, 197, 261, + 21, 85, 149, 213, 277, 37, 101, 165, 229, 293, 53, 117, 181, 245, 309, + 9, 73, 137, 201, 265, 25, 89, 153, 217, 281, 41, 105, 169, 233, 297, + 57, 121, 185, 249, 313, 13, 77, 141, 205, 269, 29, 93, 157, 221, 285, + 45, 109, 173, 237, 301, 61, 125, 189, 253, 317, 2, 66, 130, 194, 258, + 18, 82, 146, 210, 274, 34, 98, 162, 226, 290, 50, 114, 178, 242, 306, + 6, 70, 134, 198, 262, 22, 86, 150, 214, 278, 38, 102, 166, 230, 294, + 54, 118, 182, 246, 310, 10, 74, 138, 202, 266, 26, 90, 154, 218, 282, + 42, 106, 170, 234, 298, 58, 122, 186, 250, 314, 14, 78, 142, 206, 270, + 30, 94, 158, 222, 286, 46, 110, 174, 238, 302, 62, 126, 190, 254, 318, + 3, 67, 131, 195, 259, 19, 83, 147, 211, 275, 35, 99, 163, 227, 291, + 51, 115, 179, 243, 307, 7, 71, 135, 199, 263, 23, 87, 151, 215, 279, + 39, 103, 167, 231, 295, 55, 119, 183, 247, 311, 11, 75, 139, 203, 267, + 27, 91, 155, 219, 283, 43, 107, 171, 235, 299, 59, 123, 187, 251, 315, + 15, 79, 143, 207, 271, 31, 95, 159, 223, 287, 47, 111, 175, 239, 303, + 63, 127, 191, 255, 319, +}; static const kiss_twiddle_cpx fft_twiddles[320] = { -{1.00000000f, -0.00000000f}, {0.999807239f, -0.0196336918f}, -{0.999229014f, -0.0392598175f}, {0.998265624f, -0.0588708036f}, -{0.996917307f, -0.0784590989f}, {0.995184720f, -0.0980171412f}, -{0.993068457f, -0.117537394f}, {0.990569353f, -0.137012348f}, -{0.987688363f, -0.156434461f}, {0.984426558f, -0.175796285f}, -{0.980785251f, -0.195090324f}, {0.976765871f, -0.214309156f}, -{0.972369909f, -0.233445361f}, {0.967599094f, -0.252491564f}, -{0.962455213f, -0.271440446f}, {0.956940353f, -0.290284663f}, -{0.951056540f, -0.309017003f}, {0.944806039f, -0.327630192f}, -{0.938191354f, -0.346117049f}, {0.931214929f, -0.364470512f}, -{0.923879504f, -0.382683426f}, {0.916187942f, -0.400748819f}, -{0.908143163f, -0.418659747f}, {0.899748266f, -0.436409235f}, -{0.891006529f, -0.453990489f}, {0.881921291f, -0.471396744f}, -{0.872496009f, -0.488621235f}, {0.862734377f, -0.505657375f}, -{0.852640152f, -0.522498548f}, {0.842217207f, -0.539138317f}, -{0.831469595f, -0.555570245f}, {0.820401430f, -0.571787953f}, -{0.809017003f, -0.587785244f}, {0.797320664f, -0.603555918f}, -{0.785316944f, -0.619093955f}, {0.773010433f, -0.634393275f}, -{0.760405958f, -0.649448037f}, {0.747508347f, -0.664252460f}, -{0.734322488f, -0.678800762f}, {0.720853567f, -0.693087339f}, -{0.707106769f, -0.707106769f}, {0.693087339f, -0.720853567f}, -{0.678800762f, -0.734322488f}, {0.664252460f, -0.747508347f}, -{0.649448037f, -0.760405958f}, {0.634393275f, -0.773010433f}, -{0.619093955f, -0.785316944f}, {0.603555918f, -0.797320664f}, -{0.587785244f, -0.809017003f}, {0.571787953f, -0.820401430f}, -{0.555570245f, -0.831469595f}, {0.539138317f, -0.842217207f}, -{0.522498548f, -0.852640152f}, {0.505657375f, -0.862734377f}, -{0.488621235f, -0.872496009f}, {0.471396744f, -0.881921291f}, -{0.453990489f, -0.891006529f}, {0.436409235f, -0.899748266f}, -{0.418659747f, -0.908143163f}, {0.400748819f, -0.916187942f}, -{0.382683426f, -0.923879504f}, {0.364470512f, -0.931214929f}, -{0.346117049f, -0.938191354f}, {0.327630192f, -0.944806039f}, -{0.309017003f, -0.951056540f}, {0.290284663f, -0.956940353f}, -{0.271440446f, -0.962455213f}, {0.252491564f, -0.967599094f}, -{0.233445361f, -0.972369909f}, {0.214309156f, -0.976765871f}, -{0.195090324f, -0.980785251f}, {0.175796285f, -0.984426558f}, -{0.156434461f, -0.987688363f}, {0.137012348f, -0.990569353f}, -{0.117537394f, -0.993068457f}, {0.0980171412f, -0.995184720f}, -{0.0784590989f, -0.996917307f}, {0.0588708036f, -0.998265624f}, -{0.0392598175f, -0.999229014f}, {0.0196336918f, -0.999807239f}, -{6.12323426e-17f, -1.00000000f}, {-0.0196336918f, -0.999807239f}, -{-0.0392598175f, -0.999229014f}, {-0.0588708036f, -0.998265624f}, -{-0.0784590989f, -0.996917307f}, {-0.0980171412f, -0.995184720f}, -{-0.117537394f, -0.993068457f}, {-0.137012348f, -0.990569353f}, -{-0.156434461f, -0.987688363f}, {-0.175796285f, -0.984426558f}, -{-0.195090324f, -0.980785251f}, {-0.214309156f, -0.976765871f}, -{-0.233445361f, -0.972369909f}, {-0.252491564f, -0.967599094f}, -{-0.271440446f, -0.962455213f}, {-0.290284663f, -0.956940353f}, -{-0.309017003f, -0.951056540f}, {-0.327630192f, -0.944806039f}, -{-0.346117049f, -0.938191354f}, {-0.364470512f, -0.931214929f}, -{-0.382683426f, -0.923879504f}, {-0.400748819f, -0.916187942f}, -{-0.418659747f, -0.908143163f}, {-0.436409235f, -0.899748266f}, -{-0.453990489f, -0.891006529f}, {-0.471396744f, -0.881921291f}, -{-0.488621235f, -0.872496009f}, {-0.505657375f, -0.862734377f}, -{-0.522498548f, -0.852640152f}, {-0.539138317f, -0.842217207f}, -{-0.555570245f, -0.831469595f}, {-0.571787953f, -0.820401430f}, -{-0.587785244f, -0.809017003f}, {-0.603555918f, -0.797320664f}, -{-0.619093955f, -0.785316944f}, {-0.634393275f, -0.773010433f}, -{-0.649448037f, -0.760405958f}, {-0.664252460f, -0.747508347f}, -{-0.678800762f, -0.734322488f}, {-0.693087339f, -0.720853567f}, -{-0.707106769f, -0.707106769f}, {-0.720853567f, -0.693087339f}, -{-0.734322488f, -0.678800762f}, {-0.747508347f, -0.664252460f}, -{-0.760405958f, -0.649448037f}, {-0.773010433f, -0.634393275f}, -{-0.785316944f, -0.619093955f}, {-0.797320664f, -0.603555918f}, -{-0.809017003f, -0.587785244f}, {-0.820401430f, -0.571787953f}, -{-0.831469595f, -0.555570245f}, {-0.842217207f, -0.539138317f}, -{-0.852640152f, -0.522498548f}, {-0.862734377f, -0.505657375f}, -{-0.872496009f, -0.488621235f}, {-0.881921291f, -0.471396744f}, -{-0.891006529f, -0.453990489f}, {-0.899748266f, -0.436409235f}, -{-0.908143163f, -0.418659747f}, {-0.916187942f, -0.400748819f}, -{-0.923879504f, -0.382683426f}, {-0.931214929f, -0.364470512f}, -{-0.938191354f, -0.346117049f}, {-0.944806039f, -0.327630192f}, -{-0.951056540f, -0.309017003f}, {-0.956940353f, -0.290284663f}, -{-0.962455213f, -0.271440446f}, {-0.967599094f, -0.252491564f}, -{-0.972369909f, -0.233445361f}, {-0.976765871f, -0.214309156f}, -{-0.980785251f, -0.195090324f}, {-0.984426558f, -0.175796285f}, -{-0.987688363f, -0.156434461f}, {-0.990569353f, -0.137012348f}, -{-0.993068457f, -0.117537394f}, {-0.995184720f, -0.0980171412f}, -{-0.996917307f, -0.0784590989f}, {-0.998265624f, -0.0588708036f}, -{-0.999229014f, -0.0392598175f}, {-0.999807239f, -0.0196336918f}, -{-1.00000000f, -1.22464685e-16f}, {-0.999807239f, 0.0196336918f}, -{-0.999229014f, 0.0392598175f}, {-0.998265624f, 0.0588708036f}, -{-0.996917307f, 0.0784590989f}, {-0.995184720f, 0.0980171412f}, -{-0.993068457f, 0.117537394f}, {-0.990569353f, 0.137012348f}, -{-0.987688363f, 0.156434461f}, {-0.984426558f, 0.175796285f}, -{-0.980785251f, 0.195090324f}, {-0.976765871f, 0.214309156f}, -{-0.972369909f, 0.233445361f}, {-0.967599094f, 0.252491564f}, -{-0.962455213f, 0.271440446f}, {-0.956940353f, 0.290284663f}, -{-0.951056540f, 0.309017003f}, {-0.944806039f, 0.327630192f}, -{-0.938191354f, 0.346117049f}, {-0.931214929f, 0.364470512f}, -{-0.923879504f, 0.382683426f}, {-0.916187942f, 0.400748819f}, -{-0.908143163f, 0.418659747f}, {-0.899748266f, 0.436409235f}, -{-0.891006529f, 0.453990489f}, {-0.881921291f, 0.471396744f}, -{-0.872496009f, 0.488621235f}, {-0.862734377f, 0.505657375f}, -{-0.852640152f, 0.522498548f}, {-0.842217207f, 0.539138317f}, -{-0.831469595f, 0.555570245f}, {-0.820401430f, 0.571787953f}, -{-0.809017003f, 0.587785244f}, {-0.797320664f, 0.603555918f}, -{-0.785316944f, 0.619093955f}, {-0.773010433f, 0.634393275f}, -{-0.760405958f, 0.649448037f}, {-0.747508347f, 0.664252460f}, -{-0.734322488f, 0.678800762f}, {-0.720853567f, 0.693087339f}, -{-0.707106769f, 0.707106769f}, {-0.693087339f, 0.720853567f}, -{-0.678800762f, 0.734322488f}, {-0.664252460f, 0.747508347f}, -{-0.649448037f, 0.760405958f}, {-0.634393275f, 0.773010433f}, -{-0.619093955f, 0.785316944f}, {-0.603555918f, 0.797320664f}, -{-0.587785244f, 0.809017003f}, {-0.571787953f, 0.820401430f}, -{-0.555570245f, 0.831469595f}, {-0.539138317f, 0.842217207f}, -{-0.522498548f, 0.852640152f}, {-0.505657375f, 0.862734377f}, -{-0.488621235f, 0.872496009f}, {-0.471396744f, 0.881921291f}, -{-0.453990489f, 0.891006529f}, {-0.436409235f, 0.899748266f}, -{-0.418659747f, 0.908143163f}, {-0.400748819f, 0.916187942f}, -{-0.382683426f, 0.923879504f}, {-0.364470512f, 0.931214929f}, -{-0.346117049f, 0.938191354f}, {-0.327630192f, 0.944806039f}, -{-0.309017003f, 0.951056540f}, {-0.290284663f, 0.956940353f}, -{-0.271440446f, 0.962455213f}, {-0.252491564f, 0.967599094f}, -{-0.233445361f, 0.972369909f}, {-0.214309156f, 0.976765871f}, -{-0.195090324f, 0.980785251f}, {-0.175796285f, 0.984426558f}, -{-0.156434461f, 0.987688363f}, {-0.137012348f, 0.990569353f}, -{-0.117537394f, 0.993068457f}, {-0.0980171412f, 0.995184720f}, -{-0.0784590989f, 0.996917307f}, {-0.0588708036f, 0.998265624f}, -{-0.0392598175f, 0.999229014f}, {-0.0196336918f, 0.999807239f}, -{-1.83697015e-16f, 1.00000000f}, {0.0196336918f, 0.999807239f}, -{0.0392598175f, 0.999229014f}, {0.0588708036f, 0.998265624f}, -{0.0784590989f, 0.996917307f}, {0.0980171412f, 0.995184720f}, -{0.117537394f, 0.993068457f}, {0.137012348f, 0.990569353f}, -{0.156434461f, 0.987688363f}, {0.175796285f, 0.984426558f}, -{0.195090324f, 0.980785251f}, {0.214309156f, 0.976765871f}, -{0.233445361f, 0.972369909f}, {0.252491564f, 0.967599094f}, -{0.271440446f, 0.962455213f}, {0.290284663f, 0.956940353f}, -{0.309017003f, 0.951056540f}, {0.327630192f, 0.944806039f}, -{0.346117049f, 0.938191354f}, {0.364470512f, 0.931214929f}, -{0.382683426f, 0.923879504f}, {0.400748819f, 0.916187942f}, -{0.418659747f, 0.908143163f}, {0.436409235f, 0.899748266f}, -{0.453990489f, 0.891006529f}, {0.471396744f, 0.881921291f}, -{0.488621235f, 0.872496009f}, {0.505657375f, 0.862734377f}, -{0.522498548f, 0.852640152f}, {0.539138317f, 0.842217207f}, -{0.555570245f, 0.831469595f}, {0.571787953f, 0.820401430f}, -{0.587785244f, 0.809017003f}, {0.603555918f, 0.797320664f}, -{0.619093955f, 0.785316944f}, {0.634393275f, 0.773010433f}, -{0.649448037f, 0.760405958f}, {0.664252460f, 0.747508347f}, -{0.678800762f, 0.734322488f}, {0.693087339f, 0.720853567f}, -{0.707106769f, 0.707106769f}, {0.720853567f, 0.693087339f}, -{0.734322488f, 0.678800762f}, {0.747508347f, 0.664252460f}, -{0.760405958f, 0.649448037f}, {0.773010433f, 0.634393275f}, -{0.785316944f, 0.619093955f}, {0.797320664f, 0.603555918f}, -{0.809017003f, 0.587785244f}, {0.820401430f, 0.571787953f}, -{0.831469595f, 0.555570245f}, {0.842217207f, 0.539138317f}, -{0.852640152f, 0.522498548f}, {0.862734377f, 0.505657375f}, -{0.872496009f, 0.488621235f}, {0.881921291f, 0.471396744f}, -{0.891006529f, 0.453990489f}, {0.899748266f, 0.436409235f}, -{0.908143163f, 0.418659747f}, {0.916187942f, 0.400748819f}, -{0.923879504f, 0.382683426f}, {0.931214929f, 0.364470512f}, -{0.938191354f, 0.346117049f}, {0.944806039f, 0.327630192f}, -{0.951056540f, 0.309017003f}, {0.956940353f, 0.290284663f}, -{0.962455213f, 0.271440446f}, {0.967599094f, 0.252491564f}, -{0.972369909f, 0.233445361f}, {0.976765871f, 0.214309156f}, -{0.980785251f, 0.195090324f}, {0.984426558f, 0.175796285f}, -{0.987688363f, 0.156434461f}, {0.990569353f, 0.137012348f}, -{0.993068457f, 0.117537394f}, {0.995184720f, 0.0980171412f}, -{0.996917307f, 0.0784590989f}, {0.998265624f, 0.0588708036f}, -{0.999229014f, 0.0392598175f}, {0.999807239f, 0.0196336918f}, + {1.00000000f, -0.00000000f}, {0.999807239f, -0.0196336918f}, + {0.999229014f, -0.0392598175f}, {0.998265624f, -0.0588708036f}, + {0.996917307f, -0.0784590989f}, {0.995184720f, -0.0980171412f}, + {0.993068457f, -0.117537394f}, {0.990569353f, -0.137012348f}, + {0.987688363f, -0.156434461f}, {0.984426558f, -0.175796285f}, + {0.980785251f, -0.195090324f}, {0.976765871f, -0.214309156f}, + {0.972369909f, -0.233445361f}, {0.967599094f, -0.252491564f}, + {0.962455213f, -0.271440446f}, {0.956940353f, -0.290284663f}, + {0.951056540f, -0.309017003f}, {0.944806039f, -0.327630192f}, + {0.938191354f, -0.346117049f}, {0.931214929f, -0.364470512f}, + {0.923879504f, -0.382683426f}, {0.916187942f, -0.400748819f}, + {0.908143163f, -0.418659747f}, {0.899748266f, -0.436409235f}, + {0.891006529f, -0.453990489f}, {0.881921291f, -0.471396744f}, + {0.872496009f, -0.488621235f}, {0.862734377f, -0.505657375f}, + {0.852640152f, -0.522498548f}, {0.842217207f, -0.539138317f}, + {0.831469595f, -0.555570245f}, {0.820401430f, -0.571787953f}, + {0.809017003f, -0.587785244f}, {0.797320664f, -0.603555918f}, + {0.785316944f, -0.619093955f}, {0.773010433f, -0.634393275f}, + {0.760405958f, -0.649448037f}, {0.747508347f, -0.664252460f}, + {0.734322488f, -0.678800762f}, {0.720853567f, -0.693087339f}, + {0.707106769f, -0.707106769f}, {0.693087339f, -0.720853567f}, + {0.678800762f, -0.734322488f}, {0.664252460f, -0.747508347f}, + {0.649448037f, -0.760405958f}, {0.634393275f, -0.773010433f}, + {0.619093955f, -0.785316944f}, {0.603555918f, -0.797320664f}, + {0.587785244f, -0.809017003f}, {0.571787953f, -0.820401430f}, + {0.555570245f, -0.831469595f}, {0.539138317f, -0.842217207f}, + {0.522498548f, -0.852640152f}, {0.505657375f, -0.862734377f}, + {0.488621235f, -0.872496009f}, {0.471396744f, -0.881921291f}, + {0.453990489f, -0.891006529f}, {0.436409235f, -0.899748266f}, + {0.418659747f, -0.908143163f}, {0.400748819f, -0.916187942f}, + {0.382683426f, -0.923879504f}, {0.364470512f, -0.931214929f}, + {0.346117049f, -0.938191354f}, {0.327630192f, -0.944806039f}, + {0.309017003f, -0.951056540f}, {0.290284663f, -0.956940353f}, + {0.271440446f, -0.962455213f}, {0.252491564f, -0.967599094f}, + {0.233445361f, -0.972369909f}, {0.214309156f, -0.976765871f}, + {0.195090324f, -0.980785251f}, {0.175796285f, -0.984426558f}, + {0.156434461f, -0.987688363f}, {0.137012348f, -0.990569353f}, + {0.117537394f, -0.993068457f}, {0.0980171412f, -0.995184720f}, + {0.0784590989f, -0.996917307f}, {0.0588708036f, -0.998265624f}, + {0.0392598175f, -0.999229014f}, {0.0196336918f, -0.999807239f}, + {6.12323426e-17f, -1.00000000f}, {-0.0196336918f, -0.999807239f}, + {-0.0392598175f, -0.999229014f}, {-0.0588708036f, -0.998265624f}, + {-0.0784590989f, -0.996917307f}, {-0.0980171412f, -0.995184720f}, + {-0.117537394f, -0.993068457f}, {-0.137012348f, -0.990569353f}, + {-0.156434461f, -0.987688363f}, {-0.175796285f, -0.984426558f}, + {-0.195090324f, -0.980785251f}, {-0.214309156f, -0.976765871f}, + {-0.233445361f, -0.972369909f}, {-0.252491564f, -0.967599094f}, + {-0.271440446f, -0.962455213f}, {-0.290284663f, -0.956940353f}, + {-0.309017003f, -0.951056540f}, {-0.327630192f, -0.944806039f}, + {-0.346117049f, -0.938191354f}, {-0.364470512f, -0.931214929f}, + {-0.382683426f, -0.923879504f}, {-0.400748819f, -0.916187942f}, + {-0.418659747f, -0.908143163f}, {-0.436409235f, -0.899748266f}, + {-0.453990489f, -0.891006529f}, {-0.471396744f, -0.881921291f}, + {-0.488621235f, -0.872496009f}, {-0.505657375f, -0.862734377f}, + {-0.522498548f, -0.852640152f}, {-0.539138317f, -0.842217207f}, + {-0.555570245f, -0.831469595f}, {-0.571787953f, -0.820401430f}, + {-0.587785244f, -0.809017003f}, {-0.603555918f, -0.797320664f}, + {-0.619093955f, -0.785316944f}, {-0.634393275f, -0.773010433f}, + {-0.649448037f, -0.760405958f}, {-0.664252460f, -0.747508347f}, + {-0.678800762f, -0.734322488f}, {-0.693087339f, -0.720853567f}, + {-0.707106769f, -0.707106769f}, {-0.720853567f, -0.693087339f}, + {-0.734322488f, -0.678800762f}, {-0.747508347f, -0.664252460f}, + {-0.760405958f, -0.649448037f}, {-0.773010433f, -0.634393275f}, + {-0.785316944f, -0.619093955f}, {-0.797320664f, -0.603555918f}, + {-0.809017003f, -0.587785244f}, {-0.820401430f, -0.571787953f}, + {-0.831469595f, -0.555570245f}, {-0.842217207f, -0.539138317f}, + {-0.852640152f, -0.522498548f}, {-0.862734377f, -0.505657375f}, + {-0.872496009f, -0.488621235f}, {-0.881921291f, -0.471396744f}, + {-0.891006529f, -0.453990489f}, {-0.899748266f, -0.436409235f}, + {-0.908143163f, -0.418659747f}, {-0.916187942f, -0.400748819f}, + {-0.923879504f, -0.382683426f}, {-0.931214929f, -0.364470512f}, + {-0.938191354f, -0.346117049f}, {-0.944806039f, -0.327630192f}, + {-0.951056540f, -0.309017003f}, {-0.956940353f, -0.290284663f}, + {-0.962455213f, -0.271440446f}, {-0.967599094f, -0.252491564f}, + {-0.972369909f, -0.233445361f}, {-0.976765871f, -0.214309156f}, + {-0.980785251f, -0.195090324f}, {-0.984426558f, -0.175796285f}, + {-0.987688363f, -0.156434461f}, {-0.990569353f, -0.137012348f}, + {-0.993068457f, -0.117537394f}, {-0.995184720f, -0.0980171412f}, + {-0.996917307f, -0.0784590989f}, {-0.998265624f, -0.0588708036f}, + {-0.999229014f, -0.0392598175f}, {-0.999807239f, -0.0196336918f}, + {-1.00000000f, -1.22464685e-16f}, {-0.999807239f, 0.0196336918f}, + {-0.999229014f, 0.0392598175f}, {-0.998265624f, 0.0588708036f}, + {-0.996917307f, 0.0784590989f}, {-0.995184720f, 0.0980171412f}, + {-0.993068457f, 0.117537394f}, {-0.990569353f, 0.137012348f}, + {-0.987688363f, 0.156434461f}, {-0.984426558f, 0.175796285f}, + {-0.980785251f, 0.195090324f}, {-0.976765871f, 0.214309156f}, + {-0.972369909f, 0.233445361f}, {-0.967599094f, 0.252491564f}, + {-0.962455213f, 0.271440446f}, {-0.956940353f, 0.290284663f}, + {-0.951056540f, 0.309017003f}, {-0.944806039f, 0.327630192f}, + {-0.938191354f, 0.346117049f}, {-0.931214929f, 0.364470512f}, + {-0.923879504f, 0.382683426f}, {-0.916187942f, 0.400748819f}, + {-0.908143163f, 0.418659747f}, {-0.899748266f, 0.436409235f}, + {-0.891006529f, 0.453990489f}, {-0.881921291f, 0.471396744f}, + {-0.872496009f, 0.488621235f}, {-0.862734377f, 0.505657375f}, + {-0.852640152f, 0.522498548f}, {-0.842217207f, 0.539138317f}, + {-0.831469595f, 0.555570245f}, {-0.820401430f, 0.571787953f}, + {-0.809017003f, 0.587785244f}, {-0.797320664f, 0.603555918f}, + {-0.785316944f, 0.619093955f}, {-0.773010433f, 0.634393275f}, + {-0.760405958f, 0.649448037f}, {-0.747508347f, 0.664252460f}, + {-0.734322488f, 0.678800762f}, {-0.720853567f, 0.693087339f}, + {-0.707106769f, 0.707106769f}, {-0.693087339f, 0.720853567f}, + {-0.678800762f, 0.734322488f}, {-0.664252460f, 0.747508347f}, + {-0.649448037f, 0.760405958f}, {-0.634393275f, 0.773010433f}, + {-0.619093955f, 0.785316944f}, {-0.603555918f, 0.797320664f}, + {-0.587785244f, 0.809017003f}, {-0.571787953f, 0.820401430f}, + {-0.555570245f, 0.831469595f}, {-0.539138317f, 0.842217207f}, + {-0.522498548f, 0.852640152f}, {-0.505657375f, 0.862734377f}, + {-0.488621235f, 0.872496009f}, {-0.471396744f, 0.881921291f}, + {-0.453990489f, 0.891006529f}, {-0.436409235f, 0.899748266f}, + {-0.418659747f, 0.908143163f}, {-0.400748819f, 0.916187942f}, + {-0.382683426f, 0.923879504f}, {-0.364470512f, 0.931214929f}, + {-0.346117049f, 0.938191354f}, {-0.327630192f, 0.944806039f}, + {-0.309017003f, 0.951056540f}, {-0.290284663f, 0.956940353f}, + {-0.271440446f, 0.962455213f}, {-0.252491564f, 0.967599094f}, + {-0.233445361f, 0.972369909f}, {-0.214309156f, 0.976765871f}, + {-0.195090324f, 0.980785251f}, {-0.175796285f, 0.984426558f}, + {-0.156434461f, 0.987688363f}, {-0.137012348f, 0.990569353f}, + {-0.117537394f, 0.993068457f}, {-0.0980171412f, 0.995184720f}, + {-0.0784590989f, 0.996917307f}, {-0.0588708036f, 0.998265624f}, + {-0.0392598175f, 0.999229014f}, {-0.0196336918f, 0.999807239f}, + {-1.83697015e-16f, 1.00000000f}, {0.0196336918f, 0.999807239f}, + {0.0392598175f, 0.999229014f}, {0.0588708036f, 0.998265624f}, + {0.0784590989f, 0.996917307f}, {0.0980171412f, 0.995184720f}, + {0.117537394f, 0.993068457f}, {0.137012348f, 0.990569353f}, + {0.156434461f, 0.987688363f}, {0.175796285f, 0.984426558f}, + {0.195090324f, 0.980785251f}, {0.214309156f, 0.976765871f}, + {0.233445361f, 0.972369909f}, {0.252491564f, 0.967599094f}, + {0.271440446f, 0.962455213f}, {0.290284663f, 0.956940353f}, + {0.309017003f, 0.951056540f}, {0.327630192f, 0.944806039f}, + {0.346117049f, 0.938191354f}, {0.364470512f, 0.931214929f}, + {0.382683426f, 0.923879504f}, {0.400748819f, 0.916187942f}, + {0.418659747f, 0.908143163f}, {0.436409235f, 0.899748266f}, + {0.453990489f, 0.891006529f}, {0.471396744f, 0.881921291f}, + {0.488621235f, 0.872496009f}, {0.505657375f, 0.862734377f}, + {0.522498548f, 0.852640152f}, {0.539138317f, 0.842217207f}, + {0.555570245f, 0.831469595f}, {0.571787953f, 0.820401430f}, + {0.587785244f, 0.809017003f}, {0.603555918f, 0.797320664f}, + {0.619093955f, 0.785316944f}, {0.634393275f, 0.773010433f}, + {0.649448037f, 0.760405958f}, {0.664252460f, 0.747508347f}, + {0.678800762f, 0.734322488f}, {0.693087339f, 0.720853567f}, + {0.707106769f, 0.707106769f}, {0.720853567f, 0.693087339f}, + {0.734322488f, 0.678800762f}, {0.747508347f, 0.664252460f}, + {0.760405958f, 0.649448037f}, {0.773010433f, 0.634393275f}, + {0.785316944f, 0.619093955f}, {0.797320664f, 0.603555918f}, + {0.809017003f, 0.587785244f}, {0.820401430f, 0.571787953f}, + {0.831469595f, 0.555570245f}, {0.842217207f, 0.539138317f}, + {0.852640152f, 0.522498548f}, {0.862734377f, 0.505657375f}, + {0.872496009f, 0.488621235f}, {0.881921291f, 0.471396744f}, + {0.891006529f, 0.453990489f}, {0.899748266f, 0.436409235f}, + {0.908143163f, 0.418659747f}, {0.916187942f, 0.400748819f}, + {0.923879504f, 0.382683426f}, {0.931214929f, 0.364470512f}, + {0.938191354f, 0.346117049f}, {0.944806039f, 0.327630192f}, + {0.951056540f, 0.309017003f}, {0.956940353f, 0.290284663f}, + {0.962455213f, 0.271440446f}, {0.967599094f, 0.252491564f}, + {0.972369909f, 0.233445361f}, {0.976765871f, 0.214309156f}, + {0.980785251f, 0.195090324f}, {0.984426558f, 0.175796285f}, + {0.987688363f, 0.156434461f}, {0.990569353f, 0.137012348f}, + {0.993068457f, 0.117537394f}, {0.995184720f, 0.0980171412f}, + {0.996917307f, 0.0784590989f}, {0.998265624f, 0.0588708036f}, + {0.999229014f, 0.0392598175f}, {0.999807239f, 0.0196336918f}, }; -const kiss_fft_state kfft = { -320, /* nfft */ -0.0031250000f, /* scale */ --1, /* shift */ -{5, 64, 4, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ -fft_bitrev, /* bitrev*/ -fft_twiddles, /* twiddles*/ -(arch_fft_state *)&arch_fft, /* arch_fft*/ +const kiss_fft_state oaci_kfft = { + 320, /* nfft */ + 0.0031250000f, /* scale */ + -1, /* shift */ + {5, 64, 4, 16, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, }, /* factors */ + fft_bitrev, /* bitrev*/ + fft_twiddles, /* twiddles*/ + (arch_fft_state *)&arch_fft, /* arch_fft*/ }; -const float half_window[] = { -3.78491532e-05f, 0.000340620492f, 0.000946046319f, 0.00185389258f, 0.00306380726f, -0.00457531959f, 0.00638783723f, 0.00850064680f, 0.0109129101f, 0.0136236614f, -0.0166318044f, 0.0199361145f, 0.0235352255f, 0.0274276342f, 0.0316116922f, -0.0360856056f, 0.0408474281f, 0.0458950549f, 0.0512262285f, 0.0568385124f, -0.0627293140f, 0.0688958541f, 0.0753351897f, 0.0820441842f, 0.0890194997f, -0.0962576419f, 0.103754878f, 0.111507311f, 0.119510807f, 0.127761051f, -0.136253506f, 0.144983411f, 0.153945804f, 0.163135484f, 0.172547072f, -0.182174906f, 0.192013159f, 0.202055752f, 0.212296382f, 0.222728521f, -0.233345464f, 0.244140238f, 0.255105674f, 0.266234398f, 0.277518868f, -0.288951218f, 0.300523549f, 0.312227666f, 0.324055225f, 0.335997701f, -0.348046392f, 0.360192508f, 0.372427016f, 0.384740859f, 0.397124738f, -0.409569323f, 0.422065198f, 0.434602767f, 0.447172493f, 0.459764689f, -0.472369671f, 0.484977663f, 0.497579008f, 0.510163903f, 0.522722721f, -0.535245717f, 0.547723293f, 0.560145974f, 0.572504222f, 0.584788740f, -0.596990347f, 0.609099925f, 0.621108532f, 0.633007407f, 0.644788086f, -0.656442165f, 0.667961538f, 0.679338276f, 0.690564752f, 0.701633692f, -0.712537885f, 0.723270535f, 0.733825266f, 0.744195819f, 0.754376352f, -0.764361382f, 0.774145722f, 0.783724606f, 0.793093503f, 0.802248418f, -0.811185598f, 0.819901764f, 0.828393936f, 0.836659551f, 0.844696403f, -0.852502763f, 0.860077202f, 0.867418647f, 0.874526560f, 0.881400526f, -0.888040781f, 0.894447744f, 0.900622249f, 0.906565487f, 0.912279010f, -0.917764664f, 0.923024654f, 0.928061485f, 0.932878017f, 0.937477291f, -0.941862822f, 0.946038187f, 0.950007319f, 0.953774393f, 0.957343817f, -0.960720181f, 0.963908315f, 0.966913164f, 0.969739914f, 0.972393870f, -0.974880517f, 0.977205336f, 0.979374051f, 0.981392324f, 0.983266115f, -0.985001266f, 0.986603677f, 0.988079309f, 0.989434063f, 0.990674019f, -0.991804957f, 0.992832899f, 0.993763626f, 0.994602919f, 0.995356441f, -0.996029854f, 0.996628702f, 0.997158289f, 0.997623861f, 0.998030603f, -0.998383403f, 0.998687088f, 0.998946249f, 0.999165416f, 0.999348700f, -0.999500215f, 0.999623775f, 0.999723017f, 0.999801278f, 0.999861658f, -0.999907196f, 0.999940455f, 0.999963880f, 0.999979615f, 0.999989510f, -0.999995291f, 0.999998271f, 0.999999523f, 0.999999940f, 1.00000000f, +const float oaci_half_window[] = { + 3.78491532e-05f, 0.000340620492f, 0.000946046319f, 0.00185389258f, 0.00306380726f, + 0.00457531959f, 0.00638783723f, 0.00850064680f, 0.0109129101f, 0.0136236614f, + 0.0166318044f, 0.0199361145f, 0.0235352255f, 0.0274276342f, 0.0316116922f, + 0.0360856056f, 0.0408474281f, 0.0458950549f, 0.0512262285f, 0.0568385124f, + 0.0627293140f, 0.0688958541f, 0.0753351897f, 0.0820441842f, 0.0890194997f, + 0.0962576419f, 0.103754878f, 0.111507311f, 0.119510807f, 0.127761051f, + 0.136253506f, 0.144983411f, 0.153945804f, 0.163135484f, 0.172547072f, + 0.182174906f, 0.192013159f, 0.202055752f, 0.212296382f, 0.222728521f, + 0.233345464f, 0.244140238f, 0.255105674f, 0.266234398f, 0.277518868f, + 0.288951218f, 0.300523549f, 0.312227666f, 0.324055225f, 0.335997701f, + 0.348046392f, 0.360192508f, 0.372427016f, 0.384740859f, 0.397124738f, + 0.409569323f, 0.422065198f, 0.434602767f, 0.447172493f, 0.459764689f, + 0.472369671f, 0.484977663f, 0.497579008f, 0.510163903f, 0.522722721f, + 0.535245717f, 0.547723293f, 0.560145974f, 0.572504222f, 0.584788740f, + 0.596990347f, 0.609099925f, 0.621108532f, 0.633007407f, 0.644788086f, + 0.656442165f, 0.667961538f, 0.679338276f, 0.690564752f, 0.701633692f, + 0.712537885f, 0.723270535f, 0.733825266f, 0.744195819f, 0.754376352f, + 0.764361382f, 0.774145722f, 0.783724606f, 0.793093503f, 0.802248418f, + 0.811185598f, 0.819901764f, 0.828393936f, 0.836659551f, 0.844696403f, + 0.852502763f, 0.860077202f, 0.867418647f, 0.874526560f, 0.881400526f, + 0.888040781f, 0.894447744f, 0.900622249f, 0.906565487f, 0.912279010f, + 0.917764664f, 0.923024654f, 0.928061485f, 0.932878017f, 0.937477291f, + 0.941862822f, 0.946038187f, 0.950007319f, 0.953774393f, 0.957343817f, + 0.960720181f, 0.963908315f, 0.966913164f, 0.969739914f, 0.972393870f, + 0.974880517f, 0.977205336f, 0.979374051f, 0.981392324f, 0.983266115f, + 0.985001266f, 0.986603677f, 0.988079309f, 0.989434063f, 0.990674019f, + 0.991804957f, 0.992832899f, 0.993763626f, 0.994602919f, 0.995356441f, + 0.996029854f, 0.996628702f, 0.997158289f, 0.997623861f, 0.998030603f, + 0.998383403f, 0.998687088f, 0.998946249f, 0.999165416f, 0.999348700f, + 0.999500215f, 0.999623775f, 0.999723017f, 0.999801278f, 0.999861658f, + 0.999907196f, 0.999940455f, 0.999963880f, 0.999979615f, 0.999989510f, + 0.999995291f, 0.999998271f, 0.999999523f, 0.999999940f, 1.00000000f, }; -const float dct_table[] = { -0.707106769f, 0.996194720f, 0.984807730f, 0.965925813f, 0.939692616f, -0.906307817f, 0.866025388f, 0.819152057f, 0.766044438f, 0.707106769f, -0.642787635f, 0.573576450f, 0.500000000f, 0.422618270f, 0.342020154f, -0.258819044f, 0.173648179f, 0.0871557444f, 0.707106769f, 0.965925813f, -0.866025388f, 0.707106769f, 0.500000000f, 0.258819044f, 6.12323426e-17f, --0.258819044f, -0.500000000f, -0.707106769f, -0.866025388f, -0.965925813f, --1.00000000f, -0.965925813f, -0.866025388f, -0.707106769f, -0.500000000f, --0.258819044f, 0.707106769f, 0.906307817f, 0.642787635f, 0.258819044f, --0.173648179f, -0.573576450f, -0.866025388f, -0.996194720f, -0.939692616f, --0.707106769f, -0.342020154f, 0.0871557444f, 0.500000000f, 0.819152057f, -0.984807730f, 0.965925813f, 0.766044438f, 0.422618270f, 0.707106769f, -0.819152057f, 0.342020154f, -0.258819044f, -0.766044438f, -0.996194720f, --0.866025388f, -0.422618270f, 0.173648179f, 0.707106769f, 0.984807730f, -0.906307817f, 0.500000000f, -0.0871557444f, -0.642787635f, -0.965925813f, --0.939692616f, -0.573576450f, 0.707106769f, 0.707106769f, 6.12323426e-17f, --0.707106769f, -1.00000000f, -0.707106769f, -1.83697015e-16f, 0.707106769f, -1.00000000f, 0.707106769f, 3.06161700e-16f, -0.707106769f, -1.00000000f, --0.707106769f, -4.28626385e-16f, 0.707106769f, 1.00000000f, 0.707106769f, -0.707106769f, 0.573576450f, -0.342020154f, -0.965925813f, -0.766044438f, -0.0871557444f, 0.866025388f, 0.906307817f, 0.173648179f, -0.707106769f, --0.984807730f, -0.422618270f, 0.500000000f, 0.996194720f, 0.642787635f, --0.258819044f, -0.939692616f, -0.819152057f, 0.707106769f, 0.422618270f, --0.642787635f, -0.965925813f, -0.173648179f, 0.819152057f, 0.866025388f, --0.0871557444f, -0.939692616f, -0.707106769f, 0.342020154f, 0.996194720f, -0.500000000f, -0.573576450f, -0.984807730f, -0.258819044f, 0.766044438f, -0.906307817f, 0.707106769f, 0.258819044f, -0.866025388f, -0.707106769f, -0.500000000f, 0.965925813f, 3.06161700e-16f, -0.965925813f, -0.500000000f, -0.707106769f, 0.866025388f, -0.258819044f, -1.00000000f, -0.258819044f, -0.866025388f, 0.707106769f, -0.500000000f, -0.965925813f, 0.707106769f, -0.0871557444f, -0.984807730f, -0.258819044f, 0.939692616f, 0.422618270f, --0.866025388f, -0.573576450f, 0.766044438f, 0.707106769f, -0.642787635f, --0.819152057f, 0.500000000f, 0.906307817f, -0.342020154f, -0.965925813f, -0.173648179f, 0.996194720f, 0.707106769f, -0.0871557444f, -0.984807730f, -0.258819044f, 0.939692616f, -0.422618270f, -0.866025388f, 0.573576450f, -0.766044438f, -0.707106769f, -0.642787635f, 0.819152057f, 0.500000000f, --0.906307817f, -0.342020154f, 0.965925813f, 0.173648179f, -0.996194720f, -0.707106769f, -0.258819044f, -0.866025388f, 0.707106769f, 0.500000000f, --0.965925813f, -4.28626385e-16f, 0.965925813f, -0.500000000f, -0.707106769f, -0.866025388f, 0.258819044f, -1.00000000f, 0.258819044f, 0.866025388f, --0.707106769f, -0.500000000f, 0.965925813f, 0.707106769f, -0.422618270f, --0.642787635f, 0.965925813f, -0.173648179f, -0.819152057f, 0.866025388f, -0.0871557444f, -0.939692616f, 0.707106769f, 0.342020154f, -0.996194720f, -0.500000000f, 0.573576450f, -0.984807730f, 0.258819044f, 0.766044438f, --0.906307817f, 0.707106769f, -0.573576450f, -0.342020154f, 0.965925813f, --0.766044438f, -0.0871557444f, 0.866025388f, -0.906307817f, 0.173648179f, -0.707106769f, -0.984807730f, 0.422618270f, 0.500000000f, -0.996194720f, -0.642787635f, 0.258819044f, -0.939692616f, 0.819152057f, 0.707106769f, --0.707106769f, -1.83697015e-16f, 0.707106769f, -1.00000000f, 0.707106769f, -5.51091070e-16f, -0.707106769f, 1.00000000f, -0.707106769f, -2.69484189e-15f, -0.707106769f, -1.00000000f, 0.707106769f, -4.90477710e-16f, -0.707106769f, -1.00000000f, -0.707106769f, 0.707106769f, -0.819152057f, 0.342020154f, -0.258819044f, -0.766044438f, 0.996194720f, -0.866025388f, 0.422618270f, -0.173648179f, -0.707106769f, 0.984807730f, -0.906307817f, 0.500000000f, -0.0871557444f, -0.642787635f, 0.965925813f, -0.939692616f, 0.573576450f, -0.707106769f, -0.906307817f, 0.642787635f, -0.258819044f, -0.173648179f, -0.573576450f, -0.866025388f, 0.996194720f, -0.939692616f, 0.707106769f, --0.342020154f, -0.0871557444f, 0.500000000f, -0.819152057f, 0.984807730f, --0.965925813f, 0.766044438f, -0.422618270f, 0.707106769f, -0.965925813f, -0.866025388f, -0.707106769f, 0.500000000f, -0.258819044f, 1.10280111e-15f, -0.258819044f, -0.500000000f, 0.707106769f, -0.866025388f, 0.965925813f, --1.00000000f, 0.965925813f, -0.866025388f, 0.707106769f, -0.500000000f, -0.258819044f, 0.707106769f, -0.996194720f, 0.984807730f, -0.965925813f, -0.939692616f, -0.906307817f, 0.866025388f, -0.819152057f, 0.766044438f, --0.707106769f, 0.642787635f, -0.573576450f, 0.500000000f, -0.422618270f, -0.342020154f, -0.258819044f, 0.173648179f, -0.0871557444f, }; +const float oaci_dct_table[] = { + 0.707106769f, 0.996194720f, 0.984807730f, 0.965925813f, 0.939692616f, + 0.906307817f, 0.866025388f, 0.819152057f, 0.766044438f, 0.707106769f, + 0.642787635f, 0.573576450f, 0.500000000f, 0.422618270f, 0.342020154f, + 0.258819044f, 0.173648179f, 0.0871557444f, 0.707106769f, 0.965925813f, + 0.866025388f, 0.707106769f, 0.500000000f, 0.258819044f, 6.12323426e-17f, + -0.258819044f, -0.500000000f, -0.707106769f, -0.866025388f, -0.965925813f, + -1.00000000f, -0.965925813f, -0.866025388f, -0.707106769f, -0.500000000f, + -0.258819044f, 0.707106769f, 0.906307817f, 0.642787635f, 0.258819044f, + -0.173648179f, -0.573576450f, -0.866025388f, -0.996194720f, -0.939692616f, + -0.707106769f, -0.342020154f, 0.0871557444f, 0.500000000f, 0.819152057f, + 0.984807730f, 0.965925813f, 0.766044438f, 0.422618270f, 0.707106769f, + 0.819152057f, 0.342020154f, -0.258819044f, -0.766044438f, -0.996194720f, + -0.866025388f, -0.422618270f, 0.173648179f, 0.707106769f, 0.984807730f, + 0.906307817f, 0.500000000f, -0.0871557444f, -0.642787635f, -0.965925813f, + -0.939692616f, -0.573576450f, 0.707106769f, 0.707106769f, 6.12323426e-17f, + -0.707106769f, -1.00000000f, -0.707106769f, -1.83697015e-16f, 0.707106769f, + 1.00000000f, 0.707106769f, 3.06161700e-16f, -0.707106769f, -1.00000000f, + -0.707106769f, -4.28626385e-16f, 0.707106769f, 1.00000000f, 0.707106769f, + 0.707106769f, 0.573576450f, -0.342020154f, -0.965925813f, -0.766044438f, + 0.0871557444f, 0.866025388f, 0.906307817f, 0.173648179f, -0.707106769f, + -0.984807730f, -0.422618270f, 0.500000000f, 0.996194720f, 0.642787635f, + -0.258819044f, -0.939692616f, -0.819152057f, 0.707106769f, 0.422618270f, + -0.642787635f, -0.965925813f, -0.173648179f, 0.819152057f, 0.866025388f, + -0.0871557444f, -0.939692616f, -0.707106769f, 0.342020154f, 0.996194720f, + 0.500000000f, -0.573576450f, -0.984807730f, -0.258819044f, 0.766044438f, + 0.906307817f, 0.707106769f, 0.258819044f, -0.866025388f, -0.707106769f, + 0.500000000f, 0.965925813f, 3.06161700e-16f, -0.965925813f, -0.500000000f, + 0.707106769f, 0.866025388f, -0.258819044f, -1.00000000f, -0.258819044f, + 0.866025388f, 0.707106769f, -0.500000000f, -0.965925813f, 0.707106769f, + 0.0871557444f, -0.984807730f, -0.258819044f, 0.939692616f, 0.422618270f, + -0.866025388f, -0.573576450f, 0.766044438f, 0.707106769f, -0.642787635f, + -0.819152057f, 0.500000000f, 0.906307817f, -0.342020154f, -0.965925813f, + 0.173648179f, 0.996194720f, 0.707106769f, -0.0871557444f, -0.984807730f, + 0.258819044f, 0.939692616f, -0.422618270f, -0.866025388f, 0.573576450f, + 0.766044438f, -0.707106769f, -0.642787635f, 0.819152057f, 0.500000000f, + -0.906307817f, -0.342020154f, 0.965925813f, 0.173648179f, -0.996194720f, + 0.707106769f, -0.258819044f, -0.866025388f, 0.707106769f, 0.500000000f, + -0.965925813f, -4.28626385e-16f, 0.965925813f, -0.500000000f, -0.707106769f, + 0.866025388f, 0.258819044f, -1.00000000f, 0.258819044f, 0.866025388f, + -0.707106769f, -0.500000000f, 0.965925813f, 0.707106769f, -0.422618270f, + -0.642787635f, 0.965925813f, -0.173648179f, -0.819152057f, 0.866025388f, + 0.0871557444f, -0.939692616f, 0.707106769f, 0.342020154f, -0.996194720f, + 0.500000000f, 0.573576450f, -0.984807730f, 0.258819044f, 0.766044438f, + -0.906307817f, 0.707106769f, -0.573576450f, -0.342020154f, 0.965925813f, + -0.766044438f, -0.0871557444f, 0.866025388f, -0.906307817f, 0.173648179f, + 0.707106769f, -0.984807730f, 0.422618270f, 0.500000000f, -0.996194720f, + 0.642787635f, 0.258819044f, -0.939692616f, 0.819152057f, 0.707106769f, + -0.707106769f, -1.83697015e-16f, 0.707106769f, -1.00000000f, 0.707106769f, + 5.51091070e-16f, -0.707106769f, 1.00000000f, -0.707106769f, -2.69484189e-15f, + 0.707106769f, -1.00000000f, 0.707106769f, -4.90477710e-16f, -0.707106769f, + 1.00000000f, -0.707106769f, 0.707106769f, -0.819152057f, 0.342020154f, + 0.258819044f, -0.766044438f, 0.996194720f, -0.866025388f, 0.422618270f, + 0.173648179f, -0.707106769f, 0.984807730f, -0.906307817f, 0.500000000f, + 0.0871557444f, -0.642787635f, 0.965925813f, -0.939692616f, 0.573576450f, + 0.707106769f, -0.906307817f, 0.642787635f, -0.258819044f, -0.173648179f, + 0.573576450f, -0.866025388f, 0.996194720f, -0.939692616f, 0.707106769f, + -0.342020154f, -0.0871557444f, 0.500000000f, -0.819152057f, 0.984807730f, + -0.965925813f, 0.766044438f, -0.422618270f, 0.707106769f, -0.965925813f, + 0.866025388f, -0.707106769f, 0.500000000f, -0.258819044f, 1.10280111e-15f, + 0.258819044f, -0.500000000f, 0.707106769f, -0.866025388f, 0.965925813f, + -1.00000000f, 0.965925813f, -0.866025388f, 0.707106769f, -0.500000000f, + 0.258819044f, 0.707106769f, -0.996194720f, 0.984807730f, -0.965925813f, + 0.939692616f, -0.906307817f, 0.866025388f, -0.819152057f, 0.766044438f, + -0.707106769f, 0.642787635f, -0.573576450f, 0.500000000f, -0.422618270f, + 0.342020154f, -0.258819044f, 0.173648179f, -0.0871557444f, +}; diff --git a/dnn/meson.build b/dnn/meson.build index 7b324016c..af89db3d6 100644 --- a/dnn/meson.build +++ b/dnn/meson.build @@ -17,15 +17,15 @@ dnn_sources_avx2 = sources['DNN_SOURCES_AVX2'] dnn_sources_neon_intr = sources['DNN_SOURCES_NEON'] dnn_sources_dotprod_intr = sources['DNN_SOURCES_DOTPROD'] -dnn_includes = [opus_includes] +dnn_includes = [oac_includes] dnn_static_libs = [] -if host_cpu_family in ['x86', 'x86_64'] and opus_conf.has('OPUS_HAVE_RTCD') +if host_cpu_family in ['x86', 'x86_64'] and oac_conf.has('OAC_HAVE_RTCD') dnn_sources += sources['DNN_SOURCES_X86_RTCD'] endif if host_cpu_family in ['arm', 'aarch64'] and have_arm_intrinsics_or_asm - if opus_conf.has('OPUS_HAVE_RTCD') + if oac_conf.has('OAC_HAVE_RTCD') dnn_sources += sources['DNN_SOURCES_ARM_RTCD'] endif endif @@ -38,7 +38,7 @@ foreach intr_name : ['sse2', 'sse4_1', 'avx2', 'neon_intr', 'dotprod_intr'] intr_sources = get_variable('dnn_sources_' + intr_name) - intr_args = get_variable('opus_@0@_args'.format(intr_name), []) + intr_args = get_variable('oac_@0@_args'.format(intr_name), []) dnn_static_libs += static_library('dnn_' + intr_name, intr_sources, c_args: intr_args, include_directories: dnn_includes, @@ -52,7 +52,7 @@ endif if opt_deep_plc.enabled() - dnn_lib = static_library('opus-dnn', + dnn_lib = static_library('oac-dnn', dnn_sources, c_args: dnn_c_args, include_directories: dnn_includes, diff --git a/dnn/nndsp.c b/dnn/nndsp.c index 9d1d2765b..314232098 100644 --- a/dnn/nndsp.c +++ b/dnn/nndsp.c @@ -23,10 +23,10 @@ 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" +# include "config.h" #endif @@ -40,97 +40,82 @@ #include #ifndef M_PI -#define M_PI 3.141592653589793f +# define M_PI 3.141592653589793f #endif -#define KERNEL_INDEX(i_out_channels, i_in_channels, i_kernel) ((((i_out_channels) * in_channels) + (i_in_channels)) * kernel_size + (i_kernel)) +#define KERNEL_INDEX(i_out_channels, i_in_channels, \ + i_kernel) ((((i_out_channels)*in_channels) + (i_in_channels))*kernel_size + (i_kernel)) -void init_adaconv_state(AdaConvState *hAdaConv) -{ - OPUS_CLEAR(hAdaConv, 1); +void oaci_init_adaconv_state(AdaConvState *hAdaConv) { + OAC_CLEAR(hAdaConv, 1); } -void init_adacomb_state(AdaCombState *hAdaComb) -{ - OPUS_CLEAR(hAdaComb, 1); +void oaci_init_adacomb_state(AdaCombState *hAdaComb) { + OAC_CLEAR(hAdaComb, 1); } -void init_adashape_state(AdaShapeState *hAdaShape) -{ - OPUS_CLEAR(hAdaShape, 1); +void oaci_init_adashape_state(AdaShapeState *hAdaShape) { + OAC_CLEAR(hAdaShape, 1); } -void compute_overlap_window(float *window, int overlap_size) -{ +void oaci_compute_overlap_window(float *window, int overlap_size) { int i_sample; - for (i_sample=0; i_sample < overlap_size; i_sample++) - { - window[i_sample] = 0.5f + 0.5f * cos(M_PI * (i_sample + 0.5f) / overlap_size); + for (i_sample = 0; i_sample < overlap_size; i_sample++) { + window[i_sample] = 0.5f + 0.5f*cos(M_PI*(i_sample + 0.5f)/overlap_size); } } #ifdef DEBUG_NNDSP -void print_float_vector(const char* name, const float *vec, int length) -{ - for (int i = 0; i < length; i ++) - { +void print_float_vector(const char* name, const float *vec, int length) { + for (int i = 0; i < length; i++) { printf("%s[%d]: %f\n", name, i, vec[i]); } } #endif -static void scale_kernel( +static void oaci_scale_kernel( float *kernel, int in_channels, int out_channels, int kernel_size, - float *gain -) + float *gain) { /* normalizes (p-norm) kernel over input channel and kernel dimension */ -{ float norm; int i_in_channels, i_out_channels, i_kernel; - for (i_out_channels = 0; i_out_channels < out_channels; i_out_channels++) - { + for (i_out_channels = 0; i_out_channels < out_channels; i_out_channels++) { norm = 0; - for (i_in_channels = 0; i_in_channels < in_channels; i_in_channels ++) - { - for (i_kernel = 0; i_kernel < kernel_size; i_kernel++) - { - norm += kernel[KERNEL_INDEX(i_out_channels, i_in_channels, i_kernel)] * kernel[KERNEL_INDEX(i_out_channels, i_in_channels, i_kernel)]; + for (i_in_channels = 0; i_in_channels < in_channels; i_in_channels++) { + for (i_kernel = 0; i_kernel < kernel_size; i_kernel++) { + norm += kernel[KERNEL_INDEX(i_out_channels, i_in_channels, + i_kernel)]*kernel[KERNEL_INDEX(i_out_channels, i_in_channels, i_kernel)]; } } #ifdef DEBUG_NNDSP printf("kernel norm: %f, %f\n", norm, sqrt(norm)); #endif - norm = 1.f / (1e-6f + sqrt(norm)); - for (i_in_channels = 0; i_in_channels < in_channels; i_in_channels++) - { - for (i_kernel = 0; i_kernel < kernel_size; i_kernel++) - { + norm = 1.f/(1e-6f + sqrt(norm)); + for (i_in_channels = 0; i_in_channels < in_channels; i_in_channels++) { + for (i_kernel = 0; i_kernel < kernel_size; i_kernel++) { - kernel[KERNEL_INDEX(i_out_channels, i_in_channels, i_kernel)] *= norm * gain[i_out_channels]; + kernel[KERNEL_INDEX(i_out_channels, i_in_channels, i_kernel)] *= norm*gain[i_out_channels]; } } } } -static void transform_gains( +static void oaci_transform_gains( float *gains, int num_gains, float filter_gain_a, - float filter_gain_b -) -{ + float filter_gain_b) { int i; - for (i = 0; i < num_gains; i++) - { - gains[i] = exp(filter_gain_a * gains[i] + filter_gain_b); + for (i = 0; i < num_gains; i++) { + gains[i] = exp(filter_gain_a*gains[i] + filter_gain_b); } } -void adaconv_process_frame( +void oaci_adaconv_process_frame( AdaConvState* hAdaConv, float *x_out, const float *x_in, @@ -148,12 +133,10 @@ void adaconv_process_frame( float filter_gain_b, float shape_gain, float *window, - int arch -) -{ - float output_buffer[ADACONV_MAX_FRAME_SIZE * ADACONV_MAX_OUTPUT_CHANNELS]; - float kernel_buffer[ADACONV_MAX_KERNEL_SIZE * ADACONV_MAX_INPUT_CHANNELS * ADACONV_MAX_OUTPUT_CHANNELS]; - float input_buffer[ADACONV_MAX_INPUT_CHANNELS * (ADACONV_MAX_FRAME_SIZE + ADACONV_MAX_KERNEL_SIZE)]; + int arch) { + float output_buffer[ADACONV_MAX_FRAME_SIZE*ADACONV_MAX_OUTPUT_CHANNELS]; + float kernel_buffer[ADACONV_MAX_KERNEL_SIZE*ADACONV_MAX_INPUT_CHANNELS*ADACONV_MAX_OUTPUT_CHANNELS]; + float input_buffer[ADACONV_MAX_INPUT_CHANNELS*(ADACONV_MAX_FRAME_SIZE + ADACONV_MAX_KERNEL_SIZE)]; float kernel0[ADACONV_MAX_KERNEL_SIZE]; float kernel1[ADACONV_MAX_KERNEL_SIZE]; float channel_buffer0[ADACONV_MAX_OVERLAP_SIZE]; @@ -168,79 +151,79 @@ void adaconv_process_frame( celt_assert(left_padding == kernel_size - 1); /* currently only supports causal version. Non-causal version not difficult to implement but will require third loop */ celt_assert(kernel_size < frame_size); - OPUS_CLEAR(output_buffer, ADACONV_MAX_FRAME_SIZE * ADACONV_MAX_OUTPUT_CHANNELS); - OPUS_CLEAR(kernel_buffer, ADACONV_MAX_KERNEL_SIZE * ADACONV_MAX_INPUT_CHANNELS * ADACONV_MAX_OUTPUT_CHANNELS); - OPUS_CLEAR(input_buffer, ADACONV_MAX_INPUT_CHANNELS * (ADACONV_MAX_FRAME_SIZE + ADACONV_MAX_KERNEL_SIZE)); + OAC_CLEAR(output_buffer, ADACONV_MAX_FRAME_SIZE*ADACONV_MAX_OUTPUT_CHANNELS); + OAC_CLEAR(kernel_buffer, ADACONV_MAX_KERNEL_SIZE*ADACONV_MAX_INPUT_CHANNELS*ADACONV_MAX_OUTPUT_CHANNELS); + OAC_CLEAR(input_buffer, ADACONV_MAX_INPUT_CHANNELS*(ADACONV_MAX_FRAME_SIZE + ADACONV_MAX_KERNEL_SIZE)); #ifdef DEBUG_NNDSP - print_float_vector("x_in", x_in, in_channels * frame_size); + print_float_vector("x_in", x_in, in_channels*frame_size); #endif /* prepare input */ - for (i_in_channels=0; i_in_channels < in_channels; i_in_channels ++) - { - OPUS_COPY(input_buffer + i_in_channels * (kernel_size + frame_size), hAdaConv->history + i_in_channels * kernel_size, kernel_size); - OPUS_COPY(input_buffer + kernel_size + i_in_channels * (kernel_size + frame_size), x_in + frame_size * i_in_channels, frame_size); + for (i_in_channels = 0; i_in_channels < in_channels; i_in_channels++) { + OAC_COPY(input_buffer + i_in_channels*(kernel_size + frame_size), hAdaConv->history + i_in_channels*kernel_size, + kernel_size); + OAC_COPY(input_buffer + kernel_size + i_in_channels*(kernel_size + frame_size), x_in + frame_size*i_in_channels, + frame_size); } p_input = input_buffer + kernel_size; /* calculate new kernel and new gain */ - compute_generic_dense(kernel_layer, kernel_buffer, features, ACTIVATION_LINEAR, arch); - compute_generic_dense(gain_layer, gain_buffer, features, ACTIVATION_TANH, arch); + oaci_compute_generic_dense(kernel_layer, kernel_buffer, features, ACTIVATION_LINEAR, arch); + oaci_compute_generic_dense(gain_layer, gain_buffer, features, ACTIVATION_TANH, arch); #ifdef DEBUG_NNDSP print_float_vector("features", features, feature_dim); - print_float_vector("adaconv_kernel_raw", kernel_buffer, in_channels * out_channels * kernel_size); + print_float_vector("adaconv_kernel_raw", kernel_buffer, in_channels*out_channels*kernel_size); print_float_vector("adaconv_gain_raw", gain_buffer, out_channels); #endif - transform_gains(gain_buffer, out_channels, filter_gain_a, filter_gain_b); - scale_kernel(kernel_buffer, in_channels, out_channels, kernel_size, gain_buffer); + oaci_transform_gains(gain_buffer, out_channels, filter_gain_a, filter_gain_b); + oaci_scale_kernel(kernel_buffer, in_channels, out_channels, kernel_size, gain_buffer); #ifdef DEBUG_NNDSP - print_float_vector("adaconv_kernel", kernel_buffer, in_channels * out_channels * kernel_size); + print_float_vector("adaconv_kernel", kernel_buffer, in_channels*out_channels*kernel_size); print_float_vector("adaconv_gain", gain_buffer, out_channels); #endif /* calculate overlapping part using kernel from last frame */ - for (i_out_channels = 0; i_out_channels < out_channels; i_out_channels++) - { - for (i_in_channels = 0; i_in_channels < in_channels; i_in_channels++) - { - OPUS_CLEAR(kernel0, ADACONV_MAX_KERNEL_SIZE); - OPUS_CLEAR(kernel1, ADACONV_MAX_KERNEL_SIZE); - - OPUS_COPY(kernel0, hAdaConv->last_kernel + KERNEL_INDEX(i_out_channels, i_in_channels, 0), kernel_size); - OPUS_COPY(kernel1, kernel_buffer + KERNEL_INDEX(i_out_channels, i_in_channels, 0), kernel_size); - celt_pitch_xcorr(kernel0, p_input + i_in_channels * (frame_size + kernel_size) - left_padding, channel_buffer0, ADACONV_MAX_KERNEL_SIZE, overlap_size, arch); - celt_pitch_xcorr(kernel1, p_input + i_in_channels * (frame_size + kernel_size) - left_padding, channel_buffer1, ADACONV_MAX_KERNEL_SIZE, frame_size, arch); - for (i_sample = 0; i_sample < overlap_size; i_sample++) - { - output_buffer[i_sample + i_out_channels * frame_size] += window[i_sample] * channel_buffer0[i_sample]; - output_buffer[i_sample + i_out_channels * frame_size] += (1.f - window[i_sample]) * channel_buffer1[i_sample]; + for (i_out_channels = 0; i_out_channels < out_channels; i_out_channels++) { + for (i_in_channels = 0; i_in_channels < in_channels; i_in_channels++) { + OAC_CLEAR(kernel0, ADACONV_MAX_KERNEL_SIZE); + OAC_CLEAR(kernel1, ADACONV_MAX_KERNEL_SIZE); + + OAC_COPY(kernel0, hAdaConv->last_kernel + KERNEL_INDEX(i_out_channels, i_in_channels, 0), kernel_size); + OAC_COPY(kernel1, kernel_buffer + KERNEL_INDEX(i_out_channels, i_in_channels, 0), kernel_size); + oaci_celt_pitch_xcorr(kernel0, p_input + i_in_channels*(frame_size + kernel_size) - left_padding, + channel_buffer0, ADACONV_MAX_KERNEL_SIZE, overlap_size, arch); + oaci_celt_pitch_xcorr(kernel1, p_input + i_in_channels*(frame_size + kernel_size) - left_padding, + channel_buffer1, ADACONV_MAX_KERNEL_SIZE, frame_size, arch); + for (i_sample = 0; i_sample < overlap_size; i_sample++) { + output_buffer[i_sample + i_out_channels*frame_size] += window[i_sample]*channel_buffer0[i_sample]; + output_buffer[i_sample + i_out_channels*frame_size] += (1.f - window[i_sample]) + *channel_buffer1[i_sample]; } - for (i_sample = overlap_size; i_sample < frame_size; i_sample++) - { - output_buffer[i_sample + i_out_channels * frame_size] += channel_buffer1[i_sample]; + for (i_sample = overlap_size; i_sample < frame_size; i_sample++) { + output_buffer[i_sample + i_out_channels*frame_size] += channel_buffer1[i_sample]; } } } - OPUS_COPY(x_out, output_buffer, out_channels * frame_size); + OAC_COPY(x_out, output_buffer, out_channels*frame_size); #ifdef DEBUG_NNDSP - print_float_vector("x_out", x_out, out_channels * frame_size); + print_float_vector("x_out", x_out, out_channels*frame_size); #endif /* buffer update */ - for (i_in_channels=0; i_in_channels < in_channels; i_in_channels ++) - { - OPUS_COPY(hAdaConv->history + i_in_channels * kernel_size, p_input + i_in_channels * (frame_size + kernel_size) + frame_size - kernel_size, kernel_size); + for (i_in_channels = 0; i_in_channels < in_channels; i_in_channels++) { + OAC_COPY(hAdaConv->history + i_in_channels*kernel_size, + p_input + i_in_channels*(frame_size + kernel_size) + frame_size - kernel_size, kernel_size); } - OPUS_COPY(hAdaConv->last_kernel, kernel_buffer, kernel_size * in_channels * out_channels); + OAC_COPY(hAdaConv->last_kernel, kernel_buffer, kernel_size*in_channels*out_channels); } -void adacomb_process_frame( +void oaci_adacomb_process_frame( AdaCombState* hAdaComb, float *x_out, const float *x_in, @@ -258,9 +241,7 @@ void adacomb_process_frame( float filter_gain_b, float log_gain_limit, float *window, - int arch -) -{ + int arch) { float output_buffer[ADACOMB_MAX_FRAME_SIZE]; float output_buffer_last[ADACOMB_MAX_FRAME_SIZE]; float kernel_buffer[ADACOMB_MAX_KERNEL_SIZE]; @@ -273,18 +254,18 @@ void adacomb_process_frame( (void) feature_dim; /* ToDo: figure out whether we might need this information */ - OPUS_CLEAR(output_buffer, ADACOMB_MAX_FRAME_SIZE); - OPUS_CLEAR(kernel_buffer, ADACOMB_MAX_KERNEL_SIZE); - OPUS_CLEAR(input_buffer, ADACOMB_MAX_FRAME_SIZE + ADACOMB_MAX_LAG + ADACOMB_MAX_KERNEL_SIZE); + OAC_CLEAR(output_buffer, ADACOMB_MAX_FRAME_SIZE); + OAC_CLEAR(kernel_buffer, ADACOMB_MAX_KERNEL_SIZE); + OAC_CLEAR(input_buffer, ADACOMB_MAX_FRAME_SIZE + ADACOMB_MAX_LAG + ADACOMB_MAX_KERNEL_SIZE); - OPUS_COPY(input_buffer, hAdaComb->history, kernel_size + ADACOMB_MAX_LAG); - OPUS_COPY(input_buffer + kernel_size + ADACOMB_MAX_LAG, x_in, frame_size); + OAC_COPY(input_buffer, hAdaComb->history, kernel_size + ADACOMB_MAX_LAG); + OAC_COPY(input_buffer + kernel_size + ADACOMB_MAX_LAG, x_in, frame_size); p_input = input_buffer + kernel_size + ADACOMB_MAX_LAG; /* calculate new kernel and new gain */ - compute_generic_dense(kernel_layer, kernel_buffer, features, ACTIVATION_LINEAR, arch); - compute_generic_dense(gain_layer, &gain, features, ACTIVATION_RELU, arch); - compute_generic_dense(global_gain_layer, &global_gain, features, ACTIVATION_TANH, arch); + oaci_compute_generic_dense(kernel_layer, kernel_buffer, features, ACTIVATION_LINEAR, arch); + oaci_compute_generic_dense(gain_layer, &gain, features, ACTIVATION_RELU, arch); + oaci_compute_generic_dense(global_gain_layer, &global_gain, features, ACTIVATION_TANH, arch); #ifdef DEBUG_NNDSP print_float_vector("features", features, feature_dim); print_float_vector("adacomb_kernel_raw", kernel_buffer, kernel_size); @@ -292,51 +273,52 @@ void adacomb_process_frame( print_float_vector("adacomb_global_gain_raw", &global_gain, 1); #endif gain = exp(log_gain_limit - gain); - global_gain = exp(filter_gain_a * global_gain + filter_gain_b); - scale_kernel(kernel_buffer, 1, 1, kernel_size, &gain); + global_gain = exp(filter_gain_a*global_gain + filter_gain_b); + oaci_scale_kernel(kernel_buffer, 1, 1, kernel_size, &gain); #ifdef DEBUG_NNDSP print_float_vector("adacomb_kernel", kernel_buffer, kernel_size); print_float_vector("adacomb_gain", &gain, 1); #endif - OPUS_CLEAR(kernel, ADACOMB_MAX_KERNEL_SIZE); - OPUS_CLEAR(last_kernel, ADACOMB_MAX_KERNEL_SIZE); - OPUS_COPY(kernel, kernel_buffer, kernel_size); - OPUS_COPY(last_kernel, hAdaComb->last_kernel, kernel_size); + OAC_CLEAR(kernel, ADACOMB_MAX_KERNEL_SIZE); + OAC_CLEAR(last_kernel, ADACOMB_MAX_KERNEL_SIZE); + OAC_COPY(kernel, kernel_buffer, kernel_size); + OAC_COPY(last_kernel, hAdaComb->last_kernel, kernel_size); - celt_pitch_xcorr(last_kernel, &p_input[- left_padding - hAdaComb->last_pitch_lag], output_buffer_last, ADACOMB_MAX_KERNEL_SIZE, overlap_size, arch); + oaci_celt_pitch_xcorr(last_kernel, &p_input[-left_padding - hAdaComb->last_pitch_lag], output_buffer_last, + ADACOMB_MAX_KERNEL_SIZE, overlap_size, arch); - celt_pitch_xcorr(kernel, &p_input[- left_padding - pitch_lag], output_buffer, ADACOMB_MAX_KERNEL_SIZE, frame_size, arch); - for (i_sample = 0; i_sample < overlap_size; i_sample++) - { - output_buffer[i_sample] = hAdaComb->last_global_gain * window[i_sample] * output_buffer_last[i_sample] + global_gain * (1.f - window[i_sample]) * output_buffer[i_sample]; + oaci_celt_pitch_xcorr(kernel, &p_input[-left_padding - pitch_lag], output_buffer, ADACOMB_MAX_KERNEL_SIZE, frame_size, + arch); + for (i_sample = 0; i_sample < overlap_size; i_sample++) { + output_buffer[i_sample] = hAdaComb->last_global_gain*window[i_sample]*output_buffer_last[i_sample] + + global_gain*(1.f - window[i_sample])*output_buffer[i_sample]; } - for (i_sample = 0; i_sample < overlap_size; i_sample++) - { - output_buffer[i_sample] += (window[i_sample] * hAdaComb->last_global_gain + (1.f - window[i_sample]) * global_gain) * p_input[i_sample]; + for (i_sample = 0; i_sample < overlap_size; i_sample++) { + output_buffer[i_sample] += (window[i_sample]*hAdaComb->last_global_gain + (1.f - window[i_sample])*global_gain) + *p_input[i_sample]; } - for (i_sample = overlap_size; i_sample < frame_size; i_sample++) - { - output_buffer[i_sample] = global_gain * (output_buffer[i_sample] + p_input[i_sample]); + for (i_sample = overlap_size; i_sample < frame_size; i_sample++) { + output_buffer[i_sample] = global_gain*(output_buffer[i_sample] + p_input[i_sample]); } - OPUS_COPY(x_out, output_buffer, frame_size); + OAC_COPY(x_out, output_buffer, frame_size); #ifdef DEBUG_NNDSP print_float_vector("x_out", x_out, frame_size); #endif /* buffer update */ - OPUS_COPY(hAdaComb->last_kernel, kernel_buffer, kernel_size); - OPUS_COPY(hAdaComb->history, p_input + frame_size - kernel_size - ADACOMB_MAX_LAG, kernel_size + ADACOMB_MAX_LAG); + OAC_COPY(hAdaComb->last_kernel, kernel_buffer, kernel_size); + OAC_COPY(hAdaComb->history, p_input + frame_size - kernel_size - ADACOMB_MAX_LAG, kernel_size + ADACOMB_MAX_LAG); hAdaComb->last_pitch_lag = pitch_lag; hAdaComb->last_global_gain = global_gain; } -void adashape_process_frame( +void oaci_adashape_process_frame( AdaShapeState *hAdaShape, float *x_out, const float *x_in, @@ -348,43 +330,38 @@ void adashape_process_frame( int frame_size, int avg_pool_k, int interpolate_k, - int arch -) -{ + int arch) { float in_buffer[ADASHAPE_MAX_INPUT_DIM + ADASHAPE_MAX_FRAME_SIZE]; float out_buffer[ADASHAPE_MAX_FRAME_SIZE]; float tmp_buffer[ADASHAPE_MAX_FRAME_SIZE]; int i, k; int tenv_size; - int hidden_dim = frame_size / interpolate_k; + int hidden_dim = frame_size/interpolate_k; float mean; float *tenv; - float f = 1.0f / avg_pool_k; + float f = 1.0f/avg_pool_k; - celt_assert(frame_size % avg_pool_k == 0); - celt_assert(frame_size % interpolate_k == 0); - celt_assert(feature_dim + frame_size / avg_pool_k + 1 < ADASHAPE_MAX_INPUT_DIM); + celt_assert(frame_size%avg_pool_k == 0); + celt_assert(frame_size%interpolate_k == 0); + celt_assert(feature_dim + frame_size/avg_pool_k + 1 < ADASHAPE_MAX_INPUT_DIM); - tenv_size = frame_size / avg_pool_k; + tenv_size = frame_size/avg_pool_k; tenv = in_buffer + feature_dim; - OPUS_CLEAR(tenv, tenv_size + 1); + OAC_CLEAR(tenv, tenv_size + 1); - OPUS_COPY(in_buffer, features, feature_dim); + OAC_COPY(in_buffer, features, feature_dim); /* calculate temporal envelope */ mean = 0; - for (i = 0; i < tenv_size; i++) - { - for (k = 0; k < avg_pool_k; k++) - { - tenv[i] += fabs(x_in[i * avg_pool_k + k]); + for (i = 0; i < tenv_size; i++) { + for (k = 0; k < avg_pool_k; k++) { + tenv[i] += fabs(x_in[i*avg_pool_k + k]); } - tenv[i] = celt_log(tenv[i] * f + 1.52587890625e-05f); + tenv[i] = celt_log(tenv[i]*f + 1.52587890625e-05f); mean += tenv[i]; } mean /= tenv_size; - for (i = 0; i < tenv_size; i++) - { + for (i = 0; i < tenv_size; i++) { tenv[i] -= mean; } tenv[tenv_size] = mean; @@ -396,33 +373,33 @@ void adashape_process_frame( #ifdef DEBUG_NNDSP print_float_vector("alpha1_in", in_buffer, feature_dim + tenv_size + 1); #endif - compute_generic_conv1d(alpha1f, out_buffer, hAdaShape->conv_alpha1f_state, in_buffer, feature_dim, ACTIVATION_LINEAR, arch); - compute_generic_conv1d(alpha1t, tmp_buffer, hAdaShape->conv_alpha1t_state, tenv, tenv_size + 1, ACTIVATION_LINEAR, arch); + oaci_compute_generic_conv1d(alpha1f, out_buffer, hAdaShape->conv_alpha1f_state, in_buffer, feature_dim, + ACTIVATION_LINEAR, arch); + oaci_compute_generic_conv1d(alpha1t, tmp_buffer, hAdaShape->conv_alpha1t_state, tenv, tenv_size + 1, ACTIVATION_LINEAR, + arch); #ifdef DEBUG_NNDSP print_float_vector("alpha1_out", out_buffer, frame_size); #endif /* compute leaky ReLU by hand. */ - for (i = 0; i < hidden_dim; i ++) - { + for (i = 0; i < hidden_dim; i++) { float tmp = out_buffer[i] + tmp_buffer[i]; - in_buffer[i] = tmp >= 0 ? tmp : 0.2 * tmp; + in_buffer[i] = tmp >= 0 ? tmp : 0.2*tmp; } #ifdef DEBUG_NNDSP print_float_vector("post_alpha1", in_buffer, frame_size); #endif - compute_generic_conv1d(alpha2, tmp_buffer, hAdaShape->conv_alpha2_state, in_buffer, hidden_dim, ACTIVATION_LINEAR, arch); + oaci_compute_generic_conv1d(alpha2, tmp_buffer, hAdaShape->conv_alpha2_state, in_buffer, hidden_dim, ACTIVATION_LINEAR, + arch); #ifdef DEBUG_NNDSP print_float_vector("alpha2_out", tmp_buffer, hidden_dim); #endif /* upsampling by linear interpolation */ - for (i = 0; i < hidden_dim; i ++) - { - for (k = 0; k < interpolate_k; k++) - { - float alpha = (float) (k + 1) / interpolate_k; - out_buffer[i * interpolate_k + k] = alpha * tmp_buffer[i] + (1.f - alpha) * hAdaShape->interpolate_state[0]; + for (i = 0; i < hidden_dim; i++) { + for (k = 0; k < interpolate_k; k++) { + float alpha = (float) (k + 1)/interpolate_k; + out_buffer[i*interpolate_k + k] = alpha*tmp_buffer[i] + (1.f - alpha)*hAdaShape->interpolate_state[0]; } hAdaShape->interpolate_state[0] = tmp_buffer[i]; } @@ -431,11 +408,10 @@ void adashape_process_frame( print_float_vector("interpolate_out", out_buffer, frame_size); #endif - compute_activation(out_buffer, out_buffer, frame_size, ACTIVATION_EXP, arch); + oaci_compute_activation(out_buffer, out_buffer, frame_size, ACTIVATION_EXP, arch); /* shape signal */ - for (i = 0; i < frame_size; i ++) - { - x_out[i] = out_buffer[i] * x_in[i]; + for (i = 0; i < frame_size; i++) { + x_out[i] = out_buffer[i]*x_in[i]; } } diff --git a/dnn/nndsp.h b/dnn/nndsp.h index 1bce70d10..5533f7894 100644 --- a/dnn/nndsp.h +++ b/dnn/nndsp.h @@ -23,12 +23,12 @@ 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. -*/ + */ #ifndef NNDSP_H #define NNDSP_H -#include "opus_types.h" +#include "oac_types.h" #include "nnet.h" #include @@ -49,15 +49,15 @@ /*#define DEBUG_NNDSP*/ #ifdef DEBUG_NNDSP -#include +# include #endif void print_float_vector(const char* name, const float *vec, int length); typedef struct { - float history[ADACONV_MAX_KERNEL_SIZE * ADACONV_MAX_INPUT_CHANNELS]; - float last_kernel[ADACONV_MAX_KERNEL_SIZE * ADACONV_MAX_INPUT_CHANNELS * ADACONV_MAX_OUTPUT_CHANNELS]; + float history[ADACONV_MAX_KERNEL_SIZE*ADACONV_MAX_INPUT_CHANNELS]; + float last_kernel[ADACONV_MAX_KERNEL_SIZE*ADACONV_MAX_INPUT_CHANNELS*ADACONV_MAX_OUTPUT_CHANNELS]; float last_gain; } AdaConvState; @@ -77,15 +77,15 @@ typedef struct { float interpolate_state[1]; } AdaShapeState; -void init_adaconv_state(AdaConvState *hAdaConv); +void oaci_init_adaconv_state(AdaConvState *hAdaConv); -void init_adacomb_state(AdaCombState *hAdaComb); +void oaci_init_adacomb_state(AdaCombState *hAdaComb); -void init_adashape_state(AdaShapeState *hAdaShape); +void oaci_init_adashape_state(AdaShapeState *hAdaShape); -void compute_overlap_window(float *window, int overlap_size); +void oaci_compute_overlap_window(float *window, int overlap_size); -void adaconv_process_frame( +void oaci_adaconv_process_frame( AdaConvState* hAdaConv, float *x_out, const float *x_in, @@ -103,10 +103,9 @@ void adaconv_process_frame( float filter_gain_b, float shape_gain, float *window, - int arch -); + int arch); -void adacomb_process_frame( +void oaci_adacomb_process_frame( AdaCombState* hAdaComb, float *x_out, const float *x_in, @@ -124,10 +123,9 @@ void adacomb_process_frame( float filter_gain_b, float log_gain_limit, float *window, - int arch -); + int arch); -void adashape_process_frame( +void oaci_adashape_process_frame( AdaShapeState *hAdaShape, float *x_out, const float *x_in, @@ -139,7 +137,6 @@ void adashape_process_frame( int frame_size, int avg_pool_k, int interpolate_k, - int arch -); + int arch); #endif diff --git a/dnn/nnet.c b/dnn/nnet.c index eab08d219..fd8843b7f 100644 --- a/dnn/nnet.c +++ b/dnn/nnet.c @@ -24,15 +24,15 @@ 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" +# include "config.h" #endif #include #include -#include "opus_types.h" +#include "oac_types.h" #include "arch.h" #include "nnet.h" #include "dred_rdovae_constants.h" @@ -42,112 +42,112 @@ #include "vec.h" #ifdef ENABLE_OSCE -#include "osce.h" +# include "osce.h" #endif #ifdef NO_OPTIMIZATIONS -#if defined(_MSC_VER) -#pragma message ("Compiling without any vectorization. This code will be very slow") -#else -#warning Compiling without any vectorization. This code will be very slow -#endif +# if defined(_MSC_VER) +# pragma message ("Compiling without any vectorization. This code will be very slow") +# else +# warning Compiling without any vectorization. This code will be very slow +# endif #endif #define SOFTMAX_HACK -void compute_generic_dense(const LinearLayer *layer, float *output, const float *input, int activation, int arch) -{ - compute_linear(layer, output, input, arch); - compute_activation(output, output, layer->nb_outputs, activation, arch); +void oaci_compute_generic_dense(const LinearLayer *layer, float *output, const float *input, int activation, int arch) { + oaci_compute_linear(layer, output, input, arch); + oaci_compute_activation(output, output, layer->nb_outputs, activation, arch); } #ifdef ENABLE_OSCE -#ifdef ENABLE_OSCE_BWE -#define MAX_RNN_NEURONS_ALL IMAX(IMAX(IMAX(IMAX(FARGAN_MAX_RNN_NEURONS, PLC_MAX_RNN_UNITS), DRED_MAX_RNN_NEURONS), OSCE_MAX_RNN_NEURONS), OSCE_BWE_MAX_RNN_NEURONS) -#else -#define MAX_RNN_NEURONS_ALL IMAX(IMAX(IMAX(FARGAN_MAX_RNN_NEURONS, PLC_MAX_RNN_UNITS), DRED_MAX_RNN_NEURONS), OSCE_MAX_RNN_NEURONS) -#endif +# ifdef ENABLE_OSCE_BWE +# define MAX_RNN_NEURONS_ALL IMAX(IMAX(IMAX(IMAX(FARGAN_MAX_RNN_NEURONS, PLC_MAX_RNN_UNITS), DRED_MAX_RNN_NEURONS), \ + OSCE_MAX_RNN_NEURONS), OSCE_BWE_MAX_RNN_NEURONS) +# else +# define MAX_RNN_NEURONS_ALL IMAX(IMAX(IMAX(FARGAN_MAX_RNN_NEURONS, PLC_MAX_RNN_UNITS), DRED_MAX_RNN_NEURONS), \ + OSCE_MAX_RNN_NEURONS) +# endif #else -#define MAX_RNN_NEURONS_ALL IMAX(IMAX(FARGAN_MAX_RNN_NEURONS, PLC_MAX_RNN_UNITS), DRED_MAX_RNN_NEURONS) +# define MAX_RNN_NEURONS_ALL IMAX(IMAX(FARGAN_MAX_RNN_NEURONS, PLC_MAX_RNN_UNITS), DRED_MAX_RNN_NEURONS) #endif -void compute_generic_gru(const LinearLayer *input_weights, const LinearLayer *recurrent_weights, float *state, const float *in, int arch) -{ - int i; - int N; - float zrh[3*MAX_RNN_NEURONS_ALL]; - float recur[3*MAX_RNN_NEURONS_ALL]; - float *z; - float *r; - float *h; - celt_assert(3*recurrent_weights->nb_inputs == recurrent_weights->nb_outputs); - celt_assert(input_weights->nb_outputs == recurrent_weights->nb_outputs); - N = recurrent_weights->nb_inputs; - z = zrh; - r = &zrh[N]; - h = &zrh[2*N]; - celt_assert(recurrent_weights->nb_outputs <= 3*MAX_RNN_NEURONS_ALL); - celt_assert(in != state); - compute_linear(input_weights, zrh, in, arch); - compute_linear(recurrent_weights, recur, state, arch); - for (i=0;i<2*N;i++) - zrh[i] += recur[i]; - compute_activation(zrh, zrh, 2*N, ACTIVATION_SIGMOID, arch); - for (i=0;inb_inputs == recurrent_weights->nb_outputs); + celt_assert(input_weights->nb_outputs == recurrent_weights->nb_outputs); + N = recurrent_weights->nb_inputs; + z = zrh; + r = &zrh[N]; + h = &zrh[2*N]; + celt_assert(recurrent_weights->nb_outputs <= 3*MAX_RNN_NEURONS_ALL); + celt_assert(in != state); + oaci_compute_linear(input_weights, zrh, in, arch); + oaci_compute_linear(recurrent_weights, recur, state, arch); + for (i = 0; i < 2*N; i++) + zrh[i] += recur[i]; + oaci_compute_activation(zrh, zrh, 2*N, ACTIVATION_SIGMOID, arch); + for (i = 0; i < N; i++) + h[i] += recur[2*N + i]*r[i]; + oaci_compute_activation(h, h, N, ACTIVATION_TANH, arch); + for (i = 0; i < N; i++) + h[i] = z[i]*state[i] + (1 - z[i])*h[i]; + for (i = 0; i < N; i++) + state[i] = h[i]; } -void compute_glu(const LinearLayer *layer, float *output, const float *input, int arch) -{ - int i; - float act2[MAX_INPUTS]; - celt_assert(layer->nb_inputs == layer->nb_outputs); - compute_linear(layer, act2, input, arch); - compute_activation(act2, act2, layer->nb_outputs, ACTIVATION_SIGMOID, arch); - if (input == output) { - /* Give a vectorization hint to the compiler for the in-place case. */ - for (i=0;inb_outputs;i++) output[i] = output[i]*act2[i]; - } else { - for (i=0;inb_outputs;i++) output[i] = input[i]*act2[i]; - } +void oaci_compute_glu(const LinearLayer *layer, float *output, const float *input, int arch) { + int i; + float act2[MAX_INPUTS]; + celt_assert(layer->nb_inputs == layer->nb_outputs); + oaci_compute_linear(layer, act2, input, arch); + oaci_compute_activation(act2, act2, layer->nb_outputs, ACTIVATION_SIGMOID, arch); + if (input == output) { + /* Give a vectorization hint to the compiler for the in-place case. */ + for (i = 0; i < layer->nb_outputs; i++) output[i] = output[i]*act2[i]; + } else { + for (i = 0; i < layer->nb_outputs; i++) output[i] = input[i]*act2[i]; + } } #define MAX_CONV_INPUTS_ALL IMAX(DRED_MAX_CONV_INPUTS, 1024) -void compute_generic_conv1d(const LinearLayer *layer, float *output, float *mem, const float *input, int input_size, int activation, int arch) -{ - float tmp[MAX_CONV_INPUTS_ALL]; - celt_assert(input != output); - celt_assert(layer->nb_inputs <= MAX_CONV_INPUTS_ALL); - if (layer->nb_inputs!=input_size) OPUS_COPY(tmp, mem, layer->nb_inputs-input_size); - OPUS_COPY(&tmp[layer->nb_inputs-input_size], input, input_size); - compute_linear(layer, output, tmp, arch); - compute_activation(output, output, layer->nb_outputs, activation, arch); - if (layer->nb_inputs!=input_size) OPUS_COPY(mem, &tmp[input_size], layer->nb_inputs-input_size); +void oaci_compute_generic_conv1d(const LinearLayer *layer, float *output, float *mem, const float *input, int input_size, + int activation, int arch) { + float tmp[MAX_CONV_INPUTS_ALL]; + celt_assert(input != output); + celt_assert(layer->nb_inputs <= MAX_CONV_INPUTS_ALL); + if (layer->nb_inputs != input_size) OAC_COPY(tmp, mem, layer->nb_inputs - input_size); + OAC_COPY(&tmp[layer->nb_inputs - input_size], input, input_size); + oaci_compute_linear(layer, output, tmp, arch); + oaci_compute_activation(output, output, layer->nb_outputs, activation, arch); + if (layer->nb_inputs != input_size) OAC_COPY(mem, &tmp[input_size], layer->nb_inputs - input_size); } -void compute_generic_conv1d_dilation(const LinearLayer *layer, float *output, float *mem, const float *input, int input_size, int dilation, int activation, int arch) -{ - float tmp[MAX_CONV_INPUTS_ALL]; - int ksize = layer->nb_inputs/input_size; - int i; - celt_assert(input != output); - celt_assert(layer->nb_inputs <= MAX_CONV_INPUTS_ALL); - if (dilation==1) OPUS_COPY(tmp, mem, layer->nb_inputs-input_size); - else for (i=0;inb_inputs-input_size], input, input_size); - compute_linear(layer, output, tmp, arch); - compute_activation(output, output, layer->nb_outputs, activation, arch); - if (dilation==1) OPUS_COPY(mem, &tmp[input_size], layer->nb_inputs-input_size); - else { - OPUS_COPY(mem, &mem[input_size], input_size*dilation*(ksize-1)-input_size); - OPUS_COPY(&mem[input_size*dilation*(ksize-1)-input_size], input, input_size); - } +void oaci_compute_generic_conv1d_dilation(const LinearLayer *layer, float *output, float *mem, const float *input, + int input_size, int dilation, int activation, int arch) { + float tmp[MAX_CONV_INPUTS_ALL]; + int ksize = layer->nb_inputs/input_size; + int i; + celt_assert(input != output); + celt_assert(layer->nb_inputs <= MAX_CONV_INPUTS_ALL); + if (dilation == 1) OAC_COPY(tmp, mem, layer->nb_inputs - input_size); + else for (i = 0; i < ksize - 1; i++) OAC_COPY(&tmp[i*input_size], &mem[i*input_size*dilation], input_size); + OAC_COPY(&tmp[layer->nb_inputs - input_size], input, input_size); + oaci_compute_linear(layer, output, tmp, arch); + oaci_compute_activation(output, output, layer->nb_outputs, activation, arch); + if (dilation == 1) OAC_COPY(mem, &tmp[input_size], layer->nb_inputs - input_size); + else { + OAC_COPY(mem, &mem[input_size], input_size*dilation*(ksize - 1) - input_size); + OAC_COPY(&mem[input_size*dilation*(ksize - 1) - input_size], input, input_size); + } } diff --git a/dnn/nnet.h b/dnn/nnet.h index 8a44170b1..867ab5e77 100644 --- a/dnn/nnet.h +++ b/dnn/nnet.h @@ -23,13 +23,13 @@ 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. -*/ + */ #ifndef NNET_H_ #define NNET_H_ #include -#include "opus_types.h" +#include "oac_types.h" #define ACTIVATION_LINEAR 0 #define ACTIVATION_SIGMOID 1 @@ -42,10 +42,10 @@ #define WEIGHT_BLOB_VERSION 0 #define WEIGHT_BLOCK_SIZE 64 typedef struct { - const char *name; - int type; - int size; - const void *data; + const char *name; + int type; + int size; + const void *data; } WeightArray; #define WEIGHT_TYPE_float 0 @@ -54,112 +54,122 @@ typedef struct { #define WEIGHT_TYPE_int8 3 typedef struct { - char head[4]; - int version; - int type; - int size; - int block_size; - char name[44]; + char head[4]; + int version; + int type; + int size; + int block_size; + char name[44]; } WeightHead; /* Generic sparse affine transformation. */ typedef struct { - const float *bias; - const float *subias; - const opus_int8 *weights; - const float *float_weights; - const int *weights_idx; - const float *diag; - const float *scale; - int nb_inputs; - int nb_outputs; + const float *bias; + const float *subias; + const oac_int8 *weights; + const float *float_weights; + const int *weights_idx; + const float *diag; + const float *scale; + int nb_inputs; + int nb_outputs; } LinearLayer; /* Generic sparse affine transformation. */ typedef struct { - const float *bias; - const float *float_weights; - int in_channels; - int out_channels; - int ktime; - int kheight; + const float *bias; + const float *float_weights; + int in_channels; + int out_channels; + int ktime; + int kheight; } Conv2dLayer; -void compute_generic_dense(const LinearLayer *layer, float *output, const float *input, int activation, int arch); -void compute_generic_gru(const LinearLayer *input_weights, const LinearLayer *recurrent_weights, float *state, const float *in, int arch); -void compute_generic_conv1d(const LinearLayer *layer, float *output, float *mem, const float *input, int input_size, int activation, int arch); -void compute_generic_conv1d_dilation(const LinearLayer *layer, float *output, float *mem, const float *input, int input_size, int dilation, int activation, int arch); -void compute_glu(const LinearLayer *layer, float *output, const float *input, int arch); +void oaci_compute_generic_dense(const LinearLayer *layer, float *output, const float *input, int activation, int arch); +void oaci_compute_generic_gru(const LinearLayer *input_weights, const LinearLayer *recurrent_weights, float *state, + const float *in, int arch); +void oaci_compute_generic_conv1d(const LinearLayer *layer, float *output, float *mem, const float *input, int input_size, + int activation, int arch); +void oaci_compute_generic_conv1d_dilation(const LinearLayer *layer, float *output, float *mem, const float *input, + int input_size, int dilation, int activation, int arch); +void oaci_compute_glu(const LinearLayer *layer, float *output, const float *input, int arch); void compute_gated_activation(const LinearLayer *layer, float *output, const float *input, int activation, int arch); -int parse_weights(WeightArray **list, const void *data, int len); +int oaci_parse_weights(WeightArray **list, const void *data, int len); extern const WeightArray lpcnet_arrays[]; -extern const WeightArray plcmodel_arrays[]; -extern const WeightArray rdovaeenc_arrays[]; -extern const WeightArray rdovaedec_arrays[]; +extern const WeightArray oaci_plcmodel_arrays[]; +extern const WeightArray oaci_rdovaeenc_arrays[]; +extern const WeightArray oaci_rdovaedec_arrays[]; extern const WeightArray fwgan_arrays[]; -extern const WeightArray fargan_arrays[]; -extern const WeightArray pitchdnn_arrays[]; -extern const WeightArray lossgen_arrays[]; -extern const WeightArray lacelayers_arrays[]; -extern const WeightArray nolacelayers_arrays[]; -extern const WeightArray bbwenetlayers_arrays[]; - -int linear_init(LinearLayer *layer, const WeightArray *arrays, - const char *bias, - const char *subias, - const char *weights, - const char *float_weights, - const char *weights_idx, - const char *diag, - const char *scale, - int nb_inputs, - int nb_outputs); - -int conv2d_init(Conv2dLayer *layer, const WeightArray *arrays, - const char *bias, - const char *float_weights, - int in_channels, - int out_channels, - int ktime, - int kheight); - - -void compute_linear_c(const LinearLayer *linear, float *out, const float *in); -void compute_activation_c(float *output, const float *input, int N, int activation); -void compute_conv2d_c(const Conv2dLayer *conv, float *out, float *mem, const float *in, int height, int hstride, int activation); - - -#if defined(OPUS_ARM_MAY_HAVE_DOTPROD) || defined(OPUS_ARM_MAY_HAVE_NEON_INTR) -#include "arm/dnn_arm.h" +extern const WeightArray oaci_fargan_arrays[]; +extern const WeightArray oaci_pitchdnn_arrays[]; +extern const WeightArray oaci_lossgen_arrays[]; +extern const WeightArray oaci_lacelayers_arrays[]; +extern const WeightArray oaci_nolacelayers_arrays[]; +extern const WeightArray oaci_bbwenetlayers_arrays[]; + +int oaci_linear_init(LinearLayer *layer, const WeightArray *arrays, + const char *bias, + const char *subias, + const char *weights, + const char *float_weights, + const char *weights_idx, + const char *diag, + const char *scale, + int nb_inputs, + int nb_outputs); + +int oaci_conv2d_init(Conv2dLayer *layer, const WeightArray *arrays, + const char *bias, + const char *float_weights, + int in_channels, + int out_channels, + int ktime, + int kheight); + + +void oaci_compute_linear_c(const LinearLayer *linear, float *out, const float *in); +void oaci_compute_activation_c(float *output, const float *input, int N, int activation); +void oaci_compute_conv2d_c(const Conv2dLayer *conv, float *out, float *mem, const float *in, int height, int hstride, + int activation); + + +#if defined(OAC_ARM_MAY_HAVE_DOTPROD) || defined(OAC_ARM_MAY_HAVE_NEON_INTR) +# include "arm/dnn_arm.h" #endif -#if defined(OPUS_X86_MAY_HAVE_SSE2) -#include "x86/dnn_x86.h" +#if defined(OAC_X86_MAY_HAVE_SSE2) +# include "x86/dnn_x86.h" #endif #ifndef OVERRIDE_COMPUTE_LINEAR -#define compute_linear(linear, out, in, arch) ((void)(arch),compute_linear_c(linear, out, in)) +# define oaci_compute_linear(linear, out, in, arch) ((void)(arch), oaci_compute_linear_c(linear, out, in)) #endif #ifndef OVERRIDE_COMPUTE_ACTIVATION -#define compute_activation(output, input, N, activation, arch) ((void)(arch),compute_activation_c(output, input, N, activation)) +# define oaci_compute_activation(output, input, N, activation, arch) ((void)(arch), \ + oaci_compute_activation_c(output, input, N, activation)) #endif #ifndef OVERRIDE_COMPUTE_CONV2D -#define compute_conv2d(conv, out, mem, in, height, hstride, activation, arch) ((void)(arch),compute_conv2d_c(conv, out, mem, in, height, hstride, activation)) +# define oaci_compute_conv2d(conv, out, mem, in, height, hstride, activation, arch) ((void)(arch), \ + oaci_compute_conv2d_c(conv, out, mem, in, \ + height, hstride, activation)) #endif -#if defined(__x86_64__) && !defined(OPUS_X86_MAY_HAVE_SSE4_1) && !defined(OPUS_X86_MAY_HAVE_AVX2) &&!defined(SUPPRESS_PERF_WARNINGS) -#if defined(_MSC_VER) -#pragma message ("Only SSE and SSE2 are available. On newer machines, enable SSSE3/AVX/AVX2 to get better performance") -#else -#warning "Only SSE and SSE2 are available. On newer machines, enable SSSE3/AVX/AVX2 using -march= to get better performance" -#endif +#if defined(__x86_64__) && !defined(OAC_X86_MAY_HAVE_SSE4_1) && !defined(OAC_X86_MAY_HAVE_AVX2) \ + && !defined(SUPPRESS_PERF_WARNINGS) +# if defined(_MSC_VER) +# pragma \ + message ("Only SSE and SSE2 are available. On newer machines, enable SSSE3/AVX/AVX2 to get better performance") +# else +# warning \ + "Only SSE and SSE2 are available. On newer machines, enable SSSE3/AVX/AVX2 using -march= to get better performance" +# endif #endif diff --git a/dnn/nnet_arch.h b/dnn/nnet_arch.h index a855250ad..433d78a4f 100644 --- a/dnn/nnet_arch.h +++ b/dnn/nnet_arch.h @@ -23,7 +23,7 @@ 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. -*/ + */ #ifndef NNET_ARCH_H #define NNET_ARCH_H @@ -33,93 +33,89 @@ #include "os_support.h" #include "vec.h" -#define CAT_SUFFIX2(a,b) a ## b -#define CAT_SUFFIX(a,b) CAT_SUFFIX2(a, b) +#define CAT_SUFFIX2(a, b) a ## b +#define CAT_SUFFIX(a, b) CAT_SUFFIX2(a, b) #define RTCD_SUF(name) CAT_SUFFIX(name, RTCD_ARCH) /* Force vectorization on for DNN code because some of the loops rely on compiler vectorization rather than explicitly using intrinsics. */ -#if OPUS_GNUC_PREREQ(5,1) -#define GCC_POP_OPTIONS -#pragma GCC push_options -#pragma GCC optimize("tree-vectorize") +#if OAC_GNUC_PREREQ(5, 1) +# define GCC_POP_OPTIONS +# pragma GCC push_options +# pragma GCC optimize("tree-vectorize") #endif #define MAX_ACTIVATIONS (4096) -static OPUS_INLINE void vec_swish(float *y, const float *x, int N) -{ - int i; - float tmp[MAX_ACTIVATIONS]; - celt_assert(N <= MAX_ACTIVATIONS); - vec_sigmoid(tmp, x, N); - for (i=0;inb_inputs; N = linear->nb_outputs; if (linear->float_weights != NULL) { - if (linear->weights_idx != NULL) sparse_sgemv8x4(out, linear->float_weights, linear->weights_idx, N, in); - else sgemv(out, linear->float_weights, N, M, N, in); + if (linear->weights_idx != NULL) oaci_sparse_sgemv8x4(out, linear->float_weights, linear->weights_idx, N, in); + else oaci_sgemv(out, linear->float_weights, N, M, N, in); } else if (linear->weights != NULL) { - if (linear->weights_idx != NULL) sparse_cgemv8x4(out, linear->weights, linear->weights_idx, linear->scale, N, M, in); - else cgemv8x4(out, linear->weights, linear->scale, N, M, in); - /* Only use SU biases on for integer matrices on SU archs. */ + if (linear->weights_idx != NULL) oaci_sparse_cgemv8x4(out, linear->weights, linear->weights_idx, linear->scale, N, M, + in); + else oaci_cgemv8x4(out, linear->weights, linear->scale, N, M, in); + /* Only use SU biases on for integer matrices on SU archs. */ #ifdef USE_SU_BIAS - bias = linear->subias; + bias = linear->subias; #endif - } - else OPUS_CLEAR(out, N); + } else OAC_CLEAR(out, N); if (bias != NULL) { - for (i=0;idiag) { - /* Diag is only used for GRU recurrent weights. */ - celt_assert(3*M == N); - for (i=0;idiag[i]*in[i]; - out[i+M] += linear->diag[i+M]*in[i]; - out[i+2*M] += linear->diag[i+2*M]*in[i]; - } + /* Diag is only used for GRU recurrent weights. */ + celt_assert(3*M == N); + for (i = 0; i < M; i++) { + out[i] += linear->diag[i]*in[i]; + out[i + M] += linear->diag[i + M]*in[i]; + out[i + 2*M] += linear->diag[i + 2*M]*in[i]; + } } } @@ -158,92 +154,103 @@ void RTCD_SUF(compute_linear_) (const LinearLayer *linear, float *out, const flo storing the output as [ out_channels x len2 ]. We assume that the output dimension along the ksize1 axis is 1, i.e. processing one frame at a time. */ -static void conv2d_float(float *out, const float *weights, int in_channels, int out_channels, int ktime, int kheight, const float *in, int height, int hstride) -{ - int i; - int in_stride; - in_stride = height+kheight-1; - for (i=0;iin_channels*(height+conv->kheight-1); + time_stride = conv->in_channels*(height + conv->kheight - 1); celt_assert(conv->ktime*time_stride <= MAX_CONV2D_INPUTS); - OPUS_COPY(in_buf, mem, (conv->ktime-1)*time_stride); - OPUS_COPY(&in_buf[(conv->ktime-1)*time_stride], in, time_stride); - OPUS_COPY(mem, &in_buf[time_stride], (conv->ktime-1)*time_stride); + OAC_COPY(in_buf, mem, (conv->ktime - 1)*time_stride); + OAC_COPY(&in_buf[(conv->ktime - 1)*time_stride], in, time_stride); + OAC_COPY(mem, &in_buf[time_stride], (conv->ktime - 1)*time_stride); bias = conv->bias; if (conv->kheight == 3 && conv->ktime == 3) - conv2d_3x3_float(out, conv->float_weights, conv->in_channels, conv->out_channels, in_buf, height, hstride); + oaci_conv2d_3x3_float(out, conv->float_weights, conv->in_channels, conv->out_channels, in_buf, height, hstride); else - conv2d_float(out, conv->float_weights, conv->in_channels, conv->out_channels, conv->ktime, conv->kheight, in_buf, height, hstride); + oaci_conv2d_float(out, conv->float_weights, conv->in_channels, conv->out_channels, conv->ktime, conv->kheight, + in_buf, height, hstride); if (bias != NULL) { - for (i=0;iout_channels;i++) { - int j; - for (j=0;jout_channels; i++) { + int j; + for (j = 0; j < height; j++) out[i*hstride + j] += bias[i]; + } } - for (i=0;iout_channels;i++) { - RTCD_SUF(compute_activation_)(&out[i*hstride], &out[i*hstride], height, activation); + for (i = 0; i < conv->out_channels; i++) { + RTCD_SUF(oaci_compute_activation_)(&out[i*hstride], &out[i*hstride], height, activation); } } #ifdef GCC_POP_OPTIONS -#pragma GCC pop_options +# pragma GCC pop_options #endif #endif diff --git a/dnn/nnet_default.c b/dnn/nnet_default.c index 4316f0fba..cb7180a44 100644 --- a/dnn/nnet_default.c +++ b/dnn/nnet_default.c @@ -23,10 +23,10 @@ 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" +# include "config.h" #endif diff --git a/dnn/osce.c b/dnn/osce.c index 5f2752cab..5640899ec 100644 --- a/dnn/osce.c +++ b/dnn/osce.c @@ -23,10 +23,10 @@ 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" +# include "config.h" #endif @@ -40,202 +40,210 @@ #include "mathops.h" /*#define OSCE_DEBUG*/ #ifdef OSCE_DEBUG -#include +# include /*#define WRITE_FEATURES*/ /*#define DEBUG_LACE*/ /*#define DEBUG_NOLACE*/ -#define DEBUG_BBWENET -#define FINIT(fid, name, mode) do{if (fid == NULL) {fid = fopen(name, mode);}} while(0) +# define DEBUG_BBWENET +# define FINIT(fid, name, mode) do {if (fid == NULL) {fid = fopen(name, mode);}} while (0) #endif #if 0 -#include -static void print_float_array(FILE *fid, const char *name, const float *array, int n) -{ +# include +static void print_float_array(FILE *fid, const char *name, const float *array, int n) { int i; - for (i = 0; i < n; i++) - { + for (i = 0; i < n; i++) { fprintf(fid, "%s[%d]: %f\n", name, i, array[i]); } } -static void print_int_array(FILE *fid, const char *name, const int *array, int n) -{ +static void print_int_array(FILE *fid, const char *name, const int *array, int n) { int i; - for (i = 0; i < n; i++) - { + for (i = 0; i < n; i++) { fprintf(fid, "%s[%d]: %d\n", name, i, array[i]); } } -static void print_int8_array(FILE *fid, const char *name, const opus_int8 *array, int n) -{ +static void print_int8_array(FILE *fid, const char *name, const oac_int8 *array, int n) { int i; - for (i = 0; i < n; i++) - { + for (i = 0; i < n; i++) { fprintf(fid, "%s[%d]: %d\n", name, i, array[i]); } } -static void print_linear_layer(FILE *fid, const char *name, LinearLayer *layer) -{ +static void print_linear_layer(FILE *fid, const char *name, LinearLayer *layer) { int i, n_in, n_out, n_total; char tmp[256]; n_in = layer->nb_inputs; n_out = layer->nb_outputs; - n_total = n_in * n_out; + n_total = n_in*n_out; fprintf(fid, "\nprinting layer %s...\n", name); fprintf(fid, "%s.nb_inputs: %d\n%s.nb_outputs: %d\n", name, n_in, name, n_out); - if (layer->bias !=NULL){} - if (layer->subias !=NULL){} - if (layer->weights !=NULL){} - if (layer->float_weights !=NULL){} + if (layer->bias != NULL) { + } + if (layer->subias != NULL) { + } + if (layer->weights != NULL) { + } + if (layer->float_weights != NULL) { + } - if (layer->bias != NULL) {sprintf(tmp, "%s.bias", name); print_float_array(fid, tmp, layer->bias, n_out);} - if (layer->subias != NULL) {sprintf(tmp, "%s.subias", name); print_float_array(fid, tmp, layer->subias, n_out);} - if (layer->weights != NULL) {sprintf(tmp, "%s.weights", name); print_int8_array(fid, tmp, layer->weights, n_total);} - if (layer->float_weights != NULL) {sprintf(tmp, "%s.float_weights", name); print_float_array(fid, tmp, layer->float_weights, n_total);} + if (layer->bias != NULL) { + sprintf(tmp, "%s.bias", name); print_float_array(fid, tmp, layer->bias, n_out); + } + if (layer->subias != NULL) { + sprintf(tmp, "%s.subias", name); print_float_array(fid, tmp, layer->subias, n_out); + } + if (layer->weights != NULL) { + sprintf(tmp, "%s.weights", name); print_int8_array(fid, tmp, layer->weights, n_total); + } + if (layer->float_weights != NULL) { + sprintf(tmp, "%s.float_weights", name); print_float_array(fid, tmp, layer->float_weights, n_total); + } /*if (layer->weights_idx != NULL) {sprintf(tmp, "%s.weights_idx", name); print_float_array(fid, tmp, layer->weights_idx, n_total);}*/ - if (layer->diag != NULL) {sprintf(tmp, "%s.diag", name); print_float_array(fid, tmp, layer->diag, n_in);} - if (layer->scale != NULL) {sprintf(tmp, "%s.scale", name); print_float_array(fid, tmp, layer->scale, n_out);} + if (layer->diag != NULL) { + sprintf(tmp, "%s.diag", name); print_float_array(fid, tmp, layer->diag, n_in); + } + if (layer->scale != NULL) { + sprintf(tmp, "%s.scale", name); print_float_array(fid, tmp, layer->scale, n_out); + } } #endif #ifdef ENABLE_OSCE_TRAINING_DATA -#include +# include #endif #define CLIP(a, min, max) (((a) < (min) ? (min) : (a)) > (max) ? (max) : (a)) -extern const WeightArray lacelayers_arrays[]; -extern const WeightArray nolacelayers_arrays[]; -extern const WeightArray bbwenetlayers_arrays[]; +extern const WeightArray oaci_lacelayers_arrays[]; +extern const WeightArray oaci_nolacelayers_arrays[]; +extern const WeightArray oaci_bbwenetlayers_arrays[]; /* LACE */ #ifndef DISABLE_LACE -static void compute_lace_numbits_embedding(float *emb, float numbits, int dim, float min_val, float max_val, int logscale) -{ +static void oaci_compute_lace_numbits_embedding(float *emb, float numbits, int dim, float min_val, float max_val, + int logscale) { float x; (void) dim; numbits = logscale ? log(numbits) : numbits; - x = CLIP(numbits, min_val, max_val) - (max_val + min_val) / 2; - - emb[0] = sin(x * LACE_NUMBITS_SCALE_0 - 0.5f); - emb[1] = sin(x * LACE_NUMBITS_SCALE_1 - 0.5f); - emb[2] = sin(x * LACE_NUMBITS_SCALE_2 - 0.5f); - emb[3] = sin(x * LACE_NUMBITS_SCALE_3 - 0.5f); - emb[4] = sin(x * LACE_NUMBITS_SCALE_4 - 0.5f); - emb[5] = sin(x * LACE_NUMBITS_SCALE_5 - 0.5f); - emb[6] = sin(x * LACE_NUMBITS_SCALE_6 - 0.5f); - emb[7] = sin(x * LACE_NUMBITS_SCALE_7 - 0.5f); + x = CLIP(numbits, min_val, max_val) - (max_val + min_val)/2; + + emb[0] = sin(x*LACE_NUMBITS_SCALE_0 - 0.5f); + emb[1] = sin(x*LACE_NUMBITS_SCALE_1 - 0.5f); + emb[2] = sin(x*LACE_NUMBITS_SCALE_2 - 0.5f); + emb[3] = sin(x*LACE_NUMBITS_SCALE_3 - 0.5f); + emb[4] = sin(x*LACE_NUMBITS_SCALE_4 - 0.5f); + emb[5] = sin(x*LACE_NUMBITS_SCALE_5 - 0.5f); + emb[6] = sin(x*LACE_NUMBITS_SCALE_6 - 0.5f); + emb[7] = sin(x*LACE_NUMBITS_SCALE_7 - 0.5f); } -static int init_lace(LACE *hLACE, const WeightArray *weights) -{ +static int oaci_init_lace(LACE *hLACE, const WeightArray *weights) { int ret = 0; - OPUS_CLEAR(hLACE, 1); + OAC_CLEAR(hLACE, 1); celt_assert(weights != NULL); - ret = init_lacelayers(&hLACE->layers, weights); + ret = oaci_init_lacelayers(&hLACE->layers, weights); - compute_overlap_window(hLACE->window, LACE_OVERLAP_SIZE); + oaci_compute_overlap_window(hLACE->window, LACE_OVERLAP_SIZE); return ret; } -static void reset_lace_state(LACEState *state) -{ - OPUS_CLEAR(state, 1); +static void oaci_reset_lace_state(LACEState *state) { + OAC_CLEAR(state, 1); - init_adacomb_state(&state->cf1_state); - init_adacomb_state(&state->cf2_state); - init_adaconv_state(&state->af1_state); + oaci_init_adacomb_state(&state->cf1_state); + oaci_init_adacomb_state(&state->cf2_state); + oaci_init_adaconv_state(&state->af1_state); } -static void lace_feature_net( +static void oaci_lace_feature_net( LACE *hLACE, LACEState *state, float *output, const float *features, const float *numbits, const int *periods, - int arch -) -{ - float input_buffer[IMAX(4 * IMAX(LACE_COND_DIM, LACE_HIDDEN_FEATURE_DIM), LACE_NUM_FEATURES + LACE_PITCH_EMBEDDING_DIM + 2*LACE_NUMBITS_EMBEDDING_DIM)]; - float output_buffer[4 * IMAX(LACE_COND_DIM, LACE_HIDDEN_FEATURE_DIM)]; - float numbits_embedded[2 * LACE_NUMBITS_EMBEDDING_DIM]; + int arch) { + float input_buffer[IMAX(4*IMAX(LACE_COND_DIM, LACE_HIDDEN_FEATURE_DIM), + LACE_NUM_FEATURES + LACE_PITCH_EMBEDDING_DIM + 2*LACE_NUMBITS_EMBEDDING_DIM)]; + float output_buffer[4*IMAX(LACE_COND_DIM, LACE_HIDDEN_FEATURE_DIM)]; + float numbits_embedded[2*LACE_NUMBITS_EMBEDDING_DIM]; int i_subframe; - compute_lace_numbits_embedding(numbits_embedded, numbits[0], LACE_NUMBITS_EMBEDDING_DIM, + oaci_compute_lace_numbits_embedding(numbits_embedded, numbits[0], LACE_NUMBITS_EMBEDDING_DIM, log(LACE_NUMBITS_RANGE_LOW), log(LACE_NUMBITS_RANGE_HIGH), 1); - compute_lace_numbits_embedding(numbits_embedded + LACE_NUMBITS_EMBEDDING_DIM, numbits[1], LACE_NUMBITS_EMBEDDING_DIM, + oaci_compute_lace_numbits_embedding(numbits_embedded + LACE_NUMBITS_EMBEDDING_DIM, numbits[1], + LACE_NUMBITS_EMBEDDING_DIM, log(LACE_NUMBITS_RANGE_LOW), log(LACE_NUMBITS_RANGE_HIGH), 1); /* scaling and dimensionality reduction */ - for (i_subframe = 0; i_subframe < 4; i_subframe ++) - { - OPUS_COPY(input_buffer, features + i_subframe * LACE_NUM_FEATURES, LACE_NUM_FEATURES); - OPUS_COPY(input_buffer + LACE_NUM_FEATURES, hLACE->layers.lace_pitch_embedding.float_weights + periods[i_subframe] * LACE_PITCH_EMBEDDING_DIM, LACE_PITCH_EMBEDDING_DIM); - OPUS_COPY(input_buffer + LACE_NUM_FEATURES + LACE_PITCH_EMBEDDING_DIM, numbits_embedded, 2 * LACE_NUMBITS_EMBEDDING_DIM); - - compute_generic_conv1d( + for (i_subframe = 0; i_subframe < 4; i_subframe++) { + OAC_COPY(input_buffer, features + i_subframe*LACE_NUM_FEATURES, LACE_NUM_FEATURES); + OAC_COPY(input_buffer + LACE_NUM_FEATURES, + hLACE->layers.lace_pitch_embedding.float_weights + periods[i_subframe]*LACE_PITCH_EMBEDDING_DIM, + LACE_PITCH_EMBEDDING_DIM); + OAC_COPY(input_buffer + LACE_NUM_FEATURES + LACE_PITCH_EMBEDDING_DIM, numbits_embedded, + 2*LACE_NUMBITS_EMBEDDING_DIM); + + oaci_compute_generic_conv1d( &hLACE->layers.lace_fnet_conv1, - output_buffer + i_subframe * LACE_HIDDEN_FEATURE_DIM, + output_buffer + i_subframe*LACE_HIDDEN_FEATURE_DIM, NULL, input_buffer, - LACE_NUM_FEATURES + LACE_PITCH_EMBEDDING_DIM + 2 * LACE_NUMBITS_EMBEDDING_DIM, + LACE_NUM_FEATURES + LACE_PITCH_EMBEDDING_DIM + 2*LACE_NUMBITS_EMBEDDING_DIM, ACTIVATION_TANH, arch); } /* subframe accumulation */ - OPUS_COPY(input_buffer, output_buffer, 4 * LACE_HIDDEN_FEATURE_DIM); - compute_generic_conv1d( + OAC_COPY(input_buffer, output_buffer, 4*LACE_HIDDEN_FEATURE_DIM); + oaci_compute_generic_conv1d( &hLACE->layers.lace_fnet_conv2, output_buffer, state->feature_net_conv2_state, input_buffer, - 4 * LACE_HIDDEN_FEATURE_DIM, + 4*LACE_HIDDEN_FEATURE_DIM, ACTIVATION_TANH, arch - ); + ); /* tconv upsampling */ - OPUS_COPY(input_buffer, output_buffer, 4 * LACE_COND_DIM); - compute_generic_dense( + OAC_COPY(input_buffer, output_buffer, 4*LACE_COND_DIM); + oaci_compute_generic_dense( &hLACE->layers.lace_fnet_tconv, output_buffer, input_buffer, ACTIVATION_TANH, arch - ); + ); /* GRU */ - OPUS_COPY(input_buffer, output_buffer, 4 * LACE_COND_DIM); - for (i_subframe = 0; i_subframe < 4; i_subframe++) - { - compute_generic_gru( + OAC_COPY(input_buffer, output_buffer, 4*LACE_COND_DIM); + for (i_subframe = 0; i_subframe < 4; i_subframe++) { + oaci_compute_generic_gru( &hLACE->layers.lace_fnet_gru_input, &hLACE->layers.lace_fnet_gru_recurrent, state->feature_net_gru_state, - input_buffer + i_subframe * LACE_COND_DIM, + input_buffer + i_subframe*LACE_COND_DIM, arch - ); - OPUS_COPY(output + i_subframe * LACE_COND_DIM, state->feature_net_gru_state, LACE_COND_DIM); + ); + OAC_COPY(output + i_subframe*LACE_COND_DIM, state->feature_net_gru_state, LACE_COND_DIM); } } -static void lace_process_20ms_frame( +static void oaci_lace_process_20ms_frame( LACE* hLACE, LACEState *state, float *x_out, @@ -243,16 +251,14 @@ static void lace_process_20ms_frame( const float *features, const float *numbits, const int *periods, - int arch -) -{ - float feature_buffer[4 * LACE_COND_DIM]; - float output_buffer[4 * LACE_FRAME_SIZE]; + int arch) { + float feature_buffer[4*LACE_COND_DIM]; + float output_buffer[4*LACE_FRAME_SIZE]; int i_subframe, i_sample; -#ifdef DEBUG_LACE - static FILE *f_features=NULL, *f_encfeatures=NULL, *f_xin=NULL, *f_xpreemph=NULL, *f_postcf1=NULL; - static FILE *f_postcf2=NULL, *f_postaf1=NULL, *f_xdeemph, *f_numbits, *f_periods; +# ifdef DEBUG_LACE + static FILE *f_features = NULL, *f_encfeatures = NULL, *f_xin = NULL, *f_xpreemph = NULL, *f_postcf1 = NULL; + static FILE *f_postcf2 = NULL, *f_postaf1 = NULL, *f_xdeemph, *f_numbits, *f_periods; FINIT(f_features, "debug/c_features.f32", "wb"); @@ -266,34 +272,32 @@ static void lace_process_20ms_frame( FINIT(f_numbits, "debug/c_numbits.f32", "wb"); FINIT(f_periods, "debug/c_periods.s32", "wb"); - fwrite(x_in, sizeof(*x_in), 4 * LACE_FRAME_SIZE, f_xin); + fwrite(x_in, sizeof(*x_in), 4*LACE_FRAME_SIZE, f_xin); fwrite(numbits, sizeof(*numbits), 2, f_numbits); fwrite(periods, sizeof(*periods), 4, f_periods); -#endif +# endif /* pre-emphasis */ - for (i_sample = 0; i_sample < 4 * LACE_FRAME_SIZE; i_sample ++) - { - output_buffer[i_sample] = x_in[i_sample] - LACE_PREEMPH * state->preemph_mem; + for (i_sample = 0; i_sample < 4*LACE_FRAME_SIZE; i_sample++) { + output_buffer[i_sample] = x_in[i_sample] - LACE_PREEMPH*state->preemph_mem; state->preemph_mem = x_in[i_sample]; } /* run feature encoder */ - lace_feature_net(hLACE, state, feature_buffer, features, numbits, periods, arch); -#ifdef DEBUG_LACE - fwrite(features, sizeof(*features), 4 * LACE_NUM_FEATURES, f_features); - fwrite(feature_buffer, sizeof(*feature_buffer), 4 * LACE_COND_DIM, f_encfeatures); - fwrite(output_buffer, sizeof(float), 4 * LACE_FRAME_SIZE, f_xpreemph); -#endif + oaci_lace_feature_net(hLACE, state, feature_buffer, features, numbits, periods, arch); +# ifdef DEBUG_LACE + fwrite(features, sizeof(*features), 4*LACE_NUM_FEATURES, f_features); + fwrite(feature_buffer, sizeof(*feature_buffer), 4*LACE_COND_DIM, f_encfeatures); + fwrite(output_buffer, sizeof(float), 4*LACE_FRAME_SIZE, f_xpreemph); +# endif /* 1st comb filtering stage */ - for (i_subframe = 0; i_subframe < 4; i_subframe++) - { - adacomb_process_frame( + for (i_subframe = 0; i_subframe < 4; i_subframe++) { + oaci_adacomb_process_frame( &state->cf1_state, - output_buffer + i_subframe * LACE_FRAME_SIZE, - output_buffer + i_subframe * LACE_FRAME_SIZE, - feature_buffer + i_subframe * LACE_COND_DIM, + output_buffer + i_subframe*LACE_FRAME_SIZE, + output_buffer + i_subframe*LACE_FRAME_SIZE, + feature_buffer + i_subframe*LACE_COND_DIM, &hLACE->layers.lace_cf1_kernel, &hLACE->layers.lace_cf1_gain, &hLACE->layers.lace_cf1_global_gain, @@ -310,18 +314,17 @@ static void lace_process_20ms_frame( arch); } -#ifdef DEBUG_LACE - fwrite(output_buffer, sizeof(float), 4 * LACE_FRAME_SIZE, f_postcf1); -#endif +# ifdef DEBUG_LACE + fwrite(output_buffer, sizeof(float), 4*LACE_FRAME_SIZE, f_postcf1); +# endif /* 2nd comb filtering stage */ - for (i_subframe = 0; i_subframe < 4; i_subframe++) - { - adacomb_process_frame( + for (i_subframe = 0; i_subframe < 4; i_subframe++) { + oaci_adacomb_process_frame( &state->cf2_state, - output_buffer + i_subframe * LACE_FRAME_SIZE, - output_buffer + i_subframe * LACE_FRAME_SIZE, - feature_buffer + i_subframe * LACE_COND_DIM, + output_buffer + i_subframe*LACE_FRAME_SIZE, + output_buffer + i_subframe*LACE_FRAME_SIZE, + feature_buffer + i_subframe*LACE_COND_DIM, &hLACE->layers.lace_cf2_kernel, &hLACE->layers.lace_cf2_gain, &hLACE->layers.lace_cf2_global_gain, @@ -337,18 +340,17 @@ static void lace_process_20ms_frame( hLACE->window, arch); } -#ifdef DEBUG_LACE - fwrite(output_buffer, sizeof(float), 4 * LACE_FRAME_SIZE, f_postcf2); -#endif +# ifdef DEBUG_LACE + fwrite(output_buffer, sizeof(float), 4*LACE_FRAME_SIZE, f_postcf2); +# endif /* final adaptive filtering stage */ - for (i_subframe = 0; i_subframe < 4; i_subframe++) - { - adaconv_process_frame( + for (i_subframe = 0; i_subframe < 4; i_subframe++) { + oaci_adaconv_process_frame( &state->af1_state, - output_buffer + i_subframe * LACE_FRAME_SIZE, - output_buffer + i_subframe * LACE_FRAME_SIZE, - feature_buffer + i_subframe * LACE_COND_DIM, + output_buffer + i_subframe*LACE_FRAME_SIZE, + output_buffer + i_subframe*LACE_FRAME_SIZE, + feature_buffer + i_subframe*LACE_COND_DIM, &hLACE->layers.lace_af1_kernel, &hLACE->layers.lace_af1_gain, LACE_COND_DIM, @@ -364,19 +366,18 @@ static void lace_process_20ms_frame( hLACE->window, arch); } -#ifdef DEBUG_LACE - fwrite(output_buffer, sizeof(float), 4 * LACE_FRAME_SIZE, f_postaf1); -#endif +# ifdef DEBUG_LACE + fwrite(output_buffer, sizeof(float), 4*LACE_FRAME_SIZE, f_postaf1); +# endif /* de-emphasis */ - for (i_sample = 0; i_sample < 4 * LACE_FRAME_SIZE; i_sample ++) - { - x_out[i_sample] = output_buffer[i_sample] + LACE_PREEMPH * state->deemph_mem; + for (i_sample = 0; i_sample < 4*LACE_FRAME_SIZE; i_sample++) { + x_out[i_sample] = output_buffer[i_sample] + LACE_PREEMPH*state->deemph_mem; state->deemph_mem = x_out[i_sample]; } -#ifdef DEBUG_LACE - fwrite(x_out, sizeof(float), 4 * LACE_FRAME_SIZE, f_xdeemph); -#endif +# ifdef DEBUG_LACE + fwrite(x_out, sizeof(float), 4*LACE_FRAME_SIZE, f_xdeemph); +# endif } #endif /* #ifndef DISABLE_LACE */ @@ -385,128 +386,126 @@ static void lace_process_20ms_frame( /* NoLACE */ #ifndef DISABLE_NOLACE -static void compute_nolace_numbits_embedding(float *emb, float numbits, int dim, float min_val, float max_val, int logscale) -{ +static void oaci_compute_nolace_numbits_embedding(float *emb, float numbits, int dim, float min_val, float max_val, + int logscale) { float x; (void) dim; numbits = logscale ? log(numbits) : numbits; - x = CLIP(numbits, min_val, max_val) - (max_val + min_val) / 2; - - emb[0] = sin(x * NOLACE_NUMBITS_SCALE_0 - 0.5f); - emb[1] = sin(x * NOLACE_NUMBITS_SCALE_1 - 0.5f); - emb[2] = sin(x * NOLACE_NUMBITS_SCALE_2 - 0.5f); - emb[3] = sin(x * NOLACE_NUMBITS_SCALE_3 - 0.5f); - emb[4] = sin(x * NOLACE_NUMBITS_SCALE_4 - 0.5f); - emb[5] = sin(x * NOLACE_NUMBITS_SCALE_5 - 0.5f); - emb[6] = sin(x * NOLACE_NUMBITS_SCALE_6 - 0.5f); - emb[7] = sin(x * NOLACE_NUMBITS_SCALE_7 - 0.5f); + x = CLIP(numbits, min_val, max_val) - (max_val + min_val)/2; + + emb[0] = sin(x*NOLACE_NUMBITS_SCALE_0 - 0.5f); + emb[1] = sin(x*NOLACE_NUMBITS_SCALE_1 - 0.5f); + emb[2] = sin(x*NOLACE_NUMBITS_SCALE_2 - 0.5f); + emb[3] = sin(x*NOLACE_NUMBITS_SCALE_3 - 0.5f); + emb[4] = sin(x*NOLACE_NUMBITS_SCALE_4 - 0.5f); + emb[5] = sin(x*NOLACE_NUMBITS_SCALE_5 - 0.5f); + emb[6] = sin(x*NOLACE_NUMBITS_SCALE_6 - 0.5f); + emb[7] = sin(x*NOLACE_NUMBITS_SCALE_7 - 0.5f); } -static int init_nolace(NoLACE *hNoLACE, const WeightArray *weights) -{ +static int oaci_init_nolace(NoLACE *hNoLACE, const WeightArray *weights) { int ret = 0; - OPUS_CLEAR(hNoLACE, 1); + OAC_CLEAR(hNoLACE, 1); celt_assert(weights != NULL); - ret = init_nolacelayers(&hNoLACE->layers, weights); + ret = oaci_init_nolacelayers(&hNoLACE->layers, weights); - compute_overlap_window(hNoLACE->window, NOLACE_OVERLAP_SIZE); + oaci_compute_overlap_window(hNoLACE->window, NOLACE_OVERLAP_SIZE); return ret; } -static void reset_nolace_state(NoLACEState *state) -{ - OPUS_CLEAR(state, 1); - - init_adacomb_state(&state->cf1_state); - init_adacomb_state(&state->cf2_state); - init_adaconv_state(&state->af1_state); - init_adaconv_state(&state->af2_state); - init_adaconv_state(&state->af3_state); - init_adaconv_state(&state->af4_state); - init_adashape_state(&state->tdshape1_state); - init_adashape_state(&state->tdshape2_state); - init_adashape_state(&state->tdshape3_state); +static void oaci_reset_nolace_state(NoLACEState *state) { + OAC_CLEAR(state, 1); + + oaci_init_adacomb_state(&state->cf1_state); + oaci_init_adacomb_state(&state->cf2_state); + oaci_init_adaconv_state(&state->af1_state); + oaci_init_adaconv_state(&state->af2_state); + oaci_init_adaconv_state(&state->af3_state); + oaci_init_adaconv_state(&state->af4_state); + oaci_init_adashape_state(&state->tdshape1_state); + oaci_init_adashape_state(&state->tdshape2_state); + oaci_init_adashape_state(&state->tdshape3_state); } -static void nolace_feature_net( +static void oaci_nolace_feature_net( NoLACE *hNoLACE, NoLACEState *state, float *output, const float *features, const float *numbits, const int *periods, - int arch -) -{ - float input_buffer[4 * IMAX(NOLACE_COND_DIM, NOLACE_HIDDEN_FEATURE_DIM)]; - float output_buffer[4 * IMAX(NOLACE_COND_DIM, NOLACE_HIDDEN_FEATURE_DIM)]; - float numbits_embedded[2 * NOLACE_NUMBITS_EMBEDDING_DIM]; + int arch) { + float input_buffer[4*IMAX(NOLACE_COND_DIM, NOLACE_HIDDEN_FEATURE_DIM)]; + float output_buffer[4*IMAX(NOLACE_COND_DIM, NOLACE_HIDDEN_FEATURE_DIM)]; + float numbits_embedded[2*NOLACE_NUMBITS_EMBEDDING_DIM]; int i_subframe; - compute_nolace_numbits_embedding(numbits_embedded, numbits[0], NOLACE_NUMBITS_EMBEDDING_DIM, + oaci_compute_nolace_numbits_embedding(numbits_embedded, numbits[0], NOLACE_NUMBITS_EMBEDDING_DIM, log(NOLACE_NUMBITS_RANGE_LOW), log(NOLACE_NUMBITS_RANGE_HIGH), 1); - compute_nolace_numbits_embedding(numbits_embedded + NOLACE_NUMBITS_EMBEDDING_DIM, numbits[1], NOLACE_NUMBITS_EMBEDDING_DIM, + oaci_compute_nolace_numbits_embedding(numbits_embedded + NOLACE_NUMBITS_EMBEDDING_DIM, numbits[1], + NOLACE_NUMBITS_EMBEDDING_DIM, log(NOLACE_NUMBITS_RANGE_LOW), log(NOLACE_NUMBITS_RANGE_HIGH), 1); /* scaling and dimensionality reduction */ - for (i_subframe = 0; i_subframe < 4; i_subframe ++) - { - OPUS_COPY(input_buffer, features + i_subframe * NOLACE_NUM_FEATURES, NOLACE_NUM_FEATURES); - OPUS_COPY(input_buffer + NOLACE_NUM_FEATURES, hNoLACE->layers.nolace_pitch_embedding.float_weights + periods[i_subframe] * NOLACE_PITCH_EMBEDDING_DIM, NOLACE_PITCH_EMBEDDING_DIM); - OPUS_COPY(input_buffer + NOLACE_NUM_FEATURES + NOLACE_PITCH_EMBEDDING_DIM, numbits_embedded, 2 * NOLACE_NUMBITS_EMBEDDING_DIM); - - compute_generic_conv1d( + for (i_subframe = 0; i_subframe < 4; i_subframe++) { + OAC_COPY(input_buffer, features + i_subframe*NOLACE_NUM_FEATURES, NOLACE_NUM_FEATURES); + OAC_COPY(input_buffer + NOLACE_NUM_FEATURES, + hNoLACE->layers.nolace_pitch_embedding.float_weights + periods[i_subframe]*NOLACE_PITCH_EMBEDDING_DIM, + NOLACE_PITCH_EMBEDDING_DIM); + OAC_COPY(input_buffer + NOLACE_NUM_FEATURES + NOLACE_PITCH_EMBEDDING_DIM, numbits_embedded, + 2*NOLACE_NUMBITS_EMBEDDING_DIM); + + oaci_compute_generic_conv1d( &hNoLACE->layers.nolace_fnet_conv1, - output_buffer + i_subframe * NOLACE_HIDDEN_FEATURE_DIM, + output_buffer + i_subframe*NOLACE_HIDDEN_FEATURE_DIM, NULL, input_buffer, - NOLACE_NUM_FEATURES + NOLACE_PITCH_EMBEDDING_DIM + 2 * NOLACE_NUMBITS_EMBEDDING_DIM, + NOLACE_NUM_FEATURES + NOLACE_PITCH_EMBEDDING_DIM + 2*NOLACE_NUMBITS_EMBEDDING_DIM, ACTIVATION_TANH, arch); } /* subframe accumulation */ - OPUS_COPY(input_buffer, output_buffer, 4 * NOLACE_HIDDEN_FEATURE_DIM); - compute_generic_conv1d( + OAC_COPY(input_buffer, output_buffer, 4*NOLACE_HIDDEN_FEATURE_DIM); + oaci_compute_generic_conv1d( &hNoLACE->layers.nolace_fnet_conv2, output_buffer, state->feature_net_conv2_state, input_buffer, - 4 * NOLACE_HIDDEN_FEATURE_DIM, + 4*NOLACE_HIDDEN_FEATURE_DIM, ACTIVATION_TANH, arch - ); + ); /* tconv upsampling */ - OPUS_COPY(input_buffer, output_buffer, 4 * NOLACE_COND_DIM); - compute_generic_dense( + OAC_COPY(input_buffer, output_buffer, 4*NOLACE_COND_DIM); + oaci_compute_generic_dense( &hNoLACE->layers.nolace_fnet_tconv, output_buffer, input_buffer, ACTIVATION_TANH, arch - ); + ); /* GRU */ - OPUS_COPY(input_buffer, output_buffer, 4 * NOLACE_COND_DIM); - for (i_subframe = 0; i_subframe < 4; i_subframe++) - { - compute_generic_gru( + OAC_COPY(input_buffer, output_buffer, 4*NOLACE_COND_DIM); + for (i_subframe = 0; i_subframe < 4; i_subframe++) { + oaci_compute_generic_gru( &hNoLACE->layers.nolace_fnet_gru_input, &hNoLACE->layers.nolace_fnet_gru_recurrent, state->feature_net_gru_state, - input_buffer + i_subframe * NOLACE_COND_DIM, + input_buffer + i_subframe*NOLACE_COND_DIM, arch - ); - OPUS_COPY(output + i_subframe * NOLACE_COND_DIM, state->feature_net_gru_state, NOLACE_COND_DIM); + ); + OAC_COPY(output + i_subframe*NOLACE_COND_DIM, state->feature_net_gru_state, NOLACE_COND_DIM); } } -static void nolace_process_20ms_frame( +static void oaci_nolace_process_20ms_frame( NoLACE* hNoLACE, NoLACEState *state, float *x_out, @@ -514,19 +513,17 @@ static void nolace_process_20ms_frame( const float *features, const float *numbits, const int *periods, - int arch -) -{ - float feature_buffer[4 * NOLACE_COND_DIM]; - float feature_transform_buffer[4 * NOLACE_COND_DIM]; - float x_buffer1[8 * NOLACE_FRAME_SIZE]; - float x_buffer2[8 * NOLACE_FRAME_SIZE]; + int arch) { + float feature_buffer[4*NOLACE_COND_DIM]; + float feature_transform_buffer[4*NOLACE_COND_DIM]; + float x_buffer1[8*NOLACE_FRAME_SIZE]; + float x_buffer2[8*NOLACE_FRAME_SIZE]; int i_subframe, i_sample; NOLACELayers *layers = &hNoLACE->layers; -#ifdef DEBUG_NOLACE - static FILE *f_features=NULL, *f_encfeatures=NULL, *f_xin=NULL, *f_xpreemph=NULL, *f_postcf1=NULL; - static FILE *f_postcf2=NULL, *f_postaf1=NULL, *f_xdeemph, *f_numbits, *f_periods; +# ifdef DEBUG_NOLACE + static FILE *f_features = NULL, *f_encfeatures = NULL, *f_xin = NULL, *f_xpreemph = NULL, *f_postcf1 = NULL; + static FILE *f_postcf2 = NULL, *f_postaf1 = NULL, *f_xdeemph, *f_numbits, *f_periods; static FILE *f_ffpostcf1, *f_fpostcf2, *f_fpostaf1; @@ -541,35 +538,33 @@ static void nolace_process_20ms_frame( FINIT(f_numbits, "debug/c_numbits.f32", "wb"); FINIT(f_periods, "debug/c_periods.s32", "wb"); - fwrite(x_in, sizeof(*x_in), 4 * NOLACE_FRAME_SIZE, f_xin); + fwrite(x_in, sizeof(*x_in), 4*NOLACE_FRAME_SIZE, f_xin); fwrite(numbits, sizeof(*numbits), 2, f_numbits); fwrite(periods, sizeof(*periods), 4, f_periods); -#endif +# endif /* pre-emphasis */ - for (i_sample = 0; i_sample < 4 * NOLACE_FRAME_SIZE; i_sample ++) - { - x_buffer1[i_sample] = x_in[i_sample] - NOLACE_PREEMPH * state->preemph_mem; + for (i_sample = 0; i_sample < 4*NOLACE_FRAME_SIZE; i_sample++) { + x_buffer1[i_sample] = x_in[i_sample] - NOLACE_PREEMPH*state->preemph_mem; state->preemph_mem = x_in[i_sample]; } /* run feature encoder */ - nolace_feature_net(hNoLACE, state, feature_buffer, features, numbits, periods, arch); -#ifdef DEBUG_NOLACE - fwrite(features, sizeof(*features), 4 * NOLACE_NUM_FEATURES, f_features); - fwrite(feature_buffer, sizeof(*feature_buffer), 4 * NOLACE_COND_DIM, f_encfeatures); - fwrite(output_buffer, sizeof(float), 4 * NOLACE_FRAME_SIZE, f_xpreemph); -#endif + oaci_nolace_feature_net(hNoLACE, state, feature_buffer, features, numbits, periods, arch); +# ifdef DEBUG_NOLACE + fwrite(features, sizeof(*features), 4*NOLACE_NUM_FEATURES, f_features); + fwrite(feature_buffer, sizeof(*feature_buffer), 4*NOLACE_COND_DIM, f_encfeatures); + fwrite(output_buffer, sizeof(float), 4*NOLACE_FRAME_SIZE, f_xpreemph); +# endif /* 1st comb filtering stage */ - for (i_subframe = 0; i_subframe < 4; i_subframe++) - { + for (i_subframe = 0; i_subframe < 4; i_subframe++) { /* modifies signal in place */ - adacomb_process_frame( + oaci_adacomb_process_frame( &state->cf1_state, - x_buffer1 + i_subframe * NOLACE_FRAME_SIZE, - x_buffer1 + i_subframe * NOLACE_FRAME_SIZE, - feature_buffer + i_subframe * NOLACE_COND_DIM, + x_buffer1 + i_subframe*NOLACE_FRAME_SIZE, + x_buffer1 + i_subframe*NOLACE_FRAME_SIZE, + feature_buffer + i_subframe*NOLACE_COND_DIM, &hNoLACE->layers.nolace_cf1_kernel, &hNoLACE->layers.nolace_cf1_gain, &hNoLACE->layers.nolace_cf1_global_gain, @@ -585,32 +580,31 @@ static void nolace_process_20ms_frame( hNoLACE->window, arch); - compute_generic_conv1d( + oaci_compute_generic_conv1d( &layers->nolace_post_cf1, - feature_transform_buffer + i_subframe * NOLACE_COND_DIM, + feature_transform_buffer + i_subframe*NOLACE_COND_DIM, state->post_cf1_state, - feature_buffer + i_subframe * NOLACE_COND_DIM, + feature_buffer + i_subframe*NOLACE_COND_DIM, NOLACE_COND_DIM, ACTIVATION_TANH, arch); } /* update feature buffer */ - OPUS_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); + OAC_COPY(feature_buffer, feature_transform_buffer, 4*NOLACE_COND_DIM); -#ifdef DEBUG_NOLACE - fwrite(x_buffer1, sizeof(float), 4 * NOLACE_FRAME_SIZE, f_postcf1); -#endif +# ifdef DEBUG_NOLACE + fwrite(x_buffer1, sizeof(float), 4*NOLACE_FRAME_SIZE, f_postcf1); +# endif /* 2nd comb filtering stage */ - for (i_subframe = 0; i_subframe < 4; i_subframe++) - { + for (i_subframe = 0; i_subframe < 4; i_subframe++) { /* modifies signal in place */ - adacomb_process_frame( + oaci_adacomb_process_frame( &state->cf2_state, - x_buffer1 + i_subframe * NOLACE_FRAME_SIZE, - x_buffer1 + i_subframe * NOLACE_FRAME_SIZE, - feature_buffer + i_subframe * NOLACE_COND_DIM, + x_buffer1 + i_subframe*NOLACE_FRAME_SIZE, + x_buffer1 + i_subframe*NOLACE_FRAME_SIZE, + feature_buffer + i_subframe*NOLACE_COND_DIM, &hNoLACE->layers.nolace_cf2_kernel, &hNoLACE->layers.nolace_cf2_gain, &hNoLACE->layers.nolace_cf2_global_gain, @@ -626,31 +620,30 @@ static void nolace_process_20ms_frame( hNoLACE->window, arch); - compute_generic_conv1d( + oaci_compute_generic_conv1d( &layers->nolace_post_cf2, - feature_transform_buffer + i_subframe * NOLACE_COND_DIM, + feature_transform_buffer + i_subframe*NOLACE_COND_DIM, state->post_cf2_state, - feature_buffer + i_subframe * NOLACE_COND_DIM, + feature_buffer + i_subframe*NOLACE_COND_DIM, NOLACE_COND_DIM, ACTIVATION_TANH, arch); } /* update feature buffer */ - OPUS_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); + OAC_COPY(feature_buffer, feature_transform_buffer, 4*NOLACE_COND_DIM); -#ifdef DEBUG_NOLACE - fwrite(x_buffer1, sizeof(float), 4 * NOLACE_FRAME_SIZE, f_postcf2); -#endif +# ifdef DEBUG_NOLACE + fwrite(x_buffer1, sizeof(float), 4*NOLACE_FRAME_SIZE, f_postcf2); +# endif /* final adaptive filtering stage */ - for (i_subframe = 0; i_subframe < 4; i_subframe++) - { - adaconv_process_frame( + for (i_subframe = 0; i_subframe < 4; i_subframe++) { + oaci_adaconv_process_frame( &state->af1_state, - x_buffer2 + i_subframe * NOLACE_FRAME_SIZE * NOLACE_AF1_OUT_CHANNELS, - x_buffer1 + i_subframe * NOLACE_FRAME_SIZE, - feature_buffer + i_subframe * NOLACE_COND_DIM, + x_buffer2 + i_subframe*NOLACE_FRAME_SIZE*NOLACE_AF1_OUT_CHANNELS, + x_buffer1 + i_subframe*NOLACE_FRAME_SIZE, + feature_buffer + i_subframe*NOLACE_COND_DIM, &hNoLACE->layers.nolace_af1_kernel, &hNoLACE->layers.nolace_af1_gain, NOLACE_COND_DIM, @@ -666,33 +659,32 @@ static void nolace_process_20ms_frame( hNoLACE->window, arch); - compute_generic_conv1d( + oaci_compute_generic_conv1d( &layers->nolace_post_af1, - feature_transform_buffer + i_subframe * NOLACE_COND_DIM, + feature_transform_buffer + i_subframe*NOLACE_COND_DIM, state->post_af1_state, - feature_buffer + i_subframe * NOLACE_COND_DIM, + feature_buffer + i_subframe*NOLACE_COND_DIM, NOLACE_COND_DIM, ACTIVATION_TANH, arch); } /* update feature buffer */ - OPUS_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); + OAC_COPY(feature_buffer, feature_transform_buffer, 4*NOLACE_COND_DIM); -#ifdef DEBUG_NOLACE - fwrite(x_buffer2, sizeof(float), 4 * NOLACE_FRAME_SIZE * NOLACE_AF1_OUT_CHANNELS, f_postaf1); -#endif +# ifdef DEBUG_NOLACE + fwrite(x_buffer2, sizeof(float), 4*NOLACE_FRAME_SIZE*NOLACE_AF1_OUT_CHANNELS, f_postaf1); +# endif /* first shape-mix round */ - for (i_subframe = 0; i_subframe < 4; i_subframe++) - { + for (i_subframe = 0; i_subframe < 4; i_subframe++) { celt_assert(NOLACE_AF1_OUT_CHANNELS == 2); /* modifies second channel in place */ - adashape_process_frame( + oaci_adashape_process_frame( &state->tdshape1_state, - x_buffer2 + i_subframe * NOLACE_AF1_OUT_CHANNELS * NOLACE_FRAME_SIZE + NOLACE_FRAME_SIZE, - x_buffer2 + i_subframe * NOLACE_AF1_OUT_CHANNELS * NOLACE_FRAME_SIZE + NOLACE_FRAME_SIZE, - feature_buffer + i_subframe * NOLACE_COND_DIM, + x_buffer2 + i_subframe*NOLACE_AF1_OUT_CHANNELS*NOLACE_FRAME_SIZE + NOLACE_FRAME_SIZE, + x_buffer2 + i_subframe*NOLACE_AF1_OUT_CHANNELS*NOLACE_FRAME_SIZE + NOLACE_FRAME_SIZE, + feature_buffer + i_subframe*NOLACE_COND_DIM, &layers->nolace_tdshape1_alpha1_f, &layers->nolace_tdshape1_alpha1_t, &layers->nolace_tdshape1_alpha2, @@ -701,13 +693,13 @@ static void nolace_process_20ms_frame( NOLACE_TDSHAPE1_AVG_POOL_K, 1, arch - ); + ); - adaconv_process_frame( + oaci_adaconv_process_frame( &state->af2_state, - x_buffer1 + i_subframe * NOLACE_FRAME_SIZE * NOLACE_AF2_OUT_CHANNELS, - x_buffer2 + i_subframe * NOLACE_FRAME_SIZE * NOLACE_AF2_IN_CHANNELS, - feature_buffer + i_subframe * NOLACE_COND_DIM, + x_buffer1 + i_subframe*NOLACE_FRAME_SIZE*NOLACE_AF2_OUT_CHANNELS, + x_buffer2 + i_subframe*NOLACE_FRAME_SIZE*NOLACE_AF2_IN_CHANNELS, + feature_buffer + i_subframe*NOLACE_COND_DIM, &hNoLACE->layers.nolace_af2_kernel, &hNoLACE->layers.nolace_af2_gain, NOLACE_COND_DIM, @@ -723,33 +715,32 @@ static void nolace_process_20ms_frame( hNoLACE->window, arch); - compute_generic_conv1d( + oaci_compute_generic_conv1d( &layers->nolace_post_af2, - feature_transform_buffer + i_subframe * NOLACE_COND_DIM, + feature_transform_buffer + i_subframe*NOLACE_COND_DIM, state->post_af2_state, - feature_buffer + i_subframe * NOLACE_COND_DIM, + feature_buffer + i_subframe*NOLACE_COND_DIM, NOLACE_COND_DIM, ACTIVATION_TANH, arch); } /* update feature buffer */ - OPUS_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); + OAC_COPY(feature_buffer, feature_transform_buffer, 4*NOLACE_COND_DIM); -#ifdef DEBUG_NOLACE - fwrite(x_buffer1, sizeof(float), 4 * NOLACE_FRAME_SIZE * NOLACE_AF2_OUT_CHANNELS, f_postaf2); -#endif +# ifdef DEBUG_NOLACE + fwrite(x_buffer1, sizeof(float), 4*NOLACE_FRAME_SIZE*NOLACE_AF2_OUT_CHANNELS, f_postaf2); +# endif /* second shape-mix round */ - for (i_subframe = 0; i_subframe < 4; i_subframe++) - { + for (i_subframe = 0; i_subframe < 4; i_subframe++) { celt_assert(NOLACE_AF2_OUT_CHANNELS == 2); /* modifies second channel in place */ - adashape_process_frame( + oaci_adashape_process_frame( &state->tdshape2_state, - x_buffer1 + i_subframe * NOLACE_AF2_OUT_CHANNELS * NOLACE_FRAME_SIZE + NOLACE_FRAME_SIZE, - x_buffer1 + i_subframe * NOLACE_AF2_OUT_CHANNELS * NOLACE_FRAME_SIZE + NOLACE_FRAME_SIZE, - feature_buffer + i_subframe * NOLACE_COND_DIM, + x_buffer1 + i_subframe*NOLACE_AF2_OUT_CHANNELS*NOLACE_FRAME_SIZE + NOLACE_FRAME_SIZE, + x_buffer1 + i_subframe*NOLACE_AF2_OUT_CHANNELS*NOLACE_FRAME_SIZE + NOLACE_FRAME_SIZE, + feature_buffer + i_subframe*NOLACE_COND_DIM, &layers->nolace_tdshape2_alpha1_f, &layers->nolace_tdshape2_alpha1_t, &layers->nolace_tdshape2_alpha2, @@ -758,13 +749,13 @@ static void nolace_process_20ms_frame( NOLACE_TDSHAPE2_AVG_POOL_K, 1, arch - ); + ); - adaconv_process_frame( + oaci_adaconv_process_frame( &state->af3_state, - x_buffer2 + i_subframe * NOLACE_FRAME_SIZE * NOLACE_AF3_OUT_CHANNELS, - x_buffer1 + i_subframe * NOLACE_FRAME_SIZE * NOLACE_AF3_IN_CHANNELS, - feature_buffer + i_subframe * NOLACE_COND_DIM, + x_buffer2 + i_subframe*NOLACE_FRAME_SIZE*NOLACE_AF3_OUT_CHANNELS, + x_buffer1 + i_subframe*NOLACE_FRAME_SIZE*NOLACE_AF3_IN_CHANNELS, + feature_buffer + i_subframe*NOLACE_COND_DIM, &hNoLACE->layers.nolace_af3_kernel, &hNoLACE->layers.nolace_af3_gain, NOLACE_COND_DIM, @@ -780,29 +771,28 @@ static void nolace_process_20ms_frame( hNoLACE->window, arch); - compute_generic_conv1d( + oaci_compute_generic_conv1d( &layers->nolace_post_af3, - feature_transform_buffer + i_subframe * NOLACE_COND_DIM, + feature_transform_buffer + i_subframe*NOLACE_COND_DIM, state->post_af3_state, - feature_buffer + i_subframe * NOLACE_COND_DIM, + feature_buffer + i_subframe*NOLACE_COND_DIM, NOLACE_COND_DIM, ACTIVATION_TANH, arch); } /* update feature buffer */ - OPUS_COPY(feature_buffer, feature_transform_buffer, 4 * NOLACE_COND_DIM); + OAC_COPY(feature_buffer, feature_transform_buffer, 4*NOLACE_COND_DIM); /* third shape-mix round */ - for (i_subframe = 0; i_subframe < 4; i_subframe++) - { + for (i_subframe = 0; i_subframe < 4; i_subframe++) { celt_assert(NOLACE_AF3_OUT_CHANNELS == 2); /* modifies second channel in place */ - adashape_process_frame( + oaci_adashape_process_frame( &state->tdshape3_state, - x_buffer2 + i_subframe * NOLACE_AF3_OUT_CHANNELS * NOLACE_FRAME_SIZE + NOLACE_FRAME_SIZE, - x_buffer2 + i_subframe * NOLACE_AF3_OUT_CHANNELS * NOLACE_FRAME_SIZE + NOLACE_FRAME_SIZE, - feature_buffer + i_subframe * NOLACE_COND_DIM, + x_buffer2 + i_subframe*NOLACE_AF3_OUT_CHANNELS*NOLACE_FRAME_SIZE + NOLACE_FRAME_SIZE, + x_buffer2 + i_subframe*NOLACE_AF3_OUT_CHANNELS*NOLACE_FRAME_SIZE + NOLACE_FRAME_SIZE, + feature_buffer + i_subframe*NOLACE_COND_DIM, &layers->nolace_tdshape3_alpha1_f, &layers->nolace_tdshape3_alpha1_t, &layers->nolace_tdshape3_alpha2, @@ -811,13 +801,13 @@ static void nolace_process_20ms_frame( NOLACE_TDSHAPE3_AVG_POOL_K, 1, arch - ); + ); - adaconv_process_frame( + oaci_adaconv_process_frame( &state->af4_state, - x_buffer1 + i_subframe * NOLACE_FRAME_SIZE * NOLACE_AF4_OUT_CHANNELS, - x_buffer2 + i_subframe * NOLACE_FRAME_SIZE * NOLACE_AF4_IN_CHANNELS, - feature_buffer + i_subframe * NOLACE_COND_DIM, + x_buffer1 + i_subframe*NOLACE_FRAME_SIZE*NOLACE_AF4_OUT_CHANNELS, + x_buffer2 + i_subframe*NOLACE_FRAME_SIZE*NOLACE_AF4_IN_CHANNELS, + feature_buffer + i_subframe*NOLACE_COND_DIM, &hNoLACE->layers.nolace_af4_kernel, &hNoLACE->layers.nolace_af4_gain, NOLACE_COND_DIM, @@ -837,37 +827,34 @@ static void nolace_process_20ms_frame( /* de-emphasis */ - for (i_sample = 0; i_sample < 4 * NOLACE_FRAME_SIZE; i_sample ++) - { - x_out[i_sample] = x_buffer1[i_sample] + NOLACE_PREEMPH * state->deemph_mem; + for (i_sample = 0; i_sample < 4*NOLACE_FRAME_SIZE; i_sample++) { + x_out[i_sample] = x_buffer1[i_sample] + NOLACE_PREEMPH*state->deemph_mem; state->deemph_mem = x_out[i_sample]; } -#ifdef DEBUG_NOLACE - fwrite(x_out, sizeof(float), 4 * NOLACE_FRAME_SIZE, f_xdeemph); -#endif +# ifdef DEBUG_NOLACE + fwrite(x_out, sizeof(float), 4*NOLACE_FRAME_SIZE, f_xdeemph); +# endif } #endif /* #ifndef DISABLE_NOLACE */ #ifdef ENABLE_OSCE_BWE -#ifndef DISABLE_BBWENET -static void bbwe_feature_net( +# ifndef DISABLE_BBWENET +static void oaci_bbwe_feature_net( BBWENet *hBBWENET, BBWENetState *state, float *output, const float *features, int num_frames, - int arch -) -{ - float input_buffer[4 * BBWENET_FNET_GRU_STATE_SIZE]; - float output_buffer[4 * BBWENET_FNET_GRU_STATE_SIZE]; + int arch) { + float input_buffer[4*BBWENET_FNET_GRU_STATE_SIZE]; + float output_buffer[4*BBWENET_FNET_GRU_STATE_SIZE]; int i_subframe; int i_frame; -#ifdef DEBUG_BBWENET - static FILE *f_features=NULL, *f_conv1=NULL, *f_conv2=NULL, *f_tconv=NULL, *f_gru=NULL; +# ifdef DEBUG_BBWENET + static FILE *f_features = NULL, *f_conv1 = NULL, *f_conv2 = NULL, *f_tconv = NULL, *f_gru = NULL; FINIT(f_features, "debug/bbwenet_features.f32", "wb"); FINIT(f_conv1, "debug/bbwenet_conv1.f32", "wb"); @@ -875,8 +862,8 @@ static void bbwe_feature_net( FINIT(f_tconv, "debug/bbwenet_tconv.f32", "wb"); FINIT(f_gru, "debug/bbwenet_gru.f32", "wb"); - fwrite(features, sizeof(*features), num_frames * BBWENET_FEATURE_DIM, f_features); -#endif + fwrite(features, sizeof(*features), num_frames*BBWENET_FEATURE_DIM, f_features); +# endif /* adjust buffer sizes if any of this breaks */ celt_assert(BBWENET_FNET_GRU_STATE_SIZE == BBWENET_FNET_TCONV_OUT_CHANNELS); @@ -884,72 +871,72 @@ static void bbwe_feature_net( celt_assert(BBWENET_FNET_CONV2_OUT_SIZE == BBWENET_FNET_CONV1_OUT_SIZE); /* first conv layer */ - for (i_frame = 0; i_frame < num_frames; i_frame++) - { - compute_generic_conv1d( + for (i_frame = 0; i_frame < num_frames; i_frame++) { + oaci_compute_generic_conv1d( &hBBWENET->layers.bbwenet_fnet_conv1, - output_buffer + i_frame * BBWENET_FNET_CONV1_OUT_SIZE, + output_buffer + i_frame*BBWENET_FNET_CONV1_OUT_SIZE, state->feature_net_conv1_state, - features + i_frame * BBWENET_FEATURE_DIM, + features + i_frame*BBWENET_FEATURE_DIM, BBWENET_FEATURE_DIM, ACTIVATION_TANH, arch - ); -#ifdef DEBUG_BBWENET - fwrite(output_buffer + i_frame * BBWENET_FNET_CONV1_OUT_SIZE, sizeof(float), BBWENET_FNET_CONV1_OUT_SIZE, f_conv1); -#endif + ); +# ifdef DEBUG_BBWENET + fwrite(output_buffer + i_frame*BBWENET_FNET_CONV1_OUT_SIZE, sizeof(float), BBWENET_FNET_CONV1_OUT_SIZE, + f_conv1); +# endif } - OPUS_COPY(input_buffer, output_buffer, num_frames * BBWENET_FNET_CONV1_OUT_SIZE); + OAC_COPY(input_buffer, output_buffer, num_frames*BBWENET_FNET_CONV1_OUT_SIZE); /* second conv layer */ - for (i_frame = 0; i_frame < num_frames; i_frame++) - { - compute_generic_conv1d( + for (i_frame = 0; i_frame < num_frames; i_frame++) { + oaci_compute_generic_conv1d( &hBBWENET->layers.bbwenet_fnet_conv2, - output_buffer + i_frame * BBWENET_FNET_CONV2_OUT_SIZE, + output_buffer + i_frame*BBWENET_FNET_CONV2_OUT_SIZE, state->feature_net_conv2_state, - input_buffer + i_frame * BBWENET_FNET_CONV1_OUT_SIZE, + input_buffer + i_frame*BBWENET_FNET_CONV1_OUT_SIZE, BBWENET_FNET_CONV1_OUT_SIZE, ACTIVATION_TANH, arch - ); -#ifdef DEBUG_BBWENET - fwrite(output_buffer + i_frame * BBWENET_FNET_CONV2_OUT_SIZE, sizeof(float), BBWENET_FNET_CONV2_OUT_SIZE, f_conv2); -#endif + ); +# ifdef DEBUG_BBWENET + fwrite(output_buffer + i_frame*BBWENET_FNET_CONV2_OUT_SIZE, sizeof(float), BBWENET_FNET_CONV2_OUT_SIZE, + f_conv2); +# endif } - OPUS_COPY(input_buffer, output_buffer, num_frames * BBWENET_FNET_CONV2_OUT_SIZE); + OAC_COPY(input_buffer, output_buffer, num_frames*BBWENET_FNET_CONV2_OUT_SIZE); /* tconv upsampling*/ - for (i_frame = 0; i_frame < num_frames; i_frame++) - { - compute_generic_dense( + for (i_frame = 0; i_frame < num_frames; i_frame++) { + oaci_compute_generic_dense( &hBBWENET->layers.bbwenet_fnet_tconv, - output_buffer + i_frame * BBWENET_FNET_TCONV_OUT_CHANNELS * BBWENET_FNET_TCONV_STRIDE, - input_buffer + i_frame * BBWENET_FNET_CONV2_OUT_SIZE, + output_buffer + i_frame*BBWENET_FNET_TCONV_OUT_CHANNELS*BBWENET_FNET_TCONV_STRIDE, + input_buffer + i_frame*BBWENET_FNET_CONV2_OUT_SIZE, ACTIVATION_TANH, arch - ); -#ifdef DEBUG_BBWENET - fwrite(output_buffer + i_frame * BBWENET_FNET_TCONV_OUT_CHANNELS * BBWENET_FNET_TCONV_STRIDE, sizeof(float), BBWENET_FNET_TCONV_OUT_CHANNELS * BBWENET_FNET_TCONV_STRIDE, f_tconv); -#endif + ); +# ifdef DEBUG_BBWENET + fwrite(output_buffer + i_frame*BBWENET_FNET_TCONV_OUT_CHANNELS*BBWENET_FNET_TCONV_STRIDE, sizeof(float), + BBWENET_FNET_TCONV_OUT_CHANNELS*BBWENET_FNET_TCONV_STRIDE, f_tconv); +# endif } - OPUS_COPY(input_buffer, output_buffer, num_frames * BBWENET_FNET_TCONV_OUT_CHANNELS * BBWENET_FNET_TCONV_STRIDE); + OAC_COPY(input_buffer, output_buffer, num_frames*BBWENET_FNET_TCONV_OUT_CHANNELS*BBWENET_FNET_TCONV_STRIDE); /* GRU */ celt_assert(BBWENET_FNET_TCONV_STRIDE == 2); - for (i_subframe = 0; i_subframe < BBWENET_FNET_TCONV_STRIDE * num_frames; i_subframe ++) - { - compute_generic_gru( + for (i_subframe = 0; i_subframe < BBWENET_FNET_TCONV_STRIDE*num_frames; i_subframe++) { + oaci_compute_generic_gru( &hBBWENET->layers.bbwenet_fnet_gru_input, &hBBWENET->layers.bbwenet_fnet_gru_recurrent, state->feature_net_gru_state, - input_buffer + i_subframe * BBWENET_FNET_TCONV_OUT_CHANNELS, + input_buffer + i_subframe*BBWENET_FNET_TCONV_OUT_CHANNELS, arch - ); -#ifdef DEBUG_BBWENET + ); +# ifdef DEBUG_BBWENET fwrite(state->feature_net_gru_state, sizeof(float), BBWENET_FNET_GRU_STATE_SIZE, f_gru); -#endif - OPUS_COPY(output + i_subframe * BBWENET_FNET_GRU_STATE_SIZE, state->feature_net_gru_state, BBWENET_FNET_GRU_STATE_SIZE); +# endif + OAC_COPY(output + i_subframe*BBWENET_FNET_GRU_STATE_SIZE, state->feature_net_gru_state, + BBWENET_FNET_GRU_STATE_SIZE); } } @@ -968,157 +955,147 @@ static float frac_17_24[8] = { static float frac_09_24[8] = { -0.00146484, 0.02313232, -0.12072754, 0.7315979, - 0.4621277, -0.12075806, 0.0295105 , -0.00326538 + 0.4621277, -0.12075806, 0.0295105, -0.00326538 }; -static void apply_valin_activation(float *x, int len) -{ +static void oaci_apply_valin_activation(float *x, int len) { int i; - float y[2 * BBWENET_TDSHAPE2_FRAME_SIZE]; - celt_assert(len <= 2 * BBWENET_TDSHAPE2_FRAME_SIZE); - for (i = 0; i < len; i++) - { + float y[2*BBWENET_TDSHAPE2_FRAME_SIZE]; + celt_assert(len <= 2*BBWENET_TDSHAPE2_FRAME_SIZE); + for (i = 0; i < len; i++) { y[i] = fabs(x[i]) + 1e-6f; } - for (i = 0; i < len; i++) - { + for (i = 0; i < len; i++) { y[i] = celt_log(y[i]); } - for (i = 0; i < len; i++) - { - x[i] *= celt_sin(y[i]); + for (i = 0; i < len; i++) { + x[i] *= oaci_celt_sin(y[i]); } } -#define DELAY_SAMPLES 8 /* ToDo: this probably should be 7, bug in python code? */ -static void interpol_3_2(resamp_state *state, float *x_out, const float *x_in, int num_samples) -{ +# define DELAY_SAMPLES 8 /* ToDo: this probably should be 7, bug in python code? */ +static void oaci_interpol_3_2(resamp_state *state, float *x_out, const float *x_in, int num_samples) { int i_sample, i_out = 0; - float buffer[8 * BBWENET_FRAME_SIZE16 + DELAY_SAMPLES]; + float buffer[8*BBWENET_FRAME_SIZE16 + DELAY_SAMPLES]; celt_assert(num_samples > 1); - celt_assert(num_samples < 8 * BBWENET_FRAME_SIZE16); - celt_assert(num_samples % 2 == 0); - - OPUS_COPY(buffer, state->interpol_buffer, DELAY_SAMPLES); - OPUS_COPY(buffer + DELAY_SAMPLES, x_in, num_samples); - - for (i_sample = 0; i_sample < num_samples; i_sample+=2) - { - x_out[i_out++] = buffer[i_sample + 0] * frac_01_24[0] + - buffer[i_sample + 1] * frac_01_24[1] + - buffer[i_sample + 2] * frac_01_24[2] + - buffer[i_sample + 3] * frac_01_24[3] + - buffer[i_sample + 4] * frac_01_24[4] + - buffer[i_sample + 5] * frac_01_24[5] + - buffer[i_sample + 6] * frac_01_24[6] + - buffer[i_sample + 7] * frac_01_24[7]; - - x_out[i_out++] = buffer[i_sample + 0] * frac_17_24[0] + - buffer[i_sample + 1] * frac_17_24[1] + - buffer[i_sample + 2] * frac_17_24[2] + - buffer[i_sample + 3] * frac_17_24[3] + - buffer[i_sample + 4] * frac_17_24[4] + - buffer[i_sample + 5] * frac_17_24[5] + - buffer[i_sample + 6] * frac_17_24[6] + - buffer[i_sample + 7] * frac_17_24[7]; - - x_out[i_out++] = buffer[i_sample + 1] * frac_09_24[0] + - buffer[i_sample + 2] * frac_09_24[1] + - buffer[i_sample + 3] * frac_09_24[2] + - buffer[i_sample + 4] * frac_09_24[3] + - buffer[i_sample + 5] * frac_09_24[4] + - buffer[i_sample + 6] * frac_09_24[5] + - buffer[i_sample + 7] * frac_09_24[6] + - buffer[i_sample + 8] * frac_09_24[7]; + celt_assert(num_samples < 8*BBWENET_FRAME_SIZE16); + celt_assert(num_samples%2 == 0); + + OAC_COPY(buffer, state->interpol_buffer, DELAY_SAMPLES); + OAC_COPY(buffer + DELAY_SAMPLES, x_in, num_samples); + + for (i_sample = 0; i_sample < num_samples; i_sample += 2) { + x_out[i_out++] = buffer[i_sample + 0]*frac_01_24[0] + + buffer[i_sample + 1]*frac_01_24[1] + + buffer[i_sample + 2]*frac_01_24[2] + + buffer[i_sample + 3]*frac_01_24[3] + + buffer[i_sample + 4]*frac_01_24[4] + + buffer[i_sample + 5]*frac_01_24[5] + + buffer[i_sample + 6]*frac_01_24[6] + + buffer[i_sample + 7]*frac_01_24[7]; + + x_out[i_out++] = buffer[i_sample + 0]*frac_17_24[0] + + buffer[i_sample + 1]*frac_17_24[1] + + buffer[i_sample + 2]*frac_17_24[2] + + buffer[i_sample + 3]*frac_17_24[3] + + buffer[i_sample + 4]*frac_17_24[4] + + buffer[i_sample + 5]*frac_17_24[5] + + buffer[i_sample + 6]*frac_17_24[6] + + buffer[i_sample + 7]*frac_17_24[7]; + + x_out[i_out++] = buffer[i_sample + 1]*frac_09_24[0] + + buffer[i_sample + 2]*frac_09_24[1] + + buffer[i_sample + 3]*frac_09_24[2] + + buffer[i_sample + 4]*frac_09_24[3] + + buffer[i_sample + 5]*frac_09_24[4] + + buffer[i_sample + 6]*frac_09_24[5] + + buffer[i_sample + 7]*frac_09_24[6] + + buffer[i_sample + 8]*frac_09_24[7]; } /* copy last samples to buffer */ - OPUS_COPY(state->interpol_buffer, buffer + num_samples, DELAY_SAMPLES); + OAC_COPY(state->interpol_buffer, buffer + num_samples, DELAY_SAMPLES); } -static void upsamp_2x(resamp_state *state, float *x_out, const float *x_in, int num_samples) -{ - float buffer [4 * BBWENET_FRAME_SIZE16]; +static void oaci_upsamp_2x(resamp_state *state, float *x_out, const float *x_in, int num_samples) { + float buffer[4*BBWENET_FRAME_SIZE16]; float *S_even = state->upsamp_buffer[0]; float *S_odd = state->upsamp_buffer[1]; int k; float x, X, Y, tmp1, tmp2, tmp3; celt_assert(num_samples > 1); - celt_assert(num_samples < 4 * BBWENET_FRAME_SIZE16); + celt_assert(num_samples < 4*BBWENET_FRAME_SIZE16); - OPUS_COPY(buffer, x_in, num_samples); + OAC_COPY(buffer, x_in, num_samples); - for (k = 0; k < num_samples; k++) - { + for (k = 0; k < num_samples; k++) { x = buffer[k]; /* even sample, first pass, */ Y = x - S_even[0]; - X = Y * hq_2x_even[0]; + X = Y*hq_2x_even[0]; tmp1 = S_even[0] + X; S_even[0] = x + X; /* ...second pass, */ Y = tmp1 - S_even[1]; - X = Y * hq_2x_even[1]; + X = Y*hq_2x_even[1]; tmp2 = S_even[1] + X; S_even[1] = tmp1 + X; /* ...third pass */ Y = tmp2 - S_even[2]; - X = Y * (1 + hq_2x_even[2]); + X = Y*(1 + hq_2x_even[2]); tmp3 = S_even[2] + X; S_even[2] = tmp2 + X; - x_out[2 * k] = tmp3; + x_out[2*k] = tmp3; /* odd sample, first pass, */ Y = x - S_odd[0]; - X = Y * hq_2x_odd[0]; + X = Y*hq_2x_odd[0]; tmp1 = S_odd[0] + X; S_odd[0] = x + X; /* ...second pass, */ Y = tmp1 - S_odd[1]; - X = Y * hq_2x_odd[1]; + X = Y*hq_2x_odd[1]; tmp2 = S_odd[1] + X; S_odd[1] = tmp1 + X; /* ...third pass */ Y = tmp2 - S_odd[2]; - X = Y * (1 + hq_2x_odd[2]); + X = Y*(1 + hq_2x_odd[2]); tmp3 = S_odd[2] + X; S_odd[2] = tmp2 + X; - x_out[2 * k + 1] = tmp3; + x_out[2*k + 1] = tmp3; } } -static void bbwenet_process_frames( +static void oaci_bbwenet_process_frames( BBWENet *hBBWENET, BBWENetState *state, float *x_out, const float *x_in, const float *features, int num_frames, - int arch -) -{ - float latent_features[4 * BBWENET_COND_DIM]; - int i_subframe, num_subframes = 2 * num_frames, i_channel; - float x_buffer1[3 * 3 * 4 * 3*BBWENET_FRAME_SIZE16] = {0}; /* 3x3 channels, 4 subframes, 48 kHz */ - float x_buffer2[3 * 3 * 4 * 3*BBWENET_FRAME_SIZE16] = {0}; + int arch) { + float latent_features[4*BBWENET_COND_DIM]; + int i_subframe, num_subframes = 2*num_frames, i_channel; + float x_buffer1[3*3*4*3*BBWENET_FRAME_SIZE16] = {0}; /* 3x3 channels, 4 subframes, 48 kHz */ + float x_buffer2[3*3*4*3*BBWENET_FRAME_SIZE16] = {0}; BBWENETLayers *layers = &hBBWENET->layers; -#ifdef DEBUG_BBWENET - static FILE *f_latent=NULL, *f_xin=NULL, *f_af1_1=NULL, *f_af1_2=NULL, *f_af1_3=NULL; - static FILE *f_up2_1=NULL, *f_up2_2=NULL, *f_up2_3=NULL, *f2_up_shape=NULL, *f2_up_func=NULL; - static FILE *f_af2_1=NULL, *f_af2_2=NULL, *f_af2_3=NULL; - static FILE *f_up15_1=NULL, *f_up15_2=NULL, *f_up15_3=NULL; - static FILE *f_up15_shape=NULL, *f_up15_func=NULL; - static FILE *f_af3_1=NULL; +# ifdef DEBUG_BBWENET + static FILE *f_latent = NULL, *f_xin = NULL, *f_af1_1 = NULL, *f_af1_2 = NULL, *f_af1_3 = NULL; + static FILE *f_up2_1 = NULL, *f_up2_2 = NULL, *f_up2_3 = NULL, *f2_up_shape = NULL, *f2_up_func = NULL; + static FILE *f_af2_1 = NULL, *f_af2_2 = NULL, *f_af2_3 = NULL; + static FILE *f_up15_1 = NULL, *f_up15_2 = NULL, *f_up15_3 = NULL; + static FILE *f_up15_shape = NULL, *f_up15_func = NULL; + static FILE *f_af3_1 = NULL; FINIT(f_latent, "dnn/torch/osce/debugdump/feature_net_gru.f32", "rb"); FINIT(f_xin, "debug/bbwenet_x_in.f32", "wb"); @@ -1139,27 +1116,26 @@ static void bbwenet_process_frames( FINIT(f_up15_shape, "debug/bbwenet_up15_shape.f32", "wb"); FINIT(f_up15_func, "debug/bbwenet_up15_func.f32", "wb"); FINIT(f_af3_1, "debug/bbwenet_af3_1.f32", "wb"); - fwrite(x_in, sizeof(*x_in), num_subframes * BBWENET_AF1_FRAME_SIZE, f_xin); -#endif + fwrite(x_in, sizeof(*x_in), num_subframes*BBWENET_AF1_FRAME_SIZE, f_xin); +# endif /* feature net */ - bbwe_feature_net(hBBWENET, state, latent_features, features, num_frames, arch); -#ifdef DEBUG_BBWENET - if (f_latent != NULL){ - fread(latent_features, sizeof(*latent_features), num_subframes * BBWENET_COND_DIM, f_latent); + oaci_bbwe_feature_net(hBBWENET, state, latent_features, features, num_frames, arch); +# ifdef DEBUG_BBWENET + if (f_latent != NULL) { + fread(latent_features, sizeof(*latent_features), num_subframes*BBWENET_COND_DIM, f_latent); } -#endif +# endif /* signal net * first adaptive filtering stage, three output channels */ - for (i_subframe = 0; i_subframe < num_subframes; i_subframe++) - { - adaconv_process_frame( + for (i_subframe = 0; i_subframe < num_subframes; i_subframe++) { + oaci_adaconv_process_frame( &state->af1_state, - x_buffer1 + i_subframe * BBWENET_AF1_FRAME_SIZE * BBWENET_AF1_OUT_CHANNELS, - x_in + i_subframe * BBWENET_AF1_FRAME_SIZE, - latent_features + i_subframe * BBWENET_COND_DIM, + x_buffer1 + i_subframe*BBWENET_AF1_FRAME_SIZE*BBWENET_AF1_OUT_CHANNELS, + x_in + i_subframe*BBWENET_AF1_FRAME_SIZE, + latent_features + i_subframe*BBWENET_COND_DIM, &layers->bbwenet_af1_kernel, &layers->bbwenet_af1_gain, BBWENET_COND_DIM, @@ -1175,42 +1151,48 @@ static void bbwenet_process_frames( hBBWENET->window16, arch); -#ifdef DEBUG_BBWENET - fwrite(x_buffer1 + i_subframe * BBWENET_AF1_FRAME_SIZE * BBWENET_AF1_OUT_CHANNELS, sizeof(float), BBWENET_AF1_FRAME_SIZE, f_af1_1); - fwrite(x_buffer1 + i_subframe * BBWENET_AF1_FRAME_SIZE * BBWENET_AF1_OUT_CHANNELS + BBWENET_AF1_FRAME_SIZE, sizeof(float), BBWENET_AF1_FRAME_SIZE, f_af1_2); - fwrite(x_buffer1 + i_subframe * BBWENET_AF1_FRAME_SIZE * BBWENET_AF1_OUT_CHANNELS + 2 * BBWENET_AF1_FRAME_SIZE, sizeof(float), BBWENET_AF1_FRAME_SIZE, f_af1_3); -#endif +# ifdef DEBUG_BBWENET + fwrite(x_buffer1 + i_subframe*BBWENET_AF1_FRAME_SIZE*BBWENET_AF1_OUT_CHANNELS, sizeof(float), + BBWENET_AF1_FRAME_SIZE, f_af1_1); + fwrite(x_buffer1 + i_subframe*BBWENET_AF1_FRAME_SIZE*BBWENET_AF1_OUT_CHANNELS + BBWENET_AF1_FRAME_SIZE, + sizeof(float), BBWENET_AF1_FRAME_SIZE, f_af1_2); + fwrite(x_buffer1 + i_subframe*BBWENET_AF1_FRAME_SIZE*BBWENET_AF1_OUT_CHANNELS + 2*BBWENET_AF1_FRAME_SIZE, + sizeof(float), BBWENET_AF1_FRAME_SIZE, f_af1_3); +# endif } /* 1st round of non-linear extension */ - for (i_subframe = 0; i_subframe < num_subframes; i_subframe++) - { + for (i_subframe = 0; i_subframe < num_subframes; i_subframe++) { /* 2x upsampling on individual channels */ celt_assert(BBWENET_AF1_OUT_CHANNELS == 3); - celt_assert(2 * BBWENET_AF1_FRAME_SIZE == BBWENET_TDSHAPE1_FRAME_SIZE); - for (i_channel = 0; i_channel < 3; i_channel ++) - { - upsamp_2x( + celt_assert(2*BBWENET_AF1_FRAME_SIZE == BBWENET_TDSHAPE1_FRAME_SIZE); + for (i_channel = 0; i_channel < 3; i_channel++) { + oaci_upsamp_2x( &state->resampler_state[i_channel], - x_buffer2 + i_subframe * BBWENET_TDSHAPE1_FRAME_SIZE * BBWENET_AF1_OUT_CHANNELS + i_channel * BBWENET_TDSHAPE1_FRAME_SIZE, - x_buffer1 + i_subframe * BBWENET_AF1_FRAME_SIZE * BBWENET_AF1_OUT_CHANNELS + i_channel * BBWENET_AF1_FRAME_SIZE, + x_buffer2 + i_subframe*BBWENET_TDSHAPE1_FRAME_SIZE*BBWENET_AF1_OUT_CHANNELS + i_channel + *BBWENET_TDSHAPE1_FRAME_SIZE, + x_buffer1 + i_subframe*BBWENET_AF1_FRAME_SIZE*BBWENET_AF1_OUT_CHANNELS + i_channel + *BBWENET_AF1_FRAME_SIZE, BBWENET_AF1_FRAME_SIZE - ); + ); } -#ifdef DEBUG_BBWENET - fwrite(x_buffer2 + i_subframe * BBWENET_AF1_OUT_CHANNELS * BBWENET_TDSHAPE1_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE1_FRAME_SIZE, f_up2_1); - fwrite(x_buffer2 + i_subframe * BBWENET_AF1_OUT_CHANNELS * BBWENET_TDSHAPE1_FRAME_SIZE + BBWENET_TDSHAPE1_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE1_FRAME_SIZE, f_up2_2); - fwrite(x_buffer2 + i_subframe * BBWENET_AF1_OUT_CHANNELS * BBWENET_TDSHAPE1_FRAME_SIZE + 2 * BBWENET_TDSHAPE1_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE1_FRAME_SIZE, f_up2_3); -#endif +# ifdef DEBUG_BBWENET + fwrite(x_buffer2 + i_subframe*BBWENET_AF1_OUT_CHANNELS*BBWENET_TDSHAPE1_FRAME_SIZE, sizeof(float), + BBWENET_TDSHAPE1_FRAME_SIZE, f_up2_1); + fwrite(x_buffer2 + i_subframe*BBWENET_AF1_OUT_CHANNELS*BBWENET_TDSHAPE1_FRAME_SIZE + + BBWENET_TDSHAPE1_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE1_FRAME_SIZE, f_up2_2); + fwrite(x_buffer2 + i_subframe*BBWENET_AF1_OUT_CHANNELS*BBWENET_TDSHAPE1_FRAME_SIZE + 2 + *BBWENET_TDSHAPE1_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE1_FRAME_SIZE, f_up2_3); +# endif /* tdshape on second channel (in place) */ - adashape_process_frame( + oaci_adashape_process_frame( &state->tdshape1_state, - x_buffer2 + i_subframe * BBWENET_AF1_OUT_CHANNELS * BBWENET_TDSHAPE1_FRAME_SIZE + BBWENET_TDSHAPE1_FRAME_SIZE, - x_buffer2 + i_subframe * BBWENET_AF1_OUT_CHANNELS * BBWENET_TDSHAPE1_FRAME_SIZE + BBWENET_TDSHAPE1_FRAME_SIZE, - latent_features + i_subframe * BBWENET_COND_DIM, + x_buffer2 + i_subframe*BBWENET_AF1_OUT_CHANNELS*BBWENET_TDSHAPE1_FRAME_SIZE + BBWENET_TDSHAPE1_FRAME_SIZE, + x_buffer2 + i_subframe*BBWENET_AF1_OUT_CHANNELS*BBWENET_TDSHAPE1_FRAME_SIZE + BBWENET_TDSHAPE1_FRAME_SIZE, + latent_features + i_subframe*BBWENET_COND_DIM, &layers->bbwenet_tdshape1_alpha1_f, &layers->bbwenet_tdshape1_alpha1_t, &layers->bbwenet_tdshape1_alpha2, @@ -1219,31 +1201,32 @@ static void bbwenet_process_frames( BBWENET_TDSHAPE1_AVG_POOL_K, BBWENET_TDSHAPE1_INTERPOLATE_K, arch - ); + ); -#ifdef DEBUG_BBWENET - fwrite(x_buffer2 + i_subframe * BBWENET_AF1_OUT_CHANNELS * BBWENET_TDSHAPE1_FRAME_SIZE + BBWENET_TDSHAPE1_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE1_FRAME_SIZE, f2_up_shape); -#endif +# ifdef DEBUG_BBWENET + fwrite(x_buffer2 + i_subframe*BBWENET_AF1_OUT_CHANNELS*BBWENET_TDSHAPE1_FRAME_SIZE + + BBWENET_TDSHAPE1_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE1_FRAME_SIZE, f2_up_shape); +# endif /* non-linear activation of third channel (in place)*/ - apply_valin_activation( - x_buffer2 + i_subframe * BBWENET_AF1_OUT_CHANNELS * BBWENET_TDSHAPE1_FRAME_SIZE + 2 * BBWENET_TDSHAPE1_FRAME_SIZE, + oaci_apply_valin_activation( + x_buffer2 + i_subframe*BBWENET_AF1_OUT_CHANNELS*BBWENET_TDSHAPE1_FRAME_SIZE + 2*BBWENET_TDSHAPE1_FRAME_SIZE, BBWENET_TDSHAPE1_FRAME_SIZE - ); -#ifdef DEBUG_BBWENET - fwrite(x_buffer2 + i_subframe * BBWENET_AF1_OUT_CHANNELS * BBWENET_TDSHAPE1_FRAME_SIZE + 2 * BBWENET_TDSHAPE1_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE1_FRAME_SIZE, f2_up_func); -#endif + ); +# ifdef DEBUG_BBWENET + fwrite(x_buffer2 + i_subframe*BBWENET_AF1_OUT_CHANNELS*BBWENET_TDSHAPE1_FRAME_SIZE + 2 + *BBWENET_TDSHAPE1_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE1_FRAME_SIZE, f2_up_func); +# endif } /* mixing */ - for (i_subframe = 0; i_subframe < num_subframes; i_subframe++) - { - adaconv_process_frame( + for (i_subframe = 0; i_subframe < num_subframes; i_subframe++) { + oaci_adaconv_process_frame( &state->af2_state, - x_buffer1 + i_subframe * BBWENET_AF2_FRAME_SIZE * BBWENET_AF2_OUT_CHANNELS, - x_buffer2 + i_subframe * BBWENET_AF2_FRAME_SIZE * BBWENET_AF1_OUT_CHANNELS, - latent_features + i_subframe * BBWENET_COND_DIM, + x_buffer1 + i_subframe*BBWENET_AF2_FRAME_SIZE*BBWENET_AF2_OUT_CHANNELS, + x_buffer2 + i_subframe*BBWENET_AF2_FRAME_SIZE*BBWENET_AF1_OUT_CHANNELS, + latent_features + i_subframe*BBWENET_COND_DIM, &layers->bbwenet_af2_kernel, &layers->bbwenet_af2_gain, BBWENET_COND_DIM, @@ -1258,41 +1241,47 @@ static void bbwenet_process_frames( BBWENET_AF2_SHAPE_GAIN, hBBWENET->window32, arch); -#ifdef DEBUG_BBWENET - fwrite(x_buffer1 + i_subframe * BBWENET_AF2_FRAME_SIZE * BBWENET_AF2_OUT_CHANNELS, sizeof(float), BBWENET_AF2_FRAME_SIZE, f_af2_1); - fwrite(x_buffer1 + i_subframe * BBWENET_AF2_FRAME_SIZE * BBWENET_AF2_OUT_CHANNELS + BBWENET_AF2_FRAME_SIZE, sizeof(float), BBWENET_AF2_FRAME_SIZE, f_af2_2); - fwrite(x_buffer1 + i_subframe * BBWENET_AF2_FRAME_SIZE * BBWENET_AF2_OUT_CHANNELS + 2 * BBWENET_AF2_FRAME_SIZE, sizeof(float), BBWENET_AF2_FRAME_SIZE, f_af2_3); -#endif +# ifdef DEBUG_BBWENET + fwrite(x_buffer1 + i_subframe*BBWENET_AF2_FRAME_SIZE*BBWENET_AF2_OUT_CHANNELS, sizeof(float), + BBWENET_AF2_FRAME_SIZE, f_af2_1); + fwrite(x_buffer1 + i_subframe*BBWENET_AF2_FRAME_SIZE*BBWENET_AF2_OUT_CHANNELS + BBWENET_AF2_FRAME_SIZE, + sizeof(float), BBWENET_AF2_FRAME_SIZE, f_af2_2); + fwrite(x_buffer1 + i_subframe*BBWENET_AF2_FRAME_SIZE*BBWENET_AF2_OUT_CHANNELS + 2*BBWENET_AF2_FRAME_SIZE, + sizeof(float), BBWENET_AF2_FRAME_SIZE, f_af2_3); +# endif } /* second round of extension */ - for (i_subframe = 0; i_subframe < num_subframes; i_subframe++) - { + for (i_subframe = 0; i_subframe < num_subframes; i_subframe++) { /* 1.5x interpolation on individual channels */ celt_assert(BBWENET_AF2_OUT_CHANNELS == 3); - celt_assert(3 * BBWENET_AF2_FRAME_SIZE == 2 * BBWENET_TDSHAPE2_FRAME_SIZE); - for (i_channel = 0; i_channel < 3; i_channel ++) - { - interpol_3_2( + celt_assert(3*BBWENET_AF2_FRAME_SIZE == 2*BBWENET_TDSHAPE2_FRAME_SIZE); + for (i_channel = 0; i_channel < 3; i_channel++) { + oaci_interpol_3_2( &state->resampler_state[i_channel], - x_buffer2 + i_subframe * BBWENET_AF3_FRAME_SIZE * BBWENET_AF2_OUT_CHANNELS + i_channel * BBWENET_TDSHAPE2_FRAME_SIZE, - x_buffer1 + i_subframe * BBWENET_TDSHAPE1_FRAME_SIZE * BBWENET_AF2_OUT_CHANNELS + i_channel * BBWENET_TDSHAPE1_FRAME_SIZE, + x_buffer2 + i_subframe*BBWENET_AF3_FRAME_SIZE*BBWENET_AF2_OUT_CHANNELS + i_channel + *BBWENET_TDSHAPE2_FRAME_SIZE, + x_buffer1 + i_subframe*BBWENET_TDSHAPE1_FRAME_SIZE*BBWENET_AF2_OUT_CHANNELS + i_channel + *BBWENET_TDSHAPE1_FRAME_SIZE, BBWENET_TDSHAPE1_FRAME_SIZE - ); + ); } -#ifdef DEBUG_BBWENET - fwrite(x_buffer2 + i_subframe * BBWENET_AF2_OUT_CHANNELS * BBWENET_TDSHAPE2_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE2_FRAME_SIZE, f_up15_1); - fwrite(x_buffer2 + i_subframe * BBWENET_AF2_OUT_CHANNELS * BBWENET_TDSHAPE2_FRAME_SIZE + BBWENET_TDSHAPE2_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE2_FRAME_SIZE, f_up15_2); - fwrite(x_buffer2 + i_subframe * BBWENET_AF2_OUT_CHANNELS * BBWENET_TDSHAPE2_FRAME_SIZE + 2 * BBWENET_TDSHAPE2_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE2_FRAME_SIZE, f_up15_3); -#endif +# ifdef DEBUG_BBWENET + fwrite(x_buffer2 + i_subframe*BBWENET_AF2_OUT_CHANNELS*BBWENET_TDSHAPE2_FRAME_SIZE, sizeof(float), + BBWENET_TDSHAPE2_FRAME_SIZE, f_up15_1); + fwrite(x_buffer2 + i_subframe*BBWENET_AF2_OUT_CHANNELS*BBWENET_TDSHAPE2_FRAME_SIZE + + BBWENET_TDSHAPE2_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE2_FRAME_SIZE, f_up15_2); + fwrite(x_buffer2 + i_subframe*BBWENET_AF2_OUT_CHANNELS*BBWENET_TDSHAPE2_FRAME_SIZE + 2 + *BBWENET_TDSHAPE2_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE2_FRAME_SIZE, f_up15_3); +# endif /* tdshape on second channel (in place) */ - adashape_process_frame( + oaci_adashape_process_frame( &state->tdshape2_state, - x_buffer2 + i_subframe * BBWENET_AF2_OUT_CHANNELS * BBWENET_TDSHAPE2_FRAME_SIZE + BBWENET_TDSHAPE2_FRAME_SIZE, - x_buffer2 + i_subframe * BBWENET_AF2_OUT_CHANNELS * BBWENET_TDSHAPE2_FRAME_SIZE + BBWENET_TDSHAPE2_FRAME_SIZE, - latent_features + i_subframe * BBWENET_COND_DIM, + x_buffer2 + i_subframe*BBWENET_AF2_OUT_CHANNELS*BBWENET_TDSHAPE2_FRAME_SIZE + BBWENET_TDSHAPE2_FRAME_SIZE, + x_buffer2 + i_subframe*BBWENET_AF2_OUT_CHANNELS*BBWENET_TDSHAPE2_FRAME_SIZE + BBWENET_TDSHAPE2_FRAME_SIZE, + latent_features + i_subframe*BBWENET_COND_DIM, &layers->bbwenet_tdshape2_alpha1_f, &layers->bbwenet_tdshape2_alpha1_t, &layers->bbwenet_tdshape2_alpha2, @@ -1301,31 +1290,32 @@ static void bbwenet_process_frames( BBWENET_TDSHAPE2_AVG_POOL_K, BBWENET_TDSHAPE2_INTERPOLATE_K, arch - ); + ); -#ifdef DEBUG_BBWENET - fwrite(x_buffer2 + i_subframe * BBWENET_AF2_OUT_CHANNELS * BBWENET_TDSHAPE2_FRAME_SIZE + BBWENET_TDSHAPE2_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE2_FRAME_SIZE, f_up15_shape); -#endif +# ifdef DEBUG_BBWENET + fwrite(x_buffer2 + i_subframe*BBWENET_AF2_OUT_CHANNELS*BBWENET_TDSHAPE2_FRAME_SIZE + + BBWENET_TDSHAPE2_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE2_FRAME_SIZE, f_up15_shape); +# endif /* non-linear activation of third channel (in place)*/ - apply_valin_activation( - x_buffer2 + i_subframe * BBWENET_AF2_OUT_CHANNELS * BBWENET_TDSHAPE2_FRAME_SIZE + 2 * BBWENET_TDSHAPE2_FRAME_SIZE, + oaci_apply_valin_activation( + x_buffer2 + i_subframe*BBWENET_AF2_OUT_CHANNELS*BBWENET_TDSHAPE2_FRAME_SIZE + 2*BBWENET_TDSHAPE2_FRAME_SIZE, BBWENET_TDSHAPE2_FRAME_SIZE - ); -#ifdef DEBUG_BBWENET - fwrite(x_buffer2 + i_subframe * BBWENET_AF2_OUT_CHANNELS * BBWENET_TDSHAPE2_FRAME_SIZE + 2 * BBWENET_TDSHAPE2_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE2_FRAME_SIZE, f_up15_func); -#endif + ); +# ifdef DEBUG_BBWENET + fwrite(x_buffer2 + i_subframe*BBWENET_AF2_OUT_CHANNELS*BBWENET_TDSHAPE2_FRAME_SIZE + 2 + *BBWENET_TDSHAPE2_FRAME_SIZE, sizeof(float), BBWENET_TDSHAPE2_FRAME_SIZE, f_up15_func); +# endif } /* final mixing */ celt_assert(BBWENET_AF3_OUT_CHANNELS == 1); - for (i_subframe = 0; i_subframe < num_subframes; i_subframe++) - { - adaconv_process_frame( + for (i_subframe = 0; i_subframe < num_subframes; i_subframe++) { + oaci_adaconv_process_frame( &state->af3_state, - x_out + i_subframe * BBWENET_AF3_FRAME_SIZE, - x_buffer2 + i_subframe * BBWENET_TDSHAPE2_FRAME_SIZE * BBWENET_AF2_OUT_CHANNELS, - latent_features + i_subframe * BBWENET_COND_DIM, + x_out + i_subframe*BBWENET_AF3_FRAME_SIZE, + x_buffer2 + i_subframe*BBWENET_TDSHAPE2_FRAME_SIZE*BBWENET_AF2_OUT_CHANNELS, + latent_features + i_subframe*BBWENET_COND_DIM, &layers->bbwenet_af3_kernel, &layers->bbwenet_af3_gain, BBWENET_COND_DIM, @@ -1342,60 +1332,56 @@ static void bbwenet_process_frames( arch); } -#ifdef DEBUG_BBWENET - fwrite(x_out, sizeof(float), num_subframes * BBWENET_AF3_FRAME_SIZE, f_af3_1); -#endif +# ifdef DEBUG_BBWENET + fwrite(x_out, sizeof(float), num_subframes*BBWENET_AF3_FRAME_SIZE, f_af3_1); +# endif } -static void reset_bbwenet_state(BBWENetState *state) -{ - OPUS_CLEAR(state, 1); +static void oaci_reset_bbwenet_state(BBWENetState *state) { + OAC_CLEAR(state, 1); - init_adaconv_state(&state->af1_state); - init_adaconv_state(&state->af2_state); - init_adaconv_state(&state->af3_state); - init_adashape_state(&state->tdshape1_state); - init_adashape_state(&state->tdshape2_state); + oaci_init_adaconv_state(&state->af1_state); + oaci_init_adaconv_state(&state->af2_state); + oaci_init_adaconv_state(&state->af3_state); + oaci_init_adashape_state(&state->tdshape1_state); + oaci_init_adashape_state(&state->tdshape2_state); } -static int init_bbwenet(BBWENet *hBBWENET, const WeightArray *weights) -{ +static int oaci_init_bbwenet(BBWENet *hBBWENET, const WeightArray *weights) { int ret = 0; - OPUS_CLEAR(hBBWENET, 1); + OAC_CLEAR(hBBWENET, 1); celt_assert(weights != NULL); - ret = init_bbwenetlayers(&hBBWENET->layers, weights); + ret = oaci_init_bbwenetlayers(&hBBWENET->layers, weights); - compute_overlap_window(hBBWENET->window16, BBWENET_AF1_OVERLAP_SIZE); - compute_overlap_window(hBBWENET->window32, BBWENET_AF2_OVERLAP_SIZE); - compute_overlap_window(hBBWENET->window48, BBWENET_AF3_OVERLAP_SIZE); + oaci_compute_overlap_window(hBBWENET->window16, BBWENET_AF1_OVERLAP_SIZE); + oaci_compute_overlap_window(hBBWENET->window32, BBWENET_AF2_OVERLAP_SIZE); + oaci_compute_overlap_window(hBBWENET->window48, BBWENET_AF3_OVERLAP_SIZE); return ret; } -#endif +# endif #endif /* ENABLE_OSCE_BWE */ /* API */ -void osce_reset(silk_OSCE_struct *hOSCE, int method) -{ +void oaci_osce_reset(silk_OSCE_struct *hOSCE, int method) { OSCEState *state = &hOSCE->state; - OPUS_CLEAR(&hOSCE->features, 1); + OAC_CLEAR(&hOSCE->features, 1); - switch(method) - { + switch (method) { case OSCE_METHOD_NONE: break; #ifndef DISABLE_LACE case OSCE_METHOD_LACE: - reset_lace_state(&state->lace); + oaci_reset_lace_state(&state->lace); break; #endif #ifndef DISABLE_NOLACE case OSCE_METHOD_NOLACE: - reset_nolace_state(&state->nolace); + oaci_reset_nolace_state(&state->nolace); break; #endif default: @@ -1407,66 +1393,73 @@ void osce_reset(silk_OSCE_struct *hOSCE, int method) #ifdef ENABLE_OSCE_BWE -void osce_bwe_reset(silk_OSCE_BWE_struct *hOSCEBWE) -{ +void oaci_osce_bwe_reset(silk_OSCE_BWE_struct *hOSCEBWE) { int k; - OPUS_CLEAR(&hOSCEBWE->features, 1); -#if 1 + OAC_CLEAR(&hOSCEBWE->features, 1); +# if 1 /* weird python initialization: Fix eventually! */ - for (k = 0; k <= OSCE_BWE_MAX_INSTAFREQ_BIN; k ++) - { + for (k = 0; k <= OSCE_BWE_MAX_INSTAFREQ_BIN; k++) { hOSCEBWE->features.last_spec[2*k] = 1e-9; } -#endif - reset_bbwenet_state(&hOSCEBWE->state.bbwenet); +# endif + oaci_reset_bbwenet_state(&hOSCEBWE->state.bbwenet); } #endif /* ENABLE_OSCE_BWE */ -int osce_load_models(OSCEModel *model, const void *data, int len) -{ +int oaci_osce_load_models(OSCEModel *model, const void *data, int len) { int ret = 0; WeightArray *list; - if (data != NULL && len) - { + if (data != NULL && len) { /* init from buffer */ - parse_weights(&list, data, len); + oaci_parse_weights(&list, data, len); #ifndef DISABLE_LACE - if (ret == 0) {ret = init_lace(&model->lace, list);} + if (ret == 0) { + ret = oaci_init_lace(&model->lace, list); + } #endif #ifndef DISABLE_NOLACE - if (ret == 0) {ret = init_nolace(&model->nolace, list);} + if (ret == 0) { + ret = oaci_init_nolace(&model->nolace, list); + } #endif #ifdef ENABLE_OSCE_BWE -#ifndef DISABLE_BBWENET - if (ret == 0) {ret = init_bbwenet(&model->bbwenet, list);} -#endif +# ifndef DISABLE_BBWENET + if (ret == 0) { + ret = oaci_init_bbwenet(&model->bbwenet, list); + } +# endif #endif /* ENABLE_OSCE_BWE */ free(list); - } else - { + } else { #ifdef USE_WEIGHTS_FILE return -1; #else -#ifndef DISABLE_LACE - if (ret == 0) {ret = init_lace(&model->lace, lacelayers_arrays);} -#endif +# ifndef DISABLE_LACE + if (ret == 0) { + ret = oaci_init_lace(&model->lace, oaci_lacelayers_arrays); + } +# endif -#ifndef DISABLE_NOLACE - if (ret == 0) {ret = init_nolace(&model->nolace, nolacelayers_arrays);} -#endif +# ifndef DISABLE_NOLACE + if (ret == 0) { + ret = oaci_init_nolace(&model->nolace, oaci_nolacelayers_arrays); + } +# endif -#ifdef ENABLE_OSCE_BWE -#ifndef DISABLE_BBWENET - if (ret == 0) {ret = init_bbwenet(&model->bbwenet, bbwenetlayers_arrays);} -#endif -#endif /* ENABLE_OSCE_BWE */ +# ifdef ENABLE_OSCE_BWE +# ifndef DISABLE_BBWENET + if (ret == 0) { + ret = oaci_init_bbwenet(&model->bbwenet, oaci_bbwenetlayers_arrays); + } +# endif +# endif /* ENABLE_OSCE_BWE */ #endif /* USE_WEIGHTS_FILE */ } @@ -1475,41 +1468,39 @@ int osce_load_models(OSCEModel *model, const void *data, int len) } #ifdef ENABLE_OSCE_BWE -void osce_bwe( +void oaci_osce_bwe( OSCEModel *model, /* I OSCE model struct */ silk_OSCE_BWE_struct *psOSCEBWE, /* I/O OSCE BWE state */ - opus_int16 xq48[], /* O bandwidth-extended speech */ - opus_int16 xq16[], /* I Decoded speech */ - opus_int32 xq16_len, /* I Length of xq16 in samples */ - int arch /* I Run-time architecture */ - ) - { + oac_int16 xq48[], /* O bandwidth-extended speech */ + oac_int16 xq16[], /* I Decoded speech */ + oac_int32 xq16_len, /* I Length of xq16 in samples */ + int arch /* I Run-time architecture */ + ) { float in_buffer[320]; float out_buffer[3*320]; - float features[2 * OSCE_BWE_FEATURE_DIM]; + float features[2*OSCE_BWE_FEATURE_DIM]; int num_frames, i; /* currently restricting to 10 or 20-ms frames */ celt_assert(xq16_len == 160 || xq16_len == 320); - num_frames = xq16_len / 160; + num_frames = xq16_len/160; /* scale input */ - for (i = 0; i < xq16_len; i++) - { - in_buffer[i] = ((float) xq16[i]) * (1.f/32768.f); + for (i = 0; i < xq16_len; i++) { + in_buffer[i] = ((float) xq16[i])*(1.f/32768.f); } - osce_bwe_calculate_features(&psOSCEBWE->features, features, xq16, xq16_len); + oaci_osce_bwe_calculate_features(&psOSCEBWE->features, features, xq16, xq16_len); -#if 0 +# if 0 /* just upsampling for now */ - upsamp_2x(&psOSCEBWE->state.bbwenet.resampler_state[0], out_buffer, in_buffer, xq16_len); - interpol_3_2(&psOSCEBWE->state.bbwenet.resampler_state[0], out_buffer, out_buffer, 2 * xq16_len); + oaci_upsamp_2x(&psOSCEBWE->state.bbwenet.resampler_state[0], out_buffer, in_buffer, xq16_len); + oaci_interpol_3_2(&psOSCEBWE->state.bbwenet.resampler_state[0], out_buffer, out_buffer, 2*xq16_len); -#else +# else /* process frames */ - bbwenet_process_frames( + oaci_bbwenet_process_frames( &model->bbwenet, &psOSCEBWE->state.bbwenet, out_buffer, @@ -1517,81 +1508,77 @@ void osce_bwe( features, num_frames, arch - ); -#endif + ); +# endif /* scale and delay output */ - OPUS_COPY(xq48, psOSCEBWE->state.bbwenet.outbut_buffer, OSCE_BWE_OUTPUT_DELAY); - for (i = 0; i < 3 * xq16_len - OSCE_BWE_OUTPUT_DELAY; i++) - { - float tmp = 32768.f * out_buffer[i]; + OAC_COPY(xq48, psOSCEBWE->state.bbwenet.outbut_buffer, OSCE_BWE_OUTPUT_DELAY); + for (i = 0; i < 3*xq16_len - OSCE_BWE_OUTPUT_DELAY; i++) { + float tmp = 32768.f*out_buffer[i]; if (tmp > 32767.f) tmp = 32767.f; if (tmp < -32767.f) tmp = -32767.f; - xq48[i + OSCE_BWE_OUTPUT_DELAY] = float2int(tmp); + xq48[i + OSCE_BWE_OUTPUT_DELAY] = oaci_float2int(tmp); } - for (i = 0; i < OSCE_BWE_OUTPUT_DELAY; i++) - { - float tmp = 32768.f * out_buffer[3 * xq16_len - OSCE_BWE_OUTPUT_DELAY + i]; + for (i = 0; i < OSCE_BWE_OUTPUT_DELAY; i++) { + float tmp = 32768.f*out_buffer[3*xq16_len - OSCE_BWE_OUTPUT_DELAY + i]; if (tmp > 32767.f) tmp = 32767.f; if (tmp < -32767.f) tmp = -32767.f; - psOSCEBWE->state.bbwenet.outbut_buffer[i] = float2int(tmp); + psOSCEBWE->state.bbwenet.outbut_buffer[i] = oaci_float2int(tmp); } - } +} - #endif +#endif -void osce_enhance_frame( +void oaci_osce_enhance_frame( OSCEModel *model, /* I OSCE model struct */ silk_decoder_state *psDec, /* I/O Decoder state */ silk_decoder_control *psDecCtrl, /* I Decoder control */ - opus_int16 xq[], /* I/O Decoded speech */ - opus_int32 num_bits, /* I Size of SILK payload in bits */ - int arch /* I Run-time architecture */ -) -{ + oac_int16 xq[], /* I/O Decoded speech */ + oac_int32 num_bits, /* I Size of SILK payload in bits */ + int arch /* I Run-time architecture */ + ) { float in_buffer[320]; float out_buffer[320]; - float features[4 * OSCE_FEATURE_DIM]; + float features[4*OSCE_FEATURE_DIM]; float numbits[2]; int periods[4]; int i; int method; /* enhancement only implemented for 20 ms frame at 16kHz */ - if (psDec->fs_kHz != 16 || psDec->nb_subfr != 4) - { - osce_reset(&psDec->osce, psDec->osce.method); + if (psDec->fs_kHz != 16 || psDec->nb_subfr != 4) { + oaci_osce_reset(&psDec->osce, psDec->osce.method); return; } - osce_calculate_features(psDec, psDecCtrl, features, numbits, periods, xq, num_bits); + oaci_osce_calculate_features(psDec, psDecCtrl, features, numbits, periods, xq, num_bits); /* scale input */ - for (i = 0; i < 320; i++) - { - in_buffer[i] = ((float) xq[i]) * (1.f/32768.f); + for (i = 0; i < 320; i++) { + in_buffer[i] = ((float) xq[i])*(1.f/32768.f); } if (model->loaded) method = psDec->osce.method; else method = OSCE_METHOD_NONE; - switch(method) - { + switch (method) { case OSCE_METHOD_NONE: - OPUS_COPY(out_buffer, in_buffer, 320); + OAC_COPY(out_buffer, in_buffer, 320); break; #ifndef DISABLE_LACE case OSCE_METHOD_LACE: - lace_process_20ms_frame(&model->lace, &psDec->osce.state.lace, out_buffer, in_buffer, features, numbits, periods, arch); + oaci_lace_process_20ms_frame(&model->lace, &psDec->osce.state.lace, out_buffer, in_buffer, features, numbits, + periods, arch); break; #endif #ifndef DISABLE_NOLACE case OSCE_METHOD_NOLACE: - nolace_process_20ms_frame(&model->nolace, &psDec->osce.state.nolace, out_buffer, in_buffer, features, numbits, periods, arch); + oaci_nolace_process_20ms_frame(&model->nolace, &psDec->osce.state.nolace, out_buffer, in_buffer, features, + numbits, periods, arch); break; #endif default: @@ -1599,7 +1586,7 @@ void osce_enhance_frame( } #ifdef ENABLE_OSCE_TRAINING_DATA - int k; + int k; static FILE *flpc = NULL; static FILE *fgain = NULL; @@ -1609,44 +1596,55 @@ void osce_enhance_frame( static FILE* f_numbits = NULL; static FILE* f_numbits_smooth = NULL; - if (flpc == NULL) {flpc = fopen("features_lpc.f32", "wb");} - if (fgain == NULL) {fgain = fopen("features_gain.f32", "wb");} - if (fltp == NULL) {fltp = fopen("features_ltp.f32", "wb");} - if (fperiod == NULL) {fperiod = fopen("features_period.s16", "wb");} - if (fnoisy16k == NULL) {fnoisy16k = fopen("noisy_16k.s16", "wb");} - if(f_numbits == NULL) {f_numbits = fopen("features_num_bits.s32", "wb");} - if (f_numbits_smooth == NULL) {f_numbits_smooth = fopen("features_num_bits_smooth.f32", "wb");} + if (flpc == NULL) { + flpc = fopen("features_lpc.f32", "wb"); + } + if (fgain == NULL) { + fgain = fopen("features_gain.f32", "wb"); + } + if (fltp == NULL) { + fltp = fopen("features_ltp.f32", "wb"); + } + if (fperiod == NULL) { + fperiod = fopen("features_period.s16", "wb"); + } + if (fnoisy16k == NULL) { + fnoisy16k = fopen("noisy_16k.s16", "wb"); + } + if (f_numbits == NULL) { + f_numbits = fopen("features_num_bits.s32", "wb"); + } + if (f_numbits_smooth == NULL) { + f_numbits_smooth = fopen("features_num_bits_smooth.f32", "wb"); + } fwrite(&num_bits, sizeof(num_bits), 1, f_numbits); fwrite(&(psDec->osce.features.numbits_smooth), sizeof(psDec->osce.features.numbits_smooth), 1, f_numbits_smooth); - for (k = 0; k < psDec->nb_subfr; k++) - { + for (k = 0; k < psDec->nb_subfr; k++) { float tmp; int16_t itmp; float lpc_buffer[16] = {0}; - opus_int16 *A_Q12, *B_Q14; + oac_int16 *A_Q12, *B_Q14; (void) num_bits; (void) arch; /* gain */ - tmp = (float) psDecCtrl->Gains_Q16[k] / (1UL << 16); + tmp = (float) psDecCtrl->Gains_Q16[k]/(1UL<<16); fwrite(&tmp, sizeof(tmp), 1, fgain); /* LPC */ - A_Q12 = psDecCtrl->PredCoef_Q12[ k >> 1 ]; - for (i = 0; i < psDec->LPC_order; i++) - { - lpc_buffer[i] = (float) A_Q12[i] / (1U << 12); + A_Q12 = psDecCtrl->PredCoef_Q12[ k>>1 ]; + for (i = 0; i < psDec->LPC_order; i++) { + lpc_buffer[i] = (float) A_Q12[i]/(1U<<12); } fwrite(lpc_buffer, sizeof(lpc_buffer[0]), 16, flpc); /* LTP */ - B_Q14 = &psDecCtrl->LTPCoef_Q14[ k * LTP_ORDER ]; - for (i = 0; i < 5; i++) - { - tmp = (float) B_Q14[i] / (1U << 14); + B_Q14 = &psDecCtrl->LTPCoef_Q14[ k*LTP_ORDER ]; + for (i = 0; i < 5; i++) { + tmp = (float) B_Q14[i]/(1U<<14); fwrite(&tmp, sizeof(tmp), 1, fltp); } @@ -1655,27 +1653,23 @@ void osce_enhance_frame( fwrite(&itmp, sizeof(itmp), 1, fperiod); } - fwrite(xq, psDec->nb_subfr * psDec->subfr_length, sizeof(xq[0]), fnoisy16k); + fwrite(xq, psDec->nb_subfr*psDec->subfr_length, sizeof(xq[0]), fnoisy16k); #endif - if (psDec->osce.features.reset > 1) - { - OPUS_COPY(out_buffer, in_buffer, 320); - psDec->osce.features.reset --; - } - else if (psDec->osce.features.reset) - { - osce_cross_fade_10ms(out_buffer, in_buffer, 320); + if (psDec->osce.features.reset > 1) { + OAC_COPY(out_buffer, in_buffer, 320); + psDec->osce.features.reset--; + } else if (psDec->osce.features.reset) { + oaci_osce_cross_fade_10ms(out_buffer, in_buffer, 320); psDec->osce.features.reset = 0; } /* scale output */ - for (i = 0; i < 320; i++) - { - float tmp = 32768.f * out_buffer[i]; + for (i = 0; i < 320; i++) { + float tmp = 32768.f*out_buffer[i]; if (tmp > 32767.f) tmp = 32767.f; if (tmp < -32767.f) tmp = -32767.f; - xq[i] = float2int(tmp); + xq[i] = oaci_float2int(tmp); } } @@ -1683,14 +1677,12 @@ void osce_enhance_frame( #if 0 -#include +# include void lace_feature_net_compare( const char * prefix, int num_frames, - LACE* hLACE -) -{ + LACE* hLACE) { char in_feature_file[256]; char out_feature_file[256]; char numbits_file[256]; @@ -1698,21 +1690,20 @@ void lace_feature_net_compare( char message[512]; int i_frame, i_feature; float mse; - float in_features[4 * LACE_NUM_FEATURES]; - float out_features[4 * LACE_COND_DIM]; - float out_features2[4 * LACE_COND_DIM]; + float in_features[4*LACE_NUM_FEATURES]; + float out_features[4*LACE_COND_DIM]; + float out_features2[4*LACE_COND_DIM]; float numbits[2]; int periods[4]; - init_lace(hLACE); + oaci_init_lace(hLACE); FILE *f_in_features, *f_out_features, *f_numbits, *f_periods; strcpy(in_feature_file, prefix); strcat(in_feature_file, "_in_features.f32"); f_in_features = fopen(in_feature_file, "rb"); - if (f_in_features == NULL) - { + if (f_in_features == NULL) { sprintf(message, "could not open file %s", in_feature_file); perror(message); exit(1); @@ -1721,8 +1712,7 @@ void lace_feature_net_compare( strcpy(out_feature_file, prefix); strcat(out_feature_file, "_out_features.f32"); f_out_features = fopen(out_feature_file, "rb"); - if (f_out_features == NULL) - { + if (f_out_features == NULL) { sprintf(message, "could not open file %s", out_feature_file); perror(message); exit(1); @@ -1731,8 +1721,7 @@ void lace_feature_net_compare( strcpy(periods_file, prefix); strcat(periods_file, "_periods.s32"); f_periods = fopen(periods_file, "rb"); - if (f_periods == NULL) - { + if (f_periods == NULL) { sprintf(message, "could not open file %s", periods_file); perror(message); exit(1); @@ -1741,45 +1730,38 @@ void lace_feature_net_compare( strcpy(numbits_file, prefix); strcat(numbits_file, "_numbits.f32"); f_numbits = fopen(numbits_file, "rb"); - if (f_numbits == NULL) - { + if (f_numbits == NULL) { sprintf(message, "could not open file %s", numbits_file); perror(message); exit(1); } - for (i_frame = 0; i_frame < num_frames; i_frame ++) - { - if(fread(in_features, sizeof(float), 4 * LACE_NUM_FEATURES, f_in_features) != 4 * LACE_NUM_FEATURES) - { + for (i_frame = 0; i_frame < num_frames; i_frame++) { + if (fread(in_features, sizeof(float), 4*LACE_NUM_FEATURES, f_in_features) != 4*LACE_NUM_FEATURES) { fprintf(stderr, "could not read frame %d from in_features\n", i_frame); exit(1); } - if(fread(out_features, sizeof(float), 4 * LACE_COND_DIM, f_out_features) != 4 * LACE_COND_DIM) - { + if (fread(out_features, sizeof(float), 4*LACE_COND_DIM, f_out_features) != 4*LACE_COND_DIM) { fprintf(stderr, "could not read frame %d from out_features\n", i_frame); exit(1); } - if(fread(periods, sizeof(int), 4, f_periods) != 4) - { + if (fread(periods, sizeof(int), 4, f_periods) != 4) { fprintf(stderr, "could not read frame %d from periods\n", i_frame); exit(1); } - if(fread(numbits, sizeof(float), 2, f_numbits) != 2) - { + if (fread(numbits, sizeof(float), 2, f_numbits) != 2) { fprintf(stderr, "could not read frame %d from numbits\n", i_frame); exit(1); } - lace_feature_net(hLACE, out_features2, in_features, numbits, periods); + oaci_lace_feature_net(hLACE, out_features2, in_features, numbits, periods); float mse = 0; - for (int i = 0; i < 4 * LACE_COND_DIM; i ++) - { + for (int i = 0; i < 4*LACE_COND_DIM; i++) { mse += pow(out_features[i] - out_features2[i], 2); } - mse /= (4 * LACE_COND_DIM); + mse /= (4*LACE_COND_DIM); printf("rmse: %f\n", sqrt(mse)); } @@ -1793,9 +1775,7 @@ void lace_feature_net_compare( void lace_demo( char *prefix, - char *output -) -{ + char *output) { char feature_file[256]; char numbits_file[256]; char periods_file[256]; @@ -1803,23 +1783,22 @@ void lace_demo( char message[512]; int i_frame; float mse; - float features[4 * LACE_NUM_FEATURES]; + float features[4*LACE_NUM_FEATURES]; float numbits[2]; int periods[4]; - float x_in[4 * LACE_FRAME_SIZE]; - int16_t x_out[4 * LACE_FRAME_SIZE]; - float buffer[4 * LACE_FRAME_SIZE]; + float x_in[4*LACE_FRAME_SIZE]; + int16_t x_out[4*LACE_FRAME_SIZE]; + float buffer[4*LACE_FRAME_SIZE]; LACE hLACE; int frame_counter = 0; FILE *f_features, *f_numbits, *f_periods, *f_x_in, *f_x_out; - init_lace(&hLACE); + oaci_init_lace(&hLACE); strcpy(feature_file, prefix); strcat(feature_file, "_features.f32"); f_features = fopen(feature_file, "rb"); - if (f_features == NULL) - { + if (f_features == NULL) { sprintf(message, "could not open file %s", feature_file); perror(message); exit(1); @@ -1828,16 +1807,14 @@ void lace_demo( strcpy(x_in_file, prefix); strcat(x_in_file, "_x_in.f32"); f_x_in = fopen(x_in_file, "rb"); - if (f_x_in == NULL) - { + if (f_x_in == NULL) { sprintf(message, "could not open file %s", x_in_file); perror(message); exit(1); } f_x_out = fopen(output, "wb"); - if (f_x_out == NULL) - { + if (f_x_out == NULL) { sprintf(message, "could not open file %s", output); perror(message); exit(1); @@ -1846,8 +1823,7 @@ void lace_demo( strcpy(periods_file, prefix); strcat(periods_file, "_periods.s32"); f_periods = fopen(periods_file, "rb"); - if (f_periods == NULL) - { + if (f_periods == NULL) { sprintf(message, "could not open file %s", periods_file); perror(message); exit(1); @@ -1856,8 +1832,7 @@ void lace_demo( strcpy(numbits_file, prefix); strcat(numbits_file, "_numbits.f32"); f_numbits = fopen(numbits_file, "rb"); - if (f_numbits == NULL) - { + if (f_numbits == NULL) { sprintf(message, "could not open file %s", numbits_file); perror(message); exit(1); @@ -1865,42 +1840,37 @@ void lace_demo( printf("processing %s\n", prefix); - while (fread(x_in, sizeof(float), 4 * LACE_FRAME_SIZE, f_x_in) == 4 * LACE_FRAME_SIZE) - { + while (fread(x_in, sizeof(float), 4*LACE_FRAME_SIZE, f_x_in) == 4*LACE_FRAME_SIZE) { printf("\rframe: %d", frame_counter++); - if(fread(features, sizeof(float), 4 * LACE_NUM_FEATURES, f_features) != 4 * LACE_NUM_FEATURES) - { + if (fread(features, sizeof(float), 4*LACE_NUM_FEATURES, f_features) != 4*LACE_NUM_FEATURES) { fprintf(stderr, "could not read frame %d from features\n", i_frame); exit(1); } - if(fread(periods, sizeof(int), 4, f_periods) != 4) - { + if (fread(periods, sizeof(int), 4, f_periods) != 4) { fprintf(stderr, "could not read frame %d from periods\n", i_frame); exit(1); } - if(fread(numbits, sizeof(float), 2, f_numbits) != 2) - { + if (fread(numbits, sizeof(float), 2, f_numbits) != 2) { fprintf(stderr, "could not read frame %d from numbits\n", i_frame); exit(1); } - lace_process_20ms_frame( + oaci_lace_process_20ms_frame( &hLACE, buffer, x_in, features, numbits, periods - ); + ); - for (int n=0; n < 4 * LACE_FRAME_SIZE; n ++) - { - float tmp = (1UL<<15) * buffer[n]; + for (int n = 0; n < 4*LACE_FRAME_SIZE; n++) { + float tmp = (1UL<<15)*buffer[n]; tmp = CLIP(tmp, -32768, 32767); x_out[n] = (int16_t) round(tmp); } - fwrite(x_out, sizeof(int16_t), 4 * LACE_FRAME_SIZE, f_x_out); + fwrite(x_out, sizeof(int16_t), 4*LACE_FRAME_SIZE, f_x_out); } printf("\ndone!\n"); @@ -1913,9 +1883,7 @@ void lace_demo( void nolace_demo( char *prefix, - char *output -) -{ + char *output) { char feature_file[256]; char numbits_file[256]; char periods_file[256]; @@ -1923,23 +1891,22 @@ void nolace_demo( char message[512]; int i_frame; float mse; - float features[4 * LACE_NUM_FEATURES]; + float features[4*LACE_NUM_FEATURES]; float numbits[2]; int periods[4]; - float x_in[4 * LACE_FRAME_SIZE]; - int16_t x_out[4 * LACE_FRAME_SIZE]; - float buffer[4 * LACE_FRAME_SIZE]; + float x_in[4*LACE_FRAME_SIZE]; + int16_t x_out[4*LACE_FRAME_SIZE]; + float buffer[4*LACE_FRAME_SIZE]; NoLACE hNoLACE; int frame_counter = 0; FILE *f_features, *f_numbits, *f_periods, *f_x_in, *f_x_out; - init_nolace(&hNoLACE); + oaci_init_nolace(&hNoLACE); strcpy(feature_file, prefix); strcat(feature_file, "_features.f32"); f_features = fopen(feature_file, "rb"); - if (f_features == NULL) - { + if (f_features == NULL) { sprintf(message, "could not open file %s", feature_file); perror(message); exit(1); @@ -1948,16 +1915,14 @@ void nolace_demo( strcpy(x_in_file, prefix); strcat(x_in_file, "_x_in.f32"); f_x_in = fopen(x_in_file, "rb"); - if (f_x_in == NULL) - { + if (f_x_in == NULL) { sprintf(message, "could not open file %s", x_in_file); perror(message); exit(1); } f_x_out = fopen(output, "wb"); - if (f_x_out == NULL) - { + if (f_x_out == NULL) { sprintf(message, "could not open file %s", output); perror(message); exit(1); @@ -1966,8 +1931,7 @@ void nolace_demo( strcpy(periods_file, prefix); strcat(periods_file, "_periods.s32"); f_periods = fopen(periods_file, "rb"); - if (f_periods == NULL) - { + if (f_periods == NULL) { sprintf(message, "could not open file %s", periods_file); perror(message); exit(1); @@ -1976,8 +1940,7 @@ void nolace_demo( strcpy(numbits_file, prefix); strcat(numbits_file, "_numbits.f32"); f_numbits = fopen(numbits_file, "rb"); - if (f_numbits == NULL) - { + if (f_numbits == NULL) { sprintf(message, "could not open file %s", numbits_file); perror(message); exit(1); @@ -1985,42 +1948,37 @@ void nolace_demo( printf("processing %s\n", prefix); - while (fread(x_in, sizeof(float), 4 * LACE_FRAME_SIZE, f_x_in) == 4 * LACE_FRAME_SIZE) - { + while (fread(x_in, sizeof(float), 4*LACE_FRAME_SIZE, f_x_in) == 4*LACE_FRAME_SIZE) { printf("\rframe: %d", frame_counter++); - if(fread(features, sizeof(float), 4 * LACE_NUM_FEATURES, f_features) != 4 * LACE_NUM_FEATURES) - { + if (fread(features, sizeof(float), 4*LACE_NUM_FEATURES, f_features) != 4*LACE_NUM_FEATURES) { fprintf(stderr, "could not read frame %d from features\n", i_frame); exit(1); } - if(fread(periods, sizeof(int), 4, f_periods) != 4) - { + if (fread(periods, sizeof(int), 4, f_periods) != 4) { fprintf(stderr, "could not read frame %d from periods\n", i_frame); exit(1); } - if(fread(numbits, sizeof(float), 2, f_numbits) != 2) - { + if (fread(numbits, sizeof(float), 2, f_numbits) != 2) { fprintf(stderr, "could not read frame %d from numbits\n", i_frame); exit(1); } - nolace_process_20ms_frame( + oaci_nolace_process_20ms_frame( &hNoLACE, buffer, x_in, features, numbits, periods - ); + ); - for (int n=0; n < 4 * LACE_FRAME_SIZE; n ++) - { - float tmp = (1UL<<15) * buffer[n]; + for (int n = 0; n < 4*LACE_FRAME_SIZE; n++) { + float tmp = (1UL<<15)*buffer[n]; tmp = CLIP(tmp, -32768, 32767); x_out[n] = (int16_t) round(tmp); } - fwrite(x_out, sizeof(int16_t), 4 * LACE_FRAME_SIZE, f_x_out); + fwrite(x_out, sizeof(int16_t), 4*LACE_FRAME_SIZE, f_x_out); } printf("\ndone!\n"); @@ -2032,16 +1990,15 @@ void nolace_demo( } -int main() -{ -#if 0 +int main() { +# if 0 LACE hLACE; lace_feature_net_compare("testvec2/lace", 5, &hLACE); lace_demo("testdata/test9", "out_lace_c_9kbps.pcm"); lace_demo("testdata/test6", "out_lace_c_6kbps.pcm"); -#endif +# endif nolace_demo("testdata/test9", "out_nolace_c_9kbps.pcm"); } diff --git a/dnn/osce.h b/dnn/osce.h index 915e6ba23..81b5a50e7 100644 --- a/dnn/osce.h +++ b/dnn/osce.h @@ -23,19 +23,19 @@ 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. -*/ + */ #ifndef OSCE_H #define OSCE_H -#include "opus_types.h" +#include "oac_types.h" /*#include "osce_config.h"*/ #ifndef DISABLE_LACE -#include "lace_data.h" +# include "lace_data.h" #endif #ifndef DISABLE_NOLACE -#include "nolace_data.h" +# include "nolace_data.h" #endif #include "nndsp.h" #include "nnet.h" @@ -50,25 +50,25 @@ #define OSCE_METHOD_NONE 0 #ifndef DISABLE_LACE -#define OSCE_METHOD_LACE 1 +# define OSCE_METHOD_LACE 1 #endif #ifndef DISABLE_NOLACE -#define OSCE_METHOD_NOLACE 2 +# define OSCE_METHOD_NOLACE 2 #endif #if !defined(DISABLE_NOLACE) -#define OSCE_DEFAULT_METHOD OSCE_METHOD_NOLACE -#define OSCE_MAX_RNN_NEURONS NOLACE_FNET_GRU_STATE_SIZE +# define OSCE_DEFAULT_METHOD OSCE_METHOD_NOLACE +# define OSCE_MAX_RNN_NEURONS NOLACE_FNET_GRU_STATE_SIZE #elif !defined(DISABLE_LACE) -#define OSCE_DEFAULT_METHOD OSCE_METHOD_LACE -#define OSCE_MAX_RNN_NEURONS LACE_FNET_GRU_STATE_SIZE +# define OSCE_DEFAULT_METHOD OSCE_METHOD_LACE +# define OSCE_MAX_RNN_NEURONS LACE_FNET_GRU_STATE_SIZE #else -#define OSCE_DEFAULT_METHOD OSCE_METHOD_NONE -#define OSCE_MAX_RNN_NEURONS 0 +# define OSCE_DEFAULT_METHOD OSCE_METHOD_NONE +# define OSCE_MAX_RNN_NEURONS 0 #endif #ifdef ENABLE_OSCE_BWE -#define OSCE_BWE_MAX_RNN_NEURONS BBWENET_FNET_GRU_STATE_SIZE +# define OSCE_BWE_MAX_RNN_NEURONS BBWENET_FNET_GRU_STATE_SIZE #endif @@ -76,30 +76,30 @@ /* API */ -void osce_enhance_frame( +void oaci_osce_enhance_frame( OSCEModel *model, /* I OSCE model struct */ silk_decoder_state *psDec, /* I/O Decoder state */ silk_decoder_control *psDecCtrl, /* I Decoder control */ - opus_int16 xq[], /* I/O Decoded speech */ - opus_int32 num_bits, /* I Size of SILK payload in bits */ - int arch /* I Run-time architecture */ -); + oac_int16 xq[], /* I/O Decoded speech */ + oac_int32 num_bits, /* I Size of SILK payload in bits */ + int arch /* I Run-time architecture */ + ); -int osce_load_models(OSCEModel *hModel, const void *data, int len); -void osce_reset(silk_OSCE_struct *hOSCE, int method); +int oaci_osce_load_models(OSCEModel *hModel, const void *data, int len); +void oaci_osce_reset(silk_OSCE_struct *hOSCE, int method); #ifdef ENABLE_OSCE_BWE -void osce_bwe( - OSCEModel *model, /* I OSCE model struct */ - silk_OSCE_BWE_struct *psOSCEBWE, /* I/O OSCE BWE state */ - opus_int16 xq48[], /* O bandwidth-extended speech */ - opus_int16 xq16[], /* I Decoded speech */ - opus_int32 xq16_len, /* I Length of xq16 in samples */ - int arch /* I Run-time architecture */ -); - -void osce_bwe_reset(silk_OSCE_BWE_struct *hOSCEBWE); +void oaci_osce_bwe( + OSCEModel *model, /* I OSCE model struct */ + silk_OSCE_BWE_struct *psOSCEBWE, /* I/O OSCE BWE state */ + oac_int16 xq48[], /* O bandwidth-extended speech */ + oac_int16 xq16[], /* I Decoded speech */ + oac_int32 xq16_len, /* I Length of xq16 in samples */ + int arch /* I Run-time architecture */ + ); + +void oaci_osce_bwe_reset(silk_OSCE_BWE_struct *hOSCEBWE); #endif /* ENABLE_OSCE_BWE */ diff --git a/dnn/osce_config.h b/dnn/osce_config.h index 9374c6980..1917bd99c 100644 --- a/dnn/osce_config.h +++ b/dnn/osce_config.h @@ -23,7 +23,7 @@ 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. -*/ + */ #ifndef OSCE_CONFIG #define OSCE_CONFIG @@ -58,7 +58,7 @@ #define OSCE_BWE_MAX_INSTAFREQ_BIN 40 #define OSCE_BWE_HALF_WINDOW_SIZE 160 -#define OSCE_BWE_WINDOW_SIZE (2 * (OSCE_BWE_HALF_WINDOW_SIZE)) +#define OSCE_BWE_WINDOW_SIZE (2*(OSCE_BWE_HALF_WINDOW_SIZE)) #define OSCE_BWE_NUM_BANDS 32 #define OSCE_BWE_FEATURE_DIM 114 #define OSCE_BWE_OUTPUT_DELAY 21 diff --git a/dnn/osce_features.c b/dnn/osce_features.c index 8e1fa1a73..c81b084f9 100644 --- a/dnn/osce_features.c +++ b/dnn/osce_features.c @@ -23,10 +23,10 @@ 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" +# include "config.h" #endif #define OSCE_SPEC_WINDOW_SIZE 320 @@ -47,59 +47,59 @@ #if defined(WRITE_FEATURES) || defined(DEBUG_PRING) -#include -#include +# include +# include #endif static const int center_bins_clean[64] = { - 0, 2, 5, 8, 10, 12, 15, 18, - 20, 22, 25, 28, 30, 33, 35, 38, - 40, 42, 45, 48, 50, 52, 55, 58, - 60, 62, 65, 68, 70, 73, 75, 78, - 80, 82, 85, 88, 90, 92, 95, 98, + 0, 2, 5, 8, 10, 12, 15, 18, + 20, 22, 25, 28, 30, 33, 35, 38, + 40, 42, 45, 48, 50, 52, 55, 58, + 60, 62, 65, 68, 70, 73, 75, 78, + 80, 82, 85, 88, 90, 92, 95, 98, 100, 102, 105, 108, 110, 112, 115, 118, 120, 122, 125, 128, 130, 132, 135, 138, 140, 142, 145, 148, 150, 152, 155, 160 }; static const int center_bins_noisy[18] = { - 0, 4, 8, 12, 16, 20, 24, 28, - 32, 40, 48, 56, 64, 80, 96, 112, + 0, 4, 8, 12, 16, 20, 24, 28, + 32, 40, 48, 56, 64, 80, 96, 112, 136, 160 }; static const int center_bins_bwe[32] = { - 0, 5, 10, 15, 20, 25, 30, 35, - 40, 45, 50, 55, 60, 65, 70, 75, - 80, 85, 90, 95, 100, 105, 110, 115, + 0, 5, 10, 15, 20, 25, 30, 35, + 40, 45, 50, 55, 60, 65, 70, 75, + 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 160 }; static const float band_weights_clean[64] = { - 0.666666666667f, 0.400000000000f, 0.333333333333f, 0.400000000000f, - 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, - 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, - 0.400000000000f, 0.400000000000f, 0.400000000000f, 0.400000000000f, - 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, - 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, - 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, - 0.400000000000f, 0.400000000000f, 0.400000000000f, 0.400000000000f, - 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, - 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, - 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, - 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, - 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, - 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, - 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, - 0.500000000000f, 0.400000000000f, 0.250000000000f, 0.333333333333f + 0.666666666667f, 0.400000000000f, 0.333333333333f, 0.400000000000f, + 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, + 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, + 0.400000000000f, 0.400000000000f, 0.400000000000f, 0.400000000000f, + 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, + 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, + 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, + 0.400000000000f, 0.400000000000f, 0.400000000000f, 0.400000000000f, + 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, + 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, + 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, + 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, + 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, + 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, + 0.500000000000f, 0.400000000000f, 0.333333333333f, 0.400000000000f, + 0.500000000000f, 0.400000000000f, 0.250000000000f, 0.333333333333f }; static const float band_weights_noisy[18] = { - 0.400000000000f, 0.250000000000f, 0.250000000000f, 0.250000000000f, - 0.250000000000f, 0.250000000000f, 0.250000000000f, 0.250000000000f, - 0.166666666667f, 0.125000000000f, 0.125000000000f, 0.125000000000f, - 0.083333333333f, 0.062500000000f, 0.062500000000f, 0.050000000000f, - 0.041666666667f, 0.080000000000f + 0.400000000000f, 0.250000000000f, 0.250000000000f, 0.250000000000f, + 0.250000000000f, 0.250000000000f, 0.250000000000f, 0.250000000000f, + 0.166666666667f, 0.125000000000f, 0.125000000000f, 0.125000000000f, + 0.083333333333f, 0.062500000000f, 0.062500000000f, 0.050000000000f, + 0.041666666667f, 0.080000000000f }; static const float band_weights_bwe[32] = { @@ -114,111 +114,106 @@ static const float band_weights_bwe[32] = { }; static float osce_window[OSCE_SPEC_WINDOW_SIZE] = { - 0.004908718808f, 0.014725683311f, 0.024541228523f, 0.034354408400f, 0.044164277127f, - 0.053969889210f, 0.063770299562f, 0.073564563600f, 0.083351737332f, 0.093130877450f, - 0.102901041421f, 0.112661287575f, 0.122410675199f, 0.132148264628f, 0.141873117332f, - 0.151584296010f, 0.161280864678f, 0.170961888760f, 0.180626435180f, 0.190273572448f, - 0.199902370753f, 0.209511902052f, 0.219101240157f, 0.228669460829f, 0.238215641862f, - 0.247738863176f, 0.257238206902f, 0.266712757475f, 0.276161601717f, 0.285583828929f, - 0.294978530977f, 0.304344802381f, 0.313681740399f, 0.322988445118f, 0.332264019538f, - 0.341507569661f, 0.350718204573f, 0.359895036535f, 0.369037181064f, 0.378143757022f, - 0.387213886697f, 0.396246695891f, 0.405241314005f, 0.414196874117f, 0.423112513073f, - 0.431987371563f, 0.440820594212f, 0.449611329655f, 0.458358730621f, 0.467061954019f, - 0.475720161014f, 0.484332517110f, 0.492898192230f, 0.501416360796f, 0.509886201809f, - 0.518306898929f, 0.526677640552f, 0.534997619887f, 0.543266035038f, 0.551482089078f, - 0.559644990127f, 0.567753951426f, 0.575808191418f, 0.583806933818f, 0.591749407690f, - 0.599634847523f, 0.607462493302f, 0.615231590581f, 0.622941390558f, 0.630591150148f, - 0.638180132051f, 0.645707604824f, 0.653172842954f, 0.660575126926f, 0.667913743292f, - 0.675187984742f, 0.682397150168f, 0.689540544737f, 0.696617479953f, 0.703627273726f, - 0.710569250438f, 0.717442741007f, 0.724247082951f, 0.730981620454f, 0.737645704427f, - 0.744238692572f, 0.750759949443f, 0.757208846506f, 0.763584762206f, 0.769887082016f, - 0.776115198508f, 0.782268511401f, 0.788346427627f, 0.794348361383f, 0.800273734191f, - 0.806121974951f, 0.811892519997f, 0.817584813152f, 0.823198305781f, 0.828732456844f, - 0.834186732948f, 0.839560608398f, 0.844853565250f, 0.850065093356f, 0.855194690420f, - 0.860241862039f, 0.865206121757f, 0.870086991109f, 0.874883999665f, 0.879596685080f, - 0.884224593137f, 0.888767277786f, 0.893224301196f, 0.897595233788f, 0.901879654283f, - 0.906077149740f, 0.910187315596f, 0.914209755704f, 0.918144082372f, 0.921989916403f, - 0.925746887127f, 0.929414632439f, 0.932992798835f, 0.936481041442f, 0.939879024058f, - 0.943186419177f, 0.946402908026f, 0.949528180593f, 0.952561935658f, 0.955503880820f, - 0.958353732530f, 0.961111216112f, 0.963776065795f, 0.966348024735f, 0.968826845041f, - 0.971212287799f, 0.973504123096f, 0.975702130039f, 0.977806096779f, 0.979815820533f, - 0.981731107599f, 0.983551773378f, 0.985277642389f, 0.986908548290f, 0.988444333892f, - 0.989884851171f, 0.991229961288f, 0.992479534599f, 0.993633450666f, 0.994691598273f, - 0.995653875433f, 0.996520189401f, 0.997290456679f, 0.997964603026f, 0.998542563469f, - 0.999024282300f, 0.999409713092f, 0.999698818696f, 0.999891571247f, 0.999987952167f, - 0.999987952167f, 0.999891571247f, 0.999698818696f, 0.999409713092f, 0.999024282300f, - 0.998542563469f, 0.997964603026f, 0.997290456679f, 0.996520189401f, 0.995653875433f, - 0.994691598273f, 0.993633450666f, 0.992479534599f, 0.991229961288f, 0.989884851171f, - 0.988444333892f, 0.986908548290f, 0.985277642389f, 0.983551773378f, 0.981731107599f, - 0.979815820533f, 0.977806096779f, 0.975702130039f, 0.973504123096f, 0.971212287799f, - 0.968826845041f, 0.966348024735f, 0.963776065795f, 0.961111216112f, 0.958353732530f, - 0.955503880820f, 0.952561935658f, 0.949528180593f, 0.946402908026f, 0.943186419177f, - 0.939879024058f, 0.936481041442f, 0.932992798835f, 0.929414632439f, 0.925746887127f, - 0.921989916403f, 0.918144082372f, 0.914209755704f, 0.910187315596f, 0.906077149740f, - 0.901879654283f, 0.897595233788f, 0.893224301196f, 0.888767277786f, 0.884224593137f, - 0.879596685080f, 0.874883999665f, 0.870086991109f, 0.865206121757f, 0.860241862039f, - 0.855194690420f, 0.850065093356f, 0.844853565250f, 0.839560608398f, 0.834186732948f, - 0.828732456844f, 0.823198305781f, 0.817584813152f, 0.811892519997f, 0.806121974951f, - 0.800273734191f, 0.794348361383f, 0.788346427627f, 0.782268511401f, 0.776115198508f, - 0.769887082016f, 0.763584762206f, 0.757208846506f, 0.750759949443f, 0.744238692572f, - 0.737645704427f, 0.730981620454f, 0.724247082951f, 0.717442741007f, 0.710569250438f, - 0.703627273726f, 0.696617479953f, 0.689540544737f, 0.682397150168f, 0.675187984742f, - 0.667913743292f, 0.660575126926f, 0.653172842954f, 0.645707604824f, 0.638180132051f, - 0.630591150148f, 0.622941390558f, 0.615231590581f, 0.607462493302f, 0.599634847523f, - 0.591749407690f, 0.583806933818f, 0.575808191418f, 0.567753951426f, 0.559644990127f, - 0.551482089078f, 0.543266035038f, 0.534997619887f, 0.526677640552f, 0.518306898929f, - 0.509886201809f, 0.501416360796f, 0.492898192230f, 0.484332517110f, 0.475720161014f, - 0.467061954019f, 0.458358730621f, 0.449611329655f, 0.440820594212f, 0.431987371563f, - 0.423112513073f, 0.414196874117f, 0.405241314005f, 0.396246695891f, 0.387213886697f, - 0.378143757022f, 0.369037181064f, 0.359895036535f, 0.350718204573f, 0.341507569661f, - 0.332264019538f, 0.322988445118f, 0.313681740399f, 0.304344802381f, 0.294978530977f, - 0.285583828929f, 0.276161601717f, 0.266712757475f, 0.257238206902f, 0.247738863176f, - 0.238215641862f, 0.228669460829f, 0.219101240157f, 0.209511902052f, 0.199902370753f, - 0.190273572448f, 0.180626435180f, 0.170961888760f, 0.161280864678f, 0.151584296010f, - 0.141873117332f, 0.132148264628f, 0.122410675199f, 0.112661287575f, 0.102901041421f, - 0.093130877450f, 0.083351737332f, 0.073564563600f, 0.063770299562f, 0.053969889210f, - 0.044164277127f, 0.034354408400f, 0.024541228523f, 0.014725683311f, 0.004908718808f + 0.004908718808f, 0.014725683311f, 0.024541228523f, 0.034354408400f, 0.044164277127f, + 0.053969889210f, 0.063770299562f, 0.073564563600f, 0.083351737332f, 0.093130877450f, + 0.102901041421f, 0.112661287575f, 0.122410675199f, 0.132148264628f, 0.141873117332f, + 0.151584296010f, 0.161280864678f, 0.170961888760f, 0.180626435180f, 0.190273572448f, + 0.199902370753f, 0.209511902052f, 0.219101240157f, 0.228669460829f, 0.238215641862f, + 0.247738863176f, 0.257238206902f, 0.266712757475f, 0.276161601717f, 0.285583828929f, + 0.294978530977f, 0.304344802381f, 0.313681740399f, 0.322988445118f, 0.332264019538f, + 0.341507569661f, 0.350718204573f, 0.359895036535f, 0.369037181064f, 0.378143757022f, + 0.387213886697f, 0.396246695891f, 0.405241314005f, 0.414196874117f, 0.423112513073f, + 0.431987371563f, 0.440820594212f, 0.449611329655f, 0.458358730621f, 0.467061954019f, + 0.475720161014f, 0.484332517110f, 0.492898192230f, 0.501416360796f, 0.509886201809f, + 0.518306898929f, 0.526677640552f, 0.534997619887f, 0.543266035038f, 0.551482089078f, + 0.559644990127f, 0.567753951426f, 0.575808191418f, 0.583806933818f, 0.591749407690f, + 0.599634847523f, 0.607462493302f, 0.615231590581f, 0.622941390558f, 0.630591150148f, + 0.638180132051f, 0.645707604824f, 0.653172842954f, 0.660575126926f, 0.667913743292f, + 0.675187984742f, 0.682397150168f, 0.689540544737f, 0.696617479953f, 0.703627273726f, + 0.710569250438f, 0.717442741007f, 0.724247082951f, 0.730981620454f, 0.737645704427f, + 0.744238692572f, 0.750759949443f, 0.757208846506f, 0.763584762206f, 0.769887082016f, + 0.776115198508f, 0.782268511401f, 0.788346427627f, 0.794348361383f, 0.800273734191f, + 0.806121974951f, 0.811892519997f, 0.817584813152f, 0.823198305781f, 0.828732456844f, + 0.834186732948f, 0.839560608398f, 0.844853565250f, 0.850065093356f, 0.855194690420f, + 0.860241862039f, 0.865206121757f, 0.870086991109f, 0.874883999665f, 0.879596685080f, + 0.884224593137f, 0.888767277786f, 0.893224301196f, 0.897595233788f, 0.901879654283f, + 0.906077149740f, 0.910187315596f, 0.914209755704f, 0.918144082372f, 0.921989916403f, + 0.925746887127f, 0.929414632439f, 0.932992798835f, 0.936481041442f, 0.939879024058f, + 0.943186419177f, 0.946402908026f, 0.949528180593f, 0.952561935658f, 0.955503880820f, + 0.958353732530f, 0.961111216112f, 0.963776065795f, 0.966348024735f, 0.968826845041f, + 0.971212287799f, 0.973504123096f, 0.975702130039f, 0.977806096779f, 0.979815820533f, + 0.981731107599f, 0.983551773378f, 0.985277642389f, 0.986908548290f, 0.988444333892f, + 0.989884851171f, 0.991229961288f, 0.992479534599f, 0.993633450666f, 0.994691598273f, + 0.995653875433f, 0.996520189401f, 0.997290456679f, 0.997964603026f, 0.998542563469f, + 0.999024282300f, 0.999409713092f, 0.999698818696f, 0.999891571247f, 0.999987952167f, + 0.999987952167f, 0.999891571247f, 0.999698818696f, 0.999409713092f, 0.999024282300f, + 0.998542563469f, 0.997964603026f, 0.997290456679f, 0.996520189401f, 0.995653875433f, + 0.994691598273f, 0.993633450666f, 0.992479534599f, 0.991229961288f, 0.989884851171f, + 0.988444333892f, 0.986908548290f, 0.985277642389f, 0.983551773378f, 0.981731107599f, + 0.979815820533f, 0.977806096779f, 0.975702130039f, 0.973504123096f, 0.971212287799f, + 0.968826845041f, 0.966348024735f, 0.963776065795f, 0.961111216112f, 0.958353732530f, + 0.955503880820f, 0.952561935658f, 0.949528180593f, 0.946402908026f, 0.943186419177f, + 0.939879024058f, 0.936481041442f, 0.932992798835f, 0.929414632439f, 0.925746887127f, + 0.921989916403f, 0.918144082372f, 0.914209755704f, 0.910187315596f, 0.906077149740f, + 0.901879654283f, 0.897595233788f, 0.893224301196f, 0.888767277786f, 0.884224593137f, + 0.879596685080f, 0.874883999665f, 0.870086991109f, 0.865206121757f, 0.860241862039f, + 0.855194690420f, 0.850065093356f, 0.844853565250f, 0.839560608398f, 0.834186732948f, + 0.828732456844f, 0.823198305781f, 0.817584813152f, 0.811892519997f, 0.806121974951f, + 0.800273734191f, 0.794348361383f, 0.788346427627f, 0.782268511401f, 0.776115198508f, + 0.769887082016f, 0.763584762206f, 0.757208846506f, 0.750759949443f, 0.744238692572f, + 0.737645704427f, 0.730981620454f, 0.724247082951f, 0.717442741007f, 0.710569250438f, + 0.703627273726f, 0.696617479953f, 0.689540544737f, 0.682397150168f, 0.675187984742f, + 0.667913743292f, 0.660575126926f, 0.653172842954f, 0.645707604824f, 0.638180132051f, + 0.630591150148f, 0.622941390558f, 0.615231590581f, 0.607462493302f, 0.599634847523f, + 0.591749407690f, 0.583806933818f, 0.575808191418f, 0.567753951426f, 0.559644990127f, + 0.551482089078f, 0.543266035038f, 0.534997619887f, 0.526677640552f, 0.518306898929f, + 0.509886201809f, 0.501416360796f, 0.492898192230f, 0.484332517110f, 0.475720161014f, + 0.467061954019f, 0.458358730621f, 0.449611329655f, 0.440820594212f, 0.431987371563f, + 0.423112513073f, 0.414196874117f, 0.405241314005f, 0.396246695891f, 0.387213886697f, + 0.378143757022f, 0.369037181064f, 0.359895036535f, 0.350718204573f, 0.341507569661f, + 0.332264019538f, 0.322988445118f, 0.313681740399f, 0.304344802381f, 0.294978530977f, + 0.285583828929f, 0.276161601717f, 0.266712757475f, 0.257238206902f, 0.247738863176f, + 0.238215641862f, 0.228669460829f, 0.219101240157f, 0.209511902052f, 0.199902370753f, + 0.190273572448f, 0.180626435180f, 0.170961888760f, 0.161280864678f, 0.151584296010f, + 0.141873117332f, 0.132148264628f, 0.122410675199f, 0.112661287575f, 0.102901041421f, + 0.093130877450f, 0.083351737332f, 0.073564563600f, 0.063770299562f, 0.053969889210f, + 0.044164277127f, 0.034354408400f, 0.024541228523f, 0.014725683311f, 0.004908718808f }; -static void apply_filterbank(float *x_out, float *x_in, const int *center_bins, const float* band_weights, int num_bands) -{ +static void oaci_apply_filterbank(float *x_out, float *x_in, const int *center_bins, const float* band_weights, + int num_bands) { int b, i; float frac; celt_assert(x_in != x_out); x_out[0] = 0; - for (b = 0; b < num_bands - 1; b++) - { - x_out[b+1] = 0; - for (i = center_bins[b]; i < center_bins[b+1]; i++) - { - frac = (float) (center_bins[b+1] - i) / (center_bins[b+1] - center_bins[b]); - x_out[b] += band_weights[b] * frac * x_in[i]; - x_out[b+1] += band_weights[b+1] * (1 - frac) * x_in[i]; + for (b = 0; b < num_bands - 1; b++) { + x_out[b + 1] = 0; + for (i = center_bins[b]; i < center_bins[b + 1]; i++) { + frac = (float) (center_bins[b + 1] - i)/(center_bins[b + 1] - center_bins[b]); + x_out[b] += band_weights[b]*frac*x_in[i]; + x_out[b + 1] += band_weights[b + 1]*(1 - frac)*x_in[i]; } } - x_out[num_bands - 1] += band_weights[num_bands - 1] * x_in[center_bins[num_bands - 1]]; + x_out[num_bands - 1] += band_weights[num_bands - 1]*x_in[center_bins[num_bands - 1]]; #ifdef DEBUG_PRINT - for (b = 0; b < num_bands; b++) - { + for (b = 0; b < num_bands; b++) { printf("band[%d]: %f\n", b, x_out[b]); } #endif } -static void mag_spec_320_onesided(float *out, float *in) -{ +static void oaci_mag_spec_320_onesided(float *out, float *in) { celt_assert(OSCE_SPEC_WINDOW_SIZE == 320); kiss_fft_cpx buffer[OSCE_SPEC_WINDOW_SIZE]; int k; - forward_transform(buffer, in); + oaci_forward_transform(buffer, in); - for (k = 0; k < OSCE_SPEC_NUM_FREQS; k++) - { - out[k] = OSCE_SPEC_WINDOW_SIZE * sqrt(buffer[k].r * buffer[k].r + buffer[k].i * buffer[k].i); + for (k = 0; k < OSCE_SPEC_NUM_FREQS; k++) { + out[k] = OSCE_SPEC_WINDOW_SIZE*sqrt(buffer[k].r*buffer[k].r + buffer[k].i*buffer[k].i); #ifdef DEBUG_PRINT printf("magspec[%d]: %f\n", k, out[k]); #endif @@ -226,58 +221,51 @@ static void mag_spec_320_onesided(float *out, float *in) } -static void calculate_log_spectrum_from_lpc(float *spec, opus_int16 *a_q12, int lpc_order) -{ +static void oaci_calculate_log_spectrum_from_lpc(float *spec, oac_int16 *a_q12, int lpc_order) { float buffer[OSCE_SPEC_WINDOW_SIZE] = {0}; int i; /* zero expansion */ buffer[0] = 1; - for (i = 0; i < lpc_order; i++) - { - buffer[i+1] = - (float)a_q12[i] / (1U << 12); + for (i = 0; i < lpc_order; i++) { + buffer[i + 1] = -(float)a_q12[i]/(1U<<12); } /* calculate and invert magnitude spectrum */ - mag_spec_320_onesided(buffer, buffer); + oaci_mag_spec_320_onesided(buffer, buffer); - for (i = 0; i < OSCE_SPEC_NUM_FREQS; i++) - { - buffer[i] = 1.f / (buffer[i] + 1e-9f); + for (i = 0; i < OSCE_SPEC_NUM_FREQS; i++) { + buffer[i] = 1.f/(buffer[i] + 1e-9f); } /* apply filterbank */ - apply_filterbank(spec, buffer, center_bins_clean, band_weights_clean, OSCE_CLEAN_SPEC_NUM_BANDS); + oaci_apply_filterbank(spec, buffer, center_bins_clean, band_weights_clean, OSCE_CLEAN_SPEC_NUM_BANDS); /* log and scaling */ - for (i = 0; i < OSCE_CLEAN_SPEC_NUM_BANDS; i++) - { - spec[i] = 0.3f * log(spec[i] + 1e-9f); + for (i = 0; i < OSCE_CLEAN_SPEC_NUM_BANDS; i++) { + spec[i] = 0.3f*log(spec[i] + 1e-9f); } } -static void calculate_cepstrum(float *cepstrum, float *signal) -{ +static void oaci_calculate_cepstrum(float *cepstrum, float *signal) { float buffer[OSCE_SPEC_WINDOW_SIZE]; float *spec = &buffer[OSCE_SPEC_NUM_FREQS + 3]; int n; celt_assert(cepstrum != signal); - for (n = 0; n < OSCE_SPEC_WINDOW_SIZE; n++) - { - buffer[n] = osce_window[n] * signal[n]; + for (n = 0; n < OSCE_SPEC_WINDOW_SIZE; n++) { + buffer[n] = osce_window[n]*signal[n]; } /* calculate magnitude spectrum */ - mag_spec_320_onesided(buffer, buffer); + oaci_mag_spec_320_onesided(buffer, buffer); /* accumulate bands */ - apply_filterbank(spec, buffer, center_bins_noisy, band_weights_noisy, OSCE_NOISY_SPEC_NUM_BANDS); + oaci_apply_filterbank(spec, buffer, center_bins_noisy, band_weights_noisy, OSCE_NOISY_SPEC_NUM_BANDS); /* log domain conversion */ - for (n = 0; n < OSCE_NOISY_SPEC_NUM_BANDS; n++) - { + for (n = 0; n < OSCE_NOISY_SPEC_NUM_BANDS; n++) { spec[n] = log(spec[n] + 1e-9f); #ifdef DEBUG_PRINT printf("logspec[%d]: %f\n", n, spec[n]); @@ -286,71 +274,59 @@ static void calculate_cepstrum(float *cepstrum, float *signal) /* DCT-II (orthonormal) */ celt_assert(OSCE_NOISY_SPEC_NUM_BANDS == NB_BANDS); - dct(cepstrum, spec); + oaci_dct(cepstrum, spec); } -static void calculate_acorr(float *acorr, float *signal, int lag) -{ +static void oaci_calculate_acorr(float *acorr, float *signal, int lag) { int n, k; celt_assert(acorr != signal); - for (k = -2; k <= 2; k++) - { - acorr[k+2] = 0; + for (k = -2; k <= 2; k++) { + acorr[k + 2] = 0; float xx = 0; float xy = 0; float yy = 0; - for (n = 0; n < 80; n++) - { + for (n = 0; n < 80; n++) { /* obviously wasteful -> fix later */ - xx += signal[n] * signal[n]; - yy += signal[n - lag + k] * signal[n - lag + k]; - xy += signal[n] * signal[n - lag + k]; + xx += signal[n]*signal[n]; + yy += signal[n - lag + k]*signal[n - lag + k]; + xy += signal[n]*signal[n - lag + k]; } - acorr[k+2] = xy / sqrt(xx * yy + 1e-9f); + acorr[k + 2] = xy/sqrt(xx*yy + 1e-9f); } } -static int pitch_postprocessing(OSCEFeatureState *psFeatures, int lag, int type) -{ +static int oaci_pitch_postprocessing(OSCEFeatureState *psFeatures, int lag, int type) { int new_lag; int modulus; #ifdef OSCE_HANGOVER_BUGFIX -#define TESTBIT 1 +# define TESTBIT 1 #else -#define TESTBIT 0 +# define TESTBIT 0 #endif modulus = OSCE_PITCH_HANGOVER; - if (modulus == 0) modulus ++; + if (modulus == 0) modulus++; /* hangover is currently disabled to reflect a bug in the python code. ToDo: re-evaluate hangover */ - if (type != TYPE_VOICED && psFeatures->last_type == TYPE_VOICED && TESTBIT) - /* enter hangover */ - { + if (type != TYPE_VOICED && psFeatures->last_type == TYPE_VOICED && TESTBIT) { + /* enter hangover */ new_lag = OSCE_NO_PITCH_VALUE; - if (psFeatures->pitch_hangover_count < OSCE_PITCH_HANGOVER) - { + if (psFeatures->pitch_hangover_count < OSCE_PITCH_HANGOVER) { new_lag = psFeatures->last_lag; - psFeatures->pitch_hangover_count = (psFeatures->pitch_hangover_count + 1) % modulus; + psFeatures->pitch_hangover_count = (psFeatures->pitch_hangover_count + 1)%modulus; } - } - else if (type != TYPE_VOICED && psFeatures->pitch_hangover_count && TESTBIT) - /* continue hangover */ - { + } else if (type != TYPE_VOICED && psFeatures->pitch_hangover_count && TESTBIT) { + /* continue hangover */ new_lag = psFeatures->last_lag; - psFeatures->pitch_hangover_count = (psFeatures->pitch_hangover_count + 1) % modulus; - } - else if (type != TYPE_VOICED) - /* unvoiced frame after hangover */ - { + psFeatures->pitch_hangover_count = (psFeatures->pitch_hangover_count + 1)%modulus; + } else if (type != TYPE_VOICED) { + /* unvoiced frame after hangover */ new_lag = OSCE_NO_PITCH_VALUE; psFeatures->pitch_hangover_count = 0; - } - else - /* voiced frame: update last_lag */ - { + } else { + /* voiced frame: update last_lag */ new_lag = lag; psFeatures->last_lag = lag; psFeatures->pitch_hangover_count = 0; @@ -365,88 +341,80 @@ static int pitch_postprocessing(OSCEFeatureState *psFeatures, int lag, int type) return new_lag; } -void osce_calculate_features( +void oaci_osce_calculate_features( silk_decoder_state *psDec, /* I/O Decoder state */ silk_decoder_control *psDecCtrl, /* I Decoder control */ float *features, /* O input features */ float *numbits, /* O numbits and smoothed numbits */ int *periods, /* O pitch lags on subframe basis */ - const opus_int16 xq[], /* I Decoded speech */ - opus_int32 num_bits /* I Size of SILK payload in bits */ -) -{ + const oac_int16 xq[], /* I Decoded speech */ + oac_int32 num_bits /* I Size of SILK payload in bits */ + ) { int num_subframes, num_samples; - float buffer[OSCE_FEATURES_MAX_HISTORY + OSCE_MAX_FEATURE_FRAMES * 80]; + float buffer[OSCE_FEATURES_MAX_HISTORY + OSCE_MAX_FEATURE_FRAMES*80]; float *frame, *pfeatures; OSCEFeatureState *psFeatures; int i, n, k; #ifdef WRITE_FEATURES static FILE *f_feat = NULL; - if (f_feat == NULL) - { + if (f_feat == NULL) { f_feat = fopen("assembled_features.f32", "wb"); } #endif - /*OPUS_CLEAR(buffer, 1);*/ + /*OAC_CLEAR(buffer, 1);*/ memset(buffer, 0, sizeof(buffer)); num_subframes = psDec->nb_subfr; - num_samples = num_subframes * 80; + num_samples = num_subframes*80; psFeatures = &psDec->osce.features; /* smooth bit count */ - psFeatures->numbits_smooth = 0.9f * psFeatures->numbits_smooth + 0.1f * num_bits; + psFeatures->numbits_smooth = 0.9f*psFeatures->numbits_smooth + 0.1f*num_bits; numbits[0] = num_bits; numbits[1] = psFeatures->numbits_smooth; - for (n = 0; n < num_samples; n++) - { - buffer[OSCE_FEATURES_MAX_HISTORY + n] = (float) xq[n] / (1U<<15); + for (n = 0; n < num_samples; n++) { + buffer[OSCE_FEATURES_MAX_HISTORY + n] = (float) xq[n]/(1U<<15); } - OPUS_COPY(buffer, psFeatures->signal_history, OSCE_FEATURES_MAX_HISTORY); + OAC_COPY(buffer, psFeatures->signal_history, OSCE_FEATURES_MAX_HISTORY); - for (k = 0; k < num_subframes; k++) - { - pfeatures = features + k * OSCE_FEATURE_DIM; - frame = &buffer[OSCE_FEATURES_MAX_HISTORY + k * 80]; + for (k = 0; k < num_subframes; k++) { + pfeatures = features + k*OSCE_FEATURE_DIM; + frame = &buffer[OSCE_FEATURES_MAX_HISTORY + k*80]; memset(pfeatures, 0, OSCE_FEATURE_DIM); /* precaution */ /* clean spectrum from lpcs (update every other frame) */ - if (k % 2 == 0) - { - calculate_log_spectrum_from_lpc(pfeatures + OSCE_CLEAN_SPEC_START, psDecCtrl->PredCoef_Q12[k >> 1], psDec->LPC_order); - } - else - { - OPUS_COPY(pfeatures + OSCE_CLEAN_SPEC_START, pfeatures + OSCE_CLEAN_SPEC_START - OSCE_FEATURE_DIM, OSCE_CLEAN_SPEC_LENGTH); + if (k%2 == 0) { + oaci_calculate_log_spectrum_from_lpc(pfeatures + OSCE_CLEAN_SPEC_START, psDecCtrl->PredCoef_Q12[k>>1], + psDec->LPC_order); + } else { + OAC_COPY(pfeatures + OSCE_CLEAN_SPEC_START, pfeatures + OSCE_CLEAN_SPEC_START - OSCE_FEATURE_DIM, + OSCE_CLEAN_SPEC_LENGTH); } /* noisy cepstrum from signal (update every other frame) */ - if (k % 2 == 0) - { - calculate_cepstrum(pfeatures + OSCE_NOISY_CEPSTRUM_START, frame - 160); - } - else - { - OPUS_COPY(pfeatures + OSCE_NOISY_CEPSTRUM_START, pfeatures + OSCE_NOISY_CEPSTRUM_START - OSCE_FEATURE_DIM, OSCE_NOISY_CEPSTRUM_LENGTH); + if (k%2 == 0) { + oaci_calculate_cepstrum(pfeatures + OSCE_NOISY_CEPSTRUM_START, frame - 160); + } else { + OAC_COPY(pfeatures + OSCE_NOISY_CEPSTRUM_START, pfeatures + OSCE_NOISY_CEPSTRUM_START - OSCE_FEATURE_DIM, + OSCE_NOISY_CEPSTRUM_LENGTH); } /* pitch hangover and zero value replacement */ - periods[k] = pitch_postprocessing(psFeatures, psDecCtrl->pitchL[k], psDec->indices.signalType); + periods[k] = oaci_pitch_postprocessing(psFeatures, psDecCtrl->pitchL[k], psDec->indices.signalType); /* auto-correlation around pitch lag */ - calculate_acorr(pfeatures + OSCE_ACORR_START, frame, periods[k]); + oaci_calculate_acorr(pfeatures + OSCE_ACORR_START, frame, periods[k]); /* ltp */ celt_assert(OSCE_LTP_LENGTH == LTP_ORDER); - for (i = 0; i < OSCE_LTP_LENGTH; i++) - { - pfeatures[OSCE_LTP_START + i] = (float) psDecCtrl->LTPCoef_Q14[k * LTP_ORDER + i] / (1U << 14); + for (i = 0; i < OSCE_LTP_LENGTH; i++) { + pfeatures[OSCE_LTP_START + i] = (float) psDecCtrl->LTPCoef_Q14[k*LTP_ORDER + i]/(1U<<14); } /* frame gain */ - pfeatures[OSCE_LOG_GAIN_START] = log((float) psDecCtrl->Gains_Q16[k] / (1UL << 16) + 1e-9f); + pfeatures[OSCE_LOG_GAIN_START] = log((float) psDecCtrl->Gains_Q16[k]/(1UL<<16) + 1e-9f); #ifdef WRITE_FEATURES fwrite(pfeatures, sizeof(*pfeatures), 93, f_feat); @@ -454,119 +422,108 @@ void osce_calculate_features( } /* buffer update */ - OPUS_COPY(psFeatures->signal_history, &buffer[num_samples], OSCE_FEATURES_MAX_HISTORY); + OAC_COPY(psFeatures->signal_history, &buffer[num_samples], OSCE_FEATURES_MAX_HISTORY); } #ifdef ENABLE_OSCE_BWE -void osce_bwe_calculate_features( +void oaci_osce_bwe_calculate_features( OSCEBWEFeatureState *psFeatures, /* I/O BWE feature state */ float *features, /* O input features */ - const opus_int16 xq[], /* I Decoded speech */ - int num_samples /* I number of input samples */ - ) - { + const oac_int16 xq[], /* I Decoded speech */ + int num_samples /* I number of input samples */ + ) { int n, k, num_frames, frame; kiss_fft_cpx fft_buffer[OSCE_BWE_WINDOW_SIZE]; - float spec[2 * OSCE_BWE_MAX_INSTAFREQ_BIN + 2]; + float spec[2*OSCE_BWE_MAX_INSTAFREQ_BIN + 2]; float buffer[OSCE_BWE_WINDOW_SIZE]; float mag_spec[OSCE_SPEC_NUM_FREQS]; float *lmspec, *instafreq; /* OSCE_BWE_WINDOW_SIZE == 320 is a hard requirement */ - celt_assert((num_samples % OSCE_BWE_HALF_WINDOW_SIZE == 0) && (OSCE_BWE_WINDOW_SIZE == 320)); + celt_assert((num_samples%OSCE_BWE_HALF_WINDOW_SIZE == 0) && (OSCE_BWE_WINDOW_SIZE == 320)); - num_frames = num_samples / OSCE_BWE_HALF_WINDOW_SIZE; + num_frames = num_samples/OSCE_BWE_HALF_WINDOW_SIZE; - for (frame = 0; frame < num_frames; frame++) - { + for (frame = 0; frame < num_frames; frame++) { /* clear features */ - OPUS_CLEAR(features + frame * OSCE_BWE_FEATURE_DIM, OSCE_BWE_FEATURE_DIM); + OAC_CLEAR(features + frame*OSCE_BWE_FEATURE_DIM, OSCE_BWE_FEATURE_DIM); - lmspec = features + frame * OSCE_BWE_FEATURE_DIM; + lmspec = features + frame*OSCE_BWE_FEATURE_DIM; instafreq = lmspec + OSCE_BWE_NUM_BANDS; - const opus_int16 *x = xq + frame * OSCE_BWE_HALF_WINDOW_SIZE; + const oac_int16 *x = xq + frame*OSCE_BWE_HALF_WINDOW_SIZE; - OPUS_COPY(buffer, psFeatures->signal_history, OSCE_BWE_HALF_WINDOW_SIZE); - for (n = 0; n < OSCE_BWE_HALF_WINDOW_SIZE; n++) - { - buffer[n + OSCE_BWE_HALF_WINDOW_SIZE] = (float) x[n] / (1U<<15); + OAC_COPY(buffer, psFeatures->signal_history, OSCE_BWE_HALF_WINDOW_SIZE); + for (n = 0; n < OSCE_BWE_HALF_WINDOW_SIZE; n++) { + buffer[n + OSCE_BWE_HALF_WINDOW_SIZE] = (float) x[n]/(1U<<15); } /* update signal history buffer */ - OPUS_COPY(psFeatures->signal_history, buffer + OSCE_BWE_HALF_WINDOW_SIZE, OSCE_BWE_HALF_WINDOW_SIZE); + OAC_COPY(psFeatures->signal_history, buffer + OSCE_BWE_HALF_WINDOW_SIZE, OSCE_BWE_HALF_WINDOW_SIZE); /* apply window */ - for (n = 0; n < OSCE_BWE_WINDOW_SIZE; n ++) - { + for (n = 0; n < OSCE_BWE_WINDOW_SIZE; n++) { buffer[n] *= osce_window[n]; } /* DFT */ - forward_transform(fft_buffer, buffer); + oaci_forward_transform(fft_buffer, buffer); /* instafreq */ - for (k = 0; k <= OSCE_BWE_MAX_INSTAFREQ_BIN; k++) - { + for (k = 0; k <= OSCE_BWE_MAX_INSTAFREQ_BIN; k++) { float aux_r, aux_i, aux_abs; float re1, re2, im1, im2; - spec[2*k] = OSCE_BWE_WINDOW_SIZE * fft_buffer[k].r + 1e-9; /* ToDo: remove 1e-9 from python code*/ - spec[2*k+1] = OSCE_BWE_WINDOW_SIZE * fft_buffer[k].i; + spec[2*k] = OSCE_BWE_WINDOW_SIZE*fft_buffer[k].r + 1e-9; /* ToDo: remove 1e-9 from python code*/ + spec[2*k + 1] = OSCE_BWE_WINDOW_SIZE*fft_buffer[k].i; re1 = spec[2*k]; - im1 = spec[2*k+1]; + im1 = spec[2*k + 1]; re2 = psFeatures->last_spec[2*k]; - im2 = psFeatures->last_spec[2*k+1]; - aux_r = re1 * re2 + im1 * im2; - aux_i = im1 * re2 - re1 * im2; - aux_abs = sqrt(aux_r * aux_r + aux_i * aux_i); - instafreq[k] = aux_r / (aux_abs + 1e-9); - instafreq[k + OSCE_BWE_MAX_INSTAFREQ_BIN + 1] = aux_i / (aux_abs + 1e-9); + im2 = psFeatures->last_spec[2*k + 1]; + aux_r = re1*re2 + im1*im2; + aux_i = im1*re2 - re1*im2; + aux_abs = sqrt(aux_r*aux_r + aux_i*aux_i); + instafreq[k] = aux_r/(aux_abs + 1e-9); + instafreq[k + OSCE_BWE_MAX_INSTAFREQ_BIN + 1] = aux_i/(aux_abs + 1e-9); } /* erb-scale magnitude spectrogram */ - for (k = 0; k < OSCE_SPEC_NUM_FREQS; k ++) - { - mag_spec[k] = OSCE_BWE_WINDOW_SIZE * sqrt(fft_buffer[k].r * fft_buffer[k].r + fft_buffer[k].i * fft_buffer[k].i); + for (k = 0; k < OSCE_SPEC_NUM_FREQS; k++) { + mag_spec[k] = OSCE_BWE_WINDOW_SIZE*sqrt(fft_buffer[k].r*fft_buffer[k].r + fft_buffer[k].i*fft_buffer[k].i); } - apply_filterbank(lmspec, mag_spec, center_bins_bwe, band_weights_bwe, OSCE_BWE_NUM_BANDS); + oaci_apply_filterbank(lmspec, mag_spec, center_bins_bwe, band_weights_bwe, OSCE_BWE_NUM_BANDS); - for (k = 0; k < OSCE_BWE_NUM_BANDS; k++) - { + for (k = 0; k < OSCE_BWE_NUM_BANDS; k++) { lmspec[k] = log(lmspec[k] + 1e-9); } /* update instafreq buffer */ - OPUS_COPY(psFeatures->last_spec, spec, 2 * OSCE_BWE_MAX_INSTAFREQ_BIN + 2); + OAC_COPY(psFeatures->last_spec, spec, 2*OSCE_BWE_MAX_INSTAFREQ_BIN + 2); } } #endif /* ENABLE_OSCE_BWE */ -void osce_cross_fade_10ms(float *x_enhanced, float *x_in, int length) -{ +void oaci_osce_cross_fade_10ms(float *x_enhanced, float *x_in, int length) { int i; celt_assert(length >= 160); - for (i = 0; i < 160; i++) - { - x_enhanced[i] = osce_window[i] * x_enhanced[i] + (1.f - osce_window[i]) * x_in[i]; + for (i = 0; i < 160; i++) { + x_enhanced[i] = osce_window[i]*x_enhanced[i] + (1.f - osce_window[i])*x_in[i]; } } -void osce_bwe_cross_fade_10ms(opus_int16 *x_fadein, opus_int16 *x_fadeout, int length) -{ +void oaci_osce_bwe_cross_fade_10ms(oac_int16 *x_fadein, oac_int16 *x_fadeout, int length) { int i; celt_assert(length >= 480); - float f = 1.f / 3; - for (i = 0; i < 160; i++) - { + float f = 1.f/3; + for (i = 0; i < 160; i++) { float diff = i == 159 ? 0.f : osce_window[i + 1] - osce_window[i]; float w_curr = osce_window[i]; - x_fadein[3*i + 0] = (int) (w_curr * x_fadein[3*i + 0] + (1.f - w_curr) * x_fadeout[3*i + 0] + 0.5); - w_curr += diff * f; - x_fadein[3*i + 1] = (int) (w_curr * x_fadein[3*i + 1] + (1.f - w_curr) * x_fadeout[3*i + 1] + 0.5); - w_curr += diff * f; - x_fadein[3*i + 2] = (int) (w_curr * x_fadein[3*i + 2] + (1.f - w_curr) * x_fadeout[3*i + 2] + 0.5); + x_fadein[3*i + 0] = (int) (w_curr*x_fadein[3*i + 0] + (1.f - w_curr)*x_fadeout[3*i + 0] + 0.5); + w_curr += diff*f; + x_fadein[3*i + 1] = (int) (w_curr*x_fadein[3*i + 1] + (1.f - w_curr)*x_fadeout[3*i + 1] + 0.5); + w_curr += diff*f; + x_fadein[3*i + 2] = (int) (w_curr*x_fadein[3*i + 2] + (1.f - w_curr)*x_fadeout[3*i + 2] + 0.5); } } diff --git a/dnn/osce_features.h b/dnn/osce_features.h index ae276c99b..62b79f73f 100644 --- a/dnn/osce_features.h +++ b/dnn/osce_features.h @@ -23,36 +23,36 @@ 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. -*/ + */ #ifndef OSCE_FEATURES_H #define OSCE_FEATURES_H #include "structs.h" -#include "opus_types.h" +#include "oac_types.h" #define OSCE_NUMBITS_BUGFIX -void osce_calculate_features( +void oaci_osce_calculate_features( silk_decoder_state *psDec, /* I/O Decoder state */ silk_decoder_control *psDecCtrl, /* I Decoder control */ float *features, /* O input features */ float *numbits, /* O numbits and smoothed numbits */ int *periods, /* O pitch lags on subframe basis */ - const opus_int16 xq[], /* I Decoded speech */ - opus_int32 num_bits /* I Size of SILK payload in bits */ -); + const oac_int16 xq[], /* I Decoded speech */ + oac_int32 num_bits /* I Size of SILK payload in bits */ + ); #ifdef ENABLE_OSCE_BWE -void osce_bwe_calculate_features( - OSCEBWEFeatureState *psFeatures, /* I/O BWE feature state */ - float *features, /* O input features */ - const opus_int16 xq[], /* I Decoded speech */ - int num_samples /* I number of input samples */ -); +void oaci_osce_bwe_calculate_features( + OSCEBWEFeatureState *psFeatures, /* I/O BWE feature state */ + float *features, /* O input features */ + const oac_int16 xq[], /* I Decoded speech */ + int num_samples /* I number of input samples */ + ); #endif -void osce_cross_fade_10ms(float *x_enhanced, float *x_in, int length); -void osce_bwe_cross_fade_10ms(opus_int16 *x_fadein, opus_int16* x_fadeout, int length); +void oaci_osce_cross_fade_10ms(float *x_enhanced, float *x_in, int length); +void oaci_osce_bwe_cross_fade_10ms(oac_int16 *x_fadein, oac_int16* x_fadeout, int length); #endif diff --git a/dnn/osce_structs.h b/dnn/osce_structs.h index b44ee7723..7b0474785 100644 --- a/dnn/osce_structs.h +++ b/dnn/osce_structs.h @@ -23,22 +23,22 @@ 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. -*/ + */ #ifndef OSCE_STRUCTS_H #define OSCE_STRUCTS_H -#include "opus_types.h" +#include "oac_types.h" #include "osce_config.h" #ifndef DISABLE_LACE -#include "lace_data.h" +# include "lace_data.h" #endif #ifndef DISABLE_NOLACE -#include "nolace_data.h" +# include "nolace_data.h" #endif #ifndef DISABLE_BBWENET -#include "bbwenet_data.h" -#include "resampler_structs.h" +# include "bbwenet_data.h" +# include "resampler_structs.h" #endif #include "nndsp.h" #include "nnet.h" @@ -46,17 +46,17 @@ /* feature calculation */ typedef struct { - float numbits_smooth; - int pitch_hangover_count; - int last_lag; - int last_type; - float signal_history[OSCE_FEATURES_MAX_HISTORY]; - int reset; + float numbits_smooth; + int pitch_hangover_count; + int last_lag; + int last_type; + float signal_history[OSCE_FEATURES_MAX_HISTORY]; + int reset; } OSCEFeatureState; typedef struct { float signal_history[OSCE_BWE_HALF_WINDOW_SIZE]; - float last_spec[2 * OSCE_BWE_MAX_INSTAFREQ_BIN + 2]; + float last_spec[2*OSCE_BWE_MAX_INSTAFREQ_BIN + 2]; } OSCEBWEFeatureState; #ifndef DISABLE_BBWENET @@ -70,7 +70,7 @@ typedef struct { float feature_net_conv1_state[BBWENET_FNET_CONV1_STATE_SIZE]; float feature_net_conv2_state[BBWENET_FNET_CONV2_STATE_SIZE]; float feature_net_gru_state[BBWENET_FNET_GRU_STATE_SIZE]; - opus_int16 outbut_buffer[OSCE_BWE_OUTPUT_DELAY]; + oac_int16 outbut_buffer[OSCE_BWE_OUTPUT_DELAY]; AdaConvState af1_state; AdaConvState af2_state; AdaConvState af3_state; @@ -100,8 +100,7 @@ typedef struct { float deemph_mem; } LACEState; -typedef struct -{ +typedef struct { LACELayers layers; float window[LACE_OVERLAP_SIZE]; } LACE; @@ -141,7 +140,7 @@ typedef struct { /* OSCEModel */ typedef struct { - int loaded; + int loaded; #ifndef DISABLE_LACE LACE lace; #endif @@ -163,9 +162,9 @@ typedef union { } OSCEState; typedef struct { - #ifndef DISABLE_BBWENET +#ifndef DISABLE_BBWENET BBWENetState bbwenet; - #endif +#endif } OSCEBWEState; #endif diff --git a/dnn/parse_lpcnet_weights.c b/dnn/parse_lpcnet_weights.c index 1e6549680..4bdb420f9 100644 --- a/dnn/parse_lpcnet_weights.c +++ b/dnn/parse_lpcnet_weights.c @@ -22,10 +22,10 @@ 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" +# include "config.h" #endif #include @@ -35,204 +35,212 @@ #define SPARSE_BLOCK_SIZE 32 -int parse_record(const void **data, int *len, WeightArray *array) { - WeightHead *h = (WeightHead *)*data; - if (*len < WEIGHT_BLOCK_SIZE) return -1; - if (h->block_size < h->size) return -1; - if (h->block_size > *len-WEIGHT_BLOCK_SIZE) return -1; - if (h->name[sizeof(h->name)-1] != 0) return -1; - if (h->size < 0) return -1; - array->name = h->name; - array->type = h->type; - array->size = h->size; - array->data = (void*)((unsigned char*)(*data)+WEIGHT_BLOCK_SIZE); - - *data = (void*)((unsigned char*)*data + h->block_size+WEIGHT_BLOCK_SIZE); - *len -= h->block_size+WEIGHT_BLOCK_SIZE; - return array->size; +int oaci_parse_record(const void **data, int *len, WeightArray *array) { + WeightHead *h = (WeightHead *)*data; + if (*len < WEIGHT_BLOCK_SIZE) return -1; + if (h->block_size < h->size) return -1; + if (h->block_size > *len - WEIGHT_BLOCK_SIZE) return -1; + if (h->name[sizeof(h->name) - 1] != 0) return -1; + if (h->size < 0) return -1; + array->name = h->name; + array->type = h->type; + array->size = h->size; + array->data = (void*)((unsigned char*)(*data) + WEIGHT_BLOCK_SIZE); + + *data = (void*)((unsigned char*)*data + h->block_size + WEIGHT_BLOCK_SIZE); + *len -= h->block_size + WEIGHT_BLOCK_SIZE; + return array->size; } -int parse_weights(WeightArray **list, const void *data, int len) -{ - int nb_arrays=0; - int capacity=20; - *list = (WeightArray*)opus_alloc(capacity*sizeof(WeightArray)); - while (len > 0) { - int ret; - WeightArray array = {NULL, 0, 0, 0}; - ret = parse_record(&data, &len, &array); - if (ret > 0) { - if (nb_arrays+1 >= capacity) { - /* Make sure there's room for the ending NULL element too. */ - capacity = capacity*3/2; - *list = (WeightArray*)opus_realloc(*list, capacity*sizeof(WeightArray)); - } - (*list)[nb_arrays++] = array; - } else { - opus_free(*list); - *list = NULL; - return -1; +int oaci_parse_weights(WeightArray **list, const void *data, int len) { + int nb_arrays = 0; + int capacity = 20; + *list = (WeightArray*)oac_alloc(capacity*sizeof(WeightArray)); + while (len > 0) { + int ret; + WeightArray array = {NULL, 0, 0, 0}; + ret = oaci_parse_record(&data, &len, &array); + if (ret > 0) { + if (nb_arrays + 1 >= capacity) { + /* Make sure there's room for the ending NULL element too. */ + capacity = capacity*3/2; + *list = (WeightArray*)oac_realloc(*list, capacity*sizeof(WeightArray)); + } + (*list)[nb_arrays++] = array; + } else { + oac_free(*list); + *list = NULL; + return -1; + } } - } - (*list)[nb_arrays].name=NULL; - return nb_arrays; + (*list)[nb_arrays].name = NULL; + return nb_arrays; } -static const WeightArray *find_array_entry(const WeightArray *arrays, const char *name) { - while (arrays->name && strcmp(arrays->name, name) != 0) arrays++; - return arrays; +static const WeightArray *oaci_find_array_entry(const WeightArray *arrays, const char *name) { + while (arrays->name && strcmp(arrays->name, name) != 0) arrays++; + return arrays; } -static const void *find_array_check(const WeightArray *arrays, const char *name, int size) { - const WeightArray *a = find_array_entry(arrays, name); - if (a->name && a->size == size) return a->data; - else return NULL; +static const void *oaci_find_array_check(const WeightArray *arrays, const char *name, int size) { + const WeightArray *a = oaci_find_array_entry(arrays, name); + if (a->name && a->size == size) return a->data; + else return NULL; } -static const void *opt_array_check(const WeightArray *arrays, const char *name, int size, int *error) { - const WeightArray *a = find_array_entry(arrays, name); - *error = (a->name != NULL && a->size != size); - if (a->name && a->size == size) return a->data; - else return NULL; +static const void *oaci_opt_array_check(const WeightArray *arrays, const char *name, int size, int *error) { + const WeightArray *a = oaci_find_array_entry(arrays, name); + *error = (a->name != NULL && a->size != size); + if (a->name && a->size == size) return a->data; + else return NULL; } -static const void *find_idx_check(const WeightArray *arrays, const char *name, int nb_in, int nb_out, int *total_blocks) { - int remain; - const int *idx; - const WeightArray *a = find_array_entry(arrays, name); - *total_blocks = 0; - if (a == NULL) return NULL; - idx = (const int*)a->data; - remain = a->size/sizeof(int); - while (remain > 0) { - int nb_blocks; - int i; - nb_blocks = *idx++; - if (remain < nb_blocks+1) return NULL; - for (i=0;i= nb_in || (pos&0x3)) return NULL; +static const void *oaci_find_idx_check(const WeightArray *arrays, const char *name, int nb_in, int nb_out, + int *total_blocks) { + int remain; + const int *idx; + const WeightArray *a = oaci_find_array_entry(arrays, name); + *total_blocks = 0; + if (a == NULL) return NULL; + idx = (const int*)a->data; + remain = a->size/sizeof(int); + while (remain > 0) { + int nb_blocks; + int i; + nb_blocks = *idx++; + if (remain < nb_blocks + 1) return NULL; + for (i = 0; i < nb_blocks; i++) { + int pos = *idx++; + if (pos + 3 >= nb_in || (pos&0x3)) return NULL; + } + nb_out -= 8; + remain -= nb_blocks + 1; + *total_blocks += nb_blocks; } - nb_out -= 8; - remain -= nb_blocks+1; - *total_blocks += nb_blocks; - } - if (nb_out != 0) return NULL; - return a->data; + if (nb_out != 0) return NULL; + return a->data; } -int linear_init(LinearLayer *layer, const WeightArray *arrays, - const char *bias, - const char *subias, - const char *weights, - const char *float_weights, - const char *weights_idx, - const char *diag, - const char *scale, - int nb_inputs, - int nb_outputs) -{ - int err; - layer->bias = NULL; - layer->subias = NULL; - layer->weights = NULL; - layer->float_weights = NULL; - layer->weights_idx = NULL; - layer->diag = NULL; - layer->scale = NULL; - if (bias != NULL) { - if ((layer->bias = (const float*)find_array_check(arrays, bias, nb_outputs*sizeof(layer->bias[0]))) == NULL) return 1; - } - if (subias != NULL) { - if ((layer->subias = (const float*)find_array_check(arrays, subias, nb_outputs*sizeof(layer->subias[0]))) == NULL) return 1; - } - if (weights_idx != NULL) { - int total_blocks; - if ((layer->weights_idx = (const int*)find_idx_check(arrays, weights_idx, nb_inputs, nb_outputs, &total_blocks)) == NULL) return 1; - if (weights != NULL) { - if ((layer->weights = (const opus_int8*)find_array_check(arrays, weights, SPARSE_BLOCK_SIZE*total_blocks*sizeof(layer->weights[0]))) == NULL) return 1; +int oaci_linear_init(LinearLayer *layer, const WeightArray *arrays, + const char *bias, + const char *subias, + const char *weights, + const char *float_weights, + const char *weights_idx, + const char *diag, + const char *scale, + int nb_inputs, + int nb_outputs) { + int err; + layer->bias = NULL; + layer->subias = NULL; + layer->weights = NULL; + layer->float_weights = NULL; + layer->weights_idx = NULL; + layer->diag = NULL; + layer->scale = NULL; + if (bias != NULL) { + if ((layer->bias = (const float*)oaci_find_array_check(arrays, bias, + nb_outputs*sizeof(layer->bias[0]))) == NULL) return 1; } - if (float_weights != NULL) { - layer->float_weights = (const float*)opt_array_check(arrays, float_weights, SPARSE_BLOCK_SIZE*total_blocks*sizeof(layer->float_weights[0]), &err); - if (err) return 1; + if (subias != NULL) { + if ((layer->subias = (const float*)oaci_find_array_check(arrays, subias, + nb_outputs*sizeof(layer->subias[0]))) == NULL) return 1; } - } else { - if (weights != NULL) { - if ((layer->weights = (const opus_int8*)find_array_check(arrays, weights, nb_inputs*nb_outputs*sizeof(layer->weights[0]))) == NULL) return 1; + if (weights_idx != NULL) { + int total_blocks; + if ((layer->weights_idx = (const int*)oaci_find_idx_check(arrays, weights_idx, nb_inputs, nb_outputs, + &total_blocks)) == NULL) return 1; + if (weights != NULL) { + if ((layer->weights = (const oac_int8*)oaci_find_array_check(arrays, weights, + SPARSE_BLOCK_SIZE*total_blocks*sizeof(layer->weights[0]))) == NULL) return 1; + } + if (float_weights != NULL) { + layer->float_weights = (const float*)oaci_opt_array_check(arrays, float_weights, + SPARSE_BLOCK_SIZE*total_blocks*sizeof(layer->float_weights[0]), &err); + if (err) return 1; + } + } else { + if (weights != NULL) { + if ((layer->weights = (const oac_int8*)oaci_find_array_check(arrays, weights, + nb_inputs*nb_outputs*sizeof(layer->weights[0]))) == NULL) return 1; + } + if (float_weights != NULL) { + layer->float_weights = (const float*)oaci_opt_array_check(arrays, float_weights, + nb_inputs*nb_outputs*sizeof(layer->float_weights[0]), &err); + if (err) return 1; + } } - if (float_weights != NULL) { - layer->float_weights = (const float*)opt_array_check(arrays, float_weights, nb_inputs*nb_outputs*sizeof(layer->float_weights[0]), &err); - if (err) return 1; + if (diag != NULL) { + if ((layer->diag = (const float*)oaci_find_array_check(arrays, diag, + nb_outputs*sizeof(layer->diag[0]))) == NULL) return 1; } - } - if (diag != NULL) { - if ((layer->diag = (const float*)find_array_check(arrays, diag, nb_outputs*sizeof(layer->diag[0]))) == NULL) return 1; - } - if (weights != NULL) { - if ((layer->scale = (const float*)find_array_check(arrays, scale, nb_outputs*sizeof(layer->scale[0]))) == NULL) return 1; - } - layer->nb_inputs = nb_inputs; - layer->nb_outputs = nb_outputs; - return 0; + if (weights != NULL) { + if ((layer->scale = (const float*)oaci_find_array_check(arrays, scale, + nb_outputs*sizeof(layer->scale[0]))) == NULL) return 1; + } + layer->nb_inputs = nb_inputs; + layer->nb_outputs = nb_outputs; + return 0; } -int conv2d_init(Conv2dLayer *layer, const WeightArray *arrays, - const char *bias, - const char *float_weights, - int in_channels, - int out_channels, - int ktime, - int kheight) -{ - int err; - layer->bias = NULL; - layer->float_weights = NULL; - if (bias != NULL) { - if ((layer->bias = (const float*)find_array_check(arrays, bias, out_channels*sizeof(layer->bias[0]))) == NULL) return 1; - } - if (float_weights != NULL) { - layer->float_weights = (const float*)opt_array_check(arrays, float_weights, in_channels*out_channels*ktime*kheight*sizeof(layer->float_weights[0]), &err); - if (err) return 1; - } - layer->in_channels = in_channels; - layer->out_channels = out_channels; - layer->ktime = ktime; - layer->kheight = kheight; - return 0; +int oaci_conv2d_init(Conv2dLayer *layer, const WeightArray *arrays, + const char *bias, + const char *float_weights, + int in_channels, + int out_channels, + int ktime, + int kheight) { + int err; + layer->bias = NULL; + layer->float_weights = NULL; + if (bias != NULL) { + if ((layer->bias = (const float*)oaci_find_array_check(arrays, bias, + out_channels*sizeof(layer->bias[0]))) == NULL) return 1; + } + if (float_weights != NULL) { + layer->float_weights = (const float*)oaci_opt_array_check(arrays, float_weights, + in_channels*out_channels*ktime*kheight*sizeof(layer->float_weights[0]), &err); + if (err) return 1; + } + layer->in_channels = in_channels; + layer->out_channels = out_channels; + layer->ktime = ktime; + layer->kheight = kheight; + return 0; } #if 0 -#include -#include -#include -#include -#include - -int main() -{ - int fd; - void *data; - int len; - int nb_arrays; - int i; - WeightArray *list; - struct stat st; - const char *filename = "weights_blob.bin"; - stat(filename, &st); - len = st.st_size; - fd = open(filename, O_RDONLY); - data = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0); - printf("size is %d\n", len); - nb_arrays = parse_weights(&list, data, len); - for (i=0;i +# include +# include +# include +# include + +int main() { + int fd; + void *data; + int len; + int nb_arrays; + int i; + WeightArray *list; + struct stat st; + const char *filename = "weights_blob.bin"; + stat(filename, &st); + len = st.st_size; + fd = open(filename, O_RDONLY); + data = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0); + printf("size is %d\n", len); + nb_arrays = oaci_parse_weights(&list, data, len); + for (i = 0; i < nb_arrays; i++) { + printf("found %s: size %d\n", list[i].name, list[i].size); + } + printf("%p\n", list[i].name); + oac_free(list); + munmap(data, len); + close(fd); + return 0; } #endif diff --git a/dnn/pitchdnn.c b/dnn/pitchdnn.c index 5cf96e7f9..f324957a5 100644 --- a/dnn/pitchdnn.c +++ b/dnn/pitchdnn.c @@ -1,5 +1,5 @@ #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif #include @@ -9,71 +9,71 @@ #include "lpcnet_private.h" -float compute_pitchdnn( +float oaci_compute_pitchdnn( PitchDNNState *st, const float *if_features, const float *xcorr_features, - int arch - ) -{ - float if1_out[DENSE_IF_UPSAMPLER_1_OUT_SIZE]; - float downsampler_in[NB_XCORR_FEATURES + DENSE_IF_UPSAMPLER_2_OUT_SIZE]; - float downsampler_out[DENSE_DOWNSAMPLER_OUT_SIZE]; - float conv1_tmp1[(NB_XCORR_FEATURES + 2)*8] = {0}; - float conv1_tmp2[(NB_XCORR_FEATURES + 2)*8] = {0}; - float output[DENSE_FINAL_UPSAMPLER_OUT_SIZE]; - int i; - int pos=0; - float maxval=-1; - float sum=0; - float count=0; - PitchDNN *model = &st->model; - /* IF */ - compute_generic_dense(&model->dense_if_upsampler_1, if1_out, if_features, ACTIVATION_TANH, arch); - compute_generic_dense(&model->dense_if_upsampler_2, &downsampler_in[NB_XCORR_FEATURES], if1_out, ACTIVATION_TANH, arch); - /* xcorr*/ - OPUS_COPY(&conv1_tmp1[1], xcorr_features, NB_XCORR_FEATURES); - compute_conv2d(&model->conv2d_1, &conv1_tmp2[1], st->xcorr_mem1, conv1_tmp1, NB_XCORR_FEATURES, NB_XCORR_FEATURES+2, ACTIVATION_TANH, arch); - compute_conv2d(&model->conv2d_2, downsampler_in, st->xcorr_mem2, conv1_tmp2, NB_XCORR_FEATURES, NB_XCORR_FEATURES, ACTIVATION_TANH, arch); + int arch) { + float if1_out[DENSE_IF_UPSAMPLER_1_OUT_SIZE]; + float downsampler_in[NB_XCORR_FEATURES + DENSE_IF_UPSAMPLER_2_OUT_SIZE]; + float downsampler_out[DENSE_DOWNSAMPLER_OUT_SIZE]; + float conv1_tmp1[(NB_XCORR_FEATURES + 2)*8] = {0}; + float conv1_tmp2[(NB_XCORR_FEATURES + 2)*8] = {0}; + float output[DENSE_FINAL_UPSAMPLER_OUT_SIZE]; + int i; + int pos = 0; + float maxval = -1; + float sum = 0; + float count = 0; + PitchDNN *model = &st->model; + /* IF */ + oaci_compute_generic_dense(&model->dense_if_upsampler_1, if1_out, if_features, ACTIVATION_TANH, arch); + oaci_compute_generic_dense(&model->dense_if_upsampler_2, &downsampler_in[NB_XCORR_FEATURES], if1_out, ACTIVATION_TANH, + arch); + /* xcorr*/ + OAC_COPY(&conv1_tmp1[1], xcorr_features, NB_XCORR_FEATURES); + oaci_compute_conv2d(&model->conv2d_1, &conv1_tmp2[1], st->xcorr_mem1, conv1_tmp1, NB_XCORR_FEATURES, + NB_XCORR_FEATURES + 2, ACTIVATION_TANH, arch); + oaci_compute_conv2d(&model->conv2d_2, downsampler_in, st->xcorr_mem2, conv1_tmp2, NB_XCORR_FEATURES, NB_XCORR_FEATURES, + ACTIVATION_TANH, arch); - compute_generic_dense(&model->dense_downsampler, downsampler_out, downsampler_in, ACTIVATION_TANH, arch); - compute_generic_gru(&model->gru_1_input, &model->gru_1_recurrent, st->gru_state, downsampler_out, arch); - compute_generic_dense(&model->dense_final_upsampler, output, st->gru_state, ACTIVATION_LINEAR, arch); - for (i=0;i<180;i++) { - if (output[i] > maxval) { - pos = i; - maxval = output[i]; + oaci_compute_generic_dense(&model->dense_downsampler, downsampler_out, downsampler_in, ACTIVATION_TANH, arch); + oaci_compute_generic_gru(&model->gru_1_input, &model->gru_1_recurrent, st->gru_state, downsampler_out, arch); + oaci_compute_generic_dense(&model->dense_final_upsampler, output, st->gru_state, ACTIVATION_LINEAR, arch); + for (i = 0; i < 180; i++) { + if (output[i] > maxval) { + pos = i; + maxval = output[i]; + } } - } - for (i=IMAX(0, pos-2); i<=IMIN(179, pos+2); i++) { - float p = exp(output[i]); - sum += p*i; - count += p; - } - /*printf("%d %f\n", pos, sum/count);*/ - return (1.f/60.f)*(sum/count) - 1.5; - /*return 256.f/pow(2.f, (1.f/60.f)*i);*/ + for (i = IMAX(0, pos - 2); i <= IMIN(179, pos + 2); i++) { + float p = exp(output[i]); + sum += p*i; + count += p; + } + /*printf("%d %f\n", pos, sum/count);*/ + return (1.f/60.f)*(sum/count) - 1.5; + /*return 256.f/pow(2.f, (1.f/60.f)*i);*/ } -void pitchdnn_init(PitchDNNState *st) -{ - int ret; - OPUS_CLEAR(st, 1); +void oaci_pitchdnn_init(PitchDNNState *st) { + int ret; + OAC_CLEAR(st, 1); #ifndef USE_WEIGHTS_FILE - ret = init_pitchdnn(&st->model, pitchdnn_arrays); + ret = oaci_init_pitchdnn(&st->model, oaci_pitchdnn_arrays); #else - ret = 0; + ret = 0; #endif - celt_assert(ret == 0); + celt_assert(ret == 0); } -int pitchdnn_load_model(PitchDNNState *st, const void *data, int len) { - WeightArray *list; - int ret; - parse_weights(&list, data, len); - ret = init_pitchdnn(&st->model, list); - opus_free(list); - if (ret == 0) return 0; - else return -1; +int oaci_pitchdnn_load_model(PitchDNNState *st, const void *data, int len) { + WeightArray *list; + int ret; + oaci_parse_weights(&list, data, len); + ret = oaci_init_pitchdnn(&st->model, list); + oac_free(list); + if (ret == 0) return 0; + else return -1; } diff --git a/dnn/pitchdnn.h b/dnn/pitchdnn.h index 25fa3a4b0..172089916 100644 --- a/dnn/pitchdnn.h +++ b/dnn/pitchdnn.h @@ -9,26 +9,25 @@ typedef struct PitchDNN PitchDNN; #define PITCH_MIN_PERIOD 32 #define PITCH_MAX_PERIOD 256 -#define NB_XCORR_FEATURES (PITCH_MAX_PERIOD-PITCH_MIN_PERIOD) +#define NB_XCORR_FEATURES (PITCH_MAX_PERIOD - PITCH_MIN_PERIOD) typedef struct { - PitchDNN model; - float gru_state[GRU_1_STATE_SIZE]; - float xcorr_mem1[(NB_XCORR_FEATURES + 2)*2]; - float xcorr_mem2[(NB_XCORR_FEATURES + 2)*2*8]; - float xcorr_mem3[(NB_XCORR_FEATURES + 2)*2*8]; + PitchDNN model; + float gru_state[GRU_1_STATE_SIZE]; + float xcorr_mem1[(NB_XCORR_FEATURES + 2)*2]; + float xcorr_mem2[(NB_XCORR_FEATURES + 2)*2*8]; + float xcorr_mem3[(NB_XCORR_FEATURES + 2)*2*8]; } PitchDNNState; -void pitchdnn_init(PitchDNNState *st); -int pitchdnn_load_model(PitchDNNState *st, const void *data, int len); +void oaci_pitchdnn_init(PitchDNNState *st); +int oaci_pitchdnn_load_model(PitchDNNState *st, const void *data, int len); -float compute_pitchdnn( +float oaci_compute_pitchdnn( PitchDNNState *st, const float *if_features, const float *xcorr_features, - int arch - ); + int arch); #endif diff --git a/dnn/rename_downloads.bat b/dnn/rename_downloads.bat new file mode 100644 index 000000000..e67896723 --- /dev/null +++ b/dnn/rename_downloads.bat @@ -0,0 +1,23 @@ +@echo off +setlocal + +echo changing files + +powershell -NoProfile -ExecutionPolicy Bypass -Command ^ + "$files = Get-ChildItem -Path 'dnn' -Recurse -Include '*_data.c', '*_data.h' | Where-Object { $_.Name -notmatch 'dump_data' }; " ^ + "foreach ($file in $files) { " ^ + " (Get-Content $file.FullName) | ForEach-Object { " ^ + " $_ -creplace 'OPUS', 'OAC' " ^ + " -creplace 'Opus', 'Oac' " ^ + " -creplace 'opus_', 'oac_' " ^ + " -creplace 'opus', 'oac' " ^ + " -creplace 'linear_init', 'oaci_linear_init' " ^ + " -creplace '^const WeightArray ', 'const WeightArray oaci_' " ^ + " -creplace '^int init_', 'int oaci_init_' " ^ + " -creplace 'oac_uint8 dred_', 'oac_uint8 oaci_dred_' " ^ + " -creplace 'conv2d_init', 'oaci_conv2d_init' " ^ + " } | Set-Content -Path $file.FullName " ^ + "}" + +echo Done. +pause diff --git a/dnn/rename_downloads.sh b/dnn/rename_downloads.sh new file mode 100755 index 000000000..c543ff177 --- /dev/null +++ b/dnn/rename_downloads.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +echo changing files +for i in `find dnn | grep "_data\.[ch]" | grep -v dump_data` +do + cat $i | sed -e 's/OPUS/OAC/g' -e 's/Opus/Oac/g' -e 's/opus_/oac_/g' -e 's/opus/oac/g' -e 's/linear_init/oaci_linear_init/' -e 's/^const WeightArray /const WeightArray oaci_/' -e 's/^int init_/int oaci_init_/' -e 's/oac_uint8 dred_/oac_uint8 oaci_dred_/' -e 's/conv2d_init/oaci_conv2d_init/' > tmp.c + cp tmp.c $i; rm tmp.c +done diff --git a/dnn/tansig_table.h b/dnn/tansig_table.h index ebec7e3a9..39eb10705 100644 --- a/dnn/tansig_table.h +++ b/dnn/tansig_table.h @@ -4,47 +4,47 @@ #define TANSIG_TABLE_H static const float tansig_table[201] = { -0.000000f, 0.039979f, 0.079830f, 0.119427f, 0.158649f, -0.197375f, 0.235496f, 0.272905f, 0.309507f, 0.345214f, -0.379949f, 0.413644f, 0.446244f, 0.477700f, 0.507977f, -0.537050f, 0.564900f, 0.591519f, 0.616909f, 0.641077f, -0.664037f, 0.685809f, 0.706419f, 0.725897f, 0.744277f, -0.761594f, 0.777888f, 0.793199f, 0.807569f, 0.821040f, -0.833655f, 0.845456f, 0.856485f, 0.866784f, 0.876393f, -0.885352f, 0.893698f, 0.901468f, 0.908698f, 0.915420f, -0.921669f, 0.927473f, 0.932862f, 0.937863f, 0.942503f, -0.946806f, 0.950795f, 0.954492f, 0.957917f, 0.961090f, -0.964028f, 0.966747f, 0.969265f, 0.971594f, 0.973749f, -0.975743f, 0.977587f, 0.979293f, 0.980869f, 0.982327f, -0.983675f, 0.984921f, 0.986072f, 0.987136f, 0.988119f, -0.989027f, 0.989867f, 0.990642f, 0.991359f, 0.992020f, -0.992631f, 0.993196f, 0.993718f, 0.994199f, 0.994644f, -0.995055f, 0.995434f, 0.995784f, 0.996108f, 0.996407f, -0.996682f, 0.996937f, 0.997172f, 0.997389f, 0.997590f, -0.997775f, 0.997946f, 0.998104f, 0.998249f, 0.998384f, -0.998508f, 0.998623f, 0.998728f, 0.998826f, 0.998916f, -0.999000f, 0.999076f, 0.999147f, 0.999213f, 0.999273f, -0.999329f, 0.999381f, 0.999428f, 0.999472f, 0.999513f, -0.999550f, 0.999585f, 0.999617f, 0.999646f, 0.999673f, -0.999699f, 0.999722f, 0.999743f, 0.999763f, 0.999781f, -0.999798f, 0.999813f, 0.999828f, 0.999841f, 0.999853f, -0.999865f, 0.999875f, 0.999885f, 0.999893f, 0.999902f, -0.999909f, 0.999916f, 0.999923f, 0.999929f, 0.999934f, -0.999939f, 0.999944f, 0.999948f, 0.999952f, 0.999956f, -0.999959f, 0.999962f, 0.999965f, 0.999968f, 0.999970f, -0.999973f, 0.999975f, 0.999977f, 0.999978f, 0.999980f, -0.999982f, 0.999983f, 0.999984f, 0.999986f, 0.999987f, -0.999988f, 0.999989f, 0.999990f, 0.999990f, 0.999991f, -0.999992f, 0.999992f, 0.999993f, 0.999994f, 0.999994f, -0.999994f, 0.999995f, 0.999995f, 0.999996f, 0.999996f, -0.999996f, 0.999997f, 0.999997f, 0.999997f, 0.999997f, -0.999997f, 0.999998f, 0.999998f, 0.999998f, 0.999998f, -0.999998f, 0.999998f, 0.999999f, 0.999999f, 0.999999f, -0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, -0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, -1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, -1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, -1.000000f, + 0.000000f, 0.039979f, 0.079830f, 0.119427f, 0.158649f, + 0.197375f, 0.235496f, 0.272905f, 0.309507f, 0.345214f, + 0.379949f, 0.413644f, 0.446244f, 0.477700f, 0.507977f, + 0.537050f, 0.564900f, 0.591519f, 0.616909f, 0.641077f, + 0.664037f, 0.685809f, 0.706419f, 0.725897f, 0.744277f, + 0.761594f, 0.777888f, 0.793199f, 0.807569f, 0.821040f, + 0.833655f, 0.845456f, 0.856485f, 0.866784f, 0.876393f, + 0.885352f, 0.893698f, 0.901468f, 0.908698f, 0.915420f, + 0.921669f, 0.927473f, 0.932862f, 0.937863f, 0.942503f, + 0.946806f, 0.950795f, 0.954492f, 0.957917f, 0.961090f, + 0.964028f, 0.966747f, 0.969265f, 0.971594f, 0.973749f, + 0.975743f, 0.977587f, 0.979293f, 0.980869f, 0.982327f, + 0.983675f, 0.984921f, 0.986072f, 0.987136f, 0.988119f, + 0.989027f, 0.989867f, 0.990642f, 0.991359f, 0.992020f, + 0.992631f, 0.993196f, 0.993718f, 0.994199f, 0.994644f, + 0.995055f, 0.995434f, 0.995784f, 0.996108f, 0.996407f, + 0.996682f, 0.996937f, 0.997172f, 0.997389f, 0.997590f, + 0.997775f, 0.997946f, 0.998104f, 0.998249f, 0.998384f, + 0.998508f, 0.998623f, 0.998728f, 0.998826f, 0.998916f, + 0.999000f, 0.999076f, 0.999147f, 0.999213f, 0.999273f, + 0.999329f, 0.999381f, 0.999428f, 0.999472f, 0.999513f, + 0.999550f, 0.999585f, 0.999617f, 0.999646f, 0.999673f, + 0.999699f, 0.999722f, 0.999743f, 0.999763f, 0.999781f, + 0.999798f, 0.999813f, 0.999828f, 0.999841f, 0.999853f, + 0.999865f, 0.999875f, 0.999885f, 0.999893f, 0.999902f, + 0.999909f, 0.999916f, 0.999923f, 0.999929f, 0.999934f, + 0.999939f, 0.999944f, 0.999948f, 0.999952f, 0.999956f, + 0.999959f, 0.999962f, 0.999965f, 0.999968f, 0.999970f, + 0.999973f, 0.999975f, 0.999977f, 0.999978f, 0.999980f, + 0.999982f, 0.999983f, 0.999984f, 0.999986f, 0.999987f, + 0.999988f, 0.999989f, 0.999990f, 0.999990f, 0.999991f, + 0.999992f, 0.999992f, 0.999993f, 0.999994f, 0.999994f, + 0.999994f, 0.999995f, 0.999995f, 0.999996f, 0.999996f, + 0.999996f, 0.999997f, 0.999997f, 0.999997f, 0.999997f, + 0.999997f, 0.999998f, 0.999998f, 0.999998f, 0.999998f, + 0.999998f, 0.999998f, 0.999999f, 0.999999f, 0.999999f, + 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, + 0.999999f, 0.999999f, 0.999999f, 0.999999f, 0.999999f, + 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, + 1.000000f, 1.000000f, 1.000000f, 1.000000f, 1.000000f, + 1.000000f, }; #endif /*TANSIG_TABLE_H*/ diff --git a/dnn/test_vec.c b/dnn/test_vec.c index d14d2502a..1a56f76c5 100644 --- a/dnn/test_vec.c +++ b/dnn/test_vec.c @@ -1,6 +1,6 @@ #include #include -#include "opus_types.h" +#include "oac_types.h" #include "arch.h" #include "common.h" #include "tansig_table.h" @@ -12,34 +12,34 @@ #define lpcnet_exp2 lpcnet_exp2_fast #define tansig_approx tansig_approx_fast -#define sigmoid_approx sigmoid_approx_fast -#define softmax softmax_fast -#define vec_tanh vec_tanh_fast -#define vec_sigmoid vec_sigmoid_fast +#define oaci_sigmoid_approx sigmoid_approx_fast +#define oaci_softmax softmax_fast +#define oaci_vec_tanh vec_tanh_fast +#define oaci_vec_sigmoid vec_sigmoid_fast #define sgemv_accum16 sgemv_accum16_fast #define sparse_sgemv_accum16 sparse_sgemv_accum16_fast #ifdef __AVX__ -#include "vec_avx.h" -#ifdef __AVX2__ -const char simd[]="AVX2"; -#else -const char simd[]="AVX"; -#endif +# include "vec_avx.h" +# ifdef __AVX2__ +const char simd[] = "AVX2"; +# else +const char simd[] = "AVX"; +# endif #elif __ARM_NEON__ -#include "vec_neon.h" -const char simd[]="NEON"; +# include "vec_neon.h" +const char simd[] = "NEON"; #else -const char simd[]="none"; +const char simd[] = "none"; #endif #undef lpcnet_exp2 #undef tansig_approx -#undef sigmoid_approx -#undef softmax -#undef vec_tanh -#undef vec_sigmoid +#undef oaci_sigmoid_approx +#undef oaci_softmax +#undef oaci_vec_tanh +#undef oaci_vec_sigmoid #undef sgemv_accum16 #undef sparse_sgemv_accum16 #include "vec.h" @@ -56,30 +56,30 @@ int test_sgemv_accum16() { int i; printf("sgemv_accum16.....................: "); - for(i=0; i #include #include "fec_packets.h" -int get_fec_frame(const char * const filename, float *features, int packet_index, int subframe_index) -{ +int get_fec_frame(const char * const filename, float *features, int packet_index, int subframe_index) { int16_t version; int16_t header_size; @@ -54,14 +53,13 @@ int get_fec_frame(const char * const filename, float *features, int packet_index if (fread(&num_features, sizeof(num_features), 1, fid) != 1) goto error; /* check if indices are valid */ - if (packet_index >= num_packets || subframe_index >= subframes_per_packet) - { + if (packet_index >= num_packets || subframe_index >= subframes_per_packet) { fprintf(stderr, "get_fec_frame: index out of bounds\n"); goto error; } /* calculate offset in file (+ 2 is for rate) */ - offset = header_size + packet_index * packet_size + 2 + subframe_index * subframe_size; + offset = header_size + packet_index*packet_size + 2 + subframe_index*subframe_size; fseek(fid, offset, SEEK_SET); /* read features */ @@ -75,8 +73,7 @@ int get_fec_frame(const char * const filename, float *features, int packet_index return 1; } -int get_fec_rate(const char * const filename, int packet_index) -{ +int get_fec_rate(const char * const filename, int packet_index) { int16_t version; int16_t header_size; int16_t num_packets; @@ -99,14 +96,13 @@ int get_fec_rate(const char * const filename, int packet_index) if (fread(&num_features, sizeof(num_features), 1, fid) != 1) goto error; /* check if indices are valid */ - if (packet_index >= num_packets) - { + if (packet_index >= num_packets) { fprintf(stderr, "get_fec_rate: index out of bounds\n"); goto error; } /* calculate offset in file (+ 2 is for rate) */ - offset = header_size + packet_index * packet_size; + offset = header_size + packet_index*packet_size; fseek(fid, offset, SEEK_SET); /* read rate */ @@ -121,18 +117,15 @@ int get_fec_rate(const char * const filename, int packet_index) } #if 0 -int main() -{ +int main() { float features[20]; int i; - if (get_fec_frame("../test.fec", &features[0], 0, 127)) - { + if (get_fec_frame("../test.fec", &features[0], 0, 127)) { return 1; } - for (i = 0; i < 20; i ++) - { + for (i = 0; i < 20; i++) { printf("%d %f\n", i, features[i]); } diff --git a/dnn/torch/rdovae/packets/fec_packets.h b/dnn/torch/rdovae/packets/fec_packets.h index 35d355428..a268c6c3c 100644 --- a/dnn/torch/rdovae/packets/fec_packets.h +++ b/dnn/torch/rdovae/packets/fec_packets.h @@ -23,7 +23,7 @@ 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. -*/ + */ #ifndef _FEC_PACKETS_H #define _FEC_PACKETS_H diff --git a/dnn/torch/weight-exchange/wexchange/c_export/common.py b/dnn/torch/weight-exchange/wexchange/c_export/common.py index 5801c7e8a..b314a3507 100644 --- a/dnn/torch/weight-exchange/wexchange/c_export/common.py +++ b/dnn/torch/weight-exchange/wexchange/c_export/common.py @@ -40,10 +40,10 @@ def print_vector(writer, vector, name, dtype='float', reshape_8x4=False, static= dtype_suffix = { 'float' : 'float', - 'opus_uint8' : 'uint8', - 'opus_int8' : 'int8', - 'opus_uint16' : 'uint16', - 'opus_int16' : 'int16', + 'oac_uint8' : 'uint8', + 'oac_int8' : 'int8', + 'oac_uint16' : 'uint16', + 'oac_int16' : 'int16', 'int' : 'int', 'qweight': 'qweight' } @@ -164,7 +164,7 @@ def print_sparse_weight(writer, A, name, scale=1/128, have_diag=True, quantize=F W = np.concatenate([W, vblock]) idx[pos] = nb_nonzero - if quantize: print_vector(writer, W, name + '_int8', reshape_8x4=False, dtype='opus_int8') + if quantize: print_vector(writer, W, name + '_int8', reshape_8x4=False, dtype='oac_int8') print_vector(writer, W0, name + '_float', reshape_8x4=False, dtype='float', debug_float=quantize) print_vector(writer, idx, name + '_idx', reshape_8x4=False, dtype='int') @@ -237,7 +237,7 @@ def print_linear_layer(writer : CWriter, else: if quantize: weight_q = quantize_weight(weight, scale) - print_vector(writer, weight_q, name + "_weights_int8", dtype='opus_int8', reshape_8x4=True) + print_vector(writer, weight_q, name + "_weights_int8", dtype='oac_int8', reshape_8x4=True) print_vector(writer, weight, name + "_weights_float", dtype='float', reshape_8x4=False, debug_float=quantize) diff --git a/dnn/training_tf2/dataloader.py b/dnn/training_tf2/dataloader.py deleted file mode 100644 index ed441c1e3..000000000 --- a/dnn/training_tf2/dataloader.py +++ /dev/null @@ -1,49 +0,0 @@ -import numpy as np -from tensorflow.keras.utils import Sequence -from ulaw import lin2ulaw - -def lpc2rc(lpc): - #print("shape is = ", lpc.shape) - order = lpc.shape[-1] - rc = 0*lpc - for i in range(order, 0, -1): - rc[:,:,i-1] = lpc[:,:,-1] - ki = rc[:,:,i-1:i].repeat(i-1, axis=2) - lpc = (lpc[:,:,:-1] - ki*lpc[:,:,-2::-1])/(1-ki*ki) - return rc - -class LPCNetLoader(Sequence): - def __init__(self, data, features, periods, batch_size, e2e=False, lookahead=2): - self.batch_size = batch_size - self.nb_batches = np.minimum(np.minimum(data.shape[0], features.shape[0]), periods.shape[0])//self.batch_size - self.data = data[:self.nb_batches*self.batch_size, :] - self.features = features[:self.nb_batches*self.batch_size, :] - self.periods = periods[:self.nb_batches*self.batch_size, :] - self.e2e = e2e - self.lookahead = lookahead - self.on_epoch_end() - - def on_epoch_end(self): - self.indices = np.arange(self.nb_batches*self.batch_size) - np.random.shuffle(self.indices) - - def __getitem__(self, index): - data = self.data[self.indices[index*self.batch_size:(index+1)*self.batch_size], :, :] - in_data = data[: , :, :1] - out_data = data[: , :, 1:] - features = self.features[self.indices[index*self.batch_size:(index+1)*self.batch_size], :, :-16] - periods = self.periods[self.indices[index*self.batch_size:(index+1)*self.batch_size], :, :] - outputs = [out_data] - inputs = [in_data, features, periods] - if self.lookahead > 0: - lpc = self.features[self.indices[index*self.batch_size:(index+1)*self.batch_size], 4-self.lookahead:-self.lookahead, -16:] - else: - lpc = self.features[self.indices[index*self.batch_size:(index+1)*self.batch_size], 4:, -16:] - if self.e2e: - outputs.append(lpc2rc(lpc)) - else: - inputs.append(lpc) - return (inputs, outputs) - - def __len__(self): - return self.nb_batches diff --git a/dnn/training_tf2/decode_rdovae.py b/dnn/training_tf2/decode_rdovae.py deleted file mode 100644 index f9bf9bf62..000000000 --- a/dnn/training_tf2/decode_rdovae.py +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2021-2022 Amazon - Copyright (c) 2018-2019 Mozilla - - 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 FOUNDATION 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. -''' - -# Train an LPCNet model - -import argparse -#from plc_loader import PLCLoader - -parser = argparse.ArgumentParser(description='Train a PLC model') - -parser.add_argument('bits', metavar='', help='binary features file (int16)') -parser.add_argument('output', metavar='', help='output features') -parser.add_argument('--model', metavar='', default='rdovae', help='PLC model python definition (without .py)') -group1 = parser.add_mutually_exclusive_group() -group1.add_argument('--weights', metavar='', help='model weights') -parser.add_argument('--cond-size', metavar='', default=1024, type=int, help='number of units in conditioning network (default 1024)') -parser.add_argument('--batch-size', metavar='', default=1, type=int, help='batch size to use (default 128)') -parser.add_argument('--seq-length', metavar='', default=1000, type=int, help='sequence length to use (default 1000)') - - -args = parser.parse_args() - -import importlib -rdovae = importlib.import_module(args.model) - -import sys -import numpy as np -from tensorflow.keras.optimizers import Adam -from tensorflow.keras.callbacks import ModelCheckpoint, CSVLogger -import tensorflow.keras.backend as K -import h5py - -import tensorflow as tf -from rdovae import pvq_quantize -from rdovae import apply_dead_zone - -# Try reducing batch_size if you run out of memory on your GPU -batch_size = args.batch_size - -model, encoder, decoder, qembedding = rdovae.new_rdovae_model(nb_used_features=20, nb_bits=80, batch_size=batch_size, cond_size=args.cond_size) -model.load_weights(args.weights) - -lpc_order = 16 -nbits=80 - - -bits_file = args.bits -sequence_size = args.seq_length - -# u for unquantised, load 16 bit PCM samples and convert to mu-law - - -bits = np.memmap(bits_file + "-syms.f32", dtype='float32', mode='r') -nb_sequences = len(bits)//(40*sequence_size)//batch_size*batch_size -bits = bits[:nb_sequences*sequence_size*40] - -bits = np.reshape(bits, (nb_sequences, sequence_size//2, 20*4)) -print(bits.shape) - -lambda_val = 0.001 * np.ones((nb_sequences, sequence_size//2, 1)) -quant_id = np.round(3.8*np.log(lambda_val/.0002)).astype('int16') -quant_id = quant_id[:,:,0] -quant_embed = qembedding(quant_id) -quant_scale = tf.math.softplus(quant_embed[:,:,:nbits]) -dead_zone = tf.math.softplus(quant_embed[:, :, nbits : 2 * nbits]) - -bits = bits*quant_scale -bits = np.round(apply_dead_zone([bits, dead_zone]).numpy()) -bits = bits/quant_scale - - -state = np.memmap(bits_file + "-state.f32", dtype='float32', mode='r') - -state = np.reshape(state, (nb_sequences, sequence_size//2, 24)) -state = state[:,-1,:] -state = pvq_quantize(state, 82) -#state = state/(1e-15+tf.norm(state, axis=-1,keepdims=True)) - -print("shapes are:") -print(bits.shape) -print(state.shape) - -bits = bits[:,1::2,:] -features = decoder.predict([bits, state], batch_size=batch_size) - -features.astype('float32').tofile(args.output) diff --git a/dnn/training_tf2/diffembed.py b/dnn/training_tf2/diffembed.py deleted file mode 100644 index e04ae154b..000000000 --- a/dnn/training_tf2/diffembed.py +++ /dev/null @@ -1,49 +0,0 @@ -""" -Modification of Tensorflow's Embedding Layer: - 1. Not restricted to be the first layer of a model - 2. Differentiable (allows non-integer lookups) - - For non integer lookup, this layer linearly interpolates between the adjacent embeddings in the following way to preserver gradient flow - - E = (1 - frac(x))*embed(floor(x)) + frac(x)*embed(ceil(x)) -""" - -import tensorflow as tf -from tensorflow.keras.layers import Layer - -class diff_Embed(Layer): - """ - Parameters: - - units: int - Dimension of the Embedding - - dict_size: int - Number of Embeddings to lookup - - pcm_init: boolean - Initialized for the embedding matrix - """ - def __init__(self, units=128, dict_size = 256, pcm_init = True, initializer = None, **kwargs): - super(diff_Embed, self).__init__(**kwargs) - self.units = units - self.dict_size = dict_size - self.pcm_init = pcm_init - self.initializer = initializer - - def build(self, input_shape): - w_init = tf.random_normal_initializer() - if self.pcm_init: - w_init = self.initializer - self.w = tf.Variable(initial_value=w_init(shape=(self.dict_size, self.units),dtype='float32'),trainable=True) - - def call(self, inputs): - alpha = inputs - tf.math.floor(inputs) - alpha = tf.expand_dims(alpha,axis = -1) - alpha = tf.tile(alpha,[1,1,1,self.units]) - inputs = tf.cast(inputs,'int32') - M = (1 - alpha)*tf.gather(self.w,inputs) + alpha*tf.gather(self.w,tf.clip_by_value(inputs + 1, 0, 255)) - return M - - def get_config(self): - config = super(diff_Embed, self).get_config() - config.update({"units": self.units}) - config.update({"dict_size" : self.dict_size}) - config.update({"pcm_init" : self.pcm_init}) - config.update({"initializer" : self.initializer}) - return config \ No newline at end of file diff --git a/dnn/training_tf2/dump_lpcnet.py b/dnn/training_tf2/dump_lpcnet.py deleted file mode 100755 index 97ce0cedd..000000000 --- a/dnn/training_tf2/dump_lpcnet.py +++ /dev/null @@ -1,388 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2017-2018 Mozilla - - 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 FOUNDATION 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. -''' - -import os -import io -import lpcnet -import sys -import numpy as np -from tensorflow.keras.optimizers import Adam -from tensorflow.keras.layers import Layer, GRU, Dense, Conv1D, Embedding -from ulaw import ulaw2lin, lin2ulaw -from mdense import MDense -from diffembed import diff_Embed -from parameters import get_parameter -import h5py -import re -import argparse - - -# no cuda devices needed -os.environ['CUDA_VISIBLE_DEVICES'] = "" - -# Flag for dumping e2e (differentiable lpc) network weights -flag_e2e = False - - -max_rnn_neurons = 1 -max_conv_inputs = 1 -max_mdense_tmp = 1 - -def printVector(f, vector, name, dtype='float', dotp=False): - global array_list - if dotp: - vector = vector.reshape((vector.shape[0]//4, 4, vector.shape[1]//8, 8)) - vector = vector.transpose((2, 0, 3, 1)) - v = np.reshape(vector, (-1)); - #print('static const float ', name, '[', len(v), '] = \n', file=f) - if name not in array_list: - array_list.append(name) - f.write('#ifndef USE_WEIGHTS_FILE\n') - f.write('#define WEIGHTS_{}_DEFINED\n'.format(name)) - f.write('#define WEIGHTS_{}_TYPE WEIGHT_TYPE_{}\n'.format(name, dtype)) - f.write('static const {} {}[{}] = {{\n '.format(dtype, name, len(v))) - for i in range(0, len(v)): - f.write('{}'.format(v[i])) - if (i!=len(v)-1): - f.write(',') - else: - break; - if (i%8==7): - f.write("\n ") - else: - f.write(" ") - #print(v, file=f) - f.write('\n};\n') - f.write('#endif\n\n') - return; - -def printSparseVector(f, A, name, have_diag=True): - N = A.shape[0] - M = A.shape[1] - W = np.zeros((0,), dtype='int') - W0 = np.zeros((0,)) - if have_diag: - diag = np.concatenate([np.diag(A[:,:N]), np.diag(A[:,N:2*N]), np.diag(A[:,2*N:])]) - A[:,:N] = A[:,:N] - np.diag(np.diag(A[:,:N])) - A[:,N:2*N] = A[:,N:2*N] - np.diag(np.diag(A[:,N:2*N])) - A[:,2*N:] = A[:,2*N:] - np.diag(np.diag(A[:,2*N:])) - printVector(f, diag, name + '_diag') - AQ = np.minimum(127, np.maximum(-128, np.round(A*128))).astype('int') - idx = np.zeros((0,), dtype='int') - for i in range(M//8): - pos = idx.shape[0] - idx = np.append(idx, -1) - nb_nonzero = 0 - for j in range(N//4): - block = A[j*4:(j+1)*4, i*8:(i+1)*8] - qblock = AQ[j*4:(j+1)*4, i*8:(i+1)*8] - if np.sum(np.abs(block)) > 1e-10: - nb_nonzero = nb_nonzero + 1 - idx = np.append(idx, j*4) - vblock = qblock.transpose((1,0)).reshape((-1,)) - W0 = np.concatenate([W0, block.reshape((-1,))]) - W = np.concatenate([W, vblock]) - idx[pos] = nb_nonzero - f.write('#ifdef DOT_PROD\n') - printVector(f, W, name, dtype='qweight') - f.write('#else /*DOT_PROD*/\n') - printVector(f, W0, name, dtype='qweight') - f.write('#endif /*DOT_PROD*/\n') - #idx = np.tile(np.concatenate([np.array([N]), np.arange(N)]), 3*N//16) - printVector(f, idx, name + '_idx', dtype='int') - return AQ - -def dump_layer_ignore(self, f, hf): - print("ignoring layer " + self.name + " of type " + self.__class__.__name__) - return False -Layer.dump_layer = dump_layer_ignore - -def dump_sparse_gru(self, f, hf): - global max_rnn_neurons - name = 'sparse_' + self.name - print("printing layer " + name + " of type sparse " + self.__class__.__name__) - weights = self.get_weights() - qweights = printSparseVector(f, weights[1], name + '_recurrent_weights') - printVector(f, weights[-1], name + '_bias') - subias = weights[-1].copy() - subias[1,:] = subias[1,:] - np.sum(qweights*(1./128),axis=0) - printVector(f, subias, name + '_subias') - if hasattr(self, 'activation'): - activation = self.activation.__name__.upper() - else: - activation = 'TANH' - if hasattr(self, 'reset_after') and not self.reset_after: - reset_after = 0 - else: - reset_after = 1 - neurons = weights[0].shape[1]//3 - max_rnn_neurons = max(max_rnn_neurons, neurons) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - model_struct.write(' SparseGRULayer {};\n'.format(name)); - model_init.write(' if (sparse_gru_init(&model->{}, arrays, "{}_bias", "{}_subias", "{}_recurrent_weights_diag", "{}_recurrent_weights", "{}_recurrent_weights_idx", {}, ACTIVATION_{}, {})) return 1;\n' - .format(name, name, name, name, name, name, weights[0].shape[1]//3, activation, reset_after)) - return True - -def dump_grub(self, f, hf, gru_a_size): - global max_rnn_neurons - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - qweight = printSparseVector(f, weights[0][:gru_a_size, :], name + '_weights', have_diag=False) - - f.write('#ifdef DOT_PROD\n') - qweight2 = np.clip(np.round(128.*weights[1]).astype('int'), -128, 127) - printVector(f, qweight2, name + '_recurrent_weights', dotp=True, dtype='qweight') - f.write('#else /*DOT_PROD*/\n') - printVector(f, weights[1], name + '_recurrent_weights') - f.write('#endif /*DOT_PROD*/\n') - - printVector(f, weights[-1], name + '_bias') - subias = weights[-1].copy() - subias[0,:] = subias[0,:] - np.sum(qweight*(1./128.),axis=0) - subias[1,:] = subias[1,:] - np.sum(qweight2*(1./128.),axis=0) - printVector(f, subias, name + '_subias') - if hasattr(self, 'activation'): - activation = self.activation.__name__.upper() - else: - activation = 'TANH' - if hasattr(self, 'reset_after') and not self.reset_after: - reset_after = 0 - else: - reset_after = 1 - neurons = weights[0].shape[1]//3 - max_rnn_neurons = max(max_rnn_neurons, neurons) - model_struct.write(' GRULayer {};\n'.format(name)); - model_init.write(' if (gru_init(&model->{}, arrays, "{}_bias", "{}_subias", "{}_weights", "{}_weights_idx", "{}_recurrent_weights", {}, {}, ACTIVATION_{}, {})) return 1;\n' - .format(name, name, name, name, name, name, gru_a_size, weights[0].shape[1]//3, activation, reset_after)) - return True - -def dump_gru_layer_dummy(self, f, hf): - name = self.name - weights = self.get_weights() - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - return True; - -GRU.dump_layer = dump_gru_layer_dummy - -def dump_dense_layer_impl(name, weights, bias, activation, f, hf): - printVector(f, weights, name + '_weights') - printVector(f, bias, name + '_bias') - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights.shape[1])) - model_struct.write(' DenseLayer {};\n'.format(name)); - model_init.write(' if (dense_init(&model->{}, arrays, "{}_bias", "{}_weights", {}, {}, ACTIVATION_{})) return 1;\n' - .format(name, name, name, weights.shape[0], weights.shape[1], activation)) - -def dump_dense_layer(self, f, hf): - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - activation = self.activation.__name__.upper() - dump_dense_layer_impl(name, weights[0], weights[1], activation, f, hf) - return False - -Dense.dump_layer = dump_dense_layer - -def dump_mdense_layer(self, f, hf): - global max_mdense_tmp - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - printVector(f, np.transpose(weights[0], (0, 2, 1)), name + '_weights') - printVector(f, np.transpose(weights[1], (1, 0)), name + '_bias') - printVector(f, np.transpose(weights[2], (1, 0)), name + '_factor') - activation = self.activation.__name__.upper() - max_mdense_tmp = max(max_mdense_tmp, weights[0].shape[0]*weights[0].shape[2]) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[0])) - model_struct.write(' MDenseLayer {};\n'.format(name)); - model_init.write(' if (mdense_init(&model->{}, arrays, "{}_bias", "{}_weights", "{}_factor", {}, {}, {}, ACTIVATION_{})) return 1;\n' - .format(name, name, name, name, weights[0].shape[1], weights[0].shape[0], weights[0].shape[2], activation)) - return False -MDense.dump_layer = dump_mdense_layer - -def dump_conv1d_layer(self, f, hf): - global max_conv_inputs - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - printVector(f, weights[0], name + '_weights') - printVector(f, weights[-1], name + '_bias') - activation = self.activation.__name__.upper() - max_conv_inputs = max(max_conv_inputs, weights[0].shape[1]*weights[0].shape[0]) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[2])) - hf.write('#define {}_STATE_SIZE ({}*{})\n'.format(name.upper(), weights[0].shape[1], (weights[0].shape[0]-1))) - hf.write('#define {}_DELAY {}\n'.format(name.upper(), (weights[0].shape[0]-1)//2)) - model_struct.write(' Conv1DLayer {};\n'.format(name)); - model_init.write(' if (conv1d_init(&model->{}, arrays, "{}_bias", "{}_weights", {}, {}, {}, ACTIVATION_{})) return 1;\n' - .format(name, name, name, weights[0].shape[1], weights[0].shape[0], weights[0].shape[2], activation)) - return True -Conv1D.dump_layer = dump_conv1d_layer - - -def dump_embedding_layer_impl(name, weights, f, hf): - printVector(f, weights, name + '_weights') - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights.shape[1])) - model_struct.write(' EmbeddingLayer {};\n'.format(name)); - model_init.write(' if (embedding_init(&model->{}, arrays, "{}_weights", {}, {})) return 1;\n' - .format(name, name, weights.shape[0], weights.shape[1])) - -def dump_embedding_layer(self, f, hf): - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights()[0] - dump_embedding_layer_impl(name, weights, f, hf) - return False -Embedding.dump_layer = dump_embedding_layer -diff_Embed.dump_layer = dump_embedding_layer - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument('model_file', type=str, help='model weight h5 file') - parser.add_argument('--nnet-header', type=str, help='name of c header file for dumped model', default='nnet_data.h') - parser.add_argument('--nnet-source', type=str, help='name of c source file for dumped model', default='nnet_data.c') - parser.add_argument('--lpc-gamma', type=float, help='LPC weighting factor. If not specified I will attempt to read it from the model file with 1 as default', default=None) - parser.add_argument('--lookahead', type=float, help='Features lookahead. If not specified I will attempt to read it from the model file with 2 as default', default=None) - - args = parser.parse_args() - - filename = args.model_file - with h5py.File(filename, "r") as f: - units = min(f['model_weights']['gru_a']['gru_a']['recurrent_kernel:0'].shape) - units2 = min(f['model_weights']['gru_b']['gru_b']['recurrent_kernel:0'].shape) - cond_size = min(f['model_weights']['feature_dense1']['feature_dense1']['kernel:0'].shape) - e2e = 'rc2lpc' in f['model_weights'] - - model, _, _ = lpcnet.new_lpcnet_model(rnn_units1=units, rnn_units2=units2, flag_e2e = e2e, cond_size=cond_size) - model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy']) - #model.summary() - - model.load_weights(filename, by_name=True) - - cfile = args.nnet_source - hfile = args.nnet_header - - f = open(cfile, 'w') - hf = open(hfile, 'w') - model_struct = io.StringIO() - model_init = io.StringIO() - model_struct.write('typedef struct {\n') - model_init.write('#ifndef DUMP_BINARY_WEIGHTS\n') - model_init.write('int init_lpcnet_model(LPCNetModel *model, const WeightArray *arrays) {\n') - array_list = [] - - f.write('/*This file is automatically generated from a Keras model*/\n') - f.write('/*based on model {}*/\n\n'.format(sys.argv[1])) - f.write('#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif\n\n#include "nnet.h"\n#include "{}"\n\n'.format(hfile)) - - hf.write('/*This file is automatically generated from a Keras model*/\n\n') - hf.write('#ifndef RNN_DATA_H\n#define RNN_DATA_H\n\n#include "nnet.h"\n\n') - - if e2e: - hf.write('/* This is an end-to-end model */\n') - hf.write('#define END2END\n\n') - else: - hf.write('/* This is *not* an end-to-end model */\n') - hf.write('/* #define END2END */\n\n') - - # LPC weighting factor - if type(args.lpc_gamma) == type(None): - lpc_gamma = get_parameter(model, 'lpc_gamma', 1) - else: - lpc_gamma = args.lpc_gamma - - hf.write('/* LPC weighting factor */\n') - hf.write('#define LPC_GAMMA ' + str(lpc_gamma) +'f\n\n') - - # look-ahead - if type(args.lookahead) == type(None): - lookahead = get_parameter(model, 'lookahead', 2) - else: - lookahead = args.lookahead - - hf.write('/* Features look-ahead */\n') - hf.write('#define FEATURES_DELAY ' + str(lookahead) +'\n\n') - - embed_size = lpcnet.embed_size - - E = model.get_layer('embed_sig').get_weights()[0] - W = model.get_layer('gru_a').get_weights()[0][:embed_size,:] - dump_embedding_layer_impl('gru_a_embed_sig', np.dot(E, W), f, hf) - W = model.get_layer('gru_a').get_weights()[0][embed_size:2*embed_size,:] - dump_embedding_layer_impl('gru_a_embed_pred', np.dot(E, W), f, hf) - W = model.get_layer('gru_a').get_weights()[0][2*embed_size:3*embed_size,:] - dump_embedding_layer_impl('gru_a_embed_exc', np.dot(E, W), f, hf) - W = model.get_layer('gru_a').get_weights()[0][3*embed_size:,:] - #FIXME: dump only half the biases - b = model.get_layer('gru_a').get_weights()[2] - dump_dense_layer_impl('gru_a_dense_feature', W, b[:len(b)//2], 'LINEAR', f, hf) - - W = model.get_layer('gru_b').get_weights()[0][model.rnn_units1:,:] - b = model.get_layer('gru_b').get_weights()[2] - # Set biases to zero because they'll be included in the GRU input part - # (we need regular and SU biases) - dump_dense_layer_impl('gru_b_dense_feature', W, 0*b[:len(b)//2], 'LINEAR', f, hf) - dump_grub(model.get_layer('gru_b'), f, hf, model.rnn_units1) - - layer_list = [] - for i, layer in enumerate(model.layers): - if layer.dump_layer(f, hf): - layer_list.append(layer.name) - - dump_sparse_gru(model.get_layer('gru_a'), f, hf) - - f.write('#ifndef USE_WEIGHTS_FILE\n') - f.write('const WeightArray lpcnet_arrays[] = {\n') - for name in array_list: - f.write('#ifdef WEIGHTS_{}_DEFINED\n'.format(name)) - f.write(' {{"{}", WEIGHTS_{}_TYPE, sizeof({}), {}}},\n'.format(name, name, name, name)) - f.write('#endif\n') - f.write(' {NULL, 0, 0, NULL}\n};\n') - f.write('#endif\n') - - model_init.write(' return 0;\n}\n') - model_init.write('#endif\n') - f.write(model_init.getvalue()) - - hf.write('#define MAX_RNN_NEURONS {}\n\n'.format(max_rnn_neurons)) - hf.write('#define MAX_CONV_INPUTS {}\n\n'.format(max_conv_inputs)) - hf.write('#define MAX_MDENSE_TMP {}\n\n'.format(max_mdense_tmp)) - - - hf.write('typedef struct {\n') - for i, name in enumerate(layer_list): - hf.write(' float {}_state[{}_STATE_SIZE];\n'.format(name, name.upper())) - hf.write('} NNetState;\n\n') - - model_struct.write('} LPCNetModel;\n\n') - hf.write(model_struct.getvalue()) - hf.write('int init_lpcnet_model(LPCNetModel *model, const WeightArray *arrays);\n\n') - hf.write('\n\n#endif\n') - - f.close() - hf.close() diff --git a/dnn/training_tf2/dump_plc.py b/dnn/training_tf2/dump_plc.py deleted file mode 100755 index a490ade1d..000000000 --- a/dnn/training_tf2/dump_plc.py +++ /dev/null @@ -1,296 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2021-2022 Amazon - Copyright (c) 2017-2018 Mozilla - - 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 FOUNDATION 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. -''' - -import lpcnet_plc -import io -import sys -import numpy as np -from tensorflow.keras.optimizers import Adam -from tensorflow.keras.layers import Layer, GRU, Dense, Conv1D, Embedding -import h5py -import re - -# Flag for dumping e2e (differentiable lpc) network weights -flag_e2e = False - -max_rnn_neurons = 1 -max_conv_inputs = 1 - -def printVector(f, vector, name, dtype='float', dotp=False): - global array_list - if dotp: - vector = vector.reshape((vector.shape[0]//4, 4, vector.shape[1]//8, 8)) - vector = vector.transpose((2, 0, 3, 1)) - v = np.reshape(vector, (-1)); - #print('static const float ', name, '[', len(v), '] = \n', file=f) - if name not in array_list: - array_list.append(name) - f.write('#ifndef USE_WEIGHTS_FILE\n') - f.write('#define WEIGHTS_{}_DEFINED\n'.format(name)) - f.write('#define WEIGHTS_{}_TYPE WEIGHT_TYPE_{}\n'.format(name, dtype)) - f.write('static const {} {}[{}] = {{\n '.format(dtype, name, len(v))) - for i in range(0, len(v)): - f.write('{}'.format(v[i])) - if (i!=len(v)-1): - f.write(',') - else: - break; - if (i%8==7): - f.write("\n ") - else: - f.write(" ") - #print(v, file=f) - f.write('\n};\n') - f.write('#endif\n\n') - return; - -def printSparseVector(f, A, name, have_diag=True): - N = A.shape[0] - M = A.shape[1] - W = np.zeros((0,), dtype='int') - W0 = np.zeros((0,)) - if have_diag: - diag = np.concatenate([np.diag(A[:,:N]), np.diag(A[:,N:2*N]), np.diag(A[:,2*N:])]) - A[:,:N] = A[:,:N] - np.diag(np.diag(A[:,:N])) - A[:,N:2*N] = A[:,N:2*N] - np.diag(np.diag(A[:,N:2*N])) - A[:,2*N:] = A[:,2*N:] - np.diag(np.diag(A[:,2*N:])) - printVector(f, diag, name + '_diag') - AQ = np.minimum(127, np.maximum(-128, np.round(A*128))).astype('int') - idx = np.zeros((0,), dtype='int') - for i in range(M//8): - pos = idx.shape[0] - idx = np.append(idx, -1) - nb_nonzero = 0 - for j in range(N//4): - block = A[j*4:(j+1)*4, i*8:(i+1)*8] - qblock = AQ[j*4:(j+1)*4, i*8:(i+1)*8] - if np.sum(np.abs(block)) > 1e-10: - nb_nonzero = nb_nonzero + 1 - idx = np.append(idx, j*4) - vblock = qblock.transpose((1,0)).reshape((-1,)) - W0 = np.concatenate([W0, block.reshape((-1,))]) - W = np.concatenate([W, vblock]) - idx[pos] = nb_nonzero - f.write('#ifdef DOT_PROD\n') - printVector(f, W, name, dtype='qweight') - f.write('#else /*DOT_PROD*/\n') - printVector(f, W0, name, dtype='qweight') - f.write('#endif /*DOT_PROD*/\n') - #idx = np.tile(np.concatenate([np.array([N]), np.arange(N)]), 3*N//16) - printVector(f, idx, name + '_idx', dtype='int') - return AQ - -def dump_layer_ignore(self, f, hf): - print("ignoring layer " + self.name + " of type " + self.__class__.__name__) - return False -Layer.dump_layer = dump_layer_ignore - -def dump_sparse_gru(self, f, hf): - global max_rnn_neurons - name = 'sparse_' + self.name - print("printing layer " + name + " of type sparse " + self.__class__.__name__) - weights = self.get_weights() - qweights = printSparseVector(f, weights[1], name + '_recurrent_weights') - printVector(f, weights[-1], name + '_bias') - subias = weights[-1].copy() - subias[1,:] = subias[1,:] - np.sum(qweights*(1./128),axis=0) - printVector(f, subias, name + '_subias') - if hasattr(self, 'activation'): - activation = self.activation.__name__.upper() - else: - activation = 'TANH' - if hasattr(self, 'reset_after') and not self.reset_after: - reset_after = 0 - else: - reset_after = 1 - neurons = weights[0].shape[1]//3 - max_rnn_neurons = max(max_rnn_neurons, neurons) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - model_struct.write(' SparseGRULayer {};\n'.format(name)); - model_init.write(' if (sparse_gru_init(&model->{}, arrays, "{}_bias", "{}_subias", "{}_recurrent_weights_diag", "{}_recurrent_weights", "{}_recurrent_weights_idx", {}, ACTIVATION_{}, {})) return 1;\n' - .format(name, name, name, name, name, name, weights[0].shape[1]//3, activation, reset_after)) - return True - -def dump_gru_layer(self, f, hf): - global max_rnn_neurons - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - qweight = printSparseVector(f, weights[0], name + '_weights', have_diag=False) - - f.write('#ifdef DOT_PROD\n') - qweight2 = np.clip(np.round(128.*weights[1]).astype('int'), -128, 127) - printVector(f, qweight2, name + '_recurrent_weights', dotp=True, dtype='qweight') - f.write('#else /*DOT_PROD*/\n') - printVector(f, weights[1], name + '_recurrent_weights') - f.write('#endif /*DOT_PROD*/\n') - - printVector(f, weights[-1], name + '_bias') - subias = weights[-1].copy() - subias[0,:] = subias[0,:] - np.sum(qweight*(1./128.),axis=0) - subias[1,:] = subias[1,:] - np.sum(qweight2*(1./128.),axis=0) - printVector(f, subias, name + '_subias') - if hasattr(self, 'activation'): - activation = self.activation.__name__.upper() - else: - activation = 'TANH' - if hasattr(self, 'reset_after') and not self.reset_after: - reset_after = 0 - else: - reset_after = 1 - neurons = weights[0].shape[1]//3 - max_rnn_neurons = max(max_rnn_neurons, neurons) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - model_struct.write(' GRULayer {};\n'.format(name)); - model_init.write(' if (gru_init(&model->{}, arrays, "{}_bias", "{}_subias", "{}_weights", "{}_weights_idx", "{}_recurrent_weights", {}, {}, ACTIVATION_{}, {})) return 1;\n' - .format(name, name, name, name, name, name, weights[0].shape[0], weights[0].shape[1]//3, activation, reset_after)) - return True -GRU.dump_layer = dump_gru_layer - -def dump_gru_layer_dummy(self, f, hf): - name = self.name - weights = self.get_weights() - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - return True; - -#GRU.dump_layer = dump_gru_layer_dummy - -def dump_dense_layer_impl(name, weights, bias, activation, f, hf): - printVector(f, weights, name + '_weights') - printVector(f, bias, name + '_bias') - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights.shape[1])) - model_struct.write(' DenseLayer {};\n'.format(name)); - model_init.write(' if (dense_init(&model->{}, arrays, "{}_bias", "{}_weights", {}, {}, ACTIVATION_{})) return 1;\n' - .format(name, name, name, weights.shape[0], weights.shape[1], activation)) - -def dump_dense_layer(self, f, hf): - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - activation = self.activation.__name__.upper() - dump_dense_layer_impl(name, weights[0], weights[1], activation, f, hf) - return False - -Dense.dump_layer = dump_dense_layer - -def dump_conv1d_layer(self, f, hf): - global max_conv_inputs - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - printVector(f, weights[0], name + '_weights') - printVector(f, weights[-1], name + '_bias') - activation = self.activation.__name__.upper() - max_conv_inputs = max(max_conv_inputs, weights[0].shape[1]*weights[0].shape[0]) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[2])) - hf.write('#define {}_STATE_SIZE ({}*{})\n'.format(name.upper(), weights[0].shape[1], (weights[0].shape[0]-1))) - hf.write('#define {}_DELAY {}\n'.format(name.upper(), (weights[0].shape[0]-1)//2)) - model_struct.write(' Conv1DLayer {};\n'.format(name)); - model_init.write(' if (conv1d_init(&model->{}, arrays, "{}_bias", "{}_weights", {}, {}, {}, ACTIVATION_{})) return 1;\n' - .format(name, name, name, weights[0].shape[1], weights[0].shape[0], weights[0].shape[2], activation)) - return True -Conv1D.dump_layer = dump_conv1d_layer - - - -filename = sys.argv[1] -with h5py.File(filename, "r") as f: - units = min(f['model_weights']['plc_gru1']['plc_gru1']['recurrent_kernel:0'].shape) - units2 = min(f['model_weights']['plc_gru2']['plc_gru2']['recurrent_kernel:0'].shape) - cond_size = f['model_weights']['plc_dense1']['plc_dense1']['kernel:0'].shape[1] - -model = lpcnet_plc.new_lpcnet_plc_model(rnn_units=units, cond_size=cond_size) -model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy']) -#model.summary() - -model.load_weights(filename, by_name=True) - -if len(sys.argv) > 2: - cfile = sys.argv[2]; - hfile = sys.argv[3]; -else: - cfile = 'plc_data.c' - hfile = 'plc_data.h' - - -f = open(cfile, 'w') -hf = open(hfile, 'w') -model_struct = io.StringIO() -model_init = io.StringIO() -model_struct.write('typedef struct {\n') -model_init.write('#ifndef DUMP_BINARY_WEIGHTS\n') -model_init.write('int init_plc_model(PLCModel *model, const WeightArray *arrays) {\n') -array_list = [] - - -f.write('/*This file is automatically generated from a Keras model*/\n') -f.write('/*based on model {}*/\n\n'.format(sys.argv[1])) -f.write('#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif\n\n#include "nnet.h"\n#include "{}"\n\n'.format(hfile)) - -hf.write('/*This file is automatically generated from a Keras model*/\n\n') -hf.write('#ifndef PLC_DATA_H\n#define PLC_DATA_H\n\n#include "nnet.h"\n\n') - -layer_list = [] -for i, layer in enumerate(model.layers): - if layer.dump_layer(f, hf): - layer_list.append(layer.name) - -#dump_sparse_gru(model.get_layer('gru_a'), f, hf) -f.write('#ifndef USE_WEIGHTS_FILE\n') -f.write('const WeightArray lpcnet_plc_arrays[] = {\n') -for name in array_list: - f.write('#ifdef WEIGHTS_{}_DEFINED\n'.format(name)) - f.write(' {{"{}", WEIGHTS_{}_TYPE, sizeof({}), {}}},\n'.format(name, name, name, name)) - f.write('#endif\n') -f.write(' {NULL, 0, 0, NULL}\n};\n') -f.write('#endif\n') - -model_init.write(' return 0;\n}\n') -model_init.write('#endif\n') -f.write(model_init.getvalue()) - - -hf.write('#define PLC_MAX_RNN_NEURONS {}\n\n'.format(max_rnn_neurons)) -#hf.write('#define PLC_MAX_CONV_INPUTS {}\n\n'.format(max_conv_inputs)) - -hf.write('typedef struct {\n') -for i, name in enumerate(layer_list): - hf.write(' float {}_state[{}_STATE_SIZE];\n'.format(name, name.upper())) -hf.write('} PLCNetState;\n\n') - -model_struct.write('} PLCModel;\n\n') -hf.write(model_struct.getvalue()) -hf.write('int init_plc_model(PLCModel *model, const WeightArray *arrays);\n\n') - -hf.write('\n\n#endif\n') - -f.close() -hf.close() diff --git a/dnn/training_tf2/dump_rdovae.py b/dnn/training_tf2/dump_rdovae.py deleted file mode 100644 index 1858c8a49..000000000 --- a/dnn/training_tf2/dump_rdovae.py +++ /dev/null @@ -1,306 +0,0 @@ -""" -/* Copyright (c) 2022 Amazon - Written by Jan Buethe */ -/* - 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. -*/ -""" - - -import argparse -from ftplib import parse150 -import os - -os.environ['CUDA_VISIBLE_DEVICES'] = "" - -parser = argparse.ArgumentParser() - -parser.add_argument('weights', metavar="", type=str, help='model weight file in hdf5 format') -parser.add_argument('--cond-size', type=int, help="conditioning size (default: 256)", default=256) -parser.add_argument('--latent-dim', type=int, help="dimension of latent space (default: 80)", default=80) -parser.add_argument('--quant-levels', type=int, help="number of quantization steps (default: 16)", default=16) - -args = parser.parse_args() - -# now import the heavy stuff -import tensorflow as tf -import numpy as np -from keraslayerdump import dump_conv1d_layer, dump_dense_layer, dump_gru_layer, printVector -from rdovae import new_rdovae_model - -def start_header(header_fid, header_name): - header_guard = os.path.basename(header_name)[:-2].upper() + "_H" - header_fid.write( -f""" -#ifndef {header_guard} -#define {header_guard} - -""" - ) - -def finish_header(header_fid): - header_fid.write( -""" -#endif - -""" - ) - -def start_source(source_fid, header_name, weight_file): - source_fid.write( -f""" -/* this source file was automatically generated from weight file {weight_file} */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "{header_name}" - -""" - ) - -def finish_source(source_fid): - pass - - -def dump_statistical_model(qembedding, f, fh): - w = qembedding.weights[0].numpy() - levels, dim = w.shape - N = dim // 6 - - print("dumping statistical model") - quant_scales = tf.math.softplus(w[:, : N]).numpy() - dead_zone = 0.05 * tf.math.softplus(w[:, N : 2 * N]).numpy() - r = tf.math.sigmoid(w[:, 5 * N : 6 * N]).numpy() - p0 = tf.math.sigmoid(w[:, 4 * N : 5 * N]).numpy() - p0 = 1 - r ** (0.5 + 0.5 * p0) - - quant_scales_q8 = np.round(quant_scales * 2**8).astype(np.uint16) - dead_zone_q10 = np.round(dead_zone * 2**10).astype(np.uint16) - r_q15 = np.round(r * 2**15).astype(np.uint16) - p0_q15 = np.round(p0 * 2**15).astype(np.uint16) - - printVector(f, quant_scales_q8, 'dred_quant_scales_q8', dtype='opus_uint16', static=False) - printVector(f, dead_zone_q10, 'dred_dead_zone_q10', dtype='opus_uint16', static=False) - printVector(f, r_q15, 'dred_r_q15', dtype='opus_uint16', static=False) - printVector(f, p0_q15, 'dred_p0_q15', dtype='opus_uint16', static=False) - - fh.write( -f""" -extern const opus_uint16 dred_quant_scales_q8[{levels * N}]; -extern const opus_uint16 dred_dead_zone_q10[{levels * N}]; -extern const opus_uint16 dred_r_q15[{levels * N}]; -extern const opus_uint16 dred_p0_q15[{levels * N}]; - -""" - ) - -if __name__ == "__main__": - - model, encoder, decoder, qembedding = new_rdovae_model(20, args.latent_dim, cond_size=args.cond_size, nb_quant=args.quant_levels) - model.load_weights(args.weights) - - - - - # encoder - encoder_dense_names = [ - 'enc_dense1', - 'enc_dense3', - 'enc_dense5', - 'enc_dense7', - 'enc_dense8', - 'gdense1', - 'gdense2' - ] - - encoder_gru_names = [ - 'enc_dense2', - 'enc_dense4', - 'enc_dense6' - ] - - encoder_conv1d_names = [ - 'bits_dense' - ] - - source_fid = open("dred_rdovae_enc_data.c", 'w') - header_fid = open("dred_rdovae_enc_data.h", 'w') - - start_header(header_fid, "dred_rdovae_enc_data.h") - start_source(source_fid, "dred_rdovae_enc_data.h", os.path.basename(args.weights)) - - header_fid.write( -f""" -#include "dred_rdovae_constants.h" - -#include "nnet.h" -""" - ) - - # dump GRUs - max_rnn_neurons_enc = max( - [ - dump_gru_layer(encoder.get_layer(name), source_fid, header_fid, dotp=True, sparse=True) - for name in encoder_gru_names - ] - ) - - # dump conv layers - max_conv_inputs = max( - [ - dump_conv1d_layer(encoder.get_layer(name), source_fid, header_fid) - for name in encoder_conv1d_names - ] - ) - - # dump Dense layers - for name in encoder_dense_names: - layer = encoder.get_layer(name) - dump_dense_layer(layer, source_fid, header_fid) - - # some global constants - header_fid.write( -f""" - -#define DRED_ENC_MAX_RNN_NEURONS {max_rnn_neurons_enc} - -#define DRED_ENC_MAX_CONV_INPUTS {max_conv_inputs} - -""" - ) - - finish_header(header_fid) - finish_source(source_fid) - - header_fid.close() - source_fid.close() - - # statistical model - source_fid = open("dred_rdovae_stats_data.c", 'w') - header_fid = open("dred_rdovae_stats_data.h", 'w') - - start_header(header_fid, "dred_rdovae_stats_data.h") - start_source(source_fid, "dred_rdovae_stats_data.h", os.path.basename(args.weights)) - - header_fid.write( -""" - -#include "opus_types.h" - -""" - ) - - dump_statistical_model(qembedding, source_fid, header_fid) - - finish_header(header_fid) - finish_source(source_fid) - - header_fid.close() - source_fid.close() - - # decoder - decoder_dense_names = [ - 'state1', - 'state2', - 'state3', - 'dec_dense1', - 'dec_dense3', - 'dec_dense5', - 'dec_dense7', - 'dec_dense8', - 'dec_final' - ] - - decoder_gru_names = [ - 'dec_dense2', - 'dec_dense4', - 'dec_dense6' - ] - - source_fid = open("dred_rdovae_dec_data.c", 'w') - header_fid = open("dred_rdovae_dec_data.h", 'w') - - start_header(header_fid, "dred_rdovae_dec_data.h") - start_source(source_fid, "dred_rdovae_dec_data.h", os.path.basename(args.weights)) - - header_fid.write( -f""" -#include "dred_rdovae_constants.h" - -#include "nnet.h" -""" - ) - - - # dump GRUs - max_rnn_neurons_dec = max( - [ - dump_gru_layer(decoder.get_layer(name), source_fid, header_fid, dotp=True, sparse=True) - for name in decoder_gru_names - ] - ) - - # dump Dense layers - for name in decoder_dense_names: - layer = decoder.get_layer(name) - dump_dense_layer(layer, source_fid, header_fid) - - # some global constants - header_fid.write( -f""" - -#define DRED_DEC_MAX_RNN_NEURONS {max_rnn_neurons_dec} - -""" - ) - - finish_header(header_fid) - finish_source(source_fid) - - header_fid.close() - source_fid.close() - - # common constants - header_fid = open("dred_rdovae_constants.h", 'w') - start_header(header_fid, "dred_rdovae_constants.h") - - header_fid.write( -f""" -#define DRED_NUM_FEATURES 20 - -#define DRED_LATENT_DIM {args.latent_dim} - -#define DRED_STATE_DIM {24} - -#define DRED_NUM_QUANTIZATION_LEVELS {qembedding.weights[0].shape[0]} - -#define DRED_MAX_RNN_NEURONS {max(max_rnn_neurons_enc, max_rnn_neurons_dec)} - -#define DRED_MAX_CONV_INPUTS {max_conv_inputs} -""" - ) - - finish_header(header_fid) \ No newline at end of file diff --git a/dnn/training_tf2/encode_rdovae.py b/dnn/training_tf2/encode_rdovae.py deleted file mode 100644 index f144fc48e..000000000 --- a/dnn/training_tf2/encode_rdovae.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2021-2022 Amazon - Copyright (c) 2018-2019 Mozilla - - 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 FOUNDATION 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. -''' - -# Train an LPCNet model - -import argparse -#from plc_loader import PLCLoader - -parser = argparse.ArgumentParser(description='Train a PLC model') - -parser.add_argument('features', metavar='', help='binary features file (float32)') -parser.add_argument('output', metavar='', help='trained model file (.h5)') -parser.add_argument('--model', metavar='', default='rdovae', help='PLC model python definition (without .py)') -group1 = parser.add_mutually_exclusive_group() -group1.add_argument('--weights', metavar='', help='model weights') -parser.add_argument('--cond-size', metavar='', default=1024, type=int, help='number of units in conditioning network (default 1024)') -parser.add_argument('--batch-size', metavar='', default=1, type=int, help='batch size to use (default 128)') -parser.add_argument('--seq-length', metavar='', default=1000, type=int, help='sequence length to use (default 1000)') - - -args = parser.parse_args() - -import importlib -rdovae = importlib.import_module(args.model) - -from rdovae import apply_dead_zone - -import sys -import numpy as np -from tensorflow.keras.optimizers import Adam -from tensorflow.keras.callbacks import ModelCheckpoint, CSVLogger -import tensorflow.keras.backend as K -import h5py - -import tensorflow as tf -from rdovae import pvq_quantize - -# Try reducing batch_size if you run out of memory on your GPU -batch_size = args.batch_size - -model, encoder, decoder, qembedding = rdovae.new_rdovae_model(nb_used_features=20, nb_bits=80, batch_size=batch_size, cond_size=args.cond_size) -model.load_weights(args.weights) - -lpc_order = 16 - -feature_file = args.features -nb_features = model.nb_used_features + lpc_order -nb_used_features = model.nb_used_features -sequence_size = args.seq_length - -# u for unquantised, load 16 bit PCM samples and convert to mu-law - - -features = np.memmap(feature_file, dtype='float32', mode='r') -nb_sequences = len(features)//(nb_features*sequence_size)//batch_size*batch_size -features = features[:nb_sequences*sequence_size*nb_features] - -features = np.reshape(features, (nb_sequences, sequence_size, nb_features)) -print(features.shape) -features = features[:, :, :nb_used_features] -#features = np.random.randn(73600, 1000, 17) - - -bits, gru_state_dec = encoder.predict([features], batch_size=batch_size) -(gru_state_dec).astype('float32').tofile(args.output + "-state.f32") - - -#dist = rdovae.feat_dist_loss(features, quant_out) -#rate = rdovae.sq1_rate_loss(features, model_bits) -#rate2 = rdovae.sq_rate_metric(features, model_bits) -#print(dist, rate, rate2) - -print("shapes are:") -print(bits.shape) -print(gru_state_dec.shape) - -features.astype('float32').tofile(args.output + "-input.f32") -#quant_out.astype('float32').tofile(args.output + "-enc_dec.f32") -nbits=80 -bits.astype('float32').tofile(args.output + "-syms.f32") - -lambda_val = 0.0002 * np.ones((nb_sequences, sequence_size//2, 1)) -quant_id = np.round(3.8*np.log(lambda_val/.0002)).astype('int16') -quant_id = quant_id[:,:,0] -quant_embed = qembedding(quant_id) -quant_scale = tf.math.softplus(quant_embed[:,:,:nbits]) -dead_zone = tf.math.softplus(quant_embed[:, :, nbits : 2 * nbits]) - -bits = bits*quant_scale -bits = np.round(apply_dead_zone([bits, dead_zone]).numpy()) -bits = bits/quant_scale - -gru_state_dec = pvq_quantize(gru_state_dec, 82) -#gru_state_dec = gru_state_dec/(1e-15+tf.norm(gru_state_dec, axis=-1,keepdims=True)) -gru_state_dec = gru_state_dec[:,-1,:] -dec_out = decoder([bits[:,1::2,:], gru_state_dec]) - -print(dec_out.shape) - -dec_out.numpy().astype('float32').tofile(args.output + "-quant_out.f32") diff --git a/dnn/training_tf2/fec_encoder.py b/dnn/training_tf2/fec_encoder.py deleted file mode 100644 index 15ef12b2c..000000000 --- a/dnn/training_tf2/fec_encoder.py +++ /dev/null @@ -1,256 +0,0 @@ -""" -/* Copyright (c) 2022 Amazon - Written by Jan Buethe and Jean-Marc Valin */ -/* - 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. -*/ -""" -import os -import subprocess -import argparse - - -import numpy as np -from scipy.io import wavfile -import tensorflow as tf - -from rdovae import new_rdovae_model, pvq_quantize, apply_dead_zone, sq_rate_metric -from fec_packets import write_fec_packets, read_fec_packets - - -debug = False - -if debug: - args = type('dummy', (object,), - { - 'input' : 'item1.wav', - 'weights' : 'testout/rdovae_alignment_fix_1024_120.h5', - 'enc_lambda' : 0.0007, - 'output' : "test_0007.fec", - 'cond_size' : 1024, - 'num_redundancy_frames' : 64, - 'extra_delay' : 0, - 'dump_data' : './dump_data' - })() - os.environ['CUDA_VISIBLE_DEVICES']="" -else: - parser = argparse.ArgumentParser(description='Encode redundancy for Opus neural FEC. Designed for use with voip application and 20ms frames') - - parser.add_argument('input', metavar='', help='audio input (.wav or .raw or .pcm as int16)') - parser.add_argument('weights', metavar='', help='trained model file (.h5)') -# parser.add_argument('enc_lambda', metavar='', type=float, help='lambda for controlling encoder rate') - parser.add_argument('output', type=str, help='output file (will be extended with .fec)') - - parser.add_argument('--dump-data', type=str, default='./dump_data', help='path to dump data executable (default ./dump_data)') - parser.add_argument('--cond-size', metavar='', default=1024, type=int, help='number of units in conditioning network (default 1024)') - parser.add_argument('--quant-levels', type=int, help="number of quantization steps (default: 40)", default=40) - parser.add_argument('--num-redundancy-frames', default=64, type=int, help='number of redundancy frames (20ms) per packet (default 64)') - parser.add_argument('--extra-delay', default=0, type=int, help="last features in packet are calculated with the decoder aligned samples, use this option to add extra delay (in samples at 16kHz)") - parser.add_argument('--lossfile', type=str, help='file containing loss trace (0 for frame received, 1 for lost)') - - parser.add_argument('--debug-output', action='store_true', help='if set, differently assembled features are written to disk') - - args = parser.parse_args() - -model, encoder, decoder, qembedding = new_rdovae_model(nb_used_features=20, nb_bits=80, batch_size=1, nb_quant=args.quant_levels, cond_size=args.cond_size) -model.load_weights(args.weights) - -lpc_order = 16 - -## prepare input signal -# SILK frame size is 20ms and LPCNet subframes are 10ms -subframe_size = 160 -frame_size = 2 * subframe_size - -# 91 samples delay to align with SILK decoded frames -silk_delay = 91 - -# prepend zeros to have enough history to produce the first package -zero_history = (args.num_redundancy_frames - 1) * frame_size - -# dump data has a (feature) delay of 10ms -dump_data_delay = 160 - -total_delay = silk_delay + zero_history + args.extra_delay - dump_data_delay - -# load signal -if args.input.endswith('.raw') or args.input.endswith('.pcm') or args.input.endswith('.sw'): - signal = np.fromfile(args.input, dtype='int16') - -elif args.input.endswith('.wav'): - fs, signal = wavfile.read(args.input) -else: - raise ValueError(f'unknown input signal format: {args.input}') - -# fill up last frame with zeros -padded_signal_length = len(signal) + total_delay -tail = padded_signal_length % frame_size -right_padding = (frame_size - tail) % frame_size - -signal = np.concatenate((np.zeros(total_delay, dtype=np.int16), signal, np.zeros(right_padding, dtype=np.int16))) - -padded_signal_file = os.path.splitext(args.input)[0] + '_padded.raw' -signal.tofile(padded_signal_file) - -# write signal and call dump_data to create features - -feature_file = os.path.splitext(args.input)[0] + '_features.f32' -command = f"{args.dump_data} -test {padded_signal_file} {feature_file}" -r = subprocess.run(command, shell=True) -if r.returncode != 0: - raise RuntimeError(f"command '{command}' failed with exit code {r.returncode}") - -# load features -nb_features = model.nb_used_features + lpc_order -nb_used_features = model.nb_used_features - -# load features -features = np.fromfile(feature_file, dtype='float32') -num_subframes = len(features) // nb_features -num_subframes = 2 * (num_subframes // 2) -num_frames = num_subframes // 2 - -features = np.reshape(features, (1, -1, nb_features)) -features = features[:, :, :nb_used_features] -features = features[:, :num_subframes, :] - -#variable quantizer depending on the delay -q0 = 3 -q1 = 15 -quant_id = np.round(q1 + (q0-q1)*np.arange(args.num_redundancy_frames//2)/args.num_redundancy_frames).astype('int16') -#print(quant_id) - -quant_embed = qembedding(quant_id) - -# run encoder -print("running fec encoder...") -symbols, gru_state_dec = encoder.predict(features) - -# apply quantization -nsymbols = 80 -quant_scale = tf.math.softplus(quant_embed[:, :nsymbols]).numpy() -dead_zone = tf.math.softplus(quant_embed[:, nsymbols : 2 * nsymbols]).numpy() -#symbols = apply_dead_zone([symbols, dead_zone]).numpy() -#qsymbols = np.round(symbols) -quant_gru_state_dec = pvq_quantize(gru_state_dec, 82) - -# rate estimate -hard_distr_embed = tf.math.sigmoid(quant_embed[:, 4 * nsymbols : ]).numpy() -#rate_input = np.concatenate((qsymbols, hard_distr_embed, enc_lambda), axis=-1) -#rates = sq_rate_metric(None, rate_input, reduce=False).numpy() - -# run decoder -input_length = args.num_redundancy_frames // 2 -offset = args.num_redundancy_frames - 1 - -packets = [] -packet_sizes = [] - -sym_batch = np.zeros((num_frames-offset, args.num_redundancy_frames//2, nsymbols), dtype='float32') -quant_state = quant_gru_state_dec[0, offset:num_frames, :] -#pack symbols for batch processing -for i in range(offset, num_frames): - sym_batch[i-offset, :, :] = symbols[0, i - 2 * input_length + 2 : i + 1 : 2, :] - -#quantize symbols -sym_batch = sym_batch * quant_scale -sym_batch = apply_dead_zone([sym_batch, dead_zone]).numpy() -sym_batch = np.round(sym_batch) - -hard_distr_embed = np.broadcast_to(hard_distr_embed, (sym_batch.shape[0], sym_batch.shape[1], 2*sym_batch.shape[2])) -fake_lambda = np.ones((sym_batch.shape[0], sym_batch.shape[1], 1), dtype='float32') -rate_input = np.concatenate((sym_batch, hard_distr_embed, fake_lambda), axis=-1) -rates = sq_rate_metric(None, rate_input, reduce=False).numpy() -#print(rates.shape) -print("average rate = ", np.mean(rates[args.num_redundancy_frames:,:])) - -#sym_batch.tofile('qsyms.f32') - -sym_batch = sym_batch / quant_scale -#print(sym_batch.shape, quant_state.shape) -#features = decoder.predict([sym_batch, quant_state]) -features = decoder([sym_batch, quant_state]) - -#for i in range(offset, num_frames): -# print(f"processing frame {i - offset}...") -# features = decoder.predict([qsymbols[:, i - 2 * input_length + 2 : i + 1 : 2, :], quant_embed_dec[:, i - 2 * input_length + 2 : i + 1 : 2, :], quant_gru_state_dec[:, i, :]]) -# packets.append(features) -# packet_size = 8 * int((np.sum(rates[:, i - 2 * input_length + 2 : i + 1 : 2]) + 7) / 8) + 64 -# packet_sizes.append(packet_size) - - -# write packets -packet_file = args.output + '.fec' if not args.output.endswith('.fec') else args.output -#write_fec_packets(packet_file, packets, packet_sizes) - - -#print(f"average redundancy rate: {int(round(sum(packet_sizes) / len(packet_sizes) * 50 / 1000))} kbps") - -if args.lossfile != None: - loss = np.loadtxt(args.lossfile, dtype='int16') - fec_out = np.zeros((features.shape[0]*2, features.shape[-1]), dtype='float32') - foffset = -2 - ptr = 0; - count = 2; - for i in range(features.shape[0]): - if (loss[i] == 0) or (i == features.shape[0]-1): - fec_out[ptr:ptr+count,:] = features[i, foffset:, :] - #print("filled ", count) - foffset = -2 - ptr = ptr+count - count = 2 - else: - count = count + 2 - foffset = foffset - 2 - - fec_out_full = np.zeros((fec_out.shape[0], nb_features), dtype=np.float32) - fec_out_full[:, :nb_used_features] = fec_out - - fec_out_full.tofile(packet_file[:-4] + f'_fec.f32') - - -#create packets array like in the original version for debugging purposes -for i in range(offset, num_frames): - packets.append(features[i-offset:i-offset+1, :, :]) - -if args.debug_output: - import itertools - - #batches = [2, 4] - batches = [4] - #offsets = [0, 4, 20] - offsets = [0, (args.num_redundancy_frames - 2)*2] - # sanity checks - # 1. concatenate features at offset 0 - for batch, offset in itertools.product(batches, offsets): - - stop = packets[0].shape[1] - offset - print(batch, offset, stop) - test_features = np.concatenate([packet[:,stop - batch: stop, :] for packet in packets[::batch//2]], axis=1) - - test_features_full = np.zeros((test_features.shape[1], nb_features), dtype=np.float32) - test_features_full[:, :nb_used_features] = test_features[0, :, :] - - print(f"writing debug output {packet_file[:-4] + f'_tf_batch{batch}_offset{offset}.f32'}") - test_features_full.tofile(packet_file[:-4] + f'_tf_batch{batch}_offset{offset}.f32') diff --git a/dnn/training_tf2/fec_packets.c b/dnn/training_tf2/fec_packets.c deleted file mode 100644 index ee08ba95c..000000000 --- a/dnn/training_tf2/fec_packets.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright (c) 2022 Amazon - Written by Jan Buethe */ -/* - 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. -*/ - -#include -#include - -#include "fec_packets.h" - -int get_fec_frame(const char * const filename, float *features, int packet_index, int subframe_index) -{ - - int16_t version; - int16_t header_size; - int16_t num_packets; - int16_t packet_size; - int16_t subframe_size; - int16_t subframes_per_packet; - int16_t num_features; - long offset; - - FILE *fid = fopen(filename, "rb"); - - /* read header */ - if (fread(&version, sizeof(version), 1, fid) != 1) goto error; - if (fread(&header_size, sizeof(header_size), 1, fid) != 1) goto error; - if (fread(&num_packets, sizeof(num_packets), 1, fid) != 1) goto error; - if (fread(&packet_size, sizeof(packet_size), 1, fid) != 1) goto error; - if (fread(&subframe_size, sizeof(subframe_size), 1, fid) != 1) goto error; - if (fread(&subframes_per_packet, sizeof(subframes_per_packet), 1, fid) != 1) goto error; - if (fread(&num_features, sizeof(num_features), 1, fid) != 1) goto error; - - /* check if indices are valid */ - if (packet_index >= num_packets || subframe_index >= subframes_per_packet) - { - fprintf(stderr, "get_fec_frame: index out of bounds\n"); - goto error; - } - - /* calculate offset in file (+ 2 is for rate) */ - offset = header_size + packet_index * packet_size + 2 + subframe_index * subframe_size; - fseek(fid, offset, SEEK_SET); - - /* read features */ - if (fread(features, sizeof(*features), num_features, fid) != num_features) goto error; - - fclose(fid); - return 0; - -error: - fclose(fid); - return 1; -} - -int get_fec_rate(const char * const filename, int packet_index) -{ - int16_t version; - int16_t header_size; - int16_t num_packets; - int16_t packet_size; - int16_t subframe_size; - int16_t subframes_per_packet; - int16_t num_features; - long offset; - int16_t rate; - - FILE *fid = fopen(filename, "rb"); - - /* read header */ - if (fread(&version, sizeof(version), 1, fid) != 1) goto error; - if (fread(&header_size, sizeof(header_size), 1, fid) != 1) goto error; - if (fread(&num_packets, sizeof(num_packets), 1, fid) != 1) goto error; - if (fread(&packet_size, sizeof(packet_size), 1, fid) != 1) goto error; - if (fread(&subframe_size, sizeof(subframe_size), 1, fid) != 1) goto error; - if (fread(&subframes_per_packet, sizeof(subframes_per_packet), 1, fid) != 1) goto error; - if (fread(&num_features, sizeof(num_features), 1, fid) != 1) goto error; - - /* check if indices are valid */ - if (packet_index >= num_packets) - { - fprintf(stderr, "get_fec_rate: index out of bounds\n"); - goto error; - } - - /* calculate offset in file (+ 2 is for rate) */ - offset = header_size + packet_index * packet_size; - fseek(fid, offset, SEEK_SET); - - /* read rate */ - if (fread(&rate, sizeof(rate), 1, fid) != 1) goto error; - - fclose(fid); - return (int) rate; - -error: - fclose(fid); - return -1; -} - -#if 0 -int main() -{ - float features[20]; - int i; - - if (get_fec_frame("../test.fec", &features[0], 0, 127)) - { - return 1; - } - - for (i = 0; i < 20; i ++) - { - printf("%d %f\n", i, features[i]); - } - - printf("rate: %d\n", get_fec_rate("../test.fec", 0)); - -} -#endif \ No newline at end of file diff --git a/dnn/training_tf2/fec_packets.h b/dnn/training_tf2/fec_packets.h deleted file mode 100644 index 01b128b17..000000000 --- a/dnn/training_tf2/fec_packets.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) 2022 Amazon - Written by Jan Buethe */ -/* - 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. -*/ - -#ifndef FEC_PACKETS_H -#define FEC_PACKETS_H - -int get_fec_frame(const char * const filename, float *features, int packet_index, int subframe_index); -int get_fec_rate(const char * const filename, int packet_index); - -#endif diff --git a/dnn/training_tf2/fec_packets.py b/dnn/training_tf2/fec_packets.py deleted file mode 100644 index 6acbe9d2c..000000000 --- a/dnn/training_tf2/fec_packets.py +++ /dev/null @@ -1,108 +0,0 @@ -""" -/* Copyright (c) 2022 Amazon - Written by Jan Buethe */ -/* - 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. -*/ -""" - -import numpy as np - - - -def write_fec_packets(filename, packets, rates=None): - """ writes packets in binary format """ - - assert np.dtype(np.float32).itemsize == 4 - assert np.dtype(np.int16).itemsize == 2 - - # derive some sizes - num_packets = len(packets) - subframes_per_packet = packets[0].shape[-2] - num_features = packets[0].shape[-1] - - # size of float is 4 - subframe_size = num_features * 4 - packet_size = subframe_size * subframes_per_packet + 2 # two bytes for rate - - version = 1 - # header size (version, header_size, num_packets, packet_size, subframe_size, subrames_per_packet, num_features) - header_size = 14 - - with open(filename, 'wb') as f: - - # header - f.write(np.int16(version).tobytes()) - f.write(np.int16(header_size).tobytes()) - f.write(np.int16(num_packets).tobytes()) - f.write(np.int16(packet_size).tobytes()) - f.write(np.int16(subframe_size).tobytes()) - f.write(np.int16(subframes_per_packet).tobytes()) - f.write(np.int16(num_features).tobytes()) - - # packets - for i, packet in enumerate(packets): - if type(rates) == type(None): - rate = 0 - else: - rate = rates[i] - - f.write(np.int16(rate).tobytes()) - - features = np.flip(packet, axis=-2) - f.write(features.astype(np.float32).tobytes()) - - -def read_fec_packets(filename): - """ reads packets from binary format """ - - assert np.dtype(np.float32).itemsize == 4 - assert np.dtype(np.int16).itemsize == 2 - - with open(filename, 'rb') as f: - - # header - version = np.frombuffer(f.read(2), dtype=np.int16).item() - header_size = np.frombuffer(f.read(2), dtype=np.int16).item() - num_packets = np.frombuffer(f.read(2), dtype=np.int16).item() - packet_size = np.frombuffer(f.read(2), dtype=np.int16).item() - subframe_size = np.frombuffer(f.read(2), dtype=np.int16).item() - subframes_per_packet = np.frombuffer(f.read(2), dtype=np.int16).item() - num_features = np.frombuffer(f.read(2), dtype=np.int16).item() - - dummy_features = np.zeros((1, subframes_per_packet, num_features), dtype=np.float32) - - # packets - rates = [] - packets = [] - for i in range(num_packets): - - rate = np.frombuffer(f.read(2), dtype=np.int16).item - rates.append(rate) - - features = np.reshape(np.frombuffer(f.read(subframe_size * subframes_per_packet), dtype=np.float32), dummy_features.shape) - packet = np.flip(features, axis=-2) - packets.append(packet) - - return packets \ No newline at end of file diff --git a/dnn/training_tf2/keraslayerdump.py b/dnn/training_tf2/keraslayerdump.py deleted file mode 100644 index 5abc1488e..000000000 --- a/dnn/training_tf2/keraslayerdump.py +++ /dev/null @@ -1,189 +0,0 @@ -'''Copyright (c) 2017-2018 Mozilla - - 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 FOUNDATION 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. -''' - -""" helper functions for dumping some Keras layers to C files """ - -import numpy as np - - -def printVector(f, vector, name, dtype='float', dotp=False, static=True): - """ prints vector as one-dimensional C array """ - if dotp: - vector = vector.reshape((vector.shape[0]//4, 4, vector.shape[1]//8, 8)) - vector = vector.transpose((2, 0, 3, 1)) - v = np.reshape(vector, (-1)) - if static: - f.write('static const {} {}[{}] = {{\n '.format(dtype, name, len(v))) - else: - f.write('const {} {}[{}] = {{\n '.format(dtype, name, len(v))) - for i in range(0, len(v)): - f.write('{}'.format(v[i])) - if (i!=len(v)-1): - f.write(',') - else: - break; - if (i%8==7): - f.write("\n ") - else: - f.write(" ") - f.write('\n};\n\n') - return vector - -def printSparseVector(f, A, name, have_diag=True): - N = A.shape[0] - M = A.shape[1] - W = np.zeros((0,), dtype='int') - W0 = np.zeros((0,)) - if have_diag: - diag = np.concatenate([np.diag(A[:,:N]), np.diag(A[:,N:2*N]), np.diag(A[:,2*N:])]) - A[:,:N] = A[:,:N] - np.diag(np.diag(A[:,:N])) - A[:,N:2*N] = A[:,N:2*N] - np.diag(np.diag(A[:,N:2*N])) - A[:,2*N:] = A[:,2*N:] - np.diag(np.diag(A[:,2*N:])) - printVector(f, diag, name + '_diag') - AQ = np.minimum(127, np.maximum(-128, np.round(A*128))).astype('int') - idx = np.zeros((0,), dtype='int') - for i in range(M//8): - pos = idx.shape[0] - idx = np.append(idx, -1) - nb_nonzero = 0 - for j in range(N//4): - block = A[j*4:(j+1)*4, i*8:(i+1)*8] - qblock = AQ[j*4:(j+1)*4, i*8:(i+1)*8] - if np.sum(np.abs(block)) > 1e-10: - nb_nonzero = nb_nonzero + 1 - idx = np.append(idx, j*4) - vblock = qblock.transpose((1,0)).reshape((-1,)) - W0 = np.concatenate([W0, block.reshape((-1,))]) - W = np.concatenate([W, vblock]) - idx[pos] = nb_nonzero - f.write('#ifdef DOT_PROD\n') - printVector(f, W, name, dtype='qweight') - f.write('#else /*DOT_PROD*/\n') - printVector(f, W0, name, dtype='qweight') - f.write('#endif /*DOT_PROD*/\n') - printVector(f, idx, name + '_idx', dtype='int') - return AQ - -def dump_sparse_gru(self, f, hf): - name = 'sparse_' + self.name - print("printing layer " + name + " of type sparse " + self.__class__.__name__) - weights = self.get_weights() - qweights = printSparseVector(f, weights[1], name + '_recurrent_weights') - printVector(f, weights[-1], name + '_bias') - subias = weights[-1].copy() - subias[1,:] = subias[1,:] - np.sum(qweights*(1./128),axis=0) - printVector(f, subias, name + '_subias') - if hasattr(self, 'activation'): - activation = self.activation.__name__.upper() - else: - activation = 'TANH' - if hasattr(self, 'reset_after') and not self.reset_after: - reset_after = 0 - else: - reset_after = 1 - neurons = weights[0].shape[1]//3 - max_rnn_neurons = neurons - f.write('const SparseGRULayer {} = {{\n {}_bias,\n {}_subias,\n {}_recurrent_weights_diag,\n {}_recurrent_weights,\n {}_recurrent_weights_idx,\n {}, ACTIVATION_{}, {}\n}};\n\n' - .format(name, name, name, name, name, name, weights[0].shape[1]//3, activation, reset_after)) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('extern const SparseGRULayer {};\n\n'.format(name)); - return max_rnn_neurons - -def dump_gru_layer(self, f, hf, dotp=False, sparse=False): - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - if sparse: - qweight = printSparseVector(f, weights[0], name + '_weights', have_diag=False) - else: - qweight = printVector(f, weights[0], name + '_weights') - - if dotp: - f.write('#ifdef DOT_PROD\n') - qweight2 = np.clip(np.round(128.*weights[1]).astype('int'), -128, 127) - printVector(f, qweight2, name + '_recurrent_weights', dotp=True, dtype='qweight') - f.write('#else /*DOT_PROD*/\n') - else: - qweight2 = weights[1] - - printVector(f, weights[1], name + '_recurrent_weights') - if dotp: - f.write('#endif /*DOT_PROD*/\n') - - printVector(f, weights[-1], name + '_bias') - subias = weights[-1].copy() - subias[0,:] = subias[0,:] - np.sum(qweight*(1./128.),axis=0) - subias[1,:] = subias[1,:] - np.sum(qweight2*(1./128.),axis=0) - printVector(f, subias, name + '_subias') - if hasattr(self, 'activation'): - activation = self.activation.__name__.upper() - else: - activation = 'TANH' - if hasattr(self, 'reset_after') and not self.reset_after: - reset_after = 0 - else: - reset_after = 1 - neurons = weights[0].shape[1]//3 - max_rnn_neurons = neurons - f.write('const GRULayer {} = {{\n {}_bias,\n {}_subias,\n {}_weights,\n {},\n {}_recurrent_weights,\n {}, {}, ACTIVATION_{}, {}\n}};\n\n' - .format(name, name, name, name, name + "_weights_idx" if sparse else "NULL", name, weights[0].shape[0], weights[0].shape[1]//3, activation, reset_after)) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('#define {}_STATE_SIZE {}\n'.format(name.upper(), weights[0].shape[1]//3)) - hf.write('extern const GRULayer {};\n\n'.format(name)); - return max_rnn_neurons - -def dump_dense_layer_impl(name, weights, bias, activation, f, hf): - printVector(f, weights, name + '_weights') - printVector(f, bias, name + '_bias') - f.write('const DenseLayer {} = {{\n {}_bias,\n {}_weights,\n {}, {}, ACTIVATION_{}\n}};\n\n' - .format(name, name, name, weights.shape[0], weights.shape[1], activation)) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights.shape[1])) - hf.write('extern const DenseLayer {};\n\n'.format(name)); - -def dump_dense_layer(self, f, hf): - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - activation = self.activation.__name__.upper() - dump_dense_layer_impl(name, weights[0], weights[1], activation, f, hf) - return False - -def dump_conv1d_layer(self, f, hf): - name = self.name - print("printing layer " + name + " of type " + self.__class__.__name__) - weights = self.get_weights() - printVector(f, weights[0], name + '_weights') - printVector(f, weights[-1], name + '_bias') - activation = self.activation.__name__.upper() - max_conv_inputs = weights[0].shape[1]*weights[0].shape[0] - f.write('const Conv1DLayer {} = {{\n {}_bias,\n {}_weights,\n {}, {}, {}, ACTIVATION_{}\n}};\n\n' - .format(name, name, name, weights[0].shape[1], weights[0].shape[0], weights[0].shape[2], activation)) - hf.write('#define {}_OUT_SIZE {}\n'.format(name.upper(), weights[0].shape[2])) - hf.write('#define {}_STATE_SIZE ({}*{})\n'.format(name.upper(), weights[0].shape[1], (weights[0].shape[0]-1))) - hf.write('#define {}_DELAY {}\n'.format(name.upper(), (weights[0].shape[0]-1)//2)) - hf.write('extern const Conv1DLayer {};\n\n'.format(name)); - return max_conv_inputs diff --git a/dnn/training_tf2/lossfuncs.py b/dnn/training_tf2/lossfuncs.py deleted file mode 100644 index 78be1fd61..000000000 --- a/dnn/training_tf2/lossfuncs.py +++ /dev/null @@ -1,99 +0,0 @@ -""" -Custom Loss functions and metrics for training/analysis -""" - -from tf_funcs import * -import tensorflow as tf - -# The following loss functions all expect the lpcnet model to output the lpc prediction - -# Computing the excitation by subtracting the lpc prediction from the target, followed by minimizing the cross entropy -def res_from_sigloss(): - def loss(y_true,y_pred): - p = y_pred[:,:,0:1] - model_out = y_pred[:,:,2:] - e_gt = tf_l2u(y_true - p) - e_gt = tf.round(e_gt) - e_gt = tf.cast(e_gt,'int32') - sparse_cel = tf.keras.losses.SparseCategoricalCrossentropy(reduction=tf.keras.losses.Reduction.NONE)(e_gt,model_out) - return sparse_cel - return loss - -# Interpolated and Compensated Loss (In case of end to end lpcnet) -# Interpolates between adjacent embeddings based on the fractional value of the excitation computed (similar to the embedding interpolation) -# Also adds a probability compensation (to account for matching cross entropy in the linear domain), weighted by gamma -def interp_mulaw(gamma = 1): - def loss(y_true,y_pred): - y_true = tf.cast(y_true, 'float32') - p = y_pred[:,:,0:1] - real_p = y_pred[:,:,1:2] - model_out = y_pred[:,:,2:] - e_gt = tf_l2u(y_true - p) - exc_gt = tf_l2u(y_true - real_p) - prob_compensation = tf.squeeze((K.abs(e_gt - 128)/128.0)*K.log(256.0)) - regularization = tf.squeeze((K.abs(exc_gt - 128)/128.0)*K.log(256.0)) - alpha = e_gt - tf.math.floor(e_gt) - alpha = tf.tile(alpha,[1,1,256]) - e_gt = tf.cast(e_gt,'int32') - e_gt = tf.clip_by_value(e_gt,0,254) - interp_probab = (1 - alpha)*model_out + alpha*tf.roll(model_out,shift = -1,axis = -1) - sparse_cel = tf.keras.losses.SparseCategoricalCrossentropy(reduction=tf.keras.losses.Reduction.NONE)(e_gt,interp_probab) - loss_mod = sparse_cel + prob_compensation + gamma*regularization - return loss_mod - return loss - -# Same as above, except a metric -def metric_oginterploss(y_true,y_pred): - p = y_pred[:,:,0:1] - model_out = y_pred[:,:,2:] - e_gt = tf_l2u(y_true - p) - prob_compensation = tf.squeeze((K.abs(e_gt - 128)/128.0)*K.log(256.0)) - alpha = e_gt - tf.math.floor(e_gt) - alpha = tf.tile(alpha,[1,1,256]) - e_gt = tf.cast(e_gt,'int32') - e_gt = tf.clip_by_value(e_gt,0,254) - interp_probab = (1 - alpha)*model_out + alpha*tf.roll(model_out,shift = -1,axis = -1) - sparse_cel = tf.keras.losses.SparseCategoricalCrossentropy(reduction=tf.keras.losses.Reduction.NONE)(e_gt,interp_probab) - loss_mod = sparse_cel + prob_compensation - return loss_mod - -# Interpolated cross entropy loss metric -def metric_icel(y_true, y_pred): - p = y_pred[:,:,0:1] - model_out = y_pred[:,:,2:] - e_gt = tf_l2u(y_true - p) - alpha = e_gt - tf.math.floor(e_gt) - alpha = tf.tile(alpha,[1,1,256]) - e_gt = tf.cast(e_gt,'int32') - e_gt = tf.clip_by_value(e_gt,0,254) #Check direction - interp_probab = (1 - alpha)*model_out + alpha*tf.roll(model_out,shift = -1,axis = -1) - sparse_cel = tf.keras.losses.SparseCategoricalCrossentropy(reduction=tf.keras.losses.Reduction.NONE)(e_gt,interp_probab) - return sparse_cel - -# Non-interpolated (rounded) cross entropy loss metric -def metric_cel(y_true, y_pred): - y_true = tf.cast(y_true, 'float32') - p = y_pred[:,:,0:1] - model_out = y_pred[:,:,2:] - e_gt = tf_l2u(y_true - p) - e_gt = tf.round(e_gt) - e_gt = tf.cast(e_gt,'int32') - e_gt = tf.clip_by_value(e_gt,0,255) - sparse_cel = tf.keras.losses.SparseCategoricalCrossentropy(reduction=tf.keras.losses.Reduction.NONE)(e_gt,model_out) - return sparse_cel - -# Variance metric of the output excitation -def metric_exc_sd(y_true,y_pred): - p = y_pred[:,:,0:1] - e_gt = tf_l2u(y_true - p) - sd_egt = tf.keras.losses.MeanSquaredError(reduction=tf.keras.losses.Reduction.NONE)(e_gt,128) - return sd_egt - -def loss_matchlar(): - def loss(y_true,y_pred): - model_rc = y_pred[:,:,:16] - #y_true = lpc2rc(y_true) - loss_lar_diff = K.log((1.01 + model_rc)/(1.01 - model_rc)) - K.log((1.01 + y_true)/(1.01 - y_true)) - loss_lar_diff = tf.square(loss_lar_diff) - return tf.reduce_mean(loss_lar_diff, axis=-1) - return loss diff --git a/dnn/training_tf2/lpcnet.py b/dnn/training_tf2/lpcnet.py deleted file mode 100644 index 497f75722..000000000 --- a/dnn/training_tf2/lpcnet.py +++ /dev/null @@ -1,339 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2018 Mozilla - - 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 FOUNDATION 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. -''' - -import math -import tensorflow as tf -from tensorflow.keras.models import Model -from tensorflow.keras.layers import Input, GRU, Dense, Embedding, Reshape, Concatenate, Lambda, Conv1D, Multiply, Add, Bidirectional, MaxPooling1D, Activation, GaussianNoise -from tensorflow.compat.v1.keras.layers import CuDNNGRU -from tensorflow.keras import backend as K -from tensorflow.keras.constraints import Constraint -from tensorflow.keras.initializers import Initializer -from tensorflow.keras.callbacks import Callback -from mdense import MDense -import numpy as np -import h5py -import sys -from tf_funcs import * -from diffembed import diff_Embed -from parameters import set_parameter - -frame_size = 160 -pcm_bits = 8 -embed_size = 128 -pcm_levels = 2**pcm_bits - -def interleave(p, samples): - p2=tf.expand_dims(p, 3) - nb_repeats = pcm_levels//(2*p.shape[2]) - p3 = tf.reshape(tf.repeat(tf.concat([1-p2, p2], 3), nb_repeats), (-1, samples, pcm_levels)) - return p3 - -def tree_to_pdf(p, samples): - return interleave(p[:,:,1:2], samples) * interleave(p[:,:,2:4], samples) * interleave(p[:,:,4:8], samples) * interleave(p[:,:,8:16], samples) \ - * interleave(p[:,:,16:32], samples) * interleave(p[:,:,32:64], samples) * interleave(p[:,:,64:128], samples) * interleave(p[:,:,128:256], samples) - -def tree_to_pdf_train(p): - #FIXME: try not to hardcode the 2400 samples (15 frames * 160 samples/frame) - return tree_to_pdf(p, 2400) - -def tree_to_pdf_infer(p): - return tree_to_pdf(p, 1) - -def quant_regularizer(x): - Q = 128 - Q_1 = 1./Q - #return .01 * tf.reduce_mean(1 - tf.math.cos(2*3.1415926535897931*(Q*x-tf.round(Q*x)))) - return .01 * tf.reduce_mean(K.sqrt(K.sqrt(1.0001 - tf.math.cos(2*3.1415926535897931*(Q*x-tf.round(Q*x)))))) - -class Sparsify(Callback): - def __init__(self, t_start, t_end, interval, density, quantize=False): - super(Sparsify, self).__init__() - self.batch = 0 - self.t_start = t_start - self.t_end = t_end - self.interval = interval - self.final_density = density - self.quantize = quantize - - def on_batch_end(self, batch, logs=None): - #print("batch number", self.batch) - self.batch += 1 - if self.quantize or (self.batch > self.t_start and (self.batch-self.t_start) % self.interval == 0) or self.batch >= self.t_end: - #print("constrain"); - layer = self.model.get_layer('gru_a') - w = layer.get_weights() - p = w[1] - nb = p.shape[1]//p.shape[0] - N = p.shape[0] - #print("nb = ", nb, ", N = ", N); - #print(p.shape) - #print ("density = ", density) - for k in range(nb): - density = self.final_density[k] - if self.batch < self.t_end and not self.quantize: - r = 1 - (self.batch-self.t_start)/(self.t_end - self.t_start) - density = 1 - (1-self.final_density[k])*(1 - r*r*r) - A = p[:, k*N:(k+1)*N] - A = A - np.diag(np.diag(A)) - #This is needed because of the CuDNNGRU strange weight ordering - A = np.transpose(A, (1, 0)) - L=np.reshape(A, (N//4, 4, N//8, 8)) - S=np.sum(L*L, axis=-1) - S=np.sum(S, axis=1) - SS=np.sort(np.reshape(S, (-1,))) - thresh = SS[round(N*N//32*(1-density))] - mask = (S>=thresh).astype('float32') - mask = np.repeat(mask, 4, axis=0) - mask = np.repeat(mask, 8, axis=1) - mask = np.minimum(1, mask + np.diag(np.ones((N,)))) - #This is needed because of the CuDNNGRU strange weight ordering - mask = np.transpose(mask, (1, 0)) - p[:, k*N:(k+1)*N] = p[:, k*N:(k+1)*N]*mask - #print(thresh, np.mean(mask)) - if self.quantize and ((self.batch > self.t_start and (self.batch-self.t_start) % self.interval == 0) or self.batch >= self.t_end): - if self.batch < self.t_end: - threshold = .5*(self.batch - self.t_start)/(self.t_end - self.t_start) - else: - threshold = .5 - quant = np.round(p*128.) - res = p*128.-quant - mask = (np.abs(res) <= threshold).astype('float32') - p = mask/128.*quant + (1-mask)*p - - w[1] = p - layer.set_weights(w) - -class SparsifyGRUB(Callback): - def __init__(self, t_start, t_end, interval, grua_units, density, quantize=False): - super(SparsifyGRUB, self).__init__() - self.batch = 0 - self.t_start = t_start - self.t_end = t_end - self.interval = interval - self.final_density = density - self.grua_units = grua_units - self.quantize = quantize - - def on_batch_end(self, batch, logs=None): - #print("batch number", self.batch) - self.batch += 1 - if self.quantize or (self.batch > self.t_start and (self.batch-self.t_start) % self.interval == 0) or self.batch >= self.t_end: - #print("constrain"); - layer = self.model.get_layer('gru_b') - w = layer.get_weights() - p = w[0] - N = p.shape[0] - M = p.shape[1]//3 - for k in range(3): - density = self.final_density[k] - if self.batch < self.t_end and not self.quantize: - r = 1 - (self.batch-self.t_start)/(self.t_end - self.t_start) - density = 1 - (1-self.final_density[k])*(1 - r*r*r) - A = p[:, k*M:(k+1)*M] - #This is needed because of the CuDNNGRU strange weight ordering - A = np.reshape(A, (M, N)) - A = np.transpose(A, (1, 0)) - N2 = self.grua_units - A2 = A[:N2, :] - L=np.reshape(A2, (N2//4, 4, M//8, 8)) - S=np.sum(L*L, axis=-1) - S=np.sum(S, axis=1) - SS=np.sort(np.reshape(S, (-1,))) - thresh = SS[round(M*N2//32*(1-density))] - mask = (S>=thresh).astype('float32') - mask = np.repeat(mask, 4, axis=0) - mask = np.repeat(mask, 8, axis=1) - A = np.concatenate([A2*mask, A[N2:,:]], axis=0) - #This is needed because of the CuDNNGRU strange weight ordering - A = np.transpose(A, (1, 0)) - A = np.reshape(A, (N, M)) - p[:, k*M:(k+1)*M] = A - #print(thresh, np.mean(mask)) - if self.quantize and ((self.batch > self.t_start and (self.batch-self.t_start) % self.interval == 0) or self.batch >= self.t_end): - if self.batch < self.t_end: - threshold = .5*(self.batch - self.t_start)/(self.t_end - self.t_start) - else: - threshold = .5 - quant = np.round(p*128.) - res = p*128.-quant - mask = (np.abs(res) <= threshold).astype('float32') - p = mask/128.*quant + (1-mask)*p - - w[0] = p - layer.set_weights(w) - - -class PCMInit(Initializer): - def __init__(self, gain=.1, seed=None): - self.gain = gain - self.seed = seed - - def __call__(self, shape, dtype=None): - num_rows = 1 - for dim in shape[:-1]: - num_rows *= dim - num_cols = shape[-1] - flat_shape = (num_rows, num_cols) - if self.seed is not None: - np.random.seed(self.seed) - a = np.random.uniform(-1.7321, 1.7321, flat_shape) - #a[:,0] = math.sqrt(12)*np.arange(-.5*num_rows+.5,.5*num_rows-.4)/num_rows - #a[:,1] = .5*a[:,0]*a[:,0]*a[:,0] - a = a + np.reshape(math.sqrt(12)*np.arange(-.5*num_rows+.5,.5*num_rows-.4)/num_rows, (num_rows, 1)) - return self.gain * a.astype("float32") - - def get_config(self): - return { - 'gain': self.gain, - 'seed': self.seed - } - -class WeightClip(Constraint): - '''Clips the weights incident to each hidden unit to be inside a range - ''' - def __init__(self, c=2): - self.c = c - - def __call__(self, p): - # Ensure that abs of adjacent weights don't sum to more than 127. Otherwise there's a risk of - # saturation when implementing dot products with SSSE3 or AVX2. - return self.c*p/tf.maximum(self.c, tf.repeat(tf.abs(p[:, 1::2])+tf.abs(p[:, 0::2]), 2, axis=1)) - #return K.clip(p, -self.c, self.c) - - def get_config(self): - return {'name': self.__class__.__name__, - 'c': self.c} - -constraint = WeightClip(0.992) - -def new_lpcnet_model(rnn_units1=384, rnn_units2=16, nb_used_features=20, batch_size=128, training=False, adaptation=False, quantize=False, flag_e2e = False, cond_size=128, lpc_order=16, lpc_gamma=1., lookahead=2): - pcm = Input(shape=(None, 1), batch_size=batch_size) - dpcm = Input(shape=(None, 3), batch_size=batch_size) - feat = Input(shape=(None, nb_used_features), batch_size=batch_size) - pitch = Input(shape=(None, 1), batch_size=batch_size) - dec_feat = Input(shape=(None, cond_size)) - dec_state1 = Input(shape=(rnn_units1,)) - dec_state2 = Input(shape=(rnn_units2,)) - - padding = 'valid' if training else 'same' - fconv1 = Conv1D(cond_size, 3, padding=padding, activation='tanh', name='feature_conv1') - fconv2 = Conv1D(cond_size, 3, padding=padding, activation='tanh', name='feature_conv2') - pembed = Embedding(256, 64, name='embed_pitch') - cat_feat = Concatenate()([feat, Reshape((-1, 64))(pembed(pitch))]) - - cfeat = fconv2(fconv1(cat_feat)) - - fdense1 = Dense(cond_size, activation='tanh', name='feature_dense1') - fdense2 = Dense(cond_size, activation='tanh', name='feature_dense2') - - if flag_e2e and quantize: - fconv1.trainable = False - fconv2.trainable = False - fdense1.trainable = False - fdense2.trainable = False - - cfeat = fdense2(fdense1(cfeat)) - - error_calc = Lambda(lambda x: tf_l2u(x[0] - tf.roll(x[1],1,axis = 1))) - if flag_e2e: - lpcoeffs = diff_rc2lpc(name = "rc2lpc")(cfeat) - else: - lpcoeffs = Input(shape=(None, lpc_order), batch_size=batch_size) - - real_preds = diff_pred(name = "real_lpc2preds")([pcm,lpcoeffs]) - weighting = lpc_gamma ** np.arange(1, 17).astype('float32') - weighted_lpcoeffs = Lambda(lambda x: x[0]*x[1])([lpcoeffs, weighting]) - tensor_preds = diff_pred(name = "lpc2preds")([pcm,weighted_lpcoeffs]) - past_errors = error_calc([pcm,tensor_preds]) - - embed = diff_Embed(name='embed_sig',initializer = PCMInit()) - cpcm = Concatenate()([tf_l2u(pcm),tf_l2u(tensor_preds),past_errors]) - cpcm = GaussianNoise(.3)(cpcm) - cpcm = Reshape((-1, embed_size*3))(embed(cpcm)) - cpcm_decoder = Reshape((-1, embed_size*3))(embed(dpcm)) - - - rep = Lambda(lambda x: K.repeat_elements(x, frame_size, 1)) - - quant = quant_regularizer if quantize else None - - if training: - rnn = CuDNNGRU(rnn_units1, return_sequences=True, return_state=True, name='gru_a', stateful=True, - recurrent_constraint = constraint, recurrent_regularizer=quant) - rnn2 = CuDNNGRU(rnn_units2, return_sequences=True, return_state=True, name='gru_b', stateful=True, - kernel_constraint=constraint, recurrent_constraint = constraint, kernel_regularizer=quant, recurrent_regularizer=quant) - else: - rnn = GRU(rnn_units1, return_sequences=True, return_state=True, recurrent_activation="sigmoid", reset_after='true', name='gru_a', stateful=True, - recurrent_constraint = constraint, recurrent_regularizer=quant) - rnn2 = GRU(rnn_units2, return_sequences=True, return_state=True, recurrent_activation="sigmoid", reset_after='true', name='gru_b', stateful=True, - kernel_constraint=constraint, recurrent_constraint = constraint, kernel_regularizer=quant, recurrent_regularizer=quant) - - rnn_in = Concatenate()([cpcm, rep(cfeat)]) - md = MDense(pcm_levels, activation='sigmoid', name='dual_fc') - gru_out1, _ = rnn(rnn_in) - gru_out1 = GaussianNoise(.005)(gru_out1) - gru_out2, _ = rnn2(Concatenate()([gru_out1, rep(cfeat)])) - ulaw_prob = Lambda(tree_to_pdf_train)(md(gru_out2)) - - if adaptation: - rnn.trainable=False - rnn2.trainable=False - md.trainable=False - embed.Trainable=False - - m_out = Concatenate(name='pdf')([tensor_preds,real_preds,ulaw_prob]) - if not flag_e2e: - model = Model([pcm, feat, pitch, lpcoeffs], m_out) - else: - model = Model([pcm, feat, pitch], [m_out, cfeat]) - model.rnn_units1 = rnn_units1 - model.rnn_units2 = rnn_units2 - model.nb_used_features = nb_used_features - model.frame_size = frame_size - - if not flag_e2e: - encoder = Model([feat, pitch], cfeat) - dec_rnn_in = Concatenate()([cpcm_decoder, dec_feat]) - else: - encoder = Model([feat, pitch], [cfeat,lpcoeffs]) - dec_rnn_in = Concatenate()([cpcm_decoder, dec_feat]) - dec_gru_out1, state1 = rnn(dec_rnn_in, initial_state=dec_state1) - dec_gru_out2, state2 = rnn2(Concatenate()([dec_gru_out1, dec_feat]), initial_state=dec_state2) - dec_ulaw_prob = Lambda(tree_to_pdf_infer)(md(dec_gru_out2)) - - if flag_e2e: - decoder = Model([dpcm, dec_feat, dec_state1, dec_state2], [dec_ulaw_prob, state1, state2]) - else: - decoder = Model([dpcm, dec_feat, dec_state1, dec_state2], [dec_ulaw_prob, state1, state2]) - - # add parameters to model - set_parameter(model, 'lpc_gamma', lpc_gamma, dtype='float64') - set_parameter(model, 'flag_e2e', flag_e2e, dtype='bool') - set_parameter(model, 'lookahead', lookahead, dtype='int32') - - return model, encoder, decoder diff --git a/dnn/training_tf2/lpcnet_plc.py b/dnn/training_tf2/lpcnet_plc.py deleted file mode 100644 index 618e0084e..000000000 --- a/dnn/training_tf2/lpcnet_plc.py +++ /dev/null @@ -1,101 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2021-2022 Amazon - Copyright (c) 2018-2019 Mozilla - - 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 FOUNDATION 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. -''' - -import math -import tensorflow as tf -from tensorflow.keras.models import Model -from tensorflow.keras.layers import Input, GRU, Dense, Embedding, Reshape, Concatenate, Lambda, Conv1D, Multiply, Add, Bidirectional, MaxPooling1D, Activation, GaussianNoise -from tensorflow.compat.v1.keras.layers import CuDNNGRU -from tensorflow.keras import backend as K -from tensorflow.keras.constraints import Constraint -from tensorflow.keras.initializers import Initializer -from tensorflow.keras.callbacks import Callback -import numpy as np - -def quant_regularizer(x): - Q = 128 - Q_1 = 1./Q - #return .01 * tf.reduce_mean(1 - tf.math.cos(2*3.1415926535897931*(Q*x-tf.round(Q*x)))) - return .01 * tf.reduce_mean(K.sqrt(K.sqrt(1.0001 - tf.math.cos(2*3.1415926535897931*(Q*x-tf.round(Q*x)))))) - - -class WeightClip(Constraint): - '''Clips the weights incident to each hidden unit to be inside a range - ''' - def __init__(self, c=2): - self.c = c - - def __call__(self, p): - # Ensure that abs of adjacent weights don't sum to more than 127. Otherwise there's a risk of - # saturation when implementing dot products with SSSE3 or AVX2. - return self.c*p/tf.maximum(self.c, tf.repeat(tf.abs(p[:, 1::2])+tf.abs(p[:, 0::2]), 2, axis=1)) - #return K.clip(p, -self.c, self.c) - - def get_config(self): - return {'name': self.__class__.__name__, - 'c': self.c} - -constraint = WeightClip(0.992) - -def new_lpcnet_plc_model(rnn_units=256, nb_used_features=20, nb_burg_features=36, batch_size=128, training=False, adaptation=False, quantize=False, cond_size=128): - feat = Input(shape=(None, nb_used_features+nb_burg_features), batch_size=batch_size) - lost = Input(shape=(None, 1), batch_size=batch_size) - - fdense1 = Dense(cond_size, activation='tanh', name='plc_dense1') - - cfeat = Concatenate()([feat, lost]) - cfeat = fdense1(cfeat) - #cfeat = Conv1D(cond_size, 3, padding='causal', activation='tanh', name='plc_conv1')(cfeat) - - quant = quant_regularizer if quantize else None - - if training: - rnn = CuDNNGRU(rnn_units, return_sequences=True, return_state=True, name='plc_gru1', stateful=True, - kernel_constraint=constraint, recurrent_constraint = constraint, kernel_regularizer=quant, recurrent_regularizer=quant) - rnn2 = CuDNNGRU(rnn_units, return_sequences=True, return_state=True, name='plc_gru2', stateful=True, - kernel_constraint=constraint, recurrent_constraint = constraint, kernel_regularizer=quant, recurrent_regularizer=quant) - else: - rnn = GRU(rnn_units, return_sequences=True, return_state=True, recurrent_activation="sigmoid", reset_after='true', name='plc_gru1', stateful=True, - kernel_constraint=constraint, recurrent_constraint = constraint, kernel_regularizer=quant, recurrent_regularizer=quant) - rnn2 = GRU(rnn_units, return_sequences=True, return_state=True, recurrent_activation="sigmoid", reset_after='true', name='plc_gru2', stateful=True, - kernel_constraint=constraint, recurrent_constraint = constraint, kernel_regularizer=quant, recurrent_regularizer=quant) - - gru_out1, _ = rnn(cfeat) - gru_out1 = GaussianNoise(.005)(gru_out1) - gru_out2, _ = rnn2(gru_out1) - - out_dense = Dense(nb_used_features, activation='linear', name='plc_out') - plc_out = out_dense(gru_out2) - - model = Model([feat, lost], plc_out) - model.rnn_units = rnn_units - model.cond_size = cond_size - model.nb_used_features = nb_used_features - model.nb_burg_features = nb_burg_features - - return model diff --git a/dnn/training_tf2/mdense.py b/dnn/training_tf2/mdense.py deleted file mode 100644 index 844ae23e6..000000000 --- a/dnn/training_tf2/mdense.py +++ /dev/null @@ -1,95 +0,0 @@ -from tensorflow.keras import backend as K -from tensorflow.keras.layers import Layer, InputSpec -from tensorflow.keras import activations -from tensorflow.keras import initializers, regularizers, constraints -import numpy as np -import math - -class MDense(Layer): - - def __init__(self, outputs, - channels=2, - activation=None, - use_bias=True, - kernel_initializer='glorot_uniform', - bias_initializer='zeros', - kernel_regularizer=None, - bias_regularizer=None, - activity_regularizer=None, - kernel_constraint=None, - bias_constraint=None, - **kwargs): - if 'input_shape' not in kwargs and 'input_dim' in kwargs: - kwargs['input_shape'] = (kwargs.pop('input_dim'),) - super(MDense, self).__init__(**kwargs) - self.units = outputs - self.channels = channels - self.activation = activations.get(activation) - self.use_bias = use_bias - self.kernel_initializer = initializers.get(kernel_initializer) - self.bias_initializer = initializers.get(bias_initializer) - self.kernel_regularizer = regularizers.get(kernel_regularizer) - self.bias_regularizer = regularizers.get(bias_regularizer) - self.activity_regularizer = regularizers.get(activity_regularizer) - self.kernel_constraint = constraints.get(kernel_constraint) - self.bias_constraint = constraints.get(bias_constraint) - self.input_spec = InputSpec(min_ndim=2) - self.supports_masking = True - - def build(self, input_shape): - assert len(input_shape) >= 2 - input_dim = input_shape[-1] - - self.kernel = self.add_weight(shape=(self.units, input_dim, self.channels), - initializer=self.kernel_initializer, - name='kernel', - regularizer=self.kernel_regularizer, - constraint=self.kernel_constraint) - if self.use_bias: - self.bias = self.add_weight(shape=(self.units, self.channels), - initializer=self.bias_initializer, - name='bias', - regularizer=self.bias_regularizer, - constraint=self.bias_constraint) - else: - self.bias = None - self.factor = self.add_weight(shape=(self.units, self.channels), - initializer='ones', - name='factor', - regularizer=self.bias_regularizer, - constraint=self.bias_constraint) - self.input_spec = InputSpec(min_ndim=2, axes={-1: input_dim}) - self.built = True - - def call(self, inputs): - output = K.dot(inputs, self.kernel) - if self.use_bias: - output = output + self.bias - output = K.tanh(output) * self.factor - output = K.sum(output, axis=-1) - if self.activation is not None: - output = self.activation(output) - return output - - def compute_output_shape(self, input_shape): - assert input_shape and len(input_shape) >= 2 - assert input_shape[-1] - output_shape = list(input_shape) - output_shape[-1] = self.units - return tuple(output_shape) - - def get_config(self): - config = { - 'units': self.units, - 'activation': activations.serialize(self.activation), - 'use_bias': self.use_bias, - 'kernel_initializer': initializers.serialize(self.kernel_initializer), - 'bias_initializer': initializers.serialize(self.bias_initializer), - 'kernel_regularizer': regularizers.serialize(self.kernel_regularizer), - 'bias_regularizer': regularizers.serialize(self.bias_regularizer), - 'activity_regularizer': regularizers.serialize(self.activity_regularizer), - 'kernel_constraint': constraints.serialize(self.kernel_constraint), - 'bias_constraint': constraints.serialize(self.bias_constraint) - } - base_config = super(MDense, self).get_config() - return dict(list(base_config.items()) + list(config.items())) diff --git a/dnn/training_tf2/pade.py b/dnn/training_tf2/pade.py deleted file mode 100644 index f88f425c9..000000000 --- a/dnn/training_tf2/pade.py +++ /dev/null @@ -1,70 +0,0 @@ -# Optimizing a rational function to optimize a tanh() approximation - -import numpy as np -import tensorflow as tf -from tensorflow.keras.models import Model -from tensorflow.keras.layers import Input, GRU, Dense, Embedding, Reshape, Concatenate, Lambda, Conv1D, Multiply, Add, Bidirectional, MaxPooling1D, Activation -import tensorflow.keras.backend as K -from tensorflow.keras.optimizers import Adam, SGD - -def my_loss1(y_true, y_pred): - return 1*K.mean(K.square(y_true-y_pred)) + 1*K.max(K.square(y_true-y_pred), axis=1) - -def my_loss2(y_true, y_pred): - return .1*K.mean(K.square(y_true-y_pred)) + 1*K.max(K.square(y_true-y_pred), axis=1) - -def my_loss3(y_true, y_pred): - return .01*K.mean(K.square(y_true-y_pred)) + 1*K.max(K.square(y_true-y_pred), axis=1) - -# Using these initializers to seed the approximation -# with a reasonable starting point -def num_init(shape, dtype=None): - rr = tf.constant([[945], [105], [1]], dtype=dtype) - #rr = tf.constant([[946.56757], [98.01368], [0.66841]], dtype=dtype) - print(rr) - return rr - -def den_init(shape, dtype=None): - rr = tf.constant([[945], [420], [15]], dtype=dtype) - #rr = tf.constant([[946.604], [413.342], [12.465]], dtype=dtype) - print(rr) - return rr - - -x = np.arange(-10, 10, .01) -N = len(x) -x = np.reshape(x, (1, -1, 1)) -x2 = x*x - -x2in = np.concatenate([x2*0 + 1, x2, x2*x2], axis=2) -yout = np.tanh(x) - - -model_x = Input(shape=(None, 1,)) -model_x2 = Input(shape=(None, 3,)) - -num = Dense(1, name='num', use_bias=False, kernel_initializer=num_init) -den = Dense(1, name='den', use_bias=False, kernel_initializer=den_init) - -def ratio(x): - return tf.minimum(1., tf.maximum(-1., x[0]*x[1]/x[2])) - -out_layer = Lambda(ratio) -output = out_layer([model_x, num(model_x2), den(model_x2)]) - -model = Model([model_x, model_x2], output) -model.summary() - -model.compile(Adam(0.05, beta_1=0.9, beta_2=0.9, decay=2e-5), loss='mean_squared_error') -model.fit([x, x2in], yout, batch_size=1, epochs=500000, validation_split=0.0) - -model.compile(Adam(0.001, beta_2=0.9, decay=1e-4), loss=my_loss1) -model.fit([x, x2in], yout, batch_size=1, epochs=50000, validation_split=0.0) - -model.compile(Adam(0.0001, beta_2=0.9, decay=1e-4), loss=my_loss2) -model.fit([x, x2in], yout, batch_size=1, epochs=50000, validation_split=0.0) - -model.compile(Adam(0.00001, beta_2=0.9, decay=1e-4), loss=my_loss3) -model.fit([x, x2in], yout, batch_size=1, epochs=50000, validation_split=0.0) - -model.save_weights('tanh.h5') diff --git a/dnn/training_tf2/parameters.py b/dnn/training_tf2/parameters.py deleted file mode 100644 index 3621a4e4f..000000000 --- a/dnn/training_tf2/parameters.py +++ /dev/null @@ -1,29 +0,0 @@ -""" module for handling extra model parameters for tf.keras models """ - -import tensorflow as tf - - -def set_parameter(model, parameter_name, parameter_value, dtype='float32'): - """ stores parameter_value as non-trainable weight with name parameter_name:0 """ - - weights = [weight for weight in model.weights if weight.name == (parameter_name + ":0")] - - if len(weights) == 0: - model.add_weight(parameter_name, trainable=False, initializer=tf.keras.initializers.Constant(parameter_value), dtype=dtype) - elif len(weights) == 1: - weights[0].assign(parameter_value) - else: - raise ValueError(f"more than one weight starting with {parameter_name}:0 in model") - - -def get_parameter(model, parameter_name, default=None): - """ returns parameter value if parameter is present in model and otherwise default """ - - weights = [weight for weight in model.weights if weight.name == (parameter_name + ":0")] - - if len(weights) == 0: - return default - elif len(weights) > 1: - raise ValueError(f"more than one weight starting with {parameter_name}:0 in model") - else: - return weights[0].numpy().item() diff --git a/dnn/training_tf2/plc_loader.py b/dnn/training_tf2/plc_loader.py deleted file mode 100644 index a9bd41d87..000000000 --- a/dnn/training_tf2/plc_loader.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2021-2022 Amazon - - 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 FOUNDATION 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. -''' - -import numpy as np -from tensorflow.keras.utils import Sequence - -class PLCLoader(Sequence): - def __init__(self, features, lost, nb_burg_features, batch_size): - self.batch_size = batch_size - self.nb_batches = features.shape[0]//self.batch_size - self.features = features[:self.nb_batches*self.batch_size, :, :] - self.lost = lost.astype('float') - self.lost = self.lost[:(len(self.lost)//features.shape[1]-1)*features.shape[1]] - self.nb_burg_features = nb_burg_features - self.on_epoch_end() - - def on_epoch_end(self): - self.indices = np.arange(self.nb_batches*self.batch_size) - np.random.shuffle(self.indices) - offset = np.random.randint(0, high=self.features.shape[1]) - self.lost_offset = np.reshape(self.lost[offset:-self.features.shape[1]+offset], (-1, self.features.shape[1])) - self.lost_indices = np.random.randint(0, high=self.lost_offset.shape[0], size=self.nb_batches*self.batch_size) - - def __getitem__(self, index): - features = self.features[self.indices[index*self.batch_size:(index+1)*self.batch_size], :, :] - burg_lost = (np.random.rand(features.shape[0], features.shape[1]) > .1).astype('float') - burg_lost = np.reshape(burg_lost, (features.shape[0], features.shape[1], 1)) - burg_mask = np.tile(burg_lost, (1,1,self.nb_burg_features)) - - lost = self.lost_offset[self.lost_indices[index*self.batch_size:(index+1)*self.batch_size], :] - lost = np.reshape(lost, (features.shape[0], features.shape[1], 1)) - lost_mask = np.tile(lost, (1,1,features.shape[2])) - in_features = features*lost_mask - in_features[:,:,:self.nb_burg_features] = in_features[:,:,:self.nb_burg_features]*burg_mask - - #For the first frame after a loss, we don't have valid features, but the Burg estimate is valid. - #in_features[:,1:,self.nb_burg_features:] = in_features[:,1:,self.nb_burg_features:]*lost_mask[:,:-1,self.nb_burg_features:] - out_lost = np.copy(lost) - #out_lost[:,1:,:] = out_lost[:,1:,:]*out_lost[:,:-1,:] - - out_features = np.concatenate([features[:,:,self.nb_burg_features:], 1.-out_lost], axis=-1) - burg_sign = 2*burg_lost - 1 - # last dim is 1 for received packet, 0 for lost packet, and -1 when just the Burg info is missing - inputs = [in_features*lost_mask, lost*burg_sign] - outputs = [out_features] - return (inputs, outputs) - - def __len__(self): - return self.nb_batches diff --git a/dnn/training_tf2/rdovae.py b/dnn/training_tf2/rdovae.py deleted file mode 100644 index 6240120d1..000000000 --- a/dnn/training_tf2/rdovae.py +++ /dev/null @@ -1,372 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2022 Amazon - - 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 FOUNDATION 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. -''' - -import math -import tensorflow as tf -from tensorflow.keras.models import Model -from tensorflow.keras.layers import Input, GRU, Dense, Embedding, Reshape, Concatenate, Lambda, Conv1D, Multiply, Add, Bidirectional, MaxPooling1D, Activation, GaussianNoise, AveragePooling1D, RepeatVector -from tensorflow.compat.v1.keras.layers import CuDNNGRU -from tensorflow.keras import backend as K -from tensorflow.keras.constraints import Constraint -from tensorflow.keras.initializers import Initializer -from tensorflow.keras.callbacks import Callback -from tensorflow.keras.regularizers import l1 -import numpy as np -import h5py -from uniform_noise import UniformNoise - -class WeightClip(Constraint): - '''Clips the weights incident to each hidden unit to be inside a range - ''' - def __init__(self, c=2): - self.c = c - - def __call__(self, p): - # Ensure that abs of adjacent weights don't sum to more than 127. Otherwise there's a risk of - # saturation when implementing dot products with SSSE3 or AVX2. - return self.c*p/tf.maximum(self.c, tf.repeat(tf.abs(p[:, 1::2])+tf.abs(p[:, 0::2]), 2, axis=1)) - #return K.clip(p, -self.c, self.c) - - def get_config(self): - return {'name': self.__class__.__name__, - 'c': self.c} - -constraint = WeightClip(0.496) - -def soft_quantize(x): - #x = 4*x - #x = x - (.25/np.math.pi)*tf.math.sin(2*np.math.pi*x) - #x = x - (.25/np.math.pi)*tf.math.sin(2*np.math.pi*x) - #x = x - (.25/np.math.pi)*tf.math.sin(2*np.math.pi*x) - return x - -def noise_quantize(x): - return soft_quantize(x + (K.random_uniform((128, 16, 80))-.5) ) - -def hard_quantize(x): - x = soft_quantize(x) - quantized = tf.round(x) - return x + tf.stop_gradient(quantized - x) - -def apply_dead_zone(x): - d = x[1]*.05 - x = x[0] - y = x - d*tf.math.tanh(x/(.1+d)) - return y - -def rate_loss(y_true,y_pred): - log2_e = 1.4427 - n = y_pred.shape[-1] - C = n - log2_e*np.math.log(np.math.gamma(n)) - k = K.sum(K.abs(y_pred), axis=-1) - p = 1.5 - #rate = C + (n-1)*log2_e*tf.math.log((k**p + (n/5)**p)**(1/p)) - rate = C + (n-1)*log2_e*tf.math.log(k + .112*n**2/(n/1.8+k) ) - return K.mean(rate) - -eps=1e-6 -def safelog2(x): - log2_e = 1.4427 - return log2_e*tf.math.log(eps+x) - -def feat_dist_loss(y_true,y_pred): - lambda_1 = 1./K.sqrt(y_pred[:,:,:,-1]) - y_pred = y_pred[:,:,:,:-1] - ceps = y_pred[:,:,:,:18] - y_true[:,:,:18] - pitch = 2*(y_pred[:,:,:,18:19] - y_true[:,:,18:19])/(y_true[:,:,18:19] + 2) - corr = y_pred[:,:,:,19:] - y_true[:,:,19:] - pitch_weight = K.square(K.maximum(0., y_true[:,:,19:]+.5)) - return K.mean(lambda_1*K.mean(K.square(ceps) + 10*(1/18.)*K.abs(pitch)*pitch_weight + (1/18.)*K.square(corr), axis=-1)) - -def sq1_rate_loss(y_true,y_pred): - lambda_val = K.sqrt(y_pred[:,:,-1]) - y_pred = y_pred[:,:,:-1] - log2_e = 1.4427 - n = y_pred.shape[-1]//3 - r = (y_pred[:,:,2*n:]) - p0 = (y_pred[:,:,n:2*n]) - p0 = 1-r**(.5+.5*p0) - y_pred = y_pred[:,:,:n] - y_pred = soft_quantize(y_pred) - - y0 = K.maximum(0., 1. - K.abs(y_pred))**2 - rate = -y0*safelog2(p0*r**K.abs(y_pred)) - (1-y0)*safelog2(.5*(1-p0)*(1-r)*r**(K.abs(y_pred)-1)) - rate = -safelog2(-.5*tf.math.log(r)*r**K.abs(y_pred)) - rate = -safelog2((1-r)/(1+r)*r**K.abs(y_pred)) - #rate = -safelog2(- tf.math.sinh(.5*tf.math.log(r))* r**K.abs(y_pred) - tf.math.cosh(K.maximum(0., .5 - K.abs(y_pred))*tf.math.log(r)) + 1) - rate = lambda_val*K.sum(rate, axis=-1) - return K.mean(rate) - -def sq2_rate_loss(y_true,y_pred): - lambda_val = K.sqrt(y_pred[:,:,-1]) - y_pred = y_pred[:,:,:-1] - log2_e = 1.4427 - n = y_pred.shape[-1]//3 - r = y_pred[:,:,2*n:] - p0 = y_pred[:,:,n:2*n] - p0 = 1-r**(.5+.5*p0) - #theta = K.minimum(1., .5 + 0*p0 - 0.04*tf.math.log(r)) - #p0 = 1-r**theta - y_pred = tf.round(y_pred[:,:,:n]) - y0 = K.maximum(0., 1. - K.abs(y_pred))**2 - rate = -y0*safelog2(p0*r**K.abs(y_pred)) - (1-y0)*safelog2(.5*(1-p0)*(1-r)*r**(K.abs(y_pred)-1)) - rate = lambda_val*K.sum(rate, axis=-1) - return K.mean(rate) - -def sq_rate_metric(y_true,y_pred, reduce=True): - y_pred = y_pred[:,:,:-1] - log2_e = 1.4427 - n = y_pred.shape[-1]//3 - r = y_pred[:,:,2*n:] - p0 = y_pred[:,:,n:2*n] - p0 = 1-r**(.5+.5*p0) - #theta = K.minimum(1., .5 + 0*p0 - 0.04*tf.math.log(r)) - #p0 = 1-r**theta - y_pred = tf.round(y_pred[:,:,:n]) - y0 = K.maximum(0., 1. - K.abs(y_pred))**2 - rate = -y0*safelog2(p0*r**K.abs(y_pred)) - (1-y0)*safelog2(.5*(1-p0)*(1-r)*r**(K.abs(y_pred)-1)) - rate = K.sum(rate, axis=-1) - if reduce: - rate = K.mean(rate) - return rate - -def pvq_quant_search(x, k): - x = x/tf.reduce_sum(tf.abs(x), axis=-1, keepdims=True) - kx = k*x - y = tf.round(kx) - newk = k - - for j in range(10): - #print("y = ", y) - #print("iteration ", j) - abs_y = tf.abs(y) - abs_kx = tf.abs(kx) - kk=tf.reduce_sum(abs_y, axis=-1) - #print("sums = ", kk) - plus = 1.000001*tf.reduce_min((abs_y+.5)/(abs_kx+1e-15), axis=-1) - minus = .999999*tf.reduce_max((abs_y-.5)/(abs_kx+1e-15), axis=-1) - #print("plus = ", plus) - #print("minus = ", minus) - factor = tf.where(kk>k, minus, plus) - factor = tf.where(kk==k, tf.ones_like(factor), factor) - #print("scale = ", factor) - factor = tf.expand_dims(factor, axis=-1) - #newk = newk * (k/kk)**.2 - newk = newk*factor - kx = newk*x - #print("newk = ", newk) - #print("unquantized = ", newk*x) - y = tf.round(kx) - - #print(y) - #print(K.mean(K.sum(K.abs(y), axis=-1))) - return y - -def pvq_quantize(x, k): - x = x/(1e-15+tf.norm(x, axis=-1,keepdims=True)) - quantized = pvq_quant_search(x, k) - quantized = quantized/(1e-15+tf.norm(quantized, axis=-1,keepdims=True)) - return x + tf.stop_gradient(quantized - x) - - -def var_repeat(x): - return tf.repeat(tf.expand_dims(x[0], 1), K.shape(x[1])[1], axis=1) - -nb_state_dim = 24 - -def new_rdovae_encoder(nb_used_features=20, nb_bits=17, bunch=4, nb_quant=40, batch_size=128, cond_size=128, cond_size2=256, training=False): - feat = Input(shape=(None, nb_used_features), batch_size=batch_size) - - gru = CuDNNGRU if training else GRU - enc_dense1 = Dense(cond_size2, activation='tanh', kernel_constraint=constraint, name='enc_dense1') - enc_dense2 = gru(cond_size, return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, name='enc_dense2') - enc_dense3 = Dense(cond_size2, activation='tanh', kernel_constraint=constraint, name='enc_dense3') - enc_dense4 = gru(cond_size, return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, name='enc_dense4') - enc_dense5 = Dense(cond_size2, activation='tanh', kernel_constraint=constraint, name='enc_dense5') - enc_dense6 = gru(cond_size, return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, name='enc_dense6') - enc_dense7 = Dense(cond_size, activation='tanh', kernel_constraint=constraint, name='enc_dense7') - enc_dense8 = Dense(cond_size, activation='tanh', kernel_constraint=constraint, name='enc_dense8') - - #bits_dense = Dense(nb_bits, activation='linear', name='bits_dense') - bits_dense = Conv1D(nb_bits, 4, padding='causal', activation='linear', name='bits_dense') - - zero_out = Lambda(lambda x: 0*x) - inputs = Reshape((-1, 2*nb_used_features))(feat) - d1 = enc_dense1(inputs) - d2 = enc_dense2(d1) - d3 = enc_dense3(d2) - d4 = enc_dense4(d3) - d5 = enc_dense5(d4) - d6 = enc_dense6(d5) - d7 = enc_dense7(d6) - d8 = enc_dense8(d7) - pre_out = Concatenate()([d1, d2, d3, d4, d5, d6, d7, d8]) - enc_out = bits_dense(pre_out) - global_dense1 = Dense(128, activation='tanh', name='gdense1') - global_dense2 = Dense(nb_state_dim, activation='tanh', name='gdense2') - global_bits = global_dense2(global_dense1(pre_out)) - - encoder = Model([feat], [enc_out, global_bits], name='encoder') - return encoder - -def new_rdovae_decoder(nb_used_features=20, nb_bits=17, bunch=4, nb_quant=40, batch_size=128, cond_size=128, cond_size2=256, training=False): - bits_input = Input(shape=(None, nb_bits), batch_size=batch_size, name="dec_bits") - gru_state_input = Input(shape=(nb_state_dim,), batch_size=batch_size, name="dec_state") - - - gru = CuDNNGRU if training else GRU - dec_dense1 = Dense(cond_size2, activation='tanh', kernel_constraint=constraint, name='dec_dense1') - dec_dense2 = gru(cond_size, return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, name='dec_dense2') - dec_dense3 = Dense(cond_size2, activation='tanh', kernel_constraint=constraint, name='dec_dense3') - dec_dense4 = gru(cond_size, return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, name='dec_dense4') - dec_dense5 = Dense(cond_size2, activation='tanh', kernel_constraint=constraint, name='dec_dense5') - dec_dense6 = gru(cond_size, return_sequences=True, kernel_constraint=constraint, recurrent_constraint=constraint, name='dec_dense6') - dec_dense7 = Dense(cond_size, activation='tanh', kernel_constraint=constraint, name='dec_dense7') - dec_dense8 = Dense(cond_size, activation='tanh', kernel_constraint=constraint, name='dec_dense8') - - dec_final = Dense(bunch*nb_used_features, activation='linear', name='dec_final') - - time_reverse = Lambda(lambda x: K.reverse(x, 1)) - #time_reverse = Lambda(lambda x: x) - #gru_state_rep = RepeatVector(64//bunch)(gru_state_input) - - #gru_state_rep = Lambda(var_repeat, output_shape=(None, nb_state_dim)) ([gru_state_input, bits_input]) - gru_state1 = Dense(cond_size, name="state1", activation='tanh')(gru_state_input) - gru_state2 = Dense(cond_size, name="state2", activation='tanh')(gru_state_input) - gru_state3 = Dense(cond_size, name="state3", activation='tanh')(gru_state_input) - - dec1 = dec_dense1(time_reverse(bits_input)) - dec2 = dec_dense2(dec1, initial_state=gru_state1) - dec3 = dec_dense3(dec2) - dec4 = dec_dense4(dec3, initial_state=gru_state2) - dec5 = dec_dense5(dec4) - dec6 = dec_dense6(dec5, initial_state=gru_state3) - dec7 = dec_dense7(dec6) - dec8 = dec_dense8(dec7) - output = Reshape((-1, nb_used_features))(dec_final(Concatenate()([dec1, dec2, dec3, dec4, dec5, dec6, dec7, dec8]))) - decoder = Model([bits_input, gru_state_input], time_reverse(output), name='decoder') - decoder.nb_bits = nb_bits - decoder.bunch = bunch - return decoder - -def new_split_decoder(decoder): - nb_bits = decoder.nb_bits - bunch = decoder.bunch - bits_input = Input(shape=(None, nb_bits), name="split_bits") - gru_state_input = Input(shape=(None,nb_state_dim), name="split_state") - - range_select = Lambda(lambda x: x[0][:,x[1]:x[2],:]) - elem_select = Lambda(lambda x: x[0][:,x[1],:]) - points = [0, 100, 200, 300, 400] - outputs = [] - for i in range(len(points)-1): - begin = points[i]//bunch - end = points[i+1]//bunch - state = elem_select([gru_state_input, end-1]) - bits = range_select([bits_input, begin, end]) - outputs.append(decoder([bits, state])) - output = Concatenate(axis=1)(outputs) - split = Model([bits_input, gru_state_input], output, name="split") - return split - -def tensor_concat(x): - #n = x[1]//2 - #x = x[0] - n=2 - y = [] - for i in range(n-1): - offset = 2 * (n-1-i) - tmp = K.concatenate([x[i][:, offset:, :], x[-1][:, -offset:, :]], axis=-2) - y.append(tf.expand_dims(tmp, axis=0)) - y.append(tf.expand_dims(x[-1], axis=0)) - return Concatenate(axis=0)(y) - - -def new_rdovae_model(nb_used_features=20, nb_bits=17, bunch=4, nb_quant=40, batch_size=128, cond_size=128, cond_size2=256, training=False): - - feat = Input(shape=(None, nb_used_features), batch_size=batch_size) - quant_id = Input(shape=(None,), batch_size=batch_size) - lambda_val = Input(shape=(None, 1), batch_size=batch_size) - lambda_bunched = AveragePooling1D(pool_size=bunch//2, strides=bunch//2, padding="valid")(lambda_val) - lambda_up = Lambda(lambda x: K.repeat_elements(x, 2, axis=-2))(lambda_val) - - qembedding = Embedding(nb_quant, 6*nb_bits, name='quant_embed', embeddings_initializer='zeros') - quant_embed_dec = qembedding(quant_id) - quant_scale = Activation('softplus')(Lambda(lambda x: x[:,:,:nb_bits], name='quant_scale_embed')(quant_embed_dec)) - - encoder = new_rdovae_encoder(nb_used_features, nb_bits, bunch, nb_quant, batch_size, cond_size, cond_size2, training=training) - ze, gru_state_dec = encoder([feat]) - ze = Multiply()([ze, quant_scale]) - - decoder = new_rdovae_decoder(nb_used_features, nb_bits, bunch, nb_quant, batch_size, cond_size, cond_size2, training=training) - split_decoder = new_split_decoder(decoder) - - dead_zone = Activation('softplus')(Lambda(lambda x: x[:,:,nb_bits:2*nb_bits], name='dead_zone_embed')(quant_embed_dec)) - soft_distr_embed = Activation('sigmoid')(Lambda(lambda x: x[:,:,2*nb_bits:4*nb_bits], name='soft_distr_embed')(quant_embed_dec)) - hard_distr_embed = Activation('sigmoid')(Lambda(lambda x: x[:,:,4*nb_bits:], name='hard_distr_embed')(quant_embed_dec)) - - noisequant = UniformNoise() - hardquant = Lambda(hard_quantize) - dzone = Lambda(apply_dead_zone) - dze = dzone([ze,dead_zone]) - ndze = noisequant(dze) - dze_quant = hardquant(dze) - - div = Lambda(lambda x: x[0]/x[1]) - dze_quant = div([dze_quant,quant_scale]) - ndze_unquant = div([ndze,quant_scale]) - - mod_select = Lambda(lambda x: x[0][:,x[1]::bunch//2,:]) - gru_state_dec = Lambda(lambda x: pvq_quantize(x, 82))(gru_state_dec) - combined_output = [] - unquantized_output = [] - cat = Concatenate(name="out_cat") - for i in range(bunch//2): - dze_select = mod_select([dze_quant, i]) - ndze_select = mod_select([ndze_unquant, i]) - state_select = mod_select([gru_state_dec, i]) - - tmp = split_decoder([dze_select, state_select]) - tmp = cat([tmp, lambda_up]) - combined_output.append(tmp) - - tmp = split_decoder([ndze_select, state_select]) - tmp = cat([tmp, lambda_up]) - unquantized_output.append(tmp) - - concat = Lambda(tensor_concat, name="output") - combined_output = concat(combined_output) - unquantized_output = concat(unquantized_output) - - e2 = Concatenate(name="hard_bits")([dze, hard_distr_embed, lambda_val]) - e = Concatenate(name="soft_bits")([dze, soft_distr_embed, lambda_val]) - - - model = Model([feat, quant_id, lambda_val], [combined_output, unquantized_output, e, e2], name="end2end") - model.nb_used_features = nb_used_features - - return model, encoder, decoder, qembedding diff --git a/dnn/training_tf2/rdovae_exchange.py b/dnn/training_tf2/rdovae_exchange.py deleted file mode 100644 index 3249677d4..000000000 --- a/dnn/training_tf2/rdovae_exchange.py +++ /dev/null @@ -1,138 +0,0 @@ -""" -/* Copyright (c) 2022 Amazon - Written by Jan Buethe */ -/* - 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. -*/ -""" - - -import argparse -import os -import sys - -os.environ['CUDA_VISIBLE_DEVICES'] = "" - -parser = argparse.ArgumentParser() - -parser.add_argument('weights', metavar="", type=str, help='model weight file in hdf5 format') -parser.add_argument('output', metavar="", type=str, help='output exchange folder') -parser.add_argument('--cond-size', type=int, help="conditioning size (default: 256)", default=256) -parser.add_argument('--latent-dim', type=int, help="dimension of latent space (default: 80)", default=80) -parser.add_argument('--quant-levels', type=int, help="number of quantization steps (default: 16)", default=16) - -args = parser.parse_args() - -# now import the heavy stuff -from rdovae import new_rdovae_model -from wexchange.tf import dump_tf_weights, load_tf_weights - - -exchange_name = { - 'enc_dense1' : 'encoder_stack_layer1_dense', - 'enc_dense3' : 'encoder_stack_layer3_dense', - 'enc_dense5' : 'encoder_stack_layer5_dense', - 'enc_dense7' : 'encoder_stack_layer7_dense', - 'enc_dense8' : 'encoder_stack_layer8_dense', - 'gdense1' : 'encoder_state_layer1_dense', - 'gdense2' : 'encoder_state_layer2_dense', - 'enc_dense2' : 'encoder_stack_layer2_gru', - 'enc_dense4' : 'encoder_stack_layer4_gru', - 'enc_dense6' : 'encoder_stack_layer6_gru', - 'bits_dense' : 'encoder_stack_layer9_conv', - 'qembedding' : 'statistical_model_embedding', - 'state1' : 'decoder_state1_dense', - 'state2' : 'decoder_state2_dense', - 'state3' : 'decoder_state3_dense', - 'dec_dense1' : 'decoder_stack_layer1_dense', - 'dec_dense3' : 'decoder_stack_layer3_dense', - 'dec_dense5' : 'decoder_stack_layer5_dense', - 'dec_dense7' : 'decoder_stack_layer7_dense', - 'dec_dense8' : 'decoder_stack_layer8_dense', - 'dec_final' : 'decoder_stack_layer9_dense', - 'dec_dense2' : 'decoder_stack_layer2_gru', - 'dec_dense4' : 'decoder_stack_layer4_gru', - 'dec_dense6' : 'decoder_stack_layer6_gru' -} - - -if __name__ == "__main__": - - model, encoder, decoder, qembedding = new_rdovae_model(20, args.latent_dim, cond_size=args.cond_size, nb_quant=args.quant_levels) - model.load_weights(args.weights) - - os.makedirs(args.output, exist_ok=True) - - # encoder - encoder_dense_names = [ - 'enc_dense1', - 'enc_dense3', - 'enc_dense5', - 'enc_dense7', - 'enc_dense8', - 'gdense1', - 'gdense2' - ] - - encoder_gru_names = [ - 'enc_dense2', - 'enc_dense4', - 'enc_dense6' - ] - - encoder_conv1d_names = [ - 'bits_dense' - ] - - - for name in encoder_dense_names + encoder_gru_names + encoder_conv1d_names: - print(f"writing layer {exchange_name[name]}...") - dump_tf_weights(os.path.join(args.output, exchange_name[name]), encoder.get_layer(name)) - - # qembedding - print(f"writing layer {exchange_name['qembedding']}...") - dump_tf_weights(os.path.join(args.output, exchange_name['qembedding']), qembedding) - - # decoder - decoder_dense_names = [ - 'state1', - 'state2', - 'state3', - 'dec_dense1', - 'dec_dense3', - 'dec_dense5', - 'dec_dense7', - 'dec_dense8', - 'dec_final' - ] - - decoder_gru_names = [ - 'dec_dense2', - 'dec_dense4', - 'dec_dense6' - ] - - for name in decoder_dense_names + decoder_gru_names: - print(f"writing layer {exchange_name[name]}...") - dump_tf_weights(os.path.join(args.output, exchange_name[name]), decoder.get_layer(name)) diff --git a/dnn/training_tf2/rdovae_import.py b/dnn/training_tf2/rdovae_import.py deleted file mode 100644 index bc8b460d0..000000000 --- a/dnn/training_tf2/rdovae_import.py +++ /dev/null @@ -1,123 +0,0 @@ -""" -/* Copyright (c) 2022 Amazon - Written by Jan Buethe */ -/* - 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. -*/ -""" - - -import argparse -import os -import sys - -os.environ['CUDA_VISIBLE_DEVICES'] = "" - -parser = argparse.ArgumentParser() - -parser.add_argument('input', metavar="", type=str, help='input exchange folder') -parser.add_argument('weights', metavar="", type=str, help='model weight file in hdf5 format') -parser.add_argument('--cond-size', type=int, help="conditioning size (default: 256)", default=256) -parser.add_argument('--latent-dim', type=int, help="dimension of latent space (default: 80)", default=80) -parser.add_argument('--quant-levels', type=int, help="number of quantization steps (default: 16)", default=16) - -args = parser.parse_args() - -# now import the heavy stuff -from rdovae import new_rdovae_model -from wexchange.tf import load_tf_weights - - -exchange_name = { - 'enc_dense1' : 'encoder_stack_layer1_dense', - 'enc_dense3' : 'encoder_stack_layer3_dense', - 'enc_dense5' : 'encoder_stack_layer5_dense', - 'enc_dense7' : 'encoder_stack_layer7_dense', - 'enc_dense8' : 'encoder_stack_layer8_dense', - 'gdense1' : 'encoder_state_layer1_dense', - 'gdense2' : 'encoder_state_layer2_dense', - 'enc_dense2' : 'encoder_stack_layer2_gru', - 'enc_dense4' : 'encoder_stack_layer4_gru', - 'enc_dense6' : 'encoder_stack_layer6_gru', - 'bits_dense' : 'encoder_stack_layer9_conv', - 'qembedding' : 'statistical_model_embedding', - 'state1' : 'decoder_state1_dense', - 'state2' : 'decoder_state2_dense', - 'state3' : 'decoder_state3_dense', - 'dec_dense1' : 'decoder_stack_layer1_dense', - 'dec_dense3' : 'decoder_stack_layer3_dense', - 'dec_dense5' : 'decoder_stack_layer5_dense', - 'dec_dense7' : 'decoder_stack_layer7_dense', - 'dec_dense8' : 'decoder_stack_layer8_dense', - 'dec_final' : 'decoder_stack_layer9_dense', - 'dec_dense2' : 'decoder_stack_layer2_gru', - 'dec_dense4' : 'decoder_stack_layer4_gru', - 'dec_dense6' : 'decoder_stack_layer6_gru' -} - -if __name__ == "__main__": - - model, encoder, decoder, qembedding = new_rdovae_model(20, args.latent_dim, cond_size=args.cond_size, nb_quant=args.quant_levels) - - encoder_layers = [ - 'enc_dense1', - 'enc_dense3', - 'enc_dense5', - 'enc_dense7', - 'enc_dense8', - 'gdense1', - 'gdense2', - 'enc_dense2', - 'enc_dense4', - 'enc_dense6', - 'bits_dense' - ] - - decoder_layers = [ - 'state1', - 'state2', - 'state3', - 'dec_dense1', - 'dec_dense3', - 'dec_dense5', - 'dec_dense7', - 'dec_dense8', - 'dec_final', - 'dec_dense2', - 'dec_dense4', - 'dec_dense6' - ] - - for name in encoder_layers: - print(f"loading weight for layer {name}...") - load_tf_weights(os.path.join(args.input, exchange_name[name]), encoder.get_layer(name)) - - print(f"loading weight for layer qembedding...") - load_tf_weights(os.path.join(args.input, exchange_name['qembedding']), qembedding) - - for name in decoder_layers: - print(f"loading weight for layer {name}...") - load_tf_weights(os.path.join(args.input, exchange_name[name]), decoder.get_layer(name)) - - model.save(args.weights) diff --git a/dnn/training_tf2/test_lpcnet.py b/dnn/training_tf2/test_lpcnet.py deleted file mode 100755 index ca551e63c..000000000 --- a/dnn/training_tf2/test_lpcnet.py +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2018 Mozilla - - 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 FOUNDATION 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. -''' -import argparse -import sys - -import h5py -import numpy as np - -import lpcnet -from ulaw import ulaw2lin, lin2ulaw - - -parser = argparse.ArgumentParser() -parser.add_argument('model-file', type=str, help='model weight h5 file') -parser.add_argument('--lpc-gamma', type=float, help='LPC weighting factor. WARNING: giving an inconsistent value here will severely degrade performance', default=1) - -args = parser.parse_args() - -filename = args.model_file -with h5py.File(filename, "r") as f: - units = min(f['model_weights']['gru_a']['gru_a']['recurrent_kernel:0'].shape) - units2 = min(f['model_weights']['gru_b']['gru_b']['recurrent_kernel:0'].shape) - cond_size = min(f['model_weights']['feature_dense1']['feature_dense1']['kernel:0'].shape) - e2e = 'rc2lpc' in f['model_weights'] - - -model, enc, dec = lpcnet.new_lpcnet_model(training = False, rnn_units1=units, rnn_units2=units2, flag_e2e = e2e, cond_size=cond_size, batch_size=1) - -model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['sparse_categorical_accuracy']) -#model.summary() - - -feature_file = sys.argv[2] -out_file = sys.argv[3] -frame_size = model.frame_size -nb_features = 36 -nb_used_features = model.nb_used_features - -features = np.fromfile(feature_file, dtype='float32') -features = np.resize(features, (-1, nb_features)) -nb_frames = 1 -feature_chunk_size = features.shape[0] -pcm_chunk_size = frame_size*feature_chunk_size - -features = np.reshape(features, (nb_frames, feature_chunk_size, nb_features)) -periods = (.1 + 50*features[:,:,18:19]+100).astype('int16') - - - -model.load_weights(filename); - -order = 16 - -pcm = np.zeros((nb_frames*pcm_chunk_size, )) -fexc = np.zeros((1, 1, 3), dtype='int16')+128 -state1 = np.zeros((1, model.rnn_units1), dtype='float32') -state2 = np.zeros((1, model.rnn_units2), dtype='float32') - -mem = 0 -coef = 0.85 - -lpc_weights = np.array([args.lpc_gamma ** (i + 1) for i in range(16)]) - -fout = open(out_file, 'wb') - -skip = order + 1 -for c in range(0, nb_frames): - if not e2e: - cfeat = enc.predict([features[c:c+1, :, :nb_used_features], periods[c:c+1, :, :]]) - else: - cfeat,lpcs = enc.predict([features[c:c+1, :, :nb_used_features], periods[c:c+1, :, :]]) - for fr in range(0, feature_chunk_size): - f = c*feature_chunk_size + fr - if not e2e: - a = features[c, fr, nb_features-order:] * lpc_weights - else: - a = lpcs[c,fr] - for i in range(skip, frame_size): - pred = -sum(a*pcm[f*frame_size + i - 1:f*frame_size + i - order-1:-1]) - fexc[0, 0, 1] = lin2ulaw(pred) - - p, state1, state2 = dec.predict([fexc, cfeat[:, fr:fr+1, :], state1, state2]) - #Lower the temperature for voiced frames to reduce noisiness - p *= np.power(p, np.maximum(0, 1.5*features[c, fr, 19] - .5)) - p = p/(1e-18 + np.sum(p)) - #Cut off the tail of the remaining distribution - p = np.maximum(p-0.002, 0).astype('float64') - p = p/(1e-8 + np.sum(p)) - - fexc[0, 0, 2] = np.argmax(np.random.multinomial(1, p[0,0,:], 1)) - pcm[f*frame_size + i] = pred + ulaw2lin(fexc[0, 0, 2]) - fexc[0, 0, 0] = lin2ulaw(pcm[f*frame_size + i]) - mem = coef*mem + pcm[f*frame_size + i] - #print(mem) - np.array([np.round(mem)], dtype='int16').tofile(fout) - skip = 0 diff --git a/dnn/training_tf2/test_plc.py b/dnn/training_tf2/test_plc.py deleted file mode 100644 index 0c0ac25fa..000000000 --- a/dnn/training_tf2/test_plc.py +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2021-2022 Amazon - Copyright (c) 2018-2019 Mozilla - - 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 FOUNDATION 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. -''' - -# Train an LPCNet model - -import argparse -from plc_loader import PLCLoader - -parser = argparse.ArgumentParser(description='Test a PLC model') - -parser.add_argument('weights', metavar='', help='weights file (.h5)') -parser.add_argument('features', metavar='', help='binary features file (float32)') -parser.add_argument('output', metavar='', help='reconstructed file (float32)') -parser.add_argument('--model', metavar='', default='lpcnet_plc', help='PLC model python definition (without .py)') -group1 = parser.add_mutually_exclusive_group() - -parser.add_argument('--gru-size', metavar='', default=256, type=int, help='number of units in GRU (default 256)') -parser.add_argument('--cond-size', metavar='', default=128, type=int, help='number of units in conditioning network (default 128)') - - -args = parser.parse_args() - -import importlib -lpcnet = importlib.import_module(args.model) - -import sys -import numpy as np -from tensorflow.keras.optimizers import Adam -from tensorflow.keras.callbacks import ModelCheckpoint, CSVLogger -import tensorflow.keras.backend as K -import h5py - -import tensorflow as tf -#gpus = tf.config.experimental.list_physical_devices('GPU') -#if gpus: -# try: -# tf.config.experimental.set_virtual_device_configuration(gpus[0], [tf.config.experimental.VirtualDeviceConfiguration(memory_limit=5120)]) -# except RuntimeError as e: -# print(e) - -model = lpcnet.new_lpcnet_plc_model(rnn_units=args.gru_size, batch_size=1, training=False, quantize=False, cond_size=args.cond_size) -model.compile() - -lpc_order = 16 - -feature_file = args.features -nb_features = model.nb_used_features + lpc_order -nb_used_features = model.nb_used_features - -# u for unquantised, load 16 bit PCM samples and convert to mu-law - -features = np.loadtxt(feature_file) -print(features.shape) -sequence_size = features.shape[0] -lost = np.reshape(features[:,-1:], (1, sequence_size, 1)) -features = features[:,:nb_used_features] -features = np.reshape(features, (1, sequence_size, nb_used_features)) - - -model.load_weights(args.weights) - -features = features*lost -out = model.predict([features, lost]) - -out = features + (1-lost)*out - -np.savetxt(args.output, out[0,:,:]) diff --git a/dnn/training_tf2/tf_funcs.py b/dnn/training_tf2/tf_funcs.py deleted file mode 100644 index b86f075cf..000000000 --- a/dnn/training_tf2/tf_funcs.py +++ /dev/null @@ -1,70 +0,0 @@ -""" -Tensorflow/Keras helper functions to do the following: - 1. \mu law <-> Linear domain conversion - 2. Differentiable prediction from the input signal and LP coefficients - 3. Differentiable transformations Reflection Coefficients (RCs) <-> LP Coefficients -""" -from tensorflow.keras.layers import Lambda, Multiply, Layer, Concatenate -from tensorflow.keras import backend as K -import tensorflow as tf - -# \mu law <-> Linear conversion functions -scale = 255.0/32768.0 -scale_1 = 32768.0/255.0 -def tf_l2u(x): - s = K.sign(x) - x = K.abs(x) - u = (s*(128*K.log(1+scale*x)/K.log(256.0))) - u = K.clip(128 + u, 0, 255) - return u - -def tf_u2l(u): - u = tf.cast(u,"float32") - u = u - 128.0 - s = K.sign(u) - u = K.abs(u) - return s*scale_1*(K.exp(u/128.*K.log(256.0))-1) - -# Differentiable Prediction Layer -# Computes the LP prediction from the input lag signal and the LP coefficients -# The inputs xt and lpc conform with the shapes in lpcnet.py (the '2400' is coded keeping this in mind) -class diff_pred(Layer): - def call(self, inputs, lpcoeffs_N = 16, frame_size = 160): - xt = inputs[0] - lpc = inputs[1] - - rept = Lambda(lambda x: K.repeat_elements(x , frame_size, 1)) - zpX = Lambda(lambda x: K.concatenate([0*x[:,0:lpcoeffs_N,:], x],axis = 1)) - cX = Lambda(lambda x: K.concatenate([x[:,(lpcoeffs_N - i):(lpcoeffs_N - i + 2400),:] for i in range(lpcoeffs_N)],axis = 2)) - - pred = -Multiply()([rept(lpc),cX(zpX(xt))]) - - return K.sum(pred,axis = 2,keepdims = True) - -# Differentiable Transformations (RC <-> LPC) computed using the Levinson Durbin Recursion -class diff_rc2lpc(Layer): - def call(self, inputs, lpcoeffs_N = 16): - def pred_lpc_recursive(input): - temp = (input[0] + K.repeat_elements(input[1],input[0].shape[2],2)*K.reverse(input[0],axes = 2)) - temp = Concatenate(axis = 2)([temp,input[1]]) - return temp - Llpc = Lambda(pred_lpc_recursive) - inputs = inputs[:,:,:lpcoeffs_N] - lpc_init = inputs - for i in range(1,lpcoeffs_N): - lpc_init = Llpc([lpc_init[:,:,:i],K.expand_dims(inputs[:,:,i],axis = -1)]) - return lpc_init - -class diff_lpc2rc(Layer): - def call(self, inputs, lpcoeffs_N = 16): - def pred_rc_recursive(input): - ki = K.repeat_elements(K.expand_dims(input[1][:,:,0],axis = -1),input[0].shape[2],2) - temp = (input[0] - ki*K.reverse(input[0],axes = 2))/(1 - ki*ki) - temp = Concatenate(axis = 2)([temp,input[1]]) - return temp - Lrc = Lambda(pred_rc_recursive) - rc_init = inputs - for i in range(1,lpcoeffs_N): - j = (lpcoeffs_N - i + 1) - rc_init = Lrc([rc_init[:,:,:(j - 1)],rc_init[:,:,(j - 1):]]) - return rc_init diff --git a/dnn/training_tf2/train_lpcnet.py b/dnn/training_tf2/train_lpcnet.py deleted file mode 100755 index 60e2b56f5..000000000 --- a/dnn/training_tf2/train_lpcnet.py +++ /dev/null @@ -1,214 +0,0 @@ -#!/usr/bin/python3 -'''Copyright (c) 2018 Mozilla - - 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 FOUNDATION 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. -''' - -# Train an LPCNet model - -import argparse -import os - -from dataloader import LPCNetLoader - -parser = argparse.ArgumentParser(description='Train an LPCNet model') - -parser.add_argument('features', metavar='', help='binary features file (float32)') -parser.add_argument('data', metavar='